summaryrefslogtreecommitdiff
path: root/src/modules
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
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')
-rw-r--r--src/modules/crypt/encrypt.cpp65
-rw-r--r--src/modules/database/database.cpp21
-rw-r--r--src/modules/database/profilemanager.cpp17
-rw-r--r--src/modules/utils/utils.cpp6
4 files changed, 84 insertions, 25 deletions
diff --git a/src/modules/crypt/encrypt.cpp b/src/modules/crypt/encrypt.cpp
new file mode 100644
index 0000000000..8880341c58
--- /dev/null
+++ b/src/modules/crypt/encrypt.cpp
@@ -0,0 +1,65 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "..\..\core\commonheaders.h"
+
+//VERY VERY VERY BASIC ENCRYPTION FUNCTION
+
+void Encrypt(char*msg,BOOL up)
+{
+ int i;
+ int jump;
+ if (up)
+ {
+ jump = 5;
+ }
+ else
+ {
+ jump = -5;
+ }
+
+ for (i = 0;msg[i];i++)
+ {
+ msg[i] = msg[i]+jump;
+ }
+
+}
+
+static INT_PTR EncodeString(WPARAM wParam,LPARAM lParam)
+{
+ Encrypt((char*)lParam,TRUE);
+ return 0;
+}
+
+static INT_PTR DecodeString(WPARAM wParam,LPARAM lParam)
+{
+ Encrypt((char*)lParam,FALSE);
+ return 0;
+}
+
+int InitCrypt(void)
+{
+ CreateServiceFunction(MS_DB_CRYPT_ENCODESTRING,EncodeString);
+ CreateServiceFunction(MS_DB_CRYPT_DECODESTRING,DecodeString);
+ return 0;
+}
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;
}
diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp
index 64941a9b85..9d553b333b 100644
--- a/src/modules/utils/utils.cpp
+++ b/src/modules/utils/utils.cpp
@@ -36,6 +36,7 @@ int InitBitmapFilter(void);
void InitXmlApi(void);
void InitTimeZones(void);
void UninitTimeZones(void);
+int InitCrypt(void);
static BOOL bModuleInitialized = FALSE;
@@ -471,6 +472,7 @@ int LoadUtilsModule(void)
CreateServiceFunction(MS_UTILS_GETCOUNTRYLIST, GetCountryList);
CreateServiceFunction(MS_UTILS_GETRANDOM, GenerateRandom);
CreateServiceFunction(MS_SYSTEM_RESTART, RestartMiranda);
+
InitOpenUrl();
InitWindowList();
InitHyperlink();
@@ -480,12 +482,14 @@ int LoadUtilsModule(void)
InitXmlApi();
InitJson();
InitTimeZones();
+ InitCrypt();
return 0;
}
void UnloadUtilsModule(void)
{
- if ( !bModuleInitialized) return;
+ if ( !bModuleInitialized)
+ return;
FreeWindowList();
UninitTimeZones();