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/GmailNotifier | |
parent | 591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff) |
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/GmailNotifier')
-rw-r--r-- | plugins/GmailNotifier/src/check.cpp | 22 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/main.cpp | 4 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/notify.cpp | 24 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/options.cpp | 10 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/utility.cpp | 12 |
5 files changed, 36 insertions, 36 deletions
diff --git a/plugins/GmailNotifier/src/check.cpp b/plugins/GmailNotifier/src/check.cpp index fbcdc83e57..e2d5af213a 100644 --- a/plugins/GmailNotifier/src/check.cpp +++ b/plugins/GmailNotifier/src/check.cpp @@ -7,7 +7,7 @@ void CheckMailInbox(Account *curAcc) {
// internet connection handle
// internet request handle
- HINTERNET hHTTPConnection = 0, hHTTPRequest = 0;
+ HINTERNET hHTTPConnection = nullptr, hHTTPRequest = nullptr;
DBVARIANT dbv;
static char *contentType = "Content-Type: application/x-www-form-urlencoded";
@@ -49,8 +49,8 @@ void CheckMailInbox(Account *curAcc) hHTTPConnection = InternetConnectA(hHTTPOpen,
"www.google.com",
INTERNET_DEFAULT_HTTPS_PORT,
- NULL,
- NULL,
+ nullptr,
+ nullptr,
INTERNET_SERVICE_HTTP,
0,
0);
@@ -62,7 +62,7 @@ void CheckMailInbox(Account *curAcc) mir_strcpy(str, "/a/");
mir_strcat(str, curAcc->hosted);
mir_strcat(str, "/LoginAction");
- hHTTPRequest = HttpOpenRequestA(hHTTPConnection, "POST", str, HTTP_VERSIONA, NULL, NULL, INTERNET_FLAG_SECURE, 0);
+ hHTTPRequest = HttpOpenRequestA(hHTTPConnection, "POST", str, HTTP_VERSIONA, nullptr, nullptr, INTERNET_FLAG_SECURE, 0);
mir_strcat(requestBuffer, curAcc->hosted);
mir_strcat(requestBuffer, "%2Ffeed%2Fatom&service=mail&userName=");
mir_strcat(requestBuffer, curAcc->name);
@@ -77,10 +77,10 @@ void CheckMailInbox(Account *curAcc) InternetCloseHandle(hHTTPConnection);
InternetCloseHandle(hHTTPRequest);
- hHTTPRequest = 0;
+ hHTTPRequest = nullptr;
}
- hHTTPConnection = InternetConnectA(hHTTPOpen, "mail.google.com", INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ hHTTPConnection = InternetConnectA(hHTTPOpen, "mail.google.com", INTERNET_DEFAULT_HTTPS_PORT, nullptr, nullptr, INTERNET_SERVICE_HTTP, 0, 0);
if (!hHTTPConnection) {
mir_strcat(curAcc->results.content, Translate("Can't reach server!"));
goto error_handle;
@@ -92,10 +92,10 @@ void CheckMailInbox(Account *curAcc) }
else mir_strcpy(str, "/mail/feed/atom");
- hHTTPRequest = HttpOpenRequest(hHTTPConnection, L"GET", _A2T(str), NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, 0);
+ hHTTPRequest = HttpOpenRequest(hHTTPConnection, L"GET", _A2T(str), nullptr, nullptr, nullptr, INTERNET_FLAG_SECURE | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, 0);
InternetSetOption(hHTTPRequest, INTERNET_OPTION_USERNAME, _A2T(curAcc->name), (int)mir_strlen(curAcc->name) + 1);
InternetSetOption(hHTTPRequest, INTERNET_OPTION_PASSWORD, _A2T(curAcc->pass), (int)mir_strlen(curAcc->pass) + 1);
- if (!HttpSendRequest(hHTTPRequest, NULL, 0, NULL, 0)) {
+ if (!HttpSendRequest(hHTTPRequest, nullptr, 0, nullptr, 0)) {
mir_strcat(curAcc->results.content, Translate("Can't get RSS feed!"));
goto error_handle;
}
@@ -154,7 +154,7 @@ int ParsePage(char *page, resultLink *prst) int num = 0;
wchar_t str[64];
- prst->next = NULL;
+ prst->next = nullptr;
if (strstr(page, "Unauthorized"))
return -1;
if (!(str_head = strstr(page, "<entry>")))
@@ -180,9 +180,9 @@ int ParsePage(char *page, resultLink *prst) mir_strcpy(prst->content, name);
mir_strcat(prst->content, title);
MultiByteToWideChar(CP_UTF8, 0, prst->content, -1, str, 64);
- WideCharToMultiByte(CP_ACP, 0, str, -1, prst->content, 64, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, str, -1, prst->content, 64, nullptr, nullptr);
num++;
}
- prst->next = NULL;
+ prst->next = nullptr;
return num;
}
diff --git a/plugins/GmailNotifier/src/main.cpp b/plugins/GmailNotifier/src/main.cpp index d2912d2082..451c125205 100644 --- a/plugins/GmailNotifier/src/main.cpp +++ b/plugins/GmailNotifier/src/main.cpp @@ -130,7 +130,7 @@ extern "C" int __declspec(dllexport) Load() for (int i = 0; i < acc_num; i++)
db_set_dw(acc[i].hContact, MODULE_NAME, "Status", ID_STATUS_NONEW);
- hTimer = SetTimer(NULL, 0, opt.circleTime * 60000, TimerProc);
+ hTimer = SetTimer(nullptr, 0, opt.circleTime * 60000, TimerProc);
hMirandaStarted = HookEvent(ME_SYSTEM_MODULESLOADED, OnMirandaStart);
hOptionsInitial = HookEvent(ME_OPT_INITIALISE, OptInit);
@@ -154,7 +154,7 @@ extern "C" int __declspec(dllexport) Load() extern "C" int __declspec(dllexport) Unload(void)
{
if (hTimer)
- KillTimer(NULL, hTimer);
+ KillTimer(nullptr, hTimer);
for (int i = 0; i < acc_num; i++)
DeleteResults(acc[i].results.next);
free(acc);
diff --git a/plugins/GmailNotifier/src/notify.cpp b/plugins/GmailNotifier/src/notify.cpp index 7e90749477..e49421dc5d 100644 --- a/plugins/GmailNotifier/src/notify.cpp +++ b/plugins/GmailNotifier/src/notify.cpp @@ -14,7 +14,7 @@ int OpenBrowser(WPARAM hContact, LPARAM) db_set_w(curAcc->hContact, MODULE_NAME, "Status", ID_STATUS_NONEW);
curAcc->oldResults_num = 0;
DeleteResults(curAcc->results.next);
- curAcc->results.next = NULL;
+ curAcc->results.next = nullptr;
}
mir_forkthread(Login_ThreadFunc, curAcc);
}
@@ -44,7 +44,7 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA case WM_CONTEXTMENU:
PUDeletePopup(hWnd);
- curAcc->popUpHwnd = NULL;
+ curAcc->popUpHwnd = nullptr;
pcli->pfnRemoveEvent(hContact, 1);
}
return DefWindowProc(hWnd, message, wParam, lParam);
@@ -76,7 +76,7 @@ void NotifyUser(Account *curAcc) dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_READ;
dbei.szModule = MODULE_NAME;
- dbei.timestamp = time(NULL);
+ dbei.timestamp = time(nullptr);
resultLink *prst = curAcc->results.next;
for (int i = 0; i < newMails; i++) {
@@ -114,7 +114,7 @@ void NotifyUser(Account *curAcc) ppd.colorBack = opt.popupBgColor;
ppd.colorText = opt.popupTxtColor;
ppd.PluginWindowProc = PopupDlgProc;
- ppd.PluginData = NULL;
+ ppd.PluginData = nullptr;
ppd.iSeconds = opt.popupDuration;
PUDeletePopup(curAcc->popUpHwnd);
PUAddPopup(&ppd);
@@ -124,13 +124,13 @@ void NotifyUser(Account *curAcc) }
curAcc->oldResults_num = curAcc->results_num;
DeleteResults(curAcc->results.next);
- curAcc->results.next = NULL;
+ curAcc->results.next = nullptr;
}
void DeleteResults(resultLink *prst)
{
- if (prst != NULL) {
- if (prst->next != NULL)
+ if (prst != nullptr) {
+ if (prst->next != nullptr)
DeleteResults(prst->next);
free(prst);
}
@@ -138,7 +138,7 @@ void DeleteResults(resultLink *prst) void __cdecl Login_ThreadFunc(void *lpParam)
{
- if (lpParam == NULL)
+ if (lpParam == nullptr)
return;
HANDLE hTempFile;
@@ -165,7 +165,7 @@ void __cdecl Login_ThreadFunc(void *lpParam) GetTempPathA(dwBufSize, buffer);
GetTempFileNameA(buffer, "gmail", 0, szTempName);
- hTempFile = CreateFileA(szTempName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ hTempFile = CreateFileA(szTempName, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
mir_strcpy(buffer, FORMDATA1);
mir_strcat(buffer, curAcc->hosted);
mir_strcat(buffer, FORMDATA2);
@@ -173,12 +173,12 @@ void __cdecl Login_ThreadFunc(void *lpParam) mir_strcat(buffer, FORMDATA3);
mir_strcat(buffer, "<input type=hidden name=userName value=");
mir_strcat(buffer, curAcc->name);
- if ((str_temp = strstr(buffer, "@")) != NULL)
+ if ((str_temp = strstr(buffer, "@")) != nullptr)
*str_temp = '\0';
mir_strcat(buffer, "><input type=hidden name=password value=");
mir_strcat(buffer, curAcc->pass);
mir_strcat(buffer, "></form></body>");
- WriteFile(hTempFile, buffer, (DWORD)mir_strlen(buffer), &dwBytesWritten, NULL);
+ WriteFile(hTempFile, buffer, (DWORD)mir_strlen(buffer), &dwBytesWritten, nullptr);
CloseHandle(hTempFile);
mir_strcat(lpPathBuffer, szTempName);
}
@@ -199,7 +199,7 @@ void __cdecl Login_ThreadFunc(void *lpParam) PROCESS_INFORMATION procInfo;
suInfo.cb = sizeof(suInfo);
suInfo.wShowWindow = SW_MAXIMIZE;
- if (CreateProcessA(NULL, lpPathBuffer, NULL, NULL, FALSE, 0, NULL, NULL, &suInfo, &procInfo))
+ if (CreateProcessA(nullptr, lpPathBuffer, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &suInfo, &procInfo))
CloseHandle(procInfo.hProcess);
if (curAcc->hosted[0]) {
diff --git a/plugins/GmailNotifier/src/options.cpp b/plugins/GmailNotifier/src/options.cpp index aa5be0f448..4978d80214 100644 --- a/plugins/GmailNotifier/src/options.cpp +++ b/plugins/GmailNotifier/src/options.cpp @@ -163,7 +163,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA acc_num--;
SendMessage(hwndCombo, CB_DELETESTRING, curIndex, 0);
DeleteResults(acc[curIndex].results.next);
- acc[curIndex].results.next = NULL;
+ acc[curIndex].results.next = nullptr;
db_delete_contact(acc[curIndex].hContact);
for (int i = curIndex; i < acc_num; i++)
acc[i] = acc[i + 1];
@@ -198,10 +198,10 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
SaveButton(hwndDlg,hwndCombo, curIndex);
- opt.circleTime = GetDlgItemInt(hwndDlg, IDC_CIRCLE, NULL, FALSE);
+ opt.circleTime = GetDlgItemInt(hwndDlg, IDC_CIRCLE, nullptr, FALSE);
if (opt.circleTime > 0) {
- KillTimer(NULL, hTimer);
- hTimer = SetTimer(NULL, 0, opt.circleTime * 60000, TimerProc);
+ KillTimer(nullptr, hTimer);
+ hTimer = SetTimer(nullptr, 0, opt.circleTime * 60000, TimerProc);
db_set_dw(NULL, MODULE_NAME, "circleTime", opt.circleTime);
}
opt.notifierOnTray = IsDlgButtonChecked(hwndDlg, IDC_OPTTRAY);
@@ -209,7 +209,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA db_set_dw(NULL, MODULE_NAME, "notifierOnTray", opt.notifierOnTray);
db_set_dw(NULL, MODULE_NAME, "notifierOnPop", opt.notifierOnPop);
- opt.popupDuration = GetDlgItemInt(hwndDlg, IDC_DURATION, NULL, TRUE);
+ opt.popupDuration = GetDlgItemInt(hwndDlg, IDC_DURATION, nullptr, TRUE);
db_set_dw(NULL, MODULE_NAME, "popupDuration", opt.popupDuration);
opt.popupBgColor = SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, opt.popupBgColor);
diff --git a/plugins/GmailNotifier/src/utility.cpp b/plugins/GmailNotifier/src/utility.cpp index 9aa00d8e79..eb243b8f57 100644 --- a/plugins/GmailNotifier/src/utility.cpp +++ b/plugins/GmailNotifier/src/utility.cpp @@ -32,7 +32,7 @@ void BuildList(void) BOOL GetBrowser(char *str)
{
- HKEY hKey = NULL;
+ HKEY hKey = nullptr;
char *strKey;
char strIE[] = "Applications\\iexplore.exe\\shell\\open\\command";
char strDefault[] = "https\\shell\\open\\command";
@@ -56,11 +56,11 @@ BOOL GetBrowser(char *str) // Data size
DWORD cbData = 0;
// Get the default value
- if (RegQueryValueExA(hKey, NULL, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS && cbData > 0) {
- if (RegQueryValueExA(hKey, NULL, NULL, NULL, (LPBYTE)str, &cbData) == ERROR_SUCCESS) {
- if ((strKey = strstr(str, "%1")) != NULL)
+ if (RegQueryValueExA(hKey, nullptr, nullptr, nullptr, nullptr, &cbData) == ERROR_SUCCESS && cbData > 0) {
+ if (RegQueryValueExA(hKey, nullptr, nullptr, nullptr, (LPBYTE)str, &cbData) == ERROR_SUCCESS) {
+ if ((strKey = strstr(str, "%1")) != nullptr)
*(strKey--) = '\0';
- if ((strKey = strstr(str, "-")) != NULL)
+ if ((strKey = strstr(str, "-")) != nullptr)
*(strKey--) = '\0';
RegCloseKey(hKey);
return TRUE;
@@ -76,5 +76,5 @@ Account* GetAccountByContact(MCONTACT hContact) if (acc[i].hContact == hContact)
return &acc[i];
- return NULL;
+ return nullptr;
}
\ No newline at end of file |