summaryrefslogtreecommitdiff
path: root/plugins/Import
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/Import
parent591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff)
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/Import')
-rw-r--r--plugins/Import/src/import.cpp76
-rw-r--r--plugins/Import/src/main.cpp6
-rw-r--r--plugins/Import/src/miranda.cpp8
-rw-r--r--plugins/Import/src/utils.cpp6
-rw-r--r--plugins/Import/src/wizard.cpp6
5 files changed, 51 insertions, 51 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index 4b6890b7ab..80ca2367d1 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -30,7 +30,7 @@ struct AccountMap
szSrcAcc(mir_strdup(_src)),
iSrcIndex(_origIdx),
tszSrcName(mir_wstrdup(_srcName)),
- pa(NULL)
+ pa(nullptr)
{}
~AccountMap() {}
@@ -114,7 +114,7 @@ static int myGetD(MCONTACT hContact, const char *szModule, const char *szSetting
static wchar_t* myGetWs(MCONTACT hContact, const char *szModule, const char *szSetting)
{
DBVARIANT dbv = { DBVT_WCHAR };
- return srcDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? NULL : dbv.ptszVal;
+ return srcDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? nullptr : dbv.ptszVal;
}
static BOOL myGetS(MCONTACT hContact, const char *szModule, const char *szSetting, char *dest)
@@ -131,7 +131,7 @@ static MCONTACT HContactFromNumericID(char *pszProtoName, char *pszSetting, DWOR
for (MCONTACT hContact = dstDb->FindFirstContact(); hContact; hContact = dstDb->FindNextContact(hContact)) {
if (db_get_dw(hContact, pszProtoName, pszSetting, 0) == dwID) {
char* szProto = GetContactProto(hContact);
- if (szProto != NULL && !mir_strcmp(szProto, pszProtoName))
+ if (szProto != nullptr && !mir_strcmp(szProto, pszProtoName))
return hContact;
}
}
@@ -181,7 +181,7 @@ static int iPrevIndex = -1;
static void SetAccountName(int idx, PROTOACCOUNT *pa)
{
- ListView_SetItemText(hwndList, idx, 1, (pa == NULL) ? TranslateT("<New account>") : pa->tszAccountName);
+ ListView_SetItemText(hwndList, idx, 1, (pa == nullptr) ? TranslateT("<New account>") : pa->tszAccountName);
}
static LRESULT CALLBACK ComboWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -192,7 +192,7 @@ static LRESULT CALLBACK ComboWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
int idx = SendMessage(hwnd, CB_GETCURSEL, 0, 0);
if (idx == 0)
- pMap->pa = NULL;
+ pMap->pa = nullptr;
else
pMap->pa = (PROTOACCOUNT*)SendMessage(hwnd, CB_GETITEMDATA, idx, 0);
@@ -201,7 +201,7 @@ static LRESULT CALLBACK ComboWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
}
DestroyWindow(hwnd);
- hwndCombo = 0;
+ hwndCombo = nullptr;
}
return mir_callNextSubclass(hwnd, ComboWndProc, uMsg, wParam, lParam);
}
@@ -234,11 +234,11 @@ static LRESULT CALLBACK ListWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
lvitem.mask = LVIF_PARAM;
ListView_GetItem(hwnd, &lvitem);
- if (hwndCombo != NULL)
+ if (hwndCombo != nullptr)
SendMessage(hwndCombo, WM_KILLFOCUS, 0, (LPARAM)hwndCombo);
hwndCombo = CreateWindowEx(WS_EX_CLIENTEDGE, WC_COMBOBOX, L"", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST,
- r.left + 3, r.top, r.right - r.left - 3, r.bottom - r.top, hwnd, 0, hInst, NULL);
+ r.left + 3, r.top, r.right - r.left - 3, r.bottom - r.top, hwnd, nullptr, hInst, nullptr);
// copy a font from listview
HFONT hFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
@@ -310,7 +310,7 @@ static INT_PTR CALLBACK AccountsMatcherProc(HWND hwndDlg, UINT uMsg, WPARAM wPar
switch (LOWORD(wParam)) {
case IDOK:
- if (hwndCombo != NULL)
+ if (hwndCombo != nullptr)
SendMessage(hwndCombo, WM_KILLFOCUS, 0, (LPARAM)hwndCombo);
EndDialog(hwndDlg, IDOK);
break;
@@ -325,7 +325,7 @@ static INT_PTR CALLBACK AccountsMatcherProc(HWND hwndDlg, UINT uMsg, WPARAM wPar
break;
case WM_DESTROY:
- hwndAccMerge = NULL;
+ hwndAccMerge = nullptr;
break;
case WM_NOTIFY:
@@ -347,14 +347,14 @@ static INT_PTR CALLBACK AccountsMatcherProc(HWND hwndDlg, UINT uMsg, WPARAM wPar
static char* newStr(const char *s)
{
- return (s == NULL) ? NULL : mir_strcpy(new char[mir_strlen(s) + 1], s);
+ return (s == nullptr) ? nullptr : mir_strcpy(new char[mir_strlen(s) + 1], s);
}
static bool FindDestAccount(const char *szProto)
{
for (int i = 0; i < arAccountMap.getCount(); i++) {
AccountMap &pam = arAccountMap[i];
- if (pam.pa == NULL)
+ if (pam.pa == nullptr)
continue;
if (!mir_strcmp(pam.pa->szModuleName, szProto))
@@ -370,7 +370,7 @@ static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto,
PROTOACCOUNT **destAccs;
Proto_EnumAccounts(&destProtoCount, &destAccs);
- PROTOACCOUNT *pProto = NULL;
+ PROTOACCOUNT *pProto = nullptr;
for (int i = 0; i < destProtoCount; i++) {
PROTOACCOUNT *pa = destAccs[i];
// already used? skip
@@ -410,7 +410,7 @@ static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto,
if (bEqual)
return pa;
}
- return (bStrict) ? NULL : pProto;
+ return (bStrict) ? nullptr : pProto;
}
bool ImportAccounts(OBJLIST<char> &arSkippedModules)
@@ -453,14 +453,14 @@ bool ImportAccounts(OBJLIST<char> &arSkippedModules)
// all accounts to be converted automatically, no need to raise a dialog
if (bNeedManualMerge)
- if (DialogBox(hInst, MAKEINTRESOURCE(IDD_ACCMERGE), NULL, AccountsMatcherProc) != IDOK)
+ if (DialogBox(hInst, MAKEINTRESOURCE(IDD_ACCMERGE), nullptr, AccountsMatcherProc) != IDOK)
return false;
bool bImportSysAll = (nImportOptions & IOPT_SYS_SETTINGS) != 0;
for (int i = 0; i < arAccountMap.getCount(); i++) {
AccountMap &p = arAccountMap[i];
- if (p.pa != NULL || p.szBaseProto == NULL || !mir_strcmp(p.szSrcAcc, META_PROTO))
+ if (p.pa != nullptr || p.szBaseProto == NULL || !mir_strcmp(p.szSrcAcc, META_PROTO))
continue;
if (!Proto_IsProtocolLoaded(p.szBaseProto)) {
@@ -470,11 +470,11 @@ bool ImportAccounts(OBJLIST<char> &arSkippedModules)
ACC_CREATE newacc;
newacc.pszBaseProto = p.szBaseProto;
- newacc.pszInternal = NULL;
+ newacc.pszInternal = nullptr;
newacc.ptszAccountName = p.tszSrcName;
p.pa = ProtoCreateAccount(&newacc);
- if (p.pa == NULL) {
+ if (p.pa == nullptr) {
AddMessage(LPGENW("Unable to create an account %s of protocol %S"), p.tszSrcName, p.szBaseProto);
return false;
}
@@ -517,7 +517,7 @@ bool ImportAccounts(OBJLIST<char> &arSkippedModules)
static MCONTACT MapContact(MCONTACT hSrc)
{
ContactMap *pDestContact = arContactMap.find((ContactMap*)&hSrc);
- return (pDestContact == NULL) ? INVALID_CONTACT_ID : pDestContact->dstID;
+ return (pDestContact == nullptr) ? INVALID_CONTACT_ID : pDestContact->dstID;
}
static MCONTACT AddContact(char *szProto, char *pszUniqueSetting, DBVARIANT *id, const wchar_t *pszUserID, wchar_t *nick, wchar_t *group)
@@ -563,7 +563,7 @@ int ModulesEnumProc(const char *szModuleName, DWORD, LPARAM lParam)
void ImportContactSettings(AccountMap *pda, MCONTACT hSrc, MCONTACT hDst)
{
- if (pda->pa == NULL)
+ if (pda->pa == nullptr)
return;
ImportContactData icd = { hSrc, hDst, pda->szSrcAcc, pda->pa->szModuleName };
@@ -577,7 +577,7 @@ static int ImportGroup(const char* szSettingName, LPARAM lParam)
int *pnGroups = (int*)lParam;
wchar_t *tszGroup = myGetWs(NULL, "CListGroups", szSettingName);
- if (tszGroup != NULL) {
+ if (tszGroup != nullptr) {
if (CreateGroup(tszGroup + 1, NULL))
pnGroups[0]++;
mir_free(tszGroup);
@@ -612,7 +612,7 @@ DBCachedContact* FindDestMeta(DBCachedContact *ccSrc)
return cc;
}
- return NULL;
+ return nullptr;
}
MCONTACT FindExistingMeta(DBCachedContact *ccSrc)
@@ -626,7 +626,7 @@ MCONTACT FindExistingMeta(DBCachedContact *ccSrc)
continue;
DBCachedContact *cc = dstDb->m_cache->GetCachedContact(hDestSub);
- if (cc == NULL || !cc->IsSub()) // check if it's a sub
+ if (cc == nullptr || !cc->IsSub()) // check if it's a sub
continue;
if (hResult == INVALID_CONTACT_ID)
@@ -645,7 +645,7 @@ void ImportMeta(DBCachedContact *ccSrc)
// check first that the precise copy of metacontact exists
DBCachedContact *ccDst = FindDestMeta(ccSrc);
- if (ccDst == NULL) {
+ if (ccDst == nullptr) {
MCONTACT hDest = FindExistingMeta(ccSrc);
if (hDest == 0) {
AddMessage(LPGENW("Metacontact cannot be imported due to its ambiguity."));
@@ -663,7 +663,7 @@ void ImportMeta(DBCachedContact *ccSrc)
CopySettings(ccSrc->contactID, META_PROTO, hDest, META_PROTO);
ccDst = dstDb->m_cache->GetCachedContact(hDest);
- if (ccDst == NULL) // normally it shouldn't happen
+ if (ccDst == nullptr) // normally it shouldn't happen
return;
// simply copy the whole metacontact structure
@@ -688,7 +688,7 @@ void ImportMeta(DBCachedContact *ccSrc)
}
else { // add missing subs
ccDst = dstDb->m_cache->GetCachedContact(hDest);
- if (ccDst == NULL) // normally it shouldn't happen
+ if (ccDst == nullptr) // normally it shouldn't happen
return;
for (int i = 0; i < ccSrc->nSubs; i++) {
@@ -723,7 +723,7 @@ static MCONTACT ImportContact(MCONTACT hSrc)
{
// Check what protocol this contact belongs to
DBCachedContact *cc = srcDb->m_cache->GetCachedContact(hSrc);
- if (cc == NULL || cc->szProto == NULL) {
+ if (cc == nullptr || cc->szProto == nullptr) {
AddMessage(LPGENW("Skipping contact with no protocol"));
return NULL;
}
@@ -734,7 +734,7 @@ static MCONTACT ImportContact(MCONTACT hSrc)
}
AccountMap *pda = arAccountMap.find((AccountMap*)&cc->szProto);
- if (pda == NULL || pda->pa == NULL) {
+ if (pda == nullptr || pda->pa == nullptr) {
AddMessage(LPGENW("Skipping contact, account %S cannot be mapped."), cc->szProto);
return NULL;
}
@@ -774,7 +774,7 @@ static MCONTACT ImportContact(MCONTACT hSrc)
default:
hDst = INVALID_CONTACT_ID;
- pszUniqueID = NULL;
+ pszUniqueID = nullptr;
}
if (hDst != INVALID_CONTACT_ID) {
@@ -824,7 +824,7 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC
// we ignore history import for metacontacts
// the metahistory will be generated automatically by gathering subs' histories
DBCachedContact *cc = srcDb->m_cache->GetCachedContact(hContact);
- if (cc == NULL)
+ if (cc == nullptr)
return;
// for k/v databases we read history for subs only
@@ -937,7 +937,7 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC
if (!(i % 10)) {
MSG msg;
- if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@@ -961,18 +961,18 @@ void MirandaImport(HWND hdlg)
{
hdlgProgress = hdlg;
- if ((dstDb = db_get_current()) == NULL) {
+ if ((dstDb = db_get_current()) == nullptr) {
AddMessage(LPGENW("Error retrieving current profile, exiting."));
return;
}
DATABASELINK *dblink = FindDatabasePlugin(importFile);
- if (dblink == NULL) {
+ if (dblink == nullptr) {
AddMessage(LPGENW("There's no database driver to open the input file, exiting."));
return;
}
- if ((srcDb = dblink->Load(importFile, TRUE)) == NULL) {
+ if ((srcDb = dblink->Load(importFile, TRUE)) == nullptr) {
AddMessage(LPGENW("Error loading source file, exiting."));
return;
}
@@ -995,7 +995,7 @@ void MirandaImport(HWND hdlg)
dstDb->SetCacheSafetyMode(FALSE);
// Start benchmark timer
- DWORD dwTimer = time(NULL);
+ DWORD dwTimer = time(nullptr);
OBJLIST<char> arSkippedAccs(1, CompareModules);
if (!ImportAccounts(arSkippedAccs)) {
@@ -1034,7 +1034,7 @@ void MirandaImport(HWND hdlg)
// Process queued messages
MSG msg;
- if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@@ -1068,7 +1068,7 @@ void MirandaImport(HWND hdlg)
AddMessage(LPGENW("Importing history."));
MCONTACT hContact = srcDb->FindFirstContact();
for (int i = 1; hContact != NULL; i++) {
- ImportHistory(hContact, NULL, NULL);
+ ImportHistory(hContact, nullptr, NULL);
SetProgress(100 * i / nNumberOfContacts);
hContact = srcDb->FindNextContact(hContact);
@@ -1084,7 +1084,7 @@ void MirandaImport(HWND hdlg)
dblink->Unload(srcDb);
// Stop timer
- dwTimer = time(NULL) - dwTimer;
+ dwTimer = time(nullptr) - dwTimer;
// Print statistics
AddMessage(LPGENW("Import completed in %d seconds."), dwTimer);
diff --git a/plugins/Import/src/main.cpp b/plugins/Import/src/main.cpp
index 8f6b875f1a..33ae9d1494 100644
--- a/plugins/Import/src/main.cpp
+++ b/plugins/Import/src/main.cpp
@@ -58,7 +58,7 @@ static INT_PTR ImportCommand(WPARAM, LPARAM)
SetForegroundWindow(hwndWizard);
SetFocus(hwndWizard);
}
- else hwndWizard = CreateDialog(hInst, MAKEINTRESOURCE(IDD_WIZARD), NULL, WizardDlgProc);
+ else hwndWizard = CreateDialog(hInst, MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc);
return 0;
}
@@ -86,7 +86,7 @@ static int ModulesLoaded(WPARAM, LPARAM)
// Only autorun import wizard if at least one protocol is installed
int nProtocols = 0;
- PROTOACCOUNT **ppProtos = NULL;
+ PROTOACCOUNT **ppProtos = nullptr;
Proto_EnumAccounts(&nProtocols, &ppProtos);
if (nProtocols > 0) {
CallService(IMPORT_SERVICE, 0, 0);
@@ -107,7 +107,7 @@ static int OnExit(WPARAM, LPARAM)
static INT_PTR ServiceMode(WPARAM, LPARAM)
{
g_bServiceMode = true;
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_WIZARD), NULL, WizardDlgProc);
+ CreateDialog(hInst, MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc);
return SERVICE_ONLYDB;
}
diff --git a/plugins/Import/src/miranda.cpp b/plugins/Import/src/miranda.cpp
index 427b82222b..38aecfa1f5 100644
--- a/plugins/Import/src/miranda.cpp
+++ b/plugins/Import/src/miranda.cpp
@@ -46,7 +46,7 @@ static void SearchForLists(HWND hwndDlg, const wchar_t *mirandaPath, const wchar
continue;
// skip the current profile too
- if (mirandaProf != NULL && !mir_wstrcmpi(mirandaProf, fd.cFileName))
+ if (mirandaProf != nullptr && !mir_wstrcmpi(mirandaProf, fd.cFileName))
continue;
wchar_t buf[MAX_PATH], profile[MAX_PATH];
@@ -77,9 +77,9 @@ INT_PTR CALLBACK MirandaPageProc(HWND hwndDlg, UINT message, WPARAM wParam, LPAR
VARSW pfn(L"%miranda_profilename%");
SearchForLists(hwndDlg, pfd2, pfn);
- SearchForLists(hwndDlg, pfd1, NULL);
+ SearchForLists(hwndDlg, pfd1, nullptr);
if (mir_wstrcmpi(pfd, pfd2))
- SearchForLists(hwndDlg, pfd, NULL);
+ SearchForLists(hwndDlg, pfd, nullptr);
}
SendDlgItemMessage(hwndDlg, IDC_LIST, LB_SETCURSEL, 0, 0);
SendMessage(hwndDlg, WM_COMMAND, MAKELONG(IDC_LIST, LBN_SELCHANGE), 0);
@@ -222,7 +222,7 @@ INT_PTR CALLBACK MirandaAdvOptionsPageProc(HWND hwndDlg, UINT message, WPARAM wP
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
- dwSinceDate = db_get_dw(NULL, IMPORT_MODULE, "ImportSinceTS", time(NULL));
+ dwSinceDate = db_get_dw(NULL, IMPORT_MODULE, "ImportSinceTS", time(nullptr));
struct tm *TM = localtime(&dwSinceDate);
struct _SYSTEMTIME ST = { 0 };
diff --git a/plugins/Import/src/utils.cpp b/plugins/Import/src/utils.cpp
index 8425e52cab..ba9e6a45aa 100644
--- a/plugins/Import/src/utils.cpp
+++ b/plugins/Import/src/utils.cpp
@@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int CreateGroup(const wchar_t *group, MCONTACT hContact)
{
- if (group == NULL)
+ if (group == nullptr)
return 0;
if (Clist_GroupExists(group)) {
@@ -201,7 +201,7 @@ HICON GetIcon(int iIconId, bool size)
if (iconList[i].defIconID == iIconId)
return IcoLib_GetIconByHandle(iconList[i].hIcolib, size);
- return NULL;
+ return nullptr;
}
HANDLE GetIconHandle(int iIconId)
@@ -210,7 +210,7 @@ HANDLE GetIconHandle(int iIconId)
if (iconList[i].defIconID == iIconId)
return iconList[i].hIcolib;
- return NULL;
+ return nullptr;
}
void RegisterIcons()
diff --git a/plugins/Import/src/wizard.cpp b/plugins/Import/src/wizard.cpp
index 15efa50cff..a5fd8e26ee 100644
--- a/plugins/Import/src/wizard.cpp
+++ b/plugins/Import/src/wizard.cpp
@@ -66,7 +66,7 @@ INT_PTR CALLBACK FinishedPageProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM
char sModuleFileName[MAX_PATH];
GetModuleFileNameA(hInst, sModuleFileName, sizeof(sModuleFileName));
char *pszFileName = strrchr(sModuleFileName, '\\');
- if (pszFileName == NULL)
+ if (pszFileName == nullptr)
pszFileName = sModuleFileName;
else
pszFileName++;
@@ -96,7 +96,7 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lP
case WM_INITDIALOG:
TranslateDialogDefault(hdlg);
hwndPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_WIZARDINTRO), hdlg, WizardIntroPageProc);
- SetWindowPos(hwndPage, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ SetWindowPos(hwndPage, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
ShowWindow(hwndPage, SW_SHOW);
ShowWindow(hdlg, SW_SHOW);
Window_SetIcon_IcoLib(hdlg, GetIconHandle(IDI_IMPORT));
@@ -109,7 +109,7 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lP
EnableWindow(GetDlgItem(hdlg, IDCANCEL), TRUE);
SetDlgItemText(hdlg, IDCANCEL, TranslateT("Cancel"));
hwndPage = CreateDialog(hInst, MAKEINTRESOURCE(wParam), hdlg, (DLGPROC)lParam);
- SetWindowPos(hwndPage, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ SetWindowPos(hwndPage, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
ShowWindow(hwndPage, SW_SHOW);
break;