diff options
author | Goraf <22941576+Goraf@users.noreply.github.com> | 2017-11-13 15:03:31 +0100 |
---|---|---|
committer | Goraf <22941576+Goraf@users.noreply.github.com> | 2017-11-13 15:07:33 +0100 |
commit | a7c24ca48995cf2bf436156302f96b91bf135409 (patch) | |
tree | 953835509ff1b778833e78fd7b74b05e05e77c84 /plugins/New_GPG | |
parent | 591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff) |
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/New_GPG')
-rw-r--r-- | plugins/New_GPG/src/icons.cpp | 2 | ||||
-rw-r--r-- | plugins/New_GPG/src/init.cpp | 8 | ||||
-rw-r--r-- | plugins/New_GPG/src/jabber_account.cpp | 4 | ||||
-rw-r--r-- | plugins/New_GPG/src/log.cpp | 2 | ||||
-rwxr-xr-x | plugins/New_GPG/src/main.cpp | 162 | ||||
-rwxr-xr-x | plugins/New_GPG/src/messages.cpp | 26 | ||||
-rwxr-xr-x | plugins/New_GPG/src/options.cpp | 52 | ||||
-rwxr-xr-x | plugins/New_GPG/src/utilities.cpp | 80 |
8 files changed, 168 insertions, 168 deletions
diff --git a/plugins/New_GPG/src/icons.cpp b/plugins/New_GPG/src/icons.cpp index 64c9208d97..8111d29887 100644 --- a/plugins/New_GPG/src/icons.cpp +++ b/plugins/New_GPG/src/icons.cpp @@ -39,7 +39,7 @@ void setClistIcon(MCONTACT hContact) bool enabled = isContactSecured(hContact);
extern HANDLE g_hCLIcon;
MCONTACT hMC = db_mc_tryMeta(hContact);
- const char *szIconId = (enabled) ? "secured" : NULL;
+ const char *szIconId = (enabled) ? "secured" : nullptr;
ExtraIcon_SetIconByName(g_hCLIcon, hContact, szIconId);
if(hMC != hContact)
ExtraIcon_SetIconByName(g_hCLIcon, hMC, szIconId);
diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index 79a68b4bba..27bfb72b0f 100644 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -18,15 +18,15 @@ //global variables
bool bAppendTags = false, bDebugLog = false, bJabberAPI = false, bPresenceSigning = false, bFileTransfers = false, bSameAction = false, bAutoExchange = false, bStripTags = false, tabsrmm_used = false;
-wchar_t *inopentag = NULL, *inclosetag = NULL, *outopentag = NULL, *outclosetag = NULL, *password = NULL;
+wchar_t *inopentag = nullptr, *inclosetag = nullptr, *outopentag = nullptr, *outclosetag = nullptr, *password = nullptr;
list <JabberAccount*> Accounts;
CLIST_INTERFACE *pcli;
HINSTANCE hInst;
-HFONT bold_font = NULL;
-HANDLE hLoadPubKey = NULL, g_hCLIcon = NULL, hExportGpgKeys = NULL, hImportGpgKeys = NULL;
-HGENMENU hSendKey = NULL, hToggleEncryption = NULL;
+HFONT bold_font = nullptr;
+HANDLE hLoadPubKey = nullptr, g_hCLIcon = nullptr, hExportGpgKeys = nullptr, hImportGpgKeys = nullptr;
+HGENMENU hSendKey = nullptr, hToggleEncryption = nullptr;
RECT key_from_keyserver_rect = {0}, firstrun_rect = {0}, new_key_rect = {0}, key_gen_rect = {0}, load_key_rect = {0}, import_key_rect = {0}, key_password_rect = {0}, load_existing_key_rect = {0};
int hLangpack = 0;
diff --git a/plugins/New_GPG/src/jabber_account.cpp b/plugins/New_GPG/src/jabber_account.cpp index 29f561d5e2..c8fe82d0e9 100644 --- a/plugins/New_GPG/src/jabber_account.cpp +++ b/plugins/New_GPG/src/jabber_account.cpp @@ -71,12 +71,12 @@ HJHANDLER JabberAccount::getMessageHandler() JabberAccount::JabberAccount()
{
- AccountName = NULL;
+ AccountName = nullptr;
hSendHandler = INVALID_HANDLE_VALUE;
hPrescenseHandler = INVALID_HANDLE_VALUE;
hMessageHandler = INVALID_HANDLE_VALUE;
AccountNumber = -1;
- JabberInterface = NULL;
+ JabberInterface = nullptr;
}
JabberAccount::~JabberAccount()
{
diff --git a/plugins/New_GPG/src/log.cpp b/plugins/New_GPG/src/log.cpp index 362344c46f..675589111d 100644 --- a/plugins/New_GPG/src/log.cpp +++ b/plugins/New_GPG/src/log.cpp @@ -79,7 +79,7 @@ void logtofile::init() }
logtofile::logtofile()
{
- path = NULL;
+ path = nullptr;
}
logtofile::~logtofile()
{
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp index 6d954f7451..48bc61e07d 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -23,11 +23,11 @@ extern bool bAutoExchange; void ShowFirstRunDialog(); -HWND hwndFirstRun = NULL, hwndSetDirs = NULL, hwndNewKey = NULL, hwndKeyGen = NULL, hwndSelectExistingKey = NULL; +HWND hwndFirstRun = nullptr, hwndSetDirs = nullptr, hwndNewKey = nullptr, hwndKeyGen = nullptr, hwndSelectExistingKey = nullptr; int itemnum = 0; -HWND hwndList_g = NULL; +HWND hwndList_g = nullptr; BOOL CheckStateStoreDB(HWND hwndDlg, int idCtrl, const char* szSetting); wchar_t key_id_global[17] = { 0 }; @@ -41,7 +41,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, switch (uMsg) { case WM_INITDIALOG: { - SetWindowPos(hwndDlg, 0, firstrun_rect.left, firstrun_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); + SetWindowPos(hwndDlg, nullptr, firstrun_rect.left, firstrun_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); SetWindowText(hwndDlg, TranslateT("Set own key")); EnableWindow(GetDlgItem(hwndDlg, IDC_COPY_PUBKEY), 0); @@ -124,7 +124,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, break; stop = p; p2 = out.find("/", p) - 1; - wchar_t *key_len = mir_wstrdup(toUTF16(out.substr(p, p2 - p)).c_str()), *creation_date = NULL, *expire_date = NULL; + wchar_t *key_len = mir_wstrdup(toUTF16(out.substr(p, p2 - p)).c_str()), *creation_date = nullptr, *expire_date = nullptr; p2 += 2; p = out.find(" ", p2); std::wstring key_id = toUTF16(out.substr(p2, p - p2)); @@ -445,7 +445,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, string::size_type s = out.find("Key fingerprint = "); s += mir_strlen("Key fingerprint = "); string::size_type s2 = out.find("\n", s); - wchar_t *str = NULL; + wchar_t *str = nullptr; { string tmp = out.substr(s, s2 - s - 1).c_str(); string::size_type p = 0; @@ -511,7 +511,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, path.append(L"\\new_key"); wfstream f(path.c_str(), std::ios::out); if (!f.is_open()) { - MessageBox(0, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK); break; } f << "Key-Type: RSA"; @@ -655,14 +655,14 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, boost::algorithm::erase_all(out, "\r"); HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, out.size() + 1); if (!hMem) { - MessageBox(0, TranslateT("Failed to allocate memory"), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("Failed to allocate memory"), TranslateT("Error"), MB_OK); break; } char *szKey = (char*)GlobalLock(hMem); if (!szKey) { wchar_t msg[64]; mir_snwprintf(msg, TranslateT("Failed to lock memory with error %d"), GetLastError()); - MessageBox(0, msg, TranslateT("Error"), MB_OK); + MessageBox(nullptr, msg, TranslateT("Error"), MB_OK); GlobalFree(hMem); } memcpy(szKey, out.c_str(), out.size()); @@ -673,7 +673,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, GlobalFree(hMem); wchar_t msg[64]; mir_snwprintf(msg, TranslateT("Failed write to clipboard with error %d"), GetLastError()); - MessageBox(0, msg, TranslateT("Error"), MB_OK); + MessageBox(nullptr, msg, TranslateT("Error"), MB_OK); } CloseClipboard(); } @@ -774,7 +774,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg, UINT uMsg, WPARAM wParam, GetWindowRect(hwndDlg, &firstrun_rect); db_set_dw(NULL, szGPGModuleName, "FirstrunWindowX", firstrun_rect.left); db_set_dw(NULL, szGPGModuleName, "FirstrunWindowY", firstrun_rect.top); - hwndFirstRun = NULL; + hwndFirstRun = nullptr; break; } @@ -806,7 +806,7 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, if (boost::filesystem::exists(gpg_lang_path.c_str())) lang_exists = true; if (gpg_exists && !lang_exists) - MessageBox(0, TranslateT("GPG binary found in Miranda folder, but English locale does not exist.\nIt's highly recommended that you place \\gnupg.nls\\en@quot.mo in GnuPG folder under Miranda root.\nWithout this file you may experience many problems with GPG output on non-English systems\nand plugin may completely not work.\nYou have been warned."), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("GPG binary found in Miranda folder, but English locale does not exist.\nIt's highly recommended that you place \\gnupg.nls\\en@quot.mo in GnuPG folder under Miranda root.\nWithout this file you may experience many problems with GPG output on non-English systems\nand plugin may completely not work.\nYou have been warned."), TranslateT("Warning"), MB_OK); } DWORD len = MAX_PATH; bool bad_version = false; @@ -816,7 +816,7 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", (SHGetValueW(HKEY_CURRENT_USER, L"Software\\GNU\\GnuPG", L"gpgProgram", 0, (void*)path.c_str(), &len) == ERROR_SUCCESS) ? path.c_str() : L""); if (tmp[0]) if (!boost::filesystem::exists((wchar_t*)tmp)) - MessageBox(0, TranslateT("Wrong GPG binary location found in system.\nPlease choose another location"), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("Wrong GPG binary location found in system.\nPlease choose another location"), TranslateT("Warning"), MB_OK); } else tmp = mir_wstrdup(path.c_str()); @@ -844,10 +844,10 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, } else { bad_version = false; - MessageBox(0, TranslateT("This is not GnuPG binary!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("This is not GnuPG binary!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Error"), MB_OK); } if (bad_version) - MessageBox(0, TranslateT("Unsupported GnuPG version found, use at you own risk!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("Unsupported GnuPG version found, use at you own risk!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK); } } { @@ -858,7 +858,7 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, mir_wstrcat(mir_path, L"\\gpg"); if (_waccess(mir_path, 0) != -1) { tmp = mir_wstrdup(mir_path); - MessageBox(0, TranslateT("\"GPG\" directory found in Miranda root.\nAssuming it's GPG home directory.\nGPG home directory set."), TranslateT("Info"), MB_OK); + MessageBox(nullptr, TranslateT("\"GPG\" directory found in Miranda root.\nAssuming it's GPG home directory.\nGPG home directory set."), TranslateT("Info"), MB_OK); } else { wstring path_ = _wgetenv(L"APPDATA"); @@ -870,7 +870,7 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, } //TODO: additional check for write access if (gpg_exists && lang_exists && !bad_version) - MessageBox(0, TranslateT("Your GPG version is supported. The language file was found.\nGPG plugin should work fine.\nPress OK to continue."), TranslateT("Info"), MB_OK); + MessageBox(nullptr, TranslateT("Your GPG version is supported. The language file was found.\nGPG plugin should work fine.\nPress OK to continue."), TranslateT("Info"), MB_OK); EnableWindow(GetDlgItem(hwndDlg, IDC_AUTO_EXCHANGE), TRUE); return TRUE; } @@ -915,12 +915,12 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, PathToAbsoluteW(L"\\", mir_path); SetCurrentDirectoryW(mir_path); if (!boost::filesystem::exists(tmp)) { - MessageBox(0, TranslateT("GPG binary does not exist.\nPlease choose another location"), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("GPG binary does not exist.\nPlease choose another location"), TranslateT("Warning"), MB_OK); break; } } else { - MessageBox(0, TranslateT("Please choose GPG binary location"), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("Please choose GPG binary location"), TranslateT("Warning"), MB_OK); break; } { @@ -947,17 +947,17 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, } else { bad_version = false; - MessageBox(0, TranslateT("This is not GnuPG binary!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("This is not GnuPG binary!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK); } if (bad_version) - MessageBox(0, TranslateT("Unsupported GnuPG version found, use at you own risk!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("Unsupported GnuPG version found, use at you own risk!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK); } db_set_ws(NULL, szGPGModuleName, "szGpgBinPath", tmp); GetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp, _countof(tmp)); while (tmp[mir_wstrlen(tmp) - 1] == '\\') tmp[mir_wstrlen(tmp) - 1] = '\0'; if (!tmp[0]) { - MessageBox(0, TranslateT("Please set keyring's home directory"), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("Please set keyring's home directory"), TranslateT("Warning"), MB_OK); break; } db_set_ws(NULL, szGPGModuleName, "szHomePath", tmp); @@ -985,12 +985,12 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, PathToAbsoluteW(L"\\", mir_path); SetCurrentDirectoryW(mir_path); if (!boost::filesystem::exists(tmp)) { - MessageBox(0, TranslateT("GPG binary does not exist.\nPlease choose another location"), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("GPG binary does not exist.\nPlease choose another location"), TranslateT("Warning"), MB_OK); break; } } else { - MessageBox(0, TranslateT("Please choose GPG binary location"), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("Please choose GPG binary location"), TranslateT("Warning"), MB_OK); break; } { @@ -1017,17 +1017,17 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, } else { bad_version = false; - MessageBox(0, TranslateT("This is not GnuPG binary!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("This is not GnuPG binary!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK); } if (bad_version) - MessageBox(0, TranslateT("Unsupported GnuPG version found, use at you own risk!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("Unsupported GnuPG version found, use at you own risk!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK); } db_set_ws(NULL, szGPGModuleName, "szGpgBinPath", tmp); GetDlgItemText(hwndDlg, IDC_HOME_DIR, tmp, _countof(tmp)); while (tmp[mir_wstrlen(tmp) - 1] == '\\') tmp[mir_wstrlen(tmp) - 1] = '\0'; if (!tmp[0]) { - MessageBox(0, TranslateT("Please set keyring's home directory"), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("Please set keyring's home directory"), TranslateT("Warning"), MB_OK); break; } db_set_ws(NULL, szGPGModuleName, "szHomePath", tmp); @@ -1049,7 +1049,7 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, path.append(L"\\new_key"); wfstream f(path.c_str(), std::ios::out); if (!f.is_open()) { - MessageBox(0, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK); break; } f << "Key-Type: RSA"; @@ -1154,7 +1154,7 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, DestroyWindow(hwndDlg); break; case WM_DESTROY: - hwndSetDirs = NULL; + hwndSetDirs = nullptr; void InitCheck(); InitCheck(); break; @@ -1173,7 +1173,7 @@ static INT_PTR CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wPara { hContact = new_key_hcnt; //new_key_hcnt_mutex.unlock(); - SetWindowPos(hwndDlg, 0, new_key_rect.left, new_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); + SetWindowPos(hwndDlg, nullptr, new_key_rect.left, new_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); wchar_t *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", L""); SetDlgItemText(hwndDlg, IDC_MESSAGE, tmp[0] ? TranslateT("There is existing key for contact, would you like to replace it with new key?") : TranslateT("New public key was received, do you want to import it?")); @@ -1218,7 +1218,7 @@ static INT_PTR CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wPara db_set_dw(NULL, szGPGModuleName, "NewKeyWindowX", new_key_rect.left); db_set_dw(NULL, szGPGModuleName, "NewKeyWindowY", new_key_rect.top); } - hwndNewKey = NULL; + hwndNewKey = nullptr; break; } @@ -1230,7 +1230,7 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara switch (msg) { case WM_INITDIALOG: { - SetWindowPos(hwndDlg, 0, key_gen_rect.left, key_gen_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); + SetWindowPos(hwndDlg, nullptr, key_gen_rect.left, key_gen_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); SetWindowText(hwndDlg, TranslateT("Key Generation dialog")); ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEY_TYPE), L"RSA", 0); @@ -1255,8 +1255,8 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara wchar_t *tmp = (wchar_t*)mir_alloc(sizeof(wchar_t) * 5); GetDlgItemText(hwndDlg, IDC_KEY_TYPE, tmp, 5); if (mir_wstrlen(tmp) < 3) { - mir_free(tmp); tmp = NULL; - MessageBox(0, TranslateT("You must set encryption algorithm first"), TranslateT("Error"), MB_OK); + mir_free(tmp); tmp = nullptr; + MessageBox(nullptr, TranslateT("You must set encryption algorithm first"), TranslateT("Error"), MB_OK); break; } if (tmp) @@ -1266,13 +1266,13 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara int length = _wtoi(tmp); mir_free(tmp); if (length < 1024 || length > 4096) { - MessageBox(0, TranslateT("Key length must be of length from 1024 to 4096 bits"), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("Key length must be of length from 1024 to 4096 bits"), TranslateT("Error"), MB_OK); break; } tmp = (wchar_t*)mir_alloc(sizeof(wchar_t) * 12); GetDlgItemText(hwndDlg, IDC_KEY_EXPIRE_DATE, tmp, 11); if (mir_wstrlen(tmp) != 10 && tmp[0] != '0') { - MessageBox(0, TranslateT("Invalid date"), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("Invalid date"), TranslateT("Error"), MB_OK); mir_free(tmp); break; } @@ -1280,12 +1280,12 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara tmp = (wchar_t*)mir_alloc(sizeof(wchar_t) * 128); GetDlgItemText(hwndDlg, IDC_KEY_REAL_NAME, tmp, 127); if (mir_wstrlen(tmp) < 5) { - MessageBox(0, TranslateT("Name must contain at least 5 characters"), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("Name must contain at least 5 characters"), TranslateT("Error"), MB_OK); mir_free(tmp); break; } else if (wcschr(tmp, '(') || wcschr(tmp, ')')) { - MessageBox(0, TranslateT("Name cannot contain '(' or ')'"), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("Name cannot contain '(' or ')'"), TranslateT("Error"), MB_OK); mir_free(tmp); break; } @@ -1293,7 +1293,7 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara tmp = (wchar_t*)mir_alloc(sizeof(wchar_t) * 128); GetDlgItemText(hwndDlg, IDC_KEY_EMAIL, tmp, 128); if ((mir_wstrlen(tmp)) < 5 || (!wcschr(tmp, '@')) || (!wcschr(tmp, '.'))) { - MessageBox(0, TranslateT("Invalid Email"), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("Invalid Email"), TranslateT("Error"), MB_OK); mir_free(tmp); break; } @@ -1308,7 +1308,7 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara path.append(L"\\new_key"); wfstream f(path.c_str(), std::ios::out); if (!f.is_open()) { - MessageBox(0, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK); break; } f << "Key-Type: "; @@ -1509,7 +1509,7 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara db_set_dw(NULL, szGPGModuleName, "KeyGenWindowX", key_gen_rect.left); db_set_dw(NULL, szGPGModuleName, "KeyGenWindowY", key_gen_rect.top); } - hwndKeyGen = NULL; + hwndKeyGen = nullptr; break; } @@ -1529,7 +1529,7 @@ static INT_PTR CALLBACK DlgProcLoadExistingKey(HWND hwndDlg, UINT msg, WPARAM wP switch (msg) { case WM_INITDIALOG: { - SetWindowPos(hwndDlg, 0, load_existing_key_rect.left, load_existing_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); + SetWindowPos(hwndDlg, nullptr, load_existing_key_rect.left, load_existing_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); col.pszText = L"Key ID"; col.mask = LVCF_TEXT | LVCF_WIDTH; @@ -1704,10 +1704,10 @@ static INT_PTR CALLBACK DlgProcLoadExistingKey(HWND hwndDlg, UINT msg, WPARAM wP mir_free(tmp); } else - MessageBox(NULL, TranslateT("Failed to export public key."), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("Failed to export public key."), TranslateT("Error"), MB_OK); } else - MessageBox(NULL, TranslateT("Failed to export public key."), TranslateT("Error"), MB_OK); + MessageBox(nullptr, TranslateT("Failed to export public key."), TranslateT("Error"), MB_OK); // SetDlgItemText(hPubKeyEdit, IDC_PUBLIC_KEY_EDIT, tmp); } DestroyWindow(hwndDlg); @@ -1740,7 +1740,7 @@ static INT_PTR CALLBACK DlgProcLoadExistingKey(HWND hwndDlg, UINT msg, WPARAM wP GetWindowRect(hwndDlg, &load_existing_key_rect); db_set_dw(NULL, szGPGModuleName, "LoadExistingKeyWindowX", load_existing_key_rect.left); db_set_dw(NULL, szGPGModuleName, "LoadExistingKeyWindowY", load_existing_key_rect.top); - hwndSelectExistingKey = NULL; + hwndSelectExistingKey = nullptr; break; } @@ -1756,7 +1756,7 @@ static INT_PTR CALLBACK DlgProcImportKeyDialog(HWND hwndDlg, UINT msg, WPARAM wP { hContact = new_key_hcnt; new_key_hcnt_mutex.unlock(); - SetWindowPos(hwndDlg, 0, import_key_rect.left, import_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); + SetWindowPos(hwndDlg, nullptr, import_key_rect.left, import_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEYSERVER), L"subkeys.pgp.net", 0); ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEYSERVER), L"keys.gnupg.net", 0); @@ -1783,7 +1783,7 @@ static INT_PTR CALLBACK DlgProcImportKeyDialog(HWND hwndDlg, UINT msg, WPARAM wP params.code = &code; params.result = &result; gpg_launcher(params); - MessageBoxA(0, out.c_str(), "GPG output", MB_OK); + MessageBoxA(nullptr, out.c_str(), "GPG output", MB_OK); } break; } @@ -1807,8 +1807,8 @@ extern HINSTANCE hInst; void ShowFirstRunDialog() { - if (hwndFirstRun == NULL) { - hwndFirstRun = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIRST_RUN), NULL, DlgProcFirstRun); + if (hwndFirstRun == nullptr) { + hwndFirstRun = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIRST_RUN), nullptr, DlgProcFirstRun); } SetForegroundWindow(hwndFirstRun); } @@ -1816,37 +1816,37 @@ void ShowFirstRunDialog() void ShowSetDirsDialog() { - if (hwndSetDirs == NULL) { - hwndSetDirs = CreateDialog(hInst, MAKEINTRESOURCE(IDD_BIN_PATH), NULL, DlgProcGpgBinOpts); + if (hwndSetDirs == nullptr) { + hwndSetDirs = CreateDialog(hInst, MAKEINTRESOURCE(IDD_BIN_PATH), nullptr, DlgProcGpgBinOpts); } SetForegroundWindow(hwndSetDirs); } void ShowNewKeyDialog() { - hwndNewKey = CreateDialog(hInst, MAKEINTRESOURCE(IDD_NEW_KEY), NULL, DlgProcNewKeyDialog); + hwndNewKey = CreateDialog(hInst, MAKEINTRESOURCE(IDD_NEW_KEY), nullptr, DlgProcNewKeyDialog); SetForegroundWindow(hwndNewKey); } void ShowKeyGenDialog() { - if (hwndKeyGen == NULL) { - hwndKeyGen = CreateDialog(hInst, MAKEINTRESOURCE(IDD_KEY_GEN), NULL, DlgProcKeyGenDialog); + if (hwndKeyGen == nullptr) { + hwndKeyGen = CreateDialog(hInst, MAKEINTRESOURCE(IDD_KEY_GEN), nullptr, DlgProcKeyGenDialog); } SetForegroundWindow(hwndKeyGen); } void ShowSelectExistingKeyDialog() { - if (hwndSelectExistingKey == NULL) { - hwndSelectExistingKey = CreateDialog(hInst, MAKEINTRESOURCE(IDD_LOAD_EXISTING_KEY), NULL, DlgProcLoadExistingKey); + if (hwndSelectExistingKey == nullptr) { + hwndSelectExistingKey = CreateDialog(hInst, MAKEINTRESOURCE(IDD_LOAD_EXISTING_KEY), nullptr, DlgProcLoadExistingKey); } SetForegroundWindow(hwndSelectExistingKey); } void ShowImportKeyDialog() { - CreateDialog(hInst, MAKEINTRESOURCE(IDD_IMPORT_KEY), NULL, DlgProcImportKeyDialog); + CreateDialog(hInst, MAKEINTRESOURCE(IDD_IMPORT_KEY), nullptr, DlgProcImportKeyDialog); } void FirstRun() @@ -1899,7 +1899,7 @@ void InitCheck() mir_wstrncat(buf, temp_access ? TranslateT("Temp dir write access granted (this is good).\n") : TranslateT("Temp dir has no write access (plugin should work, but may have some problems, file transfers will not work)."), _countof(buf) - mir_wstrlen(buf)); if (!gpg_valid) mir_wstrncat(buf, TranslateT("\nGPG will be disabled until you solve these problems"), _countof(buf) - mir_wstrlen(buf)); - MessageBox(0, buf, TranslateT("GPG plugin problems"), MB_OK); + MessageBox(nullptr, buf, TranslateT("GPG plugin problems"), MB_OK); } if (!gpg_valid) return; @@ -1951,7 +1951,7 @@ void InitCheck() question += Translate(" for account "); question += toUTF8(accounts[i]->tszAccountName); question += Translate(" deleted from GPG secret keyring.\nDo you want to set another key?"); - if (MessageBoxA(0, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES) + if (MessageBoxA(nullptr, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES) ShowFirstRunDialog(); } p2 = p; @@ -1989,7 +1989,7 @@ void InitCheck() question += Translate(" for account "); question += toUTF8(accounts[i]->tszAccountName); question += Translate(" expired and will not work.\nDo you want to set another key?"); - if (MessageBoxA(0, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES) + if (MessageBoxA(nullptr, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES) ShowFirstRunDialog(); } mir_free(expire_date); @@ -2005,13 +2005,13 @@ void InitCheck() char *key = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); if (!db_get_b(NULL, szGPGModuleName, "FirstRun", 1) && (!keyid[0] || !key[0])) { question = Translate("You didn't set a private key.\nWould you like to set it now?"); - if (MessageBoxA(0, question.c_str(), Translate("Own private key warning"), MB_YESNO) == IDYES) + if (MessageBoxA(nullptr, question.c_str(), Translate("Own private key warning"), MB_YESNO) == IDYES) ShowFirstRunDialog(); } if ((p = out.find(keyid)) == string::npos) { question += keyid; question += Translate(" deleted from GPG secret keyring.\nDo you want to set another key?"); - if (MessageBoxA(0, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES) + if (MessageBoxA(nullptr, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES) ShowFirstRunDialog(); } p2 = p; @@ -2047,7 +2047,7 @@ void InitCheck() if (expired) { question += keyid; question += Translate(" expired and will not work.\nDo you want to set another key?"); - if (MessageBoxA(0, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES) + if (MessageBoxA(nullptr, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES) ShowFirstRunDialog(); } mir_free(expire_date); @@ -2071,7 +2071,7 @@ void InitCheck() Proto_EnumAccounts(&count, &accounts); ICQ_CUSTOMCAP cap; cap.cbSize = sizeof(ICQ_CUSTOMCAP); - cap.hIcon = 0; + cap.hIcon = nullptr; strncpy(cap.name, "GPG Key AutoExchange", MAX_CAPNAME); strncpy(cap.caps, "GPGAutoExchange", sizeof(cap.caps)); @@ -2085,7 +2085,7 @@ void InitCheck() Proto_EnumAccounts(&count, &accounts); ICQ_CUSTOMCAP cap; cap.cbSize = sizeof(ICQ_CUSTOMCAP); - cap.hIcon = 0; + cap.hIcon = nullptr; strncpy(cap.name, "GPG Encrypted FileTransfers", MAX_CAPNAME); strncpy(cap.caps, "GPGFileTransfer", sizeof(cap.caps)); @@ -2101,7 +2101,7 @@ void ImportKey() new_key_hcnt_mutex.unlock(); bool for_all_sub = false; if (db_mc_isMeta(hContact)) { - if (MessageBox(0, TranslateT("Do you want to load key for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES) + if (MessageBox(nullptr, TranslateT("Do you want to load key for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES) for_all_sub = true; if (for_all_sub) { @@ -2159,7 +2159,7 @@ void ImportKey() for (int i = 0; i < count; i++) { MCONTACT hcnt = db_mc_getSub(hContact, i); if (hcnt) { - char *tmp = NULL; + char *tmp = nullptr; string::size_type s = output.find("gpg: key ") + mir_strlen("gpg: key "); string::size_type s2 = output.find(":", s); db_set_s(hcnt, szGPGModuleName, "KeyID", output.substr(s, s2 - s).c_str()); @@ -2182,7 +2182,7 @@ void ImportKey() if (s != string::npos && s2 != string::npos) { tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s - (uncommon ? 1 : 0)).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s - (uncommon ? 1 : 0)).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(hcnt, szGPGModuleName, "KeyMainName", tmp); mir_free(tmp); } @@ -2196,7 +2196,7 @@ void ImportKey() if (output[s] == ')') { tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(hcnt, szGPGModuleName, "KeyComment", tmp); mir_free(tmp); s += 3; @@ -2204,7 +2204,7 @@ void ImportKey() if (s != string::npos && s2 != string::npos) { tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(hcnt, szGPGModuleName, "KeyMainEmail", tmp); mir_free(tmp); } @@ -2212,7 +2212,7 @@ void ImportKey() else { tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s2, s - s2).c_str()); mir_free(tmp); } @@ -2222,7 +2222,7 @@ void ImportKey() } } else { - char *tmp = NULL; + char *tmp = nullptr; string::size_type s = output.find("gpg: key ") + mir_strlen("gpg: key "); string::size_type s2 = output.find(":", s); db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyID", output.substr(s, s2 - s).c_str()); @@ -2245,7 +2245,7 @@ void ImportKey() if (s != string::npos && s2 != string::npos) { tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s - (uncommon ? 1 : 0)).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s - (uncommon ? 1 : 0)).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainName", tmp); mir_free(tmp); } @@ -2258,7 +2258,7 @@ void ImportKey() if (output[s] == ')') { tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyComment", tmp); mir_free(tmp); s += 3; @@ -2266,7 +2266,7 @@ void ImportKey() if (s != string::npos && s2 != string::npos) { tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", tmp); mir_free(tmp); } @@ -2274,7 +2274,7 @@ void ImportKey() else { tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2, s - s2).c_str()); mir_free(tmp); } @@ -2283,7 +2283,7 @@ void ImportKey() } } else { - char *tmp = NULL; + char *tmp = nullptr; string::size_type s = output.find("gpg: key ") + mir_strlen("gpg: key "); string::size_type s2 = output.find(":", s); db_set_s(hContact, szGPGModuleName, "KeyID", output.substr(s, s2 - s).c_str()); @@ -2306,7 +2306,7 @@ void ImportKey() if (s != string::npos && s2 != string::npos) { tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s - (uncommon ? 1 : 0)).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s - (uncommon ? 1 : 0)).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(hContact, szGPGModuleName, "KeyMainName", tmp); mir_free(tmp); } @@ -2319,7 +2319,7 @@ void ImportKey() if (output[s] == ')') { tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(hContact, szGPGModuleName, "KeyComment", tmp); mir_free(tmp); s += 3; @@ -2327,7 +2327,7 @@ void ImportKey() if (s != string::npos && s2 != string::npos) { tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s).length() + 1)); mir_strcpy(tmp, output.substr(s, s2 - s).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(hContact, szGPGModuleName, "KeyMainEmail", tmp); mir_free(tmp); } @@ -2335,7 +2335,7 @@ void ImportKey() else { tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2, s - s2).length() + 1)); mir_strcpy(tmp, output.substr(s2, s - s2).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2, s - s2).c_str()); mir_free(tmp); } @@ -2343,6 +2343,6 @@ void ImportKey() db_unset(hContact, szGPGModuleName, "bAlwatsTrust"); } - MessageBox(0, toUTF16(output).c_str(), L"", MB_OK); + MessageBox(nullptr, toUTF16(output).c_str(), L"", MB_OK); boost::filesystem::remove(tmp2); } diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index 2469cd3692..62d33a8839 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -37,7 +37,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR { if (bDebugLog) debuglog << std::string(time_str() + ": info: received encrypted message from: " + toUTF8(pcli->pfnGetContactDisplayName(hContact, 0)) + " with turned off encryption"); - if (MessageBox(0, TranslateT("We received encrypted message from contact with encryption turned off.\nDo you want to turn on encryption for this contact?"), TranslateT("Warning"), MB_YESNO) == IDYES) + if (MessageBox(nullptr, TranslateT("We received encrypted message from contact with encryption turned off.\nDo you want to turn on encryption for this contact?"), TranslateT("Warning"), MB_YESNO) == IDYES) { if (!isContactHaveKey(hContact)) { @@ -59,7 +59,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR setClistIcon(hContact); } } - else if (MessageBox(0, TranslateT("Do you want to try to decrypt encrypted message?"), TranslateT("Warning"), MB_YESNO) == IDNO) + else if (MessageBox(nullptr, TranslateT("Do you want to try to decrypt encrypted message?"), TranslateT("Warning"), MB_YESNO) == IDNO) { HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return; @@ -112,7 +112,7 @@ void RecvMsgSvc_func(MCONTACT hContact, std::wstring str, char *msg, DWORD, DWOR cmd.push_back(L"--batch"); { char *inkeyid = UniGetContactSettingUtf(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, szGPGModuleName, "InKeyID", ""); - wchar_t *pass = NULL; + wchar_t *pass = nullptr; if (inkeyid[0]) { string dbsetting = "szKey_"; dbsetting += inkeyid; @@ -486,7 +486,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) return 1; } */ { - char *tmp = NULL; + char *tmp = nullptr; s1 = output.find("gpg: key ") + mir_strlen("gpg: key "); s2 = output.find(":", s1); db_set_s(ccs->hContact, szGPGModuleName, "KeyID", output.substr(s1, s2 - s1).c_str()); @@ -505,7 +505,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) s2 = output.find("<", s1); tmp = (char*)mir_alloc(output.substr(s1, s2 - s1 - 1).length() + 1); mir_strcpy(tmp, output.substr(s1, s2 - s1 - 1).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(ccs->hContact, szGPGModuleName, "KeyMainName", tmp); mir_free(tmp); if ((s1 = output.find(")", s2)) == string::npos) @@ -517,14 +517,14 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) { tmp = (char*)mir_alloc(output.substr(s2, s1 - s2).length() + 1); mir_strcpy(tmp, output.substr(s2, s1 - s2).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(ccs->hContact, szGPGModuleName, "KeyComment", tmp); mir_free(tmp); s1 += 3; s2 = output.find(">", s1); tmp = (char*)mir_alloc(output.substr(s1, s2 - s1).length() + 1); mir_strcpy(tmp, output.substr(s1, s2 - s1).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(ccs->hContact, szGPGModuleName, "KeyMainEmail", tmp); mir_free(tmp); } @@ -532,7 +532,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) { tmp = (char*)mir_alloc(output.substr(s2, s1 - s2).length() + 1); mir_strcpy(tmp, output.substr(s2, s1 - s2).c_str()); - mir_utf8decode(tmp, 0); + mir_utf8decode(tmp, nullptr); db_set_s(ccs->hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2, s1 - s2).c_str()); mir_free(tmp); } @@ -746,7 +746,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) if (out.find("There is no assurance this key belongs to the named user") != string::npos) { out.clear(); - if (MessageBox(0, TranslateT("We're trying to encrypt with untrusted key. Do you want to trust this key permanently?"), TranslateT("Warning"), MB_YESNO) == IDYES) { + if (MessageBox(nullptr, TranslateT("We're trying to encrypt with untrusted key. Do you want to trust this key permanently?"), TranslateT("Warning"), MB_YESNO) == IDYES) { db_set_b(hContact, szGPGModuleName, "bAlwaysTrust", 1); std::vector<std::wstring> tmp; tmp.push_back(L"--trust-model"); @@ -779,7 +779,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags) // return; // } if (out.find("usage: ") != string::npos) { - MessageBox(0, TranslateT("Something is wrong, GPG does not understand us, aborting encryption."), TranslateT("Warning"), MB_OK); + MessageBox(nullptr, TranslateT("Something is wrong, GPG does not understand us, aborting encryption."), TranslateT("Warning"), MB_OK); //mir_free(msg); ProtoChainSend(hContact, PSS_MESSAGE, flags, (LPARAM)msg); if(!bDebugLog) @@ -1003,13 +1003,13 @@ int HookSendMsg(WPARAM w, LPARAM l) static INT_PTR CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM) { - char *inkeyid = NULL; + char *inkeyid = nullptr; switch (msg) { case WM_INITDIALOG: inkeyid = UniGetContactSettingUtf(new_key_hcnt, szGPGModuleName, "InKeyID", ""); new_key_hcnt_mutex.unlock(); - SetWindowPos(hwndDlg, 0, key_password_rect.left, key_password_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); + SetWindowPos(hwndDlg, nullptr, key_password_rect.left, key_password_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); { string questionstr = "Please enter password for key with ID: "; @@ -1073,5 +1073,5 @@ static INT_PTR CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam void ShowLoadKeyPasswordWindow() { extern HINSTANCE hInst; - DialogBox(hInst, MAKEINTRESOURCE(IDD_KEY_PASSWD), NULL, DlgProcKeyPassword); + DialogBox(hInst, MAKEINTRESOURCE(IDD_KEY_PASSWD), nullptr, DlgProcKeyPassword); } diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index e6fd670fbe..35824da12b 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -70,8 +70,8 @@ int GpgOptInit(WPARAM wParam, LPARAM) map<int, MCONTACT> user_data;
int item_num = 0;
-HWND hwndList_p = NULL;
-HWND hwndCurKey_p = NULL;
+HWND hwndList_p = nullptr;
+HWND hwndCurKey_p = nullptr;
void ShowLoadPublicKeyDialog();
static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -222,7 +222,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L }
}
if (!keep)
- if (MessageBox(0, TranslateT("This key is not used by any contact. Do you want to remove it from public keyring?"), TranslateT("Key info"), MB_YESNO) == IDYES) {
+ if (MessageBox(nullptr, TranslateT("This key is not used by any contact. Do you want to remove it from public keyring?"), TranslateT("Key info"), MB_YESNO) == IDYES) {
std::vector<wstring> cmd;
string output;
DWORD exitcode;
@@ -246,13 +246,13 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L break;
}
if (output.find("--delete-secret-keys") != string::npos)
- MessageBox(0, TranslateT("we have secret key for this public key, do not removing from GPG keyring"), TranslateT("info"), MB_OK);
+ MessageBox(nullptr, TranslateT("we have secret key for this public key, do not removing from GPG keyring"), TranslateT("info"), MB_OK);
else
- MessageBox(0, TranslateT("Key removed from GPG keyring"), TranslateT("info"), MB_OK);
+ MessageBox(nullptr, TranslateT("Key removed from GPG keyring"), TranslateT("info"), MB_OK);
}
mir_free(tmp);
if (ismetacontact) {
- if (MessageBox(0, TranslateT("Do you want to remove key from entire metacontact (all subcontacts)?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES) {
+ if (MessageBox(nullptr, TranslateT("Do you want to remove key from entire metacontact (all subcontacts)?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES) {
MCONTACT hcnt = NULL;
int count = db_mc_getSubCount(meta);
for (int i = 0; i < count; i++) {
@@ -326,14 +326,14 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L boost::algorithm::replace_all(str, "\n", "\r\n");
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, str.size() + 1);
if (!hMem) {
- MessageBox(0, TranslateT("Failed to allocate memory"), TranslateT("Error"), MB_OK);
+ MessageBox(nullptr, TranslateT("Failed to allocate memory"), TranslateT("Error"), MB_OK);
break;
}
szKey = (char*)GlobalLock(hMem);
if (!szKey) {
wchar_t msg[64];
mir_snwprintf(msg, TranslateT("Failed to lock memory with error %d"), GetLastError());
- MessageBox(0, msg, TranslateT("Error"), MB_OK);
+ MessageBox(nullptr, msg, TranslateT("Error"), MB_OK);
GlobalFree(hMem);
}
else {
@@ -346,7 +346,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L GlobalFree(hMem);
wchar_t msg[64];
mir_snwprintf(msg, TranslateT("Failed write to clipboard with error %d"), GetLastError());
- MessageBox(0, msg, TranslateT("Error"), MB_OK);
+ MessageBox(nullptr, msg, TranslateT("Error"), MB_OK);
}
CloseClipboard();
}
@@ -354,7 +354,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT uMsg, WPARAM wParam, L else {
wchar_t msg[64];
mir_snwprintf(msg, TranslateT("Failed to open clipboard with error %d"), GetLastError());
- MessageBox(0, msg, TranslateT("Error"), MB_OK);
+ MessageBox(nullptr, msg, TranslateT("Error"), MB_OK);
}
break;
@@ -456,7 +456,7 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, }
else {
bad_version = false;
- MessageBox(0, TranslateT("This is not GnuPG binary!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK);
+ MessageBox(nullptr, TranslateT("This is not GnuPG binary!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), TranslateT("Warning"), MB_OK);
}
/* if(bad_version) //looks like working fine with gpg2
MessageBox(0, TranslateT("Unsupported GnuPG version found, use at you own risk!\nIt is recommended that you use GnuPG v1.x.x with this plugin."), L"Warning", MB_OK); */
@@ -627,7 +627,7 @@ static INT_PTR CALLBACK DlgProcGpgAdvOpts(HWND hwndDlg, UINT msg, WPARAM wParam, return FALSE;
}
-HWND hPubKeyEdit = NULL;
+HWND hPubKeyEdit = nullptr;
static LRESULT CALLBACK editctrl_ctrl_a(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
@@ -649,7 +649,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa case WM_INITDIALOG:
{
hContact = user_data[1];
- SetWindowPos(hwndDlg, 0, load_key_rect.left, load_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
+ SetWindowPos(hwndDlg, nullptr, load_key_rect.left, load_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PUBLIC_KEY_EDIT), editctrl_ctrl_a);
MCONTACT hcnt = db_mc_tryMeta(hContact);
TranslateDialogDefault(hwndDlg);
@@ -671,7 +671,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa if (hcnt) {
wchar_t *tmp = UniGetContactSettingUtf(hcnt, szGPGModuleName, "GPGPubKey", L"");
wstring str = tmp;
- mir_free(tmp); tmp = NULL;
+ mir_free(tmp); tmp = nullptr;
if (!str.empty()) {
wstring::size_type p = 0, stop = 0;
for (;;) {
@@ -760,14 +760,14 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa mir_wstrcpy(end, L"-----END PGP PRIVATE KEY BLOCK-----");
}
else {
- MessageBox(0, TranslateT("This is not public or private key"), L"INFO", MB_OK);
+ MessageBox(nullptr, TranslateT("This is not public or private key"), L"INFO", MB_OK);
break;
}
ws2 += mir_wstrlen(end);
bool allsubcontacts = false;
{
if (db_mc_isMeta(hContact)) {
- if (MessageBox(0, TranslateT("Do you want to load key for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES) {
+ if (MessageBox(nullptr, TranslateT("Do you want to load key for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES) {
allsubcontacts = true;
int count = db_mc_getSubCount(hContact);
for (int i = 0; i < count; i++) {
@@ -837,7 +837,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa }
{
if (output.find("already in secret keyring") != string::npos) {
- MessageBox(0, TranslateT("Key already in secret keyring."), TranslateT("Info"), MB_OK);
+ MessageBox(nullptr, TranslateT("Key already in secret keyring."), TranslateT("Info"), MB_OK);
boost::filesystem::remove(tmp2);
break;
}
@@ -846,7 +846,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa {
char *tmp3 = (char*)mir_alloc((output.substr(s, s2 - s).length() + 1)*sizeof(char));
mir_strcpy(tmp3, output.substr(s, s2 - s).c_str());
- mir_utf8decode(tmp3, 0);
+ mir_utf8decode(tmp3, nullptr);
{
if (db_mc_isMeta(hContact)) {
if (allsubcontacts) {
@@ -889,7 +889,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa {
char *tmp3 = (char*)mir_alloc(sizeof(char)*(output.substr(s, s2 - s - (uncommon ? 1 : 0)).length() + 1));
mir_strcpy(tmp3, output.substr(s, s2 - s - (uncommon ? 1 : 0)).c_str());
- mir_utf8decode(tmp3, 0);
+ mir_utf8decode(tmp3, nullptr);
if (hContact) {
if (db_mc_isMeta(hContact)) {
if (allsubcontacts) {
@@ -919,7 +919,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa if (output[s] == ')') {
char *tmp3 = (char*)mir_alloc((output.substr(s2, s - s2).length() + 1)*sizeof(char));
mir_strcpy(tmp3, output.substr(s2, s - s2).c_str());
- mir_utf8decode(tmp3, 0);
+ mir_utf8decode(tmp3, nullptr);
if (hContact) {
if (db_mc_isMeta(hContact)) {
if (allsubcontacts) {
@@ -939,7 +939,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa s2 = output.find(">", s);
tmp3 = (char*)mir_alloc((output.substr(s, s2 - s).length() + 1) * sizeof(char));
mir_strcpy(tmp3, output.substr(s, s2 - s).c_str());
- mir_utf8decode(tmp3, 0);
+ mir_utf8decode(tmp3, nullptr);
if (hContact) {
if (db_mc_isMeta(hContact)) {
if (allsubcontacts) {
@@ -963,7 +963,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa else {
char *tmp3 = (char*)mir_alloc(output.substr(s2, s - s2).length() + 1);
mir_strcpy(tmp3, output.substr(s2, s - s2).c_str());
- mir_utf8decode(tmp3, 0);
+ mir_utf8decode(tmp3, nullptr);
if (hContact) {
if (db_mc_isMeta(hContact)) {
if (allsubcontacts) {
@@ -1021,7 +1021,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa }
}
tmp = mir_wstrdup(toUTF16(output).c_str());
- MessageBox(0, tmp, L"", MB_OK);
+ MessageBox(nullptr, tmp, L"", MB_OK);
mir_free(tmp);
boost::filesystem::remove(tmp2);
}
@@ -1066,7 +1066,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa wfstream f(tmp, std::ios::in | std::ios::ate | std::ios::binary);
delete[] tmp;
if (!f.is_open()) {
- MessageBox(0, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK);
+ MessageBox(nullptr, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK);
break;
}
if (f.is_open()) {
@@ -1092,7 +1092,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa ws1 = key_buf.find(L"-----BEGIN PGP PRIVATE KEY BLOCK-----");
}
if (ws2 == wstring::npos || ws1 == wstring::npos) {
- MessageBox(0, TranslateT("There is no public or private key."), TranslateT("Info"), MB_OK);
+ MessageBox(nullptr, TranslateT("There is no public or private key."), TranslateT("Info"), MB_OK);
break;
}
ws2 += mir_wstrlen(L"-----END PGP PUBLIC KEY BLOCK-----");
@@ -1139,5 +1139,5 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg, UINT uMsg, WPARAM wPa void ShowLoadPublicKeyDialog()
{
- DialogBox(hInst, MAKEINTRESOURCE(IDD_LOAD_PUBLIC_KEY), NULL, DlgProcLoadPublicKey);
+ DialogBox(hInst, MAKEINTRESOURCE(IDD_LOAD_PUBLIC_KEY), nullptr, DlgProcLoadPublicKey);
}
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index ac9cbdbba8..76f9a4282c 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -27,7 +27,7 @@ extern HGENMENU hToggleEncryption, hSendKey; wchar_t* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule, const char* szSetting, wchar_t* szDef) { DBVARIANT dbv = { DBVT_DELETED }; - wchar_t* szRes = NULL; + wchar_t* szRes = nullptr; if (db_get_ws(hContact, szModule, szSetting, &dbv)) return mir_wstrdup(szDef); else if (dbv.pszVal) @@ -42,7 +42,7 @@ wchar_t* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModu char* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule, const char* szSetting, char* szDef) { DBVARIANT dbv = { DBVT_DELETED }; - char* szRes = NULL; + char* szRes = nullptr; if (db_get_s(hContact, szModule, szSetting, &dbv)) return mir_strdup(szDef); else if (dbv.pszVal) @@ -103,13 +103,13 @@ wchar_t *GetFilePath(wchar_t *WindowTittle, wchar_t *szExt, wchar_t *szExtDesc, if (!save_file) { if (!GetOpenFileName(&ofn)) { delete[] str; - return NULL; + return nullptr; } } else { if (!GetSaveFileName(&ofn)) { delete[] str; - return NULL; + return nullptr; } } return str; @@ -117,16 +117,16 @@ wchar_t *GetFilePath(wchar_t *WindowTittle, wchar_t *szExt, wchar_t *szExtDesc, void GetFolderPath(wchar_t *WindowTittle, char*) { - BROWSEINFO pbi = { 0 }; + BROWSEINFO pbi = {}; pbi.lpszTitle = WindowTittle; pbi.ulFlags = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_SHAREABLE; LPITEMIDLIST pidl = SHBrowseForFolder(&pbi); - if (pidl != 0) { + if (pidl != nullptr) { wchar_t path[MAX_PATH]; if (SHGetPathFromIDList(pidl, path)) { db_set_ws(NULL, szGPGModuleName, "szHomePath", path); } - IMalloc * imalloc = 0; + IMalloc * imalloc = nullptr; if (SUCCEEDED(SHGetMalloc(&imalloc))) { imalloc->Free(pidl); imalloc->Release(); @@ -194,7 +194,7 @@ INT_PTR ToggleEncryption(WPARAM w, LPARAM) BYTE enc; if (db_mc_isMeta(hContact)) { enc = db_get_b(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0); - if (MessageBox(0, TranslateT("Do you want to toggle encryption for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES) { + if (MessageBox(nullptr, TranslateT("Do you want to toggle encryption for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES) { int count = db_mc_getSubCount(hContact); for (int i = 0; i < count; i++) { MCONTACT hcnt = db_mc_getSub(hContact, i); @@ -273,11 +273,11 @@ int onProtoAck(WPARAM, LPARAM l) case ACKRESULT_SUCCESS: if (ack->hProcess) { PROTOFILETRANSFERSTATUS *f = (PROTOFILETRANSFERSTATUS*)ack->hProcess; - if (f == NULL) + if (f == nullptr) break; if ((f->flags & PFTS_SENDING) != PFTS_SENDING) { - wchar_t *filename = NULL; + wchar_t *filename = nullptr; if (f->flags & PFTS_UNICODE) { if (f->tszCurrentFile && f->tszCurrentFile[0]) filename = mir_wstrdup(f->tszCurrentFile); @@ -312,14 +312,14 @@ int onProtoAck(WPARAM, LPARAM l) wstring::size_type p1 = file.rfind(L".gpg"); file.erase(p1, mir_wstrlen(L".gpg")); if (boost::filesystem::exists(file)) { - if (MessageBox(0, TranslateT("Target file exists, do you want to replace it?"), TranslateT("Warning"), MB_YESNO) == IDNO) + if (MessageBox(nullptr, TranslateT("Target file exists, do you want to replace it?"), TranslateT("Warning"), MB_YESNO) == IDNO) return 0; } cmd.push_back(file); boost::filesystem::remove(file); extern wchar_t *password; { // password - wchar_t *pass = NULL; + wchar_t *pass = nullptr; char *keyid = UniGetContactSettingUtf(ack->hContact, szGPGModuleName, "KeyID", ""); if (mir_strlen(keyid) > 0) { string dbsetting = "szKey_"; @@ -463,20 +463,20 @@ std::wstring encrypt_file(MCONTACT hContact, wchar_t *filename) params.result = &result; delete[] file_out; if (!gpg_launcher(params, boost::posix_time::minutes(3))) - return 0; + return nullptr; if (out.find("There is no assurance this key belongs to the named user") != string::npos) { out.clear(); - if (MessageBox(0, TranslateT("We're trying to encrypt with untrusted key. Do you want to trust this key permanently?"), TranslateT("Warning"), MB_YESNO) == IDYES) { + if (MessageBox(nullptr, TranslateT("We're trying to encrypt with untrusted key. Do you want to trust this key permanently?"), TranslateT("Warning"), MB_YESNO) == IDYES) { db_set_b(hcnt, szGPGModuleName, "bAlwaysTrust", 1); std::vector<std::wstring> tmp; tmp.push_back(L"--trust-model"); tmp.push_back(L"always"); cmd.insert(cmd.begin(), tmp.begin(), tmp.end()); if (!gpg_launcher(params, boost::posix_time::minutes(3))) - return 0; + return nullptr; } else - return 0; + return nullptr; } return path_out; } @@ -526,11 +526,11 @@ INT_PTR onSendFile(WPARAM w, LPARAM l) mir_free(jid); } if (supported_proto && !cap_found) { - if (MessageBox(0, TranslateT("Capability to decrypt file not found on other side.\nRecipient may be unable to decrypt file(s).\nDo you want to encrypt file(s) anyway?"), TranslateT("File transfer warning"), MB_YESNO) == IDNO) + if (MessageBox(nullptr, TranslateT("Capability to decrypt file not found on other side.\nRecipient may be unable to decrypt file(s).\nDo you want to encrypt file(s) anyway?"), TranslateT("File transfer warning"), MB_YESNO) == IDNO) return Proto_ChainSend(w, ccs); } if (!supported_proto) { - if (MessageBox(0, TranslateT("Unable to check encryption support on other side.\nRecipient may be unable to decrypt file(s).\nCurrently capability check supported only for ICQ and Jabber protocols.\nIt will work for any other proto if Miranda with New_GPG is used on other side.\nDo you want to encrypt file(s) anyway?"), TranslateT("File transfer warning"), MB_YESNO) == IDNO) + if (MessageBox(nullptr, TranslateT("Unable to check encryption support on other side.\nRecipient may be unable to decrypt file(s).\nCurrently capability check supported only for ICQ and Jabber protocols.\nIt will work for any other proto if Miranda with New_GPG is used on other side.\nDo you want to encrypt file(s) anyway?"), TranslateT("File transfer warning"), MB_YESNO) == IDNO) return Proto_ChainSend(w, ccs); } HistoryLog(ccs->hContact, db_event(Translate("encrypting file for transfer"), 0, 0, DBEF_SENT)); @@ -576,7 +576,7 @@ void HistoryLog(MCONTACT hContact, db_event evt) Event.eventType = evt.eventType; Event.flags = evt.flags; if (!evt.timestamp) - Event.timestamp = (DWORD)time(NULL); + Event.timestamp = (DWORD)time(nullptr); else Event.timestamp = evt.timestamp; Event.cbBlob = (DWORD)mir_strlen((char*)evt.pBlob) + 1; @@ -651,7 +651,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void*) break; } - if (str == NULL) + if (str == nullptr) continue; // TODO: make following block more readable @@ -1002,7 +1002,7 @@ bool isGPGKeyExist() } bool isGPGValid() { - wchar_t *tmp = NULL; + wchar_t *tmp = nullptr; bool gpg_exists = false, is_valid = true; tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", L""); boost::filesystem::path p(tmp); @@ -1011,7 +1011,7 @@ bool isGPGValid() gpg_exists = true; else { mir_free(tmp); - tmp = NULL; + tmp = nullptr; wchar_t *path = (wchar_t*)mir_alloc(sizeof(wchar_t)*MAX_PATH); wchar_t *mir_path = (wchar_t*)mir_alloc(MAX_PATH * sizeof(wchar_t)); PathToAbsoluteW(L"\\", mir_path); @@ -1023,7 +1023,7 @@ bool isGPGValid() mir_wstrcpy(gpg_path, tmp); mir_wstrcat(gpg_path, L"\\GnuPG\\gpg.exe"); mir_free(tmp); - tmp = NULL; + tmp = nullptr; p = boost::filesystem::path(gpg_path); if (boost::filesystem::exists(p) && boost::filesystem::is_regular_file(p)) { gpg_exists = true; @@ -1037,7 +1037,7 @@ bool isGPGValid() if (gpg_exists) { db_set_ws(NULL, szGPGModuleName, "szGpgBinPath", tmp); mir_free(tmp); - tmp = NULL; + tmp = nullptr; string out; DWORD code; std::vector<wstring> cmd; @@ -1056,7 +1056,7 @@ bool isGPGValid() } if (tmp) { mir_free(tmp); - tmp = NULL; + tmp = nullptr; } /* if(!gpg_exists) { @@ -1126,7 +1126,7 @@ unsigned __stdcall sttFakeAck(void *param) WaitForSingleObject(tParam->hEvent, INFINITE); Sleep(100); - if (tParam->msg == NULL) + if (tParam->msg == nullptr) SendBroadcast(tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)tParam->id, 0); else SendBroadcast(tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)tParam->id, LPARAM(tParam->msg)); @@ -1140,9 +1140,9 @@ unsigned __stdcall sttFakeAck(void *param) int returnNoError(MCONTACT hContact) { - HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + HANDLE hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr); unsigned int tID; - CloseHandle((HANDLE)_beginthreadex(NULL, 0, sttFakeAck, new TFakeAckParams(hEvent, hContact, 777, 0), 0, &tID)); + CloseHandle((HANDLE)_beginthreadex(nullptr, 0, sttFakeAck, new TFakeAckParams(hEvent, hContact, 777, nullptr), 0, &tID)); SetEvent(hEvent); return 777; } @@ -1416,7 +1416,7 @@ void ExportGpGKeysFunc(int type) mir_snwprintf(msg, TranslateT("We have successfully exported all private keys.")); else if (!type) mir_snwprintf(msg, TranslateT("We have successfully exported %d public keys."), exported_keys); - MessageBox(NULL, msg, TranslateT("Keys export result"), MB_OK); + MessageBox(nullptr, msg, TranslateT("Keys export result"), MB_OK); } INT_PTR ExportGpGKeys(WPARAM, LPARAM) @@ -1640,7 +1640,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) processed_keys++; { if (output.find("already in secret keyring") != string::npos) { - MessageBox(0, TranslateT("Key already in secret keyring."), TranslateT("Info"), MB_OK); + MessageBox(nullptr, TranslateT("Key already in secret keyring."), TranslateT("Info"), MB_OK); boost::filesystem::remove(path); break; } @@ -1649,7 +1649,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) string::size_type s2 = output.find(":", s); tmp2 = (char*)mir_alloc((output.substr(s, s2 - s).length() + 1) * sizeof(char)); mir_strcpy(tmp2, output.substr(s, s2 - s).c_str()); - mir_utf8decode(tmp2, 0); + mir_utf8decode(tmp2, nullptr); db_set_s(hContact, szGPGModuleName, "KeyID", tmp2); mir_free(tmp2); s = output.find("“", s2); @@ -1666,7 +1666,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) if (s2 != string::npos) { tmp2 = (char*)mir_alloc((output.substr(s, s2 - s - 1).length() + 1) * sizeof(char)); mir_strcpy(tmp2, output.substr(s, s2 - s - 1).c_str()); - mir_utf8decode(tmp2, 0); + mir_utf8decode(tmp2, nullptr); if (hContact) { db_set_s(hContact, szGPGModuleName, "KeyMainName", output.substr(s, s2 - s - 1).c_str()); } @@ -1679,7 +1679,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) if (output[s] == ')') { tmp2 = (char*)mir_alloc((output.substr(s2, s - s2).length() + 1) * sizeof(char)); mir_strcpy(tmp2, output.substr(s2, s - s2).c_str()); - mir_utf8decode(tmp2, 0); + mir_utf8decode(tmp2, nullptr); if (hContact) db_set_s(hContact, szGPGModuleName, "KeyComment", output.substr(s2, s - s2).c_str()); mir_free(tmp2); @@ -1687,7 +1687,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) s2 = output.find(">", s); tmp2 = (char*)mir_alloc((output.substr(s, s2 - s).length() + 1) * sizeof(char)); mir_strcpy(tmp2, output.substr(s, s2 - s).c_str()); - mir_utf8decode(tmp2, 0); + mir_utf8decode(tmp2, nullptr); if (hContact) db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s, s2 - s).c_str()); mir_free(tmp2); @@ -1695,7 +1695,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) else { tmp2 = (char*)mir_alloc((output.substr(s2, s - s2).length() + 1) * sizeof(char)); mir_strcpy(tmp2, output.substr(s2, s - s2).c_str()); - mir_utf8decode(tmp2, 0); + mir_utf8decode(tmp2, nullptr); if (hContact) db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2, s - s2).c_str()); mir_free(tmp2); @@ -1752,7 +1752,7 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM) mir_snwprintf(msg, TranslateT("We have successfully processed %d public keys and some private keys."), processed_keys); else mir_snwprintf(msg, TranslateT("We have successfully processed %d public keys."), processed_keys); - MessageBox(NULL, msg, TranslateT("Keys import result"), MB_OK); + MessageBox(nullptr, msg, TranslateT("Keys import result"), MB_OK); return 0; } @@ -1839,7 +1839,7 @@ static INT_PTR CALLBACK DlgProcEncryptedFileMsgBox(HWND hwndDlg, UINT msg, WPARA void ShowEncryptedFileMsgBox() { extern HINSTANCE hInst; - DialogBox(hInst, MAKEINTRESOURCE(IDD_ENCRYPTED_FILE_MSG_BOX), NULL, DlgProcEncryptedFileMsgBox); + DialogBox(hInst, MAKEINTRESOURCE(IDD_ENCRYPTED_FILE_MSG_BOX), nullptr, DlgProcEncryptedFileMsgBox); } static INT_PTR CALLBACK DlgProcExportKeys(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM) @@ -1877,7 +1877,7 @@ static INT_PTR CALLBACK DlgProcExportKeys(HWND hwndDlg, UINT msg, WPARAM wParam, void ShowExportKeysDlg() { - DialogBox(hInst, MAKEINTRESOURCE(IDD_EXPORT_TYPE), NULL, DlgProcExportKeys); + DialogBox(hInst, MAKEINTRESOURCE(IDD_EXPORT_TYPE), nullptr, DlgProcExportKeys); } static INT_PTR CALLBACK DlgProcChangePasswd(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM) @@ -1975,8 +1975,8 @@ static INT_PTR CALLBACK DlgProcChangePasswd(HWND hwndDlg, UINT msg, WPARAM wPara void ShowChangePasswdDlg() { extern HINSTANCE hInst; - HWND hwndPaaswdDlg = NULL; - hwndPaaswdDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_CHANGE_PASSWD), NULL, DlgProcChangePasswd); + HWND hwndPaaswdDlg = nullptr; + hwndPaaswdDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_CHANGE_PASSWD), nullptr, DlgProcChangePasswd); SetForegroundWindow(hwndPaaswdDlg); } |