From e254312f9a660c83081ce2062ab14ba3c3614089 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 19 Sep 2017 14:12:58 +0300 Subject: useless structure GCDEST finally removed --- include/m_chat.h | 18 ++++----- plugins/MirLua/src/m_chat.cpp | 21 ++--------- plugins/MirandaG15/src/CAppletManager.cpp | 41 ++++++++++---------- plugins/RecentContacts/src/RecentContacts.cpp | 8 ++-- plugins/Scriver/src/chat_main.cpp | 4 +- plugins/TabSRMM/src/chat_main.cpp | 2 +- plugins/TabSRMM/src/chat_tools.cpp | 10 ++--- plugins/XSoundNotify/src/xsn_main.cpp | 10 ++--- protocols/AimOscar/src/chat.cpp | 15 ++++---- protocols/Discord/src/dispatch.cpp | 12 ++---- protocols/Discord/src/groupchat.cpp | 10 ++--- protocols/Discord/src/guilds.cpp | 6 +-- protocols/Discord/src/server.cpp | 3 +- protocols/FacebookRM/src/chat.cpp | 21 ++++------- protocols/Gadu-Gadu/src/core.cpp | 6 +-- protocols/Gadu-Gadu/src/groupchat.cpp | 33 +++++++--------- protocols/IRCG/src/commandmonitor.cpp | 12 +++--- protocols/IRCG/src/scripting.cpp | 27 +++++++------- protocols/IRCG/src/services.cpp | 6 +-- protocols/IRCG/src/tools.cpp | 7 ++-- protocols/JabberG/src/jabber_chat.cpp | 54 +++++++++++++-------------- protocols/JabberG/src/jabber_groupchat.cpp | 16 ++++---- protocols/MRA/src/MraChat.cpp | 11 +++--- protocols/MSN/src/msn_chat.cpp | 50 ++++++++++++------------- protocols/MinecraftDynmap/src/chat.cpp | 18 ++++----- protocols/Omegle/src/chat.cpp | 18 ++++----- protocols/Sametime/src/conference.cpp | 42 ++++++--------------- protocols/SkypeWeb/src/skype_chatrooms.cpp | 35 +++++++---------- protocols/Twitter/src/chat.cpp | 30 +++++++-------- protocols/VKontakte/src/vk_chats.cpp | 19 ++++------ protocols/WhatsApp/src/chat.cpp | 30 +++++---------- src/core/stdmsg/src/chat_manager.cpp | 4 +- src/mir_app/src/chat_manager.cpp | 2 +- src/mir_app/src/chat_svc.cpp | 45 ++++++++++------------ src/mir_app/src/chat_tools.cpp | 14 +++---- 35 files changed, 271 insertions(+), 389 deletions(-) diff --git a/include/m_chat.h b/include/m_chat.h index 6fe8aad0ca..9107983bb3 100644 --- a/include/m_chat.h +++ b/include/m_chat.h @@ -349,14 +349,6 @@ EXTERN_C MIR_APP_DLL(struct GCSessionInfoBase*) Chat_NewSession( GC_EVENT_PART | GC_EVENT_TOPIC | GC_EVENT_ADDSTATUS | GC_EVENT_INFORMATION | GC_EVENT_QUIT | \ GC_EVENT_KICK | GC_EVENT_NOTICE) -// The GCDEST structure. It is passed to Chat inside GCEVENT. -struct GCDEST -{ - LPCSTR pszModule; // Name of the protocol (same as you registered with) - LPCTSTR ptszID; // Unique identifier of the session, or NULL to broadcast to all sessions as specified above - int iType; // Use GC_EVENT_* as defined above. Only one event per service call. -}; - // The GCEVENT structure #define GCEF_ADDTOLOG 0x0001 // force adding to log @@ -365,7 +357,10 @@ struct GCDEST struct GCEVENT { - GCDEST *pDest; // pointer to a GCDEST structure which specifies the session to receive the event + LPCSTR pszModule; // Name of the protocol (same as you registered with) + LPCTSTR ptszID; // Unique identifier of the session, or NULL to broadcast to all sessions as specified above + int iType; // Use GC_EVENT_* as defined above. Only one event per service call. + LPCTSTR ptszText; // LPCTSTR ptszNick; // LPCTSTR ptszUID; // @@ -487,7 +482,10 @@ EXTERN_C MIR_APP_DLL(int) Chat_GetInfo(GC_INFO*); struct GCHOOK { - GCDEST *pDest; // pointer to a GCDEST structure which specifies from which session the hook was triggered + LPCSTR pszModule; // Name of the protocol (same as you registered with) + LPCTSTR ptszID; // Unique identifier of the session, or NULL to broadcast to all sessions as specified above + int iType; // Use GC_EVENT_* as defined above. Only one event per service call. + LPTSTR ptszText; // usage depends on type of event LPTSTR ptszUID; // unique identifier, usage depends on type of event LPTSTR ptszNick; // user nick, as displayed in a nicklist diff --git a/plugins/MirLua/src/m_chat.cpp b/plugins/MirLua/src/m_chat.cpp index dbecbc774e..f84caa4591 100644 --- a/plugins/MirLua/src/m_chat.cpp +++ b/plugins/MirLua/src/m_chat.cpp @@ -5,29 +5,14 @@ static luaL_Reg chatApi[] = { NULL, NULL } }; -template <> -int MT::Index(lua_State *L, GCEVENT *gce) -{ - const char *key = lua_tostring(L, 2); - - if (mir_strcmp(key, "Destination") == 0) - MT::Set(L, gce->pDest); - else - lua_pushnil(L); - - return 1; -} - LUAMOD_API int luaopen_m_chat(lua_State *L) { luaL_newlib(L, chatApi); - MT(L, "GCDEST") - .Field(&GCDEST::pszModule, "Module", LUA_TSTRINGA) - .Field(&GCDEST::ptszID, "Id", LUA_TSTRINGW) - .Field(&GCDEST::iType, "Type", LUA_TINTEGER); - MT(L, "GCEVENT") + .Field(&GCEVENT::pszModule, "Module", LUA_TSTRINGA) + .Field(&GCEVENT::ptszID, "Id", LUA_TSTRINGW) + .Field(&GCEVENT::iType, "Type", LUA_TINTEGER) .Field(&GCEVENT::time, "Timestamp", LUA_TINTEGER) .Field(&GCEVENT::time, "IsMe", LUA_TINTEGER) .Field(&GCEVENT::time, "Flags", LUA_TINTEGER) diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp index 6aee1a4f3c..323c1b7c70 100644 --- a/plugins/MirandaG15/src/CAppletManager.cpp +++ b/plugins/MirandaG15/src/CAppletManager.cpp @@ -1085,19 +1085,17 @@ CIRCHistory *CAppletManager::CreateIRCHistoryByName(tstring strProtocol, tstring int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) { GCEVENT *gce = (GCEVENT*)lParam; - GCDEST *gcd; - - if (gce == NULL || (gcd = gce->pDest) == NULL) { + if (gce == NULL) { TRACE(L"<< [%s] skipping invalid event\n"); return 0; } - TRACE(L"<< [%s:%s] event %04X\n", toTstring(gcd->pszModule).c_str(), gcd->ptszID, gcd->iType); + TRACE(L"<< [%s:%s] event %04X\n", toTstring(gce->pszModule).c_str(), gce->ptszID, gce->iType); // get the matching irc connection entry - CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(toTstring(gcd->pszModule)); + CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(toTstring(gce->pszModule)); if (!pIRCCon) { - TRACE(L"<< [%s] connection not found, skipping event\n", toTstring(gcd->pszModule).c_str()); + TRACE(L"<< [%s] connection not found, skipping event\n", toTstring(gce->pszModule).c_str()); return 0; } @@ -1115,23 +1113,23 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) Event.eType = EVENT_IRC_SENT; else Event.eType = EVENT_IRC_RECEIVED; - Event.iValue = gcd->iType; + Event.iValue = gce->iType; Event.hValue = lParam; CIRCHistory *pHistory = NULL; - if (gcd->ptszID) { - tstring strChannel = toTstring(gcd->ptszID); + if (gce->ptszID) { + tstring strChannel = toTstring(gce->ptszID); tstring::size_type pos = strChannel.find('-'); if (pos != tstring::npos) strChannel = strChannel.substr(0, pos - 1); else { - if (mir_wstrcmpi(gcd->ptszID, L"Network log")) + if (mir_wstrcmpi(gce->ptszID, L"Network log")) TRACE(L"\t WARNING: ignoring unknown event!\n"); return 0; } pHistory = CAppletManager::GetInstance()->GetIRCHistoryByName(pIRCCon->strProtocol, strChannel); if (!pHistory) { - if (gcd->iType == GC_EVENT_JOIN) { + if (gce->iType == GC_EVENT_JOIN) { pHistory = CAppletManager::GetInstance()->CreateIRCHistoryByName(pIRCCon->strProtocol, strChannel); if (pHistory) pHistory->LUsers.push_back(toTstring(gce->ptszNick)); @@ -1140,7 +1138,7 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) } Event.hContact = pHistory->hContact; } - else if (gcd->iType != GC_EVENT_INFORMATION) { + else if (gce->iType != GC_EVENT_INFORMATION) { TRACE(L"\t WARNING: ignoring unknown event!\n"); return 0; } @@ -1148,8 +1146,8 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) Event.hContact = NULL; // Ignore events from hidden chatrooms, except for join events - if (gcd->ptszID != NULL && db_get_b(Event.hContact, "CList", "Hidden", 0)) { - if (gcd->iType == GC_EVENT_JOIN && pHistory) + if (gce->ptszID != NULL && db_get_b(Event.hContact, "CList", "Hidden", 0)) { + if (gce->iType == GC_EVENT_JOIN && pHistory) pHistory->LUsers.push_back(toTstring(gce->ptszNick)); TRACE(L"\t Chatroom is hidden, skipping event!\n"); @@ -1165,7 +1163,7 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) TRACE(L"\t Handling event...\t"); - switch (gcd->iType) { + switch (gce->iType) { case GC_EVENT_INFORMATION: if (CConfig::GetBoolSetting(NOTIFY_IRC_CHANNEL)) Event.bNotification = true; @@ -1284,7 +1282,7 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) TRACE(L"OK!\n"); return 0; } - if (gce->bIsMe || gcd->ptszID == NULL) + if (gce->bIsMe || gce->ptszID == NULL) Event.bNotification = false; // set the event's timestamp @@ -1305,7 +1303,7 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) if (pHistory->LMessages.size() > CConfig::GetIntSetting(SESSION_LOGSIZE)) pHistory->LMessages.pop_front(); } - else if (gce->ptszNick && gcd->iType == GC_EVENT_QUIT) { + else if (gce->ptszNick && gce->iType == GC_EVENT_QUIT) { strNick = toTstring(gce->ptszNick); if (!CAppletManager::GetInstance()->m_LIRCHistorys.empty()) { @@ -1325,7 +1323,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(gcd->pszModule) + L") " + strName; + Event.strSummary = L"(" + toTstring(gce->pszModule) + L") " + strName; CAppletManager::GetInstance()->HandleEvent(&Event); break; } @@ -1337,7 +1335,7 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam) TRACE(L"OK!\n"); return 0; } - else if (gcd->ptszID != NULL) { + else if (gce->ptszID != NULL) { TRACE(L"OK!\n"); return 0; } @@ -1348,10 +1346,9 @@ 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(gcd->pszModule) + L") " + pHistory->strChannel; + Event.strSummary = L"(" + toTstring(gce->pszModule) + L") " + pHistory->strChannel; } - else - Event.strDescription = Event.strValue; + else Event.strDescription = Event.strValue; TRACE(L"OK!\n"); diff --git a/plugins/RecentContacts/src/RecentContacts.cpp b/plugins/RecentContacts/src/RecentContacts.cpp index c88932e102..f89b112c78 100644 --- a/plugins/RecentContacts/src/RecentContacts.cpp +++ b/plugins/RecentContacts/src/RecentContacts.cpp @@ -476,8 +476,8 @@ static void SaveLastUsedTimeStamp(MCONTACT hContact) static int OnGCInEvent(WPARAM, LPARAM lParam) { GCEVENT *gce = (GCEVENT*)lParam; - if (gce->pDest->iType == GC_EVENT_MESSAGE) { - SESSION_INFO *si = pci->SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); + if (gce->iType == GC_EVENT_MESSAGE) { + SESSION_INFO *si = pci->SM_FindSession(gce->ptszID, gce->pszModule); if (si && si->hContact) { // skip old events if (gce->time && gce->time <= GetLastUsedTimeStamp(si->hContact)) @@ -491,8 +491,8 @@ static int OnGCInEvent(WPARAM, LPARAM lParam) static int OnGCOutEvent(WPARAM, LPARAM lParam) { GCEVENT *gce = (GCEVENT*)lParam; - if (gce->pDest->iType == GC_USER_MESSAGE) { - SESSION_INFO *si = pci->SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); + if (gce->iType == GC_USER_MESSAGE) { + SESSION_INFO *si = pci->SM_FindSession(gce->ptszID, gce->pszModule); if (si && si->hContact) SaveLastUsedTimeStamp(si->hContact); } diff --git a/plugins/Scriver/src/chat_main.cpp b/plugins/Scriver/src/chat_main.cpp index 9840936d74..7be39fdf65 100644 --- a/plugins/Scriver/src/chat_main.cpp +++ b/plugins/Scriver/src/chat_main.cpp @@ -105,14 +105,14 @@ static void OnCreateModule(MODULEINFO *mi) static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) { - if (gce->pDest->iType & g_Settings.dwTrayIconFlags) + if (gce->iType & g_Settings.dwTrayIconFlags) return oldDoTrayIcon(si, gce); return TRUE; } static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) { - if (gce->pDest->iType & g_Settings.dwPopupFlags) + if (gce->iType & g_Settings.dwPopupFlags) return oldDoPopup(si, gce); return TRUE; } diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp index 02c906685f..d817fd08e7 100644 --- a/plugins/TabSRMM/src/chat_main.cpp +++ b/plugins/TabSRMM/src/chat_main.cpp @@ -227,7 +227,7 @@ static int OnHandleGCMenu(WPARAM, LPARAM lParam) return 1; if (gch->dwData == 20020) { // add to highlight... - SESSION_INFO *si = pci->SM_FindSession(gch->pDest->ptszID, gch->pDest->pszModule); + SESSION_INFO *si = pci->SM_FindSession(gch->ptszID, gch->pszModule); THighLightEdit the = { THighLightEdit::CMD_ADD, si, pci->UM_FindUser(si->pUsers, gch->ptszUID) }; HWND hwndParent = si->pDlg->m_pContainer->m_hwnd; HWND hwndDlg = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_ADDHIGHLIGHT), hwndParent, CMUCHighlight::dlgProcAdd, (LPARAM)&the); diff --git a/plugins/TabSRMM/src/chat_tools.cpp b/plugins/TabSRMM/src/chat_tools.cpp index 864745498f..463b48320f 100644 --- a/plugins/TabSRMM/src/chat_tools.cpp +++ b/plugins/TabSRMM/src/chat_tools.cpp @@ -78,7 +78,7 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) { - int iEvent = gce->pDest->iType; + int iEvent = gce->iType; if (si && (iEvent & si->iLogTrayFlags)) return oldDoTrayIcon(si, gce); return TRUE; @@ -129,7 +129,7 @@ int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoNa BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) { - int iEvent = gce->pDest->iType; + int iEvent = gce->iType; if (si == nullptr || !(iEvent & si->iLogPopupFlags)) return true; @@ -301,12 +301,12 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight params->bInactive = FALSE; } params->bActiveTab = params->bMustFlash = params->bMustAutoswitch = FALSE; - params->iEvent = gce->pDest->iType; + params->iEvent = gce->iType; WPARAM wParamForHighLight = 0; bool bFlagUnread = false; if (bHighlight) { - gce->pDest->iType |= GC_EVENT_HIGHLIGHT; + gce->iType |= GC_EVENT_HIGHLIGHT; params->sound = "ChatHighlight"; if (db_get_b(si->hContact, "CList", "Hidden", 0) != 0) db_unset(si->hContact, "CList", "Hidden"); @@ -489,7 +489,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) /* * check whether we have to log this event */ - if (!(gce->pDest->iType & si->iDiskLogFlags)) + if (!(gce->iType & si->iDiskLogFlags)) return FALSE; return oldLogToFile(si, gce); // call kernel method diff --git a/plugins/XSoundNotify/src/xsn_main.cpp b/plugins/XSoundNotify/src/xsn_main.cpp index 417dd08dbd..c5e132eb39 100644 --- a/plugins/XSoundNotify/src/xsn_main.cpp +++ b/plugins/XSoundNotify/src/xsn_main.cpp @@ -149,16 +149,14 @@ static int ProcessEvent(WPARAM hContact, LPARAM lParam) static int ProcessChatEvent(WPARAM, LPARAM lParam) { GCEVENT *gce = (GCEVENT*)lParam; - if (gce == NULL || gce->pDest == NULL) + if (gce == nullptr) return 0; - - GCDEST *gcd = (GCDEST*)gce->pDest; - if (gcd->iType != GC_EVENT_MESSAGE) + if (gce->iType != GC_EVENT_MESSAGE) return 0; - MCONTACT hContact = pci->FindRoom(gcd->pszModule, gcd->ptszID); + MCONTACT hContact = pci->FindRoom(gce->pszModule, gce->ptszID); if (hContact != 0) { - ptrW nick(db_get_wsa(hContact, gcd->pszModule, "MyNick")); + ptrW nick(db_get_wsa(hContact, gce->pszModule, "MyNick")); if (nick == NULL || gce->ptszText == NULL) return 0; if (wcsstr(gce->ptszText, nick)) { diff --git a/protocols/AimOscar/src/chat.cpp b/protocols/AimOscar/src/chat.cpp index 24df22d77b..7071c9a3da 100644 --- a/protocols/AimOscar/src/chat.cpp +++ b/protocols/AimOscar/src/chat.cpp @@ -59,10 +59,8 @@ void CAimProto::chat_event(const char* id, const char* sn, int evt, const wchar_ MCONTACT hContact = contact_from_sn(sn); wchar_t *nick = hContact ? (wchar_t*)pcli->pfnGetContactDisplayName(hContact, 0) : snt; - GCDEST gcd = { m_szModuleName, idt, evt }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, idt, evt }; gce.dwFlags = GCEF_ADDTOLOG; - gce.pDest = &gcd; gce.ptszNick = nick; gce.ptszUID = snt; gce.bIsMe = _stricmp(sn, m_username) == 0; @@ -84,14 +82,15 @@ int CAimProto::OnGCEvent(WPARAM, LPARAM lParam) GCHOOK *gch = (GCHOOK*)lParam; if (!gch) return 1; - if (mir_strcmp(gch->pDest->pszModule, m_szModuleName)) return 0; + if (mir_strcmp(gch->pszModule, m_szModuleName)) + return 0; - char *id = mir_u2a(gch->pDest->ptszID); + char *id = mir_u2a(gch->ptszID); chat_list_item* item = find_chat_by_id(id); + if (item == NULL) + return 0; - if (item == NULL) return 0; - - switch (gch->pDest->iType) { + switch (gch->iType) { case GC_SESSION_TERMINATE: aim_sendflap(item->hconn, 0x04, 0, NULL, item->seqno); Netlib_Shutdown(item->hconn); diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 2046ae149d..f9d38405cf 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -141,8 +141,7 @@ void CDiscordProto::OnCommandChannelUpdated(const JSONNode &pRoot) CMStringW wszTopic = pRoot["topic"].as_mstring(); Chat_SetStatusbarText(m_szModuleName, pUser->wszUsername, wszTopic); - GCDEST gcd = { m_szModuleName, pUser->wszUsername, GC_EVENT_TOPIC }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pUser->wszUsername, GC_EVENT_TOPIC }; gce.ptszText = wszTopic; gce.time = time(0); Chat_Event(&gce); @@ -275,8 +274,7 @@ void CDiscordProto::OnCommandGuildMemberRemoved(const JSONNode &pRoot) if (pUser.guildId != pGuild->id) continue; - GCDEST gcd = { m_szModuleName, pUser.wszUsername, GC_EVENT_PART }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pUser.wszUsername, GC_EVENT_PART }; gce.time = time(0); gce.ptszUID = wszUserId; Chat_Event(&gce); @@ -311,8 +309,7 @@ void CDiscordProto::OnCommandGuildMemberUpdated(const JSONNode &pRoot) wszOldNick = ui->pszNick; } - GCDEST gcd = { m_szModuleName, pUser.wszUsername, GC_EVENT_NICK }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pUser.wszUsername, GC_EVENT_NICK }; gce.time = time(0); gce.ptszUID = wszUserId; gce.ptszNick = wszOldNick; @@ -421,8 +418,7 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot) ParseSpecialChars(si, wszText); - GCDEST gcd = { m_szModuleName, pUser->wszUsername, GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pUser->wszUsername, GC_EVENT_MESSAGE }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = wszUserId; gce.ptszText = wszText; diff --git a/protocols/Discord/src/groupchat.cpp b/protocols/Discord/src/groupchat.cpp index 729afc84f0..825d8267d2 100644 --- a/protocols/Discord/src/groupchat.cpp +++ b/protocols/Discord/src/groupchat.cpp @@ -82,7 +82,7 @@ void CDiscordProto::Chat_SendPrivateMessage(GCHOOK *gch) return; setId(hContact, DB_KEY_ID, userId); - setId(hContact, DB_KEY_CHANNELID, _wtoi64(gch->pDest->ptszID)); + setId(hContact, DB_KEY_CHANNELID, _wtoi64(gch->ptszID)); setWString(hContact, "Nick", gch->ptszNick); db_set_b(hContact, "CList", "Hidden", 1); db_set_dw(hContact, "Ignore", "Mask1", 0); @@ -94,7 +94,7 @@ void CDiscordProto::Chat_SendPrivateMessage(GCHOOK *gch) void CDiscordProto::Chat_ProcessLogMenu(GCHOOK *gch) { - CDiscordUser *pUser = FindUserByChannel(_wtoi64(gch->pDest->ptszID)); + CDiscordUser *pUser = FindUserByChannel(_wtoi64(gch->ptszID)); if (pUser == nullptr) return; @@ -154,10 +154,10 @@ int CDiscordProto::GroupchatEventHook(WPARAM, LPARAM lParam) if (gch == nullptr) return 0; - if (mir_strcmpi(gch->pDest->pszModule, m_szModuleName)) + if (mir_strcmpi(gch->pszModule, m_szModuleName)) return 0; - switch (gch->pDest->iType) { + switch (gch->iType) { case GC_USER_MESSAGE: if (mir_wstrlen(gch->ptszText) > 0) { rtrimw(gch->ptszText); @@ -167,7 +167,7 @@ int CDiscordProto::GroupchatEventHook(WPARAM, LPARAM lParam) Chat_UnescapeTags(wszText); JSONNode body; body << WCHAR_PARAM("content", wszText); - CMStringA szUrl(FORMAT, "/channels/%S/messages", gch->pDest->ptszID); + CMStringA szUrl(FORMAT, "/channels/%S/messages", gch->ptszID); Push(new AsyncHttpRequest(this, REQUEST_POST, szUrl, &CDiscordProto::OnReceiveMessage, &body)); } } diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp index 4b89937cd6..dcc19ad354 100644 --- a/protocols/Discord/src/guilds.cpp +++ b/protocols/Discord/src/guilds.cpp @@ -112,8 +112,7 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS if (!wszTopic.IsEmpty()) { Chat_SetStatusbarText(m_szModuleName, wszChannelId, wszTopic); - GCDEST gcd = { m_szModuleName, wszChannelId, GC_EVENT_TOPIC }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, wszChannelId, GC_EVENT_TOPIC }; gce.time = time(0); gce.ptszText = wszTopic; Chat_Event(&gce); @@ -147,8 +146,7 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS void CDiscordProto::ApplyUsersToChannel(CDiscordGuild *pGuild, const CDiscordUser &pUser) { - GCDEST gcd = { m_szModuleName, pUser.wszUsername, GC_EVENT_JOIN }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pUser.wszUsername, GC_EVENT_JOIN }; gce.time = time(0); gce.dwFlags = GCEF_SILENT; diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index 60d713d4f2..1d48a3dc04 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -117,8 +117,7 @@ void CDiscordProto::OnReceiveHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest else { ParseSpecialChars(si, wszText); - GCDEST gcd = { m_szModuleName, pUser->wszUsername, GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pUser->wszUsername, GC_EVENT_MESSAGE }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = wszUserId; gce.ptszText = wszText; diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index 880077eb7d..966a7a0d76 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -35,8 +35,7 @@ void FacebookProto::UpdateChat(const char *chat_id, const char *id, const char * ptrW ttext(mir_a2u_cp(smessage.c_str(), CP_UTF8)); ptrW tchat_id(mir_a2u(chat_id)); - GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, tchat_id, GC_EVENT_MESSAGE }; gce.ptszText = ttext; gce.time = timestamp ? timestamp : ::time(NULL); if (id != NULL) @@ -64,19 +63,19 @@ int FacebookProto::OnGCEvent(WPARAM, LPARAM lParam) { GCHOOK *hook = reinterpret_cast(lParam); - if (mir_strcmp(hook->pDest->pszModule, m_szModuleName)) + if (mir_strcmp(hook->pszModule, m_szModuleName)) return 0; // Ignore for special chatrooms - if (!mir_wstrcmp(hook->pDest->ptszID, _A2W(FACEBOOK_NOTIFICATIONS_CHATROOM))) + if (!mir_wstrcmp(hook->ptszID, _A2W(FACEBOOK_NOTIFICATIONS_CHATROOM))) return 0; - switch (hook->pDest->iType) + switch (hook->iType) { case GC_USER_MESSAGE: { std::string msg = _T2A(hook->ptszText, CP_UTF8); - std::string chat_id = _T2A(hook->pDest->ptszID, CP_UTF8); + std::string chat_id = _T2A(hook->ptszID, CP_UTF8); if (isOnline()) { debugLogA(" > Chat - Outgoing message"); @@ -169,9 +168,7 @@ void FacebookProto::AddChatContact(const char *chat_id, const chatroom_participa ptrW tnick(mir_a2u_cp(user.nick.c_str(), CP_UTF8)); ptrW tid(mir_a2u(user.user_id.c_str())); - GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_JOIN }; - GCEVENT gce = { &gcd }; - gce.pDest = &gcd; + GCEVENT gce = { m_szModuleName, tchat_id, GC_EVENT_JOIN }; gce.dwFlags = addToLog ? GCEF_ADDTOLOG : 0; gce.ptszNick = tnick; gce.ptszUID = tid; @@ -208,8 +205,7 @@ void FacebookProto::RemoveChatContact(const char *chat_id, const char *id, const ptrW tnick(mir_a2u_cp(name, CP_UTF8)); ptrW tid(mir_a2u(id)); - GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_PART }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, tchat_id, GC_EVENT_PART }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tnick; gce.ptszUID = tid; @@ -418,8 +414,7 @@ void FacebookProto::UpdateNotificationsChatRoom(facebook_notification *notificat ptrW idT(mir_wstrdup(_A2W(FACEBOOK_NOTIFICATIONS_CHATROOM))); ptrW messageT(mir_a2u_cp(message.c_str(), CP_UTF8)); - GCDEST gcd = { m_szModuleName, _A2W(FACEBOOK_NOTIFICATIONS_CHATROOM), GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, _A2W(FACEBOOK_NOTIFICATIONS_CHATROOM), GC_EVENT_MESSAGE }; gce.ptszText = messageT; gce.time = notification->time ? notification->time : ::time(NULL); gce.bIsMe = false; diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index b33cab8717..0fb92afbe2 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -828,8 +828,7 @@ retry: wchar_t id[32]; UIN2IDT(e->event.msg.sender, id); - GCDEST gcd = { m_szModuleName, chat, GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, chat, GC_EVENT_MESSAGE }; time_t t = time(NULL); gce.ptszUID = id; wchar_t* messageT = mir_utf8decodeW(e->event.msg.message); @@ -892,8 +891,7 @@ retry: wchar_t id[32]; UIN2IDT(getDword(GG_KEY_UIN, 0), id); - GCDEST gcd = { m_szModuleName, chat, GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, chat, GC_EVENT_MESSAGE }; gce.ptszUID = id; wchar_t* messageT = mir_utf8decodeW(e->event.multilogon_msg.message); gce.ptszText = messageT; diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 2463ef22ca..f916ee62fd 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -113,18 +113,17 @@ int GGPROTO::gc_event(WPARAM, LPARAM lParam) // Check if we got our protocol, and fields are set if (!gch - || !gch->pDest - || !gch->pDest->ptszID - || !gch->pDest->pszModule - || mir_strcmpi(gch->pDest->pszModule, m_szModuleName) + || !gch->ptszID + || !gch->pszModule + || mir_strcmpi(gch->pszModule, m_szModuleName) || !(uin = getDword(GG_KEY_UIN, 0)) - || !(chat = gc_lookup(gch->pDest->ptszID))) + || !(chat = gc_lookup(gch->ptszID))) return 0; // Window terminated (Miranda exit) - if (gch->pDest->iType == SESSION_TERMINATE) + if (gch->iType == SESSION_TERMINATE) { - debugLogW(L"gc_event(): Terminating chat %x, id %s from chat window...", chat, gch->pDest->ptszID); + debugLogW(L"gc_event(): Terminating chat %x, id %s from chat window...", chat, gch->ptszID); // Destroy chat entry free(chat->recipients); list_remove(&chats, chat, 1); @@ -134,7 +133,7 @@ int GGPROTO::gc_event(WPARAM, LPARAM lParam) MCONTACT hNext = db_find_next(hContact); DBVARIANT dbv; if (!getWString(hContact, "ChatRoomID", &dbv)) { - if (dbv.ptszVal && !mir_wstrcmp(gch->pDest->ptszID, dbv.ptszVal)) + if (dbv.ptszVal && !mir_wstrcmp(gch->ptszID, dbv.ptszVal)) db_delete_contact(hContact); db_free(&dbv); } @@ -144,13 +143,12 @@ int GGPROTO::gc_event(WPARAM, LPARAM lParam) } // Message typed / send only if online - if (isonline() && (gch->pDest->iType == GC_USER_MESSAGE) && gch->ptszText) { + if (isonline() && (gch->iType == GC_USER_MESSAGE) && gch->ptszText) { wchar_t id[32]; UIN2IDT(uin, id); DBVARIANT dbv; - GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, gch->ptszID, GC_EVENT_MESSAGE }; gce.ptszUID = id; gce.ptszText = gch->ptszText; wchar_t* nickT; @@ -169,7 +167,7 @@ int GGPROTO::gc_event(WPARAM, LPARAM lParam) gce.time = time(NULL); gce.bIsMe = 1; gce.dwFlags = GCEF_ADDTOLOG; - debugLogW(L"gc_event(): Sending conference message to room %s, \"%s\".", gch->pDest->ptszID, gch->ptszText); + debugLogW(L"gc_event(): Sending conference message to room %s, \"%s\".", gch->ptszID, gch->ptszText); Chat_Event(&gce); mir_free(nickT); @@ -181,13 +179,13 @@ int GGPROTO::gc_event(WPARAM, LPARAM lParam) } // Privmessage selected - if (gch->pDest->iType == GC_USER_PRIVMESS) + if (gch->iType == GC_USER_PRIVMESS) { MCONTACT hContact = NULL; if ((uin = _wtoi(gch->ptszUID)) && (hContact = getcontact(uin, 1, 0, NULL))) CallService(MS_MSG_SENDMESSAGE, hContact, 0); } - debugLogW(L"gc_event(): Unhandled event %d, chat %x, uin %d, text \"%s\".", gch->pDest->iType, chat, uin, gch->ptszText); + debugLogW(L"gc_event(): Unhandled event %d, chat %x, uin %d, text \"%s\".", gch->iType, chat, uin, gch->ptszText); return 0; } @@ -316,8 +314,7 @@ wchar_t* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_cou // Add normal group Chat_AddGroup(m_szModuleName, chat->id, TranslateT("Participants")); - GCDEST gcd = { m_szModuleName, chat->id, GC_EVENT_JOIN }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, chat->id, GC_EVENT_JOIN }; gce.ptszUID = id; gce.dwFlags = GCEF_ADDTOLOG; @@ -603,9 +600,7 @@ int GGPROTO::gc_changenick(MCONTACT hContact, wchar_t *ptszNick) wchar_t id[32]; UIN2IDT(uin, id); - GCDEST gcd = { m_szModuleName, chat->id, GC_EVENT_NICK }; - GCEVENT gce = { &gcd }; - gce.pDest = &gcd; + GCEVENT gce = { m_szModuleName, chat->id, GC_EVENT_NICK }; gce.ptszUID = id; gce.ptszText = ptszNick; diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index df1316ec8b..a7d5974d56 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -1297,13 +1297,12 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) while (PrefixToStatus(sTemp[0]) != pwszNormal) sTemp.Delete(0, 1); - GCDEST gcd = { m_szModuleName, sID, GC_EVENT_JOIN }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, sID, GC_EVENT_JOIN }; gce.ptszUID = sTemp; gce.ptszNick = sTemp; gce.ptszStatus = sStat; - BOOL bIsMe = (!mir_wstrcmpi(gce.ptszNick, m_info.sNick)) ? TRUE : FALSE; - if (bIsMe) { + gce.bIsMe = (!mir_wstrcmpi(gce.ptszNick, m_info.sNick)) ? TRUE : FALSE; + if (gce.bIsMe) { char BitNr = -1; switch (sTemp2[0]) { case '+': BitNr = 0; break; @@ -1317,10 +1316,11 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) else btOwnMode = 0; } - gce.bIsMe = bIsMe; - gce.time = bIsMe ? time(0) : 0; + gce.time = gce.bIsMe ? time(0) : 0; Chat_Event(&gce); + DoEvent(GC_EVENT_SETCONTACTSTATUS, sChanName, sTemp, NULL, NULL, NULL, ID_STATUS_ONLINE, FALSE, FALSE); + // fix for networks like freshirc where they allow more than one prefix if (PrefixToStatus(sTemp2[0]) != pwszNormal) { sTemp2.Delete(0, 1); diff --git a/protocols/IRCG/src/scripting.cpp b/protocols/IRCG/src/scripting.cpp index e4ef002172..d510422a84 100644 --- a/protocols/IRCG/src/scripting.cpp +++ b/protocols/IRCG/src/scripting.cpp @@ -59,9 +59,8 @@ static void __stdcall OnHook(void * pi) GCHOOK* gch = (GCHOOK*)pi; free(gch->ptszUID); free(gch->ptszText); - free((void*)gch->pDest->ptszID); - free((void*)gch->pDest->pszModule); - delete gch->pDest; + free((void*)gch->ptszID); + free((void*)gch->pszModule); delete gch; } @@ -78,28 +77,28 @@ INT_PTR __cdecl CIrcProto::Scripting_InsertGuiOut(WPARAM, LPARAM lParam) if (m_scriptingEnabled && gch) { GCHOOK* gchook = new GCHOOK; - gchook->pDest = new GCDEST; - gchook->dwData = gch->dwData; - gchook->pDest->iType = gch->pDest->iType; + gchook->iType = gch->iType; if (gch->ptszText) gchook->ptszText = wcsdup(gch->ptszText); - else gchook->ptszText = NULL; + else + gchook->ptszText = NULL; if (gch->ptszUID) gchook->ptszUID = wcsdup(gch->ptszUID); else gchook->ptszUID = NULL; - if (gch->pDest->ptszID) { - CMStringW S = MakeWndID(gch->pDest->ptszID); - gchook->pDest->ptszID = wcsdup(S.c_str()); + if (gch->ptszID) { + CMStringW S = MakeWndID(gch->ptszID); + gchook->ptszID = wcsdup(S.c_str()); } - else gchook->pDest->ptszID = NULL; + else gchook->ptszID = NULL; - if (gch->pDest->pszModule) - gchook->pDest->pszModule = _strdup(gch->pDest->pszModule); - else gchook->pDest->pszModule = NULL; + if (gch->pszModule) + gchook->pszModule = _strdup(gch->pszModule); + else + gchook->pszModule = NULL; mir_forkthread(GuiOutThread, gchook); return 0; diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp index df95b79dbc..144b98f9bb 100644 --- a/protocols/IRCG/src/services.cpp +++ b/protocols/IRCG/src/services.cpp @@ -473,13 +473,13 @@ int __cdecl CIrcProto::GCEventHook(WPARAM, LPARAM lParam) // handle the hook if (gch) { - if (!mir_strcmpi(gch->pDest->pszModule, m_szModuleName)) { - wchar_t *p1 = mir_wstrdup(gch->pDest->ptszID); + if (!mir_strcmpi(gch->pszModule, m_szModuleName)) { + wchar_t *p1 = mir_wstrdup(gch->ptszID); wchar_t *p2 = wcsstr(p1, L" - "); if (p2) *p2 = '\0'; - switch (gch->pDest->iType) { + switch (gch->iType) { case GC_SESSION_TERMINATE: FreeWindowItemData(p1, (CHANNELINFO*)gch->dwData); break; diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp index 3efe9a248e..2ae539db46 100644 --- a/protocols/IRCG/src/tools.cpp +++ b/protocols/IRCG/src/tools.cpp @@ -380,7 +380,6 @@ INT_PTR CIrcProto::DoEvent(int iEvent, const wchar_t* pszWindow, const wchar_t* const wchar_t* pszText, const wchar_t* pszStatus, const wchar_t* pszUserInfo, DWORD_PTR dwItemData, bool bAddToLog, bool bIsMe, time_t timestamp) { - GCDEST gcd = { m_szModuleName, NULL, iEvent }; CMStringW sID; CMStringW sText; @@ -390,16 +389,16 @@ INT_PTR CIrcProto::DoEvent(int iEvent, const wchar_t* pszWindow, const wchar_t* if (pszText) sText = DoColorCodes(pszText, FALSE, TRUE); + GCEVENT gce = { m_szModuleName, NULL, iEvent }; if (pszWindow) { if (mir_wstrcmpi(pszWindow, SERVERWINDOW)) sID = pszWindow + (CMStringW)L" - " + m_info.sNetwork; else sID = pszWindow; - gcd.ptszID = (wchar_t*)sID.c_str(); + gce.ptszID = (wchar_t*)sID.c_str(); } - else gcd.ptszID = NULL; + else gce.ptszID = NULL; - GCEVENT gce = { &gcd }; gce.ptszStatus = pszStatus; gce.dwFlags = (bAddToLog) ? GCEF_ADDTOLOG : 0; gce.ptszNick = pszNick; diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 7958016283..dc92fabb9b 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -229,8 +229,7 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus if (!buf.IsEmpty()) { buf.Replace(L"%", L"%%"); - GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_INFORMATION }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, item->jid, GC_EVENT_INFORMATION }; gce.ptszNick = user->m_tszResourceName; gce.ptszUID = user->m_tszResourceName; gce.ptszText = buf; @@ -256,8 +255,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t if (myNick == nullptr) myNick = JabberNickFromJID(m_szJabberJID); - GCDEST gcd = { m_szModuleName, item->jid }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, item->jid }; gce.ptszNick = nick; gce.ptszUID = resource; if (jid != nullptr) @@ -268,11 +266,12 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t gce.time = time(0); } - switch (gcd.iType = action) { + switch (gce.iType = action) { case GC_EVENT_PART: break; case GC_EVENT_KICK: gce.ptszStatus = TranslateT("Moderator"); break; + default: mir_cslock lck(m_csLists); for (int i = 0; i < item->arResources.getCount(); i++) { @@ -281,7 +280,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t if (action != GC_EVENT_JOIN) { switch (action) { case 0: - gcd.iType = GC_EVENT_ADDSTATUS; + gce.iType = GC_EVENT_ADDSTATUS; case GC_EVENT_REMOVESTATUS: gce.dwFlags &= ~GCEF_ADDTOLOG; } @@ -303,10 +302,10 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t flags += GC_SSE_ONLINE; Chat_SetStatusEx(m_szModuleName, item->jid, flags, nick); + gce.iType = GC_EVENT_SETCONTACTSTATUS; gce.ptszText = nick; gce.ptszUID = resource; gce.dwItemData = statusToSet; - gcd.iType = GC_EVENT_SETCONTACTSTATUS; Chat_Event(&gce); } } @@ -1220,66 +1219,65 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g switch (gch->dwData) { case IDM_LST_PARTICIPANT: - ppro->AdminGet(gch->pDest->ptszID, JABBER_FEAT_MUC_ADMIN, L"role", L"participant", &CJabberProto::OnIqResultMucGetVoiceList); + ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"role", L"participant", &CJabberProto::OnIqResultMucGetVoiceList); break; case IDM_LST_MEMBER: - ppro->AdminGet(gch->pDest->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"member", &CJabberProto::OnIqResultMucGetMemberList); + ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"member", &CJabberProto::OnIqResultMucGetMemberList); break; case IDM_LST_MODERATOR: - ppro->AdminGet(gch->pDest->ptszID, JABBER_FEAT_MUC_ADMIN, L"role", L"moderator", &CJabberProto::OnIqResultMucGetModeratorList); + ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"role", L"moderator", &CJabberProto::OnIqResultMucGetModeratorList); break; case IDM_LST_BAN: - ppro->AdminGet(gch->pDest->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"outcast", &CJabberProto::OnIqResultMucGetBanList); + ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"outcast", &CJabberProto::OnIqResultMucGetBanList); break; case IDM_LST_ADMIN: - ppro->AdminGet(gch->pDest->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"admin", &CJabberProto::OnIqResultMucGetAdminList); + ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"admin", &CJabberProto::OnIqResultMucGetAdminList); break; case IDM_LST_OWNER: - ppro->AdminGet(gch->pDest->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"owner", &CJabberProto::OnIqResultMucGetOwnerList); + ppro->AdminGet(gch->ptszID, JABBER_FEAT_MUC_ADMIN, L"affiliation", L"owner", &CJabberProto::OnIqResultMucGetOwnerList); break; case IDM_TOPIC: - szTitle.Format(TranslateT("Set topic for %s"), gch->pDest->ptszID); + szTitle.Format(TranslateT("Set topic for %s"), gch->ptszID); szBuffer = item->getTemp()->m_tszStatusMessage; szBuffer.Replace(L"\n", L"\r\n"); if (ppro->EnterString(szBuffer, szTitle, ESF_RICHEDIT, "gcTopic_")) ppro->m_ThreadInfo->send( - XmlNode(L"message") << XATTR(L"to", gch->pDest->ptszID) << XATTR(L"type", L"groupchat") - << XCHILD(L"subject", szBuffer)); + XmlNode(L"message") << XATTR(L"to", gch->ptszID) << XATTR(L"type", L"groupchat") << XCHILD(L"subject", szBuffer)); break; case IDM_NICK: - szTitle.Format(TranslateT("Change nickname in %s"), gch->pDest->ptszID); + szTitle.Format(TranslateT("Change nickname in %s"), gch->ptszID); if (item->nick) szBuffer = item->nick; if (ppro->EnterString(szBuffer, szTitle, ESF_COMBO, "gcNick_")) { - if (ppro->ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID) != nullptr) { + if (ppro->ListGetItemPtr(LIST_CHATROOM, gch->ptszID) != nullptr) { wchar_t text[1024]; - mir_snwprintf(text, L"%s/%s", gch->pDest->ptszID, szBuffer.c_str()); + mir_snwprintf(text, L"%s/%s", gch->ptszID, szBuffer.c_str()); ppro->SendPresenceTo(ppro->m_iStatus == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : ppro->m_iStatus, text, nullptr); } } break; case IDM_INVITE: - (new CGroupchatInviteDlg(ppro, gch->pDest->ptszID))->Show(); + (new CGroupchatInviteDlg(ppro, gch->ptszID))->Show(); break; case IDM_CONFIG: ppro->m_ThreadInfo->send( - XmlNodeIq(ppro->AddIQ(&CJabberProto::OnIqResultGetMuc, JABBER_IQ_TYPE_GET, gch->pDest->ptszID)) + XmlNodeIq(ppro->AddIQ(&CJabberProto::OnIqResultGetMuc, JABBER_IQ_TYPE_GET, gch->ptszID)) << XQUERY(JABBER_FEAT_MUC_OWNER)); break; case IDM_BOOKMARKS: - item = ppro->ListGetItemPtr(LIST_BOOKMARK, gch->pDest->ptszID); + item = ppro->ListGetItemPtr(LIST_BOOKMARK, gch->ptszID); if (item == nullptr) { - item = ppro->ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID); + item = ppro->ListGetItemPtr(LIST_CHATROOM, gch->ptszID); if (item != nullptr) { item->type = L"conference"; MCONTACT hContact = ppro->HContactFromJID(item->jid); @@ -1290,10 +1288,10 @@ static void sttLogListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* g break; case IDM_DESTROY: - szTitle.Format(TranslateT("Reason to destroy %s"), gch->pDest->ptszID); + szTitle.Format(TranslateT("Reason to destroy %s"), gch->ptszID); if (ppro->EnterString(szBuffer, szTitle, ESF_MULTILINE, "gcReason_")) ppro->m_ThreadInfo->send( - XmlNodeIq(L"set", ppro->SerialNext(), gch->pDest->ptszID) << XQUERY(JABBER_FEAT_MUC_OWNER) + XmlNodeIq(L"set", ppro->SerialNext(), gch->ptszID) << XQUERY(JABBER_FEAT_MUC_OWNER) << XCHILD(L"destroy") << XCHILD(L"reason", szBuffer)); // fall through @@ -1368,14 +1366,14 @@ int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam) if (gch == nullptr) return 0; - if (mir_strcmpi(gch->pDest->pszModule, m_szModuleName)) + if (mir_strcmpi(gch->pszModule, m_szModuleName)) return 0; - JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID); + JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, gch->ptszID); if (item == nullptr) return 0; - switch (gch->pDest->iType) { + switch (gch->iType) { case GC_USER_MESSAGE: if (gch->ptszText && mir_wstrlen(gch->ptszText) > 0) { rtrimw(gch->ptszText); diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 00904b34ea..879b9bca10 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -797,8 +797,7 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const wchar_t * Chat_ChangeUserId(m_szModuleName, item->jid, oldNick, newNick); - GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_NICK }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, item->jid, GC_EVENT_NICK }; if (jid != nullptr) gce.ptszUserInfo = jid; gce.time = time(0); @@ -1033,7 +1032,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node) if (!mir_wstrcmp(type, L"error")) return; - GCDEST gcd = { m_szModuleName, item->jid, 0 }; + GCEVENT gce = { m_szModuleName, item->jid, 0 }; const wchar_t *msgText = nullptr; @@ -1046,7 +1045,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node) if (msgText == nullptr || msgText[0] == '\0') return; - gcd.iType = GC_EVENT_TOPIC; + gce.iType = GC_EVENT_TOPIC; if (resource == nullptr && (m = XmlGetChild(node, "body")) != nullptr) { const wchar_t *tmpnick = XmlGetText(m); @@ -1075,12 +1074,12 @@ void CJabberProto::GroupchatProcessMessage(HXML node) return; if (resource == nullptr) - gcd.iType = GC_EVENT_INFORMATION; + gce.iType = GC_EVENT_INFORMATION; else if (wcsncmp(msgText, L"/me ", 4) == 0 && mir_wstrlen(msgText) > 4) { msgText += 4; - gcd.iType = GC_EVENT_ACTION; + gce.iType = GC_EVENT_ACTION; } - else gcd.iType = GC_EVENT_MESSAGE; + else gce.iType = GC_EVENT_MESSAGE; } GcInit(item); @@ -1107,7 +1106,6 @@ void CJabberProto::GroupchatProcessMessage(HXML node) tszText.Replace(L"%", L"%%"); tszText += imgLink; - GCEVENT gce = { &gcd }; gce.ptszUID = resource; gce.ptszNick = nick; gce.time = msgTime; @@ -1124,7 +1122,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node) item->bChatActive = 2; - if (gcd.iType == GC_EVENT_TOPIC) + if (gce.iType == GC_EVENT_TOPIC) Chat_SetStatusbarText(m_szModuleName, item->jid, tszText); } diff --git a/protocols/MRA/src/MraChat.cpp b/protocols/MRA/src/MraChat.cpp index de0a69c52b..69e663239f 100644 --- a/protocols/MRA/src/MraChat.cpp +++ b/protocols/MRA/src/MraChat.cpp @@ -64,13 +64,12 @@ INT_PTR CMraProto::MraChatSessionEventSendByHandle(MCONTACT hContactChatSession, CMStringW wszID, wszUID, wszNick; - GCDEST gcd = { m_szModuleName, 0, iType }; + GCEVENT gce = { m_szModuleName, 0, iType }; if (hContactChatSession) { mraGetStringW(hContactChatSession, "e-mail", wszID); - gcd.ptszID = (LPWSTR)wszID.c_str(); + gce.ptszID = wszID.c_str(); } - GCEVENT gce = { &gcd }; gce.dwFlags = dwFlags; gce.ptszUID = wszUID; gce.ptszStatus = lpwszStatus; @@ -167,11 +166,11 @@ int CMraProto::MraChatGcEventHook(WPARAM, LPARAM lParam) if (bChatExists) { GCHOOK* gch = (GCHOOK*)lParam; - if (!_stricmp(gch->pDest->pszModule, m_szModuleName)) { - switch (gch->pDest->iType) { + if (!_stricmp(gch->pszModule, m_szModuleName)) { + switch (gch->iType) { case GC_USER_MESSAGE: if (gch->ptszText && mir_wstrlen(gch->ptszText)) { - CMStringA szEmail = gch->pDest->ptszID; + CMStringA szEmail = gch->ptszID; MCONTACT hContact = MraHContactFromEmail(szEmail, FALSE, TRUE, NULL); BOOL bSlowSend = getByte("SlowSend", MRA_DEFAULT_SLOW_SEND); diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index d6983751a5..b971c362e2 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -135,7 +135,7 @@ void CMsnProto::MSN_KillChatSession(const wchar_t* id) void CMsnProto::MSN_Kickuser(GCHOOK *gch) { - GCThreadData *thread = MSN_GetThreadByChatId(gch->pDest->ptszID); + GCThreadData *thread = MSN_GetThreadByChatId(gch->ptszID); msnNsThread->sendPacketPayload("DEL", "MSGR\\THREAD", "%d:%s%s", thread->netId, thread->szEmail, _T2A(gch->ptszUID)); @@ -143,7 +143,7 @@ void CMsnProto::MSN_Kickuser(GCHOOK *gch) void CMsnProto::MSN_Promoteuser(GCHOOK *gch, const char *pszRole) { - GCThreadData *thread = MSN_GetThreadByChatId(gch->pDest->ptszID); + GCThreadData *thread = MSN_GetThreadByChatId(gch->ptszID); msnNsThread->sendPacketPayload("PUT", "MSGR\\THREAD", "%d:%s%s%s", thread->netId, thread->szEmail, _T2A(gch->ptszUID), pszRole); @@ -163,8 +163,7 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID { if (!mir_strcmp(xmli->name, "topicupdate")) { ezxml_t initiator = ezxml_child(xmli, "initiator"); - GCDEST gcd = { m_szModuleName, mChatID, GC_EVENT_TOPIC}; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, mChatID, GC_EVENT_TOPIC }; gce.dwFlags = GCEF_ADDTOLOG; gce.time = MsnTSToUnixtime(ezxml_txt(ezxml_child(xmli, "eventtime"))); gce.ptszUID = initiator ? mir_a2u(initiator->txt) : NULL; @@ -177,25 +176,24 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID } else if (ezxml_t target = ezxml_child(xmli, "target")) { MCONTACT hContInitiator = NULL; - GCDEST gcd = { m_szModuleName, mChatID, 0}; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, mChatID, 0 }; gce.dwFlags = GCEF_ADDTOLOG; if (!mir_strcmp(xmli->name, "deletemember")) { - gcd.iType = GC_EVENT_PART; + gce.iType = GC_EVENT_PART; if (ezxml_t initiator = ezxml_child(xmli, "initiator")) { if (mir_strcmp(initiator->txt, target->txt)) { hContInitiator = MSN_HContactFromEmail(initiator->txt); gce.ptszStatus = GetContactNameT(hContInitiator); - gcd.iType = GC_EVENT_KICK; + gce.iType = GC_EVENT_KICK; } } } else if (!mir_strcmp(xmli->name, "addmember")) { - gcd.iType = GC_EVENT_JOIN; + gce.iType = GC_EVENT_JOIN; } else if (!mir_strcmp(xmli->name, "roleupdate")) { - gcd.iType = GC_EVENT_ADDSTATUS; + gce.iType = GC_EVENT_ADDSTATUS; if (ezxml_t initiator = ezxml_child(xmli, "initiator")) { hContInitiator = MSN_HContactFromEmail(initiator->txt); gce.ptszText= GetContactNameT(hContInitiator); @@ -203,12 +201,12 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID gce.ptszStatus = L"admin"; } - if (gcd.iType) { + if (gce.iType) { gce.time = MsnTSToUnixtime(ezxml_txt(ezxml_child(xmli, "eventtime"))); const char *pszTarget = NULL; while (target) { - switch (gcd.iType) { + switch (gce.iType) { case GC_EVENT_JOIN: gce.ptszStatus = MSN_GCGetRole(MSN_GetThreadByChatId(mChatID), target->txt); // ..fall through.. // @@ -218,7 +216,7 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID break; case GC_EVENT_ADDSTATUS: case GC_EVENT_REMOVESTATUS: - gcd.iType = mir_strcmp(ezxml_txt(ezxml_child(target, "role")), "admin") == 0 ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS; + gce.iType = mir_strcmp(ezxml_txt(ezxml_child(target, "role")), "admin") == 0 ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS; pszTarget = ezxml_txt(ezxml_child(target, "id")); break; } @@ -230,7 +228,7 @@ void CMsnProto::MSN_GCProcessThreadActivity(ezxml_t xmli, const wchar_t *mChatID gce.ptszNick = GetContactNameT(hContTarget); Chat_Event(&gce); mir_free((wchar_t*)gce.ptszUID); - if ((gcd.iType == GC_EVENT_PART || gcd.iType == GC_EVENT_KICK) && gce.bIsMe) { + if ((gce.iType == GC_EVENT_PART || gce.iType == GC_EVENT_KICK) && gce.bIsMe) { Chat_Control(m_szModuleName, mChatID, SESSION_OFFLINE); break; } @@ -263,8 +261,7 @@ void CMsnProto::MSN_GCRefreshThreadsInfo(void) void CMsnProto::MSN_GCAddMessage(wchar_t *mChatID, MCONTACT hContact, char *email, time_t ts, bool sentMsg, char *msgBody) { - GCDEST gcd = { m_szModuleName, mChatID, GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, mChatID, GC_EVENT_MESSAGE }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = mir_a2u(email); gce.ptszNick = GetContactNameT(hContact); @@ -457,12 +454,12 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) if (!gch) return 1; - if (_stricmp(gch->pDest->pszModule, m_szModuleName)) return 0; + if (_stricmp(gch->pszModule, m_szModuleName)) return 0; - switch (gch->pDest->iType) { + switch (gch->iType) { case GC_SESSION_TERMINATE: { - GCThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID); + GCThreadData* thread = MSN_GetThreadByChatId(gch->ptszID); if (thread != NULL) { m_arGCThreads.remove(thread); for (int i = 0; i < thread->mJoinedContacts.getCount(); i++) @@ -474,7 +471,7 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) case GC_USER_MESSAGE: if (gch->ptszText && gch->ptszText[0]) { - GCThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID); + GCThreadData* thread = MSN_GetThreadByChatId(gch->ptszID); if (thread) { wchar_t* pszMsg = Chat_UnescapeTags(NEWWSTR_ALLOCA(gch->ptszText)); rtrimw(pszMsg); // remove the ending linebreak @@ -483,8 +480,7 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) DBVARIANT dbv; int bError = getWString("Nick", &dbv); - GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, gch->ptszID, GC_EVENT_MESSAGE }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = bError ? L"" : dbv.ptszVal; gce.ptszUID = mir_a2u(MyOptions.szEmail); @@ -502,7 +498,7 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) case GC_USER_CHANMGR: DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, DlgInviteToChat, - LPARAM(new InviteChatParam(gch->pDest->ptszID, NULL, this))); + LPARAM(new InviteChatParam(gch->ptszID, NULL, this))); break; case GC_USER_PRIVMESS: @@ -513,11 +509,11 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) switch (gch->dwData) { case 10: DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, DlgInviteToChat, - LPARAM(new InviteChatParam(gch->pDest->ptszID, NULL, this))); + LPARAM(new InviteChatParam(gch->ptszID, NULL, this))); break; case 20: - MSN_KillChatSession(gch->pDest->ptszID); + MSN_KillChatSession(gch->ptszID); break; } break; @@ -537,11 +533,11 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) break; case 110: - MSN_KillChatSession(gch->pDest->ptszID); + MSN_KillChatSession(gch->ptszID); break; case 40: - const wchar_t *pszRole = MSN_GCGetRole(MSN_GetThreadByChatId(gch->pDest->ptszID), _T2A(gch->ptszUID)); + const wchar_t *pszRole = MSN_GCGetRole(MSN_GetThreadByChatId(gch->ptszID), _T2A(gch->ptszUID)); MSN_Promoteuser(gch, (pszRole && !mir_wstrcmp(pszRole, L"admin")) ? "user" : "admin"); break; } diff --git a/protocols/MinecraftDynmap/src/chat.cpp b/protocols/MinecraftDynmap/src/chat.cpp index 9da4b85703..cbaf735acf 100644 --- a/protocols/MinecraftDynmap/src/chat.cpp +++ b/protocols/MinecraftDynmap/src/chat.cpp @@ -30,13 +30,12 @@ void MinecraftDynmapProto::UpdateChat(const char *name, const char *message, con ptrW tmessage(mir_a2u_cp(smessage.c_str(), CP_UTF8)); ptrW tname(mir_a2u_cp(name, CP_UTF8)); - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE }; gce.time = timestamp; gce.ptszText = tmessage; if (tname == NULL) { - gcd.iType = GC_EVENT_INFORMATION; + gce.iType = GC_EVENT_INFORMATION; tname = mir_wstrdup(TranslateT("Server")); gce.bIsMe = false; } @@ -54,10 +53,10 @@ int MinecraftDynmapProto::OnChatEvent(WPARAM, LPARAM lParam) { GCHOOK *hook = reinterpret_cast(lParam); - if(strcmp(hook->pDest->pszModule,m_szModuleName)) + if(strcmp(hook->pszModule,m_szModuleName)) return 0; - switch(hook->pDest->iType) + switch(hook->iType) { case GC_USER_MESSAGE: { @@ -90,8 +89,7 @@ void MinecraftDynmapProto::AddChatContact(const char *name) { ptrW tname(mir_a2u_cp(name, CP_UTF8)); - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN }; gce.time = DWORD(time(0)); gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tname; @@ -110,8 +108,7 @@ void MinecraftDynmapProto::DeleteChatContact(const char *name) { ptrW tname(mir_a2u_cp(name, CP_UTF8)); - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_PART }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_PART }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tname; gce.ptszUID = gce.ptszNick; @@ -146,8 +143,7 @@ void MinecraftDynmapProto::SetTopic(const char *topic) { ptrW ttopic(mir_a2u_cp(topic, CP_UTF8)); - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_TOPIC }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_TOPIC }; gce.time = ::time(NULL); gce.ptszText = ttopic; diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp index eb6c613875..4967e06727 100644 --- a/protocols/Omegle/src/chat.cpp +++ b/protocols/Omegle/src/chat.cpp @@ -27,13 +27,12 @@ void OmegleProto::UpdateChat(const wchar_t *name, const wchar_t *message, bool a std::wstring smessage = message; utils::text::treplace_all(&smessage, L"%", L"%%"); - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE }; gce.time = ::time(NULL); gce.ptszText = smessage.c_str(); if (name == NULL) { - gcd.iType = GC_EVENT_INFORMATION; + gce.iType = GC_EVENT_INFORMATION; name = TranslateT("Server"); gce.bIsMe = false; } @@ -51,10 +50,10 @@ int OmegleProto::OnChatEvent(WPARAM, LPARAM lParam) { GCHOOK *hook = reinterpret_cast(lParam); - if (mir_strcmp(hook->pDest->pszModule, m_szModuleName)) + if (mir_strcmp(hook->pszModule, m_szModuleName)) return 0; - switch (hook->pDest->iType) + switch (hook->iType) { case GC_USER_MESSAGE: { @@ -228,8 +227,7 @@ Chat_Event(WINDOW_CLEARLOG,&gce); void OmegleProto::AddChatContact(const wchar_t *name) { - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN }; gce.time = DWORD(time(0)); gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = name; @@ -250,8 +248,7 @@ void OmegleProto::AddChatContact(const wchar_t *name) void OmegleProto::DeleteChatContact(const wchar_t *name) { - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_PART }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_PART }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = name; gce.ptszUID = gce.ptszNick; @@ -287,8 +284,7 @@ INT_PTR OmegleProto::OnJoinChat(WPARAM, LPARAM suppress) void OmegleProto::SetTopic(const wchar_t *topic) { - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_TOPIC }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_TOPIC }; gce.time = ::time(NULL); if (topic == NULL) diff --git a/protocols/Sametime/src/conference.cpp b/protocols/Sametime/src/conference.cpp index 04af2e7372..6a517c6a94 100644 --- a/protocols/Sametime/src/conference.cpp +++ b/protocols/Sametime/src/conference.cpp @@ -118,8 +118,7 @@ void mwServiceConf_conf_opened(mwConference* conf, GList* members) Chat_AddGroup(proto->m_szModuleName, tszConfId, TranslateT("Normal")); // add users - GCDEST gcd = { proto->m_szModuleName, tszConfId, GC_EVENT_JOIN }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { proto->m_szModuleName, tszConfId, GC_EVENT_JOIN }; GList *user = members; for (;user; user=user->next) { @@ -180,11 +179,7 @@ void mwServiceConf_on_peer_joined(mwConference* conf, mwLoginInfo *user) ptrW tszUserId(mir_utf8decodeW(user->login_id)); // add user - GCDEST gcd = { proto->m_szModuleName }; - gcd.ptszID = tszConfId; - gcd.iType = GC_EVENT_JOIN; - - GCEVENT gce = { &gcd }; + GCEVENT gce = { proto->m_szModuleName, tszConfId, GC_EVENT_JOIN }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tszUserName; gce.ptszUID = tszUserId; @@ -209,11 +204,7 @@ void mwServiceConf_on_peer_parted(mwConference* conf, mwLoginInfo* user) ptrW tszUserId(mir_utf8decodeW(user->login_id)); // remove user - GCDEST gcd = { proto->m_szModuleName }; - gcd.ptszID = tszConfId; - gcd.iType = GC_EVENT_PART; - - GCEVENT gce = { &gcd }; + GCEVENT gce = { proto->m_szModuleName, tszConfId, GC_EVENT_PART }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tszUserName; gce.ptszUID = tszUserId; @@ -228,29 +219,18 @@ void mwServiceConf_on_text(mwConference* conf, mwLoginInfo* user, const char* wh CSametimeProto* proto = getProtoFromMwConference(conf); proto->debugLogW(L"mwServiceConf_on_text() start"); - wchar_t* tszConfId = mir_utf8decodeW(mwConference_getName(conf)); - - GCDEST gcd = { proto->m_szModuleName }; - gcd.ptszID = tszConfId; - gcd.iType = GC_EVENT_MESSAGE; + ptrW textT(mir_utf8decodeW(what)); + ptrW tszConfId(mir_utf8decodeW(mwConference_getName(conf))); + ptrW tszUserId(mir_utf8decodeW(user->login_id)); + ptrW tszUserName(mir_utf8decodeW(user->user_name)); - GCEVENT gce = { &gcd }; + GCEVENT gce = { proto->m_szModuleName, tszConfId, GC_EVENT_MESSAGE }; gce.dwFlags = GCEF_ADDTOLOG; - - wchar_t* textT = mir_utf8decodeW(what); - wchar_t* tszUserName = mir_utf8decodeW(user->user_name); - wchar_t* tszUserId = mir_utf8decodeW(user->login_id); gce.ptszText = textT; gce.ptszNick = tszUserName; gce.ptszUID = tszUserId; gce.time = (DWORD)time(0); - Chat_Event(&gce); - - mir_free(textT); - mir_free(tszUserName); - mir_free(tszUserId); - mir_free(tszConfId); } /** typing notification */ @@ -295,13 +275,13 @@ int CSametimeProto::GcEventHook(WPARAM wParam, LPARAM lParam) { GCHOOK* gch = (GCHOOK*)lParam; - if (strcmp(gch->pDest->pszModule, m_szModuleName) != 0) return 0; + if (strcmp(gch->pszModule, m_szModuleName) != 0) return 0; GList *conferences = mwServiceConference_getConferences(service_conference); for (GList *conf = conferences;conf;conf = conf->next) { wchar_t* tszConfId = mir_utf8decodeW(mwConference_getName((mwConference*)conf->data)); - if (mir_wstrcmp(gch->pDest->ptszID, tszConfId) == 0) { - switch(gch->pDest->iType) { + if (mir_wstrcmp(gch->ptszID, tszConfId) == 0) { + switch(gch->iType) { case GC_USER_MESSAGE: { debugLogW(L"CSametimeProto::GcEventHook() GC_USER_MESSAGE"); diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 223b3880cc..85ffc6a5dc 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -107,14 +107,14 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam) if (!gch) return 1; - if (mir_strcmp(gch->pDest->pszModule, m_szModuleName) != 0) + if (mir_strcmp(gch->pszModule, m_szModuleName) != 0) return 0; - _T2A chat_id(gch->pDest->ptszID); + _T2A chat_id(gch->ptszID); - switch (gch->pDest->iType) { + switch (gch->iType) { case GC_USER_MESSAGE: - OnSendChatMessage(gch->pDest->ptszID, gch->ptszText); + OnSendChatMessage(gch->ptszID, gch->ptszText); break; case GC_USER_PRIVMESS: @@ -208,9 +208,7 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam) if (!mir_wstrcmp(tnick_old, tnick_new)) break; // New nick is same, do nothing - GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_NICK }; - GCEVENT gce = { &gcd }; - + GCEVENT gce = { m_szModuleName, gch->ptszID, GC_EVENT_NICK }; gce.ptszNick = tnick_old; gce.bIsMe = IsMe(user_id); gce.ptszUID = gch->ptszUID; @@ -360,13 +358,11 @@ void CSkypeProto::OnChatEvent(const JSONNode &node) CMStringA initiator = ParseUrl(xinitiator, "8:"); CMStringA id = ParseUrl(xId, "8:"); - - GCDEST gcd = { m_szModuleName, _A2T(szConversationName), !mir_strcmpi(xRole, "Admin") ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS }; - GCEVENT gce = { &gcd }; ptrW tszId(mir_a2u(id)); ptrW tszRole(mir_a2u(xRole)); ptrW tszInitiator(mir_a2u(initiator)); - gce.pDest = &gcd; + + GCEVENT gce = { m_szModuleName, _A2T(szConversationName), !mir_strcmpi(xRole, "Admin") ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tszId; gce.ptszUID = tszId; @@ -399,11 +395,9 @@ void CSkypeProto::OnSendChatMessage(const wchar_t *chat_id, const wchar_t * tszM void CSkypeProto::AddMessageToChat(const wchar_t *chat_id, const wchar_t *from, const char *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading) { - GCDEST gcd = { m_szModuleName, chat_id, isAction ? GC_EVENT_ACTION : GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; - ptrW tnick(GetChatContactNick(_T2A(chat_id), _T2A(from), _T2A(from))); + GCEVENT gce = { m_szModuleName, chat_id, isAction ? GC_EVENT_ACTION : GC_EVENT_MESSAGE }; gce.bIsMe = IsMe(_T2A(from)); gce.ptszNick = tnick; gce.time = timestamp; @@ -418,7 +412,8 @@ void CSkypeProto::AddMessageToChat(const wchar_t *chat_id, const wchar_t *from, } else gce.ptszText = &(tszText.GetBuffer())[emoteOffset]; - if (isLoading) gce.dwFlags = GCEF_NOTNOTIFY; + if (isLoading) + gce.dwFlags |= GCEF_NOTNOTIFY; Chat_Event(&gce); } @@ -464,8 +459,7 @@ void CSkypeProto::ChangeChatTopic(const char *chat_id, const char *topic, const ptrW tname(mir_a2u(initiator)); ptrW ttopic(mir_utf8decodeW(topic)); - GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_TOPIC }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, tchat_id, GC_EVENT_TOPIC }; gce.ptszUID = tname; gce.ptszNick = tname; gce.ptszText = ttopic; @@ -530,9 +524,7 @@ void CSkypeProto::AddChatContact(const wchar_t *tchat_id, const char *id, const ptrW tnick(GetChatContactNick(_T2A(tchat_id), id, name)); ptrW tid(mir_a2u(id)); - GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_JOIN }; - GCEVENT gce = { &gcd }; - gce.pDest = &gcd; + GCEVENT gce = { m_szModuleName, tchat_id, GC_EVENT_JOIN }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tnick; gce.ptszUID = tid; @@ -552,8 +544,7 @@ void CSkypeProto::RemoveChatContact(const wchar_t *tchat_id, const char *id, con ptrW tinitiator(GetChatContactNick(_T2A(tchat_id), initiator, initiator)); ptrW tid(mir_a2u(id)); - GCDEST gcd = { m_szModuleName, tchat_id, isKick ? GC_EVENT_KICK : GC_EVENT_PART }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, tchat_id, isKick ? GC_EVENT_KICK : GC_EVENT_PART }; if (isKick) { gce.ptszUID = tid; gce.ptszNick = tnick; diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp index 491ab50848..b323d0dbfc 100644 --- a/protocols/Twitter/src/chat.cpp +++ b/protocols/Twitter/src/chat.cpp @@ -24,9 +24,7 @@ along with this program. If not, see . void TwitterProto::UpdateChat(const twitter_user &update) { - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; - gce.pDest = &gcd; + GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE }; gce.bIsMe = (update.username == twit_.get_username()); gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = mir_a2u(update.username.c_str()); @@ -59,10 +57,10 @@ void TwitterProto::UpdateChat(const twitter_user &update) int TwitterProto::OnChatOutgoing(WPARAM, LPARAM lParam) { GCHOOK *hook = reinterpret_cast(lParam); - if (mir_strcmp(hook->pDest->pszModule, m_szModuleName)) + if (mir_strcmp(hook->pszModule, m_szModuleName)) return 0; - switch (hook->pDest->iType) { + switch (hook->iType) { case GC_USER_MESSAGE: debugLogW(L"**Chat - Outgoing message: %s", hook->ptszText); { @@ -90,28 +88,26 @@ int TwitterProto::OnChatOutgoing(WPARAM, LPARAM lParam) // TODO: remove nick? void TwitterProto::AddChatContact(const char *name, const char *nick) { - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN }; - GCEVENT gce = { &gcd }; + ptrW wszId(mir_a2u(name)); + ptrW wszNick(mir_a2u(nick ? nick : name)); + + GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN }; gce.time = DWORD(time(0)); - gce.ptszNick = mir_a2u(nick ? nick : name); - gce.ptszUID = mir_a2u(name); + gce.ptszNick = wszNick; + gce.ptszUID = wszId; gce.ptszStatus = L"Normal"; Chat_Event(&gce); - - mir_free(const_cast(gce.ptszNick)); - mir_free(const_cast(gce.ptszUID)); } void TwitterProto::DeleteChatContact(const char *name) { - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_PART }; - GCEVENT gce = { &gcd }; + ptrW wszId(mir_a2u(name)); + + GCEVENT gce = { m_szModuleName, m_tszUserName, GC_EVENT_PART }; gce.time = DWORD(time(0)); - gce.ptszNick = mir_a2u(name); + gce.ptszNick = wszId; gce.ptszUID = gce.ptszNick; Chat_Event(&gce); - - mir_free(const_cast(gce.ptszNick)); } INT_PTR TwitterProto::OnJoinChat(WPARAM, LPARAM suppress) diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 43eb705527..253856cd97 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -163,8 +163,7 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe cu->m_bUnknown = false; if (bNew) { - GCDEST gcd = { m_szModuleName, cc->m_wszId, GC_EVENT_JOIN }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, cc->m_wszId, GC_EVENT_JOIN }; gce.bIsMe = uid == m_myUserId; gce.ptszUID = wszId; gce.ptszNick = wszNick; @@ -182,8 +181,7 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe wchar_t wszId[20]; _itow(cu.m_uid, wszId, 10); - GCDEST gcd = { m_szModuleName, cc->m_wszId, GC_EVENT_PART }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, cc->m_wszId, GC_EVENT_PART }; gce.ptszUID = wszId; gce.dwFlags = GCEF_NOTNOTIFY; gce.time = time(nullptr); @@ -397,8 +395,7 @@ void CVkProto::AppendChatMessage(CVkChatInfo *cc, int uid, int msgTime, LPCWSTR wchar_t wszId[20]; _itow(uid, wszId, 10); - GCDEST gcd = { m_szModuleName, cc->m_wszId, bIsAction ? GC_EVENT_ACTION : GC_EVENT_MESSAGE }; - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, cc->m_wszId, bIsAction ? GC_EVENT_ACTION : GC_EVENT_MESSAGE }; gce.bIsMe = (uid == m_myUserId); gce.ptszUID = wszId; gce.time = msgTime; @@ -441,14 +438,14 @@ int CVkProto::OnChatEvent(WPARAM, LPARAM lParam) if (gch == nullptr) return 0; - if (mir_strcmpi(gch->pDest->pszModule, m_szModuleName)) + if (mir_strcmpi(gch->pszModule, m_szModuleName)) return 0; - CVkChatInfo *cc = GetChatById(gch->pDest->ptszID); + CVkChatInfo *cc = GetChatById(gch->ptszID); if (cc == nullptr) return 0; - switch (gch->pDest->iType) { + switch (gch->iType) { case GC_USER_MESSAGE: if (IsOnline() && mir_wstrlen(gch->ptszText) > 0) { ptrW pwszBuf(mir_wstrdup(gch->ptszText)); @@ -730,12 +727,10 @@ void CVkProto::NickMenuHook(CVkChatInfo *cc, GCHOOK *gch) if (wszNewNick.IsEmpty() || wszNewNick == cu->m_wszNick) break; - GCDEST gcd = { m_szModuleName, cc->m_wszId, GC_EVENT_NICK }; - GCEVENT gce = { &gcd }; - wchar_t wszId[20]; _itow(cu->m_uid, wszId, 10); + GCEVENT gce = { m_szModuleName, cc->m_wszId, GC_EVENT_NICK }; gce.ptszNick = mir_wstrdup(cu->m_wszNick); gce.bIsMe = (cu->m_uid == m_myUserId); gce.ptszUID = wszId; diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index 38f4878f7d..3fc47cb8f9 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -40,15 +40,15 @@ INT_PTR __cdecl WhatsAppProto::OnCreateGroup(WPARAM, LPARAM) int WhatsAppProto::onGroupChatEvent(WPARAM, LPARAM lParam) { GCHOOK *gch = (GCHOOK*)lParam; - if (mir_strcmp(gch->pDest->pszModule, m_szModuleName)) + if (mir_strcmp(gch->pszModule, m_szModuleName)) return 0; - std::string chat_id(T2Utf(gch->pDest->ptszID)); + std::string chat_id(T2Utf(gch->ptszID)); WAChatInfo *pInfo = SafeGetChat(chat_id); if (pInfo == NULL) return 0; - switch (gch->pDest->iType) { + switch (gch->iType) { case GC_USER_LOGMENU: ChatLogMenuHook(pInfo, gch); break; @@ -379,9 +379,7 @@ void WhatsAppProto::onGroupMessage(const FMessage &pMsg) ptrW tszUID(str2t(pMsg.remote_resource)); ptrW tszNick(GetChatUserNick(pMsg.remote_resource)); - GCDEST gcd = { m_szModuleName, pInfo->tszJid, GC_EVENT_MESSAGE }; - - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pInfo->tszJid, GC_EVENT_MESSAGE }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = tszUID; gce.ptszNick = tszNick; @@ -408,9 +406,7 @@ void WhatsAppProto::onGroupNewSubject(const std::string &gjid, const std::string ptrW tszUID(str2t(author)); ptrW tszNick(GetChatUserNick(author)); - GCDEST gcd = { m_szModuleName, pInfo->tszJid, GC_EVENT_TOPIC }; - - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pInfo->tszJid, GC_EVENT_TOPIC }; gce.dwFlags = GCEF_ADDTOLOG + ((ts == 0) ? GCEF_NOTNOTIFY : 0); gce.ptszUID = tszUID; gce.ptszNick = tszNick; @@ -430,9 +426,7 @@ void WhatsAppProto::onGroupAddUser(const std::string &gjid, const std::string &u ptrW tszUID(str2t(ujid)); ptrW tszNick(GetChatUserNick(ujid)); - GCDEST gcd = { m_szModuleName, pInfo->tszJid, GC_EVENT_JOIN }; - - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pInfo->tszJid, GC_EVENT_JOIN }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = tszUID; gce.ptszNick = tszNick; @@ -449,9 +443,7 @@ void WhatsAppProto::onGroupRemoveUser(const std::string &gjid, const std::string ptrW tszUID(str2t(ujid)); ptrW tszNick(GetChatUserNick(ujid)); - GCDEST gcd = { m_szModuleName, pInfo->tszJid, GC_EVENT_PART }; - - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pInfo->tszJid, GC_EVENT_PART }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = tszUID; gce.ptszNick = tszNick; @@ -486,9 +478,7 @@ void WhatsAppProto::onGetParticipants(const std::string &gjid, const std::vector ptrW ujid(str2t(curr)), nick(GetChatUserNick(curr)); bool bIsOwner = !mir_wstrcmp(ujid, pInfo->tszOwner); - GCDEST gcd = { m_szModuleName, pInfo->tszJid, GC_EVENT_JOIN }; - - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pInfo->tszJid, GC_EVENT_JOIN }; gce.ptszNick = nick; gce.ptszUID = utils::removeA(ujid); gce.ptszStatus = (bIsOwner) ? L"Owners" : L"Members"; @@ -519,9 +509,7 @@ void WhatsAppProto::onGroupMessageReceived(const FMessage &msg) ptrW tszUID(str2t(m_szJid)); ptrW tszNick(str2t(m_szNick)); - GCDEST gcd = { m_szModuleName, pInfo->tszJid, GC_EVENT_MESSAGE }; - - GCEVENT gce = { &gcd }; + GCEVENT gce = { m_szModuleName, pInfo->tszJid, GC_EVENT_MESSAGE }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = tszUID; gce.ptszNick = tszNick; diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index 3afa17bccc..913c3d0987 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -121,14 +121,14 @@ static void OnFlashWindow(SESSION_INFO *si, int bInactive) static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) { - if (gce->pDest->iType & g_Settings.dwTrayIconFlags) + if (gce->iType & g_Settings.dwTrayIconFlags) return oldDoTrayIcon(si, gce); return TRUE; } static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) { - if (gce->pDest->iType & g_Settings.dwPopupFlags) + if (gce->iType & g_Settings.dwPopupFlags) return oldDoPopup(si, gce); return TRUE; } diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 141faa2be0..93f9ebe728 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -207,7 +207,7 @@ BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool LOGINFO *li = chatApi.LM_AddEvent(&si->pLog, &si->pLogEnd); si->iEventCount++; - li->iType = gce->pDest->iType; + li->iType = gce->iType; li->ptszNick = mir_wstrdup(gce->ptszNick); li->ptszText = mir_wstrdup(gce->ptszText); li->ptszStatus = mir_wstrdup(gce->ptszStatus); diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 1de51605e6..2b4458593d 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -374,7 +374,7 @@ MIR_APP_DLL(int) Chat_Terminate(const char *szModule, const wchar_t *wszId, bool static void AddUser(GCEVENT *gce) { - SESSION_INFO *si = chatApi.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); + SESSION_INFO *si = chatApi.SM_FindSession(gce->ptszID, gce->pszModule); if (si == nullptr) return; @@ -407,7 +407,7 @@ static BOOL AddEventToAllMatchingUID(GCEVENT *gce) for (int i = 0; i < g_arSessions.getCount(); i++) { SESSION_INFO *si = g_arSessions[i]; - if (!si->bInitDone || mir_strcmpi(si->pszModule, gce->pDest->pszModule)) + if (!si->bInitDone || mir_strcmpi(si->pszModule, gce->pszModule)) continue; if (!chatApi.UM_FindUser(si->pUsers, gce->ptszUID)) @@ -443,13 +443,12 @@ static INT_PTR CALLBACK sttEventStub(void *_param) bool bIsHighlighted = false, bRemoveFlag = false; // Do different things according to type of event - GCDEST *gcd = gce->pDest; - switch (gcd->iType) { + switch (gce->iType) { case GC_EVENT_SETCONTACTSTATUS: - return SM_SetContactStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, (WORD)gce->dwItemData); + return SM_SetContactStatus(gce->ptszID, gce->pszModule, gce->ptszUID, (WORD)gce->dwItemData); case GC_EVENT_TOPIC: - if (SESSION_INFO *si = chatApi.SM_FindSession(gcd->ptszID, gcd->pszModule)) { + if (SESSION_INFO *si = chatApi.SM_FindSession(gce->ptszID, gce->pszModule)) { wchar_t *pwszNew = RemoveFormatting(gce->ptszText); if (!mir_wstrcmp(si->ptszTopic, pwszNew)) // nothing changed? exiting return 0; @@ -473,25 +472,25 @@ static INT_PTR CALLBACK sttEventStub(void *_param) break; case GC_EVENT_ADDSTATUS: - SM_GiveStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, gce->ptszStatus); + SM_GiveStatus(gce->ptszID, gce->pszModule, gce->ptszUID, gce->ptszStatus); bIsHighlighted = chatApi.IsHighlighted(nullptr, gce); break; case GC_EVENT_REMOVESTATUS: - SM_TakeStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, gce->ptszStatus); + SM_TakeStatus(gce->ptszID, gce->pszModule, gce->ptszUID, gce->ptszStatus); bIsHighlighted = chatApi.IsHighlighted(nullptr, gce); break; case GC_EVENT_MESSAGE: case GC_EVENT_ACTION: - if (!gce->bIsMe && gcd->ptszID && gce->ptszText) { - SESSION_INFO *si = chatApi.SM_FindSession(gcd->ptszID, gcd->pszModule); + if (!gce->bIsMe && gce->ptszID && gce->ptszText) { + SESSION_INFO *si = chatApi.SM_FindSession(gce->ptszID, gce->pszModule); bIsHighlighted = chatApi.IsHighlighted(si, gce); } break; case GC_EVENT_NICK: - SM_ChangeNick(gcd->ptszID, gcd->pszModule, gce); + SM_ChangeNick(gce->ptszID, gce->pszModule, gce); bIsHighlighted = chatApi.IsHighlighted(nullptr, gce); break; @@ -511,13 +510,13 @@ static INT_PTR CALLBACK sttEventStub(void *_param) // Decide which window (log) should have the event LPCTSTR pWnd = nullptr; LPCSTR pMod = nullptr; - if (gcd->ptszID) { - pWnd = gcd->ptszID; - pMod = gcd->pszModule; + if (gce->ptszID) { + pWnd = gce->ptszID; + pMod = gce->pszModule; } - else if (gcd->iType == GC_EVENT_NOTICE || gcd->iType == GC_EVENT_INFORMATION) { + else if (gce->iType == GC_EVENT_NOTICE || gce->iType == GC_EVENT_INFORMATION) { SESSION_INFO *si = chatApi.GetActiveSession(); - if (si && !mir_strcmp(si->pszModule, gcd->pszModule)) { + if (si && !mir_strcmp(si->pszModule, gce->pszModule)) { pWnd = si->ptszID; pMod = si->pszModule; } @@ -538,13 +537,13 @@ static INT_PTR CALLBACK sttEventStub(void *_param) SESSION_INFO *si = chatApi.SM_FindSession(pWnd, pMod); // fix for IRC's old style mode notifications. Should not affect any other protocol - if ((gcd->iType == GC_EVENT_ADDSTATUS || gcd->iType == GC_EVENT_REMOVESTATUS) && !(gce->dwFlags & GCEF_ADDTOLOG)) + if ((gce->iType == GC_EVENT_ADDSTATUS || gce->iType == GC_EVENT_REMOVESTATUS) && !(gce->dwFlags & GCEF_ADDTOLOG)) return 0; - if (gcd->iType == GC_EVENT_JOIN && gce->time == 0) + if (gce->iType == GC_EVENT_JOIN && gce->time == 0) return 0; - if (si && (si->bInitDone || gcd->iType == GC_EVENT_TOPIC || (gcd->iType == GC_EVENT_JOIN && gce->bIsMe))) { + if (si && (si->bInitDone || gce->iType == GC_EVENT_TOPIC || (gce->iType == GC_EVENT_JOIN && gce->bIsMe))) { if (gce->ptszNick == nullptr && gce->ptszUID != nullptr) { USERINFO *ui = chatApi.UM_FindUser(si->pUsers, gce->ptszUID); if (ui != nullptr) @@ -571,7 +570,7 @@ static INT_PTR CALLBACK sttEventStub(void *_param) } if (bRemoveFlag) - return SM_RemoveUser(gcd->ptszID, gcd->pszModule, gce->ptszUID) == 0; + return SM_RemoveUser(gce->ptszID, gce->pszModule, gce->ptszUID) == 0; return GC_EVENT_ERROR; } @@ -581,11 +580,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) if (gce == nullptr) return GC_EVENT_ERROR; - GCDEST *gcd = gce->pDest; - if (gcd == nullptr) - return GC_EVENT_ERROR; - - if (!IsEventSupported(gcd->iType)) + if (!IsEventSupported(gce->iType)) return GC_EVENT_ERROR; return CallFunctionSync(sttEventStub, gce); diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index 1bffbfb6a3..2d098c0e30 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -82,7 +82,7 @@ wchar_t* RemoveFormatting(const wchar_t *pszWord) BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) { - switch (gce->pDest->iType) { + switch (gce->iType) { case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT: case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT: chatApi.AddEvent(si->hContact, Skin_LoadIcon(SKINICON_EVENT_MESSAGE), GC_FAKE_EVENT, 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName); @@ -208,7 +208,7 @@ int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char *pszProtoNa BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) { - switch (gce->pDest->iType) { + switch (gce->iType) { case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT: chatApi.ShowPopup(si->hContact, si, Skin_LoadIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, chatApi.aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText)); break; @@ -275,10 +275,10 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight BOOL bInactive = si->pDlg == nullptr || GetForegroundWindow() != si->pDlg->GetHwnd(); - int iEvent = gce->pDest->iType; + int iEvent = gce->iType; if (bHighlight) { - gce->pDest->iType |= GC_EVENT_HIGHLIGHT; + gce->iType |= GC_EVENT_HIGHLIGHT; if (bInactive || !g_Settings->bSoundsFocus) Skin_PlaySound("ChatHighlight"); if (db_get_b(si->hContact, "CList", "Hidden", 0) != 0) @@ -492,7 +492,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) pszNick = szTemp; } - switch (gce->pDest->iType) { + switch (gce->iType) { case GC_EVENT_MESSAGE: case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT: p = '*'; @@ -611,8 +611,7 @@ MIR_APP_DLL(BOOL) Chat_DoEventHook(SESSION_INFO *si, int iType, const USERINFO * if (si == nullptr) return FALSE; - GCDEST gcd = { si->pszModule, si->ptszID, iType }; - GCHOOK gch = { 0 }; + GCHOOK gch = { si->pszModule, si->ptszID, iType }; if (pUser != nullptr) { gch.ptszUID = pUser->pszUID; gch.ptszNick = pUser->pszNick; @@ -621,7 +620,6 @@ MIR_APP_DLL(BOOL) Chat_DoEventHook(SESSION_INFO *si, int iType, const USERINFO * gch.ptszText = (LPTSTR)pszText; gch.dwData = dwItem; - gch.pDest = &gcd; NotifyEventHooks(hevSendEvent, 0, (WPARAM)&gch); return TRUE; } -- cgit v1.2.3