From d9fddc0cfa9066eb1b5ad3f4807b37426ae6ca88 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 5 Mar 2019 21:10:22 +0300 Subject: Popup: - wiping out checks for service presence; - code cleaning --- protocols/Gadu-Gadu/src/core.cpp | 29 +++++++++---------- protocols/Gadu-Gadu/src/popups.cpp | 57 ++++++++++---------------------------- 2 files changed, 28 insertions(+), 58 deletions(-) (limited to 'protocols/Gadu-Gadu/src') diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 9176da06e7..4807733917 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -949,22 +949,19 @@ retry: } gg_LeaveCriticalSection(&sessions_mutex, "mainthread", 19, 1, "sessions_mutex", 1); sessions_updatedlg(); - if (ServiceExists(MS_POPUP_ADDPOPUPCLASS)) - { - const wchar_t* szText = time(0) - logonTime > 3 - ? TranslateT("You have logged in at another location") - : TranslateT("You are logged in at another location"); - for (i = 0; i < e->event.multilogon_info.count; i++) - { - wchar_t szMsg[MAX_SECONDLINE]; - if (iIndexes && iIndexes[i]) - continue; - - mir_snwprintf(szMsg, L"%s (%s)", szText, - *e->event.multilogon_info.sessions[i].name != '\0' ? - _A2T(e->event.multilogon_info.sessions[i].name) : TranslateT("Unknown client")); - showpopup(m_tszUserName, szMsg, GG_POPUP_MULTILOGON); - } + + const wchar_t* szText = time(0) - logonTime > 3 + ? TranslateT("You have logged in at another location") + : TranslateT("You are logged in at another location"); + for (i = 0; i < e->event.multilogon_info.count; i++) { + wchar_t szMsg[MAX_SECONDLINE]; + if (iIndexes && iIndexes[i]) + continue; + + mir_snwprintf(szMsg, L"%s (%s)", szText, + *e->event.multilogon_info.sessions[i].name != '\0' ? + _A2T(e->event.multilogon_info.sessions[i].name) : TranslateT("Unknown client")); + showpopup(m_tszUserName, szMsg, GG_POPUP_MULTILOGON); } mir_free(iIndexes); } diff --git a/protocols/Gadu-Gadu/src/popups.cpp b/protocols/Gadu-Gadu/src/popups.cpp index dd9c32d105..962c570002 100644 --- a/protocols/Gadu-Gadu/src/popups.cpp +++ b/protocols/Gadu-Gadu/src/popups.cpp @@ -105,48 +105,21 @@ void GaduProto::initpopups() // void CALLBACK sttMainThreadCallback(PVOID dwParam) { - PopupData* puData = (PopupData*)dwParam; - GaduProto* gg = puData->gg; - - if (ServiceExists(MS_POPUP_ADDPOPUPCLASS)) { - char szName[256]; - POPUPDATACLASS ppd = { sizeof(ppd) }; - ppd.pwszTitle = puData->title; - ppd.pwszText = puData->text; - ppd.PluginData = puData; - ppd.pszClassName = szName; - - if (puData->flags & GG_POPUP_ERROR || puData->flags & GG_POPUP_WARNING) - mir_snprintf(szName, "%s_%s", gg->m_szModuleName, "Error"); - else - mir_snprintf(szName, "%s_%s", gg->m_szModuleName, "Notify"); - - CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&ppd); - return; - } - - if (puData->flags & GG_POPUP_ALLOW_MSGBOX) { - BOOL bShow = TRUE; - - if (puData->flags & GG_POPUP_ONCE) { - HWND hWnd = FindWindow(nullptr, gg->m_tszUserName); - while (hWnd != nullptr) { - if (FindWindowEx(hWnd, nullptr, nullptr, puData->text) != nullptr) { - bShow = FALSE; - break; - } - hWnd = FindWindowEx(nullptr, hWnd, nullptr, gg->m_tszUserName); - } - } - - if (bShow) { - UINT uIcon = puData->flags & GG_POPUP_ERROR ? MB_ICONERROR : puData->flags & GG_POPUP_WARNING ? MB_ICONEXCLAMATION : MB_ICONINFORMATION; - MessageBox(nullptr, puData->text, gg->m_tszUserName, MB_OK | uIcon); - } - } - mir_free(puData->title); - mir_free(puData->text); - mir_free(puData); + PopupData *puData = (PopupData*)dwParam; + GaduProto *gg = puData->gg; + + char szName[256]; + POPUPDATACLASS ppd = { sizeof(ppd) }; + ppd.pwszTitle = puData->title; + ppd.pwszText = puData->text; + ppd.PluginData = puData; + ppd.pszClassName = szName; + + if (puData->flags & GG_POPUP_ERROR || puData->flags & GG_POPUP_WARNING) + mir_snprintf(szName, "%s_%s", gg->m_szModuleName, "Error"); + else + mir_snprintf(szName, "%s_%s", gg->m_szModuleName, "Notify"); + CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&ppd); } void GaduProto::showpopup(const wchar_t* nickname, const wchar_t* msg, int flags) -- cgit v1.2.3