From 899221e2d058f5afe30bb2ecdbf168c8ad3c15a6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 27 Jan 2023 19:48:42 +0300 Subject: Group chats: all old APIs with lookup by module+session removed --- protocols/ICQ-WIM/src/groupchats.cpp | 14 ++++++-------- protocols/ICQ-WIM/src/poll.cpp | 2 +- protocols/ICQ-WIM/src/server.cpp | 21 +++++++++++---------- 3 files changed, 18 insertions(+), 19 deletions(-) (limited to 'protocols/ICQ-WIM/src') diff --git a/protocols/ICQ-WIM/src/groupchats.cpp b/protocols/ICQ-WIM/src/groupchats.cpp index 807bec394a..d59e7c6a74 100644 --- a/protocols/ICQ-WIM/src/groupchats.cpp +++ b/protocols/ICQ-WIM/src/groupchats.cpp @@ -35,9 +35,8 @@ void CIcqProto::LoadChatInfo(SESSION_INFO *si) CMStringW role((*node)["role"].as_mstring()); CMStringW sn((*node)["sn"].as_mstring()); - GCEVENT gce = { m_szModuleName, 0, GC_EVENT_JOIN }; + GCEVENT gce = { si, GC_EVENT_JOIN }; gce.dwFlags = GCEF_SILENT; - gce.pszID.w = si->ptszID; gce.pszNick.w = nick; gce.pszUID.w = sn; gce.time = ::time(0); @@ -161,7 +160,7 @@ void CIcqProto::LeaveDestroyChat(SESSION_INFO *si) Push(new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/buddylist/hideChat") << AIMSID(this) << WCHAR_PARAM("buddy", si->ptszID) << INT64_PARAM("lastMsgId", getId(si->hContact, DB_KEY_LASTMSGID))); - Chat_Terminate(si->pszModule, si->ptszID, true); + Chat_Terminate(si, true); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -183,7 +182,7 @@ int CIcqProto::GroupchatMenuHook(WPARAM, LPARAM lParam) if (mir_strcmpi(gcmi->pszModule, m_szModuleName)) return 0; - SESSION_INFO *si = g_chatApi.SM_FindSession(gcmi->pszID, gcmi->pszModule); + SESSION_INFO *si = Chat_Find(gcmi->pszID, gcmi->pszModule); if (si == nullptr) return 0; @@ -202,7 +201,7 @@ int CIcqProto::GroupchatEventHook(WPARAM, LPARAM lParam) if (mir_strcmpi(gch->si->pszModule, m_szModuleName)) return 0; - SESSION_INFO *si = g_chatApi.SM_FindSession(gch->si->ptszID, gch->si->pszModule); + SESSION_INFO *si = Chat_Find(gch->si->ptszID, gch->si->pszModule); if (si == nullptr) return 1; @@ -263,13 +262,12 @@ void CIcqProto::ProcessGroupChat(const JSONNode &ev) { for (auto &it : ev["mchats"]) { CMStringW wszId(it["sender"].as_mstring()); - SESSION_INFO *si = g_chatApi.SM_FindSession(wszId, m_szModuleName); + auto *si = Chat_Find(wszId, m_szModuleName); if (si == nullptr) continue; CMStringW method(it["method"].as_mstring()); - GCEVENT gce = { m_szModuleName, 0, (method == "add_members") ? GC_EVENT_JOIN : GC_EVENT_PART }; - gce.pszID.w = si->ptszID; + GCEVENT gce = { si, (method == "add_members") ? GC_EVENT_JOIN : GC_EVENT_PART }; int iStart = 0; CMStringW members(it["members"].as_mstring()); diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index 6fca78728f..c6c7d0b2e0 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -167,7 +167,7 @@ void CIcqProto::ProcessHistData(const JSONNode &ev) auto *pCache = FindContactByUIN(wszId); // might be NULL for groupchats if (IsChat(wszId)) { - SESSION_INFO *si = g_chatApi.SM_FindSession(wszId, m_szModuleName); + SESSION_INFO *si = Chat_Find(wszId, m_szModuleName); if (si == nullptr) return; diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index e7468d952a..d8f203dfc9 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -300,8 +300,8 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact, boo Chat_AddGroup(si, TranslateT("admin")); Chat_AddGroup(si, TranslateT("member")); - Chat_Control(m_szModuleName, wszChatId, m_bHideGroupchats ? WINDOW_HIDDEN : SESSION_INITDONE); - Chat_Control(m_szModuleName, wszChatId, SESSION_ONLINE); + Chat_Control(si, m_bHideGroupchats ? WINDOW_HIDDEN : SESSION_INITDONE); + Chat_Control(si, SESSION_ONLINE); return si->hContact; } @@ -500,14 +500,15 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo delete pFileInfo; } - GCEVENT gce = { m_szModuleName, 0, GC_EVENT_MESSAGE }; - gce.pszID.w = wszChatId; - gce.dwFlags = GCEF_ADDTOLOG; - gce.pszUID.w = wszSender; - gce.pszText.w = wszText; - gce.time = iMsgTime; - gce.bIsMe = wszSender == m_szOwnId; - Chat_Event(&gce); + if (auto *si = Chat_Find(wszChatId, m_szModuleName)) { + GCEVENT gce = { si, GC_EVENT_MESSAGE}; + gce.dwFlags = GCEF_ADDTOLOG; + gce.pszUID.w = wszSender; + gce.pszText.w = wszText; + gce.time = iMsgTime; + gce.bIsMe = wszSender == m_szOwnId; + Chat_Event(&gce); + } return; } -- cgit v1.2.3