From c0274fa5abfcfb59a4c8ae4d113d705ea0272c4c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 3 Sep 2018 18:25:42 +0300 Subject: popup code cleaning --- include/m_popup.h | 23 +++++++---------------- plugins/BasicHistory/src/Scheduler.cpp | 4 ++-- plugins/MirFox/src/MirandaInterface.cpp | 6 +++--- plugins/Nudge/src/main.cpp | 3 +-- plugins/Ping/src/utils.cpp | 4 ++-- plugins/Popup/src/notifications.cpp | 2 +- plugins/Popup/src/services.cpp | 8 ++++---- plugins/Toaster/src/services.cpp | 2 +- plugins/YAPP/src/options.cpp | 4 ++-- plugins/YAPP/src/services.cpp | 6 +++--- protocols/FacebookRM/src/json.cpp | 4 ++-- protocols/FacebookRM/src/proto.cpp | 22 ++++++---------------- protocols/Gadu-Gadu/src/popups.cpp | 4 ++-- protocols/JabberG/src/jabber_misc.cpp | 4 ++-- protocols/MSN/src/msn_misc.cpp | 4 ++-- protocols/Sametime/src/utils.cpp | 4 ++-- protocols/SkypeWeb/src/skype_popups.cpp | 11 ++++------- protocols/VKontakte/src/vk_proto.cpp | 17 ++++++++--------- 18 files changed, 54 insertions(+), 78 deletions(-) diff --git a/include/m_popup.h b/include/m_popup.h index 509a6f20f4..4318ebb08d 100644 --- a/include/m_popup.h +++ b/include/m_popup.h @@ -631,15 +631,14 @@ returns: 0 = popup allowed, 1 = popup filtered out //------------- Class API ----------------// -typedef struct { +#define PCF_UNICODE 0x0001 + +struct POPUPCLASS +{ int cbSize; - int flags; + int flags; // PCF_* constants char *pszName; - union { - char *pszDescription; - wchar_t *pwszDescription; - wchar_t *ptszDescription; - }; + MAllStrings pszDescription; HICON hIcon; @@ -650,15 +649,7 @@ typedef struct { int iSeconds; LPARAM lParam; //APF_RETURN_HWND, APF_CUSTOM_POPUP ... as above -} POPUPCLASS; - -#define PCF_UNICODE 0x0001 - -#ifdef _UNICODE -#define PCF_TCHAR PCF_UNICODE -#else -#define PCF_TCHAR 0 -#endif +}; // wParam = 0 // lParam = (POPUPCLASS *)&pc diff --git a/plugins/BasicHistory/src/Scheduler.cpp b/plugins/BasicHistory/src/Scheduler.cpp index 57b93a97c8..9e15d37eeb 100644 --- a/plugins/BasicHistory/src/Scheduler.cpp +++ b/plugins/BasicHistory/src/Scheduler.cpp @@ -71,10 +71,10 @@ void InitScheduler() bPopupsEnabled = ServiceExists(MS_POPUP_ADDPOPUPT) || ServiceExists(MS_POPUP_ADDPOPUPCLASS); POPUPCLASS test = { sizeof(test) }; - test.flags = PCF_TCHAR; + test.flags = PCF_UNICODE; test.hIcon = Skin_LoadIcon(SKINICON_OTHER_HISTORY); test.iSeconds = 10; - test.pwszDescription = TranslateT("History task"); + test.pszDescription.w = TranslateT("History task"); test.pszName = MODULENAME; if (hPopupClass = Popup_RegisterClass(&test)) HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown); diff --git a/plugins/MirFox/src/MirandaInterface.cpp b/plugins/MirFox/src/MirandaInterface.cpp index 09cb05058a..f72400a2f6 100644 --- a/plugins/MirFox/src/MirandaInterface.cpp +++ b/plugins/MirFox/src/MirandaInterface.cpp @@ -95,10 +95,10 @@ static int onModulesLoaded(WPARAM, LPARAM) //init popup classes POPUPCLASS puc = { 0 }; puc.cbSize = sizeof(puc); - puc.flags = PCF_TCHAR; + puc.flags = PCF_UNICODE; puc.pszName = "MirFox_Notify"; - puc.pwszDescription = TranslateT("MirFox/Notification"); + puc.pszDescription.w = TranslateT("MirFox/Notification"); puc.colorBack = RGB(173, 206, 247); //light blue puc.colorText = GetSysColor(COLOR_WINDOWTEXT); puc.iSeconds = 3; @@ -106,7 +106,7 @@ static int onModulesLoaded(WPARAM, LPARAM) hPopupNotify = Popup_RegisterClass(&puc); puc.pszName = "MirFox_Error"; - puc.pwszDescription = TranslateT("MirFox/Error"); + puc.pszDescription.w = TranslateT("MirFox/Error"); puc.colorBack = RGB(255, 128, 128); //light red puc.colorText = GetSysColor(COLOR_WINDOWTEXT); puc.iSeconds = 20; diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp index c39c7d0a17..48b387bfca 100644 --- a/plugins/Nudge/src/main.cpp +++ b/plugins/Nudge/src/main.cpp @@ -222,9 +222,8 @@ static int OnShutdown(WPARAM, LPARAM) void LoadPopupClass() { POPUPCLASS ppc = { sizeof(ppc) }; - ppc.flags = PCF_TCHAR; ppc.pszName = "Nudge"; - ppc.pwszDescription = LPGENW("Show Nudge"); + ppc.pszDescription.a = LPGEN("Show Nudge"); ppc.hIcon = IcoLib_GetIconByHandle(iconList[0].hIcolib); ppc.colorBack = NULL; ppc.colorText = NULL; diff --git a/plugins/Ping/src/utils.cpp b/plugins/Ping/src/utils.cpp index 58111c7f15..b94fe07bce 100644 --- a/plugins/Ping/src/utils.cpp +++ b/plugins/Ping/src/utils.cpp @@ -312,10 +312,10 @@ void InitUtils() hIconDisabled = IcoLib_GetIcon("ping_disabled"); POPUPCLASS test = { sizeof(test) }; - test.flags = PCF_TCHAR; + test.flags = PCF_UNICODE; test.hIcon = hIconResponding; test.iSeconds = -1; - test.pwszDescription = TranslateT("Ping"); + test.pszDescription.w = TranslateT("Ping"); test.pszName = "pingpopups"; test.PluginWindowProc = NullWindowProc; if (hPopupClass = Popup_RegisterClass(&test)) diff --git a/plugins/Popup/src/notifications.cpp b/plugins/Popup/src/notifications.cpp index fdd18a93cc..f86d235189 100644 --- a/plugins/Popup/src/notifications.cpp +++ b/plugins/Popup/src/notifications.cpp @@ -73,7 +73,7 @@ void FreePopupClass(POPUPTREEDATA *ptd) { if (ptd->typ == 2) { mir_free(ptd->pupClass.pszName); - mir_free(ptd->pupClass.pszDescription); + mir_free(ptd->pupClass.pszDescription.w); } mir_free(ptd->pszTreeRoot); mir_free(ptd->pszDescription); diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp index 77ab39de01..3490c2a25f 100644 --- a/plugins/Popup/src/services.cpp +++ b/plugins/Popup/src/services.cpp @@ -368,12 +368,12 @@ INT_PTR Popup_RegisterPopupClass(WPARAM, LPARAM lParam) ptd->pszTreeRoot = mir_a2u(pc->pszName); ptd->pupClass.pszName = mir_strdup(pc->pszName); if (pc->flags & PCF_UNICODE) { - ptd->pupClass.pwszDescription = mir_wstrdup(pc->pwszDescription); - ptd->pszDescription = mir_wstrdup(pc->pwszDescription); + ptd->pupClass.pszDescription.w = mir_wstrdup(pc->pszDescription.w); + ptd->pszDescription = mir_wstrdup(pc->pszDescription.w); } else { - ptd->pupClass.pszDescription = mir_strdup(pc->pszDescription); - ptd->pszDescription = mir_a2u(pc->pszDescription); + ptd->pupClass.pszDescription.a = mir_strdup(pc->pszDescription.a); + ptd->pszDescription = mir_a2u(pc->pszDescription.a); } LoadClassSettings(ptd, PU_MODULCLASS); diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp index 3d1dbd2040..82c7572601 100644 --- a/plugins/Toaster/src/services.cpp +++ b/plugins/Toaster/src/services.cpp @@ -134,7 +134,7 @@ static INT_PTR CreateClassPopup(WPARAM, LPARAM lParam) { ToastData *td = nullptr; - if (it->second->iFlags & PCF_TCHAR) + if (it->second->iFlags & PCF_UNICODE) { td = new ToastData(ppc->hContact, ppc->pwszTitle, ppc->pwszText, it->second->hIcon); } diff --git a/plugins/YAPP/src/options.cpp b/plugins/YAPP/src/options.cpp index ac6877707c..1e2b70f3f8 100644 --- a/plugins/YAPP/src/options.cpp +++ b/plugins/YAPP/src/options.cpp @@ -361,9 +361,9 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam for (int i = 0; i < arNewClasses.getCount(); i++) { POPUPCLASS *pc = arNewClasses[i]; if (pc->flags & PCF_UNICODE) - index = SendDlgItemMessageW(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pwszDescription); + index = SendDlgItemMessageW(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pszDescription.w); else - index = SendDlgItemMessageA(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pszDescription); + index = SendDlgItemMessageA(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pszDescription.a); SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_SETITEMDATA, index, i); } diff --git a/plugins/YAPP/src/services.cpp b/plugins/YAPP/src/services.cpp index f507557c20..78c66f4f97 100644 --- a/plugins/YAPP/src/services.cpp +++ b/plugins/YAPP/src/services.cpp @@ -332,9 +332,9 @@ static INT_PTR RegisterPopupClass(WPARAM, LPARAM lParam) pc->pszName = mir_strdup(pc->pszName); if (pc->flags & PCF_UNICODE) - pc->pwszDescription = mir_wstrdup(pc->pwszDescription); + pc->pszDescription.w = mir_wstrdup(pc->pszDescription.w); else - pc->pszDescription = mir_strdup(pc->pszDescription); + pc->pszDescription.a = mir_strdup(pc->pszDescription.a); char setting[256]; mir_snprintf(setting, "%s/Timeout", pc->pszName); @@ -352,7 +352,7 @@ static INT_PTR RegisterPopupClass(WPARAM, LPARAM lParam) static void FreePopupClass(POPUPCLASS *pc) { mir_free(pc->pszName); - mir_free(pc->pszDescription); + mir_free(pc->pszDescription.w); mir_free(pc); } diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 51112635f5..0b4db5be8c 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -546,10 +546,10 @@ const char* FacebookProto::ParseIcon(const std::string &url) mir_snprintf(name, "%s_%s%d", m_szModuleName, "Reaction", idx); POPUPCLASS ppc = { sizeof(ppc) }; - ppc.flags = PCF_TCHAR; + ppc.flags = PCF_UNICODE; ppc.PluginWindowProc = PopupDlgProc; ppc.lParam = APF_RETURN_HWND; - ppc.pwszDescription = desc; + ppc.pszDescription.w = desc; ppc.pszName = name; ppc.hIcon = hIcon; ppc.colorBack = RGB(59, 89, 152); // Facebook's blue diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 0f975b148a..dd24b8af02 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -914,19 +914,19 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa */ void FacebookProto::InitPopups() { + char name[256]; + wchar_t desc[256]; + POPUPCLASS ppc = { sizeof(ppc) }; - ppc.flags = PCF_TCHAR; + ppc.flags = PCF_UNICODE; ppc.PluginWindowProc = PopupDlgProc; ppc.lParam = APF_RETURN_HWND; - - wchar_t desc[256]; - char name[256]; + ppc.pszName = name; + ppc.pszDescription.w = desc; // Client mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Client errors")); mir_snprintf(name, "%s_%s", m_szModuleName, "Client"); - ppc.pwszDescription = desc; - ppc.pszName = name; ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("facebook")); ppc.colorBack = RGB(191, 0, 0); // red ppc.colorText = RGB(255, 255, 255); // white @@ -936,7 +936,6 @@ void FacebookProto::InitPopups() // Newsfeeds mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Wall posts")); mir_snprintf(name, "%s_%s", m_szModuleName, "Newsfeed"); - ppc.pwszDescription = desc; ppc.pszName = name; ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("newsfeed")); ppc.colorBack = RGB(255, 255, 255); // white @@ -947,7 +946,6 @@ void FacebookProto::InitPopups() // Notifications mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Notifications")); mir_snprintf(name, "%s_%s", m_szModuleName, "Notification"); - ppc.pwszDescription = desc; ppc.pszName = name; ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("notification")); ppc.colorBack = RGB(59, 89, 152); // Facebook's blue @@ -958,8 +956,6 @@ void FacebookProto::InitPopups() // Others mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Other events")); mir_snprintf(name, "%s_%s", m_szModuleName, "Other"); - ppc.pwszDescription = desc; - ppc.pszName = name; ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("facebook")); ppc.colorBack = RGB(255, 255, 255); // white ppc.colorText = RGB(0, 0, 0); // black @@ -969,8 +965,6 @@ void FacebookProto::InitPopups() // Friendship changes mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Friendship events")); mir_snprintf(name, "%s_%s", m_szModuleName, "Friendship"); - ppc.pwszDescription = desc; - ppc.pszName = name; ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("friendship")); ppc.colorBack = RGB(47, 71, 122); // Facebook's darker blue ppc.colorText = RGB(255, 255, 255); // white @@ -980,8 +974,6 @@ void FacebookProto::InitPopups() // Ticker mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Real-time friends activity")); mir_snprintf(name, "%s_%s", m_szModuleName, "Ticker"); - ppc.pwszDescription = desc; - ppc.pszName = name; ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("newsfeed")); ppc.colorBack = RGB(255, 255, 255); // white ppc.colorText = RGB(0, 0, 0); // black @@ -991,8 +983,6 @@ void FacebookProto::InitPopups() // On this day (memories) mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Memories")); mir_snprintf(name, "%s_%s", m_szModuleName, "Memories"); - ppc.pwszDescription = desc; - ppc.pszName = name; ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("memories")); ppc.colorBack = RGB(255, 255, 255); // white ppc.colorText = RGB(0, 0, 0); // black diff --git a/protocols/Gadu-Gadu/src/popups.cpp b/protocols/Gadu-Gadu/src/popups.cpp index d6cae63309..ecce63ae83 100644 --- a/protocols/Gadu-Gadu/src/popups.cpp +++ b/protocols/Gadu-Gadu/src/popups.cpp @@ -78,9 +78,9 @@ void GaduProto::initpopups() POPUPCLASS puc = { 0 }; puc.cbSize = sizeof(puc); puc.PluginWindowProc = PopupWindowProc; - puc.flags = PCF_TCHAR; - puc.pwszDescription = szDescr; + puc.flags = PCF_UNICODE; puc.pszName = szName; + puc.pszDescription.w = szDescr; puc.colorBack = RGB(173, 206, 247); puc.colorText = GetSysColor(COLOR_WINDOWTEXT); diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 854d66b78a..eba91277ee 100755 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -411,9 +411,9 @@ void CJabberProto::InitPopups(void) mir_snprintf(name, "%s_%s", m_szModuleName, "Error"); POPUPCLASS ppc = { sizeof(ppc) }; - ppc.flags = PCF_TCHAR; - ppc.pwszDescription = desc; + ppc.flags = PCF_UNICODE; ppc.pszName = name; + ppc.pszDescription.w = desc; ppc.hIcon = LoadIconEx("main"); ppc.colorBack = RGB(191, 0, 0); //Red ppc.colorText = RGB(255, 245, 225); //Yellow diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 1f343115d0..9f95bb34f8 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -795,11 +795,11 @@ void CMsnProto::InitPopups(void) char name[256]; POPUPCLASS ppc = { sizeof(ppc) }; - ppc.flags = PCF_TCHAR; + ppc.flags = PCF_UNICODE; ppc.PluginWindowProc = NullWindowProc; ppc.hIcon = LoadIconEx("main"); - ppc.pwszDescription = desc; ppc.pszName = name; + ppc.pszDescription.w = desc; ppc.colorBack = RGB(173, 206, 247); ppc.colorText = GetSysColor(COLOR_WINDOWTEXT); diff --git a/protocols/Sametime/src/utils.cpp b/protocols/Sametime/src/utils.cpp index 2d942c4b7c..b83b46ea68 100644 --- a/protocols/Sametime/src/utils.cpp +++ b/protocols/Sametime/src/utils.cpp @@ -36,9 +36,9 @@ void CSametimeProto::RegisterPopups() POPUPCLASS puc = { sizeof(puc) }; puc.PluginWindowProc = PopupWindowProc; - puc.flags = PCF_TCHAR; - puc.pwszDescription = szDescr; + puc.flags = PCF_UNICODE; puc.pszName = szName; + puc.pszDescription.w = szDescr; mir_snprintf(szName, "%s_%s", m_szModuleName, "Notify"); mir_snwprintf(szDescr, L"%s/%s", m_tszUserName, TranslateT("Notifications")); diff --git a/protocols/SkypeWeb/src/skype_popups.cpp b/protocols/SkypeWeb/src/skype_popups.cpp index 64fd9b5228..06aac781c4 100644 --- a/protocols/SkypeWeb/src/skype_popups.cpp +++ b/protocols/SkypeWeb/src/skype_popups.cpp @@ -4,13 +4,14 @@ void CSkypeProto::InitPopups() { wchar_t desc[256]; char name[256]; + POPUPCLASS ppc = { sizeof(ppc) }; - ppc.flags = PCF_TCHAR; + ppc.flags = PCF_UNICODE; + ppc.pszName = name; + ppc.pszDescription.w = desc; mir_snwprintf(desc, L"%s %s", m_tszUserName, TranslateT("Notifications")); mir_snprintf(name, "%s_%s", m_szModuleName, "Notification"); - ppc.pwszDescription = desc; - ppc.pszName = name; ppc.hIcon = GetIcon(IDI_NOTIFY); ppc.colorBack = RGB(255, 255, 255); ppc.colorText = RGB(0, 0, 0); @@ -19,8 +20,6 @@ void CSkypeProto::InitPopups() mir_snwprintf(desc, L"%s %s", m_tszUserName, TranslateT("Errors")); mir_snprintf(name, "%s_%s", m_szModuleName, "Error"); - ppc.pwszDescription = desc; - ppc.pszName = name; ppc.hIcon = GetIcon(IDI_ERRORICON); ppc.colorBack = RGB(255, 255, 255); ppc.colorText = RGB(0, 0, 0); @@ -29,8 +28,6 @@ void CSkypeProto::InitPopups() mir_snwprintf(desc, L"%s %s", m_tszUserName, TranslateT("Calls")); mir_snprintf(name, "%s_%s", m_szModuleName, "Call"); - ppc.pwszDescription = desc; - ppc.pszName = name; ppc.hIcon = GetIcon(IDI_CALL); ppc.colorBack = RGB(255, 255, 255); ppc.colorText = RGB(0, 0, 0); diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 4c73f8323b..c8ec72fd91 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -409,28 +409,27 @@ void CVkProto::InitPopups(void) { wchar_t desc[256]; char name[256]; + POPUPCLASS ppc = { sizeof(ppc) }; - ppc.flags = PCF_TCHAR; + ppc.flags = PCF_UNICODE; + ppc.pszName = name; + ppc.pszDescription.w = desc; ppc.PluginWindowProc = PopupDlgProc; ppc.lParam = APF_RETURN_HWND; mir_snwprintf(desc, L"%s %s", m_tszUserName, TranslateT("Errors")); mir_snprintf(name, "%s_%s", m_szModuleName, "Error"); - ppc.pwszDescription = desc; - ppc.pszName = name; ppc.hIcon = Skin_LoadIcon(SKINICON_ERROR); - ppc.colorBack = RGB(191, 0, 0); //Red - ppc.colorText = RGB(255, 245, 225); //Yellow + ppc.colorBack = RGB(191, 0, 0); // Red + ppc.colorText = RGB(255, 245, 225); // Yellow ppc.iSeconds = 60; m_hPopupClassError = Popup_RegisterClass(&ppc); mir_snwprintf(desc, L"%s %s", m_tszUserName, TranslateT("Notifications")); mir_snprintf(name, "%s_%s", m_szModuleName, "Notification"); - ppc.pwszDescription = desc; - ppc.pszName = name; ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle(IDI_NOTIFICATION)); - ppc.colorBack = RGB(190, 225, 255); //Blue - ppc.colorText = RGB(255, 255, 255); //White + ppc.colorBack = RGB(190, 225, 255); // Blue + ppc.colorText = RGB(255, 255, 255); // White ppc.iSeconds = 4; m_hPopupClassNotification = Popup_RegisterClass(&ppc); } -- cgit v1.2.3