summaryrefslogtreecommitdiff
path: root/src/modules/database
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
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')
-rw-r--r--src/modules/database/database.cpp21
-rw-r--r--src/modules/database/profilemanager.cpp17
2 files changed, 14 insertions, 24 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;
}
diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp
index 63e6cd1c4d..4e8ebc381f 100644
--- a/src/modules/database/profilemanager.cpp
+++ b/src/modules/database/profilemanager.cpp
@@ -119,13 +119,11 @@ static int FindDbProviders(const TCHAR* tszProfileName, DATABASELINK *dblink, LP
{
HWND hwndDlg = (HWND)lParam;
HWND hwndCombo = GetDlgItem(hwndDlg, IDC_PROFILEDRIVERS);
- char szName[64];
+ TCHAR szName[64];
if (dblink->getFriendlyName(szName, SIZEOF(szName), 1) == 0) {
// add to combo box
- TCHAR* p = Langpack_PcharToTchar(szName);
- LRESULT index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)p);
- mir_free(p);
+ LRESULT index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)szName);
SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)dblink);
}
return DBPE_CONT;
@@ -221,17 +219,12 @@ static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
static int DetectDbProvider(const TCHAR*, DATABASELINK * dblink, LPARAM lParam)
{
int error;
-
- char* fullpath = makeFileName((TCHAR*)lParam);
-
- int ret = dblink->grokHeader(fullpath, &error);
- mir_free(fullpath);
+ int ret = dblink->grokHeader((TCHAR*)lParam, &error);
if (ret == 0) {
- char tmp[ MAX_PATH ];
+ TCHAR tmp[ MAX_PATH ];
dblink->getFriendlyName(tmp, SIZEOF(tmp), 1);
- MultiByteToWideChar(CP_ACP, 0, tmp, -1, (TCHAR*)lParam, MAX_PATH);
-
+ _tcsncpy((TCHAR*)lParam, tmp, MAX_PATH);
return DBPE_HALT;
}