From abcf85f5475d62c7df49746c9d6d3f1b8ecae163 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 6 Mar 2024 12:50:52 +0300 Subject: Chat_Find(MCONTACT) - new useful helper --- include/m_chat.h | 1 + libs/win32/mir_app.lib | Bin 291510 -> 291820 bytes libs/win64/mir_app.lib | Bin 291260 -> 291580 bytes plugins/Msg_Export/src/utils.cpp | 6 ++---- src/mir_app/src/chat_manager.cpp | 9 +++++++++ src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + 7 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/m_chat.h b/include/m_chat.h index e747388245..ea716ea040 100644 --- a/include/m_chat.h +++ b/include/m_chat.h @@ -466,6 +466,7 @@ MIR_APP_DLL(int) Chat_GetInfo(GC_INFO *pInfo); // Finds a session by its module & unique id // returns a pointer to session or NULL on error +MIR_APP_DLL(SESSION_INFO*) Chat_Find(MCONTACT hContact, const char *pszModule = nullptr); MIR_APP_DLL(SESSION_INFO*) Chat_Find(const wchar_t *pszID, const char *pszModule); //------------------------- HOOKS ------------------------ diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index 8fef540280..7812501077 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib index 31676ae0b1..a3f4b42cf6 100644 Binary files a/libs/win64/mir_app.lib and b/libs/win64/mir_app.lib differ diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index 1c819d20de..c30c32a62b 100644 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -642,12 +642,10 @@ static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sF else { sLocalUser = ptrW(GetMyOwnNick(hContact)); sRemoteUser = Clist_GetContactDisplayName(hContact); - if (dbei.szUserId && Contact::IsGroupChat(hContact)) { - ptrW contactId(Contact::GetInfo(CNF_UNIQUEID, hContact, szProto)); - if (auto *si = Chat_Find(contactId, szProto)) + if (dbei.szUserId && Contact::IsGroupChat(hContact)) + if (auto *si = Chat_Find(hContact, szProto)) if (auto *pUser = g_chatApi.UM_FindUser(si, Utf2T(dbei.szUserId))) sRemoteUser = pUser->pszNick; - } nFirstColumnWidth = max(sRemoteUser.size(), clFileTo1ColWidth[sFilePath]); nFirstColumnWidth = max(sLocalUser.size(), nFirstColumnWidth); diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 495e55c510..35674c113a 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -140,6 +140,15 @@ void SM_FreeSession(SESSION_INFO *si) delete si; } +MIR_APP_DLL(SESSION_INFO*) Chat_Find(MCONTACT hContact, const char *pszModule) +{ + if (pszModule == nullptr) + pszModule = Proto_GetBaseAccountName(hContact); + + ptrW contactId(Contact::GetInfo(CNF_UNIQUEID, hContact, pszModule)); + return Chat_Find(contactId, pszModule); +} + MIR_APP_DLL(SESSION_INFO*) Chat_Find(const wchar_t *pszID, const char *pszModule) { if (!pszID || !pszModule) diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 8244257bb2..7600b61835 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -964,3 +964,4 @@ _Netlib_DownloadFile@20 @1099 NONAME ??0FILE_BLOB@DB@@QAE@PAXPBD1_N@Z @1100 NONAME ?getUserInfo@FILE_BLOB@DB@@QBEPAXXZ @1101 NONAME ?setUserInfo@FILE_BLOB@DB@@QAEXPAX@Z @1102 NONAME +?Chat_Find@@YGPAUSESSION_INFO@@IPBD@Z @1103 NONAME diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index f87aca41a0..78a03b754f 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -964,3 +964,4 @@ Netlib_DownloadFile @1093 NONAME ??0FILE_BLOB@DB@@QEAA@PEAXPEBD1_N@Z @1094 NONAME ?getUserInfo@FILE_BLOB@DB@@QEBAPEAXXZ @1095 NONAME ?setUserInfo@FILE_BLOB@DB@@QEAAXPEAX@Z @1096 NONAME +?Chat_Find@@YAPEAUSESSION_INFO@@IPEBD@Z @1097 NONAME -- cgit v1.2.3