From e58823d961a630eb62e60d2ccb443761ba5f1704 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 14 Jun 2012 15:51:34 +0000 Subject: - all MS_CLIST_ADD*ITEM services replaced with Menu_Add*Item stubs. - massive cleanup of the menu-related code git-svn-id: http://svn.miranda-ng.org/main/trunk@410 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/srfile/file.cpp | 94 +++++++++--------- src/modules/srfile/file.h | 20 ++-- src/modules/srfile/fileexistsdlg.cpp | 128 ++++++++++++------------ src/modules/srfile/fileopts.cpp | 118 +++++++++++----------- src/modules/srfile/filerecvdlg.cpp | 186 +++++++++++++++++------------------ src/modules/srfile/filesenddlg.cpp | 118 +++++++++++----------- src/modules/srfile/filexferdlg.cpp | 166 +++++++++++++++---------------- src/modules/srfile/ftmanager.cpp | 8 +- 8 files changed, 419 insertions(+), 419 deletions(-) (limited to 'src/modules/srfile') diff --git a/src/modules/srfile/file.cpp b/src/modules/srfile/file.cpp index 6073dd7a8a..3a39014162 100644 --- a/src/modules/srfile/file.cpp +++ b/src/modules/srfile/file.cpp @@ -2,7 +2,7 @@ Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, +Copyright 2000-2009 Miranda ICQ/IM project, all portions of this codebase are copyrighted to the people listed in contributors.txt. @@ -11,7 +11,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -33,11 +33,11 @@ static INT_PTR SendFileCommand(WPARAM wParam, LPARAM) struct FileSendData fsd; fsd.hContact=(HANDLE)wParam; fsd.ppFiles=NULL; - CreateDialogParam(hMirandaInst,MAKEINTRESOURCE(IDD_FILESEND),NULL,DlgProcSendFile,(LPARAM)&fsd); + CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd); return 0; } -static INT_PTR SendSpecificFiles(WPARAM wParam,LPARAM lParam) +static INT_PTR SendSpecificFiles(WPARAM wParam, LPARAM lParam) { FileSendData fsd; fsd.hContact=(HANDLE)wParam; @@ -54,7 +54,7 @@ static INT_PTR SendSpecificFiles(WPARAM wParam,LPARAM lParam) #else fsd.ppFiles=(const char**)lParam; #endif - CreateDialogParam(hMirandaInst,MAKEINTRESOURCE(IDD_FILESEND),NULL,DlgProcSendFile,(LPARAM)&fsd); + CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd); #if defined( _UNICODE ) for ( int j=0; j < count; j++ ) mir_free(( void* )fsd.ppFiles[j] ); @@ -62,28 +62,28 @@ static INT_PTR SendSpecificFiles(WPARAM wParam,LPARAM lParam) return 0; } -static INT_PTR SendSpecificFilesT(WPARAM wParam,LPARAM lParam) +static INT_PTR SendSpecificFilesT(WPARAM wParam, LPARAM lParam) { FileSendData fsd; fsd.hContact=(HANDLE)wParam; fsd.ppFiles=(const TCHAR**)lParam; - CreateDialogParam(hMirandaInst,MAKEINTRESOURCE(IDD_FILESEND),NULL,DlgProcSendFile,(LPARAM)&fsd); + CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd); return 0; } -static INT_PTR GetReceivedFilesFolder(WPARAM wParam,LPARAM lParam) +static INT_PTR GetReceivedFilesFolder(WPARAM wParam, LPARAM lParam) { TCHAR buf[MAX_PATH]; - GetContactReceivedFilesDir((HANDLE)wParam,buf,MAX_PATH,TRUE); + GetContactReceivedFilesDir((HANDLE)wParam, buf, MAX_PATH, TRUE); char* dir = mir_t2a(buf); - lstrcpynA((char*)lParam,dir,MAX_PATH); + lstrcpynA((char*)lParam, dir, MAX_PATH); mir_free(dir); return 0; } static INT_PTR RecvFileCommand(WPARAM, LPARAM lParam) { - CreateDialogParam(hMirandaInst,MAKEINTRESOURCE(IDD_FILERECV),NULL,DlgProcRecvFile,lParam); + CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILERECV), NULL, DlgProcRecvFile, lParam); return 0; } @@ -94,23 +94,23 @@ void PushFileEvent( HANDLE hContact, HANDLE hdbe, LPARAM lParam ) cle.hContact = hContact; cle.hDbEvent = hdbe; cle.lParam = lParam; - if ( DBGetContactSettingByte(NULL,"SRFile","AutoAccept",0) && !DBGetContactSettingByte(hContact,"CList","NotOnList",0)) { - CreateDialogParam(hMirandaInst,MAKEINTRESOURCE(IDD_FILERECV),NULL,DlgProcRecvFile,(LPARAM)&cle); + if ( DBGetContactSettingByte(NULL, "SRFile", "AutoAccept", 0) && !DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)) { + CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILERECV), NULL, DlgProcRecvFile, (LPARAM)&cle); } else { SkinPlaySound("RecvFile"); TCHAR szTooltip[256]; - mir_sntprintf(szTooltip,SIZEOF(szTooltip),TranslateT("File from %s"), cli.pfnGetContactDisplayName( hContact, 0 )); + mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("File from %s"), cli.pfnGetContactDisplayName( hContact, 0 )); cle.ptszTooltip = szTooltip; cle.flags |= CLEF_TCHAR; cle.hIcon = LoadSkinIcon( SKINICON_EVENT_FILE ); cle.pszService = "SRFile/RecvFile"; - CallService(MS_CLIST_ADDEVENT,0,(LPARAM)&cle); + CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); } } -static int FileEventAdded(WPARAM wParam,LPARAM lParam) +static int FileEventAdded(WPARAM wParam, LPARAM lParam) { DWORD dwSignature; @@ -126,15 +126,15 @@ static int FileEventAdded(WPARAM wParam,LPARAM lParam) return 0; } -int SRFile_GetRegValue(HKEY hKeyBase,const TCHAR *szSubKey,const TCHAR *szValue,TCHAR *szOutput,int cbOutput) +int SRFile_GetRegValue(HKEY hKeyBase, const TCHAR *szSubKey, const TCHAR *szValue, TCHAR *szOutput, int cbOutput) { HKEY hKey; DWORD cbOut=cbOutput; - if ( RegOpenKeyEx( hKeyBase,szSubKey,0,KEY_QUERY_VALUE,&hKey ) != ERROR_SUCCESS) + 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, NULL, NULL, (PBYTE)szOutput, &cbOut ) != ERROR_SUCCESS ) { RegCloseKey(hKey); return 0; } @@ -143,7 +143,7 @@ int SRFile_GetRegValue(HKEY hKeyBase,const TCHAR *szSubKey,const TCHAR *szValue, return 1; } -void GetSensiblyFormattedSize(__int64 size,TCHAR *szOut,int cchOut,int unitsOverride,int appendUnits,int *unitsUsed) +void GetSensiblyFormattedSize(__int64 size, TCHAR *szOut, int cchOut, int unitsOverride, int appendUnits, int *unitsUsed) { if (!unitsOverride) { if (size<1000) unitsOverride=UNITS_BYTES; @@ -154,11 +154,11 @@ void GetSensiblyFormattedSize(__int64 size,TCHAR *szOut,int cchOut,int unitsOver } if (unitsUsed) *unitsUsed=unitsOverride; switch(unitsOverride) { - case UNITS_BYTES: mir_sntprintf(szOut,cchOut,_T("%u%s%s"),(int)size,appendUnits?_T(" "):_T(""),appendUnits?TranslateT("bytes"):_T("")); break; - case UNITS_KBPOINT1: mir_sntprintf(szOut,cchOut,_T("%.1lf%s"),size/1024.0,appendUnits?_T(" KB"):_T("")); break; - case UNITS_KBPOINT0: mir_sntprintf(szOut,cchOut,_T("%u%s"),(int)(size/1024),appendUnits?_T(" KB"):_T("")); break; - case UNITS_GBPOINT3: mir_sntprintf(szOut,cchOut,_T("%.3f%s"),(size >> 20)/1024.0,appendUnits?_T(" GB"):_T("")); break; - default: mir_sntprintf(szOut,cchOut,_T("%.2lf%s"),size/1048576.0,appendUnits?_T(" MB"):_T("")); break; + case UNITS_BYTES: mir_sntprintf(szOut, cchOut, _T("%u%s%s"), (int)size, appendUnits?_T(" "):_T(""), appendUnits?TranslateT("bytes"):_T("")); break; + case UNITS_KBPOINT1: mir_sntprintf(szOut, cchOut, _T("%.1lf%s"), size/1024.0, appendUnits?_T(" KB"):_T("")); break; + case UNITS_KBPOINT0: mir_sntprintf(szOut, cchOut, _T("%u%s"), (int)(size/1024), appendUnits?_T(" KB"):_T("")); break; + case UNITS_GBPOINT3: mir_sntprintf(szOut, cchOut, _T("%.3f%s"), (size >> 20)/1024.0, appendUnits?_T(" GB"):_T("")); break; + default: mir_sntprintf(szOut, cchOut, _T("%.2lf%s"), size/1048576.0, appendUnits?_T(" MB"):_T("")); break; } } @@ -263,20 +263,20 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS static void RemoveUnreadFileEvents(void) { DBEVENTINFO dbei={0}; - HANDLE hDbEvent,hContact; + HANDLE hDbEvent, hContact; dbei.cbSize=sizeof(dbei); - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); + hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); while (hContact) { - hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD,(WPARAM)hContact,0); + hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0); while (hDbEvent) { dbei.cbBlob=0; - CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei); + CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); if (!(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType == EVENTTYPE_FILE) - CallService(MS_DB_EVENT_MARKREAD,(WPARAM)hContact,(LPARAM)hDbEvent); - hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDNEXT,(WPARAM)hDbEvent,0); + CallService(MS_DB_EVENT_MARKREAD, (WPARAM)hContact, (LPARAM)hDbEvent); + hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0); } - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0); + hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); } } @@ -288,8 +288,8 @@ static int SRFilePreBuildMenu(WPARAM wParam, LPARAM) char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); if (szProto != NULL) { - if ( CallProtoService(szProto, PS_GETCAPS,PFLAGNUM_1, 0 ) & PF1_FILESEND) { - if ( CallProtoService(szProto, PS_GETCAPS,PFLAGNUM_4, 0 ) & PF4_OFFLINEFILES ) + if ( CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0 ) & PF1_FILESEND) { + if ( CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0 ) & PF4_OFFLINEFILES ) mi.flags = CMIM_FLAGS; else if ( DBGetContactSettingWord(( HANDLE )wParam, szProto, "Status", ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE ) mi.flags = CMIM_FLAGS; @@ -308,7 +308,7 @@ static int SRFileModulesLoaded(WPARAM, LPARAM) mi.pszName = LPGEN("&File"); mi.pszService = MS_FILE_SENDFILE; mi.flags = CMIF_ICONFROMICOLIB; - hSRFileMenuItem = ( HANDLE )CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&mi); + hSRFileMenuItem = Menu_AddContactMenuItem(&mi); RemoveUnreadFileEvents(); return 0; @@ -324,7 +324,7 @@ INT_PTR openContRecDir(WPARAM wparam, LPARAM) { TCHAR szContRecDir[MAX_PATH]; HANDLE hContact = (HANDLE)wparam; - GetContactReceivedFilesDir(hContact, szContRecDir, SIZEOF(szContRecDir),TRUE); + GetContactReceivedFilesDir(hContact, szContRecDir, SIZEOF(szContRecDir), TRUE); ShellExecute(0, _T("open"), szContRecDir, 0, 0, SW_SHOW); return 0; } @@ -348,21 +348,21 @@ int LoadSendRecvFileModule(void) mi.position = 1900000000; mi.pszName = LPGEN("File &Transfers..."); mi.pszService = "FtMgr/Show"; //MS_PROTO_SHOWFTMGR; - CallService( MS_CLIST_ADDMAINMENUITEM, 0, ( LPARAM )&mi ); + Menu_AddMainMenuItem(&mi); - HookEvent(ME_SYSTEM_MODULESLOADED,SRFileModulesLoaded); - HookEvent(ME_DB_EVENT_ADDED,FileEventAdded); - HookEvent(ME_OPT_INITIALISE,FileOptInitialise); + HookEvent(ME_SYSTEM_MODULESLOADED, SRFileModulesLoaded); + HookEvent(ME_DB_EVENT_ADDED, FileEventAdded); + HookEvent(ME_OPT_INITIALISE, FileOptInitialise); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, SRFilePreBuildMenu); - CreateServiceFunction(MS_FILE_SENDFILE,SendFileCommand); - CreateServiceFunction(MS_FILE_SENDSPECIFICFILES,SendSpecificFiles); - CreateServiceFunction(MS_FILE_SENDSPECIFICFILEST,SendSpecificFilesT); - CreateServiceFunction(MS_FILE_GETRECEIVEDFILESFOLDER,GetReceivedFilesFolder); - CreateServiceFunction("SRFile/RecvFile",RecvFileCommand); + CreateServiceFunction(MS_FILE_SENDFILE, SendFileCommand); + CreateServiceFunction(MS_FILE_SENDSPECIFICFILES, SendSpecificFiles); + CreateServiceFunction(MS_FILE_SENDSPECIFICFILEST, SendSpecificFilesT); + CreateServiceFunction(MS_FILE_GETRECEIVEDFILESFOLDER, GetReceivedFilesFolder); + CreateServiceFunction("SRFile/RecvFile", RecvFileCommand); - CreateServiceFunction("SRFile/OpenContRecDir",openContRecDir); - CreateServiceFunction("SRFile/OpenRecDir",openRecDir); + CreateServiceFunction("SRFile/OpenContRecDir", openContRecDir); + CreateServiceFunction("SRFile/OpenRecDir", openRecDir); SkinAddNewSoundEx("RecvFile", "File", "Incoming"); SkinAddNewSoundEx("FileDone", "File", "Complete"); diff --git a/src/modules/srfile/file.h b/src/modules/srfile/file.h index 8ee9048eb9..f4e9a63336 100644 --- a/src/modules/srfile/file.h +++ b/src/modules/srfile/file.h @@ -11,7 +11,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define VIRUSSCAN_DURINGDL 2 #define FILERESUME_ASK 0 -//1,2,3,4: resume, overwrite, rename, skip: from proto library +//1, 2, 3, 4: resume, overwrite, rename, skip: from proto library #define FILERESUMEF_ALL 0x80 #define FILERESUME_RESUMEALL (FILERESUME_RESUME|FILERESUMEF_ALL) #define FILERESUME_OVERWRITEALL (FILERESUME_OVERWRITE|FILERESUMEF_ALL) @@ -72,21 +72,21 @@ struct FileDlgData { #define UNITS_MBPOINT2 4 // 1024*1024<=size: "%.2f MB" #define UNITS_GBPOINT3 5 // 1024*1024*1024<=size: "%.3f GB" -void GetSensiblyFormattedSize(__int64 size,TCHAR *szOut,int cchOut,int unitsOverride,int appendUnits,int *unitsUsed); +void GetSensiblyFormattedSize(__int64 size, TCHAR *szOut, int cchOut, int unitsOverride, int appendUnits, int *unitsUsed); void FreeFilesMatrix(TCHAR ***files); //loving that triple indirection void FreeProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *fts); -void CopyProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest,PROTOFILETRANSFERSTATUS *src); -void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest,PROTOFILETRANSFERSTATUS *src); -int SRFile_GetRegValue(HKEY hKeyBase,const TCHAR *szSubKey,const TCHAR *szValue,TCHAR *szOutput,int cbOutput); +void CopyProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANSFERSTATUS *src); +void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANSFERSTATUS *src); +int SRFile_GetRegValue(HKEY hKeyBase, const TCHAR *szSubKey, const TCHAR *szValue, TCHAR *szOutput, int cbOutput); //filesenddlg.c INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); //filerecv.c INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); void RemoveInvalidFilenameChars(TCHAR *tszString); void RemoveInvalidPathChars(TCHAR *tszString); -void GetContactReceivedFilesDir(HANDLE hContact,TCHAR *szDir,int cchDir,BOOL substVars); -void GetReceivedFilesDir(TCHAR *szDir,int cchDir); -int BrowseForFolder(HWND hwnd,TCHAR *szPath); +void GetContactReceivedFilesDir(HANDLE hContact, TCHAR *szDir, int cchDir, BOOL substVars); +void GetReceivedFilesDir(TCHAR *szDir, int cchDir); +int BrowseForFolder(HWND hwnd, TCHAR *szPath); //fileexistsdlg.c struct TDlgProcFileExistsParam { @@ -97,7 +97,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM //filexferdlg.c INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); //fileopts.c -int FileOptInitialise(WPARAM wParam,LPARAM lParam); +int FileOptInitialise(WPARAM wParam, LPARAM lParam); //ftmanager.c #define WM_FT_ADD (WM_USER+701) #define WM_FT_RESIZE (WM_USER+702) diff --git a/src/modules/srfile/fileexistsdlg.cpp b/src/modules/srfile/fileexistsdlg.cpp index 23bc8b0877..a6b5dfd3c2 100644 --- a/src/modules/srfile/fileexistsdlg.cpp +++ b/src/modules/srfile/fileexistsdlg.cpp @@ -11,7 +11,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -31,16 +31,16 @@ static void SetControlToUnixTime(HWND hwndDlg, UINT idCtrl, time_t unixTime) LARGE_INTEGER liFiletime; FILETIME filetime; SYSTEMTIME st; - char szTime[64],szDate[64],szOutput[128]; + char szTime[64], szDate[64], szOutput[128]; liFiletime.QuadPart=(BIGI(11644473600)+(__int64)unixTime)*10000000; filetime.dwHighDateTime=liFiletime.HighPart; filetime.dwLowDateTime=liFiletime.LowPart; - FileTimeToSystemTime(&filetime,&st); - GetTimeFormatA(LOCALE_USER_DEFAULT,0,&st,NULL,szTime,SIZEOF(szTime)); - GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&st,NULL,szDate,SIZEOF(szDate)); - mir_snprintf(szOutput, SIZEOF(szOutput), "%s %s",szDate,szTime); - SetDlgItemTextA(hwndDlg,idCtrl,szOutput); + FileTimeToSystemTime(&filetime, &st); + GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, szTime, SIZEOF(szTime)); + GetDateFormatA(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, szDate, SIZEOF(szDate)); + mir_snprintf(szOutput, SIZEOF(szOutput), "%s %s", szDate, szTime); + SetDlgItemTextA(hwndDlg, idCtrl, szOutput); } #define C_CONTEXTMENU 0 @@ -49,7 +49,7 @@ static void SetControlToUnixTime(HWND hwndDlg, UINT idCtrl, time_t unixTime) #ifndef CMF_EXTENDEDVERBS #define CMF_EXTENDEDVERBS 0x00000100 #endif -static void DoAnnoyingShellCommand(HWND hwnd,const TCHAR *szFilename,int cmd,POINT *ptCursor) +static void DoAnnoyingShellCommand(HWND hwnd, const TCHAR *szFilename, int cmd, POINT *ptCursor) { IShellFolder *pDesktopFolder; if (SHGetDesktopFolder(&pDesktopFolder) == NOERROR) { @@ -58,26 +58,26 @@ static void DoAnnoyingShellCommand(HWND hwnd,const TCHAR *szFilename,int cmd,POI WCHAR* wszFilename = ( LPWSTR )szFilename; #else WCHAR wszFilename[MAX_PATH]; - MultiByteToWideChar(CP_ACP,0,szFilename,-1,wszFilename,SIZEOF(wszFilename)); + MultiByteToWideChar(CP_ACP, 0, szFilename, -1, wszFilename, SIZEOF(wszFilename)); #endif - if (pDesktopFolder->ParseDisplayName(NULL,NULL,wszFilename,NULL,&pCurrentIdl,NULL) == NOERROR) { + if (pDesktopFolder->ParseDisplayName(NULL, NULL, wszFilename, NULL, &pCurrentIdl, NULL) == NOERROR) { if (pCurrentIdl->mkid.cb) { - ITEMIDLIST *pidl,*pidlNext,*pidlFilename; + ITEMIDLIST *pidl, *pidlNext, *pidlFilename; IShellFolder *pFileFolder; for (pidl=pCurrentIdl;;) { pidlNext=(ITEMIDLIST*)((PBYTE)pidl+pidl->mkid.cb); if (pidlNext->mkid.cb == 0) { pidlFilename = (ITEMIDLIST*)CoTaskMemAlloc(pidl->mkid.cb+sizeof(pidl->mkid.cb)); - CopyMemory(pidlFilename,pidl,pidl->mkid.cb+sizeof(pidl->mkid.cb)); + CopyMemory(pidlFilename, pidl, pidl->mkid.cb+sizeof(pidl->mkid.cb)); pidl->mkid.cb=0; break; } pidl=pidlNext; } - if (pDesktopFolder->BindToObject(pCurrentIdl,NULL,IID_IShellFolder,(void**)&pFileFolder) == NOERROR) { + if (pDesktopFolder->BindToObject(pCurrentIdl, NULL, IID_IShellFolder, (void**)&pFileFolder) == NOERROR) { IContextMenu *pContextMenu; - if (pFileFolder->GetUIObjectOf(NULL,1,(LPCITEMIDLIST*)&pidlFilename,IID_IContextMenu,NULL,(void**)&pContextMenu) == NOERROR) { + if (pFileFolder->GetUIObjectOf(NULL, 1, (LPCITEMIDLIST*)&pidlFilename, IID_IContextMenu, NULL, (void**)&pContextMenu) == NOERROR) { switch(cmd) { case C_PROPERTIES: { CMINVOKECOMMANDINFO ici={0}; @@ -91,9 +91,9 @@ static void DoAnnoyingShellCommand(HWND hwnd,const TCHAR *szFilename,int cmd,POI case C_CONTEXTMENU: { HMENU hMenu; hMenu=CreatePopupMenu(); - if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu,0,1000,65535,(GetKeyState(VK_SHIFT)&0x8000?CMF_EXTENDEDVERBS:0)|CMF_NORMAL))) { + if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu, 0, 1000, 65535, (GetKeyState(VK_SHIFT)&0x8000?CMF_EXTENDEDVERBS:0)|CMF_NORMAL))) { int cmd; - cmd=TrackPopupMenu(hMenu,TPM_RETURNCMD,ptCursor->x,ptCursor->y,0,hwnd,NULL); + cmd=TrackPopupMenu(hMenu, TPM_RETURNCMD, ptCursor->x, ptCursor->y, 0, hwnd, NULL); if (cmd) { CMINVOKECOMMANDINFO ici={0}; ici.cbSize=sizeof(ici); @@ -122,11 +122,11 @@ static void DoAnnoyingShellCommand(HWND hwnd,const TCHAR *szFilename,int cmd,POI static WNDPROC pfnIconWindowProc; static LRESULT CALLBACK IconCtrlSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - PROTOFILETRANSFERSTATUS* pft = (PROTOFILETRANSFERSTATUS*)GetWindowLongPtr(GetParent(hwnd),GWLP_USERDATA); + PROTOFILETRANSFERSTATUS* pft = (PROTOFILETRANSFERSTATUS*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA); switch(msg) { case WM_LBUTTONDBLCLK: - ShellExecute(hwnd,NULL,pft->tszCurrentFile,NULL,NULL,SW_SHOW); + ShellExecute(hwnd, NULL, pft->tszCurrentFile, NULL, NULL, SW_SHOW); break; case WM_RBUTTONUP: { POINT pt; @@ -136,7 +136,7 @@ static LRESULT CALLBACK IconCtrlSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return 0; } } - return CallWindowProc(pfnIconWindowProc,hwnd,msg,wParam,lParam); + return CallWindowProc(pfnIconWindowProc, hwnd, msg, wParam, lParam); } struct loadiconsstartinfo { @@ -148,12 +148,12 @@ void __cdecl LoadIconsAndTypesThread(void* param) loadiconsstartinfo *info = ( loadiconsstartinfo* )param; SHFILEINFO fileInfo; - if ( SHGetFileInfo( info->szFilename, 0, &fileInfo, sizeof(fileInfo),SHGFI_TYPENAME|SHGFI_ICON|SHGFI_LARGEICON)) { - TCHAR *pszExtension,*pszFilename; + if ( SHGetFileInfo( info->szFilename, 0, &fileInfo, sizeof(fileInfo), SHGFI_TYPENAME|SHGFI_ICON|SHGFI_LARGEICON)) { + TCHAR *pszExtension, *pszFilename; TCHAR szExtension[64]; TCHAR szIconFile[MAX_PATH]; - pszFilename = _tcsrchr(info->szFilename,'\\'); + pszFilename = _tcsrchr(info->szFilename, '\\'); if ( pszFilename == NULL ) pszFilename = info->szFilename; @@ -166,28 +166,28 @@ void __cdecl LoadIconsAndTypesThread(void* param) } CharUpper(szExtension); if ( fileInfo.szTypeName[0] == '\0' ) - mir_sntprintf( fileInfo.szTypeName, SIZEOF(fileInfo.szTypeName), TranslateT("%s File"),szExtension); - SetDlgItemText(info->hwndDlg,IDC_EXISTINGTYPE,fileInfo.szTypeName); - SetDlgItemText(info->hwndDlg,IDC_NEWTYPE,fileInfo.szTypeName); - SendDlgItemMessage(info->hwndDlg,IDC_EXISTINGICON,STM_SETICON,(WPARAM)fileInfo.hIcon,0); + mir_sntprintf( fileInfo.szTypeName, SIZEOF(fileInfo.szTypeName), TranslateT("%s File"), szExtension); + SetDlgItemText(info->hwndDlg, IDC_EXISTINGTYPE, fileInfo.szTypeName); + SetDlgItemText(info->hwndDlg, IDC_NEWTYPE, fileInfo.szTypeName); + SendDlgItemMessage(info->hwndDlg, IDC_EXISTINGICON, STM_SETICON, (WPARAM)fileInfo.hIcon, 0); szIconFile[0]='\0'; if ( !lstrcmp( szExtension, _T("EXE"))) { - SRFile_GetRegValue(HKEY_LOCAL_MACHINE,_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"),_T("2"),szIconFile,SIZEOF(szIconFile)); + SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("2"), szIconFile, SIZEOF(szIconFile)); } else { TCHAR szTypeName[MAX_PATH]; - if (SRFile_GetRegValue(HKEY_CLASSES_ROOT,pszExtension,NULL,szTypeName,SIZEOF(szTypeName))) { - lstrcat(szTypeName,_T("\\DefaultIcon")); - if (SRFile_GetRegValue(HKEY_CLASSES_ROOT,szTypeName,NULL,szIconFile,SIZEOF(szIconFile))) { + if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, pszExtension, NULL, szTypeName, SIZEOF(szTypeName))) { + lstrcat(szTypeName, _T("\\DefaultIcon")); + if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, szTypeName, NULL, szIconFile, SIZEOF(szIconFile))) { if ( _tcsstr( szIconFile, _T("%1"))) - SRFile_GetRegValue(HKEY_LOCAL_MACHINE,_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"),_T("0"),szIconFile,SIZEOF(szIconFile)); + SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("0"), szIconFile, SIZEOF(szIconFile)); else szIconFile[0]='\0'; } } } if ( szIconFile[0]) { int iconIndex; HICON hIcon; - TCHAR *pszComma = _tcsrchr(szIconFile,','); + TCHAR *pszComma = _tcsrchr(szIconFile, ', '); if ( pszComma == NULL ) iconIndex=0; else { @@ -197,7 +197,7 @@ void __cdecl LoadIconsAndTypesThread(void* param) if ( hIcon ) fileInfo.hIcon = hIcon; } - SendDlgItemMessage(info->hwndDlg,IDC_NEWICON,STM_SETICON,(WPARAM)fileInfo.hIcon,0); + SendDlgItemMessage(info->hwndDlg, IDC_NEWICON, STM_SETICON, (WPARAM)fileInfo.hIcon, 0); } mir_free(info->szFilename); mir_free(info); @@ -207,7 +207,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM { PROTOFILETRANSFERSTATUS *fts; - fts=(PROTOFILETRANSFERSTATUS*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); + fts=(PROTOFILETRANSFERSTATUS*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch(msg) { case WM_INITDIALOG: { @@ -216,37 +216,37 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM HWND hwndFocus; struct TDlgProcFileExistsParam *dat = (struct TDlgProcFileExistsParam *)lParam; - SetPropA(hwndDlg,"Miranda.Preshutdown",HookEventMessage(ME_SYSTEM_PRESHUTDOWN,hwndDlg,M_PRESHUTDOWN)); - SetPropA(hwndDlg,"Miranda.ParentWnd",dat->hwndParent); + SetPropA(hwndDlg, "Miranda.Preshutdown", HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN)); + SetPropA(hwndDlg, "Miranda.ParentWnd", dat->hwndParent); TranslateDialogDefault(hwndDlg); fts=(PROTOFILETRANSFERSTATUS*)mir_alloc(sizeof(PROTOFILETRANSFERSTATUS)); - CopyProtoFileTransferStatus(fts,dat->fts); - SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)fts); - SetDlgItemText(hwndDlg,IDC_FILENAME,fts->tszCurrentFile); - SetControlToUnixTime(hwndDlg,IDC_NEWDATE,fts->currentFileTime); - GetSensiblyFormattedSize(fts->currentFileSize,szSize,SIZEOF(szSize),0,1,NULL); - SetDlgItemText(hwndDlg,IDC_NEWSIZE,szSize); + CopyProtoFileTransferStatus(fts, dat->fts); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)fts); + SetDlgItemText(hwndDlg, IDC_FILENAME, fts->tszCurrentFile); + SetControlToUnixTime(hwndDlg, IDC_NEWDATE, fts->currentFileTime); + GetSensiblyFormattedSize(fts->currentFileSize, szSize, SIZEOF(szSize), 0, 1, NULL); + SetDlgItemText(hwndDlg, IDC_NEWSIZE, szSize); - pfnIconWindowProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_EXISTINGICON),GWLP_WNDPROC,(LONG_PTR)IconCtrlSubclassProc); + pfnIconWindowProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EXISTINGICON), GWLP_WNDPROC, (LONG_PTR)IconCtrlSubclassProc); - hwndFocus=GetDlgItem(hwndDlg,IDC_RESUME); - if ( _tstati64(fts->tszCurrentFile,&statbuf) == 0) { - SetControlToUnixTime(hwndDlg,IDC_EXISTINGDATE,statbuf.st_mtime); - GetSensiblyFormattedSize(statbuf.st_size,szSize,SIZEOF(szSize),0,1,NULL); - SetDlgItemText(hwndDlg,IDC_EXISTINGSIZE,szSize); + hwndFocus=GetDlgItem(hwndDlg, IDC_RESUME); + if ( _tstati64(fts->tszCurrentFile, &statbuf) == 0) { + SetControlToUnixTime(hwndDlg, IDC_EXISTINGDATE, statbuf.st_mtime); + GetSensiblyFormattedSize(statbuf.st_size, szSize, SIZEOF(szSize), 0, 1, NULL); + SetDlgItemText(hwndDlg, IDC_EXISTINGSIZE, szSize); if (statbuf.st_size>(int)fts->currentFileSize) { - EnableWindow(GetDlgItem(hwndDlg,IDC_RESUME),FALSE); - hwndFocus=GetDlgItem(hwndDlg,IDC_OVERWRITE); + EnableWindow(GetDlgItem(hwndDlg, IDC_RESUME), FALSE); + hwndFocus=GetDlgItem(hwndDlg, IDC_OVERWRITE); } } loadiconsstartinfo *lisi = ( loadiconsstartinfo* )mir_alloc(sizeof(loadiconsstartinfo)); lisi->hwndDlg=hwndDlg; lisi->szFilename = mir_tstrdup(fts->tszCurrentFile); //can be a little slow, so why not? - forkthread(LoadIconsAndTypesThread,0,lisi); + forkthread(LoadIconsAndTypesThread, 0, lisi); SetFocus(hwndFocus); - SetWindowLongPtr(hwndFocus,GWL_STYLE,GetWindowLongPtr(hwndFocus,GWL_STYLE)|BS_DEFPUSHBUTTON); + SetWindowLongPtr(hwndFocus, GWL_STYLE, GetWindowLongPtr(hwndFocus, GWL_STYLE)|BS_DEFPUSHBUTTON); return FALSE; } case WM_COMMAND: @@ -264,11 +264,11 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TCHAR* pszLastBackslash = _tcsrchr( szFile, '\\' ); if ( pszLastBackslash ) *pszLastBackslash = '\0'; - ShellExecute(hwndDlg,NULL,szFile,NULL,NULL,SW_SHOW); + ShellExecute(hwndDlg, NULL, szFile, NULL, NULL, SW_SHOW); return FALSE; } case IDC_PROPERTIES: - DoAnnoyingShellCommand(hwndDlg,fts->tszCurrentFile,C_PROPERTIES,NULL); + DoAnnoyingShellCommand(hwndDlg, fts->tszCurrentFile, C_PROPERTIES, NULL); return FALSE; case IDC_RESUME: pfr.action=FILERESUME_RESUME; @@ -290,7 +290,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case IDC_SAVEAS: { OPENFILENAME ofn={0}; - TCHAR filter[512],*pfilter; + TCHAR filter[512], *pfilter; TCHAR str[MAX_PATH]; lstrcpyn( str, fts->tszCurrentFile, SIZEOF(str)); @@ -325,27 +325,27 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } { PROTOFILERESUME *pfrCopy; pfrCopy=(PROTOFILERESUME*)mir_alloc(sizeof(pfr)); - CopyMemory(pfrCopy,&pfr,sizeof(pfr)); - PostMessage((HWND)GetPropA(hwndDlg,"Miranda.ParentWnd"),M_FILEEXISTSDLGREPLY,(WPARAM)mir_tstrdup(fts->tszCurrentFile),(LPARAM)pfrCopy); + CopyMemory(pfrCopy, &pfr, sizeof(pfr)); + PostMessage((HWND)GetPropA(hwndDlg, "Miranda.ParentWnd"), M_FILEEXISTSDLGREPLY, (WPARAM)mir_tstrdup(fts->tszCurrentFile), (LPARAM)pfrCopy); DestroyWindow(hwndDlg); } break; } case WM_CLOSE: - PostMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDCANCEL,BN_CLICKED),(LPARAM)GetDlgItem(hwndDlg,IDCANCEL)); + PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDCANCEL)); break; case M_PRESHUTDOWN: - PostMessage(hwndDlg,WM_CLOSE,0,0); + PostMessage(hwndDlg, WM_CLOSE, 0, 0); break; case WM_DESTROY: - UnhookEvent(GetPropA(hwndDlg,"Miranda.Preshutdown")); // GetProp() will return NULL if it couldnt find anything - RemovePropA(hwndDlg,"Miranda.Preshutdown"); - RemovePropA(hwndDlg,"Miranda.ParentWnd"); - DestroyIcon((HICON)SendDlgItemMessage(hwndDlg,IDC_EXISTINGICON,STM_GETICON,0,0)); - DestroyIcon((HICON)SendDlgItemMessage(hwndDlg,IDC_NEWICON,STM_GETICON,0,0)); + UnhookEvent(GetPropA(hwndDlg, "Miranda.Preshutdown")); // GetProp() will return NULL if it couldnt find anything + RemovePropA(hwndDlg, "Miranda.Preshutdown"); + RemovePropA(hwndDlg, "Miranda.ParentWnd"); + DestroyIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_EXISTINGICON, STM_GETICON, 0, 0)); + DestroyIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_NEWICON, STM_GETICON, 0, 0)); FreeProtoFileTransferStatus(fts); mir_free(fts); break; diff --git a/src/modules/srfile/fileopts.cpp b/src/modules/srfile/fileopts.cpp index ca22961ece..e0189fc56f 100644 --- a/src/modules/srfile/fileopts.cpp +++ b/src/modules/srfile/fileopts.cpp @@ -2,7 +2,7 @@ Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, +Copyright 2000-2009 Miranda ICQ/IM project, all portions of this codebase are copyrighted to the people listed in contributors.txt. @@ -11,7 +11,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -36,16 +36,16 @@ struct virusscannerinfo { }; static const struct virusscannerinfo virusScanners[]={ - {_T("Network Associates/McAfee VirusScan"),_T("SOFTWARE\\McAfee\\VirusScan"),_T("Scan32EXE"),_T("\"%s\" %%f /nosplash /comp /autoscan /autoexit /noboot")}, - {_T("Dr Solomon's VirusScan (Network Associates)"),_T("SOFTWARE\\Network Associates\\TVD\\VirusScan\\AVConsol\\General"),_T("szScannerExe"),_T("\"%s\" %%f /uinone /noboot /comp /prompt /autoexit")}, - {_T("Norton AntiVirus"),_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Navw32.exe"),NULL,_T("\"%s\" %%f /b- /m- /s+ /noresults")}, - {_T("Computer Associates/Inoculate IT"),_T("Software\\Antivirus"),_T("ImageFilename"),_T("\"%s\" %%f /display=progress /exit")}, - {_T("Computer Associates eTrust"),_T("SOFTWARE\\ComputerAssociates\\Anti-Virus\\Resident"),_T("VetPath"),_T("\"%s\" %%f /display=progress /exit")}, - {_T("Kaspersky Anti-Virus"),_T("SOFTWARE\\KasperskyLab\\Components\\101"),_T("EXEName"),_T("\"%s\" /S /Q %%f")}, - {_T("Kaspersky Anti-Virus"),_T("SOFTWARE\\KasperskyLab\\SetupFolders"),_T("KAV8"),_T("\"%savp.exe\" SCAN %%f")}, - {_T("Kaspersky Anti-Virus"),_T("SOFTWARE\\KasperskyLab\\SetupFolders"),_T("KAV9"),_T("\"%savp.exe\" SCAN %%f")}, - {_T("AntiVir PersonalEdition Classic"),_T("SOFTWARE\\Avira\\AntiVir PersonalEdition Classic"),_T("Path"),_T("\"%savscan.exe\" /GUIMODE=2 /PATH=\"%%f\"")}, - {_T("ESET NOD32 Antivirus"),_T("SOFTWARE\\ESET\\ESET Security\\CurrentVersion\\Info"),_T("InstallDir"),_T("\"%secls.exe\" /log-all /aind /no-boots /adware /sfx /unsafe /unwanted /heur /adv-heur /action=clean \"%%f\"")}, + {_T("Network Associates/McAfee VirusScan"), _T("SOFTWARE\\McAfee\\VirusScan"), _T("Scan32EXE"), _T("\"%s\" %%f /nosplash /comp /autoscan /autoexit /noboot")}, + {_T("Dr Solomon's VirusScan (Network Associates)"), _T("SOFTWARE\\Network Associates\\TVD\\VirusScan\\AVConsol\\General"), _T("szScannerExe"), _T("\"%s\" %%f /uinone /noboot /comp /prompt /autoexit")}, + {_T("Norton AntiVirus"), _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Navw32.exe"), NULL, _T("\"%s\" %%f /b- /m- /s+ /noresults")}, + {_T("Computer Associates/Inoculate IT"), _T("Software\\Antivirus"), _T("ImageFilename"), _T("\"%s\" %%f /display=progress /exit")}, + {_T("Computer Associates eTrust"), _T("SOFTWARE\\ComputerAssociates\\Anti-Virus\\Resident"), _T("VetPath"), _T("\"%s\" %%f /display=progress /exit")}, + {_T("Kaspersky Anti-Virus"), _T("SOFTWARE\\KasperskyLab\\Components\\101"), _T("EXEName"), _T("\"%s\" /S /Q %%f")}, + {_T("Kaspersky Anti-Virus"), _T("SOFTWARE\\KasperskyLab\\SetupFolders"), _T("KAV8"), _T("\"%savp.exe\" SCAN %%f")}, + {_T("Kaspersky Anti-Virus"), _T("SOFTWARE\\KasperskyLab\\SetupFolders"), _T("KAV9"), _T("\"%savp.exe\" SCAN %%f")}, + {_T("AntiVir PersonalEdition Classic"), _T("SOFTWARE\\Avira\\AntiVir PersonalEdition Classic"), _T("Path"), _T("\"%savscan.exe\" /GUIMODE=2 /PATH=\"%%f\"")}, + {_T("ESET NOD32 Antivirus"), _T("SOFTWARE\\ESET\\ESET Security\\CurrentVersion\\Info"), _T("InstallDir"), _T("\"%secls.exe\" /log-all /aind /no-boots /adware /sfx /unsafe /unwanted /heur /adv-heur /action=clean \"%%f\"")}, }; #define M_UPDATEENABLING (WM_USER+100) @@ -67,74 +67,74 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L { TCHAR str[MAX_PATH]; - GetContactReceivedFilesDir(NULL,str,SIZEOF(str),FALSE); - SetDlgItemText(hwndDlg,IDC_FILEDIR,str); + GetContactReceivedFilesDir(NULL, str, SIZEOF(str), FALSE); + SetDlgItemText(hwndDlg, IDC_FILEDIR, str); } - CheckDlgButton(hwndDlg, IDC_AUTOACCEPT, DBGetContactSettingByte(NULL,"SRFile","AutoAccept",0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_AUTOMIN, DBGetContactSettingByte(NULL,"SRFile","AutoMin",0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_AUTOCLOSE, DBGetContactSettingByte(NULL,"SRFile","AutoClose",0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_AUTOCLEAR, DBGetContactSettingByte(NULL,"SRFile","AutoClear",1) ? BST_CHECKED : BST_UNCHECKED); - switch(DBGetContactSettingByte(NULL,"SRFile","UseScanner",VIRUSSCAN_DISABLE)) { + CheckDlgButton(hwndDlg, IDC_AUTOACCEPT, DBGetContactSettingByte(NULL, "SRFile", "AutoAccept", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_AUTOMIN, DBGetContactSettingByte(NULL, "SRFile", "AutoMin", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_AUTOCLOSE, DBGetContactSettingByte(NULL, "SRFile", "AutoClose", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_AUTOCLEAR, DBGetContactSettingByte(NULL, "SRFile", "AutoClear", 1) ? BST_CHECKED : BST_UNCHECKED); + switch(DBGetContactSettingByte(NULL, "SRFile", "UseScanner", VIRUSSCAN_DISABLE)) { case VIRUSSCAN_AFTERDL: CheckDlgButton(hwndDlg, IDC_SCANAFTERDL, BST_CHECKED); break; case VIRUSSCAN_DURINGDL: CheckDlgButton(hwndDlg, IDC_SCANDURINGDL, BST_CHECKED); break; default: CheckDlgButton(hwndDlg, IDC_NOSCANNER, BST_CHECKED); break; } - CheckDlgButton(hwndDlg, IDC_WARNBEFOREOPENING, DBGetContactSettingByte(NULL,"SRFile","WarnBeforeOpening",1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_WARNBEFOREOPENING, DBGetContactSettingByte(NULL, "SRFile", "WarnBeforeOpening", 1) ? BST_CHECKED : BST_UNCHECKED); { TCHAR szScanExe[MAX_PATH]; - int i,iItem; + int i, iItem; for ( i=0; i < SIZEOF(virusScanners); i++ ) { - if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE,virusScanners[i].szExeRegPath,virusScanners[i].szExeRegValue,szScanExe,SIZEOF(szScanExe))) { - iItem=SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_ADDSTRING,0,(LPARAM)virusScanners[i].szProductName); - SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_SETITEMDATA,iItem,i); + if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, SIZEOF(szScanExe))) { + iItem=SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)virusScanners[i].szProductName); + SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, i); } } - if ( SendDlgItemMessageA(hwndDlg,IDC_SCANCMDLINE,CB_GETCOUNT,0,0) == 0 ) + if ( SendDlgItemMessageA(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0) == 0 ) { - iItem = SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_ADDSTRING,0,(LPARAM)_T("") ); - SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_SETITEMDATA,iItem, (LPARAM)-1); + iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)_T("") ); + SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, (LPARAM)-1); } } DBVARIANT dbv; - if (DBGetContactSettingTString(NULL,"SRFile","ScanCmdLine",&dbv) == 0) { - SetDlgItemText(hwndDlg,IDC_SCANCMDLINE,dbv.ptszVal); + if (DBGetContactSettingTString(NULL, "SRFile", "ScanCmdLine", &dbv) == 0) { + SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, dbv.ptszVal); DBFreeVariant(&dbv); } else { - if (SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_GETCOUNT,0,0)) { - SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_SETCURSEL,0,0); - PostMessage(hwndDlg,M_SCANCMDLINESELCHANGE,0,0); + if (SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0)) { + SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETCURSEL, 0, 0); + PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0); } } - switch(DBGetContactSettingByte(NULL,"SRFile","IfExists",FILERESUME_ASK)) { + switch(DBGetContactSettingByte(NULL, "SRFile", "IfExists", FILERESUME_ASK)) { case FILERESUME_RESUMEALL: CheckDlgButton(hwndDlg, IDC_RESUME, BST_CHECKED); break; case FILERESUME_OVERWRITEALL: CheckDlgButton(hwndDlg, IDC_OVERWRITE, BST_CHECKED); break; case FILERESUME_RENAMEALL: CheckDlgButton(hwndDlg, IDC_RENAME, BST_CHECKED); break; default: CheckDlgButton(hwndDlg, IDC_ASK, BST_CHECKED); break; } - SendMessage(hwndDlg,M_UPDATEENABLING,0,0); + SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0); return TRUE; } case M_UPDATEENABLING: - { int on=!IsDlgButtonChecked(hwndDlg,IDC_NOSCANNER); - EnableWindow(GetDlgItem(hwndDlg,IDC_ST_CMDLINE),on); - EnableWindow(GetDlgItem(hwndDlg,IDC_SCANCMDLINE),on); - EnableWindow(GetDlgItem(hwndDlg,IDC_SCANCMDLINEBROWSE),on); - EnableWindow(GetDlgItem(hwndDlg,IDC_ST_CMDLINEHELP),on); - EnableWindow(GetDlgItem(hwndDlg,IDC_AUTOMIN),IsDlgButtonChecked(hwndDlg,IDC_AUTOACCEPT)); + { int on=!IsDlgButtonChecked(hwndDlg, IDC_NOSCANNER); + EnableWindow(GetDlgItem(hwndDlg, IDC_ST_CMDLINE), on); + EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINE), on); + EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINEBROWSE), on); + EnableWindow(GetDlgItem(hwndDlg, IDC_ST_CMDLINEHELP), on); + EnableWindow(GetDlgItem(hwndDlg, IDC_AUTOMIN), IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT)); break; } case M_SCANCMDLINESELCHANGE: { TCHAR str[512]; TCHAR szScanExe[MAX_PATH]; - int iScanner=SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_SCANCMDLINE,CB_GETCURSEL,0,0),0); + int iScanner=SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCURSEL, 0, 0), 0); if (iScanner >= SIZEOF(virusScanners) || iScanner<0) break; str[0]='\0'; - if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE,virusScanners[iScanner].szExeRegPath,virusScanners[iScanner].szExeRegValue,szScanExe,SIZEOF(szScanExe))) - mir_sntprintf(str, SIZEOF(str), virusScanners[iScanner].szCommandLine,szScanExe); - SetDlgItemText(hwndDlg,IDC_SCANCMDLINE,str); + if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, SIZEOF(szScanExe))) + mir_sntprintf(str, SIZEOF(str), virusScanners[iScanner].szCommandLine, szScanExe); + SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str); break; } case WM_COMMAND: @@ -144,19 +144,19 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L break; case IDC_FILEDIRBROWSE: { TCHAR str[MAX_PATH]; - GetDlgItemText(hwndDlg,IDC_FILEDIR,str,SIZEOF(str)); - if (BrowseForFolder(hwndDlg,str)) - SetDlgItemText(hwndDlg,IDC_FILEDIR,str); + GetDlgItemText(hwndDlg, IDC_FILEDIR, str, SIZEOF(str)); + if (BrowseForFolder(hwndDlg, str)) + SetDlgItemText(hwndDlg, IDC_FILEDIR, str); break; } case IDC_AUTOACCEPT: case IDC_NOSCANNER: case IDC_SCANAFTERDL: case IDC_SCANDURINGDL: - SendMessage(hwndDlg,M_UPDATEENABLING,0,0); + SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0); break; case IDC_SCANCMDLINE: - if (HIWORD(wParam) == CBN_SELCHANGE) PostMessage(hwndDlg,M_SCANCMDLINESELCHANGE,0,0); + if (HIWORD(wParam) == CBN_SELCHANGE) PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0); else if (HIWORD(wParam) != CBN_EDITCHANGE) return 0; break; case IDC_SCANCMDLINEBROWSE: @@ -168,7 +168,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT; - _tcscpy(filter,TranslateT("Executable Files")); + _tcscpy(filter, TranslateT("Executable Files")); _tcscat(filter, _T(" (*.exe)")); pfilter = filter + _tcslen(filter) + 1; _tcscpy(pfilter, _T("*.exe")); @@ -211,16 +211,16 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L { TCHAR str[512]; GetDlgItemText(hwndDlg, IDC_FILEDIR, str, SIZEOF(str)); RemoveInvalidPathChars(str); - DBWriteContactSettingTString(NULL,"SRFile","RecvFilesDirAdv",str); - DBWriteContactSettingByte(NULL,"SRFile","AutoAccept",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_AUTOACCEPT)); - DBWriteContactSettingByte(NULL,"SRFile","AutoMin",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_AUTOMIN)); - DBWriteContactSettingByte(NULL,"SRFile","AutoClose",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_AUTOCLOSE)); - DBWriteContactSettingByte(NULL,"SRFile","AutoClear",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_AUTOCLEAR)); - DBWriteContactSettingByte(NULL,"SRFile","UseScanner",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_SCANAFTERDL)?VIRUSSCAN_AFTERDL:(IsDlgButtonChecked(hwndDlg,IDC_SCANDURINGDL)?VIRUSSCAN_DURINGDL:VIRUSSCAN_DISABLE))); + DBWriteContactSettingTString(NULL, "SRFile", "RecvFilesDirAdv", str); + DBWriteContactSettingByte(NULL, "SRFile", "AutoAccept", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT)); + DBWriteContactSettingByte(NULL, "SRFile", "AutoMin", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOMIN)); + DBWriteContactSettingByte(NULL, "SRFile", "AutoClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLOSE)); + DBWriteContactSettingByte(NULL, "SRFile", "AutoClear", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLEAR)); + DBWriteContactSettingByte(NULL, "SRFile", "UseScanner", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCANAFTERDL)?VIRUSSCAN_AFTERDL:(IsDlgButtonChecked(hwndDlg, IDC_SCANDURINGDL)?VIRUSSCAN_DURINGDL:VIRUSSCAN_DISABLE))); GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, SIZEOF(str)); - DBWriteContactSettingTString(NULL,"SRFile","ScanCmdLine",str); - DBWriteContactSettingByte(NULL,"SRFile","WarnBeforeOpening",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_WARNBEFOREOPENING)); - DBWriteContactSettingByte(NULL,"SRFile","IfExists",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_ASK)?FILERESUME_ASK:(IsDlgButtonChecked(hwndDlg,IDC_RESUME)?FILERESUME_RESUMEALL:(IsDlgButtonChecked(hwndDlg,IDC_OVERWRITE)?FILERESUME_OVERWRITEALL:FILERESUME_RENAMEALL)))); + DBWriteContactSettingTString(NULL, "SRFile", "ScanCmdLine", str); + DBWriteContactSettingByte(NULL, "SRFile", "WarnBeforeOpening", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WARNBEFOREOPENING)); + DBWriteContactSettingByte(NULL, "SRFile", "IfExists", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ASK)?FILERESUME_ASK:(IsDlgButtonChecked(hwndDlg, IDC_RESUME)?FILERESUME_RESUMEALL:(IsDlgButtonChecked(hwndDlg, IDC_OVERWRITE)?FILERESUME_OVERWRITEALL:FILERESUME_RENAMEALL)))); return TRUE; } } diff --git a/src/modules/srfile/filerecvdlg.cpp b/src/modules/srfile/filerecvdlg.cpp index 4de076e0fe..35ed892544 100644 --- a/src/modules/srfile/filerecvdlg.cpp +++ b/src/modules/srfile/filerecvdlg.cpp @@ -2,7 +2,7 @@ Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, +Copyright 2000-2009 Miranda ICQ/IM project, all portions of this codebase are copyrighted to the people listed in contributors.txt. @@ -11,7 +11,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -27,22 +27,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static BOOL CALLBACK ClipSiblingsChildEnumProc(HWND hwnd, LPARAM) { - SetWindowLongPtr(hwnd,GWL_STYLE,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_CLIPSIBLINGS); + SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE)|WS_CLIPSIBLINGS); return TRUE; } -static void GetLowestExistingDirName(const TCHAR *szTestDir,TCHAR *szExistingDir,int cchExistingDir) +static void GetLowestExistingDirName(const TCHAR *szTestDir, TCHAR *szExistingDir, int cchExistingDir) { DWORD dwAttributes; TCHAR *pszLastBackslash; - lstrcpyn(szExistingDir,szTestDir,cchExistingDir); + lstrcpyn(szExistingDir, szTestDir, cchExistingDir); while ((dwAttributes=GetFileAttributes(szExistingDir)) != INVALID_FILE_ATTRIBUTES && !(dwAttributes&FILE_ATTRIBUTE_DIRECTORY)) { - pszLastBackslash=_tcsrchr(szExistingDir,'\\'); + pszLastBackslash=_tcsrchr(szExistingDir, '\\'); if (pszLastBackslash == NULL) {*szExistingDir='\0'; break;} *pszLastBackslash='\0'; } - if (szExistingDir[0] == '\0') GetCurrentDirectory(cchExistingDir,szExistingDir); + if (szExistingDir[0] == '\0') GetCurrentDirectory(cchExistingDir, szExistingDir); } static const TCHAR InvalidFilenameChars[] = _T("\\/:*?\"<>|"); @@ -50,7 +50,7 @@ void RemoveInvalidFilenameChars(TCHAR *tszString) { size_t i; if (tszString) { - for (i=_tcscspn(tszString,InvalidFilenameChars); tszString[i]; i+=_tcscspn(tszString+i+1,InvalidFilenameChars)+1) + for (i=_tcscspn(tszString, InvalidFilenameChars); tszString[i]; i+=_tcscspn(tszString+i+1, InvalidFilenameChars)+1) if (tszString[i] >= 0) tszString[i] = _T('_'); } @@ -61,7 +61,7 @@ void RemoveInvalidPathChars(TCHAR *tszString) { size_t i; if (tszString) { - for (i=_tcscspn(tszString,InvalidPathChars); tszString[i]; i+=_tcscspn(tszString+i+1,InvalidPathChars)+1) + for (i=_tcscspn(tszString, InvalidPathChars); tszString[i]; i+=_tcscspn(tszString+i+1, InvalidPathChars)+1) if (tszString[i] >= 0) tszString[i] = _T('_'); } @@ -75,14 +75,14 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData); break; case BFFM_SELCHANGED: - if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir)) - SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)szDir); + if (SHGetPathFromIDList((LPITEMIDLIST) lp , szDir)) + SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szDir); break; } return 0; } -int BrowseForFolder(HWND hwnd,TCHAR *szPath) +int BrowseForFolder(HWND hwnd, TCHAR *szPath) { BROWSEINFO bi={0}; LPITEMIDLIST pidlResult; @@ -96,8 +96,8 @@ int BrowseForFolder(HWND hwnd,TCHAR *szPath) pidlResult=SHBrowseForFolder(&bi); if (pidlResult) { - SHGetPathFromIDList(pidlResult,szPath); - lstrcat(szPath,_T("\\")); + SHGetPathFromIDList(pidlResult, szPath); + lstrcat(szPath, _T("\\")); CoTaskMemFree(pidlResult); } return pidlResult != NULL; @@ -105,9 +105,9 @@ int BrowseForFolder(HWND hwnd,TCHAR *szPath) static REPLACEVARSARRAY sttVarsToReplace[] = { - { ( TCHAR* )"///", ( TCHAR* )"//" }, - { ( TCHAR* )"//", ( TCHAR* )"/" }, - { ( TCHAR* )"()", ( TCHAR* )"" }, + { ( TCHAR* )"///", ( TCHAR* )"//" }, + { ( TCHAR* )"//", ( TCHAR* )"/" }, + { ( TCHAR* )"()", ( TCHAR* )"" }, { NULL, NULL } }; @@ -156,7 +156,7 @@ void GetContactReceivedFilesDir(HANDLE hContact, TCHAR *szDir, int cchDir, BOOL rvaVarsToReplace[1].lptzKey = _T("userid"); rvaVarsToReplace[1].lptzValue = GetContactID(hContact); rvaVarsToReplace[2].lptzKey = _T("proto"); - rvaVarsToReplace[2].lptzValue = mir_a2t((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact,0)); + rvaVarsToReplace[2].lptzValue = mir_a2t((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); rvaVarsToReplace[3].lptzKey = NULL; rvaVarsToReplace[3].lptzValue = NULL; for (int i=0; i < (SIZEOF(rvaVarsToReplace)-1);i++) @@ -208,7 +208,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l { struct FileDlgData *dat; - dat=(struct FileDlgData*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); + dat=(struct FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { TCHAR *contactName; @@ -218,13 +218,13 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l TranslateDialogDefault(hwndDlg); dat=(struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData)); - SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)dat); + 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->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN); dat->dwTicks = GetTickCount(); - EnumChildWindows(hwndDlg,ClipSiblingsChildEnumProc,0); + 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")); @@ -233,43 +233,43 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User Menu")); contactName = cli.pfnGetContactDisplayName( dat->hContact, 0 ); - SetDlgItemText(hwndDlg,IDC_FROM,contactName); - GetContactReceivedFilesDir(dat->hContact,szPath,SIZEOF(szPath),TRUE); - SetDlgItemText(hwndDlg,IDC_FILEDIR,szPath); + SetDlgItemText(hwndDlg, IDC_FROM, contactName); + GetContactReceivedFilesDir(dat->hContact, szPath, SIZEOF(szPath), TRUE); + SetDlgItemText(hwndDlg, IDC_FILEDIR, szPath); { int i; char idstr[32]; DBVARIANT dbv; if (shAutoComplete) - shAutoComplete(GetWindow(GetDlgItem(hwndDlg,IDC_FILEDIR),GW_CHILD),1); + shAutoComplete(GetWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), GW_CHILD), 1); for (i=0;ihContact,(LPARAM)dat->hDbEvent); + CallService(MS_DB_EVENT_MARKREAD, (WPARAM)dat->hContact, (LPARAM)dat->hDbEvent); { DBEVENTINFO dbei={0}; TCHAR datetimestr[64]; char buf[540]; dbei.cbSize=sizeof(dbei); - dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)dat->hDbEvent,0); + 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); + 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))); + lstrcpynA(buf, (char*)dbei.pBlob+4, min(dbei.cbBlob+1, SIZEOF(buf))); TCHAR* ptszFileName = DbGetEventStringT( &dbei, buf ); - SetDlgItemText(hwndDlg,IDC_FILENAMES,ptszFileName); + 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))); + 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); + SetDlgItemText(hwndDlg, IDC_MSG, ptszDescription); mir_free(ptszDescription); mir_free(dbei.pBlob); @@ -282,13 +282,13 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l CONTACTINFO ci; int hasName = 0; char buf[128]; - ZeroMemory(&ci,sizeof(ci)); + ZeroMemory(&ci, sizeof(ci)); ci.cbSize = sizeof(ci); ci.hContact = dat->hContact; ci.szProto = szProto; ci.dwFlag = CNF_UNIQUEID; - if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) { + if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { switch(ci.type) { case CNFT_ASCIIZ: hasName = 1; @@ -297,7 +297,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l break; case CNFT_DWORD: hasName = 1; - mir_snprintf(buf, SIZEOF(buf),"%u",ci.dVal); + mir_snprintf(buf, SIZEOF(buf), "%u", ci.dVal); break; } } if (hasName) @@ -306,97 +306,97 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l 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); + 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)) { + 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)); + 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); + return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis=(LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto; - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); + szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); if (szProto) { HICON hIcon; - hIcon=(HICON)CallProtoService(szProto,PS_LOADICON,PLI_PROTOCOL|PLIF_SMALL,0); + 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, NULL, DI_NORMAL); DestroyIcon(hIcon); } } } } - return CallService(MS_CLIST_MENUDRAWITEM,wParam,lParam); + return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case WM_COMMAND: - if ( CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU), (LPARAM)dat->hContact )) + if ( CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact )) break; switch ( LOWORD( wParam )) { case IDC_FILEDIRBROWSE: { - TCHAR szDirName[MAX_PATH],szExistingDirName[MAX_PATH]; + TCHAR szDirName[MAX_PATH], szExistingDirName[MAX_PATH]; - GetDlgItemText(hwndDlg,IDC_FILEDIR,szDirName,SIZEOF(szDirName)); - GetLowestExistingDirName(szDirName,szExistingDirName,SIZEOF(szExistingDirName)); - if (BrowseForFolder(hwndDlg,szExistingDirName)) - SetDlgItemText(hwndDlg,IDC_FILEDIR,szExistingDirName); + GetDlgItemText(hwndDlg, IDC_FILEDIR, szDirName, SIZEOF(szDirName)); + GetLowestExistingDirName(szDirName, szExistingDirName, SIZEOF(szExistingDirName)); + if (BrowseForFolder(hwndDlg, szExistingDirName)) + SetDlgItemText(hwndDlg, IDC_FILEDIR, szExistingDirName); } break; case IDOK: { //most recently used directories - TCHAR szRecvDir[MAX_PATH],szDefaultRecvDir[MAX_PATH]; - GetDlgItemText(hwndDlg,IDC_FILEDIR,szRecvDir,SIZEOF(szRecvDir)); + TCHAR szRecvDir[MAX_PATH], szDefaultRecvDir[MAX_PATH]; + GetDlgItemText(hwndDlg, IDC_FILEDIR, szRecvDir, SIZEOF(szRecvDir)); RemoveInvalidPathChars(szRecvDir); - GetContactReceivedFilesDir(NULL,szDefaultRecvDir,SIZEOF(szDefaultRecvDir),TRUE); - if (_tcsnicmp(szRecvDir,szDefaultRecvDir,lstrlen(szDefaultRecvDir))) { + GetContactReceivedFilesDir(NULL, szDefaultRecvDir, SIZEOF(szDefaultRecvDir), TRUE); + if (_tcsnicmp(szRecvDir, szDefaultRecvDir, lstrlen(szDefaultRecvDir))) { char idstr[32]; int i; DBVARIANT dbv; for (i=MAX_MRU_DIRS-2;i>=0;i--) { - mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d",i); - if (DBGetContactSettingTString(NULL,"SRFile",idstr,&dbv)) continue; - mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d",i+1); - DBWriteContactSettingTString(NULL,"SRFile",idstr,dbv.ptszVal); + mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i); + if (DBGetContactSettingTString(NULL, "SRFile", idstr, &dbv)) continue; + mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i+1); + DBWriteContactSettingTString(NULL, "SRFile", idstr, dbv.ptszVal); DBFreeVariant(&dbv); } - DBWriteContactSettingTString(NULL,"SRFile",idstr,szRecvDir); + DBWriteContactSettingTString(NULL, "SRFile", idstr, szRecvDir); } } - EnableWindow(GetDlgItem(hwndDlg,IDC_FILENAMES),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_MSG),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_FILEDIR),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_FILEDIRBROWSE),FALSE); - - GetDlgItemText(hwndDlg,IDC_FILEDIR,dat->szSavePath,SIZEOF(dat->szSavePath)); - GetDlgItemText(hwndDlg,IDC_FILE,dat->szFilenames,SIZEOF(dat->szFilenames)); - GetDlgItemText(hwndDlg,IDC_MSG,dat->szMsg,SIZEOF(dat->szMsg)); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAMES), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIRBROWSE), FALSE); + + GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, SIZEOF(dat->szSavePath)); + GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, SIZEOF(dat->szFilenames)); + GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, SIZEOF(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr( hwndDlg, GWLP_USERDATA, 0); //check for auto-minimize here to fix BUG#647620 - if (DBGetContactSettingByte(NULL,"SRFile","AutoAccept",0) && DBGetContactSettingByte(NULL,"SRFile","AutoMin",0)) { - ShowWindow(hwndDlg,SW_HIDE); - ShowWindow(hwndDlg,SW_SHOWMINNOACTIVE); + if (DBGetContactSettingByte(NULL, "SRFile", "AutoAccept", 0) && DBGetContactSettingByte(NULL, "SRFile", "AutoMin", 0)) { + ShowWindow(hwndDlg, SW_HIDE); + ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE); } DestroyWindow(hwndDlg); break; case IDCANCEL: - if (dat->fs) CallContactService(dat->hContact,PSS_FILEDENYT,(WPARAM)dat->fs,(LPARAM)TranslateT("Cancelled")); + if (dat->fs) CallContactService(dat->hContact, PSS_FILEDENYT, (WPARAM)dat->fs, (LPARAM)TranslateT("Cancelled")); dat->fs=NULL; /* the protocol will free the handle */ DestroyWindow(hwndDlg); break; @@ -407,37 +407,37 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l acs.handle=dat->hContact; acs.handleType=HANDLE_CONTACT; acs.szProto=""; - CallService(MS_ADDCONTACT_SHOW,(WPARAM)hwndDlg,(LPARAM)&acs); - if (!DBGetContactSettingByte(dat->hContact,"CList","NotOnList",0)) - ShowWindow(GetDlgItem(hwndDlg,IDC_ADD), SW_HIDE); + CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); + if (!DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) + ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } break; case IDC_USERMENU: { RECT rc; - HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT,(WPARAM)dat->hContact,0); - GetWindowRect((HWND)lParam,&rc); - TrackPopupMenu(hMenu,0,rc.left,rc.bottom,0,hwndDlg,NULL); + HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); + GetWindowRect((HWND)lParam, &rc); + TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_DETAILS: - CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)dat->hContact,0); + CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_HISTORY: - CallService(MS_HISTORY_SHOWCONTACTHISTORY,(WPARAM)dat->hContact,0); + CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); break; } break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); - Button_FreeIcon_IcoLib(hwndDlg,IDC_ADD); - Button_FreeIcon_IcoLib(hwndDlg,IDC_DETAILS); - Button_FreeIcon_IcoLib(hwndDlg,IDC_HISTORY); - Button_FreeIcon_IcoLib(hwndDlg,IDC_USERMENU); + Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); + Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); + Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); + Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); if ( dat ) FreeFileDlgData( dat ); break; diff --git a/src/modules/srfile/filesenddlg.cpp b/src/modules/srfile/filesenddlg.cpp index 8567003f91..228fc18059 100644 --- a/src/modules/srfile/filesenddlg.cpp +++ b/src/modules/srfile/filesenddlg.cpp @@ -2,7 +2,7 @@ Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, +Copyright 2000-2009 Miranda ICQ/IM project, all portions of this codebase are copyrighted to the people listed in contributors.txt. @@ -11,7 +11,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "file.h" -static void SetFileListAndSizeControls(HWND hwndDlg,struct FileDlgData *dat) +static void SetFileListAndSizeControls(HWND hwndDlg, struct FileDlgData *dat) { - int fileCount=0,dirCount=0,totalSize=0,i; + int fileCount=0, dirCount=0, totalSize=0, i; struct _stat statbuf; TCHAR str[64]; @@ -40,25 +40,25 @@ static void SetFileListAndSizeControls(HWND hwndDlg,struct FileDlgData *dat) totalSize += statbuf.st_size; } } - GetSensiblyFormattedSize(totalSize,str,SIZEOF(str),0,1,NULL); - SetDlgItemText(hwndDlg,IDC_TOTALSIZE,str); + GetSensiblyFormattedSize(totalSize, str, SIZEOF(str), 0, 1, NULL); + SetDlgItemText(hwndDlg, IDC_TOTALSIZE, str); if (i>1) { TCHAR szFormat[32]; if (fileCount && dirCount) { - mir_sntprintf(szFormat,SIZEOF(szFormat),_T("%s, %s"),TranslateTS(fileCount == 1?_T("%d file"):_T("%d files")),TranslateTS(dirCount == 1?_T("%d directory"):_T("%d directories"))); - mir_sntprintf(str,SIZEOF(str),szFormat,fileCount,dirCount); + mir_sntprintf(szFormat, SIZEOF(szFormat), _T("%s, %s"), TranslateTS(fileCount == 1?_T("%d file"):_T("%d files")), TranslateTS(dirCount == 1?_T("%d directory"):_T("%d directories"))); + mir_sntprintf(str, SIZEOF(str), szFormat, fileCount, dirCount); } else if (fileCount) { - lstrcpy(szFormat,TranslateT("%d files")); - mir_sntprintf(str,SIZEOF(str),szFormat,fileCount); + lstrcpy(szFormat, TranslateT("%d files")); + mir_sntprintf(str, SIZEOF(str), szFormat, fileCount); } else { - lstrcpy(szFormat,TranslateT("%d directories")); - mir_sntprintf(str,SIZEOF(str),szFormat,dirCount); + lstrcpy(szFormat, TranslateT("%d directories")); + mir_sntprintf(str, SIZEOF(str), szFormat, dirCount); } - SetDlgItemText(hwndDlg,IDC_FILE,str); + SetDlgItemText(hwndDlg, IDC_FILE, str); } - else SetDlgItemText(hwndDlg,IDC_FILE,dat->files[0]); + else SetDlgItemText(hwndDlg, IDC_FILE, dat->files[0]); EnableWindow(GetDlgItem(hwndDlg, IDOK), fileCount || dirCount); } @@ -168,53 +168,53 @@ void __cdecl ChooseFilesThread(void* param) PostMessage( hwndDlg, M_FILECHOOSEDONE, 0, ( LPARAM )( TCHAR* )NULL ); } } } -static BOOL CALLBACK ClipSiblingsChildEnumProc(HWND hwnd,LPARAM) +static BOOL CALLBACK ClipSiblingsChildEnumProc(HWND hwnd, LPARAM) { - SetWindowLongPtr(hwnd,GWL_STYLE,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_CLIPSIBLINGS); + SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE)|WS_CLIPSIBLINGS); return TRUE; } static WNDPROC OldSendEditProc; -static LRESULT CALLBACK SendEditSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +static LRESULT CALLBACK SendEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CHAR: if (wParam == '\n' && GetKeyState(VK_CONTROL)&0x8000) { - PostMessage(GetParent(hwnd),WM_COMMAND,IDOK,0); + PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0); return 0; } break; case WM_SYSCHAR: if ((wParam == 's' || wParam == 'S') && GetKeyState(VK_MENU)&0x8000) { - PostMessage(GetParent(hwnd),WM_COMMAND,IDOK,0); + PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0); return 0; } break; } - return CallWindowProc(OldSendEditProc,hwnd,msg,wParam,lParam); + return CallWindowProc(OldSendEditProc, hwnd, msg, wParam, lParam); } INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct FileDlgData *dat; - dat=(struct FileDlgData*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); + dat=(struct FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { struct FileSendData *fsd=(struct FileSendData*)lParam; dat=(struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData)); - SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)dat); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact=fsd->hContact; dat->send=1; - dat->hPreshutdownEvent=HookEventMessage(ME_SYSTEM_PRESHUTDOWN,hwndDlg,M_PRESHUTDOWN); + dat->hPreshutdownEvent=HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN); dat->fs=NULL; dat->dwTicks=GetTickCount(); TranslateDialogDefault(hwndDlg); - EnumChildWindows(hwndDlg,ClipSiblingsChildEnumProc,0); - OldSendEditProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_MSG),GWLP_WNDPROC,(LONG_PTR)SendEditSubclassProc); + EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0); + OldSendEditProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MSG), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE); Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View User's Details")); @@ -224,31 +224,31 @@ 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) { - int totalCount,i; + int totalCount, i; for (totalCount=0;fsd->ppFiles[totalCount];totalCount++); dat->files = ( TCHAR** )mir_alloc( sizeof(TCHAR*)*(totalCount+1)); // Leaks for (i=0;ifiles[i] = mir_tstrdup( fsd->ppFiles[i] ); dat->files[totalCount]=NULL; - SetFileListAndSizeControls(hwndDlg,dat); + SetFileListAndSizeControls(hwndDlg, dat); } { char *szProto; TCHAR* contactName = cli.pfnGetContactDisplayName( dat->hContact, 0 ); - SetDlgItemText(hwndDlg,IDC_TO,contactName); + SetDlgItemText(hwndDlg, IDC_TO, contactName); - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); + szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); if (szProto) { CONTACTINFO ci; int hasName = 0; char buf[128]; - ZeroMemory(&ci,sizeof(ci)); + ZeroMemory(&ci, sizeof(ci)); ci.cbSize = sizeof(ci); ci.hContact = dat->hContact; ci.szProto = szProto; ci.dwFlag = CNF_UNIQUEID; - if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) { + if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { switch(ci.type) { case CNFT_ASCIIZ: hasName = 1; @@ -257,26 +257,26 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l break; case CNFT_DWORD: hasName = 1; - mir_snprintf(buf, SIZEOF(buf),"%u",ci.dVal); + mir_snprintf(buf, SIZEOF(buf), "%u", ci.dVal); break; } } if ( hasName ) - SetDlgItemTextA(hwndDlg,IDC_NAME,buf); + SetDlgItemTextA(hwndDlg, IDC_NAME, buf); else - SetDlgItemText(hwndDlg,IDC_NAME,contactName); + SetDlgItemText(hwndDlg, IDC_NAME, contactName); } } if ( fsd->ppFiles == NULL ) { EnableWindow(hwndDlg, FALSE); dat->closeIfFileChooseCancelled=1; - PostMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_CHOOSE,BN_CLICKED),(LPARAM)GetDlgItem(hwndDlg,IDC_CHOOSE)); + PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_CHOOSE, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDC_CHOOSE)); } return TRUE; } case WM_MEASUREITEM: - return CallService(MS_CLIST_MENUMEASUREITEM,wParam,lParam); + return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: { @@ -284,14 +284,14 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto; - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); + szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); if (szProto) { - HICON hIcon = (HICON)CallProtoService(szProto,PS_LOADICON,PLI_PROTOCOL|PLIF_SMALL,0); + 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, NULL, DI_NORMAL); DestroyIcon(hIcon); } } } } - return CallService(MS_CLIST_MENUDRAWITEM,wParam,lParam); + return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case M_FILECHOOSEDONE: if ( lParam != 0 ) { @@ -300,27 +300,27 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l dat->closeIfFileChooseCancelled = 0; } else if (dat->closeIfFileChooseCancelled) DestroyWindow(hwndDlg); - EnableWindow(hwndDlg,TRUE); + EnableWindow(hwndDlg, TRUE); break; case WM_COMMAND: - if (CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU),(LPARAM)dat->hContact)) + if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { case IDC_CHOOSE: - EnableWindow(hwndDlg,FALSE); + EnableWindow(hwndDlg, FALSE); //GetOpenFileName() creates its own message queue which prevents any incoming events being processed - forkthread(ChooseFilesThread,0,hwndDlg); + forkthread(ChooseFilesThread, 0, hwndDlg); break; case IDOK: - EnableWindow(GetDlgItem(hwndDlg,IDC_FILENAME),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_MSG),FALSE); - EnableWindow(GetDlgItem(hwndDlg,IDC_CHOOSE),FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSE), FALSE); - GetDlgItemText(hwndDlg,IDC_FILEDIR,dat->szSavePath,SIZEOF(dat->szSavePath)); - GetDlgItemText(hwndDlg,IDC_FILE,dat->szFilenames,SIZEOF(dat->szFilenames)); - GetDlgItemText(hwndDlg,IDC_MSG,dat->szMsg,SIZEOF(dat->szMsg)); + GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, SIZEOF(dat->szSavePath)); + GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, SIZEOF(dat->szFilenames)); + GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, SIZEOF(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr( hwndDlg, GWLP_USERDATA, 0); DestroyWindow(hwndDlg); @@ -332,31 +332,31 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDC_USERMENU: { RECT rc; - HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT,(WPARAM)dat->hContact,0); - GetWindowRect((HWND)lParam,&rc); - TrackPopupMenu(hMenu,0,rc.left,rc.bottom,0,hwndDlg,NULL); + HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); + GetWindowRect((HWND)lParam, &rc); + TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); break; } case IDC_DETAILS: - CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)dat->hContact,0); + CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); return TRUE; case IDC_HISTORY: - CallService(MS_HISTORY_SHOWCONTACTHISTORY,(WPARAM)dat->hContact,0); + CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); return TRUE; } break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); - Button_FreeIcon_IcoLib(hwndDlg,IDC_DETAILS); - Button_FreeIcon_IcoLib(hwndDlg,IDC_HISTORY); - Button_FreeIcon_IcoLib(hwndDlg,IDC_USERMENU); + Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); + Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); + Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); if ( dat ) FreeFileDlgData( dat ); - SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_MSG),GWLP_WNDPROC,(LONG_PTR)OldSendEditProc); + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MSG), GWLP_WNDPROC, (LONG_PTR)OldSendEditProc); return TRUE; } return FALSE; diff --git a/src/modules/srfile/filexferdlg.cpp b/src/modules/srfile/filexferdlg.cpp index 7c7adf8281..ab7090166b 100644 --- a/src/modules/srfile/filexferdlg.cpp +++ b/src/modules/srfile/filexferdlg.cpp @@ -2,7 +2,7 @@ Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2010 Miranda ICQ/IM project, +Copyright 2000-2010 Miranda ICQ/IM project, all portions of this codebase are copyrighted to the people listed in contributors.txt. @@ -11,7 +11,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -26,13 +26,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define HM_RECVEVENT (WM_USER+10) -static int CheckVirusScanned(HWND hwnd,struct FileDlgData *dat,int i) +static int CheckVirusScanned(HWND hwnd, struct FileDlgData *dat, int i) { if (dat->send) return 1; if (dat->fileVirusScanned == NULL) return 0; if (dat->fileVirusScanned[i]) return 1; - if (DBGetContactSettingByte(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); + if (DBGetContactSettingByte(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); } #define M_VIRUSSCANDONE (WM_USER+100) @@ -88,15 +88,15 @@ int PFTS_CompareWithTchar( PROTOFILETRANSFERSTATUS* ft, const PROTOCHAR* s, TCHA #endif } -static void SetOpenFileButtonStyle(HWND hwndButton,int enabled) +static void SetOpenFileButtonStyle(HWND hwndButton, int enabled) { - EnableWindow(hwndButton,enabled); + EnableWindow(hwndButton, enabled); } void FillSendData( FileDlgData* dat, DBEVENTINFO& dbei ) { dbei.cbSize = sizeof(dbei); - dbei.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); + dbei.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); dbei.eventType = EVENTTYPE_FILE; dbei.flags = DBEF_SENT; dbei.timestamp = time(NULL); @@ -110,8 +110,8 @@ void FillSendData( FileDlgData* dat, DBEVENTINFO& dbei ) dbei.cbBlob = sizeof(DWORD) + lstrlenA(szFileNames)+lstrlenA(szMsg)+2; dbei.pBlob=(PBYTE)mir_alloc(dbei.cbBlob); *(PDWORD)dbei.pBlob=0; - lstrcpyA((char*)dbei.pBlob+sizeof(DWORD),szFileNames); - lstrcpyA((char*)dbei.pBlob+sizeof(DWORD)+lstrlenA(szFileNames)+1,szMsg); + lstrcpyA((char*)dbei.pBlob+sizeof(DWORD), szFileNames); + lstrcpyA((char*)dbei.pBlob+sizeof(DWORD)+lstrlenA(szFileNames)+1, szMsg); #if defined( _UNICODE ) mir_free( szFileNames ), mir_free( szMsg ); @@ -125,7 +125,7 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) DBVARIANT dbv; TCHAR szCmdLine[768]; - if (!DBGetContactSettingTString(NULL,"SRFile", "ScanCmdLine", &dbv)) + if (!DBGetContactSettingTString(NULL, "SRFile", "ScanCmdLine", &dbv)) { if (dbv.ptszVal[0]) { @@ -140,9 +140,9 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) mir_sntprintf(szCmdLine, SIZEOF(szCmdLine), _T("%s\"%s\"%s"), dbv.ptszVal, info->szFile, pszReplace+2); } else lstrcpyn(szCmdLine, dbv.ptszVal, SIZEOF(szCmdLine)); - if (CreateProcess(NULL,szCmdLine,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi)) { - if (WaitForSingleObject(pi.hProcess,3600*1000) == WAIT_OBJECT_0) - PostMessage(info->hwndReply,M_VIRUSSCANDONE,info->returnCode,0); + if (CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { + if (WaitForSingleObject(pi.hProcess, 3600*1000) == WAIT_OBJECT_0) + PostMessage(info->hwndReply, M_VIRUSSCANDONE, info->returnCode, 0); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } @@ -169,8 +169,8 @@ static void SetFilenameControls(HWND hwndDlg, struct FileDlgData *dat, PROTOFILE if (dat->hIcon) DestroyIcon(dat->hIcon); dat->hIcon = NULL; if (fn && (fts->totalFiles > 1)) { - mir_sntprintf(msg, SIZEOF(msg), _T("%s: %s (%d %s %d)"), - cli.pfnGetContactDisplayName( fts->hContact, 0 ), + mir_sntprintf(msg, SIZEOF(msg), _T("%s: %s (%d %s %d)"), + cli.pfnGetContactDisplayName( fts->hContact, 0 ), fn, fts->currentFileNumber+1, TranslateT("of"), fts->totalFiles); SHGetFileInfo(fn, FILE_ATTRIBUTE_DIRECTORY, &shfi, sizeof(shfi), SHGFI_USEFILEATTRIBUTES|SHGFI_ICON|SHGFI_SMALLICON); @@ -198,13 +198,13 @@ static void SetFilenameControls(HWND hwndDlg, struct FileDlgData *dat, PROTOFILE enum { FTS_TEXT, FTS_PROGRESS, FTS_OPEN }; static void SetFtStatus(HWND hwndDlg, TCHAR *text, int mode) { - SetDlgItemText(hwndDlg,IDC_STATUS,TranslateTS(text)); - SetDlgItemText(hwndDlg,IDC_TRANSFERCOMPLETED,TranslateTS(text)); + SetDlgItemText(hwndDlg, IDC_STATUS, TranslateTS(text)); + SetDlgItemText(hwndDlg, IDC_TRANSFERCOMPLETED, TranslateTS(text)); - ShowWindow(GetDlgItem(hwndDlg,IDC_STATUS), (mode == FTS_TEXT)?SW_SHOW:SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg,IDC_ALLFILESPROGRESS), (mode == FTS_PROGRESS)?SW_SHOW:SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg,IDC_TRANSFERCOMPLETED), (mode == FTS_OPEN)?SW_SHOW:SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg,IDC_FILEICON), (mode == FTS_OPEN)?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_STATUS), (mode == FTS_TEXT)?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_ALLFILESPROGRESS), (mode == FTS_PROGRESS)?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_TRANSFERCOMPLETED), (mode == FTS_OPEN)?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_FILEICON), (mode == FTS_OPEN)?SW_SHOW:SW_HIDE); } static void HideProgressControls(HWND hwndDlg) @@ -262,12 +262,12 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR TranslateDialogDefault(hwndDlg); dat = (FileDlgData*)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - dat->hNotifyEvent=HookEventMessage(ME_PROTO_ACK,hwndDlg,HM_RECVEVENT); + dat->hNotifyEvent=HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_RECVEVENT); dat->transferStatus.currentFileNumber = -1; if (dat->send) { - dat->fs=(HANDLE)CallContactService(dat->hContact,PSS_FILET,(WPARAM)dat->szMsg,(LPARAM)dat->files); + dat->fs=(HANDLE)CallContactService(dat->hContact, PSS_FILET, (WPARAM)dat->szMsg, (LPARAM)dat->files); SetFtStatus(hwndDlg, LPGENT("Request sent, waiting for acceptance..."), FTS_TEXT); - SetOpenFileButtonStyle(GetDlgItem(hwndDlg,IDC_OPENFILE),1); + SetOpenFileButtonStyle(GetDlgItem(hwndDlg, IDC_OPENFILE), 1); dat->waitingForAcceptance=1; // hide "open" button since it may cause potential access violations... ShowWindow(GetDlgItem(hwndDlg, IDC_OPENFILE), SW_HIDE); @@ -275,10 +275,10 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } else { //recv CreateDirectoryTreeT(dat->szSavePath); - dat->fs=(HANDLE)CallContactService(dat->hContact,PSS_FILEALLOWT,(WPARAM)dat->fs,(LPARAM)dat->szSavePath); + dat->fs=(HANDLE)CallContactService(dat->hContact, PSS_FILEALLOWT, (WPARAM)dat->fs, (LPARAM)dat->szSavePath); dat->transferStatus.tszWorkingDir = mir_tstrdup(dat->szSavePath); - if (DBGetContactSettingByte(dat->hContact,"CList","NotOnList",0)) dat->resumeBehaviour=FILERESUME_ASK; - else dat->resumeBehaviour=DBGetContactSettingByte(NULL,"SRFile","IfExists",FILERESUME_ASK); + if (DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) dat->resumeBehaviour=FILERESUME_ASK; + else dat->resumeBehaviour=DBGetContactSettingByte(NULL, "SRFile", "IfExists", FILERESUME_ASK); SetFtStatus(hwndDlg, LPGENT("Waiting for connection..."), FTS_TEXT); } { @@ -290,11 +290,11 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } { LOGFONT lf; HFONT hFont; - hFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_CONTACTNAME,WM_GETFONT,0,0); - GetObject(hFont,sizeof(lf),&lf); + hFont=(HFONT)SendDlgItemMessage(hwndDlg, IDC_CONTACTNAME, WM_GETFONT, 0, 0); + GetObject(hFont, sizeof(lf), &lf); lf.lfWeight=FW_BOLD; hFont=CreateFontIndirect(&lf); - SendDlgItemMessage(hwndDlg,IDC_CONTACTNAME,WM_SETFONT,(WPARAM)hFont,0); + SendDlgItemMessage(hwndDlg, IDC_CONTACTNAME, WM_SETFONT, (WPARAM)hFont, 0); } { SHFILEINFO shfi = {0}; @@ -304,7 +304,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR dat->hIcon = NULL; - SendDlgItemMessage(hwndDlg, IDC_CONTACT, BM_SETIMAGE, IMAGE_ICON, + SendDlgItemMessage(hwndDlg, IDC_CONTACT, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadSkinnedProtoIcon((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0), ID_STATUS_ONLINE)); SendDlgItemMessage(hwndDlg, IDC_CONTACT, BUTTONADDTOOLTIP, (WPARAM)LPGEN("Contact menu"), 0); SendDlgItemMessage(hwndDlg, IDC_CONTACT, BUTTONSETASFLATBTN, 0, 0); @@ -320,10 +320,10 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetDlgItemText(hwndDlg, IDC_CONTACTNAME, cli.pfnGetContactDisplayName( dat->hContact, 0 )); - if (!dat->waitingForAcceptance) SetTimer(hwndDlg,1,1000,NULL); + if (!dat->waitingForAcceptance) SetTimer(hwndDlg, 1, 1000, NULL); return TRUE; case WM_TIMER: - MoveMemory(dat->bytesRecvedHistory+1,dat->bytesRecvedHistory,sizeof(dat->bytesRecvedHistory)-sizeof(dat->bytesRecvedHistory[0])); + MoveMemory(dat->bytesRecvedHistory+1, dat->bytesRecvedHistory, sizeof(dat->bytesRecvedHistory)-sizeof(dat->bytesRecvedHistory[0])); dat->bytesRecvedHistory[0]=dat->transferStatus.totalProgress; if ( dat->bytesRecvedHistorySize < SIZEOF(dat->bytesRecvedHistory)) dat->bytesRecvedHistorySize++; @@ -333,32 +333,32 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ULARGE_INTEGER li; FILETIME ft; - GetSensiblyFormattedSize((dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1])/dat->bytesRecvedHistorySize,szSpeed,SIZEOF(szSpeed),0,1,NULL); + GetSensiblyFormattedSize((dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1])/dat->bytesRecvedHistorySize, szSpeed, SIZEOF(szSpeed), 0, 1, NULL); if (dat->bytesRecvedHistory[0] == dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]) - lstrcpy(szTime,_T("??:??:??")); + lstrcpy(szTime, _T("??:??:??")); else { li.QuadPart=BIGI(10000000)*(dat->transferStatus.currentFileSize-dat->transferStatus.currentFileProgress)*dat->bytesRecvedHistorySize/(dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]); ft.dwHighDateTime=li.HighPart; ft.dwLowDateTime=li.LowPart; - FileTimeToSystemTime(&ft,&st); - GetTimeFormat(LOCALE_USER_DEFAULT,TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER,&st,NULL,szTime,SIZEOF(szTime)); + FileTimeToSystemTime(&ft, &st); + GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER, &st, NULL, szTime, SIZEOF(szTime)); } if (dat->bytesRecvedHistory[0] != dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]) { li.QuadPart=BIGI(10000000)*(dat->transferStatus.totalBytes-dat->transferStatus.totalProgress)*dat->bytesRecvedHistorySize/(dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]); ft.dwHighDateTime=li.HighPart; ft.dwLowDateTime=li.LowPart; - FileTimeToSystemTime(&ft,&st); - GetTimeFormat(LOCALE_USER_DEFAULT,TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER,&st,NULL,szTime,SIZEOF(szTime)); + FileTimeToSystemTime(&ft, &st); + GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER, &st, NULL, szTime, SIZEOF(szTime)); } - mir_sntprintf(szDisplay,SIZEOF(szDisplay),_T("%s/%s (%s %s)"),szSpeed,TranslateT("sec"),szTime,TranslateT("remaining")); - SetDlgItemText(hwndDlg,IDC_ALLSPEED,szDisplay); + mir_sntprintf(szDisplay, SIZEOF(szDisplay), _T("%s/%s (%s %s)"), szSpeed, TranslateT("sec"), szTime, TranslateT("remaining")); + SetDlgItemText(hwndDlg, IDC_ALLSPEED, szDisplay); } break; case WM_MEASUREITEM: - return CallService(MS_CLIST_MENUMEASUREITEM,wParam,lParam); + return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: - return CallService(MS_CLIST_MENUDRAWITEM,wParam,lParam); + return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case WM_FT_CLEANUP: if (!dat->fs) @@ -369,7 +369,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break; case WM_COMMAND: - if ( CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU), (LPARAM)dat->hContact )) + if ( CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact )) break; switch (LOWORD(wParam)) @@ -382,9 +382,9 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case IDC_CONTACT: { RECT rc; - HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT,(WPARAM)dat->hContact,0); - GetWindowRect((HWND)lParam,&rc); - TrackPopupMenu(hMenu,0,rc.left,rc.bottom,0,hwndDlg,NULL); + HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); + GetWindowRect((HWND)lParam, &rc); + TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); break; } @@ -432,7 +432,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (files && *files) { int i, limit; - TCHAR *pszFilename,*pszNewFileName; + TCHAR *pszFilename, *pszNewFileName; if (dat->send) limit = dat->transferStatus.totalFiles; @@ -492,12 +492,12 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case M_FILEEXISTSDLGREPLY: { PROTOFILERESUME *pfr=(PROTOFILERESUME*)lParam; TCHAR *szOriginalFilename=(TCHAR*)wParam; - char *szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); + char *szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); - EnableWindow(hwndDlg,TRUE); + EnableWindow(hwndDlg, TRUE); switch(pfr->action) { case FILERESUME_CANCEL: - if (dat->fs) CallContactService(dat->hContact,PSS_FILECANCEL,(WPARAM)dat->fs,0); + if (dat->fs) CallContactService(dat->hContact, PSS_FILECANCEL, (WPARAM)dat->fs, 0); dat->fs=NULL; mir_free(szOriginalFilename); if (pfr->szFilename) mir_free((char*)pfr->szFilename); @@ -510,22 +510,22 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break; case FILERESUME_RENAMEALL: pfr->action=FILERESUME_RENAME; - { TCHAR *pszExtension,*pszFilename; + { TCHAR *pszExtension, *pszFilename; int i; - if ((pszFilename = _tcsrchr(szOriginalFilename,'\\')) == NULL) pszFilename=szOriginalFilename; - if ((pszExtension = _tcsrchr(pszFilename+1,'.')) == NULL) pszExtension=pszFilename+lstrlen(pszFilename); + if ((pszFilename = _tcsrchr(szOriginalFilename, '\\')) == NULL) pszFilename=szOriginalFilename; + if ((pszExtension = _tcsrchr(pszFilename+1, '.')) == NULL) pszExtension=pszFilename+lstrlen(pszFilename); if (pfr->szFilename) mir_free((TCHAR*)pfr->szFilename); pfr->szFilename = (TCHAR*)mir_alloc(sizeof(TCHAR)*((pszExtension-szOriginalFilename)+21+lstrlen(pszExtension))); for (i=1;;i++) { - _stprintf((TCHAR*)pfr->szFilename,_T("%.*s (%u)%s"),pszExtension-szOriginalFilename,szOriginalFilename,i,pszExtension); - if (_taccess(pfr->szFilename,0) != 0) + _stprintf((TCHAR*)pfr->szFilename, _T("%.*s (%u)%s"), pszExtension-szOriginalFilename, szOriginalFilename, i, pszExtension); + if (_taccess(pfr->szFilename, 0) != 0) break; } } break; } mir_free(szOriginalFilename); - CallProtoService(szProto,PS_FILERESUMET,(WPARAM)dat->fs,(LPARAM)pfr); + CallProtoService(szProto, PS_FILERESUMET, (WPARAM)dat->fs, (LPARAM)pfr); if (pfr->szFilename) mir_free((char*)pfr->szFilename); mir_free(pfr); break; @@ -537,7 +537,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (ack->type != ACKTYPE_FILE) break; if (dat->waitingForAcceptance) { - SetTimer(hwndDlg,1,1000,NULL); + SetTimer(hwndDlg, 1, 1000, NULL); dat->waitingForAcceptance=0; } switch(ack->result) { @@ -549,19 +549,19 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case ACKRESULT_INITIALISING: SetFtStatus(hwndDlg, LPGENT("Initialising..."), FTS_TEXT); break; case ACKRESULT_NEXTFILE: SetFtStatus(hwndDlg, LPGENT("Moving to next file..."), FTS_TEXT); - SetDlgItemTextA(hwndDlg,IDC_FILENAME,""); + SetDlgItemTextA(hwndDlg, IDC_FILENAME, ""); if (dat->transferStatus.currentFileNumber == 1 && dat->transferStatus.totalFiles>1 && !dat->send) - SetOpenFileButtonStyle(GetDlgItem(hwndDlg,IDC_OPENFILE),1); - if (dat->transferStatus.currentFileNumber != -1 && dat->files && !dat->send && DBGetContactSettingByte(NULL,"SRFile","UseScanner",VIRUSSCAN_DISABLE) == VIRUSSCAN_DURINGDL) { + SetOpenFileButtonStyle(GetDlgItem(hwndDlg, IDC_OPENFILE), 1); + if (dat->transferStatus.currentFileNumber != -1 && dat->files && !dat->send && DBGetContactSettingByte(NULL, "SRFile", "UseScanner", VIRUSSCAN_DISABLE) == VIRUSSCAN_DURINGDL) { if (GetFileAttributes(dat->files[dat->transferStatus.currentFileNumber])&FILE_ATTRIBUTE_DIRECTORY) - PostMessage(hwndDlg,M_VIRUSSCANDONE,dat->transferStatus.currentFileNumber,0); + PostMessage(hwndDlg, M_VIRUSSCANDONE, dat->transferStatus.currentFileNumber, 0); else { virusscanthreadstartinfo *vstsi; vstsi=(struct virusscanthreadstartinfo*)mir_alloc(sizeof(struct virusscanthreadstartinfo)); vstsi->hwndReply = hwndDlg; vstsi->szFile = mir_tstrdup(dat->files[dat->transferStatus.currentFileNumber]); vstsi->returnCode = dat->transferStatus.currentFileNumber; - forkthread((void (*)(void*))RunVirusScannerThread,0,vstsi); + forkthread((void (*)(void*))RunVirusScannerThread, 0, vstsi); } } break; @@ -578,24 +578,24 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetFtStatus(hwndDlg, LPGENT("File already exists"), FTS_TEXT); if (dat->resumeBehaviour == FILERESUME_ASK) { TDlgProcFileExistsParam param = { hwndDlg, fts }; - ShowWindow(hwndDlg,SW_SHOWNORMAL); - CreateDialogParam(hMirandaInst,MAKEINTRESOURCE(IDD_FILEEXISTS),hwndDlg,DlgProcFileExists,(LPARAM)¶m); - EnableWindow(hwndDlg,FALSE); + ShowWindow(hwndDlg, SW_SHOWNORMAL); + CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILEEXISTS), hwndDlg, DlgProcFileExists, (LPARAM)¶m); + EnableWindow(hwndDlg, FALSE); } else { PROTOFILERESUME *pfr; pfr=(PROTOFILERESUME*)mir_alloc(sizeof(PROTOFILERESUME)); pfr->action = dat->resumeBehaviour; pfr->szFilename = NULL; - PostMessage(hwndDlg,M_FILEEXISTSDLGREPLY,(WPARAM)mir_tstrdup(fts->tszCurrentFile),(LPARAM)pfr); + PostMessage(hwndDlg, M_FILEEXISTSDLGREPLY, (WPARAM)mir_tstrdup(fts->tszCurrentFile), (LPARAM)pfr); } - SetWindowLongPtr(hwndDlg,DWLP_MSGRESULT,1); + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, 1); return TRUE; } case ACKRESULT_DATA: { PROTOFILETRANSFERSTATUS *fts=(PROTOFILETRANSFERSTATUS*)ack->lParam; - TCHAR str[64], str2[64], szSizeDone[32], szSizeTotal[32];//,*contactName; + TCHAR str[64], str2[64], szSizeDone[32], szSizeTotal[32];//, *contactName; int units; if ( dat->fileVirusScanned == NULL ) @@ -649,10 +649,10 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { HideProgressControls(hwndDlg); - KillTimer(hwndDlg,1); + KillTimer(hwndDlg, 1); if (!dat->send) - SetOpenFileButtonStyle(GetDlgItem(hwndDlg,IDC_OPENFILE),1); - SetDlgItemText(hwndDlg,IDCANCEL,TranslateT("Close")); + SetOpenFileButtonStyle(GetDlgItem(hwndDlg, IDC_OPENFILE), 1); + SetDlgItemText(hwndDlg, IDCANCEL, TranslateT("Close")); if (dat->hNotifyEvent) UnhookEvent(dat->hNotifyEvent); dat->hNotifyEvent=NULL; @@ -676,19 +676,19 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR DBEVENTINFO dbei={0}; FillSendData( dat, dbei ); - CallService(MS_DB_EVENT_ADD,(WPARAM)dat->hContact,(LPARAM)&dbei); + CallService(MS_DB_EVENT_ADD, (WPARAM)dat->hContact, (LPARAM)&dbei); if (dbei.pBlob) mir_free(dbei.pBlob); dat->files=NULL; //protocol library frees this } else { - SetFtStatus(hwndDlg, + SetFtStatus(hwndDlg, (dat->transferStatus.totalFiles == 1) ? LPGENT("Transfer completed, open file.") : - LPGENT("Transfer completed, open folder."), + LPGENT("Transfer completed, open folder."), FTS_OPEN); - int useScanner=DBGetContactSettingByte(NULL,"SRFile","UseScanner",VIRUSSCAN_DISABLE); + int useScanner=DBGetContactSettingByte(NULL, "SRFile", "UseScanner", VIRUSSCAN_DISABLE); if (useScanner != VIRUSSCAN_DISABLE) { struct virusscanthreadstartinfo *vstsi; vstsi=(struct virusscanthreadstartinfo*)mir_alloc(sizeof(struct virusscanthreadstartinfo)); @@ -696,7 +696,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (useScanner == VIRUSSCAN_DURINGDL) { vstsi->returnCode=dat->transferStatus.currentFileNumber; if ( GetFileAttributes(dat->files[dat->transferStatus.currentFileNumber])&FILE_ATTRIBUTE_DIRECTORY) { - PostMessage(hwndDlg,M_VIRUSSCANDONE,vstsi->returnCode,0); + PostMessage(hwndDlg, M_VIRUSSCANDONE, vstsi->returnCode, 0); mir_free(vstsi); vstsi=NULL; } @@ -707,7 +707,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR vstsi->returnCode = -1; } SetFtStatus(hwndDlg, LPGENT("Scanning for viruses..."), FTS_TEXT); - if (vstsi) forkthread((void (*)(void*))RunVirusScannerThread,0,vstsi); + if (vstsi) forkthread((void (*)(void*))RunVirusScannerThread, 0, vstsi); } else { dat->fs=NULL; /* protocol will free structure */ } @@ -723,7 +723,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } // switch ack->result } break; // case HM_RECVEVENT case M_VIRUSSCANDONE: - { int done=1,i; + { int done=1, i; if ((int)wParam == -1) { for (i=0;itransferStatus.totalFiles;i++) dat->fileVirusScanned[i]=1; } @@ -746,7 +746,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR urd.hInstance=hMirandaInst; urd.lpTemplate=MAKEINTRESOURCEA(IDD_FILETRANSFERINFO); urd.pfnResizer=FileTransferDlgResizer; - CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); + CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); RedrawWindow(GetDlgItem(hwndDlg, IDC_ALLTRANSFERRED), NULL, NULL, RDW_INVALIDATE|RDW_NOERASE); RedrawWindow(GetDlgItem(hwndDlg, IDC_ALLSPEED), NULL, NULL, RDW_INVALIDATE|RDW_NOERASE); @@ -757,7 +757,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case WM_DESTROY: KillTimer(hwndDlg, 1); - HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg,IDC_CONTACTNAME,WM_GETFONT,0,0); + HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_CONTACTNAME, WM_GETFONT, 0, 0); DeleteObject(hFont); Button_FreeIcon_IcoLib(hwndDlg, IDC_CONTACT); @@ -773,7 +773,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR void FreeFileDlgData( FileDlgData* dat ) { if (dat->fs) - CallContactService(dat->hContact,PSS_FILECANCEL,(WPARAM)dat->fs,0); + CallContactService(dat->hContact, PSS_FILECANCEL, (WPARAM)dat->fs, 0); dat->fs = NULL; if (dat->hPreshutdownEvent) UnhookEvent(dat->hPreshutdownEvent); diff --git a/src/modules/srfile/ftmanager.cpp b/src/modules/srfile/ftmanager.cpp index 4199c5b255..0b321ee16c 100644 --- a/src/modules/srfile/ftmanager.cpp +++ b/src/modules/srfile/ftmanager.cpp @@ -2,7 +2,7 @@ Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, +Copyright 2000-2009 Miranda ICQ/IM project, all portions of this codebase are copyrighted to the people listed in contributors.txt. @@ -11,7 +11,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -179,7 +179,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA if (i == dat->wnds->realCount) PostMessage(GetParent(hwnd), WM_TIMER, 1, NULL); - if (dat->runningCount == 0 && (int)wParam == ACKRESULT_SUCCESS && DBGetContactSettingByte(NULL,"SRFile","AutoClose",0)) + if (dat->runningCount == 0 && (int)wParam == ACKRESULT_SUCCESS && DBGetContactSettingByte(NULL, "SRFile", "AutoClose", 0)) ShowWindow(hwndFtMgr, SW_HIDE); break; } @@ -532,7 +532,7 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM HWND FtMgr_Show(bool bForceActivate, bool bFromMenu) { - bool bAutoMin = DBGetContactSettingByte(NULL,"SRFile","AutoMin",0) != 0; /* lqbe */ + bool bAutoMin = DBGetContactSettingByte(NULL, "SRFile", "AutoMin", 0) != 0; /* lqbe */ bool bJustCreated = (hwndFtMgr == NULL); if (bJustCreated) -- cgit v1.2.3