Switch to ready-state when the data center is already registered

This commit is contained in:
mjentsch 2014-08-23 02:41:26 +02:00
parent a4e5449d5a
commit d062ec44d0
2 changed files with 10 additions and 6 deletions

6
loop.c
View file

@ -567,12 +567,6 @@ int network_phone_is_registered() {
}
*/
/**
* Return whether the current client is registered.
*/
int network_client_is_registered(struct telegram *tg) {
return !(tg->auth.auth_state == 100 || !(telegram_get_working_dc(tg)->has_auth));
}
/**
* Verify the phone number by providing the sms_code and the real name

View file

@ -74,6 +74,10 @@ void telegram_change_state (struct telegram *instance, int state, void *data)
case STATE_AUTHORIZED:
logprintf("requesting configuration\n");
telegram_change_state(instance, STATE_CONFIG_REQUESTED, NULL);
if (telegram_is_registered(instance)) {
telegram_change_state (instance, STATE_READY, NULL);
return;
}
do_help_get_config (instance);
break;
@ -102,6 +106,12 @@ void telegram_change_state (struct telegram *instance, int state, void *data)
logprintf("client authentication, user needs to enter code");
// wait for user input ...
break;
case STATE_READY:
logprintf("telegram is registered and ready.\n");
telegram_store_session (instance);
instance->config->on_ready (instance);
break;
case STATE_DISCONNECTED_SWITCH_DC: {
// telegram demands that we use a different data center, which caused