From dbc48cc0ec4df774c257d5175d62bce16e2437e3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 9 Dec 2023 20:00:47 +0300 Subject: PROTO_INTERFACE::OnContactDeleted to be able to block the contact's deletion --- protocols/Gadu-Gadu/src/core.cpp | 15 ++++++--------- protocols/Gadu-Gadu/src/gg_proto.h | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'protocols/Gadu-Gadu/src') diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 67c00622d1..93432deea9 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -1197,35 +1197,32 @@ void GaduProto::broadcastnewstatus(int newStatus) //////////////////////////////////////////////////////////// // When contact is deleted -void GaduProto::OnContactDeleted(MCONTACT hContact) +bool GaduProto::OnContactDeleted(MCONTACT hContact) { uin_t uin = (uin_t)getDword(hContact, GG_KEY_UIN); // Terminate conference if contact is deleted - if (isChatRoom(hContact) && uin && gc_enabled) - { + if (isChatRoom(hContact) && uin && gc_enabled) { CMStringW wszRoomId(FORMAT, L"%d", uin); GGGC *chat = gc_lookup(wszRoomId); debugLogA("contactdeleted(): Terminating chat %x, id %s from contact list...", chat, wszRoomId.c_str()); - if (chat) - { + if (chat) { // Destroy chat entry free(chat->recipients); list_remove(&chats, chat, 1); + // Terminate chat window / shouldn't cascade entry is deleted Chat_Control(chat->si, SESSION_OFFLINE); Chat_Terminate(chat->si); chat->si = nullptr; } - return; } - - if (uin && isonline()) - { + else if (uin && isonline()) { gg_EnterCriticalSection(&sess_mutex, "contactdeleted", 25, "sess_mutex", 1); gg_remove_notify_ex(m_sess, uin, GG_USER_NORMAL); gg_LeaveCriticalSection(&sess_mutex, "contactdeleted", 25, 1, "sess_mutex", 1); } + return true; } //////////////////////////////////////////////////////////// diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h index 5e840893d0..75da3bc4f1 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.h +++ b/protocols/Gadu-Gadu/src/gg_proto.h @@ -57,7 +57,7 @@ struct GaduProto : public PROTO int UserIsTyping(MCONTACT hContact, int type) override; void OnBuildProtoMenu(void) override; - void OnContactDeleted(MCONTACT) override; + bool OnContactDeleted(MCONTACT) override; MWindow OnCreateAccMgrUI(MWindow) override; void OnModulesLoaded() override; void OnShutdown() override; -- cgit v1.2.3