diff --git a/telegram-adium/TelegramAccount.m b/telegram-adium/TelegramAccount.m index 462f073..eb718b8 100644 --- a/telegram-adium/TelegramAccount.m +++ b/telegram-adium/TelegramAccount.m @@ -161,9 +161,10 @@ connection_data *conn = purple_connection_get_protocol_data (purple_account_get_connection(account)); AIChat *chat = adium.interfaceController.activeChat; if (chat) { - PurpleChat *purpleChat = purple_blist_find_chat (conn->pa, [chat.name UTF8String]); - if (purpleChat) { - leave_and_delete_chat ((PurpleBlistNode *)purpleChat, NULL); + const char *name = [chat.name UTF8String]; + tgl_peer_t *P = tgl_peer_get_by_name (conn->TLS, name); + if (P) { + leave_and_delete_chat (conn->TLS, P); } } } diff --git a/telegram-purple.c b/telegram-purple.c index 2c36508..0e3e983 100644 --- a/telegram-purple.c +++ b/telegram-purple.c @@ -507,21 +507,28 @@ void export_chat_link_checked (struct tgl_state *TLS, const char *name) { if (C->chat.admin_id != tgl_get_peer_id (TLS->our_id)) { purple_notify_error (_telegram_protocol, _("Creating chat link failed"), _("Creating chat link failed"), - _("You need to be admin of the group to do that.")); + _("You need to be admin of the group to do that.")); return; } tgl_do_export_chat_link (TLS, C->id, create_chat_link_done, C); } -void leave_and_delete_chat (PurpleBlistNode *node, gpointer data) { +void leave_and_delete_chat_gw (PurpleBlistNode *node, gpointer data) { PurpleChat *PC = (PurpleChat*)node; - tgl_peer_t *P = tgl_peer_get (pbn_get_conn (node)->TLS, p2tgl_chat_get_id (PC)); + leave_and_delete_chat (pbn_get_conn (node)->TLS, P); +} + +void leave_and_delete_chat (struct tgl_state *TLS, tgl_peer_t *P) { + g_return_if_fail (P); if (P && P->chat.users_num) { - tgl_do_del_user_from_chat (pbn_get_conn (node)->TLS, P->id, pbn_get_conn (node)->TLS->our_id, tgp_notify_on_error_gw, NULL); - serv_got_chat_left (pbn_get_conn (node)->gc, tgl_get_peer_id (P->id)); + tgl_do_del_user_from_chat (TLS, P->id, TLS->our_id, tgp_notify_on_error_gw, NULL); + } + serv_got_chat_left (tg_get_conn (TLS), tgl_get_peer_id (P->id)); + PurpleChat *PC = tgp_blist_chat_find (TLS, P->id); + if (PC) { + purple_blist_remove_chat (PC); } - purple_blist_remove_chat (PC); } static void import_chat_link_done (struct tgl_state *TLS, void *extra, int success) { diff --git a/telegram-purple.h b/telegram-purple.h index 72de85e..5577656 100644 --- a/telegram-purple.h +++ b/telegram-purple.h @@ -86,6 +86,6 @@ extern const char *config_dir; extern PurplePlugin *_telegram_protocol; void export_chat_link_checked (struct tgl_state *TLS, const char *name); void import_chat_link_checked (struct tgl_state *TLS, const char *link); -void leave_and_delete_chat (PurpleBlistNode *node, gpointer data); +void leave_and_delete_chat (struct tgl_state *TLS, tgl_peer_t *P); #endif