From 3f23417a1099f73dc28ec1b7d6ec2a1a7fc2b7a2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 18 Jun 2012 20:53:59 +0000 Subject: - PLUGININFO structure removed at all; - Options_AddPage & UserInfo_AddPage replaced MS_OPT_ADDPAGE & MS_USERINFO_ADDPAGE services respectively - total internal redesign of options' translation - code reformatting git-svn-id: http://svn.miranda-ng.org/main/trunk@477 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/srfile/file.cpp | 106 +++++++++++++++++------------------ src/modules/srfile/file.h | 2 +- src/modules/srfile/fileexistsdlg.cpp | 56 +++++++++--------- src/modules/srfile/fileopts.cpp | 10 ++-- src/modules/srfile/filerecvdlg.cpp | 88 ++++++++++++++--------------- src/modules/srfile/filesenddlg.cpp | 72 ++++++++++++------------ src/modules/srfile/filexferdlg.cpp | 96 +++++++++++++++---------------- src/modules/srfile/ftmanager.cpp | 8 +-- 8 files changed, 219 insertions(+), 219 deletions(-) (limited to 'src/modules/srfile') diff --git a/src/modules/srfile/file.cpp b/src/modules/srfile/file.cpp index 6570bc296a..9d142fcdbe 100644 --- a/src/modules/srfile/file.cpp +++ b/src/modules/srfile/file.cpp @@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h" #include "file.h" -TCHAR* PFTS_StringToTchar( int flags, const PROTOCHAR* s ); -int PFTS_CompareWithTchar( PROTOFILETRANSFERSTATUS* ft, const PROTOCHAR* s, TCHAR* r ); +TCHAR* PFTS_StringToTchar(int flags, const PROTOCHAR* s); +int PFTS_CompareWithTchar(PROTOFILETRANSFERSTATUS* ft, const PROTOCHAR* s, TCHAR* r); static HANDLE hSRFileMenuItem; @@ -42,19 +42,19 @@ static INT_PTR SendSpecificFiles(WPARAM wParam, LPARAM lParam) FileSendData fsd; fsd.hContact=(HANDLE)wParam; - char** ppFiles = ( char** )lParam; + char** ppFiles = (char**)lParam; int count = 0; - while ( ppFiles[count] != NULL ) + while (ppFiles[count] != NULL) count++; - fsd.ppFiles = (const TCHAR**)alloca(( count+1 ) * sizeof( void* )); - for ( int i=0; i < count; i++ ) - fsd.ppFiles[i] = ( const TCHAR* )mir_a2t( ppFiles[i] ); + fsd.ppFiles = (const TCHAR**)alloca((count+1) * sizeof(void*)); + for (int i=0; i < count; i++) + fsd.ppFiles[i] = (const TCHAR*)mir_a2t(ppFiles[i]); fsd.ppFiles[ count ] = NULL; CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd); - for ( int j=0; j < count; j++ ) - mir_free(( void* )fsd.ppFiles[j] ); + for (int j=0; j < count; j++) + mir_free((void*)fsd.ppFiles[j]); return 0; } @@ -83,25 +83,25 @@ static INT_PTR RecvFileCommand(WPARAM, LPARAM lParam) return 0; } -void PushFileEvent( HANDLE hContact, HANDLE hdbe, LPARAM lParam ) +void PushFileEvent(HANDLE hContact, HANDLE hdbe, LPARAM lParam) { CLISTEVENT cle={0}; cle.cbSize = sizeof(cle); cle.hContact = hContact; cle.hDbEvent = hdbe; cle.lParam = lParam; - if ( DBGetContactSettingByte(NULL, "SRFile", "AutoAccept", 0) && !DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)) { + 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.hIcon = LoadSkinIcon(SKINICON_EVENT_FILE); cle.pszService = "SRFile/RecvFile"; CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); } } @@ -112,13 +112,13 @@ static int FileEventAdded(WPARAM wParam, LPARAM lParam) DBEVENTINFO dbei={0}; dbei.cbSize = sizeof(dbei); - dbei.cbBlob = sizeof( DWORD ); - dbei.pBlob = ( PBYTE )&dwSignature; - CallService( MS_DB_EVENT_GET, lParam, ( LPARAM )&dbei ); - if ( dbei.flags&(DBEF_SENT|DBEF_READ) || dbei.eventType != EVENTTYPE_FILE || dwSignature == 0 ) + dbei.cbBlob = sizeof(DWORD); + dbei.pBlob = (PBYTE)&dwSignature; + CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei); + if (dbei.flags&(DBEF_SENT|DBEF_READ) || dbei.eventType != EVENTTYPE_FILE || dwSignature == 0) return 0; - PushFileEvent(( HANDLE )wParam, ( HANDLE )lParam, 0 ); + PushFileEvent((HANDLE)wParam, (HANDLE)lParam, 0); return 0; } @@ -127,10 +127,10 @@ int SRFile_GetRegValue(HKEY hKeyBase, const TCHAR *szSubKey, const TCHAR *szValu 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; } @@ -141,7 +141,7 @@ int SRFile_GetRegValue(HKEY hKeyBase, const TCHAR *szSubKey, const TCHAR *szValu void GetSensiblyFormattedSize(__int64 size, TCHAR *szOut, int cchOut, int unitsOverride, int appendUnits, int *unitsUsed) { - if (!unitsOverride) { + if ( !unitsOverride) { if (size<1000) unitsOverride=UNITS_BYTES; else if (size<100*1024) unitsOverride=UNITS_KBPOINT1; else if (size<1024*1024) unitsOverride=UNITS_KBPOINT0; @@ -182,7 +182,7 @@ void FreeProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *fts) { mir_free(fts->tszCurrentFile); if (fts->ptszFiles) { - for ( int i=0;itotalFiles;i++) mir_free(fts->ptszFiles[i]); + for (int i=0;itotalFiles;i++) mir_free(fts->ptszFiles[i]); mir_free(fts->ptszFiles); } mir_free(fts->tszWorkingDir); @@ -191,13 +191,13 @@ void FreeProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *fts) void CopyProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANSFERSTATUS *src) { *dest=*src; - if ( src->tszCurrentFile ) dest->tszCurrentFile = PFTS_StringToTchar(src->flags, src->tszCurrentFile); - if ( src->ptszFiles ) { + if (src->tszCurrentFile) dest->tszCurrentFile = PFTS_StringToTchar(src->flags, src->tszCurrentFile); + if (src->ptszFiles) { dest->ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*)*src->totalFiles); - for ( int i=0; i < src->totalFiles; i++ ) - dest->ptszFiles[i] = PFTS_StringToTchar(src->flags, src->ptszFiles[i] ); + for (int i=0; i < src->totalFiles; i++) + dest->ptszFiles[i] = PFTS_StringToTchar(src->flags, src->ptszFiles[i]); } - if ( src->tszWorkingDir ) dest->tszWorkingDir = PFTS_StringToTchar(src->flags, src->tszWorkingDir ); + if (src->tszWorkingDir) dest->tszWorkingDir = PFTS_StringToTchar(src->flags, src->tszWorkingDir); dest->flags &= ~PFTS_UTF; dest->flags |= PFTS_TCHAR; } @@ -206,46 +206,46 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS { dest->hContact = src->hContact; dest->flags = src->flags; - if ( dest->totalFiles != src->totalFiles ) { - for ( int i=0;itotalFiles;i++) mir_free(dest->ptszFiles[i]); + if (dest->totalFiles != src->totalFiles) { + for (int i=0;itotalFiles;i++) mir_free(dest->ptszFiles[i]); mir_free(dest->ptszFiles); dest->ptszFiles = NULL; dest->totalFiles = src->totalFiles; } - if ( src->ptszFiles ) { - if ( !dest->ptszFiles ) - dest->ptszFiles = ( TCHAR** )mir_calloc( sizeof(TCHAR*)*src->totalFiles); - for ( int i=0; i < src->totalFiles; i++ ) - if ( !dest->ptszFiles[i] || !src->ptszFiles[i] || PFTS_CompareWithTchar( src, src->ptszFiles[i], dest->ptszFiles[i] )) { - mir_free( dest->ptszFiles[i] ); - if ( src->ptszFiles[i] ) - dest->ptszFiles[i] = PFTS_StringToTchar( src->flags, src->ptszFiles[i] ); + if (src->ptszFiles) { + if ( !dest->ptszFiles) + dest->ptszFiles = (TCHAR**)mir_calloc(sizeof(TCHAR*)*src->totalFiles); + for (int i=0; i < src->totalFiles; i++) + if ( !dest->ptszFiles[i] || !src->ptszFiles[i] || PFTS_CompareWithTchar(src, src->ptszFiles[i], dest->ptszFiles[i])) { + mir_free(dest->ptszFiles[i]); + if (src->ptszFiles[i]) + dest->ptszFiles[i] = PFTS_StringToTchar(src->flags, src->ptszFiles[i]); else dest->ptszFiles[i] = NULL; } } else if (dest->ptszFiles) { - for ( int i=0; i < dest->totalFiles; i++ ) + for (int i=0; i < dest->totalFiles; i++) mir_free(dest->ptszFiles[i]); - mir_free( dest->ptszFiles ); + mir_free(dest->ptszFiles); dest->ptszFiles = NULL; } dest->currentFileNumber = src->currentFileNumber; dest->totalBytes = src->totalBytes; dest->totalProgress = src->totalProgress; - if (src->tszWorkingDir && (!dest->tszWorkingDir || PFTS_CompareWithTchar( src, src->tszWorkingDir, dest->tszWorkingDir))) { - mir_free( dest->tszWorkingDir ); - if ( src->tszWorkingDir ) - dest->tszWorkingDir = PFTS_StringToTchar( src->flags, src->tszWorkingDir ); + if (src->tszWorkingDir && ( !dest->tszWorkingDir || PFTS_CompareWithTchar(src, src->tszWorkingDir, dest->tszWorkingDir))) { + mir_free(dest->tszWorkingDir); + if (src->tszWorkingDir) + dest->tszWorkingDir = PFTS_StringToTchar(src->flags, src->tszWorkingDir); else dest->tszWorkingDir = NULL; } - if ( !dest->tszCurrentFile || !src->tszCurrentFile || PFTS_CompareWithTchar( src, src->tszCurrentFile, dest->tszCurrentFile )) { - mir_free( dest->tszCurrentFile ); - if ( src->tszCurrentFile ) - dest->tszCurrentFile = PFTS_StringToTchar( src->flags, src->tszCurrentFile ); + if ( !dest->tszCurrentFile || !src->tszCurrentFile || PFTS_CompareWithTchar(src, src->tszCurrentFile, dest->tszCurrentFile)) { + mir_free(dest->tszCurrentFile); + if (src->tszCurrentFile) + dest->tszCurrentFile = PFTS_StringToTchar(src->flags, src->tszCurrentFile); else dest->tszCurrentFile = NULL; } @@ -268,7 +268,7 @@ static void RemoveUnreadFileEvents(void) while (hDbEvent) { dbei.cbBlob=0; CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); - if (!(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType == EVENTTYPE_FILE) + 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); } @@ -284,10 +284,10 @@ 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 ) + else if (DBGetContactSettingWord((HANDLE)wParam, szProto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) mi.flags = CMIM_FLAGS; } } @@ -300,7 +300,7 @@ static int SRFileModulesLoaded(WPARAM, LPARAM) CLISTMENUITEM mi = { 0 }; mi.cbSize = sizeof(mi); mi.position = -2000020000; - mi.icolibItem = GetSkinIconHandle( SKINICON_EVENT_FILE ); + mi.icolibItem = GetSkinIconHandle(SKINICON_EVENT_FILE); mi.pszName = LPGEN("&File"); mi.pszService = MS_FILE_SENDFILE; mi.flags = CMIF_ICONFROMICOLIB; @@ -340,7 +340,7 @@ int LoadSendRecvFileModule(void) CLISTMENUITEM mi = { 0 }; mi.cbSize = sizeof(mi); mi.flags = CMIF_ICONFROMICOLIB; - mi.icolibItem = GetSkinIconHandle( SKINICON_EVENT_FILE ); + mi.icolibItem = GetSkinIconHandle(SKINICON_EVENT_FILE); mi.position = 1900000000; mi.pszName = LPGEN("File &Transfers..."); mi.pszService = "FtMgr/Show"; //MS_PROTO_SHOWFTMGR; diff --git a/src/modules/srfile/file.h b/src/modules/srfile/file.h index f4e9a63336..b152812467 100644 --- a/src/modules/srfile/file.h +++ b/src/modules/srfile/file.h @@ -110,6 +110,6 @@ HWND FtMgr_Show(bool bForceActivate, bool bFromMenu); void FtMgr_Destroy(); HWND FtMgr_AddTransfer(struct FileDlgData *dat); -void FreeFileDlgData( FileDlgData* dat ); +void FreeFileDlgData(FileDlgData* dat); TCHAR *GetContactID(HANDLE hContact); diff --git a/src/modules/srfile/fileexistsdlg.cpp b/src/modules/srfile/fileexistsdlg.cpp index 4414e69c2a..d98ce59f78 100644 --- a/src/modules/srfile/fileexistsdlg.cpp +++ b/src/modules/srfile/fileexistsdlg.cpp @@ -54,7 +54,7 @@ static void DoAnnoyingShellCommand(HWND hwnd, const TCHAR *szFilename, int cmd, IShellFolder *pDesktopFolder; if (SHGetDesktopFolder(&pDesktopFolder) == NOERROR) { ITEMIDLIST *pCurrentIdl; - WCHAR* wszFilename = ( LPWSTR )szFilename; + WCHAR* wszFilename = (LPWSTR)szFilename; if (pDesktopFolder->ParseDisplayName(NULL, NULL, wszFilename, NULL, &pCurrentIdl, NULL) == NOERROR) { if (pCurrentIdl->mkid.cb) { @@ -127,8 +127,8 @@ static LRESULT CALLBACK IconCtrlSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_RBUTTONUP: { POINT pt; pt.x=(short)LOWORD(lParam); pt.y=(short)HIWORD(lParam); - ClientToScreen( hwnd, &pt ); - DoAnnoyingShellCommand( hwnd, pft->tszCurrentFile, C_CONTEXTMENU, &pt ); + ClientToScreen(hwnd, &pt); + DoAnnoyingShellCommand(hwnd, pft->tszCurrentFile, C_CONTEXTMENU, &pt); return 0; } } @@ -141,33 +141,33 @@ struct loadiconsstartinfo { }; void __cdecl LoadIconsAndTypesThread(void* param) { - loadiconsstartinfo *info = ( loadiconsstartinfo* )param; + loadiconsstartinfo *info = (loadiconsstartinfo*)param; SHFILEINFO fileInfo; - if ( SHGetFileInfo( info->szFilename, 0, &fileInfo, sizeof(fileInfo), SHGFI_TYPENAME|SHGFI_ICON|SHGFI_LARGEICON)) { + 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, '\\'); - if ( pszFilename == NULL ) + if (pszFilename == NULL) pszFilename = info->szFilename; - pszExtension = _tcsrchr( pszFilename, '.' ); - if ( pszExtension ) - lstrcpyn( szExtension, pszExtension+1, SIZEOF( szExtension )); + pszExtension = _tcsrchr(pszFilename, '.'); + if (pszExtension) + lstrcpyn(szExtension, pszExtension+1, SIZEOF(szExtension)); else { pszExtension = _T("."); szExtension[0]='\0'; } CharUpper(szExtension); - if ( fileInfo.szTypeName[0] == '\0' ) - mir_sntprintf( fileInfo.szTypeName, SIZEOF(fileInfo.szTypeName), TranslateT("%s File"), 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); szIconFile[0]='\0'; - if ( !lstrcmp( szExtension, _T("EXE"))) { + if ( !lstrcmp(szExtension, _T("EXE"))) { SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("2"), szIconFile, SIZEOF(szIconFile)); } else { @@ -175,22 +175,22 @@ void __cdecl LoadIconsAndTypesThread(void* param) 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"))) + if (_tcsstr(szIconFile, _T("%1"))) 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]) { + if (szIconFile[0]) { int iconIndex; HICON hIcon; TCHAR *pszComma = _tcsrchr(szIconFile, ','); - if ( pszComma == NULL ) + if (pszComma == NULL) iconIndex=0; else { iconIndex = _ttoi(pszComma+1); *pszComma='\0'; } - hIcon = ExtractIcon( hMirandaInst, szIconFile, iconIndex ); - if ( hIcon ) + hIcon = ExtractIcon(hMirandaInst, szIconFile, iconIndex); + if (hIcon) fileInfo.hIcon = hIcon; } SendDlgItemMessage(info->hwndDlg, IDC_NEWICON, STM_SETICON, (WPARAM)fileInfo.hIcon, 0); @@ -227,7 +227,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM pfnIconWindowProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EXISTINGICON), GWLP_WNDPROC, (LONG_PTR)IconCtrlSubclassProc); hwndFocus=GetDlgItem(hwndDlg, IDC_RESUME); - if ( _tstati64(fts->tszCurrentFile, &statbuf) == 0) { + 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); @@ -236,7 +236,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM hwndFocus=GetDlgItem(hwndDlg, IDC_OVERWRITE); } } - loadiconsstartinfo *lisi = ( loadiconsstartinfo* )mir_alloc(sizeof(loadiconsstartinfo)); + loadiconsstartinfo *lisi = (loadiconsstartinfo*)mir_alloc(sizeof(loadiconsstartinfo)); lisi->hwndDlg=hwndDlg; lisi->szFilename = mir_tstrdup(fts->tszCurrentFile); //can be a little slow, so why not? @@ -250,15 +250,15 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM PROTOFILERESUME pfr={0}; switch(LOWORD(wParam)) { case IDC_OPENFILE: - ShellExecute( hwndDlg, NULL, fts->tszCurrentFile, NULL, NULL, SW_SHOW ); + ShellExecute(hwndDlg, NULL, fts->tszCurrentFile, NULL, NULL, SW_SHOW); return FALSE; case IDC_OPENFOLDER: { TCHAR szFile[MAX_PATH]; - lstrcpyn( szFile, fts->tszCurrentFile, SIZEOF(szFile)); - TCHAR* pszLastBackslash = _tcsrchr( szFile, '\\' ); - if ( pszLastBackslash ) + lstrcpyn(szFile, fts->tszCurrentFile, SIZEOF(szFile)); + TCHAR* pszLastBackslash = _tcsrchr(szFile, '\\'); + if (pszLastBackslash) *pszLastBackslash = '\0'; ShellExecute(hwndDlg, NULL, szFile, NULL, NULL, SW_SHOW); return FALSE; @@ -289,21 +289,21 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TCHAR filter[512], *pfilter; TCHAR str[MAX_PATH]; - lstrcpyn( str, fts->tszCurrentFile, SIZEOF(str)); + lstrcpyn(str, fts->tszCurrentFile, SIZEOF(str)); ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; - _tcscpy( filter, TranslateT("All Files")); - _tcscat( filter, _T(" (*)")); + _tcscpy(filter, TranslateT("All Files")); + _tcscat(filter, _T(" (*)")); pfilter = filter + _tcslen(filter) + 1; - _tcscpy( pfilter, _T("*")); + _tcscpy(pfilter, _T("*")); pfilter = pfilter + _tcslen(pfilter) + 1; *pfilter='\0'; ofn.lpstrFilter = filter; ofn.lpstrFile = str; ofn.nMaxFile = SIZEOF(str); ofn.nMaxFileTitle = MAX_PATH; - if (!GetSaveFileName(&ofn)) + if ( !GetSaveFileName(&ofn)) return FALSE; pfr.szFilename = mir_tstrdup(str); diff --git a/src/modules/srfile/fileopts.cpp b/src/modules/srfile/fileopts.cpp index e0189fc56f..bc6bafc3b5 100644 --- a/src/modules/srfile/fileopts.cpp +++ b/src/modules/srfile/fileopts.cpp @@ -84,15 +84,15 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L { TCHAR szScanExe[MAX_PATH]; int i, iItem; - for ( i=0; i < SIZEOF(virusScanners); i++ ) { + 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 ( 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("") ); + iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)_T("")); SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, (LPARAM)-1); } } @@ -192,7 +192,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L if (pszSpace) *pszSpace = 0; } ofn.nMaxFileTitle = MAX_PATH; - if (!GetOpenFileName(&ofn)) break; + if ( !GetOpenFileName(&ofn)) break; if (_tcschr(str, ' ') != NULL) { MoveMemory(str+1, str, SIZEOF(str) - 2 * sizeof(TCHAR)); str[0] = '"'; @@ -241,7 +241,7 @@ int FileOptInitialise(WPARAM wParam, LPARAM) odp.pfnDlgProc = DlgProcFileOpts; odp.flags = ODPF_BOLDGROUPS; odp.nIDBottomSimpleControl = IDC_VIRUSSCANNERGROUP; - CallService( MS_OPT_ADDPAGE, wParam, ( LPARAM )&odp ); + Options_AddPage(wParam, &odp); return 0; } diff --git a/src/modules/srfile/filerecvdlg.cpp b/src/modules/srfile/filerecvdlg.cpp index 5b10dfbf16..bdd4445ef7 100644 --- a/src/modules/srfile/filerecvdlg.cpp +++ b/src/modules/srfile/filerecvdlg.cpp @@ -105,28 +105,28 @@ int BrowseForFolder(HWND hwnd, TCHAR *szPath) static REPLACEVARSARRAY sttVarsToReplace[] = { - { ( TCHAR* )"///", ( TCHAR* )"//" }, - { ( TCHAR* )"//", ( TCHAR* )"/" }, - { ( TCHAR* )"()", ( TCHAR* )"" }, + { (TCHAR*)"///", (TCHAR*)"//" }, + { (TCHAR*)"//", (TCHAR*)"/" }, + { (TCHAR*)"()", (TCHAR*)"" }, { NULL, NULL } }; -static void patchDir( TCHAR* str, size_t strSize ) +static void patchDir(TCHAR* str, size_t strSize) { REPLACEVARSDATA dat = { 0 }; - dat.cbSize = sizeof( dat ); + dat.cbSize = sizeof(dat); dat.dwFlags = RVF_TCHAR; dat.variables = sttVarsToReplace; - TCHAR* result = ( TCHAR* )CallService( MS_UTILS_REPLACEVARS, (WPARAM)str, (LPARAM)&dat ); - if ( result ) { - _tcsncpy( str, result, strSize ); - mir_free( result ); + TCHAR* result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)str, (LPARAM)&dat); + if (result) { + _tcsncpy(str, result, strSize); + mir_free(result); } - size_t len = lstrlen( str ); - if ( len+1 < strSize && str[len-1] != '\\' ) - lstrcpy( str+len, _T("\\") ); + size_t len = lstrlen(str); + if (len+1 < strSize && str[len-1] != '\\') + lstrcpy(str+len, _T("\\")); } void GetContactReceivedFilesDir(HANDLE hContact, TCHAR *szDir, int cchDir, BOOL patchVars) @@ -135,18 +135,18 @@ void GetContactReceivedFilesDir(HANDLE hContact, TCHAR *szDir, int cchDir, BOOL TCHAR szTemp[MAX_PATH]; szTemp[0] = 0; - if ( !DBGetContactSettingTString( NULL, "SRFile", "RecvFilesDirAdv", &dbv)) { - if ( lstrlen( dbv.ptszVal ) > 0 ) - lstrcpyn( szTemp, dbv.ptszVal, SIZEOF( szTemp )); - DBFreeVariant( &dbv ); + if ( !DBGetContactSettingTString(NULL, "SRFile", "RecvFilesDirAdv", &dbv)) { + if (lstrlen(dbv.ptszVal) > 0) + lstrcpyn(szTemp, dbv.ptszVal, SIZEOF(szTemp)); + DBFreeVariant(&dbv); } - if ( !szTemp[0] ) + if ( !szTemp[0]) - mir_sntprintf( szTemp, SIZEOF(szTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My Received Files")); + mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My Received Files")); - if ( hContact ) { + if (hContact) { REPLACEVARSDATA dat = { 0 }; REPLACEVARSARRAY rvaVarsToReplace[4]; rvaVarsToReplace[0].lptzKey = _T("nick"); @@ -160,22 +160,22 @@ void GetContactReceivedFilesDir(HANDLE hContact, TCHAR *szDir, int cchDir, BOOL for (int i=0; i < (SIZEOF(rvaVarsToReplace)-1);i++) RemoveInvalidFilenameChars(rvaVarsToReplace[i].lptzValue); - dat.cbSize = sizeof( dat ); + dat.cbSize = sizeof(dat); dat.dwFlags = RVF_TCHAR; dat.variables = rvaVarsToReplace; dat.hContact = hContact; - TCHAR* result = ( TCHAR* )CallService( MS_UTILS_REPLACEVARS, (WPARAM)szTemp, (LPARAM)&dat ); - if ( result ) { - _tcsncpy( szTemp, result, SIZEOF(szTemp)); - mir_free( result ); + TCHAR* result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)szTemp, (LPARAM)&dat); + if (result) { + _tcsncpy(szTemp, result, SIZEOF(szTemp)); + mir_free(result); for (int i=0; i < (SIZEOF(rvaVarsToReplace)-1);i++) mir_free(rvaVarsToReplace[i].lptzValue); } } if (patchVars) - patchDir( szTemp, SIZEOF(szTemp)); + patchDir(szTemp, SIZEOF(szTemp)); RemoveInvalidPathChars(szTemp); - lstrcpyn( szDir, szTemp, cchDir ); + lstrcpyn(szDir, szTemp, cchDir); } void GetReceivedFilesDir(TCHAR *szDir, int cchDir) @@ -184,20 +184,20 @@ void GetReceivedFilesDir(TCHAR *szDir, int cchDir) TCHAR szTemp[MAX_PATH]; szTemp[0] = 0; - if ( !DBGetContactSettingTString( NULL, "SRFile", "RecvFilesDirAdv", &dbv )) { - if ( lstrlen( dbv.ptszVal ) > 0 ) - lstrcpyn( szTemp, dbv.ptszVal, SIZEOF( szTemp )); + if ( !DBGetContactSettingTString(NULL, "SRFile", "RecvFilesDirAdv", &dbv)) { + if (lstrlen(dbv.ptszVal) > 0) + lstrcpyn(szTemp, dbv.ptszVal, SIZEOF(szTemp)); DBFreeVariant(&dbv); } - if ( !szTemp[0] ) + if ( !szTemp[0]) - mir_sntprintf( szTemp, SIZEOF(szTemp), _T("%%mydocuments%%\\%s"), TranslateT("My Received Files")); + mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%%mydocuments%%\\%s"), TranslateT("My Received Files")); - patchDir( szTemp, SIZEOF(szTemp)); + patchDir(szTemp, SIZEOF(szTemp)); RemoveInvalidPathChars(szTemp); - lstrcpyn( szDir, szTemp, cchDir ); + lstrcpyn(szDir, szTemp, cchDir); } INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) @@ -228,7 +228,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View User's History")); Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User Menu")); - contactName = cli.pfnGetContactDisplayName( dat->hContact, 0 ); + contactName = cli.pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_FROM, contactName); GetContactReceivedFilesDir(dat->hContact, szPath, SIZEOF(szPath), TRUE); SetDlgItemText(hwndDlg, IDC_FILEDIR, szPath); @@ -260,11 +260,11 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l CallService(MS_DB_EVENT_GET, (WPARAM)dat->hDbEvent, (LPARAM)&dbei); dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob; lstrcpynA(buf, (char*)dbei.pBlob+4, min(dbei.cbBlob+1, SIZEOF(buf))); - TCHAR* ptszFileName = DbGetEventStringT( &dbei, buf ); + TCHAR* ptszFileName = DbGetEventStringT(&dbei, buf); SetDlgItemText(hwndDlg, IDC_FILENAMES, ptszFileName); mir_free(ptszFileName); lstrcpynA(buf, (char*)dbei.pBlob+4+strlen((char*)dbei.pBlob+4)+1, min((int)(dbei.cbBlob-4-strlen((char*)dbei.pBlob+4)), SIZEOF(buf))); - TCHAR* ptszDescription = DbGetEventStringT( &dbei, buf ); + TCHAR* ptszDescription = DbGetEventStringT(&dbei, buf); SetDlgItemText(hwndDlg, IDC_MSG, ptszDescription); mir_free(ptszDescription); mir_free(dbei.pBlob); @@ -284,7 +284,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l 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; } } if (hasName) - SetDlgItemTextA(hwndDlg, IDC_NAME, buf ); + SetDlgItemTextA(hwndDlg, IDC_NAME, buf); else SetDlgItemText(hwndDlg, IDC_NAME, contactName); } } @@ -313,7 +313,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l //don't check auto-min here to fix BUG#647620 PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK)); } - if (!DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) + if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); return TRUE; } @@ -338,10 +338,10 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l 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 )) { + switch (LOWORD(wParam)) { case IDC_FILEDIRBROWSE: { TCHAR szDirName[MAX_PATH], szExistingDirName[MAX_PATH]; @@ -382,7 +382,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l 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); + 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); @@ -404,7 +404,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l acs.handleType=HANDLE_CONTACT; acs.szProto=""; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); - if (!DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) + if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } break; @@ -435,7 +435,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); - if ( dat ) FreeFileDlgData( dat ); + if (dat) FreeFileDlgData(dat); break; } return FALSE; diff --git a/src/modules/srfile/filesenddlg.cpp b/src/modules/srfile/filesenddlg.cpp index 7d35eec275..d1d0f26c16 100644 --- a/src/modules/srfile/filesenddlg.cpp +++ b/src/modules/srfile/filesenddlg.cpp @@ -31,9 +31,9 @@ static void SetFileListAndSizeControls(HWND hwndDlg, struct FileDlgData *dat) struct _stat statbuf; TCHAR str[64]; - for ( i=0; dat->files[i]; i++ ) { - if ( _tstat( dat->files[i], &statbuf ) == 0 ) { - if ( statbuf.st_mode & _S_IFDIR) + for (i=0; dat->files[i]; i++) { + if (_tstat(dat->files[i], &statbuf) == 0) { + if (statbuf.st_mode & _S_IFDIR) dirCount++; else fileCount++; @@ -71,12 +71,12 @@ static void FilenameToFileList(HWND hwndDlg, struct FileDlgData* dat, const TCHA FreeFilesMatrix(&dat->files); // Get the file attributes of selection - dwFileAttributes = GetFileAttributes( buf ); + dwFileAttributes = GetFileAttributes(buf); if (dwFileAttributes == INVALID_FILE_ATTRIBUTES) return; // Check if the selection is a directory or a file - if ( GetFileAttributes( buf ) & FILE_ATTRIBUTE_DIRECTORY ) { + if (GetFileAttributes(buf) & FILE_ATTRIBUTE_DIRECTORY) { const TCHAR* pBuf; int nNumberOfFiles = 0; int nTemp; @@ -90,13 +90,13 @@ static void FilenameToFileList(HWND hwndDlg, struct FileDlgData* dat, const TCHA // Count number of files pBuf = buf + fileOffset; - while ( *pBuf ) { + while (*pBuf) { pBuf += lstrlen(pBuf) + 1; nNumberOfFiles++; } // Allocate memory for a pointer array - if (( dat->files = ( TCHAR* *)mir_alloc((nNumberOfFiles + 1) * sizeof(TCHAR*))) == NULL ) + if ((dat->files = (TCHAR* *)mir_alloc((nNumberOfFiles + 1) * sizeof(TCHAR*))) == NULL) return; // Fill the array @@ -105,11 +105,11 @@ static void FilenameToFileList(HWND hwndDlg, struct FileDlgData* dat, const TCHA while (*pBuf) { // Allocate space for path+filename - int cbFileNameLen = lstrlen( pBuf ); - dat->files[nTemp] = ( TCHAR* )mir_alloc( sizeof(TCHAR)*(fileOffset + cbFileNameLen + 1)); + int cbFileNameLen = lstrlen(pBuf); + dat->files[nTemp] = (TCHAR*)mir_alloc(sizeof(TCHAR)*(fileOffset + cbFileNameLen + 1)); // Add path to filename and copy into array - CopyMemory(dat->files[nTemp], buf, (fileOffset-1)*sizeof( TCHAR )); + CopyMemory(dat->files[nTemp], buf, (fileOffset-1)*sizeof(TCHAR)); dat->files[nTemp][fileOffset-1] = '\\'; _tcscpy(dat->files[nTemp] + fileOffset - (buf[fileOffset-2] == '\\'?1:0), pBuf); @@ -123,7 +123,7 @@ static void FilenameToFileList(HWND hwndDlg, struct FileDlgData* dat, const TCHA // ...the selection is a single file else { - if (( dat->files = ( TCHAR **)mir_alloc(2 * sizeof( TCHAR*))) == NULL ) // Leaks when aborted + if ((dat->files = (TCHAR **)mir_alloc(2 * sizeof(TCHAR*))) == NULL) // Leaks when aborted return; dat->files[0] = mir_tstrdup(buf); @@ -137,30 +137,30 @@ static void FilenameToFileList(HWND hwndDlg, struct FileDlgData* dat, const TCHA #define M_FILECHOOSEDONE (WM_USER+100) void __cdecl ChooseFilesThread(void* param) { - HWND hwndDlg = ( HWND )param; + HWND hwndDlg = (HWND)param; TCHAR filter[128], *pfilter; - TCHAR* buf = ( TCHAR* )mir_alloc( sizeof(TCHAR)*32767 ); - if ( buf == NULL ) - PostMessage( hwndDlg, M_FILECHOOSEDONE, 0, ( LPARAM )( TCHAR* )NULL ); + TCHAR* buf = (TCHAR*)mir_alloc(sizeof(TCHAR)*32767); + if (buf == NULL) + PostMessage(hwndDlg, M_FILECHOOSEDONE, 0, (LPARAM)(TCHAR*)NULL); else { OPENFILENAME ofn = {0}; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; - lstrcpy( filter, TranslateT( "All Files" )); - lstrcat( filter, _T(" (*)" )); - pfilter = filter + lstrlen( filter )+1; - lstrcpy( pfilter, _T( "*" )); - pfilter = filter + lstrlen( filter )+1; + lstrcpy(filter, TranslateT("All Files")); + lstrcat(filter, _T(" (*)")); + pfilter = filter + lstrlen(filter)+1; + lstrcpy(pfilter, _T("*")); + pfilter = filter + lstrlen(filter)+1; pfilter[ 0 ] = '\0'; ofn.lpstrFilter = filter; ofn.lpstrFile = buf; *buf = 0; ofn.nMaxFile = 32767; ofn.Flags = OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_DONTADDTORECENT; - if ( GetOpenFileName( &ofn )) - PostMessage( hwndDlg, M_FILECHOOSEDONE, 0, ( LPARAM )buf ); + if (GetOpenFileName(&ofn)) + PostMessage(hwndDlg, M_FILECHOOSEDONE, 0, (LPARAM)buf); else { - mir_free( buf ); - PostMessage( hwndDlg, M_FILECHOOSEDONE, 0, ( LPARAM )( TCHAR* )NULL ); + mir_free(buf); + PostMessage(hwndDlg, M_FILECHOOSEDONE, 0, (LPARAM)(TCHAR*)NULL); } } } static BOOL CALLBACK ClipSiblingsChildEnumProc(HWND hwnd, LPARAM) @@ -221,15 +221,15 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (fsd->ppFiles != NULL && fsd->ppFiles[0] != NULL) { int totalCount, i; for (totalCount=0;fsd->ppFiles[totalCount];totalCount++); - dat->files = ( TCHAR** )mir_alloc( sizeof(TCHAR*)*(totalCount+1)); // Leaks + dat->files = (TCHAR**)mir_alloc(sizeof(TCHAR*)*(totalCount+1)); // Leaks for (i=0;ifiles[i] = mir_tstrdup( fsd->ppFiles[i] ); + dat->files[i] = mir_tstrdup(fsd->ppFiles[i]); dat->files[totalCount]=NULL; SetFileListAndSizeControls(hwndDlg, dat); } { char *szProto; - TCHAR* contactName = cli.pfnGetContactDisplayName( dat->hContact, 0 ); + TCHAR* contactName = cli.pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_TO, contactName); szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); @@ -243,7 +243,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l 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; @@ -256,13 +256,13 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l break; } } - if ( hasName ) + if (hasName) SetDlgItemTextA(hwndDlg, IDC_NAME, buf); else SetDlgItemText(hwndDlg, IDC_NAME, contactName); } } - if ( fsd->ppFiles == NULL ) { + if (fsd->ppFiles == NULL) { EnableWindow(hwndDlg, FALSE); dat->closeIfFileChooseCancelled=1; PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_CHOOSE, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDC_CHOOSE)); @@ -289,9 +289,9 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case M_FILECHOOSEDONE: - if ( lParam != 0 ) { - FilenameToFileList( hwndDlg, dat, ( TCHAR* )lParam ); - mir_free(( TCHAR* )lParam ); + if (lParam != 0) { + FilenameToFileList(hwndDlg, dat, (TCHAR*)lParam); + mir_free((TCHAR*)lParam); dat->closeIfFileChooseCancelled = 0; } else if (dat->closeIfFileChooseCancelled) DestroyWindow(hwndDlg); @@ -317,7 +317,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l 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); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); DestroyWindow(hwndDlg); return TRUE; @@ -348,8 +348,8 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); - if ( dat ) - FreeFileDlgData( dat ); + if (dat) + FreeFileDlgData(dat); SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MSG), GWLP_WNDPROC, (LONG_PTR)OldSendEditProc); return TRUE; diff --git a/src/modules/srfile/filexferdlg.cpp b/src/modules/srfile/filexferdlg.cpp index 5775f29265..7864eb5a96 100644 --- a/src/modules/srfile/filexferdlg.cpp +++ b/src/modules/srfile/filexferdlg.cpp @@ -42,30 +42,30 @@ struct virusscanthreadstartinfo { HWND hwndReply; }; -TCHAR* PFTS_StringToTchar( int flags, const PROTOCHAR* s ) +TCHAR* PFTS_StringToTchar(int flags, const PROTOCHAR* s) { - if ( flags & PFTS_UTF ) - return Utf8DecodeUcs2(( char* )s ); - else if ( flags & PFTS_UNICODE ) - return mir_tstrdup( s ); + if (flags & PFTS_UTF) + return Utf8DecodeUcs2((char*)s); + else if (flags & PFTS_UNICODE) + return mir_tstrdup(s); else - return mir_a2t(( char* )s ); + return mir_a2t((char*)s); } -int PFTS_CompareWithTchar( PROTOFILETRANSFERSTATUS* ft, const PROTOCHAR* s, TCHAR* r ) +int PFTS_CompareWithTchar(PROTOFILETRANSFERSTATUS* ft, const PROTOCHAR* s, TCHAR* r) { - if ( ft->flags & PFTS_UTF ) { - TCHAR* ts = Utf8DecodeUcs2(( char* )s ); - int res = _tcscmp( ts, r ); - mir_free( ts ); + if (ft->flags & PFTS_UTF) { + TCHAR* ts = Utf8DecodeUcs2((char*)s); + int res = _tcscmp(ts, r); + mir_free(ts); return res; } - else if ( ft->flags & PFTS_UNICODE ) - return _tcscmp( s, r ); + else if (ft->flags & PFTS_UNICODE) + return _tcscmp(s, r); else { - TCHAR* ts = mir_a2t(( char* )s ); - int res = _tcscmp( ts, r ); - mir_free( ts ); + TCHAR* ts = mir_a2t((char*)s); + int res = _tcscmp(ts, r); + mir_free(ts); return res; } } @@ -75,7 +75,7 @@ static void SetOpenFileButtonStyle(HWND hwndButton, int enabled) EnableWindow(hwndButton, enabled); } -void FillSendData( FileDlgData* dat, DBEVENTINFO& dbei ) +void FillSendData(FileDlgData* dat, DBEVENTINFO& dbei) { dbei.cbSize = sizeof(dbei); dbei.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); @@ -91,7 +91,7 @@ void FillSendData( FileDlgData* dat, DBEVENTINFO& dbei ) lstrcpyA((char*)dbei.pBlob+sizeof(DWORD), szFileNames); lstrcpyA((char*)dbei.pBlob+sizeof(DWORD)+lstrlenA(szFileNames)+1, szMsg); - mir_free( szFileNames ), mir_free( szMsg ); + mir_free(szFileNames), mir_free(szMsg); } @@ -102,7 +102,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]) { @@ -111,7 +111,7 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) pszReplace = _tcsstr(dbv.ptszVal, _T("%f")); if (pszReplace) { - if ( info->szFile[_tcslen(info->szFile) - 1] == '\\') + if (info->szFile[_tcslen(info->szFile) - 1] == '\\') info->szFile[_tcslen(info->szFile) - 1] = '\0'; *pszReplace = 0; mir_sntprintf(szCmdLine, SIZEOF(szCmdLine), _T("%s\"%s\"%s"), dbv.ptszVal, info->szFile, pszReplace+2); @@ -136,9 +136,9 @@ static void SetFilenameControls(HWND hwndDlg, struct FileDlgData *dat, PROTOFILE TCHAR *fnbuf = NULL, *fn = NULL; SHFILEINFO shfi = {0}; - if ( fts->tszCurrentFile ) { - fnbuf = mir_tstrdup( fts->tszCurrentFile ); - if (( fn = _tcsrchr( fnbuf, '\\' )) == NULL ) + if (fts->tszCurrentFile) { + fnbuf = mir_tstrdup(fts->tszCurrentFile); + if ((fn = _tcsrchr(fnbuf, '\\')) == NULL) fn = fnbuf; else fn++; } @@ -147,26 +147,26 @@ static void SetFilenameControls(HWND hwndDlg, struct FileDlgData *dat, PROTOFILE if (fn && (fts->totalFiles > 1)) { mir_sntprintf(msg, SIZEOF(msg), _T("%s: %s (%d %s %d)"), - cli.pfnGetContactDisplayName( fts->hContact, 0 ), + 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); dat->hIcon = shfi.hIcon; } else if (fn) { - mir_sntprintf(msg, SIZEOF(msg), _T("%s: %s"), cli.pfnGetContactDisplayName( fts->hContact, 0 ), fn); + mir_sntprintf(msg, SIZEOF(msg), _T("%s: %s"), cli.pfnGetContactDisplayName(fts->hContact, 0), fn); SHGetFileInfo(fn, FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(shfi), SHGFI_USEFILEATTRIBUTES|SHGFI_ICON|SHGFI_SMALLICON); dat->hIcon = shfi.hIcon; } else { - lstrcpyn(msg, cli.pfnGetContactDisplayName( fts->hContact, 0 ), SIZEOF(msg)); + lstrcpyn(msg, cli.pfnGetContactDisplayName(fts->hContact, 0), SIZEOF(msg)); HICON hIcon = LoadSkinIcon(SKINICON_OTHER_DOWNARROW); dat->hIcon = CopyIcon(hIcon); IconLib_ReleaseIcon(hIcon, NULL); } - mir_free( fnbuf ); + mir_free(fnbuf); SendDlgItemMessage(hwndDlg, IDC_FILEICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)dat->hIcon); SetDlgItemText(hwndDlg, IDC_CONTACTNAME, msg); @@ -260,7 +260,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } { /* check we actually got an fs handle back from the protocol */ - if (!dat->fs) { + if ( !dat->fs) { SetFtStatus(hwndDlg, LPGENT("Unable to initiate transfer."), FTS_TEXT); dat->waitingForAcceptance=0; } @@ -295,14 +295,14 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR Button_SetIcon_IcoLib(hwndDlg, IDCANCEL, SKINICON_OTHER_DELETE, LPGEN("Cancel")); - SetDlgItemText(hwndDlg, IDC_CONTACTNAME, cli.pfnGetContactDisplayName( dat->hContact, 0 )); + 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])); dat->bytesRecvedHistory[0]=dat->transferStatus.totalProgress; - if ( dat->bytesRecvedHistorySize < SIZEOF(dat->bytesRecvedHistory)) + if (dat->bytesRecvedHistorySize < SIZEOF(dat->bytesRecvedHistory)) dat->bytesRecvedHistorySize++; { TCHAR szSpeed[32], szTime[32], szDisplay[96]; @@ -338,7 +338,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case WM_FT_CLEANUP: - if (!dat->fs) + if ( !dat->fs) { PostMessage(GetParent(hwndDlg), WM_FT_REMOVE, 0, (LPARAM)hwndDlg); DestroyWindow(hwndDlg); @@ -346,7 +346,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)) @@ -374,10 +374,10 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } case IDC_OPENFOLDER: - if ( dat ) + if (dat) { TCHAR* path = dat->transferStatus.tszWorkingDir; - if (!path || !path[0]) + if ( !path || !path[0]) { path = NEWTSTR_ALLOCA(dat->transferStatus.tszCurrentFile); TCHAR* p = _tcsrchr(path, '\\'); if (p) *p = 0; @@ -427,7 +427,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (pszFilename) { size_t cbFileNameLen = _tcslen(pszFilename); - pszNewFileName = (TCHAR*)mir_alloc( cbFileNameLen*2*sizeof( TCHAR )); + pszNewFileName = (TCHAR*)mir_alloc(cbFileNameLen*2*sizeof(TCHAR)); TCHAR *p = pszNewFileName; for (size_t pszlen=0; pszlen < cbFileNameLen; pszlen++) { *p++ = pszFilename[pszlen]; @@ -451,7 +451,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (ret == 1) { TCHAR* path = dat->transferStatus.tszWorkingDir; - if (!path || !path[0]) + if ( !path || !path[0]) { path = NEWTSTR_ALLOCA(dat->transferStatus.tszCurrentFile); TCHAR* p = _tcsrchr(path, '\\'); if (p) *p = 0; @@ -547,9 +547,9 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR UpdateProtoFileTransferStatus(&dat->transferStatus, (PROTOFILETRANSFERSTATUS*)ack->lParam); PROTOFILETRANSFERSTATUS *fts = &dat->transferStatus; - SetFilenameControls( hwndDlg, dat, fts ); - int res = _taccess( fts->tszCurrentFile, 0 ); - if ( res ) + SetFilenameControls(hwndDlg, dat, fts); + int res = _taccess(fts->tszCurrentFile, 0); + if (res) break; SetFtStatus(hwndDlg, LPGENT("File already exists"), FTS_TEXT); @@ -575,11 +575,11 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR TCHAR str[64], str2[64], szSizeDone[32], szSizeTotal[32];//, *contactName; int units; - if ( dat->fileVirusScanned == NULL ) + if (dat->fileVirusScanned == NULL) dat->fileVirusScanned=(int*)mir_calloc(sizeof(int) * fts->totalFiles); // This needs to be here - otherwise we get holes in the files array - if (!dat->send) { + if ( !dat->send) { if (dat->files == NULL) dat->files = (TCHAR**)mir_calloc((fts->totalFiles + 1) * sizeof(TCHAR*)); if (fts->currentFileNumber < fts->totalFiles && dat->files[fts->currentFileNumber] == NULL) @@ -597,7 +597,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR bool firstTime = false; if ((GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_ALLFILESPROGRESS), GWL_STYLE) & WS_VISIBLE) == 0) { - SetFtStatus(hwndDlg, ( fts->flags & PFTS_SENDING ) ? LPGENT("Sending...") : LPGENT("Receiving..."), FTS_PROGRESS); + SetFtStatus(hwndDlg, (fts->flags & PFTS_SENDING) ? LPGENT("Sending...") : LPGENT("Receiving..."), FTS_PROGRESS); SetFilenameControls(hwndDlg, dat, fts); firstTime = true; } @@ -627,7 +627,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR HideProgressControls(hwndDlg); KillTimer(hwndDlg, 1); - if (!dat->send) + if ( !dat->send) SetOpenFileButtonStyle(GetDlgItem(hwndDlg, IDC_OPENFILE), 1); SetDlgItemText(hwndDlg, IDCANCEL, TranslateT("Close")); if (dat->hNotifyEvent) @@ -652,7 +652,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetFtStatus(hwndDlg, LPGENT("Transfer completed."), FTS_TEXT); DBEVENTINFO dbei={0}; - FillSendData( dat, dbei ); + FillSendData(dat, dbei); CallService(MS_DB_EVENT_ADD, (WPARAM)dat->hContact, (LPARAM)&dbei); if (dbei.pBlob) mir_free(dbei.pBlob); @@ -672,7 +672,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR vstsi->hwndReply=hwndDlg; if (useScanner == VIRUSSCAN_DURINGDL) { vstsi->returnCode=dat->transferStatus.currentFileNumber; - if ( GetFileAttributes(dat->files[dat->transferStatus.currentFileNumber])&FILE_ATTRIBUTE_DIRECTORY) { + if (GetFileAttributes(dat->files[dat->transferStatus.currentFileNumber])&FILE_ATTRIBUTE_DIRECTORY) { PostMessage(hwndDlg, M_VIRUSSCANDONE, vstsi->returnCode, 0); mir_free(vstsi); vstsi=NULL; @@ -706,7 +706,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } else { dat->fileVirusScanned[wParam]=1; - for (i=0;itransferStatus.totalFiles;i++) if (!dat->fileVirusScanned[i]) {done=0; break;} + for (i=0;itransferStatus.totalFiles;i++) if ( !dat->fileVirusScanned[i]) {done=0; break;} } if (done) { @@ -747,7 +747,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return FALSE; } -void FreeFileDlgData( FileDlgData* dat ) +void FreeFileDlgData(FileDlgData* dat) { if (dat->fs) CallContactService(dat->hContact, PSS_FILECANCEL, (WPARAM)dat->fs, 0); diff --git a/src/modules/srfile/ftmanager.cpp b/src/modules/srfile/ftmanager.cpp index 0b321ee16c..3c675b5acf 100644 --- a/src/modules/srfile/ftmanager.cpp +++ b/src/modules/srfile/ftmanager.cpp @@ -205,7 +205,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA { int i, nScrollLines = 0; SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, (void*)&nScrollLines, 0); - for (i = 0; i < (nScrollLines + 1) / 2; i++ ) + for (i = 0; i < (nScrollLines + 1) / 2; i++) SendMessage(hwnd, WM_VSCROLL, (zDelta < 0) ? SB_LINEDOWN : SB_LINEUP, 0); } @@ -483,7 +483,7 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM } break; case WM_SHOWWINDOW: { - if (!wParam) // hiding + if ( !wParam) // hiding { KillTimer(hwnd, 1); break; @@ -504,7 +504,7 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (dat->errorState) { pTaskbarInterface->SetProgressState(hwnd, dat->errorState); - if (!prg.run) + if ( !prg.run) pTaskbarInterface->SetProgressValue(hwnd, 1, 1); } else if (prg.run) { @@ -559,7 +559,7 @@ HWND FtMgr_Show(bool bForceActivate, bool bFromMenu) SetForegroundWindow(hwndFtMgr); return hwndFtMgr; } - if (!bJustCreated && IsWindowVisible(hwndFtMgr)) + if ( !bJustCreated && IsWindowVisible(hwndFtMgr)) return hwndFtMgr; ShowWindow(hwndFtMgr, bAutoMin ? SW_SHOWMINNOACTIVE : SW_SHOWNOACTIVATE); -- cgit v1.2.3