summaryrefslogtreecommitdiff
path: root/plugins/PasteIt
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/PasteIt
parent591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff)
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/PasteIt')
-rw-r--r--plugins/PasteIt/src/Options.cpp10
-rw-r--r--plugins/PasteIt/src/PasteIt.cpp30
-rw-r--r--plugins/PasteIt/src/PasteToWeb.cpp56
-rw-r--r--plugins/PasteIt/src/PasteToWeb1.cpp6
-rw-r--r--plugins/PasteIt/src/PasteToWeb2.cpp30
5 files changed, 66 insertions, 66 deletions
diff --git a/plugins/PasteIt/src/Options.cpp b/plugins/PasteIt/src/Options.cpp
index 4bbb0bcea7..97d93e3d98 100644
--- a/plugins/PasteIt/src/Options.cpp
+++ b/plugins/PasteIt/src/Options.cpp
@@ -66,7 +66,7 @@ Options::~Options()
{
for (int i = 0; i < PasteToWeb::pages; ++i) {
delete webOptions[i];
- webOptions[i] = NULL;
+ webOptions[i] = nullptr;
}
}
@@ -139,7 +139,7 @@ public:
{
for (int i = 0; i < PasteToWeb::pages; ++i) {
delete webOptions[i];
- webOptions[i] = NULL;
+ webOptions[i] = nullptr;
}
}
@@ -228,7 +228,7 @@ INT_PTR CALLBACK Options::DlgProcOptsPages(HWND hwndDlg, UINT msg, WPARAM wParam
HWND btnhwnd = GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN);
int btSize = Button_GetTextLength(btnhwnd);
if (btSize > 20) {
- SetWindowPos(btnhwnd, NULL, 0, 0, 115, 34, SWP_NOZORDER | SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOREDRAW);
+ SetWindowPos(btnhwnd, nullptr, 0, 0, 115, 34, SWP_NOZORDER | SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOREDRAW);
}
for (int i = 0; i < PasteToWeb::pages; ++i) {
@@ -613,7 +613,7 @@ unsigned int Options::GetCodepageCB(HWND hwndCB, bool errorReport, unsigned int
if (selCpIdx < 0) {
wchar_t text[128];
ComboBox_GetText(hwndCB, text, 128);
- wchar_t * stopOn = NULL;
+ wchar_t * stopOn = nullptr;
long cp = wcstol(text, &stopOn, 10);
if (errorReport && (stopOn == text || *stopOn != '\0' || cp < 0 || cp > 0xffff)) {
MessageBox(GetParent(hwndCB), TranslateT("You've entered invalid codepage. Select codepage from combo box or enter correct number."), TranslateT("Invalid codepage"), MB_OK | MB_ICONERROR);
@@ -780,7 +780,7 @@ void Options::Load()
webOptions[i]->formats.clear();
int k = 0;
wchar_t *id = forms.pwszVal;
- wchar_t *name = NULL;
+ wchar_t *name = nullptr;
while (forms.pwszVal[k]) {
if (forms.pwszVal[k] == L'=') {
forms.pwszVal[k] = 0;
diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp
index 7f9dec64c7..96de6b8a51 100644
--- a/plugins/PasteIt/src/PasteIt.cpp
+++ b/plugins/PasteIt/src/PasteIt.cpp
@@ -28,7 +28,7 @@ HANDLE hPrebuildContactMenu;
HGENMENU hContactMenu;
HGENMENU hWebPageMenus[PasteToWeb::pages];
HANDLE hOptionsInit;
-HANDLE hWindowEvent = NULL;
+HANDLE hWindowEvent = nullptr;
HINSTANCE hInst;
#define FROM_CLIPBOARD 10
@@ -78,7 +78,7 @@ std::wstring GetFile()
stzFilePath[1] = 0;
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = 0;
+ ofn.hwndOwner = nullptr;
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = stzFilePath;
@@ -111,9 +111,9 @@ void PasteIt(MCONTACT hContact, int mode)
}
else return;
- if (pasteToWeb->szFileLink[0] == 0 && pasteToWeb->error != NULL)
+ if (pasteToWeb->szFileLink[0] == 0 && pasteToWeb->error != nullptr)
{
- MessageBox(NULL, pasteToWeb->error, TranslateT("Error"), MB_OK | MB_ICONERROR);
+ MessageBox(nullptr, pasteToWeb->error, TranslateT("Error"), MB_OK | MB_ICONERROR);
}
else if (hContact != NULL && pasteToWeb->szFileLink[0] != 0)
{
@@ -129,7 +129,7 @@ void PasteIt(MCONTACT hContact, int mode)
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_SENT;
dbei.szModule = szProto;
- dbei.timestamp = (DWORD)time(NULL);
+ dbei.timestamp = (DWORD)time(nullptr);
dbei.cbBlob = (DWORD)mir_strlen(pasteToWeb->szFileLink) + 1;
dbei.pBlob = (PBYTE)pasteToWeb->szFileLink;
db_event_add(hContact, &dbei);
@@ -232,7 +232,7 @@ int TabsrmmButtonPressed(WPARAM hContact, LPARAM lParam)
RECT rc;
GetWindowRect(hwndBtn, &rc);
SetForegroundWindow(cbc->hwndFrom);
- int selected = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, cbc->hwndFrom, 0);
+ int selected = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, cbc->hwndFrom, nullptr);
if (selected != 0)
{
if (selected >= DEF_PAGES_START)
@@ -328,7 +328,7 @@ void DefWebPageChanged()
{
for (int i = 0; i < PasteToWeb::pages; i++) {
int flags = (Options::instance->defWeb == i) ? CMIF_CHECKED : 0;
- Menu_ModifyItem(hWebPageMenus[i], NULL, INVALID_HANDLE_VALUE, flags);
+ Menu_ModifyItem(hWebPageMenus[i], nullptr, INVALID_HANDLE_VALUE, flags);
}
}
@@ -343,7 +343,7 @@ void InitTabsrmmButton()
btn.pwszTooltip = TranslateT("Paste It");
Srmm_AddButton(&btn);
- if (hTabsrmmButtonPressed != NULL)
+ if (hTabsrmmButtonPressed != nullptr)
UnhookEvent(hTabsrmmButtonPressed);
hTabsrmmButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed);
@@ -406,7 +406,7 @@ extern "C" int __declspec(dllexport) Load(void)
Options::instance->Load();
hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
hOptionsInit = HookEvent(ME_OPT_INITIALISE, Options::InitOptions);
- hTabsrmmButtonPressed = NULL;
+ hTabsrmmButtonPressed = nullptr;
CreateServiceFunction(MS_PASTEIT_CONTACTMENU, ContactMenuService);
contactWindows = new std::map<MCONTACT, HWND>();
return 0;
@@ -417,22 +417,22 @@ extern "C" int __declspec(dllexport) Unload(void)
UnhookEvent(hModulesLoaded);
UnhookEvent(hPrebuildContactMenu);
UnhookEvent(hOptionsInit);
- if (hWindowEvent != NULL)
+ if (hWindowEvent != nullptr)
UnhookEvent(hWindowEvent);
Netlib_CloseHandle(g_hNetlibUser);
- if (hTabsrmmButtonPressed != NULL)
+ if (hTabsrmmButtonPressed != nullptr)
UnhookEvent(hTabsrmmButtonPressed);
for (int i = 0; i < PasteToWeb::pages; ++i)
- if (pasteToWebs[i] != NULL) {
+ if (pasteToWebs[i] != nullptr) {
delete pasteToWebs[i];
- pasteToWebs[i] = NULL;
+ pasteToWebs[i] = nullptr;
}
- if (Options::instance != NULL) {
+ if (Options::instance != nullptr) {
delete Options::instance;
- Options::instance = NULL;
+ Options::instance = nullptr;
}
delete contactWindows;
diff --git a/plugins/PasteIt/src/PasteToWeb.cpp b/plugins/PasteIt/src/PasteToWeb.cpp
index 1307a2fabd..09786c738a 100644
--- a/plugins/PasteIt/src/PasteToWeb.cpp
+++ b/plugins/PasteIt/src/PasteToWeb.cpp
@@ -121,11 +121,11 @@ void RecodeDlg(HWND hwndDlg)
}
else
{
- cbLen = MultiByteToWideChar(cp, 0, fromFileData->content, fromFileData->contentLen, NULL, 0);
+ cbLen = MultiByteToWideChar(cp, 0, fromFileData->content, fromFileData->contentLen, nullptr, 0);
}
fromFileData->contentW = (wchar_t*)mir_alloc(sizeof(wchar_t)*(cbLen + 1));
- if (fromFileData->contentW != NULL)
+ if (fromFileData->contentW != nullptr)
{
if (cp == 1200)
{
@@ -263,13 +263,13 @@ INT_PTR CALLBACK DlgProcFromFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
void PasteToWeb::FromClipboard()
{
szFileLink[0] = 0;
- error = NULL;
+ error = nullptr;
std::wstring str;
BOOL isFile = 0;
- if (OpenClipboard(NULL))
+ if (OpenClipboard(nullptr))
{
HANDLE obj = GetClipboardData(CF_UNICODETEXT);
- if (obj != NULL)
+ if (obj != nullptr)
{
LPCWSTR wStr = (LPCWSTR)GlobalLock(obj);
str.append(wStr, wStr + mir_wstrlen(wStr));
@@ -278,7 +278,7 @@ void PasteToWeb::FromClipboard()
// to fix this I check if CF_TEXT contains more characters,
// if this is true, this mean that CF_UNICODETEXT is invalid.
obj = GetClipboardData(CF_TEXT);
- if (obj != NULL)
+ if (obj != nullptr)
{
LPCSTR cStr = (LPCSTR)GlobalLock(obj);
if (mir_strlen(cStr) > str.length())
@@ -294,7 +294,7 @@ void PasteToWeb::FromClipboard()
else
{
obj = GetClipboardData(CF_TEXT);
- if (obj != NULL)
+ if (obj != nullptr)
{
LPCSTR cStr = (LPCSTR)GlobalLock(obj);
LPWSTR wStr = mir_a2u_cp(cStr, CP_ACP);
@@ -305,7 +305,7 @@ void PasteToWeb::FromClipboard()
else
{
obj = GetClipboardData(CF_HDROP);
- if (obj != NULL)
+ if (obj != nullptr)
{
LPDROPFILES df = (LPDROPFILES)GlobalLock(obj);
isFile = 1;
@@ -356,13 +356,13 @@ void PasteToWeb::FromClipboard()
FromClipboardData data;
data.content = str;
data.page = pageIndex;
- if (Options::instance->confDlg && DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_FROM_CLIPBOARD), 0, DlgProcFromClipboard, (LPARAM)&data) != IDC_BTN_OK)
+ if (Options::instance->confDlg && DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_FROM_CLIPBOARD), nullptr, DlgProcFromClipboard, (LPARAM)&data) != IDC_BTN_OK)
return;
SendToServer(str, L"", data.format);
}
}
- else if (error == NULL)
+ else if (error == nullptr)
{
error = TranslateT("Cannot get data from clipboard");
}
@@ -370,10 +370,10 @@ void PasteToWeb::FromClipboard()
void PasteToWeb::FromFile(std::wstring file)
{
- error = NULL;
+ error = nullptr;
szFileLink[0] = 0;
- HANDLE hFile = CreateFile(file.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
- FromFileData fromFileData = { 0 };
+ HANDLE hFile = CreateFile(file.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
+ FromFileData fromFileData = {};
fromFileData.fileName = &file;
if (hFile != INVALID_HANDLE_VALUE)
{
@@ -385,7 +385,7 @@ void PasteToWeb::FromFile(std::wstring file)
if (fileSize.QuadPart > 512000LL)
{
mir_snwprintf(bufErr, TranslateT("File size is %d KB, do you really want to paste such a large file?"), fileSize.LowPart / 1024);
- if (MessageBox(NULL, bufErr, TranslateT("Are You sure?"), MB_YESNO | MB_ICONQUESTION) != IDYES)
+ if (MessageBox(nullptr, bufErr, TranslateT("Are You sure?"), MB_YESNO | MB_ICONQUESTION) != IDYES)
{
CloseHandle(hFile);
return;
@@ -394,10 +394,10 @@ void PasteToWeb::FromFile(std::wstring file)
DWORD readed;
fromFileData.contentLen = fileSize.LowPart;
fromFileData.content = (char*)mir_alloc(fromFileData.contentLen);
- if (!ReadFile(hFile, fromFileData.content, fromFileData.contentLen, &readed, NULL))
+ if (!ReadFile(hFile, fromFileData.content, fromFileData.contentLen, &readed, nullptr))
{
mir_free(fromFileData.content);
- fromFileData.content = NULL;
+ fromFileData.content = nullptr;
fromFileData.contentLen = 0;
mir_snwprintf(bufErr, TranslateT("Cannot read file '%s'"), file.c_str());
error = bufErr;
@@ -417,7 +417,7 @@ void PasteToWeb::FromFile(std::wstring file)
error = bufErr;
}
- if (fromFileData.content != NULL)
+ if (fromFileData.content != nullptr)
{
int cbLen = 0;
bool isDefTranslation = true;
@@ -425,7 +425,7 @@ void PasteToWeb::FromFile(std::wstring file)
{
isDefTranslation = false;
fromFileData.codepage = CP_UTF8;
- cbLen = MultiByteToWideChar(fromFileData.codepage, MB_ERR_INVALID_CHARS, fromFileData.content, fromFileData.contentLen, NULL, 0);
+ cbLen = MultiByteToWideChar(fromFileData.codepage, MB_ERR_INVALID_CHARS, fromFileData.content, fromFileData.contentLen, nullptr, 0);
if (cbLen == 0)
{
int errorN = GetLastError();
@@ -446,14 +446,14 @@ void PasteToWeb::FromFile(std::wstring file)
}
else
{
- cbLen = MultiByteToWideChar(fromFileData.codepage, 0, fromFileData.content, fromFileData.contentLen, NULL, 0);
+ cbLen = MultiByteToWideChar(fromFileData.codepage, 0, fromFileData.content, fromFileData.contentLen, nullptr, 0);
}
}
if (cbLen > 0)
{
fromFileData.contentW = (wchar_t*)mir_alloc(sizeof(wchar_t)*(cbLen + 1));
- if (fromFileData.contentW != NULL)
+ if (fromFileData.contentW != nullptr)
{
if (fromFileData.codepage == 1200)
{
@@ -473,7 +473,7 @@ void PasteToWeb::FromFile(std::wstring file)
fromFileData.contentW[cbLen] = 0;
fromFileData.page = pageIndex;
- if (!Options::instance->confDlg || DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_FROM_FILE), 0, DlgProcFromFile, (LPARAM)&fromFileData) == IDC_BTN_OK)
+ if (!Options::instance->confDlg || DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_FROM_FILE), nullptr, DlgProcFromFile, (LPARAM)&fromFileData) == IDC_BTN_OK)
{
std::wstring fileName;
std::wstring::size_type pos1 = file.find_last_of(L'\\');
@@ -502,13 +502,13 @@ extern HNETLIBUSER g_hNetlibUser;
wchar_t* PasteToWeb::SendToWeb(char* url, std::map<std::string, std::string>& headers, std::wstring content)
{
- wchar_t* resCont = NULL;
- int cbLen = WideCharToMultiByte(CP_UTF8, 0, content.c_str(), -1, NULL, 0, NULL, NULL);
+ wchar_t* resCont = nullptr;
+ int cbLen = WideCharToMultiByte(CP_UTF8, 0, content.c_str(), -1, nullptr, 0, nullptr, nullptr);
char* contentBytes = (char*)mir_alloc(cbLen);
- if (contentBytes == NULL)
+ if (contentBytes == nullptr)
return resCont;
- WideCharToMultiByte(CP_UTF8, 0, content.c_str(), -1, contentBytes, cbLen, NULL, NULL);
+ WideCharToMultiByte(CP_UTF8, 0, content.c_str(), -1, contentBytes, cbLen, nullptr, nullptr);
--cbLen;
int nHeaders = 0;
@@ -543,14 +543,14 @@ wchar_t* PasteToWeb::SendToWeb(char* url, std::map<std::string, std::string>& he
nlhr.headersCount = nHeaders;
NETLIBHTTPREQUEST* nlhrReply = Netlib_HttpTransaction(g_hNetlibUser, &nlhr);
- if (nlhrReply != NULL)
+ if (nlhrReply != nullptr)
{
if (nlhrReply->resultCode == 200)
{
- int resLen = MultiByteToWideChar(CP_UTF8, 0, nlhrReply->pData, nlhrReply->dataLength, NULL, 0);
+ int resLen = MultiByteToWideChar(CP_UTF8, 0, nlhrReply->pData, nlhrReply->dataLength, nullptr, 0);
++resLen;
resCont = (wchar_t*)mir_alloc(resLen * sizeof(wchar_t));
- if (resCont != NULL)
+ if (resCont != nullptr)
{
resLen = MultiByteToWideChar(CP_UTF8, 0, nlhrReply->pData, nlhrReply->dataLength, resCont, resLen);
resCont[resLen] = 0;
diff --git a/plugins/PasteIt/src/PasteToWeb1.cpp b/plugins/PasteIt/src/PasteToWeb1.cpp
index a7de2c10fc..b725c12f52 100644
--- a/plugins/PasteIt/src/PasteToWeb1.cpp
+++ b/plugins/PasteIt/src/PasteToWeb1.cpp
@@ -300,7 +300,7 @@ void PasteToWeb1::SendToServer(std::wstring str, std::wstring fileName, std::wst
}
wchar_t* resCont = SendToWeb("http://pastebin.com/api/api_post.php", headers, content);
- if (resCont != NULL)
+ if (resCont != nullptr)
{
if (memcmp(L"Bad API request, ", resCont, 17 * sizeof(wchar_t)) == 0)
{
@@ -332,12 +332,12 @@ std::wstring PasteToWeb1::GetUserKey(std::wstring& user, std::wstring& password)
content += L"&api_dev_key=dcba056bf9cc71729fdad76dddcb0dcd";
wchar_t* resCont = SendToWeb("http://pastebin.com/api/api_login.php", headers, content);
std::wstring toRet;
- if (resCont != NULL)
+ if (resCont != nullptr)
{
if (memcmp(L"Bad API request, ", resCont, 17 * sizeof(wchar_t)) == 0)
{
mir_snwprintf(bufErr, TranslateT("Error during getting user key from web page: %s"), resCont + 17);
- MessageBox(NULL, bufErr, TranslateT("Error"), MB_OK | MB_ICONERROR);
+ MessageBox(nullptr, bufErr, TranslateT("Error"), MB_OK | MB_ICONERROR);
}
else
toRet = resCont;
diff --git a/plugins/PasteIt/src/PasteToWeb2.cpp b/plugins/PasteIt/src/PasteToWeb2.cpp
index a5843149a3..17b3ca116f 100644
--- a/plugins/PasteIt/src/PasteToWeb2.cpp
+++ b/plugins/PasteIt/src/PasteToWeb2.cpp
@@ -103,27 +103,27 @@ void PasteToWeb2::SendToServer(std::wstring str, std::wstring fileName, std::wst
wchar_t* resCont = SendToWeb("http://wklej.to/api/", headers, content);
error = TranslateT("Error during sending text to web page");
- if (resCont != NULL)
+ if (resCont != nullptr)
{
- HXML hXml = xmlParseString(resCont, NULL, L"methodResponse");
- if (hXml != NULL)
+ HXML hXml = xmlParseString(resCont, nullptr, L"methodResponse");
+ if (hXml != nullptr)
{
HXML node = xmlGetChildByPath(hXml, L"params/param/value/array/data/value/int", 0);
- if (node != NULL && !mir_wstrcmp(xmlGetText(node), L"1"))
+ if (node != nullptr && !mir_wstrcmp(xmlGetText(node), L"1"))
{
node = xmlGetChildByPath(hXml, L"params/param/value/array/data", 0);
- if (node != NULL)
+ if (node != nullptr)
{
node = xmlGetNthChild(node, L"value", 1);
- if (node != NULL)
+ if (node != nullptr)
{
node = xmlGetChildByPath(node, L"string", 0);
- if (node != NULL)
+ if (node != nullptr)
{
char* s = mir_u2a_cp(xmlGetText(node), CP_ACP);
mir_strncpy(szFileLink, s, _countof(szFileLink));
mir_free(s);
- error = NULL;
+ error = nullptr;
}
}
}
@@ -143,22 +143,22 @@ std::list<PasteFormat> PasteToWeb2::GetFormats()
std::wstring content = L"<?xml version=\"1.0\"?>\r\n<methodCall><methodName>types</methodName></methodCall>";
wchar_t* resCont = SendToWeb("http://wklej.to/api/", headers, content);
- if (resCont != NULL)
+ if (resCont != nullptr)
{
- HXML hXml = xmlParseString(resCont, NULL, L"methodResponse");
- if (hXml != NULL)
+ HXML hXml = xmlParseString(resCont, nullptr, L"methodResponse");
+ if (hXml != nullptr)
{
HXML node = xmlGetChildByPath(hXml, L"params/param/value/array/data/value/int", 0);
- if (node != NULL && !mir_wstrcmp(xmlGetText(node), L"1"))
+ if (node != nullptr && !mir_wstrcmp(xmlGetText(node), L"1"))
{
node = xmlGetChildByPath(hXml, L"params/param/value/array/data", 0);
- if (node != NULL)
+ if (node != nullptr)
{
node = xmlGetNthChild(node, L"value", 1);
- if (node != NULL)
+ if (node != nullptr)
{
node = xmlGetChildByPath(node, L"string", 0);
- if (node != NULL)
+ if (node != nullptr)
{
std::wstring str = xmlGetText(node);
std::wstring::size_type pos = str.find(L'\n');