diff --git a/purple-plugin/telegram-purple.c b/purple-plugin/telegram-purple.c index 59c9a83..abf13f8 100644 --- a/purple-plugin/telegram-purple.c +++ b/purple-plugin/telegram-purple.c @@ -371,7 +371,8 @@ static void tgprpl_login(PurpleAccount * acct) tg->extra = conn; purple_connection_set_state (conn->gc, PURPLE_CONNECTING); - telegram_network_connect (tg); + telegram_connect (tg); +} /** * This must be implemented. diff --git a/telegram.c b/telegram.c index 56cb768..60c22e3 100755 --- a/telegram.c +++ b/telegram.c @@ -161,9 +161,8 @@ void telegram_change_state (struct telegram *instance, int state, void *data) instance->config->proxy_close_cb (instance, instance->connection->connection->fd); // start a new connection to the demanded data center. The pointer to the - // currently working dc should have already been updated by the - // on_error function of the query - telegram_network_connect (instance); + // new dc should was already updated by the on_error function of the query + telegram_connect (instance); } break; } @@ -308,7 +307,7 @@ void on_authorized(struct mtproto_connection *c, void* data); /** * Connect to the currently active data center */ -void telegram_network_connect(struct telegram *instance) +void telegram_connect (struct telegram *instance) { logprintf ("telegram_network_connect()\n"); if (! instance->auth.DC_list) { @@ -364,8 +363,9 @@ int telegram_write_output (struct telegram *instance) return try_write(instance->connection->connection); } -int telegram_has_output (struct telegram *instance) +int telegram_authenticated (struct telegram *instance) { - return instance->connection->queries_num > 0; + return telegram_get_working_dc (instance)->auth_key_id > 0; } + diff --git a/telegram.h b/telegram.h index c13590e..7eb3c89 100644 --- a/telegram.h +++ b/telegram.h @@ -290,7 +290,7 @@ void telegram_change_state(struct telegram *instance, int state, void *data); /** * Connect to the telegram network with the given configuration */ -void telegram_network_connect(struct telegram *instance); +void telegram_connect(struct telegram *instance); int telegram_login (struct telegram *instance); @@ -397,4 +397,9 @@ void set_net_write_cb(ssize_t (*cb)(int fd, const void *buff, size_t size)); */ void telegram_set_proxy(struct telegram *instance, int fd); +/** + * Return wether telegram is authenticated with the currently active data center + */ +int telegram_authenticated (struct telegram *instance); + #endif