diff options
author | George Hazan <ghazan@miranda.im> | 2023-01-27 19:48:42 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-01-27 19:48:42 +0300 |
commit | 899221e2d058f5afe30bb2ecdbf168c8ad3c15a6 (patch) | |
tree | ea2346678575a4fc5fdd9575b6a9174bd30c70dc /plugins | |
parent | c736d08681747a9453bd4c266f6dd54d8cbd79eb (diff) |
Group chats: all old APIs with lookup by module+session removed
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/KeyboardNotify/src/main.cpp | 2 | ||||
-rw-r--r-- | plugins/MirLua/src/Modules/m_chat.cpp | 2 | ||||
-rw-r--r-- | plugins/MirLua/src/Modules/m_message.cpp | 2 | ||||
-rw-r--r-- | plugins/MirandaG15/src/CAppletManager.cpp | 25 | ||||
-rw-r--r-- | plugins/MirandaG15/src/StdAfx.h | 2 | ||||
-rw-r--r-- | plugins/PasteIt/src/PasteIt.cpp | 23 | ||||
-rw-r--r-- | plugins/RecentContacts/src/RecentContacts.cpp | 4 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/CSend.cpp | 64 | ||||
-rw-r--r-- | plugins/XSoundNotify/src/xsn_main.cpp | 2 |
9 files changed, 45 insertions, 81 deletions
diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp index 5c454d239a..b0b65376aa 100644 --- a/plugins/KeyboardNotify/src/main.cpp +++ b/plugins/KeyboardNotify/src/main.cpp @@ -413,7 +413,7 @@ static int OnGcEvent(WPARAM, LPARAM lParam) {
auto *gce = (GCEVENT *)lParam;
if (gce->iType == GC_EVENT_MESSAGE && bFlashOnGC)
- if (SESSION_INFO *si = g_chatApi.SM_FindSession(gce->pszID.w, gce->pszModule))
+ if (SESSION_INFO *si = gce->si)
if (contactCheckProtocol(si->pszModule, si->hContact, EVENTTYPE_MESSAGE) && checkNotifyOptions() && checkStatus(si->pszModule))
SetEvent(hFlashEvent);
diff --git a/plugins/MirLua/src/Modules/m_chat.cpp b/plugins/MirLua/src/Modules/m_chat.cpp index 8611b6bc08..a5e7ef57e4 100644 --- a/plugins/MirLua/src/Modules/m_chat.cpp +++ b/plugins/MirLua/src/Modules/m_chat.cpp @@ -10,8 +10,6 @@ LUAMOD_API int luaopen_m_chat(lua_State *L) luaL_newlib(L, chatApi); MT<GCEVENT>(L, "GCEVENT") - .Field(&GCEVENT::pszModule, "Module", LUA_TSTRINGA) - .Field(&GCEVENT::pszID, "Id", LUA_TSTRINGW) .Field(&GCEVENT::iType, "Type", LUA_TINTEGER) .Field(&GCEVENT::time, "Timestamp", LUA_TINTEGER) .Field(&GCEVENT::time, "IsMe", LUA_TINTEGER) diff --git a/plugins/MirLua/src/Modules/m_message.cpp b/plugins/MirLua/src/Modules/m_message.cpp index a00ec285e1..eee8c43f3e 100644 --- a/plugins/MirLua/src/Modules/m_message.cpp +++ b/plugins/MirLua/src/Modules/m_message.cpp @@ -30,7 +30,7 @@ static int message_Send(lua_State *L) if (Contact::IsGroupChat(hContact, szProto)) { ptrW wszChatRoom(Contact::GetInfo(CNF_UNIQUEID, hContact, szProto)); ptrW wszMessage(mir_utf8decodeW(message)); - res = Chat_SendUserMessage(szProto, wszChatRoom, wszMessage); + res = Chat_SendUserMessage(Chat_Find(wszChatRoom, szProto), wszMessage); lua_pushinteger(L, res); } else if ((res = ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)message)) != ACKRESULT_FAILED) { diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index ed688f189c..62bd9e5ab9 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -1,7 +1,6 @@ #include "stdafx.h" #include "CConfig.h" #include "CAppletManager.h" -#include "m_system.h" // specifies how long contact status notifications are ignored after signon #define PROTOCOL_NOTIFY_DELAY 1500 @@ -744,7 +743,7 @@ MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact, tstring strMessag return NULL; tstring strID = tstring(wszNick) + L" - " + tstring(_A2T(toNarrowString(pIRCCon->strNetwork).c_str())); - Chat_SendUserMessage(szProto, strID.c_str(), strAscii.c_str()); + Chat_SendUserMessage(Chat_Find(strID.c_str(), szProto), strAscii.c_str()); return 0; } @@ -1051,12 +1050,12 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) return 0; } - TRACE(L"<< [%s:%s] event %04X\n", toTstring(gce->pszModule).c_str(), gce->pszID.w, gce->iType); + TRACE(L"<< [%s:%s] event %04X\n", toTstring(gce->si->pszModule).c_str(), gce->si->ptszID, gce->iType); // get the matching irc connection entry - CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(toTstring(gce->pszModule)); + CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(toTstring(gce->si->pszModule)); if (!pIRCCon) { - TRACE(L"<< [%s] connection not found, skipping event\n", toTstring(gce->pszModule).c_str()); + TRACE(L"<< [%s] connection not found, skipping event\n", toTstring(gce->si->pszModule).c_str()); return 0; } @@ -1078,13 +1077,13 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) Event.hValue = lParam; CIRCHistory *pHistory = nullptr; - if (gce->pszID.w) { - tstring strChannel = toTstring(gce->pszID.w); + if (gce->si->ptszID) { + tstring strChannel = toTstring(gce->si->ptszID); tstring::size_type pos = strChannel.find('-'); if (pos != tstring::npos) strChannel = strChannel.substr(0, pos - 1); else { - if (mir_wstrcmpi(gce->pszID.w, L"Network log")) + if (mir_wstrcmpi(gce->si->ptszID, L"Network log")) TRACE(L"\t WARNING: ignoring unknown event!\n"); return 0; } @@ -1107,7 +1106,7 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) Event.hContact = NULL; // Ignore events from hidden chatrooms, except for join events - if (gce->pszID.w != nullptr && Contact::IsHidden(Event.hContact)) { + if (gce->si->ptszID != nullptr && Contact::IsHidden(Event.hContact)) { if (gce->iType == GC_EVENT_JOIN && pHistory) pHistory->LUsers.push_back(toTstring(gce->pszNick.w)); @@ -1243,7 +1242,7 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) TRACE(L"OK!\n"); return 0; } - if (gce->bIsMe || gce->pszID.w == nullptr) + if (gce->bIsMe || gce->si->ptszID == nullptr) Event.bNotification = false; // set the event's timestamp @@ -1284,7 +1283,7 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) Event.hContact = (*iter)->hContact; tstring strName = CAppletManager::GetContactDisplayname((*iter)->hContact, true); Event.strDescription = strName + L" - " + Event.strValue; - Event.strSummary = L"(" + toTstring(gce->pszModule) + L") " + strName; + Event.strSummary = L"(" + toTstring(gce->si->pszModule) + L") " + strName; CAppletManager::GetInstance()->HandleEvent(&Event); break; } @@ -1296,7 +1295,7 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) TRACE(L"OK!\n"); return 0; } - else if (gce->pszID.w != nullptr) { + else if (gce->si->ptszID != nullptr) { TRACE(L"OK!\n"); return 0; } @@ -1307,7 +1306,7 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) strChannel = strChannel.erase(CConfig::GetIntSetting(NOTIFY_CHANNELCUTOFF_OFFSET)) + L"..."; } Event.strDescription = strChannel + L" - " + Event.strValue; - Event.strSummary = L"(" + toTstring(gce->pszModule) + L") " + pHistory->strChannel; + Event.strSummary = L"(" + toTstring(gce->si->pszModule) + L") " + pHistory->strChannel; } else Event.strDescription = Event.strValue; diff --git a/plugins/MirandaG15/src/StdAfx.h b/plugins/MirandaG15/src/StdAfx.h index 61fed0dbd1..fba8ef69bf 100644 --- a/plugins/MirandaG15/src/StdAfx.h +++ b/plugins/MirandaG15/src/StdAfx.h @@ -25,7 +25,7 @@ using namespace std; #include <m_clistint.h>
#include <m_protocols.h>
#include <m_skin.h>
-#include <m_chat.h>
+#include <m_chat_int.h>
#include <m_idle.h>
#include <m_metacontacts.h>
#include <m_langpack.h>
diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp index b7fb63df7d..ee1393169e 100644 --- a/plugins/PasteIt/src/PasteIt.cpp +++ b/plugins/PasteIt/src/PasteIt.cpp @@ -122,28 +122,7 @@ static void PasteIt(MCONTACT hContact, int mode) db_event_add(hContact, &dbei);
ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)pasteToWeb->szFileLink);
}
- else {
- // PSS_MESSAGE is not compatible with chat rooms
- // there are no simple method to send text to all users
- // in chat room.
- // Next step is to get all protocol sessions and find
- // one with correct hContact
- int cnt = g_chatApi.SM_GetCount(szProto);
- for (int i = 0; i < cnt; i++) {
- GC_INFO gci = {};
- gci.iItem = i;
- gci.pszModule = szProto;
- gci.Flags = GCF_BYINDEX | GCF_HCONTACT | GCF_ID;
- Chat_GetInfo(&gci);
- if (gci.hContact == hContact) {
- // In this place session was finded, gci.pszID contains
- // session ID, but it is in unicode or ascii format,
- // depends on protocol wersion
- Chat_SendUserMessage(szProto, gci.pszID, _A2T(pasteToWeb->szFileLink));
- break;
- }
- }
- }
+ else Chat_SendUserMessage(szProto, _A2T(pasteToWeb->szFileLink));
// Send message to focus window
CallServiceSync(MS_MSG_SENDMESSAGE, hContact, 0);
diff --git a/plugins/RecentContacts/src/RecentContacts.cpp b/plugins/RecentContacts/src/RecentContacts.cpp index 9b2970e5af..8787936cc9 100644 --- a/plugins/RecentContacts/src/RecentContacts.cpp +++ b/plugins/RecentContacts/src/RecentContacts.cpp @@ -455,7 +455,7 @@ static int OnGCInEvent(WPARAM, LPARAM lParam) {
GCEVENT *gce = (GCEVENT*)lParam;
if (gce->iType == GC_EVENT_MESSAGE) {
- SESSION_INFO *si = g_chatApi.SM_FindSession(gce->pszID.w, gce->pszModule);
+ SESSION_INFO *si = gce->si;
if (si && si->hContact) {
// skip old events
if (gce->time && gce->time <= GetLastUsedTimeStamp(si->hContact))
@@ -470,7 +470,7 @@ static int OnGCOutEvent(WPARAM, LPARAM lParam) {
GCEVENT *gce = (GCEVENT*)lParam;
if (gce->iType == GC_USER_MESSAGE) {
- SESSION_INFO *si = g_chatApi.SM_FindSession(gce->pszID.w, gce->pszModule);
+ SESSION_INFO *si = gce->si;
if (si && si->hContact)
SaveLastUsedTimeStamp(si->hContact);
}
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp index 3e83d4b6c6..1591919edf 100644 --- a/plugins/SendScreenshotPlus/src/CSend.cpp +++ b/plugins/SendScreenshotPlus/src/CSend.cpp @@ -177,12 +177,15 @@ INT_PTR CALLBACK CSend::ResultDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, void CSend::svcSendMsgExit(const char* szMessage)
{
if (m_bSilent) {
- Exit(ACKRESULT_SUCCESS); return;
+ Exit(ACKRESULT_SUCCESS);
+ return;
}
+
if (!m_hContact) {
if (!m_pszFileDesc)
m_pszFileDesc = mir_a2u(szMessage);
- Exit(CSEND_DIALOG); return;
+ Exit(CSEND_DIALOG);
+ return;
}
if (m_ChatRoom) {
@@ -191,46 +194,31 @@ void CSend::svcSendMsgExit(const char* szMessage) tmp.Append(L"\r\n");
tmp.Append(m_pszFileDesc);
}
-
- int res = GC_RESULT_NOSESSION;
- int cnt = g_chatApi.SM_GetCount(m_pszProto);
-
- // loop on all gc session to get the right (save) ptszID for the chatroom from m_hContact
- GC_INFO gci = { 0 };
- gci.pszModule = m_pszProto;
- for (int i = 0; i < cnt; i++) {
- gci.iItem = i;
- gci.Flags = GCF_BYINDEX | GCF_HCONTACT | GCF_ID;
- Chat_GetInfo(&gci);
- if (gci.hContact == m_hContact) {
- Chat_SendUserMessage(m_pszProto, gci.pszID, tmp);
- res = 200;
- break;
- }
- }
- Exit(res); return;
+ Chat_SendUserMessage(m_pszProto, tmp);
+
+ Exit(200);
+ return;
+ }
+
+ m_szEventMsg = szMessage;
+ if (m_pszFileDesc && m_pszFileDesc[0] != NULL) {
+ m_szEventMsg.Append("\r\n");
+ m_szEventMsg.Append(_T2A(m_pszFileDesc));
+ m_cbEventMsg = m_szEventMsg.GetLength() + 1;
}
- else {
- m_szEventMsg = szMessage;
- if (m_pszFileDesc && m_pszFileDesc[0] != NULL) {
- m_szEventMsg.Append("\r\n");
- m_szEventMsg.Append(_T2A(m_pszFileDesc));
- m_cbEventMsg = m_szEventMsg.GetLength() + 1;
- }
- // create a HookEventObj on ME_PROTO_ACK
- if (!m_hOnSend)
- m_hOnSend = HookEventObj(ME_PROTO_ACK, OnSend, this);
+ // create a HookEventObj on ME_PROTO_ACK
+ if (!m_hOnSend)
+ m_hOnSend = HookEventObj(ME_PROTO_ACK, OnSend, this);
- // start PSS_MESSAGE service
- m_hSend = (HANDLE)ProtoChainSend(m_hContact, PSS_MESSAGE, NULL, ptrA(mir_utf8encode(m_szEventMsg)));
+ // start PSS_MESSAGE service
+ m_hSend = (HANDLE)ProtoChainSend(m_hContact, PSS_MESSAGE, NULL, ptrA(mir_utf8encode(m_szEventMsg)));
- // check we actually got an ft handle back from the protocol
- if (!m_hSend) {
- Unhook();
- Error(SS_ERR_INIT, m_pszSendTyp);
- Exit(ACKRESULT_FAILED); return;
- }
+ // check we actually got an ft handle back from the protocol
+ if (!m_hSend) {
+ Unhook();
+ Error(SS_ERR_INIT, m_pszSendTyp);
+ Exit(ACKRESULT_FAILED);
}
}
diff --git a/plugins/XSoundNotify/src/xsn_main.cpp b/plugins/XSoundNotify/src/xsn_main.cpp index 4abffe43e8..b002b0d66e 100644 --- a/plugins/XSoundNotify/src/xsn_main.cpp +++ b/plugins/XSoundNotify/src/xsn_main.cpp @@ -171,7 +171,7 @@ static int ProcessChatEvent(WPARAM, LPARAM lParam) if (gce->iType != GC_EVENT_MESSAGE)
return 0;
- auto *si = g_chatApi.SM_FindSession(gce->pszID.w, gce->pszModule);
+ auto *si = gce->si;
if (si && g_chatApi.IsHighlighted(si, gce))
PlayWorker(si->hContact);
|