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/NewXstatusNotify/src/indsnd.cpp | 18 +++---- plugins/NewXstatusNotify/src/main.cpp | 86 ++++++++++++++++---------------- plugins/NewXstatusNotify/src/options.cpp | 16 +++--- plugins/NewXstatusNotify/src/popup.cpp | 18 +++---- plugins/NewXstatusNotify/src/utils.cpp | 10 ++-- plugins/NewXstatusNotify/src/xstatus.cpp | 38 +++++++------- 6 files changed, 93 insertions(+), 93 deletions(-) (limited to 'plugins/NewXstatusNotify') diff --git a/plugins/NewXstatusNotify/src/indsnd.cpp b/plugins/NewXstatusNotify/src/indsnd.cpp index 6c7d5e9ee5..9e6224f92b 100644 --- a/plugins/NewXstatusNotify/src/indsnd.cpp +++ b/plugins/NewXstatusNotify/src/indsnd.cpp @@ -65,7 +65,7 @@ wchar_t *SelectSound(HWND hwndDlg, wchar_t *buff, size_t bufflen) HWND hList = GetDlgItem(hwndDlg, IDC_INDSNDLIST); ListView_GetItemText(hList, ListView_GetNextItem(hList, -1, LVNI_SELECTED), 1, buff, (DWORD)bufflen); if (!mir_wstrcmp(buff, TranslateW(DEFAULT_SOUND))) - buff = NULL; + buff = nullptr; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = GetParent(hwndDlg); @@ -84,15 +84,15 @@ wchar_t *SelectSound(HWND hwndDlg, wchar_t *buff, size_t bufflen) if (GetOpenFileName(&ofn)) return buff; - return NULL; + return nullptr; } HIMAGELIST GetStatusIconsImgList(char *szProto) { - HIMAGELIST hList = NULL; + HIMAGELIST hList = nullptr; if (szProto) { hList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, STATUS_COUNT - 1, 0); - if (hList != NULL) { + if (hList != nullptr) { for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX; i++) ImageList_AddIcon(hList, Skin_LoadProtoIcon(szProto, i)); ImageList_AddIcon(hList, Skin_LoadIcon(SKINICON_OTHER_USERONLINE)); @@ -201,7 +201,7 @@ INT_PTR CALLBACK DlgProcSoundUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA int iSel = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_INDSNDLIST), -1, LVNI_SELECTED); if (iSel != -1) { wchar_t stzFilePath[MAX_PATH]; - if (SelectSound(hwndDlg, stzFilePath, MAX_PATH - 1) != NULL) { + if (SelectSound(hwndDlg, stzFilePath, MAX_PATH - 1) != nullptr) { iSel = -1; while ((iSel = ListView_GetNextItem(hList, iSel, LVNI_SELECTED)) != -1) ListView_SetItemText(hList, iSel, 1, stzFilePath); @@ -260,7 +260,7 @@ INT_PTR CALLBACK DlgProcSoundUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDC_INDSNDLIST: if (((LPNMHDR)lParam)->code == NM_DBLCLK) { wchar_t stzFilePath[MAX_PATH]; - if (SelectSound(hwndDlg, stzFilePath, MAX_PATH - 1) != NULL) { + if (SelectSound(hwndDlg, stzFilePath, MAX_PATH - 1) != nullptr) { int iSel = -1; while ((iSel = ListView_GetNextItem(hList, iSel, LVNI_SELECTED)) != -1) ListView_SetItemText(hList, iSel, 1, stzFilePath); @@ -470,7 +470,7 @@ INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) SetAllContactsIcons(hList); //fall through case CLN_CONTACTMOVED: - SetGroupsIcons(hList, (HANDLE)SendMessage(hList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); + SetGroupsIcons(hList, (HANDLE)SendMessage(hList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, nullptr); break; case CLN_OPTIONSCHANGED: ResetListOptions(hList); @@ -486,7 +486,7 @@ INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) // Find clicked item HANDLE hItem = (HANDLE)SendMessage(hList, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); - if (hItem == NULL) + if (hItem == nullptr) break; if (!(hitFlags & CLCHT_ONITEMEXTRA)) break; @@ -532,7 +532,7 @@ INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) } // Update the all/none icons - SetGroupsIcons(hList, (HANDLE)SendMessage(hList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); + SetGroupsIcons(hList, (HANDLE)SendMessage(hList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, nullptr); // Activate Apply button SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index a05e146a39..eea1cf800f 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -94,7 +94,7 @@ HANDLE GetIconHandle(char *szIcon) static int __inline CheckStr(char *str, int not_empty, int empty) { - if (str == NULL || str[0] == '\0') + if (str == nullptr || str[0] == '\0') return empty; else return not_empty; @@ -102,7 +102,7 @@ static int __inline CheckStr(char *str, int not_empty, int empty) static int __inline CheckStrW(WCHAR *str, int not_empty, int empty) { - if (str == NULL || str[0] == L'\0') + if (str == nullptr || str[0] == L'\0') return empty; else return not_empty; @@ -114,33 +114,33 @@ static int CompareStatusMsg(STATUSMSGINFO *smi, DBCONTACTWRITESETTING *cws_new, switch (cws_new->value.type) { case DBVT_ASCIIZ: - smi->newstatusmsg = (CheckStr(cws_new->value.pszVal, 0, 1) ? NULL : mir_a2u_cp(cws_new->value.pszVal, CP_ACP)); + smi->newstatusmsg = (CheckStr(cws_new->value.pszVal, 0, 1) ? nullptr : mir_a2u_cp(cws_new->value.pszVal, CP_ACP)); break; case DBVT_UTF8: - smi->newstatusmsg = (CheckStr(cws_new->value.pszVal, 0, 1) ? NULL : mir_a2u_cp(cws_new->value.pszVal, CP_UTF8)); + smi->newstatusmsg = (CheckStr(cws_new->value.pszVal, 0, 1) ? nullptr : mir_a2u_cp(cws_new->value.pszVal, CP_UTF8)); break; case DBVT_WCHAR: - smi->newstatusmsg = (CheckStrW(cws_new->value.pwszVal, 0, 1) ? NULL : mir_wstrdup(cws_new->value.pwszVal)); + smi->newstatusmsg = (CheckStrW(cws_new->value.pwszVal, 0, 1) ? nullptr : mir_wstrdup(cws_new->value.pwszVal)); break; case DBVT_DELETED: default: - smi->newstatusmsg = NULL; + smi->newstatusmsg = nullptr; break; } if (!db_get_s(smi->hContact, "UserOnline", szSetting, &dbv_old, 0)) { switch (dbv_old.type) { case DBVT_ASCIIZ: - smi->oldstatusmsg = (CheckStr(dbv_old.pszVal, 0, 1) ? NULL : mir_a2u_cp(dbv_old.pszVal, CP_ACP)); + smi->oldstatusmsg = (CheckStr(dbv_old.pszVal, 0, 1) ? nullptr : mir_a2u_cp(dbv_old.pszVal, CP_ACP)); break; case DBVT_UTF8: - smi->oldstatusmsg = (CheckStr(dbv_old.pszVal, 0, 1) ? NULL : mir_a2u_cp(dbv_old.pszVal, CP_UTF8)); + smi->oldstatusmsg = (CheckStr(dbv_old.pszVal, 0, 1) ? nullptr : mir_a2u_cp(dbv_old.pszVal, CP_UTF8)); break; case DBVT_WCHAR: - smi->oldstatusmsg = (CheckStrW(dbv_old.pwszVal, 0, 1) ? NULL : mir_wstrdup(dbv_old.pwszVal)); + smi->oldstatusmsg = (CheckStrW(dbv_old.pwszVal, 0, 1) ? nullptr : mir_wstrdup(dbv_old.pwszVal)); break; default: - smi->oldstatusmsg = NULL; + smi->oldstatusmsg = nullptr; break; } @@ -176,7 +176,7 @@ static int CompareStatusMsg(STATUSMSGINFO *smi, DBCONTACTWRITESETTING *cws_new, else ret = COMPARE_DIFF; - smi->oldstatusmsg = NULL; + smi->oldstatusmsg = nullptr; } return ret; @@ -184,8 +184,8 @@ static int CompareStatusMsg(STATUSMSGINFO *smi, DBCONTACTWRITESETTING *cws_new, wchar_t* GetStr(STATUSMSGINFO *n, const wchar_t *tmplt) { - if (n == NULL || tmplt == NULL || tmplt[0] == '\0') - return NULL; + if (n == nullptr || tmplt == nullptr || tmplt[0] == '\0') + return nullptr; CMStringW res; size_t len = mir_wstrlen(tmplt); @@ -202,7 +202,7 @@ wchar_t* GetStr(STATUSMSGINFO *n, const wchar_t *tmplt) break; case 'o': - if (n->oldstatusmsg == NULL || n->oldstatusmsg[0] == '\0' || mir_wstrcmp(n->oldstatusmsg, TranslateT("")) == 0) + if (n->oldstatusmsg == nullptr || n->oldstatusmsg[0] == '\0' || mir_wstrcmp(n->oldstatusmsg, TranslateT("")) == 0) res.Append(TranslateT("")); else AddCR(res, n->oldstatusmsg); @@ -271,7 +271,7 @@ void LogSMsgToDB(STATUSMSGINFO *smi, const wchar_t *tmplt) dbei.eventType = EVENTTYPE_STATUSCHANGE; dbei.flags = DBEF_READ | DBEF_UTF; - dbei.timestamp = (DWORD)time(NULL); + dbei.timestamp = (DWORD)time(nullptr); dbei.szModule = MODULE; MEVENT hDBEvent = db_event_add(smi->hContact, &dbei); @@ -356,7 +356,7 @@ int ContactStatusChanged(MCONTACT hContact, WORD oldStatus, WORD newStatus) dbei.eventType = EVENTTYPE_STATUSCHANGE; dbei.flags = DBEF_READ | DBEF_UTF; - dbei.timestamp = (DWORD)time(NULL); + dbei.timestamp = (DWORD)time(nullptr); dbei.szModule = MODULE; MEVENT hDBEvent = db_event_add(hContact, &dbei); @@ -375,7 +375,7 @@ int ContactStatusChanged(MCONTACT hContact, WORD oldStatus, WORD newStatus) if (!mir_strcmp(szProto, META_PROTO)) { //this contact is Meta MCONTACT hSubContact = db_mc_getMostOnline(hContact); char *szSubProto = GetContactProto(hSubContact); - if (szSubProto == NULL) + if (szSubProto == nullptr) return 0; if (newStatus == ID_STATUS_OFFLINE) { @@ -431,8 +431,8 @@ int ContactStatusChanged(MCONTACT hContact, WORD oldStatus, WORD newStatus) PLUGINDATA *pdp = (PLUGINDATA *)mir_calloc(sizeof(PLUGINDATA)); pdp->oldStatus = oldStatus; pdp->newStatus = newStatus; - pdp->hAwayMsgHook = NULL; - pdp->hAwayMsgProcess = NULL; + pdp->hAwayMsgHook = nullptr; + pdp->hAwayMsgProcess = nullptr; ShowChangePopup(hContact, Skin_LoadProtoIcon(szProto, newStatus), newStatus, str, pdp); } @@ -453,8 +453,8 @@ int ContactStatusChanged(MCONTACT hContact, WORD oldStatus, WORD newStatus) if (opt.LogToFile) { wchar_t stzDate[MAX_STATUSTEXT], stzTime[MAX_STATUSTEXT], stzText[MAX_TEXT_LEN]; - GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, L"HH':'mm", stzTime, _countof(stzTime)); - GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, L"dd/MM/yyyy", stzDate, _countof(stzDate)); + GetTimeFormat(LOCALE_USER_DEFAULT, 0, nullptr, L"HH':'mm", stzTime, _countof(stzTime)); + GetDateFormat(LOCALE_USER_DEFAULT, 0, nullptr, L"dd/MM/yyyy", stzDate, _countof(stzDate)); mir_snwprintf(stzText, TranslateT("%s, %s. %s changed status to %s (was %s)\r\n"), stzDate, stzTime, pcli->pfnGetContactDisplayName(hContact, 0), StatusList[Index(newStatus)].lpzStandardText, StatusList[Index(oldStatus)].lpzStandardText); @@ -535,8 +535,8 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) if (strstr(cws->szSetting, "title")) { smi.compare = CompareStatusMsg(&smi, cws, szSetting); if (smi.compare == COMPARE_SAME) { - replaceStrW(smi.newstatusmsg, 0); - replaceStrW(smi.oldstatusmsg, 0); + replaceStrW(smi.newstatusmsg, nullptr); + replaceStrW(smi.oldstatusmsg, nullptr); } if (cws->value.type == DBVT_DELETED) @@ -544,7 +544,7 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) else db_set(hContact, "UserOnline", szSetting, &cws->value); - xsc = NewXSC(hContact, szProto, type, smi.compare, smi.newstatusmsg, NULL); + xsc = NewXSC(hContact, szProto, type, smi.compare, smi.newstatusmsg, nullptr); ExtraStatusChanged(xsc); } else if (strstr(cws->szSetting, "text")) { @@ -552,8 +552,8 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) mir_snprintf(dbSetting, "%s%s", szSetting, "Msg"); smi.compare = CompareStatusMsg(&smi, cws, dbSetting); if (smi.compare == COMPARE_SAME) { - replaceStrW(smi.newstatusmsg, 0); - replaceStrW(smi.oldstatusmsg, 0); + replaceStrW(smi.newstatusmsg, nullptr); + replaceStrW(smi.oldstatusmsg, nullptr); } if (cws->value.type == DBVT_DELETED) @@ -561,7 +561,7 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) else db_set(hContact, "UserOnline", dbSetting, &cws->value); - xsc = NewXSC(hContact, szProto, type, smi.compare * 4, NULL, smi.newstatusmsg); + xsc = NewXSC(hContact, szProto, type, smi.compare * 4, nullptr, smi.newstatusmsg); ExtraStatusChanged(xsc); } return 1; @@ -574,8 +574,8 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) if (mir_strcmp(cws->szSetting, "XStatusName") == 0) { smi.compare = CompareStatusMsg(&smi, cws, "LastXStatusName"); if (smi.compare == COMPARE_SAME) { - replaceStrW(smi.newstatusmsg, 0); - replaceStrW(smi.oldstatusmsg, 0); + replaceStrW(smi.newstatusmsg, nullptr); + replaceStrW(smi.oldstatusmsg, nullptr); } if (cws->value.type == DBVT_DELETED) @@ -583,14 +583,14 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) else db_set(hContact, "UserOnline", "LastXStatusName", &cws->value); - xsc = NewXSC(hContact, szProto, TYPE_ICQ_XSTATUS, smi.compare, smi.newstatusmsg, NULL); + xsc = NewXSC(hContact, szProto, TYPE_ICQ_XSTATUS, smi.compare, smi.newstatusmsg, nullptr); ExtraStatusChanged(xsc); } else if (!mir_strcmp(cws->szSetting, "XStatusMsg")) { smi.compare = CompareStatusMsg(&smi, cws, "LastXStatusMsg"); if (smi.compare == COMPARE_SAME) { - replaceStrW(smi.newstatusmsg, 0); - replaceStrW(smi.oldstatusmsg, 0); + replaceStrW(smi.newstatusmsg, nullptr); + replaceStrW(smi.oldstatusmsg, nullptr); } if (cws->value.type == DBVT_DELETED) @@ -598,7 +598,7 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) else db_set(hContact, "UserOnline", "LastXStatusMsg", &cws->value); - xsc = NewXSC(hContact, szProto, TYPE_ICQ_XSTATUS, smi.compare * 4, NULL, smi.newstatusmsg); + xsc = NewXSC(hContact, szProto, TYPE_ICQ_XSTATUS, smi.compare * 4, nullptr, smi.newstatusmsg); ExtraStatusChanged(xsc); } return 1; @@ -678,7 +678,7 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) if (bEnablePopup && db_get_b(hContact, MODULE, "EnablePopups", 1) && !opt.TempDisabled) { // cut message if needed - wchar_t *copyText = NULL; + wchar_t *copyText = nullptr; if (opt.PSMsgTruncate && (opt.PSMsgLen > 0) && smi.newstatusmsg && (mir_wstrlen(smi.newstatusmsg) > opt.PSMsgLen)) { wchar_t buff[MAX_TEXT_LEN + 3]; copyText = mir_wstrdup(smi.newstatusmsg); @@ -747,8 +747,8 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) if (opt.SMsgLogToFile && db_get_b(hContact, MODULE, "EnableSMsgLogging", 1)) { wchar_t stzDate[MAX_STATUSTEXT], stzTime[MAX_STATUSTEXT], stzText[MAX_TEXT_LEN]; - GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, L"HH':'mm", stzTime, _countof(stzTime)); - GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, L"dd/MM/yyyy", stzDate, _countof(stzDate)); + GetTimeFormat(LOCALE_USER_DEFAULT, 0, nullptr, L"HH':'mm", stzTime, _countof(stzTime)); + GetDateFormat(LOCALE_USER_DEFAULT, 0, nullptr, L"dd/MM/yyyy", stzDate, _countof(stzDate)); wchar_t *str; if (smi.compare == COMPARE_DEL) @@ -763,8 +763,8 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) } skip_notify: - replaceStrW(smi.newstatusmsg, 0); - replaceStrW(smi.oldstatusmsg, 0); + replaceStrW(smi.newstatusmsg, nullptr); + replaceStrW(smi.oldstatusmsg, nullptr); return 1; } @@ -774,7 +774,7 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) return 0; char *szProto = GetContactProto(hContact); - if (szProto == NULL) + if (szProto == nullptr) return 0; DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; @@ -796,7 +796,7 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) int StatusModeChanged(WPARAM wParam, LPARAM lParam) { char *szProto = (char *)lParam; - if (opt.AutoDisable && (!opt.OnlyGlobalChanges || szProto == NULL)) { + if (opt.AutoDisable && (!opt.OnlyGlobalChanges || szProto == nullptr)) { if (opt.DisablePopupGlobally && ServiceExists(MS_POPUP_QUERY)) { char szSetting[12]; mir_snprintf(szSetting, "p%d", wParam); @@ -1112,7 +1112,7 @@ void InitSound() int InitTopToolbar(WPARAM, LPARAM) { - TTBButton tbb = { 0 }; + TTBButton tbb = {}; tbb.pszService = MS_STATUSCHANGE_MENUCOMMAND; tbb.dwFlags = (opt.TempDisabled ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON; tbb.name = LPGEN("Toggle status notification"); @@ -1135,10 +1135,10 @@ int ModulesLoaded(WPARAM, LPARAM) SecretWnd = CreateWindowEx(WS_EX_TOOLWINDOW, L"static", L"ConnectionTimerWindow", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, - NULL, hInst, NULL); + nullptr, hInst, nullptr); int count = 0; - PROTOACCOUNT **accounts = NULL; + PROTOACCOUNT **accounts = nullptr; Proto_EnumAccounts(&count, &accounts); for (int i = 0; i < count; i++) if (Proto_IsAccountEnabled(accounts[i])) diff --git a/plugins/NewXstatusNotify/src/options.cpp b/plugins/NewXstatusNotify/src/options.cpp index 6e2ca296df..82705d78b0 100644 --- a/plugins/NewXstatusNotify/src/options.cpp +++ b/plugins/NewXstatusNotify/src/options.cpp @@ -403,12 +403,12 @@ INT_PTR CALLBACK DlgProcPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM mir_wstrcat(str, TranslateT("This is status message")); } - ShowChangePopup(NULL, Skin_LoadProtoIcon(NULL, i), i, str); + ShowChangePopup(NULL, Skin_LoadProtoIcon(nullptr, i), i, str); } wcsncpy(str, TranslateT("This is extra status"), _countof(str)); - ShowChangePopup(NULL, Skin_LoadProtoIcon(NULL, ID_STATUS_ONLINE), ID_STATUS_EXTRASTATUS, str); + ShowChangePopup(NULL, Skin_LoadProtoIcon(nullptr, ID_STATUS_ONLINE), ID_STATUS_EXTRASTATUS, str); wcsncpy(str, TranslateT("This is status message"), _countof(str)); - ShowChangePopup(NULL, Skin_LoadProtoIcon(NULL, ID_STATUS_ONLINE), ID_STATUS_STATUSMSG, str); + ShowChangePopup(NULL, Skin_LoadProtoIcon(nullptr, ID_STATUS_ONLINE), ID_STATUS_STATUSMSG, str); return FALSE; } @@ -449,8 +449,8 @@ INT_PTR CALLBACK DlgProcPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM opt.ReadAwayMsg = IsDlgButtonChecked(hwndDlg, IDC_READAWAYMSG); opt.ShowPreviousStatus = IsDlgButtonChecked(hwndDlg, IDC_SHOWPREVIOUSSTATUS); opt.ShowGroup = IsDlgButtonChecked(hwndDlg, IDC_SHOWGROUP); - opt.PopupTimeout = GetDlgItemInt(hwndDlg, IDC_TIMEOUT_VALUE, 0, TRUE); - opt.PopupConnectionTimeout = GetDlgItemInt(hwndDlg, IDC_CONNECTIONTIMEOUT_VALUE, 0, TRUE); + opt.PopupTimeout = GetDlgItemInt(hwndDlg, IDC_TIMEOUT_VALUE, nullptr, TRUE); + opt.PopupConnectionTimeout = GetDlgItemInt(hwndDlg, IDC_CONNECTIONTIMEOUT_VALUE, nullptr, TRUE); opt.LeftClickAction = (BYTE)SendDlgItemMessage(hwndDlg, IDC_STATUS_LC, CB_GETCURSEL, 0, 0); opt.RightClickAction = (BYTE)SendDlgItemMessage(hwndDlg, IDC_STATUS_RC, CB_GETCURSEL, 0, 0); @@ -617,7 +617,7 @@ INT_PTR CALLBACK DlgProcXPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM opt.PXOnConnect = IsDlgButtonChecked(hwndDlg, IDC_XONCONNECT); opt.PXDisableForMusic = IsDlgButtonChecked(hwndDlg, IDC_CHK_DISABLEMUSIC); opt.PXMsgTruncate = IsDlgButtonChecked(hwndDlg, IDC_CHK_CUTMSG); - opt.PXMsgLen = GetDlgItemInt(hwndDlg, IDC_ED_MSGLEN, 0, FALSE); + opt.PXMsgLen = GetDlgItemInt(hwndDlg, IDC_ED_MSGLEN, nullptr, FALSE); templates.PopupXFlags = 0; templates.PopupXFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CHK_XSTATUSCHANGE) ? NOTIFY_NEW_XSTATUS : 0) | @@ -662,7 +662,7 @@ INT_PTR CALLBACK DlgProcXPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM bool IsSuitableProto(PROTOACCOUNT *pa) { - return (pa != NULL && !pa->bDynDisabled && pa->bIsEnabled && CallProtoService(pa->szProtoName, PS_GETCAPS, PFLAGNUM_2, 0) != 0 && CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGRECV); + return (pa != nullptr && !pa->bDynDisabled && pa->bIsEnabled && CallProtoService(pa->szProtoName, PS_GETCAPS, PFLAGNUM_2, 0) != 0 && CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGRECV); } INT_PTR CALLBACK DlgProcSMPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) @@ -829,7 +829,7 @@ INT_PTR CALLBACK DlgProcSMPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA if (((LPNMHDR)lParam)->code == PSN_APPLY) { opt.PSMsgOnConnect = IsDlgButtonChecked(hwndDlg, IDC_ONCONNECT); opt.PSMsgTruncate = IsDlgButtonChecked(hwndDlg, IDC_CHK_CUTSMSG); - opt.PSMsgLen = GetDlgItemInt(hwndDlg, IDC_ED_SMSGLEN, 0, FALSE); + opt.PSMsgLen = GetDlgItemInt(hwndDlg, IDC_ED_SMSGLEN, nullptr, FALSE); templates.PopupSMsgFlags = 0; templates.PopupSMsgFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CHK_NEWSMSG) ? NOTIFY_NEW_MESSAGE : 0) | diff --git a/plugins/NewXstatusNotify/src/popup.cpp b/plugins/NewXstatusNotify/src/popup.cpp index 386f9f3196..8b4593ce47 100644 --- a/plugins/NewXstatusNotify/src/popup.cpp +++ b/plugins/NewXstatusNotify/src/popup.cpp @@ -62,7 +62,7 @@ void ShowChangePopup(MCONTACT hContact, HICON hIcon, WORD newStatus, const wchar static int AwayMsgHook(WPARAM, LPARAM lParam, LPARAM pObj) { PLUGINDATA *pdp = (PLUGINDATA *)pObj; - if (pdp == NULL) + if (pdp == nullptr) return 0; ACKDATA *ack = (ACKDATA *)lParam; @@ -71,7 +71,7 @@ static int AwayMsgHook(WPARAM, LPARAM lParam, LPARAM pObj) //The first thing we do is removing the hook from the chain to avoid useless calls. UnhookEvent(pdp->hAwayMsgHook); - pdp->hAwayMsgHook = NULL; + pdp->hAwayMsgHook = nullptr; if (ack->result != ACKRESULT_SUCCESS) return 0; @@ -80,7 +80,7 @@ static int AwayMsgHook(WPARAM, LPARAM lParam, LPARAM pObj) ptrW pstzLast(db_get_wsa(hContact, MODULE, "LastPopupText")); wchar_t *tszStatus = (wchar_t *)ack->lParam; - if (tszStatus == NULL || *tszStatus == 0) + if (tszStatus == nullptr || *tszStatus == 0) return 0; wchar_t stzText[1024]; @@ -125,7 +125,7 @@ void PopupAction(HWND hWnd, BYTE action) POINT pt = { 0 }; GetCursorPos(&pt); HMENU hMenu = Menu_BuildContactMenu(hContact); - TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hWnd, NULL); + TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hWnd, nullptr); DestroyMenu(hMenu); } return; @@ -151,7 +151,7 @@ void PopupAction(HWND hWnd, BYTE action) LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - PLUGINDATA *pdp = NULL; + PLUGINDATA *pdp = nullptr; switch (message) { case WM_MEASUREITEM: // Needed by the contact's context menu @@ -174,10 +174,10 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case UM_FREEPLUGINDATA: pdp = (PLUGINDATA *)PUGetPluginData(hwnd); - if (pdp != NULL) { - if (pdp->hAwayMsgHook != NULL) { + if (pdp != nullptr) { + if (pdp->hAwayMsgHook != nullptr) { UnhookEvent(pdp->hAwayMsgHook); - pdp->hAwayMsgHook = NULL; + pdp->hAwayMsgHook = nullptr; } mir_free(pdp); @@ -186,7 +186,7 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case UM_INITPOPUP: pdp = (PLUGINDATA *)PUGetPluginData(hwnd); - if (pdp != NULL) { + if (pdp != nullptr) { char *szProto = GetContactProto(PUGetContact(hwnd)); if (szProto && opt.ReadAwayMsg && StatusHasAwayMessage(szProto, pdp->newStatus)) { WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0); diff --git a/plugins/NewXstatusNotify/src/utils.cpp b/plugins/NewXstatusNotify/src/utils.cpp index 56ef4931c7..120964b038 100644 --- a/plugins/NewXstatusNotify/src/utils.cpp +++ b/plugins/NewXstatusNotify/src/utils.cpp @@ -28,7 +28,7 @@ bool CheckMsgWnd(MCONTACT hContact) if (Srmm_GetWindowData(hContact, mwd) != NULL) return false; - if (mwd.hwndWindow != NULL && (mwd.uState & MSG_WINDOW_STATE_EXISTS)) + if (mwd.hwndWindow != nullptr && (mwd.uState & MSG_WINDOW_STATE_EXISTS)) return true; return false; @@ -49,14 +49,14 @@ int DBGetStringDefault(MCONTACT hContact, const char *szModule, const char *szSe void ShowLog(wchar_t *file) { - INT_PTR res = (INT_PTR)ShellExecute(NULL, L"open", file, NULL, NULL, SW_SHOW); + INT_PTR res = (INT_PTR)ShellExecute(nullptr, L"open", file, nullptr, nullptr, SW_SHOW); if (res <= 32) // error - MessageBox(0, TranslateT("Can't open the log file!"), TranslateT("NewXstatusNotify"), MB_OK | MB_ICONERROR); + MessageBox(nullptr, TranslateT("Can't open the log file!"), TranslateT("NewXstatusNotify"), MB_OK | MB_ICONERROR); } BOOL StatusHasAwayMessage(char *szProto, int status) { - if (szProto != NULL) { + if (szProto != nullptr) { unsigned long iSupportsSM = (unsigned long)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0); return (iSupportsSM & Proto_Status2Flag(status)) ? TRUE : FALSE; } @@ -87,7 +87,7 @@ void LogToFile(wchar_t *stzText) void AddCR(CMStringW &str, const wchar_t *stzText) { - if (stzText == NULL) + if (stzText == nullptr) return; CMStringW res(stzText); diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp index 0ebdb88bb1..a3cacaecb0 100644 --- a/plugins/NewXstatusNotify/src/xstatus.cpp +++ b/plugins/NewXstatusNotify/src/xstatus.cpp @@ -92,7 +92,7 @@ wchar_t* GetStatusTypeAsString(int type, wchar_t *buff) CMStringW ReplaceVars(XSTATUSCHANGE *xsc, const wchar_t *tmplt) { - if (xsc == NULL || tmplt == NULL || tmplt[0] == '\0') + if (xsc == nullptr || tmplt == nullptr || tmplt[0] == '\0') return CMStringW(); size_t len = mir_wstrlen(tmplt); @@ -108,14 +108,14 @@ CMStringW ReplaceVars(XSTATUSCHANGE *xsc, const wchar_t *tmplt) break; case 't': - if (xsc->stzTitle == NULL || xsc->stzTitle[0] == '\0') + if (xsc->stzTitle == nullptr || xsc->stzTitle[0] == '\0') res.Append(TranslateT("")); else res.Append(xsc->stzTitle); break; case 'm': - if (xsc->stzText == NULL || xsc->stzText[0] == '\0') + if (xsc->stzText == nullptr || xsc->stzText[0] == '\0') res.Append(TranslateT("")); else AddCR(res, xsc->stzText); @@ -162,10 +162,10 @@ CMStringW ReplaceVars(XSTATUSCHANGE *xsc, const wchar_t *tmplt) void ShowXStatusPopup(XSTATUSCHANGE *xsc) { - if (xsc == NULL) + if (xsc == nullptr) return; - HICON hIcon = NULL; + HICON hIcon = nullptr; switch (xsc->type) { case TYPE_JABBER_MOOD: @@ -184,11 +184,11 @@ void ShowXStatusPopup(XSTATUSCHANGE *xsc) hIcon = (HICON)CallProtoService(xsc->szProto, PS_GETCUSTOMSTATUSICON, statusId, LR_SHARED); } - if (hIcon == NULL) + if (hIcon == nullptr) hIcon = Skin_LoadProtoIcon(xsc->szProto, db_get_w(xsc->hContact, xsc->szProto, "Status", ID_STATUS_ONLINE)); // cut message if needed - wchar_t *copyText = NULL; + wchar_t *copyText = nullptr; if (opt.PXMsgTruncate && (opt.PXMsgLen > 0) && xsc->stzText && (mir_wstrlen(xsc->stzText) > opt.PXMsgLen)) { wchar_t buff[MAX_TEXT_LEN + 3]; copyText = mir_wstrdup(xsc->stzText); @@ -220,10 +220,10 @@ void ShowXStatusPopup(XSTATUSCHANGE *xsc) void BlinkXStatusIcon(XSTATUSCHANGE *xsc) { - if (xsc == NULL) + if (xsc == nullptr) return; - HICON hIcon = NULL; + HICON hIcon = nullptr; wchar_t str[256] = { 0 }; wchar_t stzType[32]; mir_snwprintf(str, TranslateT("%s changed %s"), pcli->pfnGetContactDisplayName(xsc->hContact, 0), GetStatusTypeAsString(xsc->type, stzType)); @@ -247,7 +247,7 @@ void BlinkXStatusIcon(XSTATUSCHANGE *xsc) } } - if (hIcon == NULL) + if (hIcon == nullptr) hIcon = Skin_LoadIcon(SKINICON_OTHER_USERONLINE); BlinkIcon(xsc->hContact, hIcon, str); @@ -270,7 +270,7 @@ void PlayXStatusSound(MCONTACT hContact, int action) void LogChangeToDB(XSTATUSCHANGE *xsc) { - if (xsc == NULL || (opt.XLogToDB_WinOpen && !CheckMsgWnd(xsc->hContact))) + if (xsc == nullptr || (opt.XLogToDB_WinOpen && !CheckMsgWnd(xsc->hContact))) return; wchar_t *Template = L""; @@ -301,7 +301,7 @@ void LogChangeToDB(XSTATUSCHANGE *xsc) dbei.pBlob = (PBYTE)(char*)blob; dbei.eventType = EVENTTYPE_STATUSCHANGE; dbei.flags = DBEF_READ | DBEF_UTF; - dbei.timestamp = (DWORD)time(NULL); + dbei.timestamp = (DWORD)time(nullptr); dbei.szModule = MODULE; MEVENT hDBEvent = db_event_add(xsc->hContact, &dbei); @@ -316,13 +316,13 @@ void LogChangeToDB(XSTATUSCHANGE *xsc) void LogChangeToFile(XSTATUSCHANGE *xsc) { - if (xsc == NULL) + if (xsc == nullptr) return; wchar_t stzDate[32], stzTime[32], stzText[MAX_TEXT_LEN]; - GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, L"HH':'mm", stzTime, _countof(stzTime)); - GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, L"dd/MM/yyyy", stzDate, _countof(stzDate)); + GetTimeFormat(LOCALE_USER_DEFAULT, 0, nullptr, L"HH':'mm", stzTime, _countof(stzTime)); + GetDateFormat(LOCALE_USER_DEFAULT, 0, nullptr, L"dd/MM/yyyy", stzDate, _countof(stzDate)); wchar_t *Template = L""; switch (xsc->action) { @@ -344,7 +344,7 @@ void LogChangeToFile(XSTATUSCHANGE *xsc) void ExtraStatusChanged(XSTATUSCHANGE *xsc) { - if (xsc == NULL) + if (xsc == nullptr) return; BOOL bEnablePopup = true, bEnableSound = true, bEnableLog = opt.XLogToDB; @@ -463,7 +463,7 @@ wchar_t* GetJabberAdvStatusText(MCONTACT hContact, char *szProto, char *szSlot, void LogXstatusChange(MCONTACT hContact, char *szProto, int xstatusType, wchar_t *stzTitle, wchar_t *stzText) { - XSTATUSCHANGE *xsc = NewXSC(hContact, szProto, xstatusType, NOTIFY_OPENING_ML, stzTitle[0] ? mir_wstrdup(stzTitle) : NULL, stzText[0] ? mir_wstrdup(stzText) : NULL); + XSTATUSCHANGE *xsc = NewXSC(hContact, szProto, xstatusType, NOTIFY_OPENING_ML, stzTitle[0] ? mir_wstrdup(stzTitle) : nullptr, stzText[0] ? mir_wstrdup(stzText) : nullptr); LogChangeToDB(xsc); FreeXSC(xsc); @@ -474,7 +474,7 @@ void AddXStatusEventThread(void *arg) MCONTACT hContact = (MCONTACT)(DWORD_PTR)arg; char *szProto = GetContactProto(hContact); - if (szProto == NULL) + if (szProto == nullptr) return; wchar_t stzTitle[MAX_TITLE_LEN], stzText[MAX_TEXT_LEN]; @@ -507,7 +507,7 @@ void AddSMsgEventThread(void *arg) STATUSMSGINFO smi; smi.hContact = hContact; smi.proto = GetContactProto(hContact); - if (smi.proto == NULL) + if (smi.proto == nullptr) return; smi.newstatusmsg = db_get_wsa(smi.hContact, "CList", "StatusMsg"); -- cgit v1.2.3