summaryrefslogtreecommitdiff
path: root/src/modules/srfile/file.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/srfile/file.cpp')
-rw-r--r--src/modules/srfile/file.cpp106
1 files changed, 53 insertions, 53 deletions
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;i<fts->totalFiles;i++) mir_free(fts->ptszFiles[i]);
+ for (int i=0;i<fts->totalFiles;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;i<dest->totalFiles;i++) mir_free(dest->ptszFiles[i]);
+ if (dest->totalFiles != src->totalFiles) {
+ for (int i=0;i<dest->totalFiles;i++) mir_free(dest->ptszFiles[i]);
mir_free(dest->ptszFiles);
dest->ptszFiles = NULL;
dest->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;