summaryrefslogtreecommitdiff
path: root/plugins/AutoShutdown
diff options
context:
space:
mode:
authorGoraf <22941576+Goraf@users.noreply.github.com>2017-11-13 15:03:31 +0100
committerGoraf <22941576+Goraf@users.noreply.github.com>2017-11-13 15:07:33 +0100
commita7c24ca48995cf2bf436156302f96b91bf135409 (patch)
tree953835509ff1b778833e78fd7b74b05e05e77c84 /plugins/AutoShutdown
parent591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff)
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/AutoShutdown')
-rw-r--r--plugins/AutoShutdown/src/cpuusage.cpp22
-rw-r--r--plugins/AutoShutdown/src/frame.cpp106
-rw-r--r--plugins/AutoShutdown/src/options.cpp4
-rw-r--r--plugins/AutoShutdown/src/settingsdlg.cpp38
-rw-r--r--plugins/AutoShutdown/src/shutdownsvc.cpp48
-rw-r--r--plugins/AutoShutdown/src/utils.cpp34
-rw-r--r--plugins/AutoShutdown/src/watcher.cpp36
7 files changed, 144 insertions, 144 deletions
diff --git a/plugins/AutoShutdown/src/cpuusage.cpp b/plugins/AutoShutdown/src/cpuusage.cpp
index 555f1c8dbb..2959013407 100644
--- a/plugins/AutoShutdown/src/cpuusage.cpp
+++ b/plugins/AutoShutdown/src/cpuusage.cpp
@@ -35,7 +35,7 @@ static BOOL WinNT_PerfStatsSwitch(wchar_t *pszServiceName, BOOL fDisable)
if (!RegOpenKeyEx(hKeyServices, pszServiceName, 0, KEY_QUERY_VALUE | KEY_SET_VALUE, &hKeyService)) {
if (!RegOpenKeyEx(hKeyService, L"Performance", 0, KEY_QUERY_VALUE | KEY_SET_VALUE, &hKeyPerf)) {
dwDataSize = sizeof(DWORD);
- if (!RegQueryValueEx(hKeyPerf, L"Disable Performance Counters", NULL, NULL, (BYTE*)&dwData, &dwDataSize))
+ if (!RegQueryValueEx(hKeyPerf, L"Disable Performance Counters", nullptr, nullptr, (BYTE*)&dwData, &dwDataSize))
if ((dwData != 0) != fDisable)
fSwitched = !RegSetValueEx(hKeyPerf, L"Disable Performance Counters", 0, REG_DWORD, (BYTE*)&fDisable, dwDataSize);
RegCloseKey(hKeyPerf);
@@ -59,11 +59,11 @@ struct CpuUsageThreadParams
static BOOL CallBackAndWait(struct CpuUsageThreadParams *param, BYTE nCpuUsage)
{
- if (param->hFirstEvent != NULL) {
+ if (param->hFirstEvent != nullptr) {
/* return value for PollCpuUsage() */
*param->pidThread = GetCurrentThreadId();
SetEvent(param->hFirstEvent);
- param->hFirstEvent = NULL;
+ param->hFirstEvent = nullptr;
/* lower priority after first call */
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE);
}
@@ -77,8 +77,8 @@ static void WinNT_PollThread(void *vparam)
CpuUsageThreadParams *param = (CpuUsageThreadParams*)vparam;
DWORD dwBufferSize = 0, dwCount;
- BYTE *pBuffer = NULL;
- PERF_DATA_BLOCK *pPerfData = NULL;
+ BYTE *pBuffer = nullptr;
+ PERF_DATA_BLOCK *pPerfData = nullptr;
LONG res, lCount;
PERF_OBJECT_TYPE *pPerfObj;
PERF_COUNTER_DEFINITION *pPerfCounter;
@@ -100,12 +100,12 @@ static void WinNT_PollThread(void *vparam)
/* poll */
for (;;) {
/* retrieve data for given object */
- res = RegQueryValueExW(HKEY_PERFORMANCE_DATA, wszValueName, NULL, NULL, (BYTE*)pPerfData, &dwBufferSize);
+ res = RegQueryValueExW(HKEY_PERFORMANCE_DATA, wszValueName, nullptr, nullptr, (BYTE*)pPerfData, &dwBufferSize);
while (!pBuffer || res == ERROR_MORE_DATA) {
pBuffer = (BYTE*)mir_realloc(pPerfData, dwBufferSize += 256);
if (!pBuffer) break;
pPerfData = (PERF_DATA_BLOCK*)pBuffer;
- res = RegQueryValueExW(HKEY_PERFORMANCE_DATA, wszValueName, NULL, NULL, pBuffer, &dwBufferSize);
+ res = RegQueryValueExW(HKEY_PERFORMANCE_DATA, wszValueName, nullptr, nullptr, pBuffer, &dwBufferSize);
}
if (res != ERROR_SUCCESS) break;
@@ -174,7 +174,7 @@ static void WinNT_PollThread(void *vparam)
WinNT_PerfStatsSwitch(L"PerfOS", TRUE);
/* return error for PollCpuUsage() if never succeeded */
- if (param->hFirstEvent != NULL)
+ if (param->hFirstEvent != nullptr)
SetEvent(param->hFirstEvent);
mir_free(param);
}
@@ -188,11 +188,11 @@ DWORD PollCpuUsage(CPUUSAGEAVAILPROC pfnDataAvailProc, LPARAM lParam, DWORD dwDe
/* init params */
CpuUsageThreadParams *param = (struct CpuUsageThreadParams*)mir_alloc(sizeof(struct CpuUsageThreadParams));
- if (param == NULL)
+ if (param == nullptr)
return FALSE;
- HANDLE hFirstEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (hFirstEvent == NULL) {
+ HANDLE hFirstEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
+ if (hFirstEvent == nullptr) {
mir_free(param);
return FALSE;
}
diff --git a/plugins/AutoShutdown/src/frame.cpp b/plugins/AutoShutdown/src/frame.cpp
index a450355f22..5908be544f 100644
--- a/plugins/AutoShutdown/src/frame.cpp
+++ b/plugins/AutoShutdown/src/frame.cpp
@@ -56,7 +56,7 @@ static LOGFONT* GetDefaultFont(LOGFONT *lf)
*lf = ncm.lfStatusFont;
return lf;
}
- return (LOGFONT*)NULL;
+ return nullptr;
}
static LRESULT CALLBACK ProgressBarSubclassProc(HWND hwndProgress, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -116,7 +116,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
case WM_NCCREATE: /* init window data */
dat = (struct CountdownFrameWndData*)mir_calloc(sizeof(*dat));
SetWindowLongPtr(hwndFrame, GWLP_USERDATA, (LONG_PTR)dat);
- if (dat == NULL) return FALSE; /* creation failed */
+ if (dat == nullptr) return FALSE; /* creation failed */
dat->fTimeFlags = *(WORD*)((CREATESTRUCT*)lParam)->lpCreateParams;
dat->flags = FWPDF_COUNTDOWNINVALID;
break;
@@ -124,26 +124,26 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
case WM_CREATE: /* create childs */
{
CREATESTRUCT *params = (CREATESTRUCT*)lParam;
- dat->hwndIcon = CreateWindowEx(WS_EX_NOPARENTNOTIFY, L"Static", NULL, WS_CHILD | WS_VISIBLE | SS_ICON | SS_CENTERIMAGE | SS_NOTIFY,
- 3, 0, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), hwndFrame, NULL, params->hInstance, NULL);
+ dat->hwndIcon = CreateWindowEx(WS_EX_NOPARENTNOTIFY, L"Static", nullptr, WS_CHILD | WS_VISIBLE | SS_ICON | SS_CENTERIMAGE | SS_NOTIFY,
+ 3, 0, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), hwndFrame, nullptr, params->hInstance, nullptr);
dat->hwndProgress = CreateWindowEx(WS_EX_NOPARENTNOTIFY, PROGRESS_CLASS, (dat->fTimeFlags&SDWTF_ST_TIME) ? TranslateT("Shutdown at:") : TranslateT("Time left:"),
- WS_CHILD | WS_VISIBLE | PBS_SMOOTH, GetSystemMetrics(SM_CXICON) + 5, 5, 90, (GetSystemMetrics(SM_CXICON) / 2) - 5, hwndFrame, NULL, params->hInstance, NULL);
- if (dat->hwndProgress == NULL) return -1; /* creation failed, calls WM_DESTROY */
+ WS_CHILD | WS_VISIBLE | PBS_SMOOTH, GetSystemMetrics(SM_CXICON) + 5, 5, 90, (GetSystemMetrics(SM_CXICON) / 2) - 5, hwndFrame, nullptr, params->hInstance, nullptr);
+ if (dat->hwndProgress == nullptr) return -1; /* creation failed, calls WM_DESTROY */
SendMessage(dat->hwndProgress, PBM_SETSTEP, 1, 0);
mir_subclassWindow(dat->hwndProgress, ProgressBarSubclassProc);
dat->hwndDesc = CreateWindowEx(WS_EX_NOPARENTNOTIFY, L"Static", (dat->fTimeFlags&SDWTF_ST_TIME) ? TranslateT("Shutdown at:") : TranslateT("Time left:"),
WS_CHILD | WS_VISIBLE | SS_LEFTNOWORDWRAP | SS_NOTIFY, GetSystemMetrics(SM_CXICON) + 5, (GetSystemMetrics(SM_CXICON) / 2), 75,
- (GetSystemMetrics(SM_CXICON) / 2), hwndFrame, NULL, params->hInstance, NULL);
- dat->hwndTime = CreateWindowEx(WS_EX_NOPARENTNOTIFY, L"Static", NULL, WS_CHILD | WS_VISIBLE | SS_RIGHT | SS_NOTIFY | SS_ENDELLIPSIS,
- (GetSystemMetrics(SM_CXICON) + 80), (GetSystemMetrics(SM_CXICON) / 2), 35, (GetSystemMetrics(SM_CXICON) / 2), hwndFrame, NULL, params->hInstance, NULL);
- if (dat->hwndTime == NULL)
+ (GetSystemMetrics(SM_CXICON) / 2), hwndFrame, nullptr, params->hInstance, nullptr);
+ dat->hwndTime = CreateWindowEx(WS_EX_NOPARENTNOTIFY, L"Static", nullptr, WS_CHILD | WS_VISIBLE | SS_RIGHT | SS_NOTIFY | SS_ENDELLIPSIS,
+ (GetSystemMetrics(SM_CXICON) + 80), (GetSystemMetrics(SM_CXICON) / 2), 35, (GetSystemMetrics(SM_CXICON) / 2), hwndFrame, nullptr, params->hInstance, nullptr);
+ if (dat->hwndTime == nullptr)
return -1; /* creation failed, calls WM_DESTROY */
// create tooltips
TTTOOLINFO ti;
- dat->hwndToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_ALWAYSTIP | TTS_NOPREFIX,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndFrame, NULL, params->hInstance, NULL);
- if (dat->hwndToolTip != NULL) {
+ dat->hwndToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_ALWAYSTIP | TTS_NOPREFIX,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndFrame, nullptr, params->hInstance, nullptr);
+ if (dat->hwndToolTip != nullptr) {
SetWindowPos(dat->hwndToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
memset(&ti, 0, sizeof(ti));
ti.cbSize = sizeof(ti);
@@ -155,11 +155,11 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
ti.uFlags &= ~TTF_TRANSPARENT;
ti.uId = (UINT_PTR)dat->hwndProgress;
SendMessage(dat->hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
- if (dat->hwndDesc != NULL) {
+ if (dat->hwndDesc != nullptr) {
ti.uId = (UINT_PTR)dat->hwndDesc;
SendMessage(dat->hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
}
- if (dat->hwndIcon != NULL) {
+ if (dat->hwndIcon != nullptr) {
ti.uId = (UINT_PTR)dat->hwndIcon;
SendMessage(dat->hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
}
@@ -173,26 +173,26 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
SendMessage(hwndFrame, M_REFRESH_ICONS, 0, 0);
SendMessage(hwndFrame, M_SET_COUNTDOWN, 0, 0);
SendMessage(hwndFrame, M_UPDATE_COUNTDOWN, 0, 0);
- if (!SetTimer(hwndFrame, 1, 1000, NULL))
+ if (!SetTimer(hwndFrame, 1, 1000, nullptr))
return -1; /* creation failed, calls WM_DESTROY */
}
return 0;
case WM_DESTROY:
- if (dat == NULL) return 0;
+ if (dat == nullptr) return 0;
UnhookEvent(dat->hHookColorsChanged);
UnhookEvent(dat->hHookFontsChanged);
UnhookEvent(dat->hHookIconsChanged);
/* other childs are destroyed automatically */
- if (dat->hwndToolTip != NULL)
+ if (dat->hwndToolTip != nullptr)
DestroyWindow(dat->hwndToolTip);
break;
case WM_NCDESTROY:
- if (dat == NULL) return 0;
- if (dat->hFont != NULL) DeleteObject(dat->hFont);
- if (dat->hbrBackground != NULL) DeleteObject(dat->hbrBackground);
+ if (dat == nullptr) return 0;
+ if (dat->hFont != nullptr) DeleteObject(dat->hFont);
+ if (dat->hbrBackground != nullptr) DeleteObject(dat->hbrBackground);
mir_free(dat);
SetWindowLongPtr(hwndFrame, GWLP_USERDATA, 0);
break;
@@ -208,14 +208,14 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
/* progress */
LONG width = rc.right - GetSystemMetrics(SM_CXICON) - 10;
LONG height = rc.bottom - (GetSystemMetrics(SM_CYICON) / 2) - 5;
- if (NULL != dat->hwndProgress) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, dat->hwndProgress, NULL, 0, 0, width, height, SWP_NOMOVE | defflg);
+ if (nullptr != dat->hwndProgress) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, dat->hwndProgress, nullptr, 0, 0, width, height, SWP_NOMOVE | defflg);
/* desc */
- if (dat->hwndDesc != NULL) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, dat->hwndDesc, NULL, GetSystemMetrics(SM_CXICON) + 5, 5 + height, 0, 0, SWP_NOSIZE | defflg);
+ if (dat->hwndDesc != nullptr) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, dat->hwndDesc, nullptr, GetSystemMetrics(SM_CXICON) + 5, 5 + height, 0, 0, SWP_NOSIZE | defflg);
/* time */
- if (NULL != dat->hwndTime) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, dat->hwndTime, NULL, GetSystemMetrics(SM_CXICON) + 85, 5 + height, width - 80, (GetSystemMetrics(SM_CXICON) / 2), defflg);
+ if (nullptr != dat->hwndTime) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, dat->hwndTime, nullptr, GetSystemMetrics(SM_CXICON) + 85, 5 + height, width - 80, (GetSystemMetrics(SM_CXICON) / 2), defflg);
EndDeferWindowPos(hdwp);
}
PostMessage(hwndFrame, M_CHECK_CLIPPED, 0, 0);
@@ -231,13 +231,13 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
if (dat->clrBackground == -1)
dat->clrBackground = GetDefaultColor(FRAMEELEMENT_BKGRND);
- if (dat->hbrBackground != NULL)
+ if (dat->hbrBackground != nullptr)
DeleteObject(dat->hbrBackground);
dat->hbrBackground = CreateSolidBrush(dat->clrBackground);
SendMessage(dat->hwndProgress, PBM_SETBARCOLOR, 0, (LPARAM)clrBar);
SendMessage(dat->hwndProgress, PBM_SETBKCOLOR, 0, (LPARAM)dat->clrBackground);
- InvalidateRect(hwndFrame, NULL, TRUE);
+ InvalidateRect(hwndFrame, nullptr, TRUE);
return 0;
case M_REFRESH_ICONS:
@@ -247,13 +247,13 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
{
LOGFONT lf;
dat->clrText = Font_GetW(L"Automatic shutdown", L"Countdown on frame", &lf);
- if (dat->hFont != NULL) DeleteObject(dat->hFont);
+ if (dat->hFont != nullptr) DeleteObject(dat->hFont);
dat->hFont = CreateFontIndirect(&lf);
}
- if (dat->hwndDesc != NULL)
+ if (dat->hwndDesc != nullptr)
SendMessage(dat->hwndDesc, WM_SETFONT, (WPARAM)dat->hFont, FALSE);
SendMessage(dat->hwndTime, WM_SETFONT, (WPARAM)dat->hFont, FALSE);
- InvalidateRect(hwndFrame, NULL, FALSE);
+ InvalidateRect(hwndFrame, nullptr, FALSE);
return 0;
case WM_SYSCOLORCHANGE:
@@ -264,7 +264,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
SendMessage(hwndFrame, M_REFRESH_COLORS, 0, 0);
SendMessage(hwndFrame, M_REFRESH_FONTS, 0, 0);
SendMessage(hwndFrame, M_UPDATE_COUNTDOWN, 0, 0);
- RedrawWindow(hwndFrame, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE);
+ RedrawWindow(hwndFrame, nullptr, nullptr, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE);
break;
case WM_TIMECHANGE: /* windows system clock changed */
@@ -281,7 +281,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
case WM_ERASEBKGND:
{
RECT rc;
- if (dat->hbrBackground != NULL && GetClientRect(hwndFrame, &rc)) {
+ if (dat->hbrBackground != nullptr && GetClientRect(hwndFrame, &rc)) {
FillRect((HDC)wParam, &rc, dat->hbrBackground);
return TRUE;
}
@@ -290,7 +290,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
case M_SET_COUNTDOWN:
if (dat->fTimeFlags&SDWTF_ST_TIME) {
dat->settingLastTime = (time_t)db_get_dw(NULL, "AutoShutdown", "TimeStamp", SETTING_TIMESTAMP_DEFAULT);
- dat->countdown = time(NULL);
+ dat->countdown = time(nullptr);
if (dat->settingLastTime > dat->countdown) dat->countdown = dat->settingLastTime - dat->countdown;
else dat->countdown = 0;
}
@@ -303,7 +303,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
SendMessage(dat->hwndProgress, PBM_SETRANGE32, 0, (LPARAM)dat->countdown);
return 0;
case WM_TIMER:
- if (dat == NULL) return 0;
+ if (dat == nullptr) return 0;
if (dat->countdown != 0 && !(dat->flags&FWPDF_COUNTDOWNINVALID) && !(dat->flags&FWPDF_PAUSED)) {
dat->countdown--;
PostMessage(dat->hwndProgress, PBM_STEPIT, 0, 0);
@@ -332,7 +332,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
SetWindowText(dat->hwndTime, szOutput);
PostMessage(hwndFrame, M_CHECK_CLIPPED, 0, 0);
/* update tooltip text (if shown) */
- if (dat->hwndToolTip != NULL && !(dat->flags&FWPDF_PAUSED)) {
+ if (dat->hwndToolTip != nullptr && !(dat->flags&FWPDF_PAUSED)) {
TTTOOLINFO ti;
ti.cbSize = sizeof(ti);
if (SendMessage(dat->hwndToolTip, TTM_GETCURRENTTOOL, 0, (LPARAM)&ti) && (HWND)ti.uId != dat->hwndIcon)
@@ -380,11 +380,11 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
pt.y = rc.top + ((int)(rc.bottom - rc.top) / 2);
}
HMENU hContextMenu = CreatePopupMenu();
- if (hContextMenu != NULL) {
+ if (hContextMenu != nullptr) {
AppendMenu(hContextMenu, MF_STRING, MENUITEM_PAUSECOUNTDOWN, (dat->flags&FWPDF_PAUSED) ? TranslateT("&Unpause countdown") : TranslateT("&Pause countdown"));
SetMenuDefaultItem(hContextMenu, MENUITEM_PAUSECOUNTDOWN, FALSE);
AppendMenu(hContextMenu, MF_STRING, MENUITEM_STOPCOUNTDOWN, TranslateT("&Cancel countdown"));
- TrackPopupMenuEx(hContextMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_HORPOSANIMATION | TPM_VERPOSANIMATION | TPM_RIGHTBUTTON, pt.x, pt.y, hwndFrame, NULL);
+ TrackPopupMenuEx(hContextMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_HORPOSANIMATION | TPM_VERPOSANIMATION | TPM_RIGHTBUTTON, pt.x, pt.y, hwndFrame, nullptr);
DestroyMenu(hContextMenu);
}
}
@@ -411,19 +411,19 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
RECT rc;
HDC hdc;
SIZE size;
- HFONT hFontPrev = NULL;
+ HFONT hFontPrev = nullptr;
wchar_t szOutput[256];
dat->flags &= ~FWPDF_TIMEISCLIPPED;
if (GetWindowText(dat->hwndTime, szOutput, _countof(szOutput)))
if (GetClientRect(dat->hwndTime, &rc)) {
hdc = GetDC(dat->hwndTime);
- if (hdc != NULL) {
- if (dat->hFont != NULL)
+ if (hdc != nullptr) {
+ if (dat->hFont != nullptr)
hFontPrev = (HFONT)SelectObject(hdc, dat->hFont);
if (GetTextExtentPoint32(hdc, szOutput, (int)mir_wstrlen(szOutput), &size))
if (size.cx >= (rc.right - rc.left))
dat->flags &= FWPDF_TIMEISCLIPPED;
- if (dat->hFont != NULL)
+ if (dat->hFont != nullptr)
SelectObject(hdc, hFontPrev);
ReleaseDC(dat->hwndTime, hdc);
}
@@ -440,7 +440,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
SetWindowLongPtr(dat->hwndToolTip, GWL_STYLE, GetWindowLongPtr(dat->hwndToolTip, GWL_STYLE) | TTS_NOANIMATE);
SetWindowLongPtr(dat->hwndToolTip, GWL_EXSTYLE, GetWindowLongPtr(dat->hwndToolTip, GWL_EXSTYLE) | WS_EX_TRANSPARENT);
SendMessage(dat->hwndToolTip, TTM_ADJUSTRECT, TRUE, (LPARAM)&rc);
- SetWindowPos(dat->hwndToolTip, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+ SetWindowPos(dat->hwndToolTip, nullptr, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
return TRUE; /* self-defined position */
}
}
@@ -450,7 +450,7 @@ static LRESULT CALLBACK FrameWndProc(HWND hwndFrame, UINT msg, WPARAM wParam, LP
case TTN_POP:
/* workaround #5: frame does not get redrawn after
* in-place tooltip hidden on dat->hwndTime */
- RedrawWindow(hwndCountdownFrame, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE);
+ RedrawWindow(hwndCountdownFrame, nullptr, nullptr, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE);
return 0;
case TTN_NEEDTEXT:
{
@@ -483,16 +483,16 @@ void ShowCountdownFrame(WORD fTimeFlags)
{
hwndCountdownFrame = CreateWindowEx(WS_EX_CONTROLPARENT | WS_EX_NOPARENTNOTIFY | WS_EX_TRANSPARENT,
COUNTDOWNFRAME_CLASS,
- NULL,
+ nullptr,
WS_CHILD | WS_TABSTOP,
0, 0,
GetSystemMetrics(SM_CXICON) + 103,
GetSystemMetrics(SM_CYICON) + 2,
pcli->hwndContactList,
- NULL,
+ nullptr,
hInst,
&fTimeFlags);
- if (hwndCountdownFrame == NULL) return;
+ if (hwndCountdownFrame == nullptr) return;
if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
CLISTFrame clf = { sizeof(clf) };
@@ -517,7 +517,7 @@ void ShowCountdownFrame(WORD fTimeFlags)
if (!(CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, hFrame), 0)&F_VISIBLE))
CallService(MS_CLIST_FRAMES_SHFRAME, hFrame, 0);
/* workaround #4: MS_CLIST_FRAMES_SHFRAME does cause redrawing problems when frame was hidden */
- RedrawWindow(hwndCountdownFrame, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE);
+ RedrawWindow(hwndCountdownFrame, nullptr, nullptr, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE);
/* workaround #5: for in-place tooltip TTN_POP
* workaround #6 and #7: see CloseCountdownFrame() */
}
@@ -526,7 +526,7 @@ void ShowCountdownFrame(WORD fTimeFlags)
void CloseCountdownFrame(void)
{
- if (hwndCountdownFrame != NULL) {
+ if (hwndCountdownFrame != nullptr) {
SendMessage(hwndCountdownFrame, M_CLOSE_COUNTDOWN, 0, 0);
if (hFrame) {
/* HACKS TO FIX CLUIFrames:
@@ -540,7 +540,7 @@ void CloseCountdownFrame(void)
#endif
}
else DestroyWindow(hwndCountdownFrame);
- hwndCountdownFrame = NULL;
+ hwndCountdownFrame = nullptr;
hFrame = 0;
}
@@ -573,12 +573,12 @@ int InitFrame(void)
wcx.style = CS_DBLCLKS | CS_PARENTDC;
wcx.lpfnWndProc = FrameWndProc;
wcx.hInstance = hInst;
- wcx.hCursor = (HCURSOR)LoadImage(NULL, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED);
+ wcx.hCursor = (HCURSOR)LoadImage(nullptr, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED);
wcx.lpszClassName = COUNTDOWNFRAME_CLASS;
if (!RegisterClassEx(&wcx))
return 1;
- hwndCountdownFrame = NULL;
+ hwndCountdownFrame = nullptr;
hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, FrameModulesLoaded);
return 0;
}
diff --git a/plugins/AutoShutdown/src/options.cpp b/plugins/AutoShutdown/src/options.cpp
index 7a9f2001fd..c9b8a508ce 100644
--- a/plugins/AutoShutdown/src/options.cpp
+++ b/plugins/AutoShutdown/src/options.cpp
@@ -76,7 +76,7 @@ static INT_PTR CALLBACK ShutdownOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
switch (LOWORD(wParam)) {
case IDC_EDIT_CONFIRMDLGCOUNTDOWN:
if (HIWORD(wParam) == EN_KILLFOCUS)
- if ((int)GetDlgItemInt(hwndDlg, IDC_EDIT_CONFIRMDLGCOUNTDOWN, NULL, TRUE) < 3) {
+ if ((int)GetDlgItemInt(hwndDlg, IDC_EDIT_CONFIRMDLGCOUNTDOWN, nullptr, TRUE) < 3) {
SendDlgItemMessage(hwndDlg, IDC_SPIN_CONFIRMDLGCOUNTDOWN, UDM_SETPOS, 0, MAKELPARAM(3, 0));
SetDlgItemInt(hwndDlg, IDC_EDIT_CONFIRMDLGCOUNTDOWN, 3, FALSE);
}
@@ -92,7 +92,7 @@ static INT_PTR CALLBACK ShutdownOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
switch (((NMHDR*)lParam)->code) {
case PSN_APPLY:
db_set_b(NULL, "AutoShutdown", "ShowConfirmDlg", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHOWCONFIRMDLG) != 0));
- db_set_w(NULL, "AutoShutdown", "ConfirmDlgCountdown", (WORD)GetDlgItemInt(hwndDlg, IDC_EDIT_CONFIRMDLGCOUNTDOWN, NULL, FALSE));
+ db_set_w(NULL, "AutoShutdown", "ConfirmDlgCountdown", (WORD)GetDlgItemInt(hwndDlg, IDC_EDIT_CONFIRMDLGCOUNTDOWN, nullptr, FALSE));
db_set_b(NULL, "AutoShutdown", "RememberOnRestart", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CHECK_REMEMBERONRESTART) != 0));
db_set_b(NULL, "AutoShutdown", "SmartOfflineCheck", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CHECK_SMARTOFFLINECHECK) != 0));
if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHECK_WEATHER)))
diff --git a/plugins/AutoShutdown/src/settingsdlg.cpp b/plugins/AutoShutdown/src/settingsdlg.cpp
index 15bcc187c5..662196b3ca 100644
--- a/plugins/AutoShutdown/src/settingsdlg.cpp
+++ b/plugins/AutoShutdown/src/settingsdlg.cpp
@@ -33,7 +33,7 @@ const wchar_t *unitNames[] = { LPGENW("Second(s)"), LPGENW("Minute(s)"), LPGENW(
static void EnableDlgItem(HWND hwndDlg, int idCtrl, BOOL fEnable)
{
hwndDlg = GetDlgItem(hwndDlg, idCtrl);
- if (hwndDlg != NULL && IsWindowEnabled(hwndDlg) != fEnable)
+ if (hwndDlg != nullptr && IsWindowEnabled(hwndDlg) != fEnable)
EnableWindow(hwndDlg, fEnable);
}
@@ -80,7 +80,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
lf.lfWeight = FW_BOLD;
hBoldFont = CreateFontIndirect(&lf);
}
- else hBoldFont = NULL;
+ else hBoldFont = nullptr;
SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_SETFONT, (WPARAM)hBoldFont, FALSE);
}
/* read-in watcher flags */
@@ -183,9 +183,9 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
{
HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_GETFONT, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_SETFONT, 0, FALSE); /* no return value */
- if (hFont != NULL)
+ if (hFont != nullptr)
DeleteObject(hFont);
- hwndSettingsDlg = NULL;
+ hwndSettingsDlg = nullptr;
}
return TRUE;
@@ -258,14 +258,14 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
GetLocalTime(&stBuf);
if (SystemTimeToTimeStamp(&st, &timestamp)) {
/* set to current date if earlier */
- if (timestamp < time(NULL)) {
+ if (timestamp < time(nullptr)) {
st.wDay = stBuf.wDay;
st.wDayOfWeek = stBuf.wDayOfWeek;
st.wMonth = stBuf.wMonth;
st.wYear = stBuf.wYear;
if (SystemTimeToTimeStamp(&st, &timestamp)) {
/* step one day up if still earlier */
- if (timestamp < time(NULL)) {
+ if (timestamp < time(nullptr)) {
timestamp += 24 * 60 * 60;
TimeStampToSystemTime(timestamp, &st);
}
@@ -307,7 +307,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
case IDC_EDIT_COUNTDOWN:
if (HIWORD(wParam) == EN_KILLFOCUS) {
- if ((int)GetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, NULL, TRUE) < 1) {
+ if ((int)GetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, nullptr, TRUE) < 1) {
SendDlgItemMessage(hwndDlg, IDC_SPIN_COUNTDOWN, UDM_SETPOS, 0, MAKELPARAM(1, 0));
SetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, 1, FALSE);
}
@@ -317,7 +317,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
case IDC_EDIT_CPUUSAGE:
if (HIWORD(wParam) == EN_KILLFOCUS) {
- WORD val = (WORD)GetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, NULL, FALSE);
+ WORD val = (WORD)GetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, nullptr, FALSE);
if (val < 1) val = 1;
else if (val>100) val = 100;
SendDlgItemMessage(hwndDlg, IDC_SPIN_CPUUSAGE, UDM_SETPOS, 0, MAKELPARAM(val, 0));
@@ -342,7 +342,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
HWND hwndEdit = GetDlgItem(hwndDlg, IDC_EDIT_MESSAGE);
int len = GetWindowTextLength(hwndEdit) + 1;
wchar_t *pszText = (wchar_t*)mir_alloc(len*sizeof(wchar_t));
- if (pszText != NULL && GetWindowText(hwndEdit, pszText, len + 1)) {
+ if (pszText != nullptr && GetWindowText(hwndEdit, pszText, len + 1)) {
TrimString(pszText);
db_set_ws(NULL, "AutoShutdown", "Message", pszText);
}
@@ -354,7 +354,7 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
time_t timestamp;
DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_TIME_TIMESTAMP), &st); /* time gets synchronized */
if (!SystemTimeToTimeStamp(&st, &timestamp))
- timestamp = time(NULL);
+ timestamp = time(nullptr);
db_set_dw(NULL, "AutoShutdown", "TimeStamp", (DWORD)timestamp);
}
/* shutdown type */
@@ -365,8 +365,8 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
index = SendDlgItemMessage(hwndDlg, IDC_COMBO_COUNTDOWNUNIT, CB_GETCURSEL, 0, 0);
if (index != LB_ERR)
db_set_dw(NULL, "AutoShutdown", "CountdownUnit", (DWORD)SendDlgItemMessage(hwndDlg, IDC_COMBO_COUNTDOWNUNIT, CB_GETITEMDATA, (WPARAM)index, 0));
- db_set_dw(NULL, "AutoShutdown", "Countdown", (DWORD)GetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, NULL, FALSE));
- db_set_b(NULL, "AutoShutdown", "CpuUsageThreshold", (BYTE)GetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, NULL, FALSE));
+ db_set_dw(NULL, "AutoShutdown", "Countdown", (DWORD)GetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, nullptr, FALSE));
+ db_set_b(NULL, "AutoShutdown", "CpuUsageThreshold", (BYTE)GetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, nullptr, FALSE));
}
/* watcher type */
{
@@ -399,11 +399,11 @@ static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
static INT_PTR ServiceShowSettingsDialog(WPARAM, LPARAM)
{
- if (hwndSettingsDlg != NULL) { /* already opened, bring to front */
+ if (hwndSettingsDlg != nullptr) { /* already opened, bring to front */
SetForegroundWindow(hwndSettingsDlg);
return 0;
}
- return CreateDialog(hInst, MAKEINTRESOURCE(IDD_SETTINGS), NULL, SettingsDlgProc) == NULL;
+ return CreateDialog(hInst, MAKEINTRESOURCE(IDD_SETTINGS), nullptr, SettingsDlgProc) == nullptr;
}
/************************* Toolbar ************************************/
@@ -412,7 +412,7 @@ static HANDLE hToolbarButton;
int ToolbarLoaded(WPARAM, LPARAM)
{
- TTBButton ttb = { 0 };
+ TTBButton ttb = {};
ttb.hIconHandleUp = iconList[2].hIcolib;
ttb.hIconHandleDn = iconList[1].hIcolib;
ttb.pszService = "AutoShutdown/MenuCommand";
@@ -450,14 +450,14 @@ void SetShutdownMenuItem(bool fActive)
}
mi.pszService = "AutoShutdown/MenuCommand";
mi.flags = CMIF_UNICODE;
- if (hMainMenuItem != NULL)
+ if (hMainMenuItem != nullptr)
Menu_ModifyItem(hMainMenuItem, mi.name.w, mi.hIcolibItem);
else
hMainMenuItem = Menu_AddMainMenuItem(&mi);
/* tray menu */
mi.position = 899999;
- if (hTrayMenuItem != NULL)
+ if (hTrayMenuItem != nullptr)
Menu_ModifyItem(hTrayMenuItem, mi.name.w, mi.hIcolibItem);
else
hTrayMenuItem = Menu_AddTrayMenuItem(&mi);
@@ -479,11 +479,11 @@ void InitSettingsDlg(void)
{
/* Menu Item */
CreateServiceFunction("AutoShutdown/MenuCommand", MenuItemCommand);
- hMainMenuItem = hTrayMenuItem = NULL;
+ hMainMenuItem = hTrayMenuItem = nullptr;
SetShutdownMenuItem(false);
/* Hotkey */
AddHotkey();
/* Services */
- hwndSettingsDlg = NULL;
+ hwndSettingsDlg = nullptr;
CreateServiceFunction(MS_AUTOSHUTDOWN_SHOWSETTINGSDIALOG, ServiceShowSettingsDialog);
}
diff --git a/plugins/AutoShutdown/src/shutdownsvc.cpp b/plugins/AutoShutdown/src/shutdownsvc.cpp
index 095c55d25b..bce97d110c 100644
--- a/plugins/AutoShutdown/src/shutdownsvc.cpp
+++ b/plugins/AutoShutdown/src/shutdownsvc.cpp
@@ -52,10 +52,10 @@ static BOOL WinNT_SetPrivilege(wchar_t *pszPrivName, BOOL bEnable)
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
tkp.PrivilegeCount = 1; /* one privilege is to set */
/* get the LUID for the shutdown privilege */
- if (LookupPrivilegeValue(NULL, pszPrivName, &tkp.Privileges[0].Luid)) {
+ if (LookupPrivilegeValue(nullptr, pszPrivName, &tkp.Privileges[0].Luid)) {
tkp.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
/* get the shutdown privilege for this process */
- bReturn = AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
+ bReturn = AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, nullptr, nullptr);
}
CloseHandle(hToken);
}
@@ -89,7 +89,7 @@ static BOOL IsShutdownTypeEnabled(BYTE shutdownType)
bReturn = TRUE;
if (RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
dwSize = sizeof(dwSetting);
- if (RegQueryValueEx(hKey, L"NoLogOff", 0, NULL, (LPBYTE)&dwSetting, &dwSize) == ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, L"NoLogOff", nullptr, nullptr, (LPBYTE)&dwSetting, &dwSize) == ERROR_SUCCESS)
if (dwSetting) bReturn = FALSE;
RegCloseKey(hKey);
}
@@ -103,7 +103,7 @@ static BOOL IsShutdownTypeEnabled(BYTE shutdownType)
bReturn = TRUE;
if (RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
dwSize = sizeof(dwSetting);
- if (!RegQueryValueEx(hKey, L"DisableLockWorkstation", 0, NULL, (LPBYTE)&dwSetting, &dwSize))
+ if (!RegQueryValueEx(hKey, L"DisableLockWorkstation", nullptr, nullptr, (LPBYTE)&dwSetting, &dwSize))
if (dwSetting)
bReturn = FALSE;
RegCloseKey(hKey);
@@ -183,16 +183,16 @@ static DWORD ShutdownNow(BYTE shutdownType)
DWORD dwConnItems = 0;
RASCONN *paConn = (RASCONN*)mir_alloc(dwConnSize);
dwErrCode = ERROR_NOT_ENOUGH_MEMORY;
- if (paConn != NULL) {
+ if (paConn != nullptr) {
for (dwRetries = 5; dwRetries != 0; dwRetries--) { /* prevent infinite loop (rare) */
memset(paConn, 0, dwConnSize);
paConn[0].dwSize = sizeof(RASCONN);
dwErrCode = RasEnumConnections(paConn, &dwConnSize, &dwConnItems);
if (dwErrCode != ERROR_BUFFER_TOO_SMALL) break;
RASCONN *paConnBuf = (RASCONN*)mir_realloc(paConn, dwConnSize);
- if (paConnBuf == NULL) {
+ if (paConnBuf == nullptr) {
mir_free(paConn);
- paConn = NULL;
+ paConn = nullptr;
dwErrCode = ERROR_NOT_ENOUGH_MEMORY;
break;
}
@@ -202,11 +202,11 @@ static DWORD ShutdownNow(BYTE shutdownType)
for (dw = 0; dw < dwConnItems; ++dw) {
if (dwErrCode) {
if (RasHangUp(paConn[dw].hrasconn))
- paConn[dw].hrasconn = NULL; /* do not wait for on error */
+ paConn[dw].hrasconn = nullptr; /* do not wait for on error */
}
else {
dwErrCode = RasHangUp(paConn[dw].hrasconn);
- if (!dwErrCode) paConn[dw].hrasconn = NULL; /* do not wait for on error */
+ if (!dwErrCode) paConn[dw].hrasconn = nullptr; /* do not wait for on error */
}
}
/* RAS does not allow to quit directly after HangUp (see docs) */
@@ -214,7 +214,7 @@ static DWORD ShutdownNow(BYTE shutdownType)
memset(&rcs, 0, sizeof(RASCONNSTATUS));
rcs.dwSize = sizeof(RASCONNSTATUS);
for (dw = 0; dw < dwConnItems; ++dw) {
- if (paConn[dw].hrasconn != NULL) {
+ if (paConn[dw].hrasconn != nullptr) {
while (RasGetConnectStatus(paConn[dw].hrasconn, &rcs) != ERROR_INVALID_HANDLE) {
Sleep(0); /* give rest of time silce to other threads with equal priority */
/* infinite loop protection (3000ms defined in docs) */
@@ -248,7 +248,7 @@ static DWORD ShutdownNow(BYTE shutdownType)
BroadcastEndSession(BSM_APPLICATIONS | BSM_ALLDESKTOPS, ENDSESSION_CLOSEAPP); /* app should close itself */
WinNT_SetPrivilege(SE_TCB_NAME, FALSE);
- if (!InitiateSystemShutdownEx(NULL, TranslateT("AutoShutdown"), 0, TRUE, shutdownType == SDSDT_REBOOT, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED))
+ if (!InitiateSystemShutdownEx(nullptr, TranslateT("AutoShutdown"), 0, TRUE, shutdownType == SDSDT_REBOOT, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED))
dwErrCode = GetLastError();
/* cleanly close Miranda */
@@ -317,7 +317,7 @@ static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
lf.lfWeight = FW_BOLD;
hBoldFont = CreateFontIndirect(&lf);
}
- else hBoldFont = NULL;
+ else hBoldFont = nullptr;
SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_SETFONT, (WPARAM)hBoldFont, FALSE);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TEXT_HEADER), GWLP_USERDATA, (LONG_PTR)hBoldFont);
}
@@ -329,7 +329,7 @@ static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
SendMessage(hwndDlg, M_UPDATE_COUNTDOWN, 0, countdown);
}
Skin_PlaySound("AutoShutdown_Countdown");
- if (!SetTimer(hwndDlg, 1, 1000, NULL))
+ if (!SetTimer(hwndDlg, 1, 1000, nullptr))
PostMessage(hwndDlg, M_START_SHUTDOWN, 0, 0);
Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "AutoShutdown", "ConfirmDlg_");
@@ -343,14 +343,14 @@ static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
case WM_DESTROY:
{
- hwndShutdownDlg = NULL;
+ hwndShutdownDlg = nullptr;
ShowWindow(hwndDlg, SW_HIDE);
/* reallow foreground window changes (WinMe/2000+) */
LockSetForegroundWindow(LSFW_UNLOCK);
Utils_SaveWindowPosition(hwndDlg, NULL, "AutoShutdown", "ConfirmDlg_");
HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_GETFONT, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_SETFONT, 0, FALSE); /* no return value */
- if (hFont != NULL) DeleteObject(hFont);
+ if (hFont != nullptr) DeleteObject(hFont);
}
return TRUE;
@@ -361,8 +361,8 @@ static INT_PTR CALLBACK ShutdownDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
DWORD dwErrCode = ShutdownNow(shutdownType);
if (dwErrCode != ERROR_SUCCESS) {
char *pszErr = GetWinErrorDescription(dwErrCode);
- ShowInfoMessage(NIIF_ERROR, Translate("Automatic shutdown error"), Translate("The shutdown process failed!\nReason: %s"), (pszErr != NULL) ? pszErr : Translate("Unknown"));
- if (pszErr != NULL) LocalFree(pszErr);
+ ShowInfoMessage(NIIF_ERROR, Translate("Automatic shutdown error"), Translate("The shutdown process failed!\nReason: %s"), (pszErr != nullptr) ? pszErr : Translate("Unknown"));
+ if (pszErr != nullptr) LocalFree(pszErr);
}
DestroyWindow(hwndDlg);
}
@@ -419,7 +419,7 @@ INT_PTR ServiceShutdown(WPARAM wParam, LPARAM lParam)
/* passing 0 as wParam is only to be used internally, undocumented */
if (!wParam) wParam = db_get_b(NULL, "AutoShutdown", "ShutdownType", SETTING_SHUTDOWNTYPE_DEFAULT);
if (!IsShutdownTypeEnabled((BYTE)wParam)) return 1; /* does shutdownType range check */
- if ((BOOL)lParam && hwndShutdownDlg != NULL) return 2;
+ if ((BOOL)lParam && hwndShutdownDlg != nullptr) return 2;
/* ask others if allowed */
if (NotifyEventHooks(hEventOkToShutdown, wParam, lParam)) {
@@ -430,15 +430,15 @@ INT_PTR ServiceShutdown(WPARAM wParam, LPARAM lParam)
NotifyEventHooks(hEventShutdown, wParam, lParam);
/* show dialog */
if (lParam && db_get_b(NULL, "AutoShutdown", "ShowConfirmDlg", SETTING_SHOWCONFIRMDLG_DEFAULT))
- if (CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SHUTDOWNNOW), NULL, ShutdownDlgProc, (BYTE)wParam) != NULL)
+ if (CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SHUTDOWNNOW), nullptr, ShutdownDlgProc, (BYTE)wParam) != nullptr)
return 0;
/* show error */
DWORD dwErrCode = ShutdownNow((BYTE)wParam);
if (dwErrCode != ERROR_SUCCESS) {
char *pszErr = GetWinErrorDescription(dwErrCode);
- ShowInfoMessage(NIIF_ERROR, Translate("Automatic shutdown error"), Translate("Initiating the shutdown process failed!\nReason: %s"), (pszErr != NULL) ? pszErr : Translate("Unknown"));
- if (pszErr != NULL)
+ ShowInfoMessage(NIIF_ERROR, Translate("Automatic shutdown error"), Translate("Initiating the shutdown process failed!\nReason: %s"), (pszErr != nullptr) ? pszErr : Translate("Unknown"));
+ if (pszErr != nullptr)
LocalFree(pszErr);
return 4;
}
@@ -482,7 +482,7 @@ INT_PTR ServiceGetTypeDescription(WPARAM wParam, LPARAM lParam)
if (!(lParam&GSTDF_UNICODE)) {
static char szConvBuf[128];
char *buf = u2a(pszDesc);
- if (buf == NULL) return 0;
+ if (buf == nullptr) return 0;
mir_strncpy(szConvBuf, buf, sizeof(szConvBuf));
mir_free(buf);
return (INT_PTR)szConvBuf;
@@ -495,7 +495,7 @@ INT_PTR ServiceGetTypeDescription(WPARAM wParam, LPARAM lParam)
void InitShutdownSvc(void)
{
/* Shutdown Dialog */
- hwndShutdownDlg = NULL;
+ hwndShutdownDlg = nullptr;
Skin_AddSound("AutoShutdown_Countdown", LPGENW("Alerts"), LPGENW("Automatic shutdown countdown"));
/* Events */
@@ -511,7 +511,7 @@ void InitShutdownSvc(void)
void UninitShutdownSvc(void)
{
/* Shutdown Dialog */
- if (hwndShutdownDlg != NULL)
+ if (hwndShutdownDlg != nullptr)
DestroyWindow(hwndShutdownDlg);
/* Services */
diff --git a/plugins/AutoShutdown/src/utils.cpp b/plugins/AutoShutdown/src/utils.cpp
index 32272d33fe..e288740dbb 100644
--- a/plugins/AutoShutdown/src/utils.cpp
+++ b/plugins/AutoShutdown/src/utils.cpp
@@ -26,23 +26,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// mir_free() the return value
char* u2a(const WCHAR *pszUnicode)
{
- if (pszUnicode == NULL)
- return NULL;
+ if (pszUnicode == nullptr)
+ return nullptr;
int codepage = Langpack_GetDefaultCodePage();
/* without WC_COMPOSITECHECK some characters might get out strange (see MS blog) */
DWORD flags;
- int cch = WideCharToMultiByte(codepage, flags = WC_COMPOSITECHECK, pszUnicode, -1, NULL, 0, NULL, NULL);
+ int cch = WideCharToMultiByte(codepage, flags = WC_COMPOSITECHECK, pszUnicode, -1, nullptr, 0, nullptr, nullptr);
if (!cch)
- cch = WideCharToMultiByte(codepage, flags = 0, pszUnicode, -1, NULL, 0, NULL, NULL);
+ cch = WideCharToMultiByte(codepage, flags = 0, pszUnicode, -1, nullptr, 0, nullptr, nullptr);
if (!cch)
- return NULL;
+ return nullptr;
char *psz = (char*)mir_alloc(cch);
- if (psz != NULL && !WideCharToMultiByte(codepage, flags, pszUnicode, -1, psz, cch, NULL, NULL)) {
+ if (psz != nullptr && !WideCharToMultiByte(codepage, flags, pszUnicode, -1, psz, cch, nullptr, nullptr)) {
mir_free(psz);
- return NULL;
+ return nullptr;
}
return psz;
}
@@ -84,11 +84,11 @@ void ShowInfoMessage(BYTE flags, const char *pszTitle, const char *pszTextFmt, .
mir_vsnprintf(szText, _countof(szText), pszTextFmt, va);
va_end(va);
- if (!Clist_TrayNotifyA(NULL, pszTitle, szText, flags, 30000)) // success
+ if (!Clist_TrayNotifyA(nullptr, pszTitle, szText, flags, 30000)) // success
return;
MSGBOXPARAMSA *mbp = (MSGBOXPARAMSA*)mir_calloc(sizeof(*mbp));
- if (mbp == NULL) return;
+ if (mbp == nullptr) return;
mbp->cbSize = sizeof(*mbp);
mbp->lpszCaption = mir_strdup(pszTitle);
mbp->lpszText = mir_strdup(szText);
@@ -105,11 +105,11 @@ void ShowInfoMessage(BYTE flags, const char *pszTitle, const char *pszTextFmt, .
// LocalFree() the return value
char* GetWinErrorDescription(DWORD dwLastError)
{
- char *buf = NULL;
+ char *buf = nullptr;
DWORD flags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM;
- if (!FormatMessageA(flags, NULL, dwLastError, LANGIDFROMLCID(Langpack_GetDefaultLocale()), (char*)&buf, 0, NULL))
+ if (!FormatMessageA(flags, nullptr, dwLastError, LANGIDFROMLCID(Langpack_GetDefaultLocale()), (char*)&buf, 0, nullptr))
if (GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND)
- FormatMessageA(flags, NULL, dwLastError, 0, (char*)&buf, 0, NULL);
+ FormatMessageA(flags, nullptr, dwLastError, 0, (char*)&buf, 0, nullptr);
return buf;
}
@@ -160,12 +160,12 @@ BOOL GetFormatedCountdown(wchar_t *pszOut, int nSize, time_t countdown)
}
/* WinVista */
- if (pfnGetDurationFormat != NULL) {
+ if (pfnGetDurationFormat != nullptr) {
SYSTEMTIME st;
LCID locale;
locale = Langpack_GetDefaultLocale();
if (TimeStampToSystemTime(countdown, &st))
- if (pfnGetDurationFormat(locale, 0, &st, 0, NULL, pszOut, nSize))
+ if (pfnGetDurationFormat(locale, 0, &st, 0, nullptr, pszOut, nSize))
return TRUE;
return FALSE;
}
@@ -182,13 +182,13 @@ BOOL GetFormatedDateTime(wchar_t *pszOut, int nSize, time_t timestamp, BOOL fSho
TimeStampToSystemTime(timestamp, &st);
/* today: no need to show the date */
if (!fShowDateEvenToday && st.wDay == stNow.wDay && st.wMonth == stNow.wMonth && st.wYear == stNow.wYear)
- return GetTimeFormat(locale, ((st.wSecond == 0) ? TIME_NOSECONDS : 0) | TIME_FORCE24HOURFORMAT, &st, NULL, pszOut, nSize) != 0;
+ return GetTimeFormat(locale, ((st.wSecond == 0) ? TIME_NOSECONDS : 0) | TIME_FORCE24HOURFORMAT, &st, nullptr, pszOut, nSize) != 0;
/* show both date and time */
{
wchar_t szDate[128], szTime[128];
- if (!GetTimeFormat(locale, ((st.wSecond == 0) ? TIME_NOSECONDS : 0) | TIME_FORCE24HOURFORMAT, &st, NULL, szTime, _countof(szTime)))
+ if (!GetTimeFormat(locale, ((st.wSecond == 0) ? TIME_NOSECONDS : 0) | TIME_FORCE24HOURFORMAT, &st, nullptr, szTime, _countof(szTime)))
return FALSE;
- if (!GetDateFormat(locale, DATE_SHORTDATE, &st, NULL, szDate, _countof(szDate)))
+ if (!GetDateFormat(locale, DATE_SHORTDATE, &st, nullptr, szDate, _countof(szDate)))
return FALSE;
mir_snwprintf(pszOut, nSize, L"%s %s", szTime, szDate);
return TRUE;
diff --git a/plugins/AutoShutdown/src/watcher.cpp b/plugins/AutoShutdown/src/watcher.cpp
index d5422b632f..04f8429eb0 100644
--- a/plugins/AutoShutdown/src/watcher.cpp
+++ b/plugins/AutoShutdown/src/watcher.cpp
@@ -45,15 +45,15 @@ static void __stdcall MainThreadMapping(void *param)
HANDLE *phDoneEvent = (HANDLE*)param;
ServiceShutdown(0, TRUE); /* ensure main thread (for cpu usage shutdown) */
ServiceStopWatcher(0, 0);
- if (*phDoneEvent != NULL)
+ if (*phDoneEvent != nullptr)
SetEvent(*phDoneEvent);
}
static void __inline ShutdownAndStopWatcher(void)
{
- HANDLE hDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ HANDLE hDoneEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
CallFunctionAsync(MainThreadMapping, &hDoneEvent);
- if (hDoneEvent != NULL) {
+ if (hDoneEvent != nullptr) {
WaitForSingleObject(hDoneEvent, INFINITE);
CloseHandle(hDoneEvent);
}
@@ -72,13 +72,13 @@ static wchar_t* GetMessageText(BYTE **ppBlob, DWORD *pcbBlob)
return (WCHAR*)&(*ppBlob)[cb];
}
/* no Unicode data present, convert from ANSI */
- int len = MultiByteToWideChar(CP_ACP, 0, (char*)*ppBlob, -1, NULL, 0);
+ int len = MultiByteToWideChar(CP_ACP, 0, (char*)*ppBlob, -1, nullptr, 0);
if (!len)
- return NULL;
+ return nullptr;
BYTE *buf = (BYTE*)mir_realloc(*ppBlob, (*pcbBlob) + (len*sizeof(WCHAR)));
- if (buf == NULL)
- return NULL;
+ if (buf == nullptr)
+ return nullptr;
*pcbBlob += len*sizeof(WCHAR);
*ppBlob = buf;
@@ -94,7 +94,7 @@ static int MsgEventAdded(WPARAM, LPARAM hDbEvent)
DBEVENTINFO dbe = {};
dbe.cbBlob = db_event_getBlobSize(hDbEvent);
dbe.pBlob = (BYTE*)mir_alloc(dbe.cbBlob + 2); /* ensure term zero */
- if (dbe.pBlob == NULL)
+ if (dbe.pBlob == nullptr)
return 0;
if (!db_event_get(hDbEvent, &dbe))
if (dbe.eventType == EVENTTYPE_MESSAGE && !(dbe.flags & DBEF_SENT)) {
@@ -102,7 +102,7 @@ static int MsgEventAdded(WPARAM, LPARAM hDbEvent)
if (!db_get_ws(NULL, "AutoShutdown", "Message", &dbv)) {
TrimString(dbv.ptszVal);
wchar_t *pszMsg = GetMessageText(&dbe.pBlob, &dbe.cbBlob);
- if (pszMsg != NULL && wcsstr(pszMsg, dbv.ptszVal) != NULL)
+ if (pszMsg != nullptr && wcsstr(pszMsg, dbv.ptszVal) != nullptr)
ShutdownAndStopWatcher(); /* msg with specified text recvd */
mir_free(dbv.ptszVal); /* does NULL check */
}
@@ -131,7 +131,7 @@ static int ProtoAck(WPARAM, LPARAM lParam)
break; /* already in list */
/* insert into list */
HANDLE *buf = (HANDLE*)mir_realloc(transfers, (nTransfersCount + 1)*sizeof(HANDLE));
- if (buf != NULL) {
+ if (buf != nullptr) {
transfers = buf;
transfers[nTransfersCount] = ack->hProcess;
++nTransfersCount;
@@ -148,8 +148,8 @@ static int ProtoAck(WPARAM, LPARAM lParam)
memmove(&transfers[i], &transfers[i + 1], (nTransfersCount - i - 1)*sizeof(HANDLE));
--nTransfersCount;
HANDLE *buf = (HANDLE*)mir_realloc(transfers, nTransfersCount*sizeof(HANDLE));
- if (buf != NULL) transfers = buf;
- else if (!nTransfersCount) transfers = NULL;
+ if (buf != nullptr) transfers = buf;
+ else if (!nTransfersCount) transfers = nullptr;
/* stop watcher */
if (!nTransfersCount && (currentWatcherType&SDWTF_FILETRANSFER))
ShutdownAndStopWatcher();
@@ -178,7 +178,7 @@ static BOOL CheckAllContactsOffline(void)
fSmartCheck = db_get_b(NULL, "AutoShutdown", "SmartOfflineCheck", SETTING_SMARTOFFLINECHECK_DEFAULT);
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *pszProto = GetContactProto(hContact);
- if (pszProto != NULL && CallProtoService(pszProto, PS_GETSTATUS, 0, 0) != ID_STATUS_OFFLINE) {
+ if (pszProto != nullptr && CallProtoService(pszProto, PS_GETSTATUS, 0, 0) != ID_STATUS_OFFLINE) {
if (db_get_b(hContact, pszProto, "ChatRoom", 0)) continue;
if (db_get_w(hContact, pszProto, "Status", 0) != ID_STATUS_OFFLINE) {
if (fSmartCheck) {
@@ -197,9 +197,9 @@ static int StatusSettingChanged(WPARAM wParam, LPARAM lParam)
{
if (currentWatcherType&SDWTF_STATUS) {
DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam;
- if ((HANDLE)wParam != NULL && dbcws->value.wVal == ID_STATUS_OFFLINE && !strcmp(dbcws->szSetting, "Status")) {
+ if ((HANDLE)wParam != nullptr && dbcws->value.wVal == ID_STATUS_OFFLINE && !strcmp(dbcws->szSetting, "Status")) {
char *pszProto = GetContactProto(wParam);
- if (pszProto != NULL && !strcmp(dbcws->szModule, pszProto))
+ if (pszProto != nullptr && !strcmp(dbcws->szModule, pszProto))
if (CheckAllContactsOffline())
ShutdownAndStopWatcher();
}
@@ -235,7 +235,7 @@ static BOOL CALLBACK CpuUsageWatcherProc(BYTE nCpuUsage, LPARAM lParam)
static int WeatherUpdated(WPARAM wParam, LPARAM lParam)
{
char *pszProto = GetContactProto(wParam);
- if ((BOOL)lParam && pszProto != NULL && CallProtoService(pszProto, PS_GETSTATUS, 0, 0) == THUNDER)
+ if ((BOOL)lParam && pszProto != nullptr && CallProtoService(pszProto, PS_GETSTATUS, 0, 0) == THUNDER)
if (db_get_b(NULL, "AutoShutdown", "WeatherShutdown", SETTING_WEATHERSHUTDOWN_DEFAULT))
ServiceShutdown(SDSDT_SHUTDOWN, TRUE);
return 0;
@@ -334,11 +334,11 @@ void InitWatcher(void)
/* Idle Shutdown */
hHookIdleChanged = HookEvent(ME_IDLE_CHANGED, IdleChanged);
/* Transfer Shutdown */
- transfers = NULL;
+ transfers = nullptr;
nTransfersCount = 0;
hHookProtoAck = HookEvent(ME_PROTO_ACK, ProtoAck);
/* Weather Shutdown */
- hHookWeatherUpdated = NULL;
+ hHookWeatherUpdated = nullptr;
/* Services */
hEventWatcherChanged = CreateHookableEvent(ME_AUTOSHUTDOWN_WATCHERCHANGED);
CreateServiceFunction(MS_AUTOSHUTDOWN_STARTWATCHER, ServiceStartWatcher);