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 /src/core/stdfile | |
parent | 591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff) |
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'src/core/stdfile')
-rw-r--r-- | src/core/stdfile/src/file.cpp | 36 | ||||
-rw-r--r-- | src/core/stdfile/src/fileexistsdlg.cpp | 12 | ||||
-rw-r--r-- | src/core/stdfile/src/fileopts.cpp | 4 | ||||
-rw-r--r-- | src/core/stdfile/src/filerecvdlg.cpp | 18 | ||||
-rw-r--r-- | src/core/stdfile/src/filesenddlg.cpp | 20 | ||||
-rw-r--r-- | src/core/stdfile/src/filexferdlg.cpp | 72 | ||||
-rw-r--r-- | src/core/stdfile/src/ftmanager.cpp | 28 | ||||
-rw-r--r-- | src/core/stdfile/src/main.cpp | 2 |
8 files changed, 96 insertions, 96 deletions
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp index 3d391dd7a7..b2e5b04769 100644 --- a/src/core/stdfile/src/file.cpp +++ b/src/core/stdfile/src/file.cpp @@ -46,7 +46,7 @@ static INT_PTR SendFileCommand(WPARAM hContact, LPARAM) {
struct FileSendData fsd;
fsd.hContact = hContact;
- fsd.ppFiles = NULL;
+ fsd.ppFiles = nullptr;
return (INT_PTR)CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd);
}
@@ -57,13 +57,13 @@ static INT_PTR SendSpecificFiles(WPARAM hContact, LPARAM lParam) char** ppFiles = (char**)lParam;
int count = 0;
- while (ppFiles[count] != NULL)
+ while (ppFiles[count] != nullptr)
count++;
fsd.ppFiles = (const wchar_t**)alloca((count + 1) * sizeof(void*));
for (int i = 0; i < count; i++)
fsd.ppFiles[i] = mir_a2u(ppFiles[i]);
- fsd.ppFiles[count] = NULL;
+ fsd.ppFiles[count] = nullptr;
HWND hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd);
for (int j = 0; j < count; j++)
@@ -141,7 +141,7 @@ int SRFile_GetRegValue(HKEY hKeyBase, const wchar_t *szSubKey, const wchar_t *sz if (RegOpenKeyEx(hKeyBase, szSubKey, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
return 0;
- if (RegQueryValueEx(hKey, szValue, NULL, NULL, (PBYTE)szOutput, &cbOut) != ERROR_SUCCESS) {
+ if (RegQueryValueEx(hKey, szValue, nullptr, nullptr, (PBYTE)szOutput, &cbOut) != ERROR_SUCCESS) {
RegCloseKey(hKey);
return 0;
}
@@ -175,20 +175,20 @@ void GetSensiblyFormattedSize(__int64 size, wchar_t *szOut, int cchOut, int unit // Tripple redirection sucks but is needed to nullify the array pointer
void FreeFilesMatrix(wchar_t ***files)
{
- if (*files == NULL)
+ if (*files == nullptr)
return;
// Free each filename in the pointer array
wchar_t **pFile = *files;
- while (*pFile != NULL) {
+ while (*pFile != nullptr) {
mir_free(*pFile);
- *pFile = NULL;
+ *pFile = nullptr;
pFile++;
}
// Free the array itself
mir_free(*files);
- *files = NULL;
+ *files = nullptr;
}
void FreeProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *fts)
@@ -222,7 +222,7 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS if (dest->totalFiles != src->totalFiles) {
for (int i = 0; i < dest->totalFiles; i++) mir_free(dest->ptszFiles[i]);
mir_free(dest->ptszFiles);
- dest->ptszFiles = NULL;
+ dest->ptszFiles = nullptr;
dest->totalFiles = src->totalFiles;
}
if (src->ptszFiles) {
@@ -234,14 +234,14 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS if (src->ptszFiles[i])
dest->ptszFiles[i] = PFTS_StringToTchar(src->flags, src->ptszFiles[i]);
else
- dest->ptszFiles[i] = NULL;
+ dest->ptszFiles[i] = nullptr;
}
}
else if (dest->ptszFiles) {
for (int i = 0; i < dest->totalFiles; i++)
mir_free(dest->ptszFiles[i]);
mir_free(dest->ptszFiles);
- dest->ptszFiles = NULL;
+ dest->ptszFiles = nullptr;
}
dest->currentFileNumber = src->currentFileNumber;
@@ -252,7 +252,7 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS if (src->tszWorkingDir)
dest->tszWorkingDir = PFTS_StringToTchar(src->flags, src->tszWorkingDir);
else
- dest->tszWorkingDir = NULL;
+ dest->tszWorkingDir = nullptr;
}
if (!dest->tszCurrentFile || !src->tszCurrentFile || PFTS_CompareWithTchar(src, src->tszCurrentFile, dest->tszCurrentFile)) {
@@ -260,7 +260,7 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS if (src->tszCurrentFile)
dest->tszCurrentFile = PFTS_StringToTchar(src->flags, src->tszCurrentFile);
else
- dest->tszCurrentFile = NULL;
+ dest->tszCurrentFile = nullptr;
}
dest->currentFileSize = src->currentFileSize;
dest->currentFileProgress = src->currentFileProgress;
@@ -287,7 +287,7 @@ static int SRFilePreBuildMenu(WPARAM wParam, LPARAM) {
bool bEnabled = false;
char *szProto = GetContactProto(wParam);
- if (szProto != NULL) {
+ if (szProto != nullptr) {
bool isChat = db_get_b(wParam, szProto, "ChatRoom", false) != 0;
if (CallProtoService(szProto, PS_GETCAPS, isChat ? PFLAGNUM_4 : PFLAGNUM_1, 0) & (isChat ? PF4_GROUPCHATFILES : PF1_FILESEND)) {
if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_OFFLINEFILES)
@@ -338,7 +338,7 @@ INT_PTR openContRecDir(WPARAM hContact, LPARAM) {
wchar_t szContRecDir[MAX_PATH];
GetContactReceivedFilesDir(hContact, szContRecDir, _countof(szContRecDir), TRUE);
- ShellExecute(0, L"open", szContRecDir, 0, 0, SW_SHOW);
+ ShellExecute(nullptr, L"open", szContRecDir, nullptr, nullptr, SW_SHOW);
return 0;
}
@@ -346,7 +346,7 @@ INT_PTR openRecDir(WPARAM, LPARAM) {
wchar_t szContRecDir[MAX_PATH];
GetReceivedFilesDir(szContRecDir, _countof(szContRecDir));
- ShellExecute(0, L"open", szContRecDir, 0, 0, SW_SHOW);
+ ShellExecute(nullptr, L"open", szContRecDir, nullptr, nullptr, SW_SHOW);
return 0;
}
@@ -389,7 +389,7 @@ static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam) dbei.cbBlob += (int)mir_strlen(szDescr) + 1;
- if ((dbei.pBlob = (BYTE*)mir_alloc(dbei.cbBlob)) == 0)
+ if ((dbei.pBlob = (BYTE*)mir_alloc(dbei.cbBlob)) == nullptr)
return 0;
*(DWORD*)dbei.pBlob = 0;
@@ -401,7 +401,7 @@ static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam) mir_free(pszFiles[i]);
}
- mir_strcpy((char*)p, (szDescr == NULL) ? "" : szDescr);
+ mir_strcpy((char*)p, (szDescr == nullptr) ? "" : szDescr);
if (bUnicode)
mir_free(szDescr);
diff --git a/src/core/stdfile/src/fileexistsdlg.cpp b/src/core/stdfile/src/fileexistsdlg.cpp index 13e2557e35..217d80fa82 100644 --- a/src/core/stdfile/src/fileexistsdlg.cpp +++ b/src/core/stdfile/src/fileexistsdlg.cpp @@ -54,7 +54,7 @@ static void DoAnnoyingShellCommand(HWND hwnd, const wchar_t *szFilename, int cmd ITEMIDLIST *pCurrentIdl;
WCHAR* wszFilename = (LPWSTR)szFilename;
- if (pDesktopFolder->ParseDisplayName(NULL, NULL, wszFilename, NULL, &pCurrentIdl, NULL) == NOERROR) {
+ if (pDesktopFolder->ParseDisplayName(nullptr, nullptr, wszFilename, nullptr, &pCurrentIdl, nullptr) == NOERROR) {
if (pCurrentIdl->mkid.cb) {
ITEMIDLIST *pidl, *pidlNext, *pidlFilename;
IShellFolder *pFileFolder;
@@ -69,9 +69,9 @@ static void DoAnnoyingShellCommand(HWND hwnd, const wchar_t *szFilename, int cmd }
pidl = pidlNext;
}
- if (pDesktopFolder->BindToObject(pCurrentIdl, NULL, IID_IShellFolder, (void**)&pFileFolder) == NOERROR) {
+ if (pDesktopFolder->BindToObject(pCurrentIdl, nullptr, IID_IShellFolder, (void**)&pFileFolder) == NOERROR) {
IContextMenu *pContextMenu;
- if (pFileFolder->GetUIObjectOf(NULL, 1, (LPCITEMIDLIST*)&pidlFilename, IID_IContextMenu, NULL, (void**)&pContextMenu) == NOERROR) {
+ if (pFileFolder->GetUIObjectOf(nullptr, 1, (LPCITEMIDLIST*)&pidlFilename, IID_IContextMenu, nullptr, (void**)&pContextMenu) == NOERROR) {
switch (cmd) {
case C_PROPERTIES:
{
@@ -87,7 +87,7 @@ static void DoAnnoyingShellCommand(HWND hwnd, const wchar_t *szFilename, int cmd case C_CONTEXTMENU:
HMENU hMenu = CreatePopupMenu();
if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu, 0, 1000, 65535, (GetKeyState(VK_SHIFT) & 0x8000 ? CMF_EXTENDEDVERBS : 0) | CMF_NORMAL))) {
- int ret = TrackPopupMenu(hMenu, TPM_RETURNCMD, ptCursor->x, ptCursor->y, 0, hwnd, NULL);
+ int ret = TrackPopupMenu(hMenu, TPM_RETURNCMD, ptCursor->x, ptCursor->y, 0, hwnd, nullptr);
if (ret) {
CMINVOKECOMMANDINFO ici = { 0 };
ici.cbSize = sizeof(ici);
@@ -118,7 +118,7 @@ static LRESULT CALLBACK IconCtrlSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, switch (msg) {
case WM_LBUTTONDBLCLK:
- ShellExecute(hwnd, NULL, pft->tszCurrentFile, NULL, NULL, SW_SHOW);
+ ShellExecute(hwnd, nullptr, pft->tszCurrentFile, nullptr, nullptr, SW_SHOW);
break;
case WM_RBUTTONUP:
POINT pt;
@@ -144,7 +144,7 @@ void __cdecl LoadIconsAndTypesThread(void* param) wchar_t szExtension[64], szIconFile[MAX_PATH];
wchar_t *pszFilename = wcsrchr(info->szFilename, '\\');
- if (pszFilename == NULL)
+ if (pszFilename == nullptr)
pszFilename = info->szFilename;
wchar_t *pszExtension = wcsrchr(pszFilename, '.');
diff --git a/src/core/stdfile/src/fileopts.cpp b/src/core/stdfile/src/fileopts.cpp index d751fce211..1b30b39758 100644 --- a/src/core/stdfile/src/fileopts.cpp +++ b/src/core/stdfile/src/fileopts.cpp @@ -37,7 +37,7 @@ struct virusscannerinfo { } virusScanners[] = {
{L"Network Associates/McAfee VirusScan", L"SOFTWARE\\McAfee\\VirusScan", L"Scan32EXE", L"\"%s\" %%f /nosplash /comp /autoscan /autoexit /noboot"},
{L"Dr Solomon's VirusScan (Network Associates)", L"SOFTWARE\\Network Associates\\TVD\\VirusScan\\AVConsol\\General", L"szScannerExe", L"\"%s\" %%f /uinone /noboot /comp /prompt /autoexit"},
- {L"Norton AntiVirus", L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Navw32.exe", NULL, L"\"%s\" %%f /b- /m- /s+ /noresults"},
+ {L"Norton AntiVirus", L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Navw32.exe", nullptr, L"\"%s\" %%f /b- /m- /s+ /noresults"},
{L"Computer Associates/Inoculate IT", L"Software\\Antivirus", L"ImageFilename", L"\"%s\" %%f /display = progress /exit"},
{L"Computer Associates eTrust", L"SOFTWARE\\ComputerAssociates\\Anti-Virus\\Resident", L"VetPath", L"\"%s\" %%f /display = progress /exit"},
{L"Kaspersky Anti-Virus", L"SOFTWARE\\KasperskyLab\\Components\\101", L"EXEName", L"\"%s\" /S /Q %%f"},
@@ -188,7 +188,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L }
ofn.nMaxFileTitle = MAX_PATH;
if (!GetOpenFileName(&ofn)) break;
- if (wcschr(str, ' ') != NULL) {
+ if (wcschr(str, ' ') != nullptr) {
memmove(str + 1, str, ((_countof(str) - 2) * sizeof(wchar_t)));
str[0] = '"';
mir_wstrcat(str, L"\"");
diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp index 5f6baa2e04..baf12e60ec 100644 --- a/src/core/stdfile/src/filerecvdlg.cpp +++ b/src/core/stdfile/src/filerecvdlg.cpp @@ -41,7 +41,7 @@ static void GetLowestExistingDirName(const wchar_t *szTestDir, wchar_t *szExisti mir_wstrncpy(szExistingDir, szTestDir, cchExistingDir);
while ((dwAttributes = GetFileAttributes(szExistingDir)) != INVALID_FILE_ATTRIBUTES && !(dwAttributes&FILE_ATTRIBUTE_DIRECTORY)) {
pszLastBackslash = wcsrchr(szExistingDir, '\\');
- if (pszLastBackslash == NULL) { *szExistingDir = '\0'; break; }
+ if (pszLastBackslash == nullptr) { *szExistingDir = '\0'; break; }
*pszLastBackslash = '\0';
}
if (szExistingDir[0] == '\0')
@@ -83,7 +83,7 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p int BrowseForFolder(HWND hwnd, wchar_t *szPath)
{
- BROWSEINFO bi = { 0 };
+ BROWSEINFO bi = {};
bi.hwndOwner = hwnd;
bi.pszDisplayName = szPath;
bi.lpszTitle = TranslateT("Select folder");
@@ -97,7 +97,7 @@ int BrowseForFolder(HWND hwnd, wchar_t *szPath) mir_wstrcat(szPath, L"\\");
CoTaskMemFree(pidlResult);
}
- return pidlResult != NULL;
+ return pidlResult != nullptr;
}
static REPLACEVARSARRAY sttVarsToReplace[] =
@@ -105,7 +105,7 @@ static REPLACEVARSARRAY sttVarsToReplace[] = { "///", "//" },
{ "//", "/" },
{ "()", "" },
- { NULL, NULL }
+ { nullptr, nullptr }
};
static void patchDir(wchar_t *str, size_t strSize)
@@ -141,8 +141,8 @@ void GetContactReceivedFilesDir(MCONTACT hContact, wchar_t *szDir, int cchDir, B rvaVarsToReplace[1].value.w = GetContactID(hContact);
rvaVarsToReplace[2].key.w = L"proto";
rvaVarsToReplace[2].value.w = mir_a2u(GetContactProto(hContact));
- rvaVarsToReplace[3].key.w = NULL;
- rvaVarsToReplace[3].value.w = NULL;
+ rvaVarsToReplace[3].key.w = nullptr;
+ rvaVarsToReplace[3].value.w = nullptr;
for (int i = 0; i < (_countof(rvaVarsToReplace) - 1); i++)
RemoveInvalidFilenameChars(rvaVarsToReplace[i].value.w);
@@ -277,7 +277,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (szProto) {
HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
if (hIcon) {
- DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
+ DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, nullptr, DI_NORMAL);
DestroyIcon(hIcon);
}
}
@@ -341,7 +341,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDCANCEL:
if (dat->fs) ProtoChainSend(dat->hContact, PSS_FILEDENY, (WPARAM)dat->fs, (LPARAM)TranslateT("Canceled"));
- dat->fs = NULL; /* the protocol will free the handle */
+ dat->fs = nullptr; /* the protocol will free the handle */
DestroyWindow(hwndDlg);
break;
@@ -380,7 +380,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case HM_RECVEVENT:
{
ACKDATA *ack = (ACKDATA*)lParam;
- if ((ack == NULL) || (ack->hProcess != dat->fs) || (ack->type != ACKTYPE_FILE) || (ack->hContact != dat->hContact))
+ if ((ack == nullptr) || (ack->hProcess != dat->fs) || (ack->type != ACKTYPE_FILE) || (ack->hContact != dat->hContact))
break;
if (ack->result == ACKRESULT_DENIED || ack->result == ACKRESULT_FAILED) {
diff --git a/src/core/stdfile/src/filesenddlg.cpp b/src/core/stdfile/src/filesenddlg.cpp index 1e2741f1d2..c8c6fb4a3d 100644 --- a/src/core/stdfile/src/filesenddlg.cpp +++ b/src/core/stdfile/src/filesenddlg.cpp @@ -97,7 +97,7 @@ static void FilenameToFileList(HWND hwndDlg, FileDlgData* dat, const wchar_t *bu }
// Allocate memory for a pointer array
- if ((dat->files = (wchar_t**)mir_alloc((nNumberOfFiles + 1) * sizeof(wchar_t*))) == NULL)
+ if ((dat->files = (wchar_t**)mir_alloc((nNumberOfFiles + 1) * sizeof(wchar_t*))) == nullptr)
return;
// Fill the array
@@ -118,15 +118,15 @@ static void FilenameToFileList(HWND hwndDlg, FileDlgData* dat, const wchar_t *bu nTemp++;
}
// Terminate array
- dat->files[nNumberOfFiles] = NULL;
+ dat->files[nNumberOfFiles] = nullptr;
}
// ...the selection is a single file
else {
- if ((dat->files = (wchar_t **)mir_alloc(2 * sizeof(wchar_t*))) == NULL) // Leaks when aborted
+ if ((dat->files = (wchar_t **)mir_alloc(2 * sizeof(wchar_t*))) == nullptr) // Leaks when aborted
return;
dat->files[0] = mir_wstrdup(buf);
- dat->files[1] = NULL;
+ dat->files[1] = nullptr;
}
// Update dialog text with new file selection
@@ -140,7 +140,7 @@ void __cdecl ChooseFilesThread(void* param) FileDlgData *dat = (FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
wchar_t *buf = (wchar_t*)mir_alloc(sizeof(wchar_t) * 32767);
- if (buf == NULL) {
+ if (buf == nullptr) {
PostMessage(hwndDlg, M_FILECHOOSEDONE, 0, NULL);
return;
}
@@ -212,7 +212,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l dat->hContact = fsd->hContact;
dat->send = 1;
dat->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN);
- dat->fs = NULL;
+ dat->fs = nullptr;
dat->dwTicks = GetTickCount();
EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0);
@@ -225,13 +225,13 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
- if (fsd->ppFiles != NULL && fsd->ppFiles[0] != NULL) {
+ if (fsd->ppFiles != nullptr && fsd->ppFiles[0] != nullptr) {
int totalCount, i;
for (totalCount = 0; fsd->ppFiles[totalCount]; totalCount++);
dat->files = (wchar_t**)mir_alloc(sizeof(wchar_t*)*(totalCount + 1)); // Leaks
for (i = 0; i < totalCount; i++)
dat->files[i] = mir_wstrdup(fsd->ppFiles[i]);
- dat->files[totalCount] = NULL;
+ dat->files[totalCount] = nullptr;
SetFileListAndSizeControls(hwndDlg, dat);
}
@@ -241,7 +241,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l ptrW id(Contact_GetInfo(CNF_UNIQUEID, dat->hContact));
SetDlgItemText(hwndDlg, IDC_NAME, (id) ? id : contactName);
- if (fsd->ppFiles == NULL) {
+ if (fsd->ppFiles == nullptr) {
EnableWindow(hwndDlg, FALSE);
dat->closeIfFileChooseCancelled = 1;
PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_CHOOSE, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDC_CHOOSE));
@@ -260,7 +260,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (szProto) {
HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
if (hIcon) {
- DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
+ DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, nullptr, DI_NORMAL);
DestroyIcon(hIcon);
}
}
diff --git a/src/core/stdfile/src/filexferdlg.cpp b/src/core/stdfile/src/filexferdlg.cpp index d3499bfcb8..37a22a1dcf 100644 --- a/src/core/stdfile/src/filexferdlg.cpp +++ b/src/core/stdfile/src/filexferdlg.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static int CheckVirusScanned(HWND hwnd, FileDlgData *dat, int i) { if (dat->send) return 1; - if (dat->fileVirusScanned == NULL) return 0; + if (dat->fileVirusScanned == nullptr) return 0; if (dat->fileVirusScanned[i]) return 1; if (db_get_b(NULL, "SRFile", "WarnBeforeOpening", 1) == 0) return 1; return IDYES == MessageBox(hwnd, TranslateT("This file has not yet been scanned for viruses. Are you certain you want to open it?"), TranslateT("File received"), MB_YESNO|MB_DEFBUTTON2); @@ -78,7 +78,7 @@ void FillSendData(FileDlgData *dat, DBEVENTINFO& dbei) dbei.szModule = GetContactProto(dat->hContact); dbei.eventType = EVENTTYPE_FILE; dbei.flags = DBEF_SENT; - dbei.timestamp = time(NULL); + dbei.timestamp = time(nullptr); char *szFileNames = Utf8EncodeW(dat->szFilenames), *szMsg = Utf8EncodeW(dat->szMsg); dbei.flags |= DBEF_UTF; @@ -109,7 +109,7 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) wcsncpy_s(szCmdLine, dbv.ptszVal, _TRUNCATE); PROCESS_INFORMATION pi; - if (CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { + if (CreateProcess(nullptr, szCmdLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi)) { if (WaitForSingleObject(pi.hProcess, 3600 * 1000) == WAIT_OBJECT_0) PostMessage(info->hwndReply, M_VIRUSSCANDONE, info->returnCode, 0); CloseHandle(pi.hProcess); @@ -125,17 +125,17 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) static void SetFilenameControls(HWND hwndDlg, FileDlgData *dat, PROTOFILETRANSFERSTATUS *fts) { wchar_t msg[MAX_PATH]; - wchar_t *fnbuf = NULL, *fn = NULL; - SHFILEINFO shfi = { 0 }; + wchar_t *fnbuf = nullptr, *fn = nullptr; + SHFILEINFO shfi = {}; if (fts->tszCurrentFile) { fnbuf = mir_wstrdup(fts->tszCurrentFile); - if ((fn = wcsrchr(fnbuf, '\\')) == NULL) + if ((fn = wcsrchr(fnbuf, '\\')) == nullptr) fn = fnbuf; else fn++; } - if (dat->hIcon) DestroyIcon(dat->hIcon); dat->hIcon = NULL; + if (dat->hIcon) DestroyIcon(dat->hIcon); dat->hIcon = nullptr; if (fn && (fts->totalFiles > 1)) { mir_snwprintf(msg, L"%s: %s (%d %s %d)", @@ -182,8 +182,8 @@ static void HideProgressControls(HWND hwndDlg) char buf[64]; GetWindowRect(GetDlgItem(hwndDlg, IDC_ALLPRECENTS), &rc); - MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc, 2); - SetWindowPos(hwndDlg, NULL, 0, 0, 100, rc.bottom + 3, SWP_NOMOVE | SWP_NOZORDER); + MapWindowPoints(nullptr, hwndDlg, (LPPOINT)&rc, 2); + SetWindowPos(hwndDlg, nullptr, 0, 0, 100, rc.bottom + 3, SWP_NOMOVE | SWP_NOZORDER); ShowWindow(GetDlgItem(hwndDlg, IDC_ALLTRANSFERRED), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_ALLSPEED), SW_HIDE); @@ -265,11 +265,11 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR hFont = CreateFontIndirect(&lf); SendDlgItemMessage(hwndDlg, IDC_CONTACTNAME, WM_SETFONT, (WPARAM)hFont, 0); - SHFILEINFO shfi = { 0 }; + SHFILEINFO shfi = {}; SHGetFileInfo(L"", FILE_ATTRIBUTE_DIRECTORY, &shfi, sizeof(shfi), SHGFI_USEFILEATTRIBUTES | SHGFI_ICON | SHGFI_SMALLICON); dat->hIconFolder = shfi.hIcon; } - dat->hIcon = NULL; + dat->hIcon = nullptr; { char *szProto = GetContactProto(dat->hContact); WORD status = db_get_w(dat->hContact, szProto, "Status", ID_STATUS_ONLINE); @@ -290,7 +290,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetDlgItemText(hwndDlg, IDC_CONTACTNAME, pcli->pfnGetContactDisplayName(dat->hContact, 0)); - if (!dat->waitingForAcceptance) SetTimer(hwndDlg, 1, 1000, NULL); + if (!dat->waitingForAcceptance) SetTimer(hwndDlg, 1, 1000, nullptr); return TRUE; case WM_TIMER: @@ -384,7 +384,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case IDC_OPENFILE: wchar_t **files; if (dat->send) { - if (dat->files == NULL) + if (dat->files == nullptr) files = dat->transferStatus.ptszFiles; else files = dat->files; @@ -393,7 +393,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR HMENU hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING, 1, TranslateT("Open folder")); - AppendMenu(hMenu, MF_SEPARATOR, 0, 0); + AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); if (files && *files) { int limit; @@ -407,7 +407,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR // Loop over all transfered files and add them to the menu for (int i = 0; i < limit; i++) { pszFilename = wcsrchr(files[i], '\\'); - if (pszFilename == NULL) + if (pszFilename == nullptr) pszFilename = files[i]; else pszFilename++; @@ -432,7 +432,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR RECT rc; GetWindowRect((HWND)lParam, &rc); CheckDlgButton(hwndDlg, IDC_OPENFILE, BST_CHECKED); - int ret = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_RIGHTALIGN, rc.right, rc.bottom, 0, hwndDlg, NULL); + int ret = TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_RIGHTALIGN, rc.right, rc.bottom, 0, hwndDlg, nullptr); CheckDlgButton(hwndDlg, IDC_OPENFILE, BST_UNCHECKED); DestroyMenu(hMenu); @@ -445,10 +445,10 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR *p = 0; } - if (path) ShellExecute(NULL, L"open", path, NULL, NULL, SW_SHOW); + if (path) ShellExecute(nullptr, L"open", path, nullptr, nullptr, SW_SHOW); } else if (ret && CheckVirusScanned(hwndDlg, dat, ret)) - ShellExecute(NULL, NULL, files[ret - 10], NULL, NULL, SW_SHOW); + ShellExecute(nullptr, nullptr, files[ret - 10], nullptr, nullptr, SW_SHOW); } break; @@ -462,7 +462,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR switch (pfr->action) { case FILERESUME_CANCEL: if (dat->fs) ProtoChainSend(dat->hContact, PSS_FILECANCEL, (WPARAM)dat->fs, 0); - dat->fs = NULL; + dat->fs = nullptr; mir_free(szOriginalFilename); if (pfr->szFilename) mir_free((char*)pfr->szFilename); mir_free(pfr); @@ -476,8 +476,8 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR pfr->action = FILERESUME_RENAME; { wchar_t *pszExtension, *pszFilename; - if ((pszFilename = wcsrchr(szOriginalFilename, '\\')) == NULL) pszFilename = szOriginalFilename; - if ((pszExtension = wcsrchr(pszFilename + 1, '.')) == NULL) pszExtension = pszFilename + mir_wstrlen(pszFilename); + if ((pszFilename = wcsrchr(szOriginalFilename, '\\')) == nullptr) pszFilename = szOriginalFilename; + if ((pszExtension = wcsrchr(pszFilename + 1, '.')) == nullptr) pszExtension = pszFilename + mir_wstrlen(pszFilename); if (pfr->szFilename) mir_free((wchar_t*)pfr->szFilename); size_t size = (pszExtension - szOriginalFilename) + 21 + mir_wstrlen(pszExtension); pfr->szFilename = (wchar_t*)mir_alloc(sizeof(wchar_t)*size); @@ -504,7 +504,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (ack->hContact != dat->hContact) break; if (dat->waitingForAcceptance) { - SetTimer(hwndDlg, 1, 1000, NULL); + SetTimer(hwndDlg, 1, 1000, nullptr); dat->waitingForAcceptance = 0; } @@ -552,7 +552,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR else { PROTOFILERESUME *pfr = (PROTOFILERESUME*)mir_alloc(sizeof(PROTOFILERESUME)); pfr->action = dat->resumeBehaviour; - pfr->szFilename = NULL; + pfr->szFilename = nullptr; PostMessage(hwndDlg, M_FILEEXISTSDLGREPLY, (WPARAM)mir_wstrdup(fts->tszCurrentFile), (LPARAM)pfr); } } @@ -564,14 +564,14 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR PROTOFILETRANSFERSTATUS *fts = (PROTOFILETRANSFERSTATUS*)ack->lParam; wchar_t str[64], str2[64], szSizeDone[32], szSizeTotal[32];//, *contactName; - if (dat->fileVirusScanned == NULL) + if (dat->fileVirusScanned == nullptr) dat->fileVirusScanned = (int*)mir_calloc(sizeof(int) * fts->totalFiles); // This needs to be here - otherwise we get holes in the files array if (!dat->send) { - if (dat->files == NULL) + if (dat->files == nullptr) dat->files = (wchar_t**)mir_calloc((fts->totalFiles + 1) * sizeof(wchar_t*)); - if (fts->currentFileNumber < fts->totalFiles && dat->files[fts->currentFileNumber] == NULL) + if (fts->currentFileNumber < fts->totalFiles && dat->files[fts->currentFileNumber] == nullptr) dat->files[fts->currentFileNumber] = PFTS_StringToTchar(fts->flags, fts->tszCurrentFile); } @@ -620,30 +620,30 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetDlgItemText(hwndDlg, IDCANCEL, TranslateT("Close")); if (dat->hNotifyEvent) UnhookEvent(dat->hNotifyEvent); - dat->hNotifyEvent = NULL; + dat->hNotifyEvent = nullptr; if (ack->result == ACKRESULT_DENIED) { - dat->fs = NULL; /* protocol will free structure */ + dat->fs = nullptr; /* protocol will free structure */ Skin_PlaySound("FileDenied"); SetFtStatus(hwndDlg, LPGENW("File transfer denied"), FTS_TEXT); } else if (ack->result == ACKRESULT_FAILED) { - dat->fs = NULL; /* protocol will free structure */ + dat->fs = nullptr; /* protocol will free structure */ Skin_PlaySound("FileFailed"); SetFtStatus(hwndDlg, LPGENW("File transfer failed"), FTS_TEXT); } else { Skin_PlaySound("FileDone"); if (dat->send) { - dat->fs = NULL; /* protocol will free structure */ + dat->fs = nullptr; /* protocol will free structure */ SetFtStatus(hwndDlg, LPGENW("Transfer completed."), FTS_TEXT); - DBEVENTINFO dbei = { 0 }; + DBEVENTINFO dbei = {}; FillSendData(dat, dbei); db_event_add(dat->hContact, &dbei); if (dbei.pBlob) mir_free(dbei.pBlob); - dat->files = NULL; //protocol library frees this + dat->files = nullptr; //protocol library frees this } else { SetFtStatus(hwndDlg, @@ -662,7 +662,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (GetFileAttributes(dat->files[dat->transferStatus.currentFileNumber])&FILE_ATTRIBUTE_DIRECTORY) { PostMessage(hwndDlg, M_VIRUSSCANDONE, vstsi->returnCode, 0); mir_free(vstsi); - vstsi = NULL; + vstsi = nullptr; } else vstsi->szFile = mir_wstrdup(dat->files[dat->transferStatus.currentFileNumber]); } @@ -674,7 +674,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (vstsi) mir_forkthread((void(*)(void*))RunVirusScannerThread, vstsi); } - else dat->fs = NULL; /* protocol will free structure */ + else dat->fs = nullptr; /* protocol will free structure */ dat->transferStatus.currentFileNumber = dat->transferStatus.totalFiles; } // else dat->send @@ -703,7 +703,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } } if (done) { - dat->fs = NULL; /* protocol will free structure */ + dat->fs = nullptr; /* protocol will free structure */ SetFtStatus(hwndDlg, LPGENW("Transfer and virus scan complete"), FTS_TEXT); } } @@ -737,7 +737,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR void FreeFileDlgData(FileDlgData* dat) { - if (dat == NULL) + if (dat == nullptr) return; if (dat->fs) diff --git a/src/core/stdfile/src/ftmanager.cpp b/src/core/stdfile/src/ftmanager.cpp index fa749d503e..a70a26d2eb 100644 --- a/src/core/stdfile/src/ftmanager.cpp +++ b/src/core/stdfile/src/ftmanager.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
#include "file.h"
-static HWND hwndFtMgr = NULL;
+static HWND hwndFtMgr = nullptr;
struct TFtMgrData
{
@@ -78,8 +78,8 @@ static void LayoutTransfers(HWND hwnd, struct TFtPageData *dat) top -= dat->scrollPos;
for (int i = 0; i < dat->wnds->realCount; ++i) {
int height = dat->wnds->items[i]->rc.bottom - dat->wnds->items[i]->rc.top;
- if (NULL != dat->wnds->items[i]->hwnd) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, dat->wnds->items[i]->hwnd, NULL, 0, top, rc.right, height, SWP_NOZORDER);
+ if (nullptr != dat->wnds->items[i]->hwnd) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, dat->wnds->items[i]->hwnd, nullptr, 0, top, rc.right, height, SWP_NOZORDER);
top += height;
}
top += dat->scrollPos;
@@ -215,7 +215,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA if (pos < 0) pos = 0;
if (dat->scrollPos != pos) {
- ScrollWindow(hwnd, 0, dat->scrollPos - pos, NULL, NULL);
+ ScrollWindow(hwnd, 0, dat->scrollPos - pos, nullptr, nullptr);
SetScrollPos(hwnd, SB_VERT, pos, TRUE);
dat->scrollPos = pos;
}
@@ -306,25 +306,25 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM hdwp = BeginDeferWindowPos(3);
hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_CLEAR), NULL, rc.left, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
- hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDCANCEL), NULL, rc.right-rcButton.right, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
+ hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDCANCEL), nullptr, rc.right-rcButton.right, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
rc.bottom -= rcButton.bottom + 5;
- if (NULL != hwndTab) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, hwndTab, NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER);
+ if (nullptr != hwndTab) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, hwndTab, nullptr, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER);
EndDeferWindowPos(hdwp);
GetWindowRect(hwndTab, &rc);
- MapWindowPoints(NULL, hwnd, (LPPOINT)&rc, 2);
+ MapWindowPoints(nullptr, hwnd, (LPPOINT)&rc, 2);
TabCtrl_AdjustRect(hwndTab, FALSE, &rc);
InflateRect(&rc, -5, -5);
hdwp = BeginDeferWindowPos(2);
- if (NULL != dat->hwndIncoming) /* Wine fix. */
+ if (nullptr != dat->hwndIncoming) /* Wine fix. */
hdwp = DeferWindowPos(hdwp, dat->hwndIncoming, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0);
- if (NULL != dat->hwndOutgoing) /* Wine fix. */
+ if (nullptr != dat->hwndOutgoing) /* Wine fix. */
hdwp = DeferWindowPos(hdwp, dat->hwndOutgoing, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0);
EndDeferWindowPos(hdwp);
@@ -444,7 +444,7 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case WM_TIMER:
if (pTaskbarInterface) {
- SetTimer(hwnd, 1, 400, NULL);
+ SetTimer(hwnd, 1, 400, nullptr);
if ((lParam == ACKRESULT_FAILED) || (lParam == ACKRESULT_DENIED))
dat->errorState = TBPF_ERROR;
@@ -478,7 +478,7 @@ HWND FtMgr_Show(bool bForceActivate, bool bFromMenu) {
bool bAutoMin = db_get_b(NULL, "SRFile", "AutoMin", 0) != 0; /* lqbe */
- bool bJustCreated = (hwndFtMgr == NULL);
+ bool bJustCreated = (hwndFtMgr == nullptr);
if (bJustCreated)
hwndFtMgr = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FTMGR), NULL, FtMgrDlgProc);
@@ -522,8 +522,8 @@ HWND FtMgr_AddTransfer(FileDlgData *fdd) {
bool bForceActivate = fdd->send || !db_get_b(NULL, "SRFile", "AutoAccept", 0);
TFtMgrData *dat = (TFtMgrData*)GetWindowLongPtr(FtMgr_Show(bForceActivate, false), GWLP_USERDATA);
- if (dat == NULL)
- return NULL;
+ if (dat == nullptr)
+ return nullptr;
HWND hwndBox = fdd->send ? dat->hwndOutgoing : dat->hwndIncoming;
HWND hwndFt = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILETRANSFERINFO), hwndBox, DlgProcFileTransfer, (LPARAM)fdd);
diff --git a/src/core/stdfile/src/main.cpp b/src/core/stdfile/src/main.cpp index 82815089e7..6fd42be78e 100644 --- a/src/core/stdfile/src/main.cpp +++ b/src/core/stdfile/src/main.cpp @@ -62,7 +62,7 @@ extern "C" int __declspec(dllexport) Load(void) pcli = Clist_GetInterface();
if ( IsWinVer7Plus())
- CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (void**)&pTaskbarInterface);
+ CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_ALL, IID_ITaskbarList3, (void**)&pTaskbarInterface);
LoadSendRecvFileModule();
return 0;
|