summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-18 21:37:39 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-18 21:37:39 +0000
commit0a46be5b99fe49b8f4616a88459381133d6c9b5f (patch)
treeade0f4bb63087f5cd01c6b00a53e2a461e2b1ae2 /src
parent02413392a2b40fcebe5f178c776402a9ce148604 (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@1028 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/core/stdfile/file.cpp2
-rw-r--r--src/core/stdfile/fileexistsdlg.cpp2
-rw-r--r--src/core/stdfile/filerecvdlg.cpp137
-rw-r--r--src/core/stdfile/filesenddlg.cpp13
-rw-r--r--src/core/stdfile/filexferdlg.cpp14
5 files changed, 84 insertions, 84 deletions
diff --git a/src/core/stdfile/file.cpp b/src/core/stdfile/file.cpp
index 45a84aaeaf..aff4fcbfa3 100644
--- a/src/core/stdfile/file.cpp
+++ b/src/core/stdfile/file.cpp
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "file.h"
TCHAR* PFTS_StringToTchar(int flags, const PROTOCHAR* s);
-int PFTS_CompareWithTchar(PROTOFILETRANSFERSTATUS* ft, const PROTOCHAR* s, TCHAR* r);
+int PFTS_CompareWithTchar(PROTOFILETRANSFERSTATUS* ft, const PROTOCHAR* s, TCHAR *r);
static HANDLE hSRFileMenuItem;
diff --git a/src/core/stdfile/fileexistsdlg.cpp b/src/core/stdfile/fileexistsdlg.cpp
index c0592c8b39..5a66611237 100644
--- a/src/core/stdfile/fileexistsdlg.cpp
+++ b/src/core/stdfile/fileexistsdlg.cpp
@@ -248,7 +248,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
{
TCHAR szFile[MAX_PATH];
lstrcpyn(szFile, fts->tszCurrentFile, SIZEOF(szFile));
- TCHAR* pszLastBackslash = _tcsrchr(szFile, '\\');
+ TCHAR *pszLastBackslash = _tcsrchr(szFile, '\\');
if (pszLastBackslash)
*pszLastBackslash = '\0';
ShellExecute(hwndDlg, NULL, szFile, NULL, NULL, SW_SHOW);
diff --git a/src/core/stdfile/filerecvdlg.cpp b/src/core/stdfile/filerecvdlg.cpp
index 31d534e232..6b4ce2e743 100644
--- a/src/core/stdfile/filerecvdlg.cpp
+++ b/src/core/stdfile/filerecvdlg.cpp
@@ -111,14 +111,14 @@ static REPLACEVARSARRAY sttVarsToReplace[] =
{ NULL, NULL }
};
-static void patchDir(TCHAR* str, size_t strSize)
+static void patchDir(TCHAR *str, size_t strSize)
{
REPLACEVARSDATA dat = { 0 };
dat.cbSize = sizeof(dat);
dat.dwFlags = RVF_TCHAR;
dat.variables = sttVarsToReplace;
- TCHAR* result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)str, (LPARAM)&dat);
+ TCHAR *result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)str, (LPARAM)&dat);
if (result) {
_tcsncpy(str, result, strSize);
mir_free(result);
@@ -164,7 +164,7 @@ void GetContactReceivedFilesDir(HANDLE hContact, TCHAR *szDir, int cchDir, BOOL
dat.dwFlags = RVF_TCHAR;
dat.variables = rvaVarsToReplace;
dat.hContact = hContact;
- TCHAR* result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)szTemp, (LPARAM)&dat);
+ TCHAR *result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)szTemp, (LPARAM)&dat);
if (result) {
_tcsncpy(szTemp, result, SIZEOF(szTemp));
mir_free(result);
@@ -206,73 +206,74 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
dat = (struct FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
- case WM_INITDIALOG: {
- TCHAR *contactName;
- TCHAR szPath[450];
- CLISTEVENT* cle = (CLISTEVENT*)lParam;
-
+ case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
-
- dat = (struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData));
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
- dat->hContact = cle->hContact;
- dat->hDbEvent = cle->hDbEvent;
- dat->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN);
- dat->dwTicks = GetTickCount();
-
- EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0);
-
- Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE);
- Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add Contact Permanently to List"));
- Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View User's Details"));
- Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View User's History"));
- Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User Menu"));
-
- contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
- SetDlgItemText(hwndDlg, IDC_FROM, contactName);
- GetContactReceivedFilesDir(dat->hContact, szPath, SIZEOF(szPath), TRUE);
- SetDlgItemText(hwndDlg, IDC_FILEDIR, szPath);
{
- int i;
- char idstr[32];
- DBVARIANT dbv;
+ TCHAR szPath[450];
+ CLISTEVENT* cle = (CLISTEVENT*)lParam;
+
+
+ dat = (struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData));
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
+ dat->hContact = cle->hContact;
+ dat->hDbEvent = cle->hDbEvent;
+ dat->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN);
+ dat->dwTicks = GetTickCount();
+
+ EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0);
+
+ Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE);
+ Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add Contact Permanently to List"));
+ Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View User's Details"));
+ Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View User's History"));
+ Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User Menu"));
+ TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
+ SetDlgItemText(hwndDlg, IDC_FROM, contactName);
+ GetContactReceivedFilesDir(dat->hContact, szPath, SIZEOF(szPath), TRUE);
+ SetDlgItemText(hwndDlg, IDC_FILEDIR, szPath);
if (shAutoComplete)
shAutoComplete(GetWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), GW_CHILD), 1);
- for (i=0;i<MAX_MRU_DIRS;i++) {
+ for (int i=0; i < MAX_MRU_DIRS; i++) {
+ char idstr[32];
mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i);
- if (DBGetContactSettingTString(NULL, "SRFile", idstr, &dbv)) break;
+
+ DBVARIANT dbv;
+ if (DBGetContactSettingTString(NULL, "SRFile", idstr, &dbv))
+ break;
SendDlgItemMessage(hwndDlg, IDC_FILEDIR, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal);
DBFreeVariant(&dbv);
}
- }
- CallService(MS_DB_EVENT_MARKREAD, (WPARAM)dat->hContact, (LPARAM)dat->hDbEvent);
- {
- DBEVENTINFO dbei = {0};
- TCHAR datetimestr[64];
- char buf[540];
+ CallService(MS_DB_EVENT_MARKREAD, (WPARAM)dat->hContact, (LPARAM)dat->hDbEvent);
+ DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)dat->hDbEvent, 0);
- dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
- CallService(MS_DB_EVENT_GET, (WPARAM)dat->hDbEvent, (LPARAM)&dbei);
- dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob;
- lstrcpynA(buf, (char*)dbei.pBlob+4, min(dbei.cbBlob+1, SIZEOF(buf)));
- TCHAR* ptszFileName = DbGetEventStringT(&dbei, buf);
- SetDlgItemText(hwndDlg, IDC_FILENAMES, ptszFileName);
- mir_free(ptszFileName);
- lstrcpynA(buf, (char*)dbei.pBlob+4+strlen((char*)dbei.pBlob+4)+1, min((int)(dbei.cbBlob-4-strlen((char*)dbei.pBlob+4)), SIZEOF(buf)));
- TCHAR* ptszDescription = DbGetEventStringT(&dbei, buf);
- SetDlgItemText(hwndDlg, IDC_MSG, ptszDescription);
- mir_free(ptszDescription);
- mir_free(dbei.pBlob);
+ if (dbei.cbBlob > 4 && dbei.cbBlob <= 8196) {
+ dbei.pBlob = (PBYTE)alloca(dbei.cbBlob + 1);
+ CallService(MS_DB_EVENT_GET, (WPARAM)dat->hDbEvent, (LPARAM)&dbei);
+ dbei.pBlob[dbei.cbBlob] = 0;
+ dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob;
+
+ char *str = (char*)dbei.pBlob + 4;
+ mir_ptr<TCHAR> ptszFileName( DbGetEventStringT(&dbei, str));
+ SetDlgItemText(hwndDlg, IDC_FILENAMES, ptszFileName);
+
+ unsigned len = (unsigned)strlen(str) + 1;
+ if (len + 4 < dbei.cbBlob) {
+ str += len;
+ mir_ptr<TCHAR> ptszDescription( DbGetEventStringT(&dbei, str));
+ SetDlgItemText(hwndDlg, IDC_MSG, ptszDescription);
+ }
+ }
+ else DestroyWindow(hwndDlg);
+ TCHAR datetimestr[64];
tmi.printTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, SIZEOF(datetimestr), 0);
SetDlgItemText(hwndDlg, IDC_DATE, datetimestr);
- }
- {
+
char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0);
if (szProto) {
int hasName = 0;
@@ -299,23 +300,23 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
SetDlgItemTextA(hwndDlg, IDC_NAME, buf);
else
SetDlgItemText(hwndDlg, IDC_NAME, contactName);
- } }
-
- if (DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) {
- RECT rcBtn1, rcBtn2, rcDateCtrl;
- GetWindowRect(GetDlgItem(hwndDlg, IDC_ADD), &rcBtn1);
- GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rcBtn2);
- GetWindowRect(GetDlgItem(hwndDlg, IDC_DATE), &rcDateCtrl);
- SetWindowPos(GetDlgItem(hwndDlg, IDC_DATE), 0, 0, 0, rcDateCtrl.right-rcDateCtrl.left-(rcBtn2.left-rcBtn1.left), rcDateCtrl.bottom-rcDateCtrl.top, SWP_NOZORDER|SWP_NOMOVE);
- }
- else if (DBGetContactSettingByte(NULL, "SRFile", "AutoAccept", 0)) {
- //don't check auto-min here to fix BUG#647620
- PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK));
+ }
+
+ if (DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) {
+ RECT rcBtn1, rcBtn2, rcDateCtrl;
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_ADD), &rcBtn1);
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rcBtn2);
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_DATE), &rcDateCtrl);
+ SetWindowPos(GetDlgItem(hwndDlg, IDC_DATE), 0, 0, 0, rcDateCtrl.right-rcDateCtrl.left-(rcBtn2.left-rcBtn1.left), rcDateCtrl.bottom-rcDateCtrl.top, SWP_NOZORDER|SWP_NOMOVE);
+ }
+ else if (DBGetContactSettingByte(NULL, "SRFile", "AutoAccept", 0)) {
+ //don't check auto-min here to fix BUG#647620
+ PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK));
+ }
+ if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0))
+ ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE);
}
- if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0))
- ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE);
return TRUE;
- }
case WM_MEASUREITEM:
return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
diff --git a/src/core/stdfile/filesenddlg.cpp b/src/core/stdfile/filesenddlg.cpp
index 3551078176..642e2fd950 100644
--- a/src/core/stdfile/filesenddlg.cpp
+++ b/src/core/stdfile/filesenddlg.cpp
@@ -63,7 +63,7 @@ static void SetFileListAndSizeControls(HWND hwndDlg, struct FileDlgData *dat)
EnableWindow(GetDlgItem(hwndDlg, IDOK), fileCount || dirCount);
}
-static void FilenameToFileList(HWND hwndDlg, struct FileDlgData* dat, const TCHAR* buf)
+static void FilenameToFileList(HWND hwndDlg, struct FileDlgData* dat, const TCHAR *buf)
{
DWORD dwFileAttributes;
@@ -77,7 +77,7 @@ static void FilenameToFileList(HWND hwndDlg, struct FileDlgData* dat, const TCHA
// Check if the selection is a directory or a file
if (GetFileAttributes(buf) & FILE_ATTRIBUTE_DIRECTORY) {
- const TCHAR* pBuf;
+ const TCHAR *pBuf;
int nNumberOfFiles = 0;
int nTemp;
int fileOffset;
@@ -96,7 +96,7 @@ static void FilenameToFileList(HWND hwndDlg, struct FileDlgData* dat, const TCHA
}
// Allocate memory for a pointer array
- if ((dat->files = (TCHAR* *)mir_alloc((nNumberOfFiles + 1) * sizeof(TCHAR*))) == NULL)
+ if ((dat->files = (TCHAR**)mir_alloc((nNumberOfFiles + 1) * sizeof(TCHAR*))) == NULL)
return;
// Fill the array
@@ -139,7 +139,7 @@ void __cdecl ChooseFilesThread(void* param)
{
HWND hwndDlg = (HWND)param;
TCHAR filter[128], *pfilter;
- TCHAR* buf = (TCHAR*)mir_alloc(sizeof(TCHAR)*32767);
+ TCHAR *buf = (TCHAR*)mir_alloc(sizeof(TCHAR)*32767);
if (buf == NULL)
PostMessage(hwndDlg, M_FILECHOOSEDONE, 0, (LPARAM)(TCHAR*)NULL);
else {
@@ -228,11 +228,10 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
SetFileListAndSizeControls(hwndDlg, dat);
}
{
- char *szProto;
- TCHAR* contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
+ TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
SetDlgItemText(hwndDlg, IDC_TO, contactName);
- szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0);
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0);
if (szProto) {
CONTACTINFO ci;
int hasName = 0;
diff --git a/src/core/stdfile/filexferdlg.cpp b/src/core/stdfile/filexferdlg.cpp
index 09b2807201..306c0cd457 100644
--- a/src/core/stdfile/filexferdlg.cpp
+++ b/src/core/stdfile/filexferdlg.cpp
@@ -52,10 +52,10 @@ TCHAR* PFTS_StringToTchar(int flags, const PROTOCHAR* s)
return mir_a2t((char*)s);
}
-int PFTS_CompareWithTchar(PROTOFILETRANSFERSTATUS* ft, const PROTOCHAR* s, TCHAR* r)
+int PFTS_CompareWithTchar(PROTOFILETRANSFERSTATUS* ft, const PROTOCHAR* s, TCHAR *r)
{
if (ft->flags & PFTS_UTF) {
- TCHAR* ts = Utf8DecodeW((char*)s);
+ TCHAR *ts = Utf8DecodeW((char*)s);
int res = _tcscmp(ts, r);
mir_free(ts);
return res;
@@ -63,7 +63,7 @@ int PFTS_CompareWithTchar(PROTOFILETRANSFERSTATUS* ft, const PROTOCHAR* s, TCHAR
else if (ft->flags & PFTS_UNICODE)
return _tcscmp(s, r);
else {
- TCHAR* ts = mir_a2t((char*)s);
+ TCHAR *ts = mir_a2t((char*)s);
int res = _tcscmp(ts, r);
mir_free(ts);
return res;
@@ -376,11 +376,11 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case IDC_OPENFOLDER:
if (dat)
{
- TCHAR* path = dat->transferStatus.tszWorkingDir;
+ TCHAR *path = dat->transferStatus.tszWorkingDir;
if ( !path || !path[0])
{
path = NEWTSTR_ALLOCA(dat->transferStatus.tszCurrentFile);
- TCHAR* p = _tcsrchr(path, '\\'); if (p) *p = 0;
+ TCHAR *p = _tcsrchr(path, '\\'); if (p) *p = 0;
}
if (path) ShellExecute(NULL, _T("open"), path, NULL, NULL, SW_SHOW);
@@ -450,11 +450,11 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (ret == 1)
{
- TCHAR* path = dat->transferStatus.tszWorkingDir;
+ TCHAR *path = dat->transferStatus.tszWorkingDir;
if ( !path || !path[0])
{
path = NEWTSTR_ALLOCA(dat->transferStatus.tszCurrentFile);
- TCHAR* p = _tcsrchr(path, '\\'); if (p) *p = 0;
+ TCHAR *p = _tcsrchr(path, '\\'); if (p) *p = 0;
}
if (path) ShellExecute(NULL, _T("open"), path, NULL, NULL, SW_SHOW);