summaryrefslogtreecommitdiff
path: root/plugins/AvatarHistory
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/AvatarHistory
parent591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff)
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/AvatarHistory')
-rw-r--r--plugins/AvatarHistory/src/AvatarDlg.cpp18
-rw-r--r--plugins/AvatarHistory/src/AvatarHistory.cpp20
-rw-r--r--plugins/AvatarHistory/src/icolib.cpp2
-rw-r--r--plugins/AvatarHistory/src/options.cpp10
-rw-r--r--plugins/AvatarHistory/src/popup.cpp16
-rw-r--r--plugins/AvatarHistory/src/utils.cpp26
6 files changed, 46 insertions, 46 deletions
diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp
index 42dbfa80ef..a352efd61b 100644
--- a/plugins/AvatarHistory/src/AvatarDlg.cpp
+++ b/plugins/AvatarHistory/src/AvatarDlg.cpp
@@ -20,7 +20,7 @@ Avatar History Plugin
#include "stdafx.h"
-HGENMENU hMenu = NULL;
+HGENMENU hMenu = nullptr;
static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int ShowSaveDialog(HWND hwnd, wchar_t* fn, MCONTACT hContact = NULL);
@@ -49,8 +49,8 @@ public:
ListEntry()
{
hDbEvent = NULL;
- filename = NULL;
- filelink = NULL;
+ filename = nullptr;
+ filelink = nullptr;
}
~ListEntry()
@@ -82,7 +82,7 @@ int OpenAvatarDialog(MCONTACT hContact, char* fn)
struct AvatarDialogData *avdlg = (struct AvatarDialogData*)malloc(sizeof(struct AvatarDialogData));
memset(avdlg, 0, sizeof(struct AvatarDialogData));
avdlg->hContact = hContact;
- if (fn == NULL)
+ if (fn == nullptr)
avdlg->fn[0] = '\0';
else
MultiByteToWideChar(CP_ACP, 0, fn, -1, avdlg->fn, _countof(avdlg->fn));
@@ -143,7 +143,7 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
TranslateDialogDefault(hwnd);
EnableDisableControls(hwnd);
free(data);
- data = NULL;
+ data = nullptr;
}
break;
@@ -204,7 +204,7 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
POINT p;
p.x = LOWORD(lParam);
p.y = HIWORD(lParam);
- int ret = TrackPopupMenu(submenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, p.x, p.y, 0, hwndList, NULL);
+ int ret = TrackPopupMenu(submenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, p.x, p.y, 0, hwndList, nullptr);
DestroyMenu(menu);
ListEntry *le = (ListEntry*)SendMessage(hwndList, LB_GETITEMDATA, pos, 0);
@@ -312,7 +312,7 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
wchar_t avfolder[MAX_PATH];
MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
GetContactFolder(avfolder, hContact);
- ShellExecute(NULL, db_get_b(NULL, MODULE_NAME, "OpenFolderMethod", 0) ? L"explore" : L"open", avfolder, NULL, NULL, SW_SHOWNORMAL);
+ ShellExecute(nullptr, db_get_b(NULL, MODULE_NAME, "OpenFolderMethod", 0) ? L"explore" : L"open", avfolder, nullptr, nullptr, SW_SHOWNORMAL);
return TRUE;
}
break;
@@ -352,7 +352,7 @@ int AddFileToList(wchar_t *path, wchar_t *lnk, wchar_t *filename, HWND list)
le->filelink = mir_wstrdup(lnk);
wchar_t *p = wcschr(filename, '.');
- if (p != NULL)
+ if (p != nullptr)
p[0] = '\0';
int max_pos = SendMessage(list, LB_ADDSTRING, 0, (LPARAM)filename);
SendMessage(list, LB_SETITEMDATA, max_pos, (LPARAM)le);
@@ -464,7 +464,7 @@ bool UpdateAvatarPic(HWND hwnd)
HBITMAP avpic = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)le->filename, IMGL_WCHAR);
- bool found_image = (avpic != NULL);
+ bool found_image = (avpic != nullptr);
avpic = (HBITMAP)SendMessage(hwndpic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)avpic);
if (avpic)
diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp
index 0cc29ece82..cc4704a7c2 100644
--- a/plugins/AvatarHistory/src/AvatarHistory.cpp
+++ b/plugins/AvatarHistory/src/AvatarHistory.cpp
@@ -28,12 +28,12 @@ HINSTANCE hInst;
DWORD mirVer;
-HANDLE hFolder = NULL;
+HANDLE hFolder = nullptr;
wchar_t profilePath[MAX_PATH]; // database profile path (read at startup only)
wchar_t basedir[MAX_PATH];
int hLangpack = 0;
-MWindowList hAvatarWindowsList = NULL;
+MWindowList hAvatarWindowsList = nullptr;
int OptInit(WPARAM wParam, LPARAM lParam);
@@ -109,7 +109,7 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam)
return 0;
char *proto = GetContactProto(hContact);
- if (proto == NULL)
+ if (proto == nullptr)
return 0;
if (mir_strcmp(META_PROTO, proto) == 0)
@@ -119,7 +119,7 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam)
bool ret = (db_get_ws(hContact, MODULE_NAME, "AvatarHash", &dbvOldHash) == 0);
CONTACTAVATARCHANGEDNOTIFICATION* avatar = (CONTACTAVATARCHANGEDNOTIFICATION*)lParam;
- if (avatar == NULL) {
+ if (avatar == nullptr) {
if (!ret || !mir_wstrcmp(dbvOldHash.ptszVal, L"-")) {
//avoid duplicate "removed avatar" notifications
//do not notify on an empty profile
@@ -133,7 +133,7 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam)
db_set_ws(hContact, MODULE_NAME, "AvatarHash", L"-");
if (ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_removed)
- ShowPopup(hContact, NULL, opts.popup_removed);
+ ShowPopup(hContact, nullptr, opts.popup_removed);
}
else {
if (ret && !mir_wstrcmp(dbvOldHash.ptszVal, avatar->hash)) {
@@ -177,7 +177,7 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam)
wchar_t *file = GetCachedAvatar(proto, hash);
- if (file != NULL) {
+ if (file != nullptr) {
mir_wstrncpy(history_filename, file, _countof(history_filename));
mir_free(file);
}
@@ -207,7 +207,7 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam)
}
if (ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_changed)
- ShowPopup(hContact, NULL, opts.popup_changed);
+ ShowPopup(hContact, nullptr, opts.popup_changed);
if (ContactEnabled(hContact, "LogToHistory", AVH_DEF_LOGTOHISTORY)) {
wchar_t rel_path[MAX_PATH];
@@ -217,7 +217,7 @@ static int AvatarChanged(WPARAM hContact, LPARAM lParam)
DBEVENTINFO dbei = {};
dbei.szModule = GetContactProto(hContact);
dbei.flags = DBEF_READ | DBEF_UTF;
- dbei.timestamp = (DWORD)time(NULL);
+ dbei.timestamp = (DWORD)time(nullptr);
dbei.eventType = EVENTTYPE_AVATAR_CHANGE;
dbei.cbBlob = (DWORD)mir_strlen(blob) + 1;
dbei.pBlob = blob;
@@ -294,12 +294,12 @@ extern "C" __declspec(dllexport) int Load(void)
mir_getLP(&pluginInfo);
pcli = Clist_GetInterface();
- CoInitialize(NULL);
+ CoInitialize(nullptr);
// Is first run?
if (db_get_b(NULL, MODULE_NAME, "FirstRun", 1)) {
// Show dialog
- int ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FIRST_RUN), NULL, FirstRunDlgProc, 0);
+ int ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FIRST_RUN), nullptr, FirstRunDlgProc, 0);
if (ret == 0)
return -1;
diff --git a/plugins/AvatarHistory/src/icolib.cpp b/plugins/AvatarHistory/src/icolib.cpp
index 28cfbb9f6c..38ce5a44a7 100644
--- a/plugins/AvatarHistory/src/icolib.cpp
+++ b/plugins/AvatarHistory/src/icolib.cpp
@@ -25,7 +25,7 @@ static void ReleaseIconEx(HICON hIcon)
static void IcoLibUpdateMenus()
{
HICON hIcon = createDefaultOverlayedIcon(FALSE);
- Menu_ModifyItem(hMenu, 0, hIcon, 0);
+ Menu_ModifyItem(hMenu, nullptr, hIcon, 0);
DestroyIcon(hIcon);
}
diff --git a/plugins/AvatarHistory/src/options.cpp b/plugins/AvatarHistory/src/options.cpp
index 3d94a21e3c..7987f862a4 100644
--- a/plugins/AvatarHistory/src/options.cpp
+++ b/plugins/AvatarHistory/src/options.cpp
@@ -25,18 +25,18 @@ Options opts;
// Prototypes /////////////////////////////////////////////////////////////////////////////////////
static OptPageControl optionsControls[] = {
- { NULL, CONTROL_PROTOCOL_LIST, IDC_PROTOCOLS, "%sEnabled", TRUE }
+ { nullptr, CONTROL_PROTOCOL_LIST, IDC_PROTOCOLS, "%sEnabled", TRUE }
};
static OptPageControl popupsControls[] = {
- { NULL, CONTROL_CHECKBOX, IDC_POPUPS, "AvatarPopups", AVH_DEF_AVPOPUPS },
+ { nullptr, CONTROL_CHECKBOX, IDC_POPUPS, "AvatarPopups", AVH_DEF_AVPOPUPS },
{ &opts.popup_bkg_color, CONTROL_COLOR, IDC_BGCOLOR, "PopupsBgColor", AVH_DEF_POPUPBG },
{ &opts.popup_text_color, CONTROL_COLOR, IDC_TEXTCOLOR, "PopupsTextColor", AVH_DEF_POPUPFG },
{ &opts.popup_use_win_colors, CONTROL_CHECKBOX, IDC_WINCOLORS, "PopupsWinColors", FALSE },
{ &opts.popup_use_default_colors, CONTROL_CHECKBOX, IDC_DEFAULTCOLORS, "PopupsDefaultColors", AVH_DEF_DEFPOPUPS },
{ &opts.popup_delay_type, CONTROL_RADIO, IDC_DELAYFROMPU, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_DEFAULT },
- { NULL, CONTROL_RADIO, IDC_DELAYCUSTOM, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_CUSTOM },
- { NULL, CONTROL_RADIO, IDC_DELAYPERMANENT, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_PERMANENT },
+ { nullptr, CONTROL_RADIO, IDC_DELAYCUSTOM, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_CUSTOM },
+ { nullptr, CONTROL_RADIO, IDC_DELAYPERMANENT, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_PERMANENT },
{ &opts.popup_timeout, CONTROL_SPIN, IDC_DELAY, "PopupsTimeout", 10, IDC_DELAY_SPIN, (WORD)1, (WORD)255 },
{ &opts.popup_right_click_action, CONTROL_COMBO, IDC_RIGHT_ACTION, "PopupsRightClick", POPUP_ACTION_CLOSEPOPUP },
{ &opts.popup_left_click_action, CONTROL_COMBO, IDC_LEFT_ACTION, "PopupsLeftClick", POPUP_ACTION_OPENAVATARHISTORY },
@@ -127,7 +127,7 @@ static INT_PTR CALLBACK PopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYPERMANENT))
op.popup_delay_type = POPUP_DELAY_PERMANENT;
- op.popup_timeout = GetDlgItemInt(hwndDlg, IDC_DELAY, NULL, FALSE);
+ op.popup_timeout = GetDlgItemInt(hwndDlg, IDC_DELAY, nullptr, FALSE);
op.popup_bkg_color = SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0);
op.popup_text_color = SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, 0);
op.popup_use_win_colors = IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS) != 0;
diff --git a/plugins/AvatarHistory/src/popup.cpp b/plugins/AvatarHistory/src/popup.cpp
index 9fee0bb3ff..6d4ef5c8ab 100644
--- a/plugins/AvatarHistory/src/popup.cpp
+++ b/plugins/AvatarHistory/src/popup.cpp
@@ -26,7 +26,7 @@ Boston, MA 02111-1307, USA.
LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-HWND hPopupWindow = NULL;
+HWND hPopupWindow = nullptr;
static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
@@ -43,7 +43,7 @@ void InitPopups()
// window needed for popup commands
hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW, L"static", _A2W(MODULE_NAME) L"_PopupWindow",
0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP,
- NULL, hInst, NULL);
+ nullptr, hInst, nullptr);
SetWindowLongPtr(hPopupWindow, GWLP_WNDPROC, (LONG_PTR)PopupWndProc);
}
@@ -56,14 +56,14 @@ void DeInitPopups()
// Show an error popup
void ShowErrPopup(const wchar_t *description, const wchar_t *title)
{
- ShowPopupEx(NULL, title == NULL ? _A2W(MODULE_NAME) L" Error" : title, description,
- NULL, POPUP_TYPE_ERROR, NULL);
+ ShowPopupEx(NULL, title == nullptr ? _A2W(MODULE_NAME) L" Error" : title, description,
+ nullptr, POPUP_TYPE_ERROR, nullptr);
}
void ShowTestPopup(MCONTACT hContact, const wchar_t *title, const wchar_t *description, const Options *op)
{
- ShowPopupEx(hContact, title, description, NULL, POPUP_TYPE_TEST, op);
+ ShowPopupEx(hContact, title, description, nullptr, POPUP_TYPE_TEST, op);
}
@@ -101,13 +101,13 @@ void ShowPopupEx(MCONTACT hContact, const wchar_t *title, const wchar_t *descrip
((PopupDataType*)ppd.PluginData)->plugin_data = plugin_data;
((PopupDataType*)ppd.PluginData)->hIcon = ppd.lchIcon;
- if (title != NULL)
+ if (title != nullptr)
mir_wstrncpy(ppd.lptzContactName, title, _countof(ppd.lptzContactName));
else if (hContact != NULL)
mir_wstrncpy(ppd.lptzContactName, (wchar_t *)pcli->pfnGetContactDisplayName(hContact, 0),
_countof(ppd.lptzContactName));
- if (description != NULL)
+ if (description != nullptr)
mir_wstrncpy(ppd.lptzText, description, _countof(ppd.lptzText));
if (type == POPUP_TYPE_NORMAL || type == POPUP_TYPE_TEST) {
@@ -163,7 +163,7 @@ void ShowPopupEx(MCONTACT hContact, const wchar_t *title, const wchar_t *descrip
PUAddPopupT(&ppd);
}
else {
- MessageBox(NULL, description, title ? title : (wchar_t *)pcli->pfnGetContactDisplayName(hContact, 0),
+ MessageBox(nullptr, description, title ? title : (wchar_t *)pcli->pfnGetContactDisplayName(hContact, 0),
MB_OK);
}
diff --git a/plugins/AvatarHistory/src/utils.cpp b/plugins/AvatarHistory/src/utils.cpp
index 30f756839b..71214413a2 100644
--- a/plugins/AvatarHistory/src/utils.cpp
+++ b/plugins/AvatarHistory/src/utils.cpp
@@ -74,9 +74,9 @@ void ConvertToFilename(wchar_t *str, size_t size)
wchar_t* GetExtension(wchar_t *file)
{
- if (file == NULL) return L"";
+ if (file == nullptr) return L"";
wchar_t *ext = wcsrchr(file, '.');
- if (ext != NULL)
+ if (ext != nullptr)
ext++;
else
ext = L"";
@@ -86,7 +86,7 @@ wchar_t* GetExtension(wchar_t *file)
wchar_t* GetHistoryFolder(wchar_t *fn)
{
- if (fn == NULL) return NULL;
+ if (fn == nullptr) return nullptr;
FoldersGetCustomPathT(hFolder, fn, MAX_PATH, basedir);
CreateDirectoryTreeW(fn);
return fn;
@@ -96,7 +96,7 @@ wchar_t* GetProtocolFolder(wchar_t *fn, char *proto)
{
GetHistoryFolder(fn);
- if (proto == NULL)
+ if (proto == nullptr)
proto = Translate("Unknown protocol");
mir_snwprintf(fn, MAX_PATH, L"%s\\%S", fn, proto);
@@ -163,7 +163,7 @@ BOOL CopyImageFile(wchar_t *old_file, wchar_t *new_file)
wchar_t* GetCachedAvatar(char *proto, wchar_t *hash)
{
- wchar_t *ret = NULL;
+ wchar_t *ret = nullptr;
wchar_t file[1024] = L"";
wchar_t search[1024] = L"";
if (opts.log_keep_same_folder)
@@ -176,7 +176,7 @@ wchar_t* GetCachedAvatar(char *proto, wchar_t *hash)
WIN32_FIND_DATA finddata;
HANDLE hFind = FindFirstFile(search, &finddata);
if (hFind == INVALID_HANDLE_VALUE)
- return NULL;
+ return nullptr;
do {
size_t len = mir_wstrlen(finddata.cFileName);
@@ -198,12 +198,12 @@ wchar_t* GetCachedAvatar(char *proto, wchar_t *hash)
BOOL CreateShortcut(wchar_t *file, wchar_t *shortcut)
{
- IShellLink *psl = NULL;
- HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
+ IShellLink *psl = nullptr;
+ HRESULT hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
if (SUCCEEDED(hr)) {
psl->SetPath(file);
- IPersistFile *ppf = NULL;
+ IPersistFile *ppf = nullptr;
hr = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
if (SUCCEEDED(hr)) {
hr = ppf->Save(shortcut, TRUE);
@@ -218,18 +218,18 @@ BOOL CreateShortcut(wchar_t *file, wchar_t *shortcut)
BOOL ResolveShortcut(wchar_t *shortcut, wchar_t *file)
{
- IShellLink* psl = NULL;
+ IShellLink* psl = nullptr;
- HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
+ HRESULT hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
if (SUCCEEDED(hr)) {
- IPersistFile* ppf = NULL;
+ IPersistFile* ppf = nullptr;
hr = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
if (SUCCEEDED(hr)) {
hr = ppf->Load(shortcut, STGM_READ);
if (SUCCEEDED(hr)) {
- hr = psl->Resolve(NULL, SLR_UPDATE);
+ hr = psl->Resolve(nullptr, SLR_UPDATE);
if (SUCCEEDED(hr)) {
WIN32_FIND_DATA wfd;
hr = psl->GetPath(file, MAX_PATH, &wfd, SLGP_RAWPATH);