Fix leaving and removing chats again

This commit is contained in:
mjentsch 2015-10-31 20:11:31 +01:00
parent 81b64d7542
commit e3892cab16
3 changed files with 18 additions and 10 deletions

View file

@ -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);
}
}
}

View file

@ -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) {

View file

@ -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