From a27b07c35565ced7f690890dcba29518ae2e4928 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 6 Sep 2016 18:26:47 +0000 Subject: MS_CLIST_SYSTRAY_NOTIFY - more useless code removed git-svn-id: http://svn.miranda-ng.org/main/trunk@17268 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AssocMgr/src/utils.cpp | 16 +---- plugins/AutoShutdown/src/utils.cpp | 13 +--- plugins/MirOTR/src/utils.cpp | 106 +++++++++++--------------------- plugins/PluginUpdater/src/DlgUpdate.cpp | 20 +----- plugins/Scriver/src/msgoptions.cpp | 16 +---- plugins/Scriver/src/msgs.cpp | 24 +------- plugins/TabSRMM/src/mim.cpp | 13 +--- plugins/TabSRMM/src/msgoptions.cpp | 5 -- plugins/TabSRMM/src/srmm.cpp | 20 ++---- plugins/WebView/src/webview_alerts.cpp | 12 +--- 10 files changed, 58 insertions(+), 187 deletions(-) (limited to 'plugins') diff --git a/plugins/AssocMgr/src/utils.cpp b/plugins/AssocMgr/src/utils.cpp index 494dd298c5..6028343440 100644 --- a/plugins/AssocMgr/src/utils.cpp +++ b/plugins/AssocMgr/src/utils.cpp @@ -139,26 +139,16 @@ static void MessageBoxIndirectFree(void *param) void ShowInfoMessage(BYTE flags,const char *pszTitle,const char *pszTextFmt,...) { char szText[256]; /* max for systray */ - MSGBOXPARAMSA *mbp; va_list va; va_start(va,pszTextFmt); mir_vsnprintf(szText,_countof(szText),pszTextFmt,va); va_end(va); - if(ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) { - MIRANDASYSTRAYNOTIFY msn; - msn.cbSize=sizeof(msn); - msn.szProto=NULL; - msn.szInfoTitle=(char*)pszTitle; - msn.szInfo=(char*)szText; - msn.uTimeout=30000; /* max timeout */ - msn.dwInfoFlags=flags; - if (!CallServiceSync(MS_CLIST_SYSTRAY_NOTIFY,0,(LPARAM)&msn)) - return; /* success */ - } + if (!Clist_TrayNotifyA(NULL, pszTitle, szText, flags, 30000)) // success + return; - mbp = (MSGBOXPARAMSA*)mir_calloc(sizeof(*mbp)); + MSGBOXPARAMSA *mbp = (MSGBOXPARAMSA*)mir_calloc(sizeof(*mbp)); if(mbp == NULL) return; diff --git a/plugins/AutoShutdown/src/utils.cpp b/plugins/AutoShutdown/src/utils.cpp index d071125a2c..c854534161 100644 --- a/plugins/AutoShutdown/src/utils.cpp +++ b/plugins/AutoShutdown/src/utils.cpp @@ -84,17 +84,8 @@ void ShowInfoMessage(BYTE flags, const char *pszTitle, const char *pszTextFmt, . mir_vsnprintf(szText, _countof(szText), pszTextFmt, va); va_end(va); - if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) { - MIRANDASYSTRAYNOTIFY msn; - msn.cbSize = sizeof(msn); - msn.szProto = NULL; - msn.szInfoTitle = (char*)pszTitle; - msn.szInfo = (char*)szText; - msn.uTimeout = 30000; /* max timeout */ - msn.dwInfoFlags = flags; - if (!CallServiceSync(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&msn)) - return; /* success */ - } + if (!Clist_TrayNotifyA(NULL, pszTitle, szText, flags, 30000)) // success + return; MSGBOXPARAMSA *mbp = (MSGBOXPARAMSA*)mir_calloc(sizeof(*mbp)); if (mbp == NULL) return; diff --git a/plugins/MirOTR/src/utils.cpp b/plugins/MirOTR/src/utils.cpp index 5b10c37451..d0447831d6 100644 --- a/plugins/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/src/utils.cpp @@ -158,45 +158,28 @@ void ShowWarning(wchar_t *msg) { wchar_t buffer[512]; ErrorDisplay disp = options.err_method; // funny logic :) ... try to avoid message boxes - // if want baloons but no balloons, try popups // if want popups but no popups, try baloons - // if, after that, you want balloons but no balloons, revert to message boxes - if(disp == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) disp = ED_POP; - if(disp == ED_POP && !options.bHavePopups) disp = ED_BAL; - if(disp == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) disp = ED_MB; + if(disp == ED_POP && !options.bHavePopups) + disp = ED_BAL; mir_snwprintf(buffer, L"%s Warning", _A2W(MODULENAME)); - - switch(disp) { - case ED_POP: - { - int size = int(mir_wstrlen(msg) + 515); - wchar_t *message = new wchar_t[size]; // newline and null terminator - mir_snwprintf(message, size, L"%s\r\n%s", buffer, msg); - PUShowMessageT(message, SM_WARNING); - delete[] message; - } - break; - case ED_MB: - MessageBox(0, msg, buffer, MB_OK | MB_ICONWARNING); - break; - case ED_BAL: - { - MIRANDASYSTRAYNOTIFY sn = {0}; - sn.cbSize = sizeof(sn); - sn.szProto= MODULENAME; - sn.tszInfoTitle = buffer; - sn.tszInfo = msg; - - sn.dwInfoFlags = NIIF_WARNING | NIIF_INTERN_UNICODE; - - sn.uTimeout = 10; - - CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&sn); - } - - break; + switch (disp) { + case ED_POP: + { + int size = int(mir_wstrlen(msg) + 515); + wchar_t *message = new wchar_t[size]; // newline and null terminator + mir_snwprintf(message, size, L"%s\r\n%s", buffer, msg); + PUShowMessageT(message, SM_WARNING); + delete[] message; + } + break; + case ED_MB: + MessageBox(0, msg, buffer, MB_OK | MB_ICONWARNING); + break; + case ED_BAL: + Clist_TrayNotifyW(MODULENAME, buffer, msg, NIIF_WARNING, 10000); + break; } } @@ -204,46 +187,29 @@ void ShowError(wchar_t *msg) { wchar_t buffer[512]; ErrorDisplay disp = options.err_method; // funny logic :) ... try to avoid message boxes - // if want baloons but no balloons, try popups // if want popups but no popups, try baloons - // if, after that, you want balloons but no balloons, revert to message boxes - if(disp == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) disp = ED_POP; - if(disp == ED_POP && !options.bHavePopups) disp = ED_BAL; - if(disp == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) disp = ED_MB; + if(disp == ED_POP && !options.bHavePopups) + disp = ED_BAL; mir_snwprintf(buffer, L"%s Error", _A2W(MODULENAME)); - wchar_t *message; - switch(disp) { - case ED_POP: - { - int size = int(mir_wstrlen(msg) + 515); - message = new wchar_t[size]; // newline and null terminator - mir_snwprintf(message, size, L"%s\r\n%s", buffer, msg); - PUShowMessageT(message, SM_WARNING); - delete[] message; - } - break; - case ED_MB: - MessageBox(0, msg, buffer, MB_OK | MB_ICONERROR); - break; - case ED_BAL: - { - MIRANDASYSTRAYNOTIFY sn = {0}; - sn.cbSize = sizeof(sn); - sn.szProto = MODULENAME; - sn.tszInfoTitle = buffer; - sn.tszInfo = msg; - - sn.dwInfoFlags = NIIF_ERROR | NIIF_INTERN_UNICODE; - - sn.uTimeout = 10; - - CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&sn); - } - - break; + switch (disp) { + case ED_POP: + { + int size = int(mir_wstrlen(msg) + 515); + message = new wchar_t[size]; // newline and null terminator + mir_snwprintf(message, size, L"%s\r\n%s", buffer, msg); + PUShowMessageT(message, SM_WARNING); + delete[] message; + } + break; + case ED_MB: + MessageBox(0, msg, buffer, MB_OK | MB_ICONERROR); + break; + case ED_BAL: + Clist_TrayNotifyW(MODULENAME, buffer, msg, NIIF_ERROR, 10000); + break; } } diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 06a9badcf1..7bbb59b784 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -495,24 +495,10 @@ static void DlgUpdateSilent(void *param) wchar_t tszTitle[100]; mir_snwprintf(tszTitle, TranslateT("%d component(s) was updated"), count); - if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1)) { + if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1)) ShowPopup(tszTitle,TranslateT("You need to restart your Miranda to apply installed updates."),POPUP_TYPE_MSG); - } else { - bool notified = false; - - if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) { - MIRANDASYSTRAYNOTIFY err; - err.szProto = MODULEA; - err.cbSize = sizeof(err); - err.dwInfoFlags = NIIF_INTERN_UNICODE | NIIF_INFO; - err.tszInfoTitle = tszTitle; - err.tszInfo = TranslateT("You need to restart your Miranda to apply installed updates."); - err.uTimeout = 30000; - - notified = !CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&err); - } - - if (!notified) { + else { + if (Clist_TrayNotifyW(MODULEA, tszTitle, TranslateT("You need to restart your Miranda to apply installed updates."), NIIF_INFO, 30000)) { // Error, let's try to show MessageBox as last way to inform user about successful update wchar_t tszText[200]; mir_snwprintf(tszText, L"%s\n\n%s", TranslateT("You need to restart your Miranda to apply installed updates."), TranslateT("Would you like to restart it now?")); diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp index 98198af1a6..abb4b38229 100644 --- a/plugins/Scriver/src/msgoptions.cpp +++ b/plugins/Scriver/src/msgoptions.cpp @@ -880,23 +880,14 @@ static INT_PTR CALLBACK DlgProcTypeOptions(HWND hwndDlg, UINT msg, WPARAM wParam EnableWindow(GetDlgItem(hwndDlg, IDC_TYPETRAY), IsDlgButtonChecked(hwndDlg, IDC_SHOWNOTIFY)); EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYTRAY), IsDlgButtonChecked(hwndDlg, IDC_TYPETRAY)); EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYBALLOON), IsDlgButtonChecked(hwndDlg, IDC_TYPETRAY)); - if (!ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYBALLOON), FALSE); - CheckDlgButton(hwndDlg, IDC_NOTIFYTRAY, BST_CHECKED); - SetDlgItemText(hwndDlg, IDC_NOTIFYBALLOON, TranslateT("Show balloon popup (unsupported system)")); - } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_TYPETRAY: if (IsDlgButtonChecked(hwndDlg, IDC_TYPETRAY)) { - if (!ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) - EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYTRAY), TRUE); - else { - EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYTRAY), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYBALLOON), TRUE); - } + EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYTRAY), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYBALLOON), TRUE); } else { EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYTRAY), FALSE); @@ -908,8 +899,7 @@ static INT_PTR CALLBACK DlgProcTypeOptions(HWND hwndDlg, UINT msg, WPARAM wParam EnableWindow(GetDlgItem(hwndDlg, IDC_TYPEWIN), IsDlgButtonChecked(hwndDlg, IDC_SHOWNOTIFY)); EnableWindow(GetDlgItem(hwndDlg, IDC_TYPETRAY), IsDlgButtonChecked(hwndDlg, IDC_SHOWNOTIFY)); EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYTRAY), IsDlgButtonChecked(hwndDlg, IDC_SHOWNOTIFY)); - EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYBALLOON), IsDlgButtonChecked(hwndDlg, IDC_SHOWNOTIFY) - && ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)); + EnableWindow(GetDlgItem(hwndDlg, IDC_NOTIFYBALLOON), IsDlgButtonChecked(hwndDlg, IDC_SHOWNOTIFY)); //fall-thru case IDC_TYPEWIN: case IDC_NOTIFYTRAY: diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 19f42b14f9..49310e20e8 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -207,29 +207,7 @@ static int TypingMessage(WPARAM hContact, LPARAM lParam) else if (lParam && (g_dat.flags2 & SMF2_SHOWTYPINGTRAY)) { wchar_t szTip[256]; mir_snwprintf(szTip, TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0)); - - if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat.flags2 & SMF2_SHOWTYPINGCLIST)) { - MIRANDASYSTRAYNOTIFY tn; - tn.szProto = NULL; - tn.cbSize = sizeof(tn); - tn.tszInfoTitle = TranslateT("Typing notification"); - tn.tszInfo = szTip; - tn.dwInfoFlags = NIIF_INFO | NIIF_INTERN_UNICODE; - tn.uTimeout = 1000 * 4; - CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&tn); - } - else { - pcli->pfnRemoveEvent(hContact, 1); - - CLISTEVENT cle = {}; - cle.hContact = hContact; - cle.hDbEvent = 1; - cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR; - cle.hIcon = GetCachedIcon("scriver_TYPING"); - cle.pszService = "SRMsg/TypingMessage"; - cle.ptszTooltip = szTip; - pcli->pfnAddEvent(&cle); - } + Clist_TrayNotifyW(NULL, TranslateT("Typing notification"), szTip, NIIF_INFO, 1000 * 4); } return 0; } diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index 000043e8b6..b222fdc845 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -300,16 +300,9 @@ int CMimAPI::TypingMessage(WPARAM hContact, LPARAM mode) if (mode) { wchar_t szTip[256]; mir_snwprintf(szTip, TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0)); - if (fShowOnClist && ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && M.GetByte(SRMSGMOD, "ShowTypingBalloon", 0)) { - MIRANDASYSTRAYNOTIFY tn; - tn.szProto = NULL; - tn.cbSize = sizeof(tn); - tn.tszInfoTitle = TranslateT("Typing notification"); - tn.tszInfo = szTip; - tn.dwInfoFlags = NIIF_INFO | NIIF_INTERN_UNICODE; - tn.uTimeout = 1000 * 4; - CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&tn); - } + if (fShowOnClist && M.GetByte(SRMSGMOD, "ShowTypingBalloon", 0)) + Clist_TrayNotifyW(NULL, TranslateT("Typing notification"), szTip, NIIF_INFO, 1000 * 4); + if (fShowOnClist) { pcli->pfnRemoveEvent(hContact, 1); diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index ddf7c16651..68bb2837a4 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -915,11 +915,6 @@ static INT_PTR CALLBACK DlgProcTypeOptions(HWND hwndDlg, UINT msg, WPARAM wParam Utils::enableDlgControl(hwndDlg, IDC_TYPEFLASHWIN, IsDlgButtonChecked(hwndDlg, IDC_SHOWNOTIFY) != 0); Utils::enableDlgControl(hwndDlg, IDC_MTN_POPUPMODE, IsDlgButtonChecked(hwndDlg, IDC_NOTIFYPOPUP) != 0); - if (!ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) { - Utils::enableDlgControl(hwndDlg, IDC_NOTIFYBALLOON, false); - SetDlgItemText(hwndDlg, IDC_NOTIFYBALLOON, TranslateT("Show balloon popup (unsupported system)")); - } - SendDlgItemMessage(hwndDlg, IDC_MTN_POPUPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Always")); SendDlgItemMessage(hwndDlg, IDC_MTN_POPUPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Always, but no popup when window is focused")); SendDlgItemMessage(hwndDlg, IDC_MTN_POPUPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Only when no message window is open")); diff --git a/plugins/TabSRMM/src/srmm.cpp b/plugins/TabSRMM/src/srmm.cpp index 3f3cb18bb1..750f006ed3 100644 --- a/plugins/TabSRMM/src/srmm.cpp +++ b/plugins/TabSRMM/src/srmm.cpp @@ -150,20 +150,10 @@ int _DebugPopup(MCONTACT hContact, const wchar_t *fmt, ...) va_start(va, fmt); mir_vsnwprintf(debug, ibsize, fmt, va); - if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) { - MIRANDASYSTRAYNOTIFY tn; - wchar_t szTitle[128]; - mir_snwprintf(szTitle, TranslateT("TabSRMM message (%s)"), - (hContact != 0) ? pcli->pfnGetContactDisplayName(hContact, 0) : TranslateT("Global")); - - tn.szProto = NULL; - tn.cbSize = sizeof(tn); - tn.tszInfoTitle = szTitle; - tn.tszInfo = debug; - tn.dwInfoFlags = NIIF_INFO; - tn.dwInfoFlags |= NIIF_INTERN_UNICODE; - tn.uTimeout = 1000 * 4; - CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&tn); - } + wchar_t szTitle[128]; + mir_snwprintf(szTitle, TranslateT("TabSRMM message (%s)"), + (hContact != 0) ? pcli->pfnGetContactDisplayName(hContact, 0) : TranslateT("Global")); + + Clist_TrayNotifyW(NULL, szTitle, debug, NIIF_INFO, 1000 * 4); return 0; } diff --git a/plugins/WebView/src/webview_alerts.cpp b/plugins/WebView/src/webview_alerts.cpp index f5e40cb45d..a816dfb319 100644 --- a/plugins/WebView/src/webview_alerts.cpp +++ b/plugins/WebView/src/webview_alerts.cpp @@ -195,16 +195,8 @@ int ErrorMsgs(WPARAM wParam, LPARAM lParam) mir_snwprintf(newdisplaytext, L"%s: %s", ptszContactName, TranslateW(displaytext)); CallService("OSD/Announce", (WPARAM)newdisplaytext, 0); } - else if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) { - MIRANDASYSTRAYNOTIFY webview_tip = {0}; - webview_tip.cbSize = sizeof(MIRANDASYSTRAYNOTIFY); - webview_tip.szProto = NULL; - webview_tip.tszInfoTitle = ptszContactName; - webview_tip.tszInfo = TranslateW(displaytext); - webview_tip.dwInfoFlags = NIIF_ERROR | NIIF_INTERN_UNICODE; - webview_tip.uTimeout = 15000; - CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) &webview_tip); - } + + Clist_TrayNotifyW(NULL, ptszContactName, TranslateW(displaytext), NIIF_ERROR, 15000); return 0; } -- cgit v1.2.3