summaryrefslogtreecommitdiff
path: root/src/modules/database/database.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-18 14:11:28 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-18 14:11:28 +0000
commit4bc88d46fa9859615521f436511d4f102f20eb67 (patch)
tree3a6ee91b74be2a4f5e60520885aa601c74bc3fa7 /src/modules/database/database.cpp
parent4f8f5427687792492ee49e06cafb9bd50cfc53d4 (diff)
databases are still static, but are controlled via classes
git-svn-id: http://svn.miranda-ng.org/main/trunk@1014 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/database/database.cpp')
-rw-r--r--src/modules/database/database.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp
index ec25931527..8686d50bc6 100644
--- a/src/modules/database/database.cpp
+++ b/src/modules/database/database.cpp
@@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\..\core\commonheaders.h"
#include "profilemanager.h"
+MIR_CORE_DLL(void) db_setCurrent(MIDatabase* _db);
+
// contains the location of mirandaboot.ini
extern TCHAR mirandabootini[MAX_PATH];
bool dbCreated;
@@ -400,16 +402,13 @@ int makeDatabase(TCHAR *profile, DATABASELINK * link, HWND hwndDlg)
}
// ask the database to create the profile
CreatePathToFileT(profile);
- char *prf = makeFileName(profile);
- if (link->makeDatabase(prf, &err)) {
+ if (link->makeDatabase(profile, &err)) {
mir_sntprintf(buf, SIZEOF(buf), TranslateT("Unable to create the profile '%s', the error was %x"), file, err);
MessageBox(hwndDlg, buf, TranslateT("Problem creating profile"), MB_ICONERROR|MB_OK);
- mir_free(prf);
return 0;
}
dbCreated = true;
// the profile has been created! woot
- mir_free(prf);
return 1;
}
@@ -419,13 +418,14 @@ static int FindDbPluginForProfile(const TCHAR*, DATABASELINK *dblink, LPARAM lPa
TCHAR* tszProfile = (TCHAR*)lParam;
int res = DBPE_CONT;
if (dblink && dblink->cbSize == sizeof(DATABASELINK)) {
- char* szProfile = makeFileName(tszProfile);
// liked the profile?
int err = 0;
- if (dblink->grokHeader(szProfile, &err) == 0) {
+ if (dblink->grokHeader(tszProfile, &err) == 0) {
// added APIs?
- if ( !dblink->Load(szProfile)) {
+ MIDatabase* pDb = dblink->Load(tszProfile);
+ if (pDb) {
fillProfileName(tszProfile);
+ db_setCurrent(currDb = pDb);
res = DBPE_DONE;
}
else res = DBPE_HALT;
@@ -443,7 +443,6 @@ static int FindDbPluginForProfile(const TCHAR*, DATABASELINK *dblink, LPARAM lPa
break;
}
} //if
- mir_free(szProfile);
}
return res;
}
@@ -457,16 +456,14 @@ static int FindDbPluginAutoCreate(const TCHAR* ptszProfile, DATABASELINK * dblin
CreatePathToFileT(tszProfile);
int err;
- char *szProfile = makeFileName(tszProfile);
- if (dblink->makeDatabase(szProfile, &err) == 0) {
+ if (dblink->makeDatabase(tszProfile, &err) == 0) {
dbCreated = true;
- if ( !dblink->Load(szProfile)) {
+ if ( !dblink->Load(tszProfile)) {
fillProfileName(tszProfile);
res = DBPE_DONE;
}
else res = DBPE_HALT;
}
- mir_free(szProfile);
}
return res;
}