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/database/database.cpp | 74 ++++----- src/modules/database/dbini.cpp | 38 ++--- src/modules/database/dblists.cpp | 84 +++++----- src/modules/database/dblists.h | 22 +-- src/modules/database/dbutils.cpp | 214 +++++++++++++------------- src/modules/database/profilemanager.cpp | 264 ++++++++++++++++---------------- src/modules/database/profilemanager.h | 2 +- 7 files changed, 349 insertions(+), 349 deletions(-) (limited to 'src/modules/database') diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index e4b2663b60..407cc4b4b2 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -41,15 +41,15 @@ bool fileExist(TCHAR* fname) return res; } -static void fillProfileName( const TCHAR* ptszFileName ) +static void fillProfileName(const TCHAR* ptszFileName) { - const TCHAR* p = _tcsrchr( ptszFileName, '\\' ); - if ( p == NULL ) + const TCHAR* p = _tcsrchr(ptszFileName, '\\'); + if (p == NULL) p = ptszFileName; else p++; - _tcsncpy( g_profileName, p, SIZEOF(g_profileName)); + _tcsncpy(g_profileName, p, SIZEOF(g_profileName)); } bool IsInsideRootDir(TCHAR* profiledir, bool exact) @@ -103,7 +103,7 @@ static bool showProfileManager(void) // wanna show it? GetPrivateProfileString(_T("Database"), _T("ShowProfileMgr"), _T("never"), Mgr, SIZEOF(Mgr), mirandabootini); - return ( _tcsicmp(Mgr, _T("yes")) == 0 ); + return (_tcsicmp(Mgr, _T("yes")) == 0); } bool shouldAutoCreate(TCHAR *szProfile) @@ -177,7 +177,7 @@ void getProfileCmdLine(TCHAR * szProfile, size_t cch, TCHAR * profiledir) p = _tcsrchr(buf, '\\'); if (p) ++p; else p = buf; - if (!isValidProfileName(buf) && *p) + if ( !isValidProfileName(buf) && *p) _tcscat(buf, _T(".dat")); _tcscpy(profileName, p); @@ -299,10 +299,10 @@ static int getProfile1(TCHAR * szProfile, size_t cch, TCHAR * profiledir, BOOL * reqfd = !shpm && found == 1 && nodprof; } - if ( noProfiles ) + if (noProfiles) *noProfiles = found == 0; - if ( nodprof && !reqfd ) + if (nodprof && !reqfd) szProfile[0] = 0; return reqfd; @@ -352,18 +352,18 @@ static int getProfile(TCHAR * szProfile, size_t cch) } // carefully converts a file name from TCHAR* to char* -char* makeFileName( const TCHAR* tszOriginalName ) +char* makeFileName(const TCHAR* tszOriginalName) { char* szResult = NULL; - char* szFileName = mir_t2a( tszOriginalName ); - TCHAR* tszFileName = mir_a2t( szFileName ); - if ( _tcscmp( tszOriginalName, tszFileName )) { + char* szFileName = mir_t2a(tszOriginalName); + TCHAR* tszFileName = mir_a2t(szFileName); + if (_tcscmp(tszOriginalName, tszFileName)) { TCHAR tszProfile[MAX_PATH]; - if ( GetShortPathName( tszOriginalName, tszProfile, MAX_PATH) != 0) - szResult = mir_t2a( tszProfile ); + if (GetShortPathName(tszOriginalName, tszProfile, MAX_PATH) != 0) + szResult = mir_t2a(tszProfile); } - if ( !szResult ) + if ( !szResult) szResult = szFileName; else mir_free(szFileName); @@ -382,10 +382,10 @@ int makeDatabase(TCHAR * profile, DATABASELINK * link, HWND hwndDlg) if (file) file++; if (_taccess(profile, 0) == 0) { // file already exists! - mir_sntprintf(buf, SIZEOF(buf), TranslateTS( _T("The profile '%s' already exists. Do you want to move it to the ") + mir_sntprintf(buf, SIZEOF(buf), TranslateTS(_T("The profile '%s' already exists. Do you want to move it to the ") _T("Recycle Bin? \n\nWARNING: The profile will be deleted if Recycle Bin is disabled.\n") - _T("WARNING: A profile may contain confidential information and should be properly deleted.")), file ); - if ( MessageBox(hwndDlg, buf, TranslateT("The profile already exists"), MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2) != IDYES ) + _T("WARNING: A profile may contain confidential information and should be properly deleted.")), file); + if (MessageBox(hwndDlg, buf, TranslateT("The profile already exists"), MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2) != IDYES) return 0; // move the file @@ -394,7 +394,7 @@ int makeDatabase(TCHAR * profile, DATABASELINK * link, HWND hwndDlg) sf.pFrom = buf; sf.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; mir_sntprintf(buf, SIZEOF(buf), _T("%s\0"), profile); - if ( SHFileOperation(&sf) != 0 ) { + if (SHFileOperation(&sf) != 0) { mir_sntprintf(buf, SIZEOF(buf), TranslateT("Couldn't move '%s' to the Recycle Bin, Please select another profile name."), file); MessageBox(0, buf, TranslateT("Problem moving profile"), MB_ICONINFORMATION|MB_OK); return 0; @@ -419,24 +419,24 @@ int makeDatabase(TCHAR * profile, DATABASELINK * link, HWND hwndDlg) // enumerate all plugins that had valid DatabasePluginInfo() static int FindDbPluginForProfile(const char*, DATABASELINK * dblink, LPARAM lParam) { - TCHAR* tszProfile = ( TCHAR* )lParam; + TCHAR* tszProfile = (TCHAR*)lParam; int res = DBPE_CONT; - if ( dblink && dblink->cbSize == sizeof(DATABASELINK)) { + if (dblink && dblink->cbSize == sizeof(DATABASELINK)) { char* szProfile = makeFileName(tszProfile); // liked the profile? int err = 0; if (dblink->grokHeader(szProfile, &err) == 0) { // added APIs? if ( !dblink->Load(szProfile, &pluginCoreLink)) { - fillProfileName( tszProfile ); + fillProfileName(tszProfile); res = DBPE_DONE; } else res = DBPE_HALT; } else { res = DBPE_HALT; - switch ( err ) { + switch (err) { case EGROKPRF_CANTREAD: case EGROKPRF_UNKHEADER: // just not supported. @@ -455,18 +455,18 @@ static int FindDbPluginForProfile(const char*, DATABASELINK * dblink, LPARAM lPa // enumerate all plugins that had valid DatabasePluginInfo() static int FindDbPluginAutoCreate(const char*, DATABASELINK * dblink, LPARAM lParam) { - TCHAR* tszProfile = ( TCHAR* )lParam; + TCHAR* tszProfile = (TCHAR*)lParam; int res = DBPE_CONT; if (dblink && dblink->cbSize == sizeof(DATABASELINK)) { - CreatePathToFileT( tszProfile ); + CreatePathToFileT(tszProfile); int err; - char *szProfile = makeFileName( tszProfile ); + char *szProfile = makeFileName(tszProfile); if (dblink->makeDatabase(szProfile, &err) == 0) { dbCreated = true; if ( !dblink->Load(szProfile, &pluginCoreLink)) { - fillProfileName( tszProfile ); + fillProfileName(tszProfile); res = DBPE_DONE; } else res = DBPE_HALT; @@ -488,8 +488,8 @@ static BOOL CALLBACK EnumMirandaWindows(HWND hwnd, LPARAM lParam) TCHAR classname[256]; ENUMMIRANDAWINDOW * x = (ENUMMIRANDAWINDOW *)lParam; DWORD_PTR res=0; - if ( GetClassName(hwnd, classname, SIZEOF(classname)) && lstrcmp( _T("Miranda"), classname) == 0 ) { - if ( SendMessageTimeout(hwnd, x->msg, (WPARAM)x->aPath, 0, SMTO_ABORTIFHUNG, 100, &res) && res ) { + if (GetClassName(hwnd, classname, SIZEOF(classname)) && lstrcmp(_T("Miranda"), classname) == 0) { + if (SendMessageTimeout(hwnd, x->msg, (WPARAM)x->aPath, 0, SMTO_ABORTIFHUNG, 100, &res) && res) { x->found++; return FALSE; } @@ -501,7 +501,7 @@ static int FindMirandaForProfile(TCHAR * szProfile) { ENUMMIRANDAWINDOW x={0}; x.profile=szProfile; - x.msg=RegisterWindowMessage( _T( "Miranda::ProcessProfile" )); + x.msg=RegisterWindowMessage(_T("Miranda::ProcessProfile")); x.aPath=GlobalAddAtom(szProfile); EnumWindows(EnumMirandaWindows, (LPARAM)&x); GlobalDeleteAtom(x.aPath); @@ -519,17 +519,17 @@ int LoadDatabaseModule(void) InitUtils(); // find out which profile to load - if ( !getProfile( szProfile, SIZEOF( szProfile ))) + if ( !getProfile(szProfile, SIZEOF(szProfile))) return 1; PLUGIN_DB_ENUM dbe; dbe.cbSize = sizeof(PLUGIN_DB_ENUM); dbe.lParam = (LPARAM)szProfile; - if ( _taccess(szProfile, 0) && shouldAutoCreate( szProfile )) - dbe.pfnEnumCallback=( int(*) (const char*, void*, LPARAM) )FindDbPluginAutoCreate; + if (_taccess(szProfile, 0) && shouldAutoCreate(szProfile)) + dbe.pfnEnumCallback=(int(*) (const char*, void*, LPARAM))FindDbPluginAutoCreate; else - dbe.pfnEnumCallback=( int(*) (const char*, void*, LPARAM) )FindDbPluginForProfile; + dbe.pfnEnumCallback=(int(*) (const char*, void*, LPARAM))FindDbPluginForProfile; // find a driver to support the given profile bool retry; @@ -537,12 +537,12 @@ int LoadDatabaseModule(void) do { retry = false; rc = CallService(MS_PLUGINS_ENUMDBPLUGINS, 0, (LPARAM)&dbe); - switch ( rc ) { + switch (rc) { case -1: { // no plugins at all TCHAR buf[256]; TCHAR* p = _tcsrchr(szProfile, '\\'); - mir_sntprintf(buf, SIZEOF(buf), TranslateT("Miranda is unable to open '%s' because you do not have any profile plugins installed.\nYou need to install dbx_3x.dll or equivalent."), p ? ++p : szProfile ); + mir_sntprintf(buf, SIZEOF(buf), TranslateT("Miranda is unable to open '%s' because you do not have any profile plugins installed.\nYou need to install dbx_3x.dll or equivalent."), p ? ++p : szProfile); MessageBox(0, buf, TranslateT("No profile support installed!"), MB_OK | MB_ICONERROR); break; } @@ -555,7 +555,7 @@ int LoadDatabaseModule(void) mir_sntprintf(buf, SIZEOF(buf), TranslateT("Miranda was unable to open '%s', it's in an unknown format.\nThis profile might also be damaged, please run DB-tool which should be installed."), p ? ++p : szProfile); MessageBox(0, buf, TranslateT("Miranda can't understand that profile"), MB_OK | MB_ICONERROR); } - else if (!FindMirandaForProfile(szProfile)) { + else if ( !FindMirandaForProfile(szProfile)) { TCHAR buf[256]; TCHAR* p = _tcsrchr(szProfile, '\\'); mir_sntprintf(buf, SIZEOF(buf), TranslateT("Miranda was unable to open '%s'\nIt's inaccessible or used by other application or Miranda instance"), p ? ++p : szProfile); diff --git a/src/modules/database/dbini.cpp b/src/modules/database/dbini.cpp index ce01d20dc8..e8836114c1 100644 --- a/src/modules/database/dbini.cpp +++ b/src/modules/database/dbini.cpp @@ -41,11 +41,11 @@ static INT_PTR CALLBACK InstallIniDlgProc(HWND hwndDlg, UINT message, WPARAM wPa const TCHAR *pszSecurityInfo; GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, SIZEOF(szSecurity), mirandabootini); - if (!lstrcmpi(szSecurity, _T("all"))) + if ( !lstrcmpi(szSecurity, _T("all"))) pszSecurityInfo = LPGENT("Security systems to prevent malicious changes are in place and you will be warned before every change that is made."); - else if (!lstrcmpi(szSecurity, _T("onlyunsafe"))) + else if ( !lstrcmpi(szSecurity, _T("onlyunsafe"))) pszSecurityInfo = LPGENT("Security systems to prevent malicious changes are in place and you will be warned before changes that are known to be unsafe."); - else if (!lstrcmpi(szSecurity, _T("none"))) + else if ( !lstrcmpi(szSecurity, _T("none"))) pszSecurityInfo = LPGENT("Security systems to prevent malicious changes have been disabled. You will receive no further warnings."); else pszSecurityInfo = NULL; if (pszSecurityInfo) SetDlgItemText(hwndDlg, IDC_SECURITYINFO, TranslateTS(pszSecurityInfo)); @@ -78,9 +78,9 @@ static bool IsInSpaceSeparatedList(const char *szWord, const char *szList) for (szItem = szList;;) { szEnd = strchr(szItem, ' '); if (szEnd == NULL) - return !lstrcmpA( szItem, szWord ); - if ( szEnd - szItem == wordLen ) { - if ( !strncmp( szItem, szWord, wordLen )) + return !lstrcmpA(szItem, szWord); + if (szEnd - szItem == wordLen) { + if ( !strncmp(szItem, szWord, wordLen)) return true; } szItem = szEnd+1; @@ -197,13 +197,13 @@ void ConvertBackslashes(char *, UINT); static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsafeSections, int secur, bool secFN) { FILE *fp = _tfopen(szIniPath, _T("rt")); - if ( fp == NULL ) + if (fp == NULL) return; bool warnThisSection = false; char szSection[128]; szSection[0] = 0; - while (!feof(fp)) { + while ( !feof(fp)) { char szLine[2048]; if (fgets(szLine, sizeof(szLine), fp) == NULL) break; @@ -270,7 +270,7 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf continue; char *szValue=strchr(szLine, '='); - if ( szValue == NULL ) + if (szValue == NULL) continue; char szName[128]; @@ -376,15 +376,15 @@ static void DoAutoExec(void) int secur; GetPrivateProfileString(_T("AutoExec"), _T("Use"), _T("prompt"), szUse, SIZEOF(szUse), mirandabootini); - if (!lstrcmpi(szUse, _T("no"))) return; + if ( !lstrcmpi(szUse, _T("no"))) return; GetPrivateProfileString(_T("AutoExec"), _T("Safe"), _T("CLC Icons CLUI CList SkinSounds"), buf, SIZEOF(buf), mirandabootini); szSafeSections = mir_t2a(buf); GetPrivateProfileString(_T("AutoExec"), _T("Unsafe"), _T("ICQ MSN"), buf, SIZEOF(buf), mirandabootini); szUnsafeSections = mir_t2a(buf); GetPrivateProfileString(_T("AutoExec"), _T("Warn"), _T("notsafe"), szSecurity, SIZEOF(szSecurity), mirandabootini); - if (!lstrcmpi(szSecurity, _T("none"))) secur = 0; - else if (!lstrcmpi(szSecurity, _T("notsafe"))) secur = 1; - else if (!lstrcmpi(szSecurity, _T("onlyunsafe"))) secur = 2; + if ( !lstrcmpi(szSecurity, _T("none"))) secur = 0; + else if ( !lstrcmpi(szSecurity, _T("notsafe"))) secur = 1; + else if ( !lstrcmpi(szSecurity, _T("onlyunsafe"))) secur = 2; GetPrivateProfileString(_T("AutoExec"), _T("OverrideSecurityFilename"), _T(""), szOverrideSecurityFilename, SIZEOF(szOverrideSecurityFilename), mirandabootini); GetPrivateProfileString(_T("AutoExec"), _T("OnCreateFilename"), _T(""), szOnCreateFilename, SIZEOF(szOnCreateFilename), mirandabootini); @@ -418,7 +418,7 @@ static void DoAutoExec(void) bool secFN = lstrcmpi(fd.cFileName, szOverrideSecurityFilename) == 0; mir_sntprintf(szIniPath, SIZEOF(szIniPath), _T("%s%s"), szFindPath, fd.cFileName); - if (!lstrcmpi(szUse, _T("prompt")) && !secFN) { + if ( !lstrcmpi(szUse, _T("prompt")) && !secFN) { int result=DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_INSTALLINI), NULL, InstallIniDlgProc, (LPARAM)szIniPath); if (result == IDC_NOTOALL) break; if (result == IDCANCEL) continue; @@ -431,9 +431,9 @@ static void DoAutoExec(void) else { TCHAR szOnCompletion[8]; GetPrivateProfileString(_T("AutoExec"), _T("OnCompletion"), _T("recycle"), szOnCompletion, SIZEOF(szOnCompletion), mirandabootini); - if (!lstrcmpi(szOnCompletion, _T("delete"))) + if ( !lstrcmpi(szOnCompletion, _T("delete"))) DeleteFile(szIniPath); - else if (!lstrcmpi(szOnCompletion, _T("recycle"))) { + else if ( !lstrcmpi(szOnCompletion, _T("recycle"))) { SHFILEOPSTRUCT shfo={0}; shfo.wFunc=FO_DELETE; shfo.pFrom=szIniPath; @@ -441,7 +441,7 @@ static void DoAutoExec(void) shfo.fFlags=FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; SHFileOperation(&shfo); } - else if (!lstrcmpi(szOnCompletion, _T("rename"))) { + else if ( !lstrcmpi(szOnCompletion, _T("rename"))) { TCHAR szRenamePrefix[MAX_PATH]; TCHAR szNewPath[MAX_PATH]; GetPrivateProfileString(_T("AutoExec"), _T("RenamePrefix"), _T("done_"), szRenamePrefix, SIZEOF(szRenamePrefix), mirandabootini); @@ -450,7 +450,7 @@ static void DoAutoExec(void) lstrcat(szNewPath, fd.cFileName); MoveFile(szIniPath, szNewPath); } - else if (!lstrcmpi(szOnCompletion, _T("ask"))) + else if ( !lstrcmpi(szOnCompletion, _T("ask"))) DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_INIIMPORTDONE), NULL, IniImportDoneDlgProc, (LPARAM)szIniPath); } } while (FindNextFile(hFind, &fd)); @@ -484,7 +484,7 @@ int InitIni(void) void UninitIni(void) { - if ( !bModuleInitialized ) return; + if ( !bModuleInitialized) return; CallService(MS_SYSTEM_REMOVEWAIT, (WPARAM)hIniChangeNotification, 0); FindCloseChangeNotification(hIniChangeNotification); } diff --git a/src/modules/database/dblists.cpp b/src/modules/database/dblists.cpp index c4dabf8fae..1dd802c196 100644 --- a/src/modules/database/dblists.cpp +++ b/src/modules/database/dblists.cpp @@ -25,10 +25,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* a simple sorted list implementation */ -SortedList* List_Create( int p_limit, int p_increment ) +SortedList* List_Create(int p_limit, int p_increment) { - SortedList* result = ( SortedList* )mir_calloc( sizeof( SortedList )); - if ( result == NULL ) + SortedList* result = (SortedList*)mir_calloc(sizeof(SortedList)); + if (result == NULL) return(NULL); result->increment = p_increment; @@ -36,34 +36,34 @@ SortedList* List_Create( int p_limit, int p_increment ) return(result); } -void List_Destroy( SortedList* p_list ) +void List_Destroy(SortedList* p_list) { - if ( p_list == NULL ) + if (p_list == NULL) return; - if ( p_list->items != NULL ) { - mir_free( p_list->items ); + if (p_list->items != NULL) { + mir_free(p_list->items); p_list->items = NULL; } p_list->realCount = p_list->limit = 0; } -void* List_Find( SortedList* p_list, void* p_value ) +void* List_Find(SortedList* p_list, void* p_value) { int index; - if ( !List_GetIndex( p_list, p_value, &index )) + if ( !List_GetIndex(p_list, p_value, &index)) return(NULL); return(p_list->items[ index ]); } #ifdef _DEBUG -#pragma optimize( "gt", on ) +#pragma optimize("gt", on) #endif -int List_GetIndex( SortedList* p_list, void* p_value, int* p_index ) +int List_GetIndex(SortedList* p_list, void* p_value, int* p_index) { if (p_value == NULL) { @@ -184,36 +184,36 @@ int List_GetIndex( SortedList* p_list, void* p_value, int* p_index ) return 0; } -int List_IndexOf( SortedList* p_list, void* p_value ) +int List_IndexOf(SortedList* p_list, void* p_value) { - if ( p_value == NULL ) + if (p_value == NULL) return -1; int i; - for ( i=0; i < p_list->realCount; i++ ) - if ( p_list->items[i] == p_value ) + for (i=0; i < p_list->realCount; i++) + if (p_list->items[i] == p_value) return i; return -1; } #ifdef _DEBUG -#pragma optimize( "", on ) +#pragma optimize("", on) #endif -int List_Insert( SortedList* p_list, void* p_value, int p_index) +int List_Insert(SortedList* p_list, void* p_value, int p_index) { - if ( p_value == NULL || p_index > p_list->realCount ) + if (p_value == NULL || p_index > p_list->realCount) return 0; - if ( p_list->realCount == p_list->limit ) + if (p_list->realCount == p_list->limit) { - p_list->items = ( void** )mir_realloc( p_list->items, sizeof( void* )*(p_list->realCount + p_list->increment)); + p_list->items = (void**)mir_realloc(p_list->items, sizeof(void*)*(p_list->realCount + p_list->increment)); p_list->limit += p_list->increment; } - if ( p_index < p_list->realCount ) - memmove( p_list->items+p_index+1, p_list->items+p_index, sizeof( void* )*( p_list->realCount-p_index )); + if (p_index < p_list->realCount) + memmove(p_list->items+p_index+1, p_list->items+p_index, sizeof(void*)*(p_list->realCount-p_index)); p_list->realCount++; @@ -221,62 +221,62 @@ int List_Insert( SortedList* p_list, void* p_value, int p_index) return 1; } -int List_InsertPtr( SortedList* list, void* p ) +int List_InsertPtr(SortedList* list, void* p) { - if ( p == NULL ) + if (p == NULL) return -1; int idx = list->realCount; - List_GetIndex( list, p, &idx ); - return List_Insert( list, p, idx ); + List_GetIndex(list, p, &idx); + return List_Insert(list, p, idx); } -int List_Remove( SortedList* p_list, int index ) +int List_Remove(SortedList* p_list, int index) { - if ( index < 0 || index > p_list->realCount ) + if (index < 0 || index > p_list->realCount) return(0); p_list->realCount--; - if ( p_list->realCount > index ) + if (p_list->realCount > index) { - memmove( p_list->items+index, p_list->items+index+1, sizeof( void* )*( p_list->realCount-index )); + memmove(p_list->items+index, p_list->items+index+1, sizeof(void*)*(p_list->realCount-index)); p_list->items[ p_list->realCount ] = NULL; } return 1; } -int List_RemovePtr( SortedList* list, void* p ) +int List_RemovePtr(SortedList* list, void* p) { int idx = -1; - if ( List_GetIndex( list, p, &idx )) - List_Remove( list, idx ); + if (List_GetIndex(list, p, &idx)) + List_Remove(list, idx); return idx; } -void List_Copy( SortedList* s, SortedList* d, size_t itemSize ) +void List_Copy(SortedList* s, SortedList* d, size_t itemSize) { int i; d->increment = s->increment; d->sortFunc = s->sortFunc; - for ( i = 0; i < s->realCount; i++ ) { - void* item = mir_alloc( itemSize ); - memcpy( item, s->items[i], itemSize ); - List_Insert( d, item, i ); + for (i = 0; i < s->realCount; i++) { + void* item = mir_alloc(itemSize); + memcpy(item, s->items[i], itemSize); + List_Insert(d, item, i); } } -void List_ObjCopy( SortedList* s, SortedList* d, size_t itemSize ) +void List_ObjCopy(SortedList* s, SortedList* d, size_t itemSize) { int i; d->increment = s->increment; d->sortFunc = s->sortFunc; - for ( i = 0; i < s->realCount; i++ ) { + for (i = 0; i < s->realCount; i++) { void* item = new char[ itemSize ]; - memcpy( item, s->items[i], itemSize ); - List_Insert( d, item, i ); + memcpy(item, s->items[i], itemSize); + List_Insert(d, item, i); } } diff --git a/src/modules/database/dblists.h b/src/modules/database/dblists.h index 160e45eca3..8975f37275 100644 --- a/src/modules/database/dblists.h +++ b/src/modules/database/dblists.h @@ -23,17 +23,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* a simple sorted list implementation */ -SortedList* List_Create( int, int ); -void List_Destroy( SortedList* ); +SortedList* List_Create(int, int); +void List_Destroy(SortedList*); -void* List_Find( SortedList*, void* ); -int List_GetIndex( SortedList*, void*, int* ); -int List_Insert( SortedList*, void*, int ); -int List_Remove( SortedList*, int ); -int List_IndexOf( SortedList*, void* ); +void* List_Find(SortedList*, void*); +int List_GetIndex(SortedList*, void*, int*); +int List_Insert(SortedList*, void*, int); +int List_Remove(SortedList*, int); +int List_IndexOf(SortedList*, void*); -int List_InsertPtr( SortedList* list, void* p ); -int List_RemovePtr( SortedList* list, void* p ); +int List_InsertPtr(SortedList* list, void* p); +int List_RemovePtr(SortedList* list, void* p); -void List_Copy( SortedList*, SortedList*, size_t ); -void List_ObjCopy( SortedList*, SortedList*, size_t ); +void List_Copy(SortedList*, SortedList*, size_t); +void List_ObjCopy(SortedList*, SortedList*, size_t); diff --git a/src/modules/database/dbutils.cpp b/src/modules/database/dbutils.cpp index 6cad16035b..dede30691b 100644 --- a/src/modules/database/dbutils.cpp +++ b/src/modules/database/dbutils.cpp @@ -24,51 +24,51 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h" #include "profilemanager.h" -static int CompareEventTypes( const DBEVENTTYPEDESCR* p1, const DBEVENTTYPEDESCR* p2 ) +static int CompareEventTypes(const DBEVENTTYPEDESCR* p1, const DBEVENTTYPEDESCR* p2) { - int result = strcmp( p1->module, p2->module ); - if ( result ) + int result = strcmp(p1->module, p2->module); + if (result) return result; return p1->eventType - p2->eventType; } -static LIST eventTypes( 10, CompareEventTypes ); +static LIST eventTypes(10, CompareEventTypes); static BOOL bModuleInitialized = FALSE; static INT_PTR DbEventTypeRegister(WPARAM, LPARAM lParam) { - DBEVENTTYPEDESCR* et = ( DBEVENTTYPEDESCR* )lParam; - if ( eventTypes.getIndex( et ) == -1 ) { - DBEVENTTYPEDESCR* p = ( DBEVENTTYPEDESCR* )mir_alloc( sizeof( DBEVENTTYPEDESCR )); + DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)lParam; + if (eventTypes.getIndex(et) == -1) { + DBEVENTTYPEDESCR* p = (DBEVENTTYPEDESCR*)mir_alloc(sizeof(DBEVENTTYPEDESCR)); p->cbSize = DBEVENTTYPEDESCR_SIZE; - p->module = mir_strdup( et->module ); + p->module = mir_strdup(et->module); p->eventType = et->eventType; - p->descr = mir_strdup( et->descr ); + p->descr = mir_strdup(et->descr); p->textService = NULL; p->iconService = NULL; p->eventIcon = NULL; p->flags = 0; - if ( et->cbSize == DBEVENTTYPEDESCR_SIZE ) { - if ( et->textService ) - p->textService = mir_strdup( et->textService ); - if ( et->iconService ) - p->iconService = mir_strdup( et->iconService ); + if (et->cbSize == DBEVENTTYPEDESCR_SIZE) { + if (et->textService) + p->textService = mir_strdup(et->textService); + if (et->iconService) + p->iconService = mir_strdup(et->iconService); p->eventIcon = et->eventIcon; p->flags = et->flags; } - if ( !p->textService ) { + if ( !p->textService) { char szServiceName[100]; - mir_snprintf( szServiceName, sizeof(szServiceName), "%s/GetEventText%d", p->module, p->eventType ); - p->textService = mir_strdup( szServiceName ); + mir_snprintf(szServiceName, sizeof(szServiceName), "%s/GetEventText%d", p->module, p->eventType); + p->textService = mir_strdup(szServiceName); } - if ( !p->iconService ) { + if ( !p->iconService) { char szServiceName[100]; - mir_snprintf( szServiceName, sizeof(szServiceName), "%s/GetEventIcon%d", p->module, p->eventType ); - p->iconService = mir_strdup( szServiceName ); + mir_snprintf(szServiceName, sizeof(szServiceName), "%s/GetEventIcon%d", p->module, p->eventType); + p->iconService = mir_strdup(szServiceName); } - eventTypes.insert( p ); + eventTypes.insert(p); } return 0; @@ -79,12 +79,12 @@ static INT_PTR DbEventTypeGet(WPARAM wParam, LPARAM lParam) DBEVENTTYPEDESCR tmp; int idx; - tmp.module = ( char* )wParam; + tmp.module = (char*)wParam; tmp.eventType = lParam; - if ( !List_GetIndex(( SortedList* )&eventTypes, &tmp, &idx )) + if ( !List_GetIndex((SortedList*)&eventTypes, &tmp, &idx)) return 0; - return ( INT_PTR )eventTypes[idx]; + return (INT_PTR)eventTypes[idx]; } static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam) @@ -93,147 +93,147 @@ static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam) BOOL bIsDenyUnicode = (egt->datatype & DBVTF_DENYUNICODE); DBEVENTINFO* dbei = egt->dbei; - DBEVENTTYPEDESCR* et = ( DBEVENTTYPEDESCR* )DbEventTypeGet(( WPARAM )dbei->szModule, ( LPARAM )dbei->eventType ); + DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)DbEventTypeGet((WPARAM)dbei->szModule, (LPARAM)dbei->eventType); - if ( et && ServiceExists( et->textService )) - return CallService( et->textService, wParam, lParam ); + if (et && ServiceExists(et->textService)) + return CallService(et->textService, wParam, lParam); - if ( !dbei->pBlob ) return 0; + if ( !dbei->pBlob) return 0; - if ( dbei->eventType == EVENTTYPE_FILE ) { + if (dbei->eventType == EVENTTYPE_FILE) { char* filename = ((char *)dbei->pBlob) + sizeof(DWORD); - char* descr = filename + lstrlenA( filename ) + 1; + char* descr = filename + lstrlenA(filename) + 1; char* str = (*descr == 0) ? filename : descr; - switch ( egt->datatype ) { + switch (egt->datatype) { case DBVT_WCHAR: - return ( INT_PTR )(( dbei->flags & DBEF_UTF ) ? - Utf8DecodeT( str ) : mir_a2t( str )); + return (INT_PTR)((dbei->flags & DBEF_UTF) ? + Utf8DecodeT(str) : mir_a2t(str)); case DBVT_ASCIIZ: - return ( INT_PTR )(( dbei->flags & DBEF_UTF ) ? Utf8Decode( mir_strdup( str ), NULL ) : mir_strdup( str )); + return (INT_PTR)((dbei->flags & DBEF_UTF) ? Utf8Decode(mir_strdup(str), NULL) : mir_strdup(str)); } return 0; } // temporary fix for bug with event types conflict between jabber chat states notifications // and srmm's status changes, must be commented out in future releases - if ( dbei->eventType == 25368 && dbei->cbBlob == 1 && dbei->pBlob[0] == 1 ) + if (dbei->eventType == 25368 && dbei->cbBlob == 1 && dbei->pBlob[0] == 1) return 0; egt->datatype &= ~DBVTF_DENYUNICODE; - if ( egt->datatype == DBVT_WCHAR ) + if (egt->datatype == DBVT_WCHAR) { WCHAR* msg = NULL; - if ( dbei->flags & DBEF_UTF ) { + if (dbei->flags & DBEF_UTF) { char* str = (char*)alloca(dbei->cbBlob + 1); if (str == NULL) return NULL; memcpy(str, dbei->pBlob, dbei->cbBlob); str[dbei->cbBlob] = 0; - Utf8DecodeCP( str, egt->codepage, &msg ); + Utf8DecodeCP(str, egt->codepage, &msg); } else { - size_t msglen = strlen(( char* )dbei->pBlob) + 1, msglenW = 0; - if ( msglen != dbei->cbBlob ) { - size_t i, count = (( dbei->cbBlob - msglen ) / sizeof( WCHAR )); - WCHAR* p = ( WCHAR* )&dbei->pBlob[ msglen ]; - for ( i=0; i < count; i++ ) { - if ( p[i] == 0 ) { + size_t msglen = strlen((char*)dbei->pBlob) + 1, msglenW = 0; + if (msglen != dbei->cbBlob) { + size_t i, count = ((dbei->cbBlob - msglen) / sizeof(WCHAR)); + WCHAR* p = (WCHAR*)&dbei->pBlob[ msglen ]; + for (i=0; i < count; i++) { + if (p[i] == 0) { msglenW = i; break; } } } - if ( msglenW > 0 && msglenW < msglen && !bIsDenyUnicode ) - msg = mir_wstrdup(( WCHAR* )&dbei->pBlob[ msglen ] ); + if (msglenW > 0 && msglenW < msglen && !bIsDenyUnicode) + msg = mir_wstrdup((WCHAR*)&dbei->pBlob[ msglen ]); else { - msg = ( WCHAR* )mir_alloc( sizeof(WCHAR) * msglen ); - MultiByteToWideChar( egt->codepage, 0, (char *) dbei->pBlob, -1, msg, (int)msglen ); + msg = (WCHAR*)mir_alloc(sizeof(WCHAR) * msglen); + MultiByteToWideChar(egt->codepage, 0, (char *) dbei->pBlob, -1, msg, (int)msglen); } } - return ( INT_PTR )msg; + return (INT_PTR)msg; } - else if ( egt->datatype == DBVT_ASCIIZ ) { - char* msg = mir_strdup(( char* )dbei->pBlob ); + else if (egt->datatype == DBVT_ASCIIZ) { + char* msg = mir_strdup((char*)dbei->pBlob); if (dbei->flags & DBEF_UTF) - Utf8DecodeCP( msg, egt->codepage, NULL ); + Utf8DecodeCP(msg, egt->codepage, NULL); - return ( INT_PTR )msg; + return (INT_PTR)msg; } return 0; } -static INT_PTR DbEventGetIcon( WPARAM wParam, LPARAM lParam ) +static INT_PTR DbEventGetIcon(WPARAM wParam, LPARAM lParam) { - DBEVENTINFO* dbei = ( DBEVENTINFO* )lParam; + DBEVENTINFO* dbei = (DBEVENTINFO*)lParam; HICON icon = NULL; - DBEVENTTYPEDESCR* et = ( DBEVENTTYPEDESCR* )DbEventTypeGet(( WPARAM )dbei->szModule, ( LPARAM )dbei->eventType ); + DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)DbEventTypeGet((WPARAM)dbei->szModule, (LPARAM)dbei->eventType); - if ( et && ServiceExists( et->iconService )) { - icon = ( HICON )CallService( et->iconService, wParam, lParam ); - if ( icon ) - return ( INT_PTR )icon; + if (et && ServiceExists(et->iconService)) { + icon = (HICON)CallService(et->iconService, wParam, lParam); + if (icon) + return (INT_PTR)icon; } - if ( et && et->eventIcon ) - icon = ( HICON )CallService( MS_SKIN2_GETICONBYHANDLE, 0, ( LPARAM )et->eventIcon ); - if ( !icon ) { + if (et && et->eventIcon) + icon = (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)et->eventIcon); + if ( !icon) { char szName[100]; - mir_snprintf( szName, sizeof( szName ), "eventicon_%s%d", dbei->szModule, dbei->eventType ); - icon = ( HICON )CallService( MS_SKIN2_GETICON, 0, ( LPARAM )szName ); + mir_snprintf(szName, sizeof(szName), "eventicon_%s%d", dbei->szModule, dbei->eventType); + icon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)szName); } - if ( !icon ) + if ( !icon) { - switch( dbei->eventType ) { + switch(dbei->eventType) { case EVENTTYPE_URL: - icon = LoadSkinIcon( SKINICON_EVENT_URL ); + icon = LoadSkinIcon(SKINICON_EVENT_URL); break; case EVENTTYPE_FILE: - icon = LoadSkinIcon( SKINICON_EVENT_FILE ); + icon = LoadSkinIcon(SKINICON_EVENT_FILE); break; default: // EVENTTYPE_MESSAGE and unknown types - icon = LoadSkinIcon( SKINICON_EVENT_MESSAGE ); + icon = LoadSkinIcon(SKINICON_EVENT_MESSAGE); break; } } - if ( wParam & LR_SHARED ) - return ( INT_PTR )icon; + if (wParam & LR_SHARED) + return (INT_PTR)icon; else - return ( INT_PTR )CopyIcon( icon ); + return (INT_PTR)CopyIcon(icon); } -static INT_PTR DbEventGetStringT( WPARAM wParam, LPARAM lParam ) +static INT_PTR DbEventGetStringT(WPARAM wParam, LPARAM lParam) { - DBEVENTINFO* dbei = ( DBEVENTINFO* )wParam; - char* string = ( char* )lParam; + DBEVENTINFO* dbei = (DBEVENTINFO*)wParam; + char* string = (char*)lParam; - if ( dbei->flags & DBEF_UTF ) - return ( INT_PTR )Utf8DecodeUcs2( string ); + if (dbei->flags & DBEF_UTF) + return (INT_PTR)Utf8DecodeUcs2(string); - return ( INT_PTR )mir_a2t( string ); + return (INT_PTR)mir_a2t(string); } ///////////////////////////////////////////////////////////////////////////////////////// -static int sttEnumVars( const char* szVarName, LPARAM lParam ) +static int sttEnumVars(const char* szVarName, LPARAM lParam) { - LIST* vars = ( LIST* )lParam; - vars->insert( mir_strdup( szVarName )); + LIST* vars = (LIST*)lParam; + vars->insert(mir_strdup(szVarName)); return 0; } -static INT_PTR DbDeleteModule( WPARAM, LPARAM lParam ) +static INT_PTR DbDeleteModule(WPARAM, LPARAM lParam) { - LIST vars( 20 ); + LIST vars(20); DBCONTACTENUMSETTINGS dbces = { 0 }; dbces.pfnEnumProc = sttEnumVars; - dbces.lParam = ( LPARAM )&vars; - dbces.szModule = ( char* )lParam; - CallService( MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbces ); + dbces.lParam = (LPARAM)&vars; + dbces.szModule = (char*)lParam; + CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbces); - for ( int i=vars.getCount()-1; i >= 0; i-- ) { - DBDeleteContactSetting( NULL, ( char* )lParam, vars[i] ); - mir_free( vars[i] ); + for (int i=vars.getCount()-1; i >= 0; i--) { + DBDeleteContactSetting(NULL, (char*)lParam, vars[i]); + mir_free(vars[i]); } vars.destroy(); return 0; @@ -241,14 +241,14 @@ static INT_PTR DbDeleteModule( WPARAM, LPARAM lParam ) static INT_PTR GetProfilePath(WPARAM wParam, LPARAM lParam) { - if (!wParam || !lParam) + if ( !wParam || !lParam) return 1; char* dst = (char*)lParam; - char* tmp = mir_t2a( g_profileDir ); - strncpy( dst, tmp, wParam ); - mir_free( tmp ); + char* tmp = mir_t2a(g_profileDir); + strncpy(dst, tmp, wParam); + mir_free(tmp); if (wParam <= _tcslen(g_profileName)) { @@ -260,14 +260,14 @@ static INT_PTR GetProfilePath(WPARAM wParam, LPARAM lParam) static INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam) { - if (!wParam || !lParam) + if ( !wParam || !lParam) return 1; char* dst = (char*)lParam; - char* tmp = makeFileName( g_profileName ); - strncpy( dst, tmp, wParam ); - mir_free( tmp ); + char* tmp = makeFileName(g_profileName); + strncpy(dst, tmp, wParam); + mir_free(tmp); if (wParam <= _tcslen(g_profileName)) { @@ -279,7 +279,7 @@ static INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam) static INT_PTR GetProfilePathW(WPARAM wParam, LPARAM lParam) { - if (!wParam || !lParam) + if ( !wParam || !lParam) return 1; wchar_t* dst = (wchar_t*)lParam; @@ -295,7 +295,7 @@ static INT_PTR GetProfilePathW(WPARAM wParam, LPARAM lParam) static INT_PTR GetProfileNameW(WPARAM wParam, LPARAM lParam) { wchar_t* dst = (wchar_t*)lParam; - wcsncpy(dst, g_profileName, wParam ); + wcsncpy(dst, g_profileName, wParam); if (wParam <= wcslen(g_profileName)) { dst[wParam - 1] = 0; @@ -329,15 +329,15 @@ void UnloadEventsModule() { int i; - if ( !bModuleInitialized ) return; + if ( !bModuleInitialized) return; - for ( i=0; i < eventTypes.getCount(); i++ ) { + for (i=0; i < eventTypes.getCount(); i++) { DBEVENTTYPEDESCR* p = eventTypes[i]; - mir_free( p->module ); - mir_free( p->descr ); - mir_free( p->textService ); - mir_free( p->iconService ); - mir_free( p ); + mir_free(p->module); + mir_free(p->descr); + mir_free(p->textService); + mir_free(p->iconService); + mir_free(p); } eventTypes.destroy(); diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp index 7d362fd554..e568aa778e 100644 --- a/src/modules/database/profilemanager.cpp +++ b/src/modules/database/profilemanager.cpp @@ -68,7 +68,7 @@ struct ProfileEnumData { extern TCHAR mirandabootini[MAX_PATH]; char **GetServiceModePluginsList(void); -void SetServiceModePlugin( int idx ); +void SetServiceModePlugin(int idx); static void ThemeDialogBackground(HWND hwnd) { @@ -84,22 +84,22 @@ static int findProfiles(TCHAR * szProfileDir, ENUMPROFILECALLBACK callback, LPAR TCHAR searchspec[MAX_PATH]; mir_sntprintf(searchspec, SIZEOF(searchspec), _T("%s\\*.*"), szProfileDir); hFind = FindFirstFile(searchspec, &ffd); - if ( hFind == INVALID_HANDLE_VALUE ) + if (hFind == INVALID_HANDLE_VALUE) return 0; do { // find all subfolders except "." and ".." - if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && _tcscmp(ffd.cFileName, _T(".")) && _tcscmp(ffd.cFileName, _T("..")) ) { + if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && _tcscmp(ffd.cFileName, _T(".")) && _tcscmp(ffd.cFileName, _T(".."))) { TCHAR buf[MAX_PATH], profile[MAX_PATH]; mir_sntprintf(buf, SIZEOF(buf), _T("%s\\%s\\%s.dat"), szProfileDir, ffd.cFileName, ffd.cFileName); if (_taccess(buf, 0) == 0) { mir_sntprintf(profile, SIZEOF(profile), _T("%s.dat"), ffd.cFileName); - if ( !callback(buf, profile, lParam )) + if ( !callback(buf, profile, lParam)) break; } } } - while ( FindNextFile(hFind, &ffd) ); + while (FindNextFile(hFind, &ffd)); FindClose(hFind); return 1; @@ -107,8 +107,8 @@ static int findProfiles(TCHAR * szProfileDir, ENUMPROFILECALLBACK callback, LPAR static LRESULT CALLBACK ProfileNameValidate(HWND edit, UINT msg, WPARAM wParam, LPARAM lParam) { - if ( msg == WM_CHAR ) { - if ( _tcschr( _T(".?/\\#' "), (TCHAR)wParam) != 0 ) + if (msg == WM_CHAR) { + if (_tcschr(_T(".?/\\#' "), (TCHAR)wParam) != 0) return 0; PostMessage(GetParent(edit), WM_INPUTCHANGED, 0, 0); } @@ -121,11 +121,11 @@ static int FindDbProviders(const char*, DATABASELINK * dblink, LPARAM lParam) HWND hwndCombo = GetDlgItem(hwndDlg, IDC_PROFILEDRIVERS); char szName[64]; - if ( dblink->getFriendlyName(szName, SIZEOF(szName), 1) == 0 ) { + if (dblink->getFriendlyName(szName, SIZEOF(szName), 1) == 0) { // add to combo box - TCHAR* p = LangPackPcharToTchar( szName ); - LRESULT index = SendMessage( hwndCombo, CB_ADDSTRING, 0, (LPARAM)p ); - mir_free( p ); + TCHAR* p = LangPackPcharToTchar(szName); + LRESULT index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)p); + mir_free(p); SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)dblink); } return DBPE_CONT; @@ -136,7 +136,7 @@ static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPA struct DlgProfData * dat = (struct DlgProfData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: - TranslateDialogDefault( hwndDlg ); + TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); dat = (struct DlgProfData *)lParam; { @@ -145,11 +145,11 @@ static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPA dbe.cbSize = sizeof(dbe); dbe.pfnEnumCallback = (int(*)(const char*, void*, LPARAM))FindDbProviders; dbe.lParam = (LPARAM)hwndDlg; - if ( CallService( MS_PLUGINS_ENUMDBPLUGINS, 0, ( LPARAM )&dbe ) == -1 ) { + if (CallService(MS_PLUGINS_ENUMDBPLUGINS, 0, (LPARAM)&dbe) == -1) { // no plugins?! - EnableWindow( GetDlgItem(hwndDlg, IDC_PROFILEDRIVERS ), FALSE ); - EnableWindow( GetDlgItem(hwndDlg, IDC_PROFILENAME ), FALSE ); - ShowWindow( GetDlgItem(hwndDlg, IDC_NODBDRIVERS ), TRUE ); + EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILEDRIVERS), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILENAME), FALSE); + ShowWindow(GetDlgItem(hwndDlg, IDC_NODBDRIVERS), TRUE); } // default item SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_SETCURSEL, 0, 0); @@ -178,43 +178,43 @@ static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPA } // focus on the textbox - PostMessage( hwndDlg, WM_FOCUSTEXTBOX, 0, 0 ); + PostMessage(hwndDlg, WM_FOCUSTEXTBOX, 0, 0); return TRUE; case WM_FOCUSTEXTBOX: - SetFocus( GetDlgItem( hwndDlg, IDC_PROFILENAME )); + SetFocus(GetDlgItem(hwndDlg, IDC_PROFILENAME)); break; case WM_INPUTCHANGED: // when input in the edit box changes - SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); - EnableWindow( dat->hwndOK, GetWindowTextLength( GetDlgItem( hwndDlg, IDC_PROFILENAME )) > 0 ); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + EnableWindow(dat->hwndOK, GetWindowTextLength(GetDlgItem(hwndDlg, IDC_PROFILENAME)) > 0); break; case WM_SHOWWINDOW: - if ( wParam ) { - SetWindowText( dat->hwndOK, TranslateT("&Create")); - SendMessage( hwndDlg, WM_INPUTCHANGED, 0, 0 ); + if (wParam) { + SetWindowText(dat->hwndOK, TranslateT("&Create")); + SendMessage(hwndDlg, WM_INPUTCHANGED, 0, 0); } break; case WM_NOTIFY: { - NMHDR* hdr = ( NMHDR* )lParam; - if ( hdr && hdr->code == PSN_APPLY && dat && IsWindowVisible( hwndDlg )) { + NMHDR* hdr = (NMHDR*)lParam; + if (hdr && hdr->code == PSN_APPLY && dat && IsWindowVisible(hwndDlg)) { TCHAR szName[MAX_PATH]; LRESULT curSel = SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETCURSEL, 0, 0); - if ( curSel == CB_ERR ) break; // should never happen - GetDlgItemText(hwndDlg, IDC_PROFILENAME, szName, SIZEOF( szName )); - if ( szName[0] == 0 ) + if (curSel == CB_ERR) break; // should never happen + GetDlgItemText(hwndDlg, IDC_PROFILENAME, szName, SIZEOF(szName)); + if (szName[0] == 0) break; // profile placed in "profile_name" subfolder - mir_sntprintf( dat->pd->szProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, szName, szName ); + mir_sntprintf(dat->pd->szProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, szName, szName); dat->pd->newProfile = 1; - dat->pd->dblink = (DATABASELINK *)SendDlgItemMessage( hwndDlg, IDC_PROFILEDRIVERS, CB_GETITEMDATA, ( WPARAM )curSel, 0 ); + dat->pd->dblink = (DATABASELINK *)SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETITEMDATA, (WPARAM)curSel, 0); - if ( makeDatabase( dat->pd->szProfile, dat->pd->dblink, hwndDlg ) == 0 ) { - SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE ); + if (makeDatabase(dat->pd->szProfile, dat->pd->dblink, hwndDlg) == 0) { + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE); } } } break; } @@ -226,11 +226,11 @@ static int DetectDbProvider(const char*, DATABASELINK * dblink, LPARAM lParam) { int error; -char* fullpath = makeFileName(( TCHAR* )lParam ); +char* fullpath = makeFileName((TCHAR*)lParam); int ret = dblink->grokHeader(fullpath, &error); - mir_free( fullpath ); - if ( ret == 0) { + mir_free(fullpath); + if (ret == 0) { char tmp[ MAX_PATH ]; dblink->getFriendlyName(tmp, SIZEOF(tmp), 1); @@ -254,20 +254,20 @@ BOOL EnumProfilesForList(TCHAR * fullpath, TCHAR * profile, LPARAM lParam) TCHAR* p = _tcsrchr(profile, '.'); _tcscpy(sizeBuf, _T("0 KB")); - if ( p != NULL ) *p=0; + if (p != NULL) *p=0; LVITEM item = { 0 }; item.mask = LVIF_TEXT | LVIF_IMAGE; item.pszText = profile; item.iItem = 0; - if ( _tstat(fullpath, &statbuf) == 0) { - if ( statbuf.st_size > 1000000 ) { - mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1048576.0 ); + if (_tstat(fullpath, &statbuf) == 0) { + if (statbuf.st_size > 1000000) { + mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1048576.0); _tcscpy(sizeBuf+5, _T(" MB")); } else { - mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1024.0 ); + mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1024.0); _tcscpy(sizeBuf+5, _T(" KB")); } bFileExists = TRUE; @@ -277,16 +277,16 @@ BOOL EnumProfilesForList(TCHAR * fullpath, TCHAR * profile, LPARAM lParam) item.iImage = bFileLocked; - iItem = SendMessage( hwndList, LVM_INSERTITEM, 0, (LPARAM)&item ); - if ( lstrcmpi(ped->szProfile, fullpath) == 0 ) + iItem = SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item); + if (lstrcmpi(ped->szProfile, fullpath) == 0) ListView_SetItemState(hwndList, iItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); item.iItem = iItem; item.iSubItem = 2; item.pszText = sizeBuf; - SendMessage( hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item ); + SendMessage(hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item); - if ( bFileExists ) { + if (bFileExists) { PLUGIN_DB_ENUM dbe; TCHAR szPath[MAX_PATH]; @@ -298,26 +298,26 @@ BOOL EnumProfilesForList(TCHAR * fullpath, TCHAR * profile, LPARAM lParam) dbe.pfnEnumCallback = (int(*)(const char*, void*, LPARAM))DetectDbProvider; dbe.lParam = (LPARAM)szPath; _tcscpy(szPath, fullpath); - if ( CallService( MS_PLUGINS_ENUMDBPLUGINS, 0, ( LPARAM )&dbe ) == 1 ) { + if (CallService(MS_PLUGINS_ENUMDBPLUGINS, 0, (LPARAM)&dbe) == 1) { if (bFileLocked) { // file locked - item2.pszText = TranslateT( "" ); + item2.pszText = TranslateT(""); item2.iSubItem = 1; - SendMessage( hwndList, LVM_SETITEMTEXT, iItem, ( LPARAM )&item2 ); + SendMessage(hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item2); } else { item.pszText = szPath; item.iSubItem = 1; - SendMessage( hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item ); + SendMessage(hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item); } } item2.iSubItem = 3; - item2.pszText = rtrim( _tctime( &statbuf.st_ctime )); - SendMessage( hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item2 ); + item2.pszText = rtrim(_tctime(&statbuf.st_ctime)); + SendMessage(hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item2); item2.iSubItem = 4; - item2.pszText = rtrim( _tctime( &statbuf.st_mtime )); - SendMessage( hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item2 ); + item2.pszText = rtrim(_tctime(&statbuf.st_mtime)); + SendMessage(hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item2); } return TRUE; } @@ -334,7 +334,7 @@ void DeleteProfile(HWND hwndList, int iItem, DlgProfData* dat) item.iItem = iItem; item.pszText = profile; item.cchTextMax = SIZEOF(profile); - if (!ListView_GetItem(hwndList, &item)) + if ( !ListView_GetItem(hwndList, &item)) return; mir_sntprintf(profilef, SIZEOF(profilef), TranslateT("Are you sure you want to remove profile \"%s\"?"), profile); @@ -363,7 +363,7 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, HIMAGELIST hImgList; LVCOLUMN col; - TranslateDialogDefault( hwndDlg ); + TranslateDialogDefault(hwndDlg); dat = (DlgProfData*) lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); @@ -372,23 +372,23 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = TranslateT("Profile"); col.cx=122; - ListView_InsertColumn( hwndList, 0, &col ); + ListView_InsertColumn(hwndList, 0, &col); col.pszText = TranslateT("Driver"); col.cx=100; - ListView_InsertColumn( hwndList, 1, &col ); + ListView_InsertColumn(hwndList, 1, &col); col.pszText = TranslateT("Size"); col.cx=60; - ListView_InsertColumn( hwndList, 2, &col ); + ListView_InsertColumn(hwndList, 2, &col); col.pszText = TranslateT("Created"); col.cx=145; - ListView_InsertColumn( hwndList, 3, &col ); + ListView_InsertColumn(hwndList, 3, &col); col.pszText = TranslateT("Modified"); col.cx=145; - ListView_InsertColumn( hwndList, 4, &col ); + ListView_InsertColumn(hwndList, 4, &col); // icons hImgList = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 2, 1); @@ -435,7 +435,7 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, break; case WM_SHOWWINDOW: - if ( wParam ) + if (wParam) { SetWindowText(dat->hwndOK, TranslateT("&Run")); EnableWindow(dat->hwndOK, ListView_GetSelectedCount(hwndList) == 1); @@ -529,7 +529,7 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - struct DetailsData* dat = ( struct DetailsData* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); + struct DetailsData* dat = (struct DetailsData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: @@ -541,9 +541,9 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadImage(hMirandaInst, MAKEINTRESOURCE(IDI_USERDETAILS), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0)); dat = (struct DetailsData*)mir_alloc(sizeof(struct DetailsData)); dat->prof = prof; - prof->hwndOK = GetDlgItem( hwndDlg, IDOK ); - EnableWindow( prof->hwndOK, FALSE ); - SetWindowLongPtr( hwndDlg, GWLP_USERDATA, (LONG_PTR)dat ); + prof->hwndOK = GetDlgItem(hwndDlg, IDOK); + EnableWindow(prof->hwndOK, FALSE); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); { TCHAR buf[512]; @@ -558,72 +558,72 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, dat->currentPage = 0; dat->pageCount = psh->nPages; - dat->opd = ( struct DetailsPageData* )mir_calloc( sizeof( struct DetailsPageData )*dat->pageCount ); - odp = ( OPTIONSDIALOGPAGE* )psh->ppsp; + dat->opd = (struct DetailsPageData*)mir_calloc(sizeof(struct DetailsPageData)*dat->pageCount); + odp = (OPTIONSDIALOGPAGE*)psh->ppsp; tci.mask = TCIF_TEXT; - for ( i=0; i < dat->pageCount; i++ ) { + for (i=0; i < dat->pageCount; i++) { dat->opd[i].pTemplate = (DLGTEMPLATE *)LockResource(LoadResource(odp[i].hInstance, FindResourceA(odp[i].hInstance, odp[i].pszTemplate, MAKEINTRESOURCEA(5)))); dat->opd[i].dlgProc = odp[i].pfnDlgProc; dat->opd[i].hInst = odp[i].hInstance; dat->opd[i].hwnd = NULL; dat->opd[i].changed = 0; - tci.pszText = ( TCHAR* )odp[i].ptszTitle; + tci.pszText = (TCHAR*)odp[i].ptszTitle; if (dat->prof->pd->noProfiles || shouldAutoCreate(dat->prof->pd->szProfile)) dat->currentPage = 1; - TabCtrl_InsertItem( GetDlgItem(hwndDlg, IDC_TABS), i, &tci ); + TabCtrl_InsertItem(GetDlgItem(hwndDlg, IDC_TABS), i, &tci); } } GetWindowRect(GetDlgItem(hwndDlg, IDC_TABS), &dat->rcDisplay); TabCtrl_AdjustRect(GetDlgItem(hwndDlg, IDC_TABS), FALSE, &dat->rcDisplay); { POINT pt = {0, 0}; - ClientToScreen( hwndDlg, &pt ); - OffsetRect( &dat->rcDisplay, -pt.x, -pt.y ); + ClientToScreen(hwndDlg, &pt); + OffsetRect(&dat->rcDisplay, -pt.x, -pt.y); } - TabCtrl_SetCurSel( GetDlgItem( hwndDlg, IDC_TABS ), dat->currentPage ); + TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_TABS), dat->currentPage); dat->opd[dat->currentPage].hwnd = CreateDialogIndirectParam(dat->opd[dat->currentPage].hInst, dat->opd[dat->currentPage].pTemplate, hwndDlg, dat->opd[dat->currentPage].dlgProc, (LPARAM)dat->prof); - ThemeDialogBackground( dat->opd[dat->currentPage].hwnd ); - SetWindowPos( dat->opd[dat->currentPage].hwnd, HWND_TOP, dat->rcDisplay.left, dat->rcDisplay.top, 0, 0, SWP_NOSIZE ); + ThemeDialogBackground(dat->opd[dat->currentPage].hwnd); + SetWindowPos(dat->opd[dat->currentPage].hwnd, HWND_TOP, dat->rcDisplay.left, dat->rcDisplay.top, 0, 0, SWP_NOSIZE); { PSHNOTIFY pshn; pshn.hdr.code = PSN_INFOCHANGED; pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; pshn.hdr.idFrom = 0; - pshn.lParam = ( LPARAM )0; - SendMessage( dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, ( LPARAM )&pshn ); + pshn.lParam = (LPARAM)0; + SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); } // service mode combobox { char **list = GetServiceModePluginsList(); - if ( !list ) { - ShowWindow( GetDlgItem(hwndDlg, IDC_SM_LABEL ), FALSE ); - ShowWindow( GetDlgItem(hwndDlg, IDC_SM_COMBO ), FALSE ); + if ( !list) { + ShowWindow(GetDlgItem(hwndDlg, IDC_SM_LABEL), FALSE); + ShowWindow(GetDlgItem(hwndDlg, IDC_SM_COMBO), FALSE); } else { int i = 0; LRESULT index; - HWND hwndCombo = GetDlgItem(hwndDlg, IDC_SM_COMBO ); - index = SendMessage( hwndCombo, CB_ADDSTRING, 0, (LPARAM)_T("") ); - SendMessage( hwndCombo, CB_SETITEMDATA, index, (LPARAM)-1 ); - SendMessage( hwndCombo, CB_SETCURSEL, 0, 0); - while ( list[i] ) { - TCHAR *str = LangPackPcharToTchar( list[i] ); - index = SendMessage( hwndCombo, CB_ADDSTRING, 0, (LPARAM)str ); + HWND hwndCombo = GetDlgItem(hwndDlg, IDC_SM_COMBO); + index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)_T("")); + SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)-1); + SendMessage(hwndCombo, CB_SETCURSEL, 0, 0); + while (list[i]) { + TCHAR *str = LangPackPcharToTchar(list[i]); + index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)str); mir_free(str); - SendMessage( hwndCombo, CB_SETITEMDATA, index, (LPARAM)i ); + SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)i); i++; } mir_free(list); } } - ShowWindow( dat->opd[dat->currentPage].hwnd, SW_SHOW ); + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOW); return TRUE; } case WM_CTLCOLORSTATIC: - switch ( GetDlgCtrlID(( HWND )lParam )) { + switch (GetDlgCtrlID((HWND)lParam)) { case IDC_WHITERECT: - SetBkColor(( HDC )wParam, GetSysColor( COLOR_WINDOW )); - return ( INT_PTR )GetSysColorBrush( COLOR_WINDOW ); + SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); + return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); } break; @@ -638,9 +638,9 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, pshn.hdr.code = PSN_INFOCHANGED; pshn.hdr.idFrom = 0; pshn.lParam = (LPARAM)0; - for ( i=0; i < dat->pageCount; i++ ) { + for (i=0; i < dat->pageCount; i++) { pshn.hdr.hwndFrom = dat->opd[i].hwnd; - if ( dat->opd[i].hwnd != NULL ) + if (dat->opd[i].hwnd != NULL) SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); } break; @@ -651,25 +651,25 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, switch(((LPNMHDR)lParam)->code) { case TCN_SELCHANGING: { PSHNOTIFY pshn; - if ( dat->currentPage == -1 || dat->opd[dat->currentPage].hwnd == NULL ) + if (dat->currentPage == -1 || dat->opd[dat->currentPage].hwnd == NULL) break; pshn.hdr.code = PSN_KILLACTIVE; pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; pshn.hdr.idFrom = 0; pshn.lParam = 0; - if ( SendMessage( dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, ( LPARAM )&pshn )) { - SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, TRUE ); + if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) { + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); return TRUE; } break; } case TCN_SELCHANGE: - if ( dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL ) - ShowWindow( dat->opd[ dat->currentPage ].hwnd, SW_HIDE ); + if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) + ShowWindow(dat->opd[ dat->currentPage ].hwnd, SW_HIDE); dat->currentPage = TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TABS)); - if ( dat->currentPage != -1 ) { - if ( dat->opd[dat->currentPage].hwnd == NULL ) { + if (dat->currentPage != -1) { + if (dat->opd[dat->currentPage].hwnd == NULL) { PSHNOTIFY pshn; dat->opd[dat->currentPage].hwnd=CreateDialogIndirectParam(dat->opd[dat->currentPage].hInst, dat->opd[dat->currentPage].pTemplate, hwndDlg, dat->opd[dat->currentPage].dlgProc, (LPARAM)dat->prof); ThemeDialogBackground(dat->opd[dat->currentPage].hwnd); @@ -706,7 +706,7 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, break; case IDC_REMOVE: - if (!dat->prof->pd->noProfiles) { + if ( !dat->prof->pd->noProfiles) { HWND hwndList = GetDlgItem(dat->opd[0].hwnd, IDC_PROFILELIST); DeleteProfile(hwndList, ListView_GetNextItem(hwndList, -1, LVNI_SELECTED | LVNI_ALL), dat->prof); } @@ -718,26 +718,26 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, PSHNOTIFY pshn; pshn.hdr.idFrom=0; pshn.lParam=(LPARAM)0; - if ( dat->currentPage != -1 ) { + if (dat->currentPage != -1) { pshn.hdr.code = PSN_KILLACTIVE; pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; - if ( SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, ( LPARAM )&pshn )) + if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) break; } pshn.hdr.code=PSN_APPLY; - for ( i=0; i < dat->pageCount; i++ ) { - if ( dat->opd[i].hwnd == NULL || !dat->opd[i].changed ) + for (i=0; i < dat->pageCount; i++) { + if (dat->opd[i].hwnd == NULL || !dat->opd[i].changed) continue; pshn.hdr.hwndFrom = dat->opd[i].hwnd; - SendMessage( dat->opd[i].hwnd, WM_NOTIFY, 0, ( LPARAM )&pshn ); - if ( GetWindowLongPtr( dat->opd[i].hwnd, DWLP_MSGRESULT ) == PSNRET_INVALID_NOCHANGEPAGE) { - TabCtrl_SetCurSel( GetDlgItem( hwndDlg, IDC_TABS ), i ); - if ( dat->currentPage != -1 ) - ShowWindow( dat->opd[ dat->currentPage ].hwnd, SW_HIDE ); + SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); + if (GetWindowLongPtr(dat->opd[i].hwnd, DWLP_MSGRESULT) == PSNRET_INVALID_NOCHANGEPAGE) { + TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_TABS), i); + if (dat->currentPage != -1) + ShowWindow(dat->opd[ dat->currentPage ].hwnd, SW_HIDE); dat->currentPage = i; - ShowWindow( dat->opd[dat->currentPage].hwnd, SW_SHOW ); + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOW); return 0; } } EndDialog(hwndDlg, 1); @@ -748,21 +748,21 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_DESTROY: { LRESULT curSel = SendDlgItemMessage(hwndDlg, IDC_SM_COMBO, CB_GETCURSEL, 0, 0); - if ( curSel != CB_ERR ) { - int idx = SendDlgItemMessage( hwndDlg, IDC_SM_COMBO, CB_GETITEMDATA, ( WPARAM )curSel, 0 ); + if (curSel != CB_ERR) { + int idx = SendDlgItemMessage(hwndDlg, IDC_SM_COMBO, CB_GETITEMDATA, (WPARAM)curSel, 0); SetServiceModePlugin(idx); } } - DestroyIcon(( HICON )SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); - DestroyIcon(( HICON )SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); - DeleteObject( dat->hBoldFont ); + DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); + DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); + DeleteObject(dat->hBoldFont); { int i; - for ( i=0; i < dat->pageCount; i++ ) - if ( dat->opd[i].hwnd != NULL ) - DestroyWindow( dat->opd[i].hwnd ); + for (i=0; i < dat->pageCount; i++) + if (dat->opd[i].hwnd != NULL) + DestroyWindow(dat->opd[i].hwnd); } - mir_free( dat->opd ); - mir_free( dat ); + mir_free(dat->opd); + mir_free(dat); break; } return FALSE; @@ -770,10 +770,10 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, static int AddProfileManagerPage(struct DetailsPageInit * opi, OPTIONSDIALOGPAGE * odp) { - if ( odp->cbSize != sizeof( OPTIONSDIALOGPAGE )) + if (odp->cbSize != sizeof(OPTIONSDIALOGPAGE)) return 1; - opi->odp = ( OPTIONSDIALOGPAGE* )mir_realloc( opi->odp, sizeof( OPTIONSDIALOGPAGE )*( opi->pageCount+1 )); + opi->odp = (OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount+1)); { OPTIONSDIALOGPAGE* p = opi->odp + opi->pageCount++; p->cbSize = sizeof(OPTIONSDIALOGPAGE); @@ -785,8 +785,8 @@ static int AddProfileManagerPage(struct DetailsPageInit * opi, OPTIONSDIALOGPAGE p->groupPosition = odp->groupPosition; p->hGroupIcon = odp->hGroupIcon; p->hIcon = odp->hIcon; - if (( DWORD_PTR )odp->pszTemplate & 0xFFFF0000 ) - p->pszTemplate = mir_strdup( odp->pszTemplate ); + if ((DWORD_PTR)odp->pszTemplate & 0xFFFF0000) + p->pszTemplate = mir_strdup(odp->pszTemplate); else p->pszTemplate = odp->pszTemplate; } @@ -827,15 +827,15 @@ int getProfileManager(PROFILEMANAGERDATA * pd) prof.psh = &psh; int rc = DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_PROFILEMANAGER), NULL, DlgProfileManager, (LPARAM)&prof); - if ( rc != -1 ) - for ( int i=0; i < opi.pageCount; i++ ) { - mir_free(( char* )opi.odp[i].pszTitle ); - mir_free( opi.odp[i].pszGroup ); - if (( DWORD_PTR )opi.odp[i].pszTemplate & 0xFFFF0000 ) - mir_free(( char* )opi.odp[i].pszTemplate ); + if (rc != -1) + for (int i=0; i < opi.pageCount; i++) { + mir_free((char*)opi.odp[i].pszTitle); + mir_free(opi.odp[i].pszGroup); + if ((DWORD_PTR)opi.odp[i].pszTemplate & 0xFFFF0000) + mir_free((char*)opi.odp[i].pszTemplate); } - if ( opi.odp != NULL ) + if (opi.odp != NULL) mir_free(opi.odp); return rc; diff --git a/src/modules/database/profilemanager.h b/src/modules/database/profilemanager.h index f132dfad84..9d4e7821e1 100644 --- a/src/modules/database/profilemanager.h +++ b/src/modules/database/profilemanager.h @@ -31,7 +31,7 @@ typedef struct { int InitUtils(void); -char* makeFileName( const TCHAR* tszOriginalName ); +char* makeFileName(const TCHAR* tszOriginalName); int makeDatabase(TCHAR * profile, DATABASELINK * link, HWND hwndDlg); int getProfileManager(PROFILEMANAGERDATA * pd); int getProfilePath(TCHAR * buf, size_t cch); -- cgit v1.2.3