diff --git a/telegram-base.c b/telegram-base.c index 1b1d4d2..fb86bfc 100644 --- a/telegram-base.c +++ b/telegram-base.c @@ -518,7 +518,9 @@ static int all_authorized (struct tgl_state *TLS) { static int check_all_authorized (gpointer arg) { struct tgl_state *TLS = arg; + if (all_authorized (TLS)) { + ((connection_data *)TLS->ev_base)->login_timer = 0; telegram_send_sms (TLS); return FALSE; } else { @@ -526,7 +528,9 @@ static int check_all_authorized (gpointer arg) { } } -void telegram_login (struct tgl_state *TLS) { +void telegram_login (struct tgl_state *TLS) { + connection_data *conn = TLS->ev_base; + read_auth_file (TLS); read_state_file (TLS); read_secret_chat_file (TLS); @@ -534,7 +538,7 @@ void telegram_login (struct tgl_state *TLS) { telegram_send_sms (TLS); return; } - purple_timeout_add (100, check_all_authorized, TLS); + conn->login_timer = purple_timeout_add (100, check_all_authorized, TLS); } PurpleConversation *chat_show (PurpleConnection *gc, int id) { diff --git a/tgp-structs.c b/tgp-structs.c index 24f8718..6d348eb 100644 --- a/tgp-structs.c +++ b/tgp-structs.c @@ -111,7 +111,8 @@ connection_data *connection_data_init (struct tgl_state *TLS, PurpleConnection * void *connection_data_free (connection_data *conn) { - purple_timeout_remove(conn->timer); + purple_timeout_remove (conn->timer); + if (conn->login_timer) { purple_timeout_remove(conn->login_timer); } tgp_g_queue_free_full (conn->pending_reads, pending_reads_free_cb); tgp_g_queue_free_full (conn->new_messages, message_text_free); g_hash_table_destroy (conn->joining_chats); diff --git a/tgp-structs.h b/tgp-structs.h index 5dde5f1..f0f2aed 100755 --- a/tgp-structs.h +++ b/tgp-structs.h @@ -37,6 +37,7 @@ typedef struct { GList *used_images; GHashTable *joining_chats; guint timer; + guint login_timer; int in_fallback_chat; } connection_data;