summaryrefslogtreecommitdiff
path: root/plugins/FavContacts/src
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/FavContacts/src
parent591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff)
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/FavContacts/src')
-rw-r--r--plugins/FavContacts/src/contact_cache.cpp16
-rw-r--r--plugins/FavContacts/src/cserver.cpp2
-rw-r--r--plugins/FavContacts/src/main.cpp2
-rw-r--r--plugins/FavContacts/src/menu.cpp28
-rw-r--r--plugins/FavContacts/src/options.cpp14
-rw-r--r--plugins/FavContacts/src/services.cpp6
6 files changed, 34 insertions, 34 deletions
diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp
index 9c6b49543e..d6039f3782 100644
--- a/plugins/FavContacts/src/contact_cache.cpp
+++ b/plugins/FavContacts/src/contact_cache.cpp
@@ -30,13 +30,13 @@ int __cdecl CContactCache::OnDbEventAdded(WPARAM hContact, LPARAM hEvent)
if (dbei.eventType != EVENTTYPE_MESSAGE)
return 0;
- float weight = GetEventWeight(time(NULL) - dbei.timestamp);
- float q = GetTimeWeight(time(NULL) - m_lastUpdate);
- m_lastUpdate = time(NULL);
+ float weight = GetEventWeight(time(nullptr) - dbei.timestamp);
+ float q = GetTimeWeight(time(nullptr) - m_lastUpdate);
+ m_lastUpdate = time(nullptr);
if (!weight)
return 0;
- TContactInfo *pFound = NULL;
+ TContactInfo *pFound = nullptr;
mir_cslock lck(m_cs);
for (int i = m_cache.getCount()-1; i >= 0; i--) {
TContactInfo *p = m_cache[i];
@@ -77,8 +77,8 @@ float CContactCache::GetTimeWeight(unsigned long age)
void CContactCache::Rebuild()
{
- unsigned long timestamp = time(NULL);
- m_lastUpdate = time(NULL);
+ unsigned long timestamp = time(nullptr);
+ m_lastUpdate = time(nullptr);
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
TContactInfo *info = new TContactInfo;
@@ -150,7 +150,7 @@ void CContactCache::TContactInfo::LoadInfo()
wchar_t *nb_stristr(wchar_t *str, wchar_t *substr)
{
if (!substr || !*substr) return str;
- if (!str || !*str) return NULL;
+ if (!str || !*str) return nullptr;
wchar_t *str_up = NEWWSTR_ALLOCA(str);
wchar_t *substr_up = NEWWSTR_ALLOCA(substr);
@@ -159,7 +159,7 @@ wchar_t *nb_stristr(wchar_t *str, wchar_t *substr)
CharUpperBuff(substr_up, (DWORD)mir_wstrlen(substr_up));
wchar_t *p = wcsstr(str_up, substr_up);
- return p ? (str + (p - str_up)) : NULL;
+ return p ? (str + (p - str_up)) : nullptr;
}
bool CContactCache::filter(int rate, wchar_t *str)
diff --git a/plugins/FavContacts/src/cserver.cpp b/plugins/FavContacts/src/cserver.cpp
index 18739f8e34..42f35cd687 100644
--- a/plugins/FavContacts/src/cserver.cpp
+++ b/plugins/FavContacts/src/cserver.cpp
@@ -37,7 +37,7 @@ void CServer::Stop()
DWORD CServer::ConnectionAcceptThread()
{
while (1) {
- SOCKET s = accept(m_socket, NULL, NULL);
+ SOCKET s = accept(m_socket, nullptr, nullptr);
if (s == INVALID_SOCKET) break;
mir_forkthread(GlobalConnectionProcessThread, new GlobalConnectionProcessThreadArgs(this, s));
diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp
index 22fa356b6c..04d429a82b 100644
--- a/plugins/FavContacts/src/main.cpp
+++ b/plugins/FavContacts/src/main.cpp
@@ -48,7 +48,7 @@ IconItem iconList[] =
{ LPGEN("Regular Contact"), "favcontacts_regular", IDI_REGULAR },
};
-CContactCache *g_contactCache = NULL;
+CContactCache *g_contactCache = nullptr;
Options g_Options = { 0 };
diff --git a/plugins/FavContacts/src/menu.cpp b/plugins/FavContacts/src/menu.cpp
index 176f645120..f0c8e1072e 100644
--- a/plugins/FavContacts/src/menu.cpp
+++ b/plugins/FavContacts/src/menu.cpp
@@ -25,7 +25,7 @@ float g_widthMultiplier = 0;
wchar_t g_filter[1024] = { 0 };
-HWND g_hwndMenuHost = NULL;
+HWND g_hwndMenuHost = nullptr;
static wchar_t* sttGetGroupName(int id)
{
@@ -35,7 +35,7 @@ static wchar_t* sttGetGroupName(int id)
return TranslateT("Favorite Contacts");
}
- return Clist_GroupGetName(id - 1, NULL);
+ return Clist_GroupGetName(id - 1, nullptr);
}
static BOOL sttMeasureItem_Group(LPMEASUREITEMSTRUCT lpmis, Options *options)
@@ -72,7 +72,7 @@ static BOOL sttMeasureItem_Contact(LPMEASUREITEMSTRUCT lpmis, Options *options)
if (options->bSecondLine) {
bool bFree = false;
wchar_t *title = db_get_wsa(hContact, "CList", "StatusMsg");
- if (title == NULL) {
+ if (title == nullptr) {
char *proto = GetContactProto(hContact);
int status = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
title = pcli->pfnGetStatusModeDescription(status, 0);
@@ -137,7 +137,7 @@ BOOL MenuMeasureItem(LPMEASUREITEMSTRUCT lpmis, Options *options)
return FALSE;
}
-static BOOL sttDrawItem_Group(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
+static BOOL sttDrawItem_Group(LPDRAWITEMSTRUCT lpdis, Options *options = nullptr)
{
lpdis->rcItem.top++;
lpdis->rcItem.bottom--;
@@ -183,7 +183,7 @@ void ImageList_DrawDimmed(HIMAGELIST himl, int i, HDC hdc, int left, int top, UI
DeleteDC(dcMem);
}
-static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
+static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = nullptr)
{
MCONTACT hContact = (MCONTACT)lpdis->itemData;
@@ -259,7 +259,7 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
if (options->wMaxRecent && db_get_b(hContact, "FavContacts", "IsFavourite", 0)) {
DrawIconEx(hdcTemp, lpdis->rcItem.right - 18, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
- IcoLib_GetIconByHandle(iconList[0].hIcolib), 16, 16, 0, NULL, DI_NORMAL);
+ IcoLib_GetIconByHandle(iconList[0].hIcolib), 16, 16, 0, nullptr, DI_NORMAL);
lpdis->rcItem.right -= 20;
}
@@ -316,7 +316,7 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL)
if (options->bSecondLine) {
bool bFree = false;
wchar_t *title = db_get_wsa(hContact, "CList", "StatusMsg");
- if (title == NULL) {
+ if (title == nullptr) {
int status = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
title = pcli->pfnGetStatusModeDescription(status, 0);
}
@@ -428,7 +428,7 @@ static LRESULT CALLBACK MenuHostWndProc(HWND hwnd, UINT message, WPARAM wParam,
GetCursorPos(&pt);
HWND hwndSave = GetForegroundWindow();
SetForegroundWindow(g_hwndMenuHost);
- int res = TrackPopupMenu(hMenu, TPM_RECURSE | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, g_hwndMenuHost, NULL);
+ int res = TrackPopupMenu(hMenu, TPM_RECURSE | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, g_hwndMenuHost, nullptr);
SetForegroundWindow(hwndSave);
DestroyMenu(hMenu);
@@ -444,7 +444,7 @@ int ShowMenu(bool centered)
HMENU hMenu = CreatePopupMenu();
SIZE szMenu = { 0 };
SIZE szColumn = { 0 };
- wchar_t *prevGroup = NULL;
+ wchar_t *prevGroup = nullptr;
int idItem = 100;
MCONTACT hContact;
@@ -457,7 +457,7 @@ int ShowMenu(bool centered)
if (g_Options.bUseColumns)
g_maxItemWidth /= favList.groupCount();
- prevGroup = NULL;
+ prevGroup = nullptr;
for (int i = 0; i < favList.getCount(); ++i) {
hContact = favList[i]->getHandle();
@@ -517,7 +517,7 @@ int ShowMenu(bool centered)
hContact = NULL;
g_filter[0] = 0;
- if (int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, g_hwndMenuHost, NULL)) {
+ if (int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, g_hwndMenuHost, nullptr)) {
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_DATA;
@@ -538,13 +538,13 @@ void InitMenu()
WNDCLASSEX wcl = { sizeof(wcl) };
wcl.lpfnWndProc = MenuHostWndProc;
wcl.hInstance = g_hInst;
- wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcl.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcl.lpszClassName = L"FavContactsMenuHostWnd";
RegisterClassEx(&wcl);
- g_hwndMenuHost = CreateWindow(L"FavContactsMenuHostWnd", NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, g_hInst, NULL);
- SetWindowPos(g_hwndMenuHost, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_HIDEWINDOW);
+ g_hwndMenuHost = CreateWindow(L"FavContactsMenuHostWnd", nullptr, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, g_hInst, nullptr);
+ SetWindowPos(g_hwndMenuHost, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_HIDEWINDOW);
}
void UninitMenu()
diff --git a/plugins/FavContacts/src/options.cpp b/plugins/FavContacts/src/options.cpp
index e479ee58ce..5a5ce392b7 100644
--- a/plugins/FavContacts/src/options.cpp
+++ b/plugins/FavContacts/src/options.cpp
@@ -133,8 +133,8 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
options.bCenterHotkey = IsDlgButtonChecked(hwnd, IDC_CHK_CENTERHOTKEY);
options.bRightAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_RIGHTAVATARS);
options.bDimIdle = IsDlgButtonChecked(hwnd, IDC_CHK_DIMIDLE);
- options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, NULL, FALSE);
- options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, NULL, FALSE);
+ options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, nullptr, FALSE);
+ options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, nullptr, FALSE);
mis.CtlID = 0;
mis.CtlType = ODT_MENU;
@@ -168,7 +168,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
case IDC_CHK_GROUPCOLUMS:
case IDC_CHK_RIGHTAVATARS:
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
+ RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), nullptr, nullptr, RDW_INVALIDATE);
PostMessage(hwnd, WM_APP, 0, 0);
break;
@@ -178,7 +178,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
case IDC_TXT_RADIUS:
if ((HIWORD(wParam) == EN_CHANGE) && bInitialized) {
- RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
+ RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), nullptr, nullptr, RDW_INVALIDATE);
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
break;
@@ -202,8 +202,8 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
g_Options.bUseColumns = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPCOLUMS);
g_Options.bRightAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_RIGHTAVATARS);
g_Options.bDimIdle = IsDlgButtonChecked(hwnd, IDC_CHK_DIMIDLE);
- g_Options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, NULL, FALSE);
- g_Options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, NULL, FALSE);
+ g_Options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, nullptr, FALSE);
+ g_Options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, nullptr, FALSE);
sttSaveOptions();
@@ -239,7 +239,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0) == iSelection) {
hSelectedContact = hContact;
- RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
+ RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), nullptr, nullptr, RDW_INVALIDATE);
}
}
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
diff --git a/plugins/FavContacts/src/services.cpp b/plugins/FavContacts/src/services.cpp
index d562f5e187..c348de82ce 100644
--- a/plugins/FavContacts/src/services.cpp
+++ b/plugins/FavContacts/src/services.cpp
@@ -62,11 +62,11 @@ int ProcessSrmmEvent(WPARAM, LPARAM lParam)
while (HWND hwndParent = GetParent(hwndRoot))
hwndRoot = hwndParent;
- AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(), NULL), GetCurrentThreadId(), TRUE);
+ AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(), nullptr), GetCurrentThreadId(), TRUE);
SetForegroundWindow(hwndRoot);
SetActiveWindow(hwndRoot);
SetFocus(hwndRoot);
- AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(), NULL), GetCurrentThreadId(), FALSE);
+ AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(), nullptr), GetCurrentThreadId(), FALSE);
}
hContactToActivate = NULL;
@@ -112,7 +112,7 @@ static __forceinline COLORREF sttShadeColor(COLORREF clLine1, COLORREF clBack)
int ProcessTBLoaded(WPARAM, LPARAM)
{
- TTBButton ttb = { 0 };
+ TTBButton ttb = {};
ttb.pszTooltipUp = ttb.name = LPGEN("Favorite Contacts");
ttb.pszService = MS_FAVCONTACTS_SHOWMENU;
ttb.dwFlags = TTBBF_SHOWTOOLTIP | TTBBF_VISIBLE;