From f3311cd7eb5e87b3718f763a3c08cd3764c84f51 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 28 Jul 2012 16:23:55 +0000 Subject: - added MS_DB_SETDEFAULTPROFILE service for the service plugins - added ability to call the service plugin before loading database - changed the core module modules' loading order git-svn-id: http://svn.miranda-ng.org/main/trunk@1225 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/database/database.cpp | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'src/modules/database/database.cpp') diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index 24b220cd44..8aaa5b9ccc 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern TCHAR mirandabootini[MAX_PATH]; bool dbCreated; TCHAR g_profileDir[MAX_PATH], g_profileName[MAX_PATH]; +TCHAR* g_defaultProfile; bool fileExist(TCHAR* fname) { @@ -129,14 +130,10 @@ static void getDefaultProfile(TCHAR *szProfile, size_t cch, TCHAR *profiledir) } // returns 1 if something that looks like a profile is there -void getProfileCmdLine(TCHAR *szProfile, size_t cch, TCHAR *profiledir) -{ - LPCTSTR ptszProfileName = CmdLine_GetOption( _T("profile")); - if (ptszProfileName == NULL) - return; - +static void loadProfileByShortName(const TCHAR* src, TCHAR *szProfile, size_t cch, TCHAR *profiledir) +{ TCHAR buf[MAX_PATH]; - _tcsncpy(buf, ptszProfileName, SIZEOF(buf)); + _tcsncpy(buf, src, SIZEOF(buf)); TCHAR *p = _tcsrchr(buf, '\\'); if (p) ++p; else p = buf; if ( !isValidProfileName(buf) && *p) @@ -165,6 +162,21 @@ void getProfileCmdLine(TCHAR *szProfile, size_t cch, TCHAR *profiledir) } } +void getProfileCmdLine(TCHAR *szProfile, size_t cch, TCHAR *profiledir) +{ + LPCTSTR ptszProfileName = CmdLine_GetOption( _T("profile")); + if (ptszProfileName != NULL) + loadProfileByShortName(ptszProfileName, szProfile, cch, profiledir); +} + +void getProfileDefault(TCHAR *szProfile, size_t cch, TCHAR *profiledir) +{ + if (g_defaultProfile != NULL) { + loadProfileByShortName(g_defaultProfile, szProfile, cch, profiledir); + mir_free(g_defaultProfile); + } +} + // move profile from profile subdir static void moveProfileDirProfiles(TCHAR *profiledir, BOOL isRootDir = TRUE) { @@ -288,6 +300,7 @@ static int getProfile(TCHAR *szProfile, size_t cch) getDefaultProfile(szProfile, cch, g_profileDir); getProfileCmdLine(szProfile, cch, g_profileDir); + getProfileDefault(szProfile, cch, g_profileDir); if (IsInsideRootDir(g_profileDir, true)) { MessageBox(NULL, _T("Profile cannot be placed into Miranda root folder.\n") @@ -464,9 +477,6 @@ int LoadDatabaseModule(void) _tchdir(szProfile); szProfile[0] = 0; - // load the older basic services of the db - InitUtils(); - // find out which profile to load if ( !getProfile(szProfile, SIZEOF(szProfile))) return 1; @@ -508,5 +518,10 @@ int LoadDatabaseModule(void) } while (retry); - return (rc != 0); + if (rc == ERROR_SUCCESS) { + InitIni(); + return 0; + } + + return rc; } -- cgit v1.2.3