From 9885bf54f788e831a80c76001340aa68d31d2aaa Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 25 Jan 2023 18:34:51 +0300 Subject: Group chats: ChatRoomID setting replaced with real protocol id --- protocols/Gadu-Gadu/src/core.cpp | 20 ++++++++++---------- protocols/Gadu-Gadu/src/gg.cpp | 2 +- protocols/Gadu-Gadu/src/groupchat.cpp | 13 ++----------- 3 files changed, 13 insertions(+), 22 deletions(-) (limited to 'protocols/Gadu-Gadu/src') diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index f1daddfbd4..6a0698e1cf 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -1210,14 +1210,14 @@ void GaduProto::broadcastnewstatus(int newStatus) void GaduProto::OnContactDeleted(MCONTACT hContact) { - uin_t uin = (uin_t)getDword(hContact, GG_KEY_UIN, 0); + uin_t uin = (uin_t)getDword(hContact, GG_KEY_UIN); // Terminate conference if contact is deleted - ptrW wszRoomId(getWStringA(hContact, "ChatRoomID")); - if (isChatRoom(hContact) && wszRoomId != NULL && 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.get()); + debugLogA("contactdeleted(): Terminating chat %x, id %s from contact list...", chat, wszRoomId.c_str()); if (chat) { // Destroy chat entry @@ -1279,20 +1279,20 @@ int GaduProto::dbsettingchanged(WPARAM hContact, LPARAM lParam) return 0; // Groupchat window contact is being renamed - DBVARIANT dbv; - if (isChatRoom(hContact) && !getWString(hContact, "ChatRoomID", &dbv)) + if (isChatRoom(hContact)) { + CMStringW wszId(FORMAT, L"%d", getDword(hContact, GG_KEY_UIN)); + // Most important... check redundancy (fucking cascading) static int cascade = 0; - if (!cascade && dbv.pwszVal) + if (!cascade) { - debugLogA("dbsettingchanged(): Conference %s was renamed.", dbv.pszVal); + debugLogA("dbsettingchanged(): Conference %s was renamed.", wszId.c_str()); // Mark cascading /* FIXME */ cascade = 1; - Chat_ChangeSessionName(m_szModuleName, dbv.pwszVal, ptszVal); + Chat_ChangeSessionName(m_szModuleName, wszId, ptszVal); /* FIXME */ cascade = 0; } - db_free(&dbv); } else { // Change contact name on all chats diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index 34b7e1b8fa..fd0aea0f03 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -48,7 +48,7 @@ CMPlugin::CMPlugin() : ACCPROTOPLUGIN(GGDEF_PROTO, pluginInfoEx) { crc_gentable(); - SetUniqueId(GG_KEY_UIN); + SetUniqueId(GG_KEY_UIN, DBVT_DWORD); } ////////////////////////////////////////////////////////// diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 6eac366e71..81deec7393 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -114,7 +114,7 @@ int GaduProto::gc_event(WPARAM, LPARAM lParam) // Check if we got our protocol, and fields are set if (!gch || !gch->si->ptszID || !gch->si->pszModule || mir_strcmpi(gch->si->pszModule, m_szModuleName) - || !(uin = getDword(GG_KEY_UIN, 0)) + || !(uin = getDword(gch->si->hContact, GG_KEY_UIN)) || !(chat = gc_lookup(gch->si->ptszID))) return 0; @@ -126,16 +126,7 @@ int GaduProto::gc_event(WPARAM, LPARAM lParam) list_remove(&chats, chat, 1); // Remove contact from contact list (duh!) should be done by chat.dll !! - for (MCONTACT hContact = db_find_first(); hContact; ) { - MCONTACT hNext = db_find_next(hContact); - DBVARIANT dbv; - if (!getWString(hContact, "ChatRoomID", &dbv)) { - if (dbv.pwszVal && !mir_wstrcmp(gch->si->ptszID, dbv.pwszVal)) - db_delete_contact(hContact); - db_free(&dbv); - } - hContact = hNext; - } + db_delete_contact(gch->si->hContact); return 1; } -- cgit v1.2.3