summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/core/commonheaders.h1
-rw-r--r--src/core/miranda.h4
-rw-r--r--src/core/modules.cpp2
-rw-r--r--src/mir_core/commonheaders.h1
-rw-r--r--src/mir_core/db.cpp7
-rw-r--r--src/miranda32_10.vcxproj7
-rw-r--r--src/miranda32_10.vcxproj.filters18
-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
11 files changed, 121 insertions, 28 deletions
diff --git a/src/core/commonheaders.h b/src/core/commonheaders.h
index 13287d770a..ae6790a974 100644
--- a/src/core/commonheaders.h
+++ b/src/core/commonheaders.h
@@ -61,6 +61,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_core.h>
#include <newpluginapi.h>
#include <m_database.h>
+#include <m_db_int.h>
#include <m_clc.h>
#include <m_clui.h>
#include <m_crypto.h>
diff --git a/src/core/miranda.h b/src/core/miranda.h
index 8c3a3b1d20..00eab4fcae 100644
--- a/src/core/miranda.h
+++ b/src/core/miranda.h
@@ -108,6 +108,10 @@ extern LPFN_FREEADDRINFO MyFreeaddrinfo;
extern LPFN_WSASTRINGTOADDRESSA MyWSAStringToAddress;
extern LPFN_WSAADDRESSTOSTRINGA MyWSAAddressToString;
+/**** database.cpp *********************************************************************/
+
+extern MIDatabase* currDb;
+
/**** fontService.cpp ******************************************************************/
void KillModuleFonts(int hLangpack);
diff --git a/src/core/modules.cpp b/src/core/modules.cpp
index 423bd3471a..e44114cf96 100644
--- a/src/core/modules.cpp
+++ b/src/core/modules.cpp
@@ -41,6 +41,7 @@ int LoadLangpackModule(void); // core: translation
int LoadProtocolsModule(void); // core: protocol manager
int LoadAccountsModule(void); // core: account manager
int LoadIgnoreModule(void); // protocol filter: ignore
+int LoadDbintfModule(void);
int LoadContactListModule(void);// ui: clist
int LoadOptionsModule(void); // ui: options dialog
@@ -89,6 +90,7 @@ int LoadDefaultModules(void)
if ( LoadUtilsModule()) return 1; //order not important for this, but no dependencies and no point in pluginising
if ( LoadIcoTabsModule()) return 1;
if ( LoadHeaderbarModule()) return 1;
+ if ( LoadDbintfModule()) return 1;
if ( LoadNewPluginsModuleInfos()) return 1;
// database is available here
diff --git a/src/mir_core/commonheaders.h b/src/mir_core/commonheaders.h
index 2d04e12f4b..5afcda256e 100644
--- a/src/mir_core/commonheaders.h
+++ b/src/mir_core/commonheaders.h
@@ -55,6 +55,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_system.h>
#include <m_system_cpp.h>
#include <m_database.h>
+#include <m_db_int.h>
#include <newpluginapi.h>
#include "miranda.h"
diff --git a/src/mir_core/db.cpp b/src/mir_core/db.cpp
index af6a89537f..36902702ff 100644
--- a/src/mir_core/db.cpp
+++ b/src/mir_core/db.cpp
@@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
+static MIDatabase* currDb = NULL;
+
MIR_CORE_DLL(int) db_get_b(HANDLE hContact, const char *szModule, const char *szSetting, int errorValue)
{
DBVARIANT dbv;
@@ -202,3 +204,8 @@ MIR_CORE_DLL(INT_PTR) db_set_blob(HANDLE hContact, const char *szModule, const c
cws.value.pbVal = (unsigned char*)val;
return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws);
}
+
+MIR_CORE_DLL(void) db_setCurrent(MIDatabase* _db)
+{
+ currDb = _db;
+}
diff --git a/src/miranda32_10.vcxproj b/src/miranda32_10.vcxproj
index 5b817e1d8e..540be17025 100644
--- a/src/miranda32_10.vcxproj
+++ b/src/miranda32_10.vcxproj
@@ -220,6 +220,7 @@
<ClInclude Include="..\include\m_clui.h" />
<ClInclude Include="..\include\m_contacts.h" />
<ClInclude Include="..\include\m_database.h" />
+ <ClInclude Include="..\include\m_db_int.h" />
<ClInclude Include="..\include\m_email.h" />
<ClInclude Include="..\include\m_file.h" />
<ClInclude Include="..\include\m_findadd.h" />
@@ -290,12 +291,18 @@
<ClCompile Include="modules\button\button.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
+ <ClCompile Include="modules\crypt\encrypt.cpp">
+ <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
<ClCompile Include="modules\database\database.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="modules\database\dbini.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
+ <ClCompile Include="modules\database\dbintf.cpp">
+ <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
<ClCompile Include="modules\database\dbutils.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/src/miranda32_10.vcxproj.filters b/src/miranda32_10.vcxproj.filters
index 90c60ffac7..8be88946e7 100644
--- a/src/miranda32_10.vcxproj.filters
+++ b/src/miranda32_10.vcxproj.filters
@@ -67,6 +67,9 @@
<Filter Include="Modules\json">
<UniqueIdentifier>{8aad13dd-0e8d-4154-ad6f-913724b5a499}</UniqueIdentifier>
</Filter>
+ <Filter Include="Modules\crypt">
+ <UniqueIdentifier>{15d84b6a-4aa3-4cd5-93b3-2559709224ea}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\m_addcontact.h">
@@ -90,9 +93,6 @@
<ClInclude Include="..\include\m_contacts.h">
<Filter>SDK</Filter>
</ClInclude>
- <ClInclude Include="..\include\m_database.h">
- <Filter>SDK</Filter>
- </ClInclude>
<ClInclude Include="..\include\m_email.h">
<Filter>SDK</Filter>
</ClInclude>
@@ -270,6 +270,12 @@
<ClInclude Include="..\include\m_button.h">
<Filter>Modules\button</Filter>
</ClInclude>
+ <ClInclude Include="..\include\m_database.h">
+ <Filter>Modules\database</Filter>
+ </ClInclude>
+ <ClInclude Include="..\include\m_db_int.h">
+ <Filter>Modules\database</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="core\commonheaders.cpp">
@@ -563,6 +569,12 @@
<ClCompile Include="modules\plugins\dll_sniffer.cpp">
<Filter>Modules\plugins</Filter>
</ClCompile>
+ <ClCompile Include="modules\database\dbintf.cpp">
+ <Filter>Modules\database</Filter>
+ </ClCompile>
+ <ClCompile Include="modules\crypt\encrypt.cpp">
+ <Filter>Modules\crypt</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="res\_blank.ico">
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();