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/ListeningTo/src/listeningto.cpp | 94 ++++++++++++++--------------- plugins/ListeningTo/src/main.cpp | 2 +- plugins/ListeningTo/src/music.cpp | 4 +- plugins/ListeningTo/src/options.cpp | 16 ++--- plugins/ListeningTo/src/players/generic.cpp | 40 ++++++------ plugins/ListeningTo/src/players/itunes.cpp | 26 ++++---- plugins/ListeningTo/src/players/player.cpp | 36 +++++------ plugins/ListeningTo/src/players/watrack.cpp | 18 +++--- plugins/ListeningTo/src/players/wmp.cpp | 34 +++++------ plugins/ListeningTo/src/variables.cpp | 4 +- 10 files changed, 137 insertions(+), 137 deletions(-) (limited to 'plugins/ListeningTo/src') diff --git a/plugins/ListeningTo/src/listeningto.cpp b/plugins/ListeningTo/src/listeningto.cpp index 8ec11cec68..ad77475d8a 100644 --- a/plugins/ListeningTo/src/listeningto.cpp +++ b/plugins/ListeningTo/src/listeningto.cpp @@ -20,11 +20,11 @@ Boston, MA 02111-1307, USA. #include "stdafx.h" HANDLE hExtraIcon; -static HGENMENU hMainMenuGroup = NULL; +static HGENMENU hMainMenuGroup = nullptr; static HANDLE hListeningInfoChangedEvent; static HANDLE hEnableStateChangedEvent; -static HANDLE hTTB = NULL; +static HANDLE hTTB = nullptr; BOOL loaded = FALSE; static UINT hTimer = 0; static DWORD lastInfoSetTime = 0; @@ -45,7 +45,7 @@ INT_PTR MainMenuClicked(WPARAM wParam, LPARAM lParam); bool ListeningToEnabled(char *proto, bool ignoreGlobal = false); INT_PTR ListeningToEnabled(WPARAM wParam, LPARAM lParam); INT_PTR EnableListeningTo(WPARAM wParam, LPARAM lParam); -INT_PTR EnableListeningTo(char *proto = NULL, bool enabled = false); +INT_PTR EnableListeningTo(char *proto = nullptr, bool enabled = false); INT_PTR GetTextFormat(WPARAM wParam, LPARAM lParam); wchar_t* GetParsedFormat(LISTENINGTOINFO *lti); INT_PTR GetParsedFormat(WPARAM wParam, LPARAM lParam); @@ -53,7 +53,7 @@ INT_PTR GetOverrideContactOption(WPARAM wParam, LPARAM lParam); INT_PTR GetUnknownText(WPARAM wParam, LPARAM lParam); INT_PTR SetNewSong(WPARAM wParam, LPARAM lParam); void SetExtraIcon(MCONTACT hContact, BOOL set); -void SetListeningInfos(LISTENINGTOINFO *lti = NULL); +void SetListeningInfos(LISTENINGTOINFO *lti = nullptr); INT_PTR HotkeysEnable(WPARAM wParam, LPARAM lParam); INT_PTR HotkeysDisable(WPARAM wParam, LPARAM lParam); INT_PTR HotkeysToggle(WPARAM wParam, LPARAM lParam); @@ -62,12 +62,12 @@ INT_PTR HotkeysToggle(WPARAM wParam, LPARAM lParam); void UpdateGlobalStatusMenus() { - bool enabled = ListeningToEnabled(NULL, true); + bool enabled = ListeningToEnabled(nullptr, true); Menu_SetChecked(proto_items[0].hMenu, enabled); Menu_EnableItem(proto_items[0].hMenu, opts.enable_sending); - if (hTTB != NULL) + if (hTTB != nullptr) CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTTB, (LPARAM)(enabled ? TTBST_PUSHED : 0)); } @@ -88,7 +88,7 @@ void RebuildMenu() for (unsigned int i = 1; i < proto_items.size(); i++) { ProtocolInfo *info = &proto_items[i]; - if (info->hMenu != NULL) + if (info->hMenu != nullptr) Menu_RemoveItem(info->hMenu); wchar_t text[512]; @@ -124,7 +124,7 @@ void RegisterProtocol(char *proto, wchar_t *account) mir_wstrncpy(proto_items[id].account, account, _countof(proto_items[id].account)); - proto_items[id].hMenu = NULL; + proto_items[id].hMenu = nullptr; proto_items[id].old_xstatus = 0; proto_items[id].old_xstatus_name[0] = '\0'; proto_items[id].old_xstatus_message[0] = '\0'; @@ -134,11 +134,11 @@ void RegisterProtocol(char *proto, wchar_t *account) int AccListChanged(WPARAM wParam, LPARAM lParam) { PROTOACCOUNT *proto = (PROTOACCOUNT *)lParam; - if (proto == NULL) + if (proto == nullptr) return 0; ProtocolInfo *info = GetProtoInfo(proto->szModuleName); - if (info != NULL) { + if (info != nullptr) { if (wParam == PRAC_UPGRADED || wParam == PRAC_CHANGED) { mir_wstrncpy(info->account, proto->tszAccountName, _countof(info->account)); @@ -180,10 +180,10 @@ int ModulesLoaded(WPARAM, LPARAM) for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { char *proto = GetContactProto(hContact); - if (proto != NULL) { + if (proto != nullptr) { DBVARIANT dbv; if (!db_get_ws(hContact, proto, "ListeningTo", &dbv)) { - if (dbv.ptszVal != NULL && dbv.ptszVal[0] != 0) + if (dbv.ptszVal != nullptr && dbv.ptszVal[0] != 0) SetExtraIcon(hContact, TRUE); db_free(&dbv); @@ -203,13 +203,13 @@ int ModulesLoaded(WPARAM, LPARAM) mi.root = hMainMenuGroup; mi.position = 0; mi.pszService = MS_LISTENINGTO_MAINMENU; - mi.hIcolibItem = NULL; + mi.hIcolibItem = nullptr; // Add all protos SET_UID(mi, 0xc396a9dd, 0x9a00, 0x46af, 0x96, 0x2e, 0x5, 0x5a, 0xbc, 0x52, 0xfc, 0x9b); mi.name.w = LPGENW("Send to all protocols"); mi.flags = CMIF_UNICODE - | (ListeningToEnabled(NULL, true) ? CMIF_CHECKED : 0) + | (ListeningToEnabled(nullptr, true) ? CMIF_CHECKED : 0) | (opts.enable_sending ? 0 : CMIF_GRAYED); proto_items.resize(1); proto_items[0].hMenu = Menu_AddMainMenuItem(&mi); @@ -325,7 +325,7 @@ int PreShutdown(WPARAM, LPARAM) loaded = FALSE; if (hTimer != NULL) { - KillTimer(NULL, hTimer); + KillTimer(nullptr, hTimer); hTimer = NULL; } @@ -338,18 +338,18 @@ int PreShutdown(WPARAM, LPARAM) static INT_PTR TopToolBarClick(WPARAM, LPARAM) { - EnableListeningTo(NULL, !ListeningToEnabled(NULL, true)); + EnableListeningTo(nullptr, !ListeningToEnabled(nullptr, true)); return 0; } // Toptoolbar hook to put an icon in the toolbar int TopToolBarLoaded(WPARAM, LPARAM) { - BOOL enabled = ListeningToEnabled(NULL, true); + BOOL enabled = ListeningToEnabled(nullptr, true); CreateServiceFunction(MS_LISTENINGTO_TTB, TopToolBarClick); - TTBButton ttb = { 0 }; + TTBButton ttb = {}; ttb.hIconHandleDn = iconList[0].hIcolib; ttb.hIconHandleUp = iconList[1].hIcolib; ttb.pszService = MS_LISTENINGTO_TTB; @@ -378,7 +378,7 @@ bool ListeningToEnabled(char *proto, bool ignoreGlobal) if (!ignoreGlobal && !opts.enable_sending) return FALSE; - if (proto == NULL || proto[0] == 0) { + if (proto == nullptr || proto[0] == 0) { // Check all protocols for (unsigned int i = 1; i < proto_items.size(); ++i) if (!ListeningToEnabled(proto_items[i].proto, TRUE)) @@ -406,7 +406,7 @@ ProtocolInfo* GetProtoInfo(char *proto) if (mir_strcmp(proto, proto_items[i].proto) == 0) return &proto_items[i]; - return NULL; + return nullptr; } static void ReplaceVars(Buffer *buffer, MCONTACT hContact, wchar_t **variables, int numVariables) @@ -433,7 +433,7 @@ static void ReplaceVars(Buffer *buffer, MCONTACT hContact, wchar_t **va } else if (foundLen == 6 && wcsncmp(&buffer->str[j], L"%date%", 6) == 0) { wchar_t tmp[128]; - TimeZone_ToStringT(time(NULL), L"d s", tmp, _countof(tmp)); + TimeZone_ToStringT(time(nullptr), L"d s", tmp, _countof(tmp)); buffer->replace(j, i + 1, tmp); } else { @@ -462,8 +462,8 @@ void ReplaceTemplate(Buffer *out, MCONTACT hContact, wchar_t *templ, wc { if (ServiceExists(MS_VARS_FORMATSTRING)) { - wchar_t *tmp = variables_parse_ex(templ, NULL, hContact, vars, numVars); - if (tmp != NULL) { + wchar_t *tmp = variables_parse_ex(templ, nullptr, hContact, vars, numVars); + if (tmp != nullptr) { out->append(tmp); mir_free(tmp); out->pack(); @@ -476,9 +476,9 @@ void ReplaceTemplate(Buffer *out, MCONTACT hContact, wchar_t *templ, wc out->pack(); } -void SetListeningInfo(char *proto, LISTENINGTOINFO *lti = NULL) +void SetListeningInfo(char *proto, LISTENINGTOINFO *lti = nullptr) { - if (proto == NULL || !ListeningToEnabled(proto)) + if (proto == nullptr || !ListeningToEnabled(proto)) return; if (ProtoServiceExists(proto, PS_SET_LISTENINGTO)) @@ -494,13 +494,13 @@ void SetListeningInfo(char *proto, LISTENINGTOINFO *lti = NULL) ics.status = &status; // Set or reset? - if (lti == NULL) { + if (lti == nullptr) { // Reset -> only if is still in music xstatus ics.flags = CSSF_MASK_STATUS; if (CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&ics) || status != XSTATUS_MUSIC) { if (opts.xstatus_set == SET_XSTATUS) { ProtocolInfo *pi = GetProtoInfo(proto); - if (pi != NULL) { + if (pi != nullptr) { pi->old_xstatus = 0; pi->old_xstatus_name[0] = '\0'; pi->old_xstatus_message[0] = '\0'; @@ -535,7 +535,7 @@ void SetListeningInfo(char *proto, LISTENINGTOINFO *lti = NULL) else { // Set to old text ProtocolInfo *pi = GetProtoInfo(proto); - if (pi != NULL) { + if (pi != nullptr) { ics.flags = CSSF_UNICODE | CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE; ics.status = &pi->old_xstatus; ics.ptszName = pi->old_xstatus_name; @@ -548,7 +548,7 @@ void SetListeningInfo(char *proto, LISTENINGTOINFO *lti = NULL) CallProtoService(proto, PS_SETCUSTOMSTATUSEX, 0, (LPARAM)&ics); - if (pi != NULL) { + if (pi != nullptr) { pi->old_xstatus = 0; pi->old_xstatus_name[0] = '\0'; pi->old_xstatus_message[0] = '\0'; @@ -572,7 +572,7 @@ void SetListeningInfo(char *proto, LISTENINGTOINFO *lti = NULL) ics.flags = CSSF_MASK_STATUS; if (!CallProtoService(proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&ics) && status != XSTATUS_MUSIC) { ProtocolInfo *pi = GetProtoInfo(proto); - if (pi != NULL) { + if (pi != nullptr) { ics.flags = CSSF_UNICODE | CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE; ics.status = &pi->old_xstatus; ics.ptszName = pi->old_xstatus_name; @@ -614,7 +614,7 @@ void SetListeningInfo(char *proto, LISTENINGTOINFO *lti = NULL) } else if (db_get_b(0, MODULE_NAME, "UseStatusMessage", 1) && ProtoServiceExists(proto, PS_SETAWAYMSG)) { int status = CallProtoService(proto, PS_GETSTATUS, 0, 0); - if (lti == NULL) + if (lti == nullptr) CallProtoService(proto, PS_SETAWAYMSG, status, 0); else { ptrW fr(GetParsedFormat(lti)); @@ -628,7 +628,7 @@ INT_PTR EnableListeningTo(char *proto, bool enabled) if (!loaded) return -1; - if (proto == NULL || proto[0] == 0) { + if (proto == nullptr || proto[0] == 0) { // For all protocols for (unsigned int i = 1; i < proto_items.size(); ++i) EnableListeningTo(proto_items[i].proto, enabled); @@ -643,11 +643,11 @@ INT_PTR EnableListeningTo(char *proto, bool enabled) // Modify menu info ProtocolInfo *info = GetProtoInfo(proto); - if (info != NULL) { + if (info != nullptr) { Menu_EnableItem(info->hMenu, opts.enable_sending); Menu_SetChecked(info->hMenu, enabled); - SetListeningInfo(proto, (opts.enable_sending && enabled) ? GetListeningInfo() : NULL); + SetListeningInfo(proto, (opts.enable_sending && enabled) ? GetListeningInfo() : nullptr); } // Set all protos info @@ -691,8 +691,8 @@ INT_PTR GetTextFormat(WPARAM, LPARAM) wchar_t *GetParsedFormat(LISTENINGTOINFO *lti) { - if (lti == NULL) - return NULL; + if (lti == nullptr) + return nullptr; wchar_t *fr[] = { L"artist", UNKNOWN(lti->ptszArtist), @@ -732,8 +732,8 @@ void SetListeningInfos(LISTENINGTOINFO *lti) for (unsigned int i = 1; i < proto_items.size(); ++i) SetListeningInfo(proto_items[i].proto, lti); - wchar_t *fr = NULL; - char *info = NULL; + wchar_t *fr = nullptr; + char *info = nullptr; if (lti) { fr = GetParsedFormat(lti); @@ -751,14 +751,14 @@ void SetListeningInfos(LISTENINGTOINFO *lti) static void CALLBACK GetInfoTimer(HWND, UINT, UINT_PTR, DWORD) { if (hTimer != NULL) { - KillTimer(NULL, hTimer); + KillTimer(nullptr, hTimer); hTimer = NULL; } // Check if we can set it now... DWORD now = GetTickCount(); if (now < lastInfoSetTime + MIN_TIME_BEETWEEN_SETS) { - hTimer = SetTimer(NULL, NULL, lastInfoSetTime + MIN_TIME_BEETWEEN_SETS - now, GetInfoTimer); + hTimer = SetTimer(nullptr, NULL, lastInfoSetTime + MIN_TIME_BEETWEEN_SETS - now, GetInfoTimer); return; } lastInfoSetTime = GetTickCount(); // TODO Move this to inside the if that really sets @@ -808,11 +808,11 @@ void StartTimer() if (want) { if (hTimer == NULL) - hTimer = SetTimer(NULL, NULL, opts.time_to_pool * 1000, GetInfoTimer); + hTimer = SetTimer(nullptr, NULL, opts.time_to_pool * 1000, GetInfoTimer); } else { if (hTimer != NULL) { - KillTimer(NULL, hTimer); + KillTimer(nullptr, hTimer); hTimer = NULL; // To be sure that no one was left behind @@ -824,17 +824,17 @@ void StartTimer() void HasNewListeningInfo() { if (hTimer != NULL) { - KillTimer(NULL, hTimer); + KillTimer(nullptr, hTimer); hTimer = NULL; } - hTimer = SetTimer(NULL, NULL, 100, GetInfoTimer); + hTimer = SetTimer(nullptr, NULL, 100, GetInfoTimer); } void SetExtraIcon(MCONTACT hContact, BOOL set) { - ExtraIcon_SetIconByName(hExtraIcon, hContact, set ? "listening_to_icon" : NULL); + ExtraIcon_SetIconByName(hExtraIcon, hContact, set ? "listening_to_icon" : nullptr); } int SettingChanged(WPARAM hContact, LPARAM lParam) @@ -847,10 +847,10 @@ int SettingChanged(WPARAM hContact, LPARAM lParam) return 0; char *proto = GetContactProto(hContact); - if (proto == NULL || strcmp(cws->szModule, proto) != 0) + if (proto == nullptr || strcmp(cws->szModule, proto) != 0) return 0; - if (cws->value.type == DBVT_DELETED || cws->value.ptszVal == NULL || cws->value.ptszVal[0] == 0) + if (cws->value.type == DBVT_DELETED || cws->value.ptszVal == nullptr || cws->value.ptszVal[0] == 0) SetExtraIcon(hContact, FALSE); else SetExtraIcon(hContact, TRUE); diff --git a/plugins/ListeningTo/src/main.cpp b/plugins/ListeningTo/src/main.cpp index 132e2b7385..d3eb164123 100644 --- a/plugins/ListeningTo/src/main.cpp +++ b/plugins/ListeningTo/src/main.cpp @@ -59,7 +59,7 @@ extern "C" int __declspec(dllexport) Load(void) mir_getLP(&pluginInfo); pcli = Clist_GetInterface(); - CoInitialize(NULL); + CoInitialize(nullptr); InitServices(); InitMusic(); diff --git a/plugins/ListeningTo/src/music.cpp b/plugins/ListeningTo/src/music.cpp index 3ded9a24d2..7fdec99f11 100644 --- a/plugins/ListeningTo/src/music.cpp +++ b/plugins/ListeningTo/src/music.cpp @@ -37,7 +37,7 @@ void FreeMusic() { for (int i = 0; i < NUM_PLAYERS; i++) { delete players[i]; - players[i] = NULL; + players[i] = nullptr; } } @@ -146,7 +146,7 @@ int ChangedListeningInfo() LISTENINGTOINFO * GetListeningInfo() { if (current.cbSize == 0) - return NULL; + return nullptr; return ¤t; } diff --git a/plugins/ListeningTo/src/options.cpp b/plugins/ListeningTo/src/options.cpp index 9bc51bd3ab..a4d934f8c8 100644 --- a/plugins/ListeningTo/src/options.cpp +++ b/plugins/ListeningTo/src/options.cpp @@ -55,13 +55,13 @@ static OptPageControl formatControls[] = { }; static OptPageControl playersControls[] = { - { NULL, CONTROL_CHECKBOX, IDC_WATRACK, "GetInfoFromWATrack", FALSE }, + { nullptr, CONTROL_CHECKBOX, IDC_WATRACK, "GetInfoFromWATrack", FALSE }, { &opts.time_to_pool, CONTROL_SPIN, IDC_POLL_TIMER, "TimeToPool", (WORD)5, IDC_POLL_TIMER_SPIN, (WORD)1, (WORD)255 }, - { NULL, CONTROL_CHECKBOX, IDC_WINAMP, "EnableWinamp", TRUE }, - { NULL, CONTROL_CHECKBOX, IDC_ITUNES, "EnableITunes", TRUE }, - { NULL, CONTROL_CHECKBOX, IDC_WMP, "EnableWMP", TRUE }, - { NULL, CONTROL_CHECKBOX, IDC_FOOBAR, "EnableFoobar", TRUE }, - { NULL, CONTROL_CHECKBOX, IDC_MRADIO, "EnableMRadio", TRUE }, + { nullptr, CONTROL_CHECKBOX, IDC_WINAMP, "EnableWinamp", TRUE }, + { nullptr, CONTROL_CHECKBOX, IDC_ITUNES, "EnableITunes", TRUE }, + { nullptr, CONTROL_CHECKBOX, IDC_WMP, "EnableWMP", TRUE }, + { nullptr, CONTROL_CHECKBOX, IDC_FOOBAR, "EnableFoobar", TRUE }, + { nullptr, CONTROL_CHECKBOX, IDC_MRADIO, "EnableMRadio", TRUE }, { &opts.enable_other_players, CONTROL_CHECKBOX, IDC_OTHER, "EnableOtherPlayers", TRUE }, { &opts.enable_code_injection, CONTROL_CHECKBOX, IDC_CODE_INJECTION, "EnableCodeInjection", TRUE } }; @@ -118,7 +118,7 @@ void LoadOptions() BOOL IsTypeEnabled(LISTENINGTOINFO *lti) { - if (lti == NULL) + if (lti == nullptr) return TRUE; if (lti->dwFlags & LTI_UNICODE) { @@ -171,7 +171,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP switch (msg) { case WM_INITDIALOG: - if (hExtraIcon != NULL) { + if (hExtraIcon != nullptr) { ShowWindow(GetDlgItem(hwndDlg, IDC_SHOW_ADV_ICON), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_ADV_ICON), SW_HIDE); } diff --git a/plugins/ListeningTo/src/players/generic.cpp b/plugins/ListeningTo/src/players/generic.cpp index db11f757d7..c4996d763b 100644 --- a/plugins/ListeningTo/src/players/generic.cpp +++ b/plugins/ListeningTo/src/players/generic.cpp @@ -20,15 +20,15 @@ Boston, MA 02111-1307, USA. #include "../stdafx.h" static UINT hTimer = NULL; -static HANDLE hLog = NULL; +static HANDLE hLog = nullptr; -GenericPlayer *singleton = NULL; +GenericPlayer *singleton = nullptr; void m_log(const wchar_t *function, const wchar_t *fmt, ...) { - if (hLog == NULL) { + if (hLog == nullptr) { hLog = mir_createLog(MODULE_NAME, L"ListeningTo log", L"c:\\temp\\listeningto.txt", 0); - if (hLog == NULL) + if (hLog == nullptr) return; } @@ -45,10 +45,10 @@ static LRESULT CALLBACK ReceiverWndProc(HWND hWnd, UINT message, WPARAM wParam, case WM_COPYDATA: if (loaded) { COPYDATASTRUCT *pData = (PCOPYDATASTRUCT)lParam; - if (pData == NULL || pData->dwData != MIRANDA_DW_PROTECTION || pData->cbData == 0 || pData->lpData == NULL) + if (pData == nullptr || pData->dwData != MIRANDA_DW_PROTECTION || pData->cbData == 0 || pData->lpData == nullptr) return FALSE; - if (singleton != NULL) + if (singleton != nullptr) singleton->NewData((WCHAR *)pData->lpData, pData->cbData / 2); return TRUE; @@ -75,21 +75,21 @@ GenericPlayer::GenericPlayer() wc.lpszClassName = MIRANDA_WINDOWCLASS; RegisterClass(&wc); - hWnd = CreateWindow(MIRANDA_WINDOWCLASS, LPGENW("Miranda ListeningTo receiver"), 0, 0, 0, 0, 0, NULL, NULL, hInst, NULL); + hWnd = CreateWindow(MIRANDA_WINDOWCLASS, LPGENW("Miranda ListeningTo receiver"), 0, 0, 0, 0, 0, nullptr, nullptr, hInst, nullptr); } GenericPlayer::~GenericPlayer() { if (hTimer != NULL) { - KillTimer(NULL, hTimer); + KillTimer(nullptr, hTimer); hTimer = NULL; } DestroyWindow(hWnd); - hWnd = NULL; + hWnd = nullptr; UnregisterClass(MIRANDA_WINDOWCLASS, hInst); - singleton = NULL; + singleton = nullptr; } void GenericPlayer::ProcessReceived() @@ -100,11 +100,11 @@ void GenericPlayer::ProcessReceived() // L"\\0\\0\\0\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0\\0" WCHAR *p1 = wcsstr(received, L"\\0"); - if (IsEmpty(received) || p1 == NULL) + if (IsEmpty(received) || p1 == nullptr) return; // Process string - WCHAR *parts[11] = { 0 }; + WCHAR *parts[11] = {}; int pCount = 0; WCHAR *p = received; do { @@ -113,8 +113,8 @@ void GenericPlayer::ProcessReceived() pCount++; p = p1 + 2; p1 = wcsstr(p, L"\\0"); - } while (p1 != NULL && pCount < 10); - if (p1 != NULL) + } while (p1 != nullptr && pCount < 10); + if (p1 != nullptr) *p1 = '\0'; parts[pCount] = p; @@ -157,7 +157,7 @@ void GenericPlayer::ProcessReceived() else li->ptszPlayer = mir_wstrdup(player->name); - if (parts[9] != NULL) { + if (parts[9] != nullptr) { long length = _wtoi(parts[9]); if (length > 0) { li->ptszLength = (wchar_t*)mir_alloc(10 * sizeof(wchar_t)); @@ -177,7 +177,7 @@ void GenericPlayer::ProcessReceived() // Put back the '\\'s for (int i = 1; i <= pCount; i++) *(parts[i] - 2) = L'\\'; - if (p1 != NULL) + if (p1 != nullptr) *p1 = L'\\'; wcscpy(last_received, received); @@ -189,13 +189,13 @@ void GenericPlayer::ProcessReceived() static VOID CALLBACK SendTimerProc(HWND, UINT, UINT_PTR, DWORD) { - KillTimer(NULL, hTimer); + KillTimer(nullptr, hTimer); hTimer = NULL; if (!loaded) return; - if (singleton != NULL) + if (singleton != nullptr) singleton->ProcessReceived(); } @@ -213,7 +213,7 @@ void GenericPlayer::NewData(const WCHAR *data, size_t len) received[len] = L'\0'; if (hTimer) - KillTimer(NULL, hTimer); - hTimer = SetTimer(NULL, NULL, 300, SendTimerProc); // Do the processing after we return true + KillTimer(nullptr, hTimer); + hTimer = SetTimer(nullptr, NULL, 300, SendTimerProc); // Do the processing after we return true } } diff --git a/plugins/ListeningTo/src/players/itunes.cpp b/plugins/ListeningTo/src/players/itunes.cpp index 167779db76..49def11904 100644 --- a/plugins/ListeningTo/src/players/itunes.cpp +++ b/plugins/ListeningTo/src/players/itunes.cpp @@ -31,11 +31,11 @@ ITunes::ITunes() filename[0] = L'\0'; - hwnd = NULL; - iTunesApp = NULL; - track = NULL; - file = NULL; - ret = NULL; + hwnd = nullptr; + iTunesApp = nullptr; + track = nullptr; + file = nullptr; + ret = nullptr; } void ITunes::FindWindow() @@ -51,9 +51,9 @@ void ITunes::FreeTempData() RELEASE(track); RELEASE(iTunesApp); - if (ret != NULL) { + if (ret != nullptr) { SysFreeString(ret); - ret = NULL; + ret = nullptr; } } @@ -66,10 +66,10 @@ BOOL ITunes::InitAndGetFilename() // Find window FindWindow(); - if (hwnd == NULL) + if (hwnd == nullptr) return FALSE; - CALL(CoCreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER, __uuidof(iTunesApp), (void **)&iTunesApp)); + CALL(CoCreateInstance(CLSID_iTunesApp, nullptr, CLSCTX_LOCAL_SERVER, __uuidof(iTunesApp), (void **)&iTunesApp)); ITPlayerState state; CALL(iTunesApp->get_PlayerState(&state)); @@ -77,7 +77,7 @@ BOOL ITunes::InitAndGetFilename() return FALSE; CALL(iTunesApp->get_CurrentTrack(&track)); - if (track == NULL) + if (track == nullptr) return FALSE; CALL(track->QueryInterface(__uuidof(file), (void **)&file)); @@ -132,10 +132,10 @@ BOOL ITunes::FillCache() listening_info.ptszType = mir_wstrdup(L"Music"); - if (listening_info.ptszTitle == NULL) { + if (listening_info.ptszTitle == nullptr) { // Get from filename WCHAR *p = wcsrchr(filename, '\\'); - if (p != NULL) + if (p != nullptr) p++; else p = filename; @@ -143,7 +143,7 @@ BOOL ITunes::FillCache() listening_info.ptszTitle = mir_wstrdup(p); wchar_t *pt = wcsrchr(listening_info.ptszTitle, '.'); - if (pt != NULL) + if (pt != nullptr) *p = '\0'; } diff --git a/plugins/ListeningTo/src/players/player.cpp b/plugins/ListeningTo/src/players/player.cpp index a2bfcd1751..666f640cf8 100644 --- a/plugins/ListeningTo/src/players/player.cpp +++ b/plugins/ListeningTo/src/players/player.cpp @@ -44,7 +44,7 @@ BOOL Player::GetListeningInfo(LISTENINGTOINFO *lti) if (listening_info.cbSize == 0) return false; - if (lti != NULL) + if (lti != nullptr) CopyListeningInfo(lti, &listening_info); return true; } @@ -62,7 +62,7 @@ ExternalPlayer::ExternalPlayer() name = L"ExternalPlayer"; needPoll = TRUE; - window_classes = NULL; + window_classes = nullptr; num_window_classes = 0; found_window = FALSE; } @@ -73,10 +73,10 @@ ExternalPlayer::~ExternalPlayer() HWND ExternalPlayer::FindWindow() { - HWND hwnd = NULL; + HWND hwnd = nullptr; for (int i = 0; i < num_window_classes; i++) { - hwnd = ::FindWindow(window_classes[i], NULL); - if (hwnd != NULL) + hwnd = ::FindWindow(window_classes[i], nullptr); + if (hwnd != nullptr) break; } return hwnd; @@ -84,7 +84,7 @@ HWND ExternalPlayer::FindWindow() BOOL ExternalPlayer::GetListeningInfo(LISTENINGTOINFO *lti) { - if (FindWindow() == NULL) + if (FindWindow() == nullptr) return FALSE; return Player::GetListeningInfo(lti); @@ -95,8 +95,8 @@ BOOL ExternalPlayer::GetListeningInfo(LISTENINGTOINFO *lti) CodeInjectionPlayer::CodeInjectionPlayer() { name = L"CodeInjectionPlayer"; - dll_name = NULL; - message_window_class = NULL; + dll_name = nullptr; + message_window_class = nullptr; next_request_time = 0; } @@ -113,12 +113,12 @@ void CodeInjectionPlayer::InjectCode() // Window is opened? HWND hwnd = FindWindow(); - if (hwnd == NULL) + if (hwnd == nullptr) return; // Msg Window is registered? (aka plugin is running?) - HWND msgHwnd = ::FindWindow(message_window_class, NULL); - if (msgHwnd != NULL) + HWND msgHwnd = ::FindWindow(message_window_class, nullptr); + if (msgHwnd != nullptr) return; @@ -131,7 +131,7 @@ void CodeInjectionPlayer::InjectCode() return; char *p = strrchr(dll_path, '\\'); - if (p == NULL) + if (p == nullptr) return; p++; @@ -153,21 +153,21 @@ void CodeInjectionPlayer::InjectCode() GetWindowThreadProcessId(hwnd, &pid); HANDLE hProcess = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, FALSE, pid); - if (hProcess == NULL) + if (hProcess == nullptr) return; - char *_dll = (char *)VirtualAllocEx(hProcess, NULL, len + 1, MEM_COMMIT, PAGE_READWRITE); - if (_dll == NULL) { + char *_dll = (char *)VirtualAllocEx(hProcess, nullptr, len + 1, MEM_COMMIT, PAGE_READWRITE); + if (_dll == nullptr) { CloseHandle(hProcess); return; } - WriteProcessMemory(hProcess, _dll, dll_path, len + 1, NULL); + WriteProcessMemory(hProcess, _dll, dll_path, len + 1, nullptr); HMODULE hKernel32 = GetModuleHandleA("kernel32"); HANDLE hLoadLibraryA = GetProcAddress(hKernel32, "LoadLibraryA"); DWORD threadId; - HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)hLoadLibraryA, _dll, 0, &threadId); - if (hThread == NULL) { + HANDLE hThread = CreateRemoteThread(hProcess, nullptr, 0, (LPTHREAD_START_ROUTINE)hLoadLibraryA, _dll, 0, &threadId); + if (hThread == nullptr) { VirtualFreeEx(hProcess, _dll, len + 1, MEM_RELEASE); CloseHandle(hProcess); return; diff --git a/plugins/ListeningTo/src/players/watrack.cpp b/plugins/ListeningTo/src/players/watrack.cpp index 895c555b91..bbbd1ee81f 100644 --- a/plugins/ListeningTo/src/players/watrack.cpp +++ b/plugins/ListeningTo/src/players/watrack.cpp @@ -19,13 +19,13 @@ Boston, MA 02111-1307, USA. #include "../stdafx.h" -static WATrack *instance = NULL; +static WATrack *instance = nullptr; int NewStatusCallback(WPARAM wParam, LPARAM lParam) { if (!loaded) return 0; - if (instance != NULL) + if (instance != nullptr) instance->NewStatus(wParam, lParam); return 0; } @@ -34,16 +34,16 @@ WATrack::WATrack() { name = L"WATrack"; instance = this; - hNewStatusHook = NULL; + hNewStatusHook = nullptr; } WATrack::~WATrack() { - if (hNewStatusHook != NULL) { + if (hNewStatusHook != nullptr) { UnhookEvent(hNewStatusHook); - hNewStatusHook = NULL; + hNewStatusHook = nullptr; } - instance = NULL; + instance = nullptr; } void WATrack::EnableDisable() @@ -53,7 +53,7 @@ void WATrack::EnableDisable() return; } - if (hNewStatusHook == NULL) + if (hNewStatusHook == nullptr) hNewStatusHook = HookEvent(ME_WAT_NEWSTATUS, NewStatusCallback); } @@ -72,13 +72,13 @@ void WATrack::NewStatus(int event, int value) void WATrack::GetData() { - SONGINFO *si = NULL; + SONGINFO *si = nullptr; int playing = CallService(MS_WAT_GETMUSICINFO, WAT_INF_UNICODE, (LPARAM)&si); FreeData(); // See if something is playing - if (playing == WAT_RES_NOTFOUND || si == NULL || si->status != 1 || (IsEmpty(si->artist) && IsEmpty(si->title))) + if (playing == WAT_RES_NOTFOUND || si == nullptr || si->status != 1 || (IsEmpty(si->artist) && IsEmpty(si->title))) return; // Copy new data diff --git a/plugins/ListeningTo/src/players/wmp.cpp b/plugins/ListeningTo/src/players/wmp.cpp index a78f6f3a57..c69f288765 100644 --- a/plugins/ListeningTo/src/players/wmp.cpp +++ b/plugins/ListeningTo/src/players/wmp.cpp @@ -25,7 +25,7 @@ static LRESULT CALLBACK ReceiverWndProc(HWND hWnd, UINT message, WPARAM wParam, static UINT hTimer = NULL; -WindowsMediaPlayer *singleton = NULL; +WindowsMediaPlayer *singleton = nullptr; WindowsMediaPlayer::WindowsMediaPlayer() { @@ -39,21 +39,21 @@ WindowsMediaPlayer::WindowsMediaPlayer() wc.lpszClassName = WMP_WINDOWCLASS; RegisterClass(&wc); - hWnd = CreateWindow(WMP_WINDOWCLASS, LPGENW("Miranda ListeningTo WMP receiver"), 0, 0, 0, 0, 0, NULL, NULL, hInst, NULL); + hWnd = CreateWindow(WMP_WINDOWCLASS, LPGENW("Miranda ListeningTo WMP receiver"), 0, 0, 0, 0, 0, nullptr, nullptr, hInst, nullptr); } WindowsMediaPlayer::~WindowsMediaPlayer() { if (hTimer != NULL) { - KillTimer(NULL, hTimer); + KillTimer(nullptr, hTimer); hTimer = NULL; } DestroyWindow(hWnd); - hWnd = NULL; + hWnd = nullptr; UnregisterClass(WMP_WINDOWCLASS, hInst); - singleton = NULL; + singleton = nullptr; } void WindowsMediaPlayer::ProcessReceived() @@ -68,13 +68,13 @@ void WindowsMediaPlayer::ProcessReceived() WCHAR *p1 = wcsstr(received, L"\\0"); - if (received[0] == L'\0' || p1 == NULL) { + if (received[0] == L'\0' || p1 == nullptr) { NotifyInfoChanged(); return; } // Process string - WCHAR *parts[8] = { 0 }; + WCHAR *parts[8] = {}; int pCount = 0; WCHAR *p = received; do { @@ -83,8 +83,8 @@ void WindowsMediaPlayer::ProcessReceived() pCount++; p = p1 + 2; p1 = wcsstr(p, L"\\0"); - } while (p1 != NULL && pCount < 7); - if (p1 != NULL) + } while (p1 != nullptr && pCount < 7); + if (p1 != nullptr) *p1 = L'\0'; parts[pCount] = p; @@ -104,7 +104,7 @@ void WindowsMediaPlayer::ProcessReceived() // Put back the '\\'s for (int i = 1; i <= pCount; i++) *(parts[i] - 2) = L'\\'; - if (p1 != NULL) + if (p1 != nullptr) *p1 = L'\\'; } @@ -113,13 +113,13 @@ void WindowsMediaPlayer::ProcessReceived() static VOID CALLBACK SendTimerProc(HWND, UINT, UINT_PTR, DWORD) { - KillTimer(NULL, hTimer); + KillTimer(nullptr, hTimer); hTimer = NULL; if (!loaded) return; - if (singleton != NULL) + if (singleton != nullptr) singleton->ProcessReceived(); } @@ -133,8 +133,8 @@ void WindowsMediaPlayer::NewData(const WCHAR *data, size_t len) received[len] = '\0'; if (hTimer) - KillTimer(NULL, hTimer); - hTimer = SetTimer(NULL, NULL, 300, SendTimerProc); // Do the processing after we return true + KillTimer(nullptr, hTimer); + hTimer = SetTimer(nullptr, NULL, 300, SendTimerProc); // Do the processing after we return true } } @@ -144,14 +144,14 @@ static LRESULT CALLBACK ReceiverWndProc(HWND hWnd, UINT message, WPARAM wParam, if (!loaded) return FALSE; - if (singleton == NULL || !singleton->enabled) + if (singleton == nullptr || !singleton->enabled) return FALSE; COPYDATASTRUCT* pData = (PCOPYDATASTRUCT)lParam; - if (pData->dwData != 0x547 || pData->cbData == 0 || pData->lpData == NULL) + if (pData->dwData != 0x547 || pData->cbData == 0 || pData->lpData == nullptr) return FALSE; - if (singleton != NULL) + if (singleton != nullptr) singleton->NewData((WCHAR *)pData->lpData, pData->cbData / 2); return TRUE; diff --git a/plugins/ListeningTo/src/variables.cpp b/plugins/ListeningTo/src/variables.cpp index 011404689f..73cb62f6d4 100644 --- a/plugins/ListeningTo/src/variables.cpp +++ b/plugins/ListeningTo/src/variables.cpp @@ -22,10 +22,10 @@ Boston, MA 02111-1307, USA. wchar_t* VariablesParseInfo(ARGUMENTSINFO *ai) { if (ai->cbSize < sizeof(ARGUMENTSINFO)) - return NULL; + return nullptr; LISTENINGTOINFO *lti = GetListeningInfo(); - if (lti == NULL) { + if (lti == nullptr) { ai->flags = AIF_FALSE; return mir_wstrdup(L""); } -- cgit v1.2.3