From a7c24ca48995cf2bf436156302f96b91bf135409 Mon Sep 17 00:00:00 2001 From: Goraf <22941576+Goraf@users.noreply.github.com> Date: Mon, 13 Nov 2017 15:03:31 +0100 Subject: Code modernize ... * replace 0/NULL with nullptr [using clang-tidy] --- plugins/WebView/src/main.cpp | 14 ++--- plugins/WebView/src/webview.cpp | 20 +++---- plugins/WebView/src/webview_alerts.cpp | 42 +++++++-------- plugins/WebView/src/webview_cleanup.cpp | 52 +++++++++--------- plugins/WebView/src/webview_datawnd.cpp | 16 +++--- plugins/WebView/src/webview_getdata.cpp | 14 ++--- plugins/WebView/src/webview_opts.cpp | 92 ++++++++++++++++---------------- plugins/WebView/src/webview_services.cpp | 40 +++++++------- 8 files changed, 145 insertions(+), 145 deletions(-) (limited to 'plugins/WebView/src') diff --git a/plugins/WebView/src/main.cpp b/plugins/WebView/src/main.cpp index fd897fb380..421e92fdd2 100644 --- a/plugins/WebView/src/main.cpp +++ b/plugins/WebView/src/main.cpp @@ -29,7 +29,7 @@ HANDLE hHookDisplayDataAlert, hHookAlertPopup, hHookAlertWPopup, hHookErrorPopup int hLangpack = 0; CLIST_INTERFACE *pcli; -static HMODULE hRichEd = NULL; +static HMODULE hRichEd = nullptr; PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), @@ -95,8 +95,8 @@ extern "C" int __declspec(dllexport) Unload(void) { ChangeContactStatus(0); - KillTimer(NULL, timerId); - KillTimer(NULL, Countdown); + KillTimer(nullptr, timerId); + KillTimer(nullptr, Countdown); db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 0); SavewinSettings(); @@ -105,7 +105,7 @@ extern "C" int __declspec(dllexport) Unload(void) if (hNetlibUser) { Netlib_CloseHandle(hNetlibUser); - hNetlibUser = NULL; + hNetlibUser = nullptr; } if (hHookDisplayDataAlert) @@ -115,7 +115,7 @@ extern "C" int __declspec(dllexport) Unload(void) if (hHookAlertWPopup) DestroyHookableEvent(hHookAlertWPopup); - if (h_font != NULL) + if (h_font != nullptr) DeleteObject(h_font); if (hMenu) DestroyMenu(hMenu); @@ -136,9 +136,9 @@ extern "C" int __declspec(dllexport) Load() /*TIMERS*/ if ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, TIME) != 0)) { - timerId = SetTimer(NULL, 0, ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, TIME)) * MINUTE), timerfunc); + timerId = SetTimer(nullptr, 0, ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, TIME)) * MINUTE), timerfunc); db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, 0); - Countdown = SetTimer(NULL, 0, MINUTE, Countdownfunc); + Countdown = SetTimer(nullptr, 0, MINUTE, Countdownfunc); } InitialiseGlobals(); diff --git a/plugins/WebView/src/webview.cpp b/plugins/WebView/src/webview.cpp index 592a4a734d..9c77b5e6af 100644 --- a/plugins/WebView/src/webview.cpp +++ b/plugins/WebView/src/webview.cpp @@ -97,7 +97,7 @@ void TxtclrLoop() for (MCONTACT hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) { HWND hwndDlg = WindowList_Find(hWindowList, hContact); SetDlgItemText(hwndDlg, IDC_DATA, L""); - InvalidateRect(hwndDlg, NULL, 1); + InvalidateRect(hwndDlg, nullptr, 1); } } @@ -108,7 +108,7 @@ void BGclrLoop() HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); SetDlgItemText(hwndDlg, IDC_DATA, L""); SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETBKGNDCOLOR, 0, BackgoundClr); - InvalidateRect(hwndDlg, NULL, 1); + InvalidateRect(hwndDlg, nullptr, 1); } } @@ -185,7 +185,7 @@ int Doubleclick(WPARAM wParam, LPARAM) SetFocus(hwndDlg); } else { - hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM)hContact); + hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), nullptr, DlgProcDisplayData, (LPARAM)hContact); HWND hTopmost = db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST; SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); @@ -269,7 +269,7 @@ void CALLBACK timerfunc(HWND, UINT, UINT_PTR, DWORD) if (!(db_get_b(NULL, MODULENAME, OFFLINE_STATUS, 1))) if (!(db_get_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0))) - mir_forkthread(ContactLoop, NULL); + mir_forkthread(ContactLoop, nullptr); db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, 0); } @@ -352,7 +352,7 @@ int ModulesLoaded(WPARAM, LPARAM) // get data on startup if (db_get_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, 0)) - mir_forkthread(StartUpdate, NULL); + mir_forkthread(StartUpdate, nullptr); return 0; } @@ -362,13 +362,13 @@ INT_PTR DataWndMenuCommand(WPARAM wParam, LPARAM) { MCONTACT hContact = wParam; HWND hwndDlg = WindowList_Find(hWindowList, hContact); - if (hwndDlg != NULL) { + if (hwndDlg != nullptr) { DestroyWindow(hwndDlg); return 0; } HWND hTopmost = db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST; - hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM)hContact); + hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), nullptr, DlgProcDisplayData, (LPARAM)hContact); SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)); if (db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0)) SetWindowPos(hwndDlg, hTopmost, @@ -396,7 +396,7 @@ INT_PTR DataWndMenuCommand(WPARAM wParam, LPARAM) /*****************************************************************************/ INT_PTR UpdateAllMenuCommand(WPARAM, LPARAM) { - mir_forkthread(ContactLoop, NULL); + mir_forkthread(ContactLoop, nullptr); return 0; } @@ -474,7 +474,7 @@ INT_PTR CntOptionsMenuCommand(WPARAM wParam, LPARAM) return 0; } - hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT), NULL, DlgProcContactOpt, (LPARAM)wParam); + hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT), nullptr, DlgProcContactOpt, (LPARAM)wParam); ShowWindow(hwndDlg, SW_SHOW); SetActiveWindow(hwndDlg); return 0; @@ -489,7 +489,7 @@ INT_PTR CntAlertMenuCommand(WPARAM wParam, LPARAM) return 0; } - hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), NULL, DlgProcAlertOpt, (LPARAM)wParam); + hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), nullptr, DlgProcAlertOpt, (LPARAM)wParam); ShowWindow(hwndDlg, SW_SHOW); SetActiveWindow(hwndDlg); return 0; diff --git a/plugins/WebView/src/webview_alerts.cpp b/plugins/WebView/src/webview_alerts.cpp index bdd4551410..78d217a383 100644 --- a/plugins/WebView/src/webview_alerts.cpp +++ b/plugins/WebView/src/webview_alerts.cpp @@ -113,7 +113,7 @@ int PopupAlert(WPARAM wParam, LPARAM lParam) { POPUPDATAT ppd = { 0 }; - if( ((HANDLE)wParam) != NULL) { + if( ((HANDLE)wParam) != nullptr) { DBVARIANT dbv; db_get_ws(wParam, MODULENAME, PRESERVE_NAME_KEY, &dbv); mir_wstrncpy(ppd.lptzContactName, dbv.ptszVal, _countof(ppd.lptzContactName)); @@ -143,7 +143,7 @@ int PopupAlert(WPARAM wParam, LPARAM lParam) ppd.colorText = TextClr; } - ppd.PluginWindowProc = NULL; + ppd.PluginWindowProc = nullptr; ppd.iSeconds = db_get_dw(NULL, MODULENAME, POP_DELAY_KEY, 0); if (ServiceExists(MS_POPUP_ADDPOPUPT)) @@ -196,7 +196,7 @@ int ErrorMsgs(WPARAM wParam, LPARAM lParam) CallService("OSD/Announce", (WPARAM)newdisplaytext, 0); } - Clist_TrayNotifyW(NULL, ptszContactName, TranslateW(displaytext), NIIF_ERROR, 15000); + Clist_TrayNotifyW(nullptr, ptszContactName, TranslateW(displaytext), NIIF_ERROR, 15000); return 0; } @@ -220,13 +220,13 @@ void SaveToFile(MCONTACT hContact, char *truncated) return; FILE *pfile = fopen(dbv.pszVal, mode); - if (pfile == NULL) + if (pfile == nullptr) WErrorPopup(hContact, TranslateT("Cannot write to file")); else { char timestring[128], timeprefix[32]; char temptime1[32], temptime2[32]; - time_t ftime = time(NULL); + time_t ftime = time(nullptr); struct tm *nTime = localtime(&ftime); mir_snprintf(timeprefix, " %s ", Translate("Last updated on")); @@ -332,7 +332,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Start/end strings not found or strings not set.")); } - else MessageBox(NULL, TranslateT("Start/end strings not found or strings not set."), _A2W(MODULENAME), MB_OK); + else MessageBox(nullptr, TranslateT("Start/end strings not found or strings not set."), _A2W(MODULENAME), MB_OK); } if (eventIndex == 0) { // string present @@ -340,7 +340,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn strncpy_s(alertstring, _countof(alertstring), tdbv.pszVal, _TRUNCATE); db_free(&tdbv); - if ((strstr(tempraw, alertstring)) != 0) { // // ENDALERT EVENT:CHECK FOR STRING + if ((strstr(tempraw, alertstring)) != nullptr) { // // ENDALERT EVENT:CHECK FOR STRING // there was an alert wasAlert = 1; @@ -405,7 +405,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn HWND hwndDlg = WindowList_Find(hWindowList, hContact); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download successful; about to process data...")); } - else MessageBox(NULL, TranslateT("Unknown alert type."), _A2W(MODULENAME), MB_OK); + else MessageBox(nullptr, TranslateT("Unknown alert type."), _A2W(MODULENAME), MB_OK); } } } @@ -419,11 +419,11 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn *cacheend = '\0'; mir_snwprintf(cachedirectorypath, L"%s%S%S", cachepath, MODULENAME, "cache\\"); - CreateDirectory(cachedirectorypath, NULL); + CreateDirectory(cachedirectorypath, nullptr); mir_snwprintf(newcachepath, L"%s%S%S%S%S", cachepath, MODULENAME, "cache\\", contactname, ".txt"); // file exists? if ( _waccess(newcachepath, 0) != -1) { - if ((pcachefile = _wfopen(newcachepath, L"r")) == NULL) + if ((pcachefile = _wfopen(newcachepath, L"r")) == nullptr) WErrorPopup((UINT_PTR)contactname, TranslateT("Cannot read from file")); else { memset(&cachecompare, 0, sizeof(cachecompare)); @@ -432,7 +432,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn } } // write to cache - if ((pcachefile = _wfopen(newcachepath, L"w")) == NULL) + if ((pcachefile = _wfopen(newcachepath, L"w")) == nullptr) WErrorPopup((UINT_PTR)contactname, TranslateT("Cannot write to file 1")); else { fwrite(tempraw, mir_strlen(tempraw), 1, pcachefile); //smaller cache @@ -500,7 +500,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0)) db_set_s(hContact, "CList", "MyHandle", tstr); } - else MessageBox(NULL, TranslateT("Unknown alert type."), _A2W(MODULENAME), MB_OK); + else MessageBox(nullptr, TranslateT("Unknown alert type."), _A2W(MODULENAME), MB_OK); } } } @@ -517,7 +517,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn } // putting data into string - if (((strstr(tempraw, Alerttempstring)) != 0) && ((strstr(tempraw, Alerttempstring2)) != 0)) { + if (((strstr(tempraw, Alerttempstring)) != nullptr) && ((strstr(tempraw, Alerttempstring2)) != nullptr)) { //start string alertpos = strstr(tempraw, Alerttempstring); statalertpos = alertpos - tempraw; @@ -616,13 +616,13 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Alert start/end strings not found or strings not set.")); } - else MessageBox(NULL, TranslateT("Alert start/end strings not found or strings not set."), _A2W(MODULENAME), MB_OK); + else MessageBox(nullptr, TranslateT("Alert start/end strings not found or strings not set."), _A2W(MODULENAME), MB_OK); db_set_w(hContact, MODULENAME, "Status", ID_STATUS_AWAY); } /////////////// - if (((strstr(tempraw, Alerttempstring)) != 0) && ((strstr(tempraw, Alerttempstring2)) != 0)) { + if (((strstr(tempraw, Alerttempstring)) != nullptr) && ((strstr(tempraw, Alerttempstring2)) != nullptr)) { // TEST GET NAME FOR CACHE wchar_t cachepath[MAX_PATH], cachedirectorypath[MAX_PATH], newcachepath[MAX_PATH + 50]; GetModuleFileName(hInst, cachepath, _countof(cachepath)); @@ -631,11 +631,11 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn *cacheend = '\0'; mir_snwprintf(cachedirectorypath, L"%s%S%S", cachepath, MODULENAME, "cache\\"); - CreateDirectory(cachedirectorypath, NULL); + CreateDirectory(cachedirectorypath, nullptr); mir_snwprintf(newcachepath, L"%s%S%S%S%S", cachepath, MODULENAME, "cache\\", contactname, ".txt"); // file exists? if ( _waccess(newcachepath, 0) != -1) { - if ((pcachefile = _wfopen(newcachepath, L"r")) == NULL) + if ((pcachefile = _wfopen(newcachepath, L"r")) == nullptr) WErrorPopup((UINT_PTR)contactname, TranslateT("Cannot read from file")); else { memset(&cachecompare, 0, sizeof(cachecompare)); @@ -644,7 +644,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn } } // write to cache - if ((pcachefile = _wfopen(newcachepath, L"w")) == NULL) + if ((pcachefile = _wfopen(newcachepath, L"w")) == nullptr) WErrorPopup((UINT_PTR)contactname, TranslateT("Cannot write to file 2")); else { fwrite(raw, mir_strlen(raw), 1, pcachefile); //smaller cache @@ -710,7 +710,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0)) db_set_s(hContact, "CList", "MyHandle", tstr); } - else MessageBox(NULL, TranslateT("Unknown alert type."), _A2W(MODULENAME), MB_OK); + else MessageBox(nullptr, TranslateT("Unknown alert type."), _A2W(MODULENAME), MB_OK); } } } @@ -763,7 +763,7 @@ int DataWndAlertCommand(WPARAM wParam, LPARAM) if ( WindowList_Find(hWindowList, hContact)) return 0; - HWND hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, hContact); + HWND hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), nullptr, DlgProcDisplayData, hContact); HWND hTopmost = db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST; SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0))); if ( db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0)) @@ -802,7 +802,7 @@ void ReadFromFile(void *param) return; FILE *pfile; - if ((pfile = fopen(dbv.pszVal, "r")) == NULL) { + if ((pfile = fopen(dbv.pszVal, "r")) == nullptr) { SendToRichEdit(hwndDlg, Translate("Cannot read from cache file"), TextClr, BackgoundClr); fileexists = 0; } diff --git a/plugins/WebView/src/webview_cleanup.cpp b/plugins/WebView/src/webview_cleanup.cpp index 11c7558f9c..31d081e15c 100644 --- a/plugins/WebView/src/webview_cleanup.cpp +++ b/plugins/WebView/src/webview_cleanup.cpp @@ -374,8 +374,8 @@ void CodetoSymbol(char *truncated) while (true) { // loop forever Sleep(1); // avoid 100% CPU - if ( strstr(truncated, CharacterCodes[n]) != 0) { // does character code exist? - if (strstr(truncated, CharacterCodes[n]) != 0) + if ( strstr(truncated, CharacterCodes[n]) != nullptr) { // does character code exist? + if (strstr(truncated, CharacterCodes[n]) != nullptr) stringfrompos = strstr(truncated, CharacterCodes[n]); position = stringfrompos - truncated; @@ -415,25 +415,25 @@ void EraseBlock(char *truncated) Sleep(1); // avoid 100% CPU // /get start and end of block - if (strstr(tempraw, "") != 0) // does tag exist? + if (strstr(tempraw, "-->") != nullptr) // does tag exist? { stringfrompos = strstr(tempraw, "-->"); positionEnd = stringfrompos - tempraw; } BlockLength = (positionEnd - positionStart) + 3; - if ((strstr(tempraw, "") == 0)) + if ((strstr(tempraw, "") == nullptr)) break; ///////////////////////////////////////// - if (strstr(tempraw, "