summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/stdfile/src/file.cpp70
-rw-r--r--src/core/stdfile/src/fileexistsdlg.cpp20
-rw-r--r--src/core/stdfile/src/filexferdlg.cpp24
3 files changed, 57 insertions, 57 deletions
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp
index 717ad29457..87fcaf65d1 100644
--- a/src/core/stdfile/src/file.cpp
+++ b/src/core/stdfile/src/file.cpp
@@ -193,24 +193,24 @@ void FreeFilesMatrix(wchar_t ***files)
void FreeProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *fts)
{
- mir_free(fts->tszCurrentFile);
- if (fts->ptszFiles) {
- for (int i = 0; i < fts->totalFiles; i++) mir_free(fts->ptszFiles[i]);
- mir_free(fts->ptszFiles);
+ mir_free(fts->szCurrentFile.w);
+ if (fts->pszFiles.w) {
+ for (int i = 0; i < fts->totalFiles; i++) mir_free(fts->pszFiles.w[i]);
+ mir_free(fts->pszFiles.w);
}
- mir_free(fts->tszWorkingDir);
+ mir_free(fts->szWorkingDir.w);
}
void CopyProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANSFERSTATUS *src)
{
*dest = *src;
- if (src->tszCurrentFile) dest->tszCurrentFile = PFTS_StringToTchar(src->flags, src->tszCurrentFile);
- if (src->ptszFiles) {
- dest->ptszFiles = (wchar_t**)mir_alloc(sizeof(wchar_t*)*src->totalFiles);
+ if (src->szCurrentFile.w) dest->szCurrentFile.w = PFTS_StringToTchar(src->flags, src->szCurrentFile.w);
+ if (src->pszFiles.w) {
+ dest->pszFiles.w = (wchar_t**)mir_alloc(sizeof(wchar_t*)*src->totalFiles);
for (int i = 0; i < src->totalFiles; i++)
- dest->ptszFiles[i] = PFTS_StringToTchar(src->flags, src->ptszFiles[i]);
+ dest->pszFiles.w[i] = PFTS_StringToTchar(src->flags, src->pszFiles.w[i]);
}
- if (src->tszWorkingDir) dest->tszWorkingDir = PFTS_StringToTchar(src->flags, src->tszWorkingDir);
+ if (src->szWorkingDir.w) dest->szWorkingDir.w = PFTS_StringToTchar(src->flags, src->szWorkingDir.w);
dest->flags &= ~PFTS_UTF;
dest->flags |= PFTS_UNICODE;
}
@@ -220,47 +220,47 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS
dest->hContact = src->hContact;
dest->flags = src->flags;
if (dest->totalFiles != src->totalFiles) {
- for (int i = 0; i < dest->totalFiles; i++) mir_free(dest->ptszFiles[i]);
- mir_free(dest->ptszFiles);
- dest->ptszFiles = nullptr;
+ for (int i = 0; i < dest->totalFiles; i++) mir_free(dest->pszFiles.w[i]);
+ mir_free(dest->pszFiles.w);
+ dest->pszFiles.w = nullptr;
dest->totalFiles = src->totalFiles;
}
- if (src->ptszFiles) {
- if (!dest->ptszFiles)
- dest->ptszFiles = (wchar_t**)mir_calloc(sizeof(wchar_t*)*src->totalFiles);
+ if (src->pszFiles.w) {
+ if (!dest->pszFiles.w)
+ dest->pszFiles.w = (wchar_t**)mir_calloc(sizeof(wchar_t*)*src->totalFiles);
for (int i = 0; i < src->totalFiles; i++)
- if (!dest->ptszFiles[i] || !src->ptszFiles[i] || PFTS_CompareWithTchar(src, src->ptszFiles[i], dest->ptszFiles[i])) {
- mir_free(dest->ptszFiles[i]);
- if (src->ptszFiles[i])
- dest->ptszFiles[i] = PFTS_StringToTchar(src->flags, src->ptszFiles[i]);
+ if (!dest->pszFiles.w[i] || !src->pszFiles.w[i] || PFTS_CompareWithTchar(src, src->pszFiles.w[i], dest->pszFiles.w[i])) {
+ mir_free(dest->pszFiles.w[i]);
+ if (src->pszFiles.w[i])
+ dest->pszFiles.w[i] = PFTS_StringToTchar(src->flags, src->pszFiles.w[i]);
else
- dest->ptszFiles[i] = nullptr;
+ dest->pszFiles.w[i] = nullptr;
}
}
- else if (dest->ptszFiles) {
+ else if (dest->pszFiles.w) {
for (int i = 0; i < dest->totalFiles; i++)
- mir_free(dest->ptszFiles[i]);
- mir_free(dest->ptszFiles);
- dest->ptszFiles = nullptr;
+ mir_free(dest->pszFiles.w[i]);
+ mir_free(dest->pszFiles.w);
+ dest->pszFiles.w = nullptr;
}
dest->currentFileNumber = src->currentFileNumber;
dest->totalBytes = src->totalBytes;
dest->totalProgress = src->totalProgress;
- if (src->tszWorkingDir && (!dest->tszWorkingDir || PFTS_CompareWithTchar(src, src->tszWorkingDir, dest->tszWorkingDir))) {
- mir_free(dest->tszWorkingDir);
- if (src->tszWorkingDir)
- dest->tszWorkingDir = PFTS_StringToTchar(src->flags, src->tszWorkingDir);
+ if (src->szWorkingDir.w && (!dest->szWorkingDir.w || PFTS_CompareWithTchar(src, src->szWorkingDir.w, dest->szWorkingDir.w))) {
+ mir_free(dest->szWorkingDir.w);
+ if (src->szWorkingDir.w)
+ dest->szWorkingDir.w = PFTS_StringToTchar(src->flags, src->szWorkingDir.w);
else
- dest->tszWorkingDir = nullptr;
+ dest->szWorkingDir.w = nullptr;
}
- if (!dest->tszCurrentFile || !src->tszCurrentFile || PFTS_CompareWithTchar(src, src->tszCurrentFile, dest->tszCurrentFile)) {
- mir_free(dest->tszCurrentFile);
- if (src->tszCurrentFile)
- dest->tszCurrentFile = PFTS_StringToTchar(src->flags, src->tszCurrentFile);
+ if (!dest->szCurrentFile.w || !src->szCurrentFile.w || PFTS_CompareWithTchar(src, src->szCurrentFile.w, dest->szCurrentFile.w)) {
+ mir_free(dest->szCurrentFile.w);
+ if (src->szCurrentFile.w)
+ dest->szCurrentFile.w = PFTS_StringToTchar(src->flags, src->szCurrentFile.w);
else
- dest->tszCurrentFile = nullptr;
+ dest->szCurrentFile.w = nullptr;
}
dest->currentFileSize = src->currentFileSize;
dest->currentFileProgress = src->currentFileProgress;
diff --git a/src/core/stdfile/src/fileexistsdlg.cpp b/src/core/stdfile/src/fileexistsdlg.cpp
index dfc3334850..7a8125d02a 100644
--- a/src/core/stdfile/src/fileexistsdlg.cpp
+++ b/src/core/stdfile/src/fileexistsdlg.cpp
@@ -118,13 +118,13 @@ static LRESULT CALLBACK IconCtrlSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
switch (msg) {
case WM_LBUTTONDBLCLK:
- ShellExecute(hwnd, nullptr, pft->tszCurrentFile, nullptr, nullptr, SW_SHOW);
+ ShellExecute(hwnd, nullptr, pft->szCurrentFile.w, nullptr, nullptr, SW_SHOW);
break;
case WM_RBUTTONUP:
POINT pt;
pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam);
ClientToScreen(hwnd, &pt);
- DoAnnoyingShellCommand(hwnd, pft->tszCurrentFile, C_CONTEXTMENU, &pt);
+ DoAnnoyingShellCommand(hwnd, pft->szCurrentFile.w, C_CONTEXTMENU, &pt);
return 0;
}
return mir_callNextSubclass(hwnd, IconCtrlSubclassProc, msg, wParam, lParam);
@@ -211,7 +211,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
fts = (PROTOFILETRANSFERSTATUS*)mir_alloc(sizeof(PROTOFILETRANSFERSTATUS));
CopyProtoFileTransferStatus(fts, dat->fts);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)fts);
- SetDlgItemText(hwndDlg, IDC_FILENAME, fts->tszCurrentFile);
+ SetDlgItemText(hwndDlg, IDC_FILENAME, fts->szCurrentFile.w);
SetControlToUnixTime(hwndDlg, IDC_NEWDATE, fts->currentFileTime);
GetSensiblyFormattedSize(fts->currentFileSize, szSize, _countof(szSize), 0, 1, NULL);
SetDlgItemText(hwndDlg, IDC_NEWSIZE, szSize);
@@ -219,7 +219,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
mir_subclassWindow(GetDlgItem(hwndDlg, IDC_EXISTINGICON), IconCtrlSubclassProc);
HWND hwndFocus = GetDlgItem(hwndDlg, IDC_RESUME);
- if (_wstat64(fts->tszCurrentFile, &statbuf) == 0) {
+ if (_wstat64(fts->szCurrentFile.w, &statbuf) == 0) {
SetControlToUnixTime(hwndDlg, IDC_EXISTINGDATE, statbuf.st_mtime);
GetSensiblyFormattedSize(statbuf.st_size, szSize, _countof(szSize), 0, 1, NULL);
SetDlgItemText(hwndDlg, IDC_EXISTINGSIZE, szSize);
@@ -231,7 +231,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
loadiconsstartinfo *lisi = (loadiconsstartinfo*)mir_alloc(sizeof(loadiconsstartinfo));
lisi->hwndDlg = hwndDlg;
- lisi->szFilename = mir_wstrdup(fts->tszCurrentFile);
+ lisi->szFilename = mir_wstrdup(fts->szCurrentFile.w);
//can be a little slow, so why not?
mir_forkthread(LoadIconsAndTypesThread, lisi);
SetFocus(hwndFocus);
@@ -244,13 +244,13 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
PROTOFILERESUME pfr = { 0 };
switch (LOWORD(wParam)) {
case IDC_OPENFILE:
- ShellExecute(hwndDlg, NULL, fts->tszCurrentFile, NULL, NULL, SW_SHOW);
+ ShellExecute(hwndDlg, NULL, fts->szCurrentFile.w, NULL, NULL, SW_SHOW);
return FALSE;
case IDC_OPENFOLDER:
{
wchar_t szFile[MAX_PATH];
- mir_wstrncpy(szFile, fts->tszCurrentFile, _countof(szFile));
+ mir_wstrncpy(szFile, fts->szCurrentFile.w, _countof(szFile));
wchar_t *pszLastBackslash = wcsrchr(szFile, '\\');
if (pszLastBackslash)
*pszLastBackslash = '\0';
@@ -258,7 +258,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
}
return FALSE;
case IDC_PROPERTIES:
- DoAnnoyingShellCommand(hwndDlg, fts->tszCurrentFile, C_PROPERTIES, NULL);
+ DoAnnoyingShellCommand(hwndDlg, fts->szCurrentFile.w, C_PROPERTIES, NULL);
return FALSE;
case IDC_RESUME:
pfr.action = FILERESUME_RESUME;
@@ -283,7 +283,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
wchar_t filter[512], *pfilter;
wchar_t str[MAX_PATH];
- mir_wstrncpy(str, fts->tszCurrentFile, _countof(str));
+ mir_wstrncpy(str, fts->szCurrentFile.w, _countof(str));
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwndDlg;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
@@ -319,7 +319,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
PROTOFILERESUME *pfrCopy = (PROTOFILERESUME*)mir_alloc(sizeof(pfr));
memcpy(pfrCopy, &pfr, sizeof(pfr));
- PostMessage((HWND)GetPropA(hwndDlg, "Miranda.ParentWnd"), M_FILEEXISTSDLGREPLY, (WPARAM)mir_wstrdup(fts->tszCurrentFile), (LPARAM)pfrCopy);
+ PostMessage((HWND)GetPropA(hwndDlg, "Miranda.ParentWnd"), M_FILEEXISTSDLGREPLY, (WPARAM)mir_wstrdup(fts->szCurrentFile.w), (LPARAM)pfrCopy);
DestroyWindow(hwndDlg);
}
break;
diff --git a/src/core/stdfile/src/filexferdlg.cpp b/src/core/stdfile/src/filexferdlg.cpp
index 0a82e74343..37ae7a99e7 100644
--- a/src/core/stdfile/src/filexferdlg.cpp
+++ b/src/core/stdfile/src/filexferdlg.cpp
@@ -128,8 +128,8 @@ static void SetFilenameControls(HWND hwndDlg, FileDlgData *dat, PROTOFILETRANSFE
wchar_t *fnbuf = nullptr, *fn = nullptr;
SHFILEINFO shfi = {};
- if (fts->tszCurrentFile) {
- fnbuf = mir_wstrdup(fts->tszCurrentFile);
+ if (fts->szCurrentFile.w) {
+ fnbuf = mir_wstrdup(fts->szCurrentFile.w);
if ((fn = wcsrchr(fnbuf, '\\')) == nullptr)
fn = fnbuf;
else fn++;
@@ -246,7 +246,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
else { //recv
CreateDirectoryTreeW(dat->szSavePath);
dat->fs = (HANDLE)ProtoChainSend(dat->hContact, PSS_FILEALLOW, (WPARAM)dat->fs, (LPARAM)dat->szSavePath);
- dat->transferStatus.tszWorkingDir = mir_wstrdup(dat->szSavePath);
+ dat->transferStatus.szWorkingDir.w = mir_wstrdup(dat->szSavePath);
if (db_get_b(dat->hContact, "CList", "NotOnList", 0)) dat->resumeBehaviour = FILERESUME_ASK;
else dat->resumeBehaviour = db_get_b(NULL, "SRFile", "IfExists", FILERESUME_ASK);
SetFtStatus(hwndDlg, LPGENW("Waiting for connection..."), FTS_TEXT);
@@ -371,9 +371,9 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case IDC_OPENFOLDER:
{
- wchar_t *path = dat->transferStatus.tszWorkingDir;
+ wchar_t *path = dat->transferStatus.szWorkingDir.w;
if (!path || !path[0]) {
- path = NEWWSTR_ALLOCA(dat->transferStatus.tszCurrentFile);
+ path = NEWWSTR_ALLOCA(dat->transferStatus.szCurrentFile.w);
wchar_t *p = wcsrchr(path, '\\'); if (p) *p = 0;
}
@@ -385,7 +385,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
wchar_t **files;
if (dat->send) {
if (dat->files == nullptr)
- files = dat->transferStatus.ptszFiles;
+ files = dat->transferStatus.pszFiles.w;
else
files = dat->files;
}
@@ -437,9 +437,9 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
DestroyMenu(hMenu);
if (ret == 1) {
- wchar_t *path = dat->transferStatus.tszWorkingDir;
+ wchar_t *path = dat->transferStatus.szWorkingDir.w;
if (!path || !path[0]) {
- path = NEWWSTR_ALLOCA(dat->transferStatus.tszCurrentFile);
+ path = NEWWSTR_ALLOCA(dat->transferStatus.szCurrentFile.w);
wchar_t *p = wcsrchr(path, '\\');
if (p)
*p = 0;
@@ -539,7 +539,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
{
PROTOFILETRANSFERSTATUS *fts = &dat->transferStatus;
SetFilenameControls(hwndDlg, dat, fts);
- if (_waccess(fts->tszCurrentFile, 0))
+ if (_waccess(fts->szCurrentFile.w, 0))
break;
SetFtStatus(hwndDlg, LPGENW("File already exists"), FTS_TEXT);
@@ -553,7 +553,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
PROTOFILERESUME *pfr = (PROTOFILERESUME*)mir_alloc(sizeof(PROTOFILERESUME));
pfr->action = dat->resumeBehaviour;
pfr->szFilename = nullptr;
- PostMessage(hwndDlg, M_FILEEXISTSDLGREPLY, (WPARAM)mir_wstrdup(fts->tszCurrentFile), (LPARAM)pfr);
+ PostMessage(hwndDlg, M_FILEEXISTSDLGREPLY, (WPARAM)mir_wstrdup(fts->szCurrentFile.w), (LPARAM)pfr);
}
}
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, 1);
@@ -572,7 +572,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
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] == nullptr)
- dat->files[fts->currentFileNumber] = PFTS_StringToTchar(fts->flags, fts->tszCurrentFile);
+ dat->files[fts->currentFileNumber] = PFTS_StringToTchar(fts->flags, fts->szCurrentFile.w);
}
/* HACK: for 0.3.3, limit updates to around 1.1 ack per second */
@@ -667,7 +667,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
else vstsi->szFile = mir_wstrdup(dat->files[dat->transferStatus.currentFileNumber]);
}
else {
- vstsi->szFile = mir_wstrdup(dat->transferStatus.tszWorkingDir);
+ vstsi->szFile = mir_wstrdup(dat->transferStatus.szWorkingDir.w);
vstsi->returnCode = -1;
}
SetFtStatus(hwndDlg, LPGENW("Scanning for viruses..."), FTS_TEXT);