summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-09-14 18:01:49 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-09-14 18:01:49 +0000
commit7bdb598e26e7e98788933af43090d34027166969 (patch)
tree65c215c0693c86134e471f0746e9726b645b51bb /src
parent9f285a935709f4dda1065d6450739476168c43af (diff)
second major wipeout of database services & structures:
- DBCONTACTENUMSETTINGS removed; - all helpers moved to mir_core.dll git-svn-id: http://svn.miranda-ng.org/main/trunk@17296 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp2
-rw-r--r--src/mir_app/src/chat_clist.cpp2
-rw-r--r--src/mir_app/src/chat_manager.cpp2
-rw-r--r--src/mir_app/src/clc.cpp2
-rw-r--r--src/mir_app/src/clistmod.cpp4
-rw-r--r--src/mir_app/src/clui.cpp2
-rw-r--r--src/mir_app/src/database.cpp7
-rw-r--r--src/mir_app/src/db_events.cpp (renamed from src/mir_app/src/dbutils.cpp)26
-rw-r--r--src/mir_app/src/db_ini.cpp (renamed from src/mir_app/src/dbini.cpp)13
-rw-r--r--src/mir_app/src/db_intf.cpp98
-rw-r--r--src/mir_app/src/dbintf.cpp167
-rw-r--r--src/mir_app/src/ignore.cpp2
-rw-r--r--src/mir_app/src/menu_options.cpp2
-rw-r--r--src/mir_app/src/menu_utils.cpp2
-rw-r--r--src/mir_app/src/meta_menu.cpp6
-rw-r--r--src/mir_app/src/meta_services.cpp2
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/options_ei.cpp2
-rw-r--r--src/mir_app/src/proto_accs.cpp14
-rw-r--r--src/mir_core/src/db.cpp76
-rw-r--r--src/mir_core/src/mir_core.def9
-rw-r--r--src/mir_core/src/mir_core64.def9
23 files changed, 218 insertions, 234 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index e5309b928b..ad192efb95 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -1628,7 +1628,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
NotifyLocalWinEvent(dat->hContact, hwndDlg, MSG_WINDOW_EVT_CLOSE);
if (dat->hContact && db_get_b(NULL, SRMMMOD, SRMSGSET_DELTEMP, SRMSGDEFSET_DELTEMP))
if (db_get_b(dat->hContact, "CList", "NotOnList", 0))
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)dat->hContact, 0);
+ db_delete_contact(dat->hContact);
Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD);
Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS);
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp
index 859c93e59a..d371083f5f 100644
--- a/src/mir_app/src/chat_clist.cpp
+++ b/src/mir_app/src/chat_clist.cpp
@@ -54,7 +54,7 @@ MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *p
}
// here we create a new one since no one is to be found
- if ((hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0)) == NULL)
+ if ((hContact = db_add_contact()) == NULL)
return NULL;
Proto_AddToContact(hContact, pszModule);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index 83044f9d79..3ec71e4886 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -137,7 +137,7 @@ static int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL re
// contact may have been deleted here already, since function may be called after deleting
// contact so the handle may be invalid, therefore db_get_b shall return 0
if (pTemp->hContact && removeContact)
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)pTemp->hContact, 0);
+ db_delete_contact(pTemp->hContact);
SM_FreeSession(pTemp);
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp
index f0f947ad0f..0af50af530 100644
--- a/src/mir_app/src/clc.cpp
+++ b/src/mir_app/src/clc.cpp
@@ -495,7 +495,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam
contact = NULL;
group = NULL;
if (!cli.pfnFindItem(hwnd, dat, wParam, &contact, &group, NULL)) {
- if (shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) {
+ if (shouldShow && db_is_contact(wParam)) {
if (dat->selection >= 0 && cli.pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1)
hSelItem = Clist_ContactToHItem(selcontact);
cli.pfnAddContactToTree(hwnd, dat, wParam, (style & CLS_CONTACTLIST) == 0, 0);
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp
index b74a591854..2255ed5ff7 100644
--- a/src/mir_app/src/clistmod.cpp
+++ b/src/mir_app/src/clistmod.cpp
@@ -125,7 +125,7 @@ static int ProtocolAck(WPARAM, LPARAM lParam)
for (MCONTACT hContact = db_find_first(ack->szModule); hContact; ) {
MCONTACT hNext = db_find_next(hContact, ack->szModule);
if (db_get_b(hContact, "CList", "Delete", 0))
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
hContact = hNext;
}
}
@@ -453,7 +453,7 @@ void UnloadContactListModule()
for (MCONTACT hContact = db_find_first(); hContact != NULL; ) {
MCONTACT hNext = db_find_next(hContact);
if (db_get_b(hContact, "CList", "NotOnList", 0))
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
hContact = hNext;
}
ImageList_Destroy(hCListImages);
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp
index c679c6a15f..873caf139f 100644
--- a/src/mir_app/src/clui.cpp
+++ b/src/mir_app/src/clui.cpp
@@ -195,7 +195,7 @@ static INT_PTR MenuItem_DeleteContact(WPARAM wParam, LPARAM lParam)
}
}
- CallService(MS_DB_CONTACT_DELETE, wParam, 0);
+ db_delete_contact(wParam);
break;
}
diff --git a/src/mir_app/src/database.cpp b/src/mir_app/src/database.cpp
index 420e442f15..70db2791ef 100644
--- a/src/mir_app/src/database.cpp
+++ b/src/mir_app/src/database.cpp
@@ -25,14 +25,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "profilemanager.h"
+MIDatabase *currDb = NULL;
+DATABASELINK *currDblink = NULL;
+
// contains the location of mirandaboot.ini
bool g_bDbCreated;
wchar_t g_profileDir[MAX_PATH], g_profileName[MAX_PATH], g_shortProfileName[MAX_PATH];
wchar_t* g_defaultProfile;
void EnsureCheckerLoaded(bool);
-void LoadDatabaseServices();
-
bool fileExist(const wchar_t *fname)
{
if (*fname == 0)
@@ -486,8 +487,6 @@ int LoadDatabaseModule(void)
_tchdir(szProfile);
szProfile[0] = 0;
- LoadDatabaseServices();
-
// find out which profile to load
if (!getProfile(szProfile, _countof(szProfile)))
return 1;
diff --git a/src/mir_app/src/dbutils.cpp b/src/mir_app/src/db_events.cpp
index 155851a2e5..bc3fb4d470 100644
--- a/src/mir_app/src/dbutils.cpp
+++ b/src/mir_app/src/db_events.cpp
@@ -268,32 +268,6 @@ MIR_APP_DLL(wchar_t*) DbEvent_GetString(DBEVENTINFO *dbei, const char *str)
/////////////////////////////////////////////////////////////////////////////////////////
-static int sttEnumVars(const char *szVarName, LPARAM lParam)
-{
- LIST<char>* vars = (LIST<char>*)lParam;
- vars->insert(mir_strdup(szVarName));
- return 0;
-}
-
-MIR_APP_DLL(int) DbModule_Delete(MCONTACT hContact, const char *szModuleName)
-{
- LIST<char> vars(20);
-
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = sttEnumVars;
- dbces.lParam = (LPARAM)&vars;
- dbces.szModule = (char*)szModuleName;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces);
-
- for (int i = vars.getCount()-1; i >= 0; i--) {
- db_unset(hContact, szModuleName, vars[i]);
- mir_free(vars[i]);
- }
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
MIR_APP_DLL(int) Profile_GetPathA(size_t cbLen, char *pszDest)
{
if (!pszDest || !cbLen)
diff --git a/src/mir_app/src/dbini.cpp b/src/mir_app/src/db_ini.cpp
index 8239b448e2..b33095de6c 100644
--- a/src/mir_app/src/dbini.cpp
+++ b/src/mir_app/src/db_ini.cpp
@@ -361,12 +361,8 @@ LBL_NewLine:
if (secFN) warnThisSection = 0;
}
if (szLine[1] == '?') {
- DBCONTACTENUMSETTINGS dbces;
- dbces.pfnEnumProc = SettingsEnumProc;
mir_strncpy(szSection, szLine + 2, min(sizeof(szSection), (int)(szEnd - szLine - 1)));
- dbces.szModule = szSection;
- dbces.ofsSettings = 0;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+ db_enum_settings(NULL, SettingsEnumProc, szSection);
while (setting_items) {
SettingsList *next = setting_items->next;
@@ -428,11 +424,8 @@ LBL_NewLine:
if (szValue[1] == '*') {
LIST<char> arSettings(1);
ESFDParam param = { &arSettings, szName };
- DBCONTACTENUMSETTINGS dbep = {};
- dbep.pfnEnumProc = EnumSettingsForDeletion;
- dbep.szModule = szSection;
- dbep.lParam = (LPARAM)&param;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, LPARAM(&dbep));
+ db_enum_settings(NULL, EnumSettingsForDeletion, szSection, &param);
+
while (arSettings.getCount()) {
db_unset(NULL, szSection, arSettings[0]);
mir_free(arSettings[0]);
diff --git a/src/mir_app/src/db_intf.cpp b/src/mir_app/src/db_intf.cpp
new file mode 100644
index 0000000000..eaab4d9e9b
--- /dev/null
+++ b/src/mir_app/src/db_intf.cpp
@@ -0,0 +1,98 @@
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright (C) 2012-16 Miranda NG 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 "stdafx.h"
+#include "database.h"
+
+///////////////////////////////////////////////////////////////////////////////
+// Database list
+
+LIST<DATABASELINK> arDbPlugins(5);
+
+static INT_PTR srvRegisterPlugin(WPARAM, LPARAM lParam)
+{
+ DATABASELINK* pPlug = (DATABASELINK*)lParam;
+ if (pPlug == NULL)
+ return 1;
+
+ arDbPlugins.insert(pPlug);
+ return 0;
+}
+
+static INT_PTR srvFindPlugin(WPARAM, LPARAM lParam)
+{
+ for (int i = arDbPlugins.getCount() - 1; i >= 0; i--) {
+ int error = arDbPlugins[i]->grokHeader((wchar_t*)lParam);
+ if (error == ERROR_SUCCESS || error == EGROKPRF_OBSOLETE)
+ return (INT_PTR)arDbPlugins[i];
+ }
+
+ return NULL;
+}
+
+static INT_PTR srvGetCurrentDb(WPARAM, LPARAM)
+{
+ return (INT_PTR)currDb;
+}
+
+static INT_PTR srvInitInstance(WPARAM, LPARAM lParam)
+{
+ MIDatabase *pDb = (MIDatabase*)lParam;
+ if (pDb != NULL)
+ pDb->m_cache = new MDatabaseCache(pDb->GetContactSize());
+ return 0;
+}
+
+static INT_PTR srvDestroyInstance(WPARAM, LPARAM lParam)
+{
+ MIDatabase *pDb = (MIDatabase*)lParam;
+ if (pDb != NULL) {
+ MDatabaseCache *pCache = (MDatabaseCache*)pDb->m_cache;
+ pDb->m_cache = NULL;
+ delete pCache;
+ }
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+int LoadDbintfModule()
+{
+ CreateServiceFunction(MS_DB_REGISTER_PLUGIN, srvRegisterPlugin);
+ CreateServiceFunction(MS_DB_FIND_PLUGIN, srvFindPlugin);
+ CreateServiceFunction(MS_DB_GET_CURRENT, srvGetCurrentDb);
+
+ CreateServiceFunction(MS_DB_INIT_INSTANCE, srvInitInstance);
+ CreateServiceFunction(MS_DB_DESTROY_INSTANCE, srvDestroyInstance);
+
+ // create events once, they will be inherited by all database plugins
+ CreateHookableEvent(ME_DB_CONTACT_DELETED);
+ CreateHookableEvent(ME_DB_CONTACT_ADDED);
+ CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
+ CreateHookableEvent(ME_DB_EVENT_MARKED_READ);
+
+ CreateHookableEvent(ME_DB_EVENT_ADDED);
+ CreateHookableEvent(ME_DB_EVENT_DELETED);
+ CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
+ return 0;
+}
diff --git a/src/mir_app/src/dbintf.cpp b/src/mir_app/src/dbintf.cpp
deleted file mode 100644
index ffa510f9e9..0000000000
--- a/src/mir_app/src/dbintf.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (C) 2012-16 Miranda NG 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 "stdafx.h"
-#include "database.h"
-
-MIDatabase *currDb = NULL;
-DATABASELINK *currDblink = NULL;
-
-MIR_CORE_DLL(void) db_setCurrent(MIDatabase*);
-
-static INT_PTR srvSetSafetyMode(WPARAM wParam, LPARAM)
-{
- if (!currDb) return 1;
-
- currDb->SetCacheSafetyMode(wParam != 0);
- return 0;
-}
-
-static INT_PTR srvGetContactCount(WPARAM, LPARAM)
-{
- return (currDb) ? currDb->GetContactCount() : 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Contacts
-
-static INT_PTR srvDeleteContact(WPARAM wParam, LPARAM)
-{
- DBVARIANT dbv = { 0 };
- if (!db_get_ws(wParam, "ContactPhoto", "File", &dbv)) {
- DeleteFile(dbv.ptszVal);
- db_free(&dbv);
- }
- return (currDb) ? currDb->DeleteContact(wParam) : 0;
-}
-
-static INT_PTR srvAddContact(WPARAM, LPARAM)
-{
- MCONTACT hNew = (currDb) ? currDb->AddContact() : 0;
- Netlib_Logf(NULL, "New contact created: %d", hNew);
- return hNew;
-}
-
-static INT_PTR srvIsDbContact(WPARAM wParam, LPARAM)
-{
- return (currDb) ? currDb->IsDbContact(wParam) : 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Module chain
-
-static INT_PTR srvEnumModuleNames(WPARAM wParam, LPARAM lParam)
-{
- return (currDb) ? (INT_PTR)currDb->EnumModuleNames((DBMODULEENUMPROC)lParam, (void*)wParam) : 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Settings
-
-static INT_PTR srvEnumContactSettings(WPARAM wParam, LPARAM lParam)
-{
- return (currDb) ? (INT_PTR)currDb->EnumContactSettings(wParam, (DBCONTACTENUMSETTINGS*)lParam) : 0;
-}
-
-static INT_PTR srvEnumResidentSettings(WPARAM wParam, LPARAM lParam)
-{
- return (currDb) ? (INT_PTR)currDb->EnumResidentSettings((DBMODULEENUMPROC)wParam, (void*)lParam) : 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Database list
-
-LIST<DATABASELINK> arDbPlugins(5);
-
-static INT_PTR srvRegisterPlugin(WPARAM, LPARAM lParam)
-{
- DATABASELINK* pPlug = (DATABASELINK*)lParam;
- if (pPlug == NULL)
- return 1;
-
- arDbPlugins.insert(pPlug);
- return 0;
-}
-
-static INT_PTR srvFindPlugin(WPARAM, LPARAM lParam)
-{
- for (int i = arDbPlugins.getCount() - 1; i >= 0; i--) {
- int error = arDbPlugins[i]->grokHeader((wchar_t*)lParam);
- if (error == ERROR_SUCCESS || error == EGROKPRF_OBSOLETE)
- return (INT_PTR)arDbPlugins[i];
- }
-
- return NULL;
-}
-
-static INT_PTR srvGetCurrentDb(WPARAM, LPARAM)
-{
- return (INT_PTR)currDb;
-}
-
-static INT_PTR srvInitInstance(WPARAM, LPARAM lParam)
-{
- MIDatabase* pDb = (MIDatabase*)lParam;
- if (pDb != NULL)
- pDb->m_cache = new MDatabaseCache(pDb->GetContactSize());
- return 0;
-}
-
-static INT_PTR srvDestroyInstance(WPARAM, LPARAM lParam)
-{
- MIDatabase* pDb = (MIDatabase*)lParam;
- if (pDb != NULL) {
- MDatabaseCache *pCache = (MDatabaseCache*)pDb->m_cache;
- pDb->m_cache = NULL;
- delete pCache;
- }
- return 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-int LoadDbintfModule()
-{
- CreateServiceFunction(MS_DB_CONTACT_GETCOUNT, srvGetContactCount);
- CreateServiceFunction(MS_DB_CONTACT_DELETE, srvDeleteContact);
- CreateServiceFunction(MS_DB_CONTACT_ADD, srvAddContact);
- CreateServiceFunction(MS_DB_CONTACT_IS, srvIsDbContact);
-
- CreateServiceFunction(MS_DB_MODULES_ENUM, srvEnumModuleNames);
-
- CreateServiceFunction(MS_DB_CONTACT_ENUMSETTINGS, srvEnumContactSettings);
- CreateServiceFunction("DB/ResidentSettings/Enum", srvEnumResidentSettings);
-
- CreateServiceFunction(MS_DB_REGISTER_PLUGIN, srvRegisterPlugin);
- CreateServiceFunction(MS_DB_FIND_PLUGIN, srvFindPlugin);
- CreateServiceFunction(MS_DB_GET_CURRENT, srvGetCurrentDb);
-
- CreateServiceFunction(MS_DB_INIT_INSTANCE, srvInitInstance);
- CreateServiceFunction(MS_DB_DESTROY_INSTANCE, srvDestroyInstance);
- return 0;
-}
-
-void LoadDatabaseServices()
-{
- CreateServiceFunction(MS_DB_SETSAFETYMODE, srvSetSafetyMode);
-}
diff --git a/src/mir_app/src/ignore.cpp b/src/mir_app/src/ignore.cpp
index 4ea32d150c..3a5baf7905 100644
--- a/src/mir_app/src/ignore.cpp
+++ b/src/mir_app/src/ignore.cpp
@@ -409,7 +409,7 @@ static int IgnoreAddedNotify(WPARAM, LPARAM lParam)
DBEVENTINFO *dbei = (DBEVENTINFO*)lParam;
if (dbei && dbei->eventType == EVENTTYPE_ADDED && dbei->pBlob != NULL) {
MCONTACT hContact = DbGetAuthEventContact(dbei);
- if (CallService(MS_DB_CONTACT_IS, hContact, 0) && IsIgnored(hContact, IGNOREEVENT_YOUWEREADDED))
+ if (db_is_contact(hContact) && IsIgnored(hContact, IGNOREEVENT_YOUWEREADDED))
return 1;
}
return 0;
diff --git a/src/mir_app/src/menu_options.cpp b/src/mir_app/src/menu_options.cpp
index 5a9a88b60c..7863b338c0 100644
--- a/src/mir_app/src/menu_options.cpp
+++ b/src/mir_app/src/menu_options.cpp
@@ -130,7 +130,7 @@ class CGenMenuOptionsPage : public CDlgBase
char szModule[256];
mir_snprintf(szModule, "%s_Items", pmo->pszName);
- DbModule_Delete(NULL, szModule);
+ db_delete_module(NULL, szModule);
SaveTreeInternal(NULL, m_menuItems.GetRoot(), szModule);
db_set_b(NULL, szModule, "MenuFormat", 1);
}
diff --git a/src/mir_app/src/menu_utils.cpp b/src/mir_app/src/menu_utils.cpp
index c714f06418..2b2f07e35d 100644
--- a/src/mir_app/src/menu_utils.cpp
+++ b/src/mir_app/src/menu_utils.cpp
@@ -935,7 +935,7 @@ static INT_PTR sttUpdateMenuService(WPARAM wParam, LPARAM)
MO_RecursiveWalkMenu(pmo->m_items.first, sttReadOldItem, szModule);
// wipe out old trash, write new data & compatibility flag
- DbModule_Delete(NULL, szModule);
+ db_delete_module(NULL, szModule);
db_set_b(NULL, szModule, "MenuFormat", true);
MO_RecursiveWalkMenu(pmo->m_items.first, sttDumpItem, szModule);
}
diff --git a/src/mir_app/src/meta_menu.cpp b/src/mir_app/src/meta_menu.cpp
index cac1b4bdb2..674b55a9cd 100644
--- a/src/mir_app/src/meta_menu.cpp
+++ b/src/mir_app/src/meta_menu.cpp
@@ -52,7 +52,7 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM)
ptrW tszGroup(db_get_wsa(wParam, "CList", "Group"));
// Create a new metacontact
- MCONTACT hMetaContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ MCONTACT hMetaContact = db_add_contact();
if (hMetaContact == NULL)
return NULL;
@@ -73,7 +73,7 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM)
// Assign the contact to the MetaContact just created (and make default).
if (!Meta_Assign(wParam, hMetaContact, TRUE)) {
MessageBox(0, TranslateT("There was a problem in assigning the contact to the metacontact"), TranslateT("Error"), MB_ICONEXCLAMATION);
- CallService(MS_DB_CONTACT_DELETE, hMetaContact, 0);
+ db_delete_contact(hMetaContact);
return 0;
}
@@ -200,7 +200,7 @@ INT_PTR Meta_Delete(WPARAM hContact, LPARAM bSkipQuestion)
Meta_RemoveContactNumber(cc, i, false);
NotifyEventHooks(hSubcontactsChanged, hContact, 0);
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
}
else if (cc->IsSub()) {
if ((cc = currDb->m_cache->GetCachedContact(cc->parentID)) == NULL)
diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp
index 7a862f79df..37b23f355c 100644
--- a/src/mir_app/src/meta_services.cpp
+++ b/src/mir_app/src/meta_services.cpp
@@ -473,7 +473,7 @@ int Meta_ContactDeleted(WPARAM hContact, LPARAM)
// no more subs? remove the meta itself
if (ccMeta->nSubs == 0)
- CallService(MS_DB_CONTACT_DELETE, ccMeta->contactID, 0);
+ db_delete_contact(ccMeta->contactID);
}
return 0;
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index dfc1f380b4..d4755280f1 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -286,9 +286,9 @@ DbEvent_GetTextA @285
DbEvent_GetTextW @286
DbEvent_GetType @287
DbEvent_RegisterType @288
-DbModule_Delete @289
Profile_GetNameA @290
Profile_GetNameW @291
Profile_GetPathA @292
Profile_GetPathW @293
Profile_SetDefault @294
+DbModule_Delete @295 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 309b40d02d..db6e5def22 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -286,7 +286,6 @@ DbEvent_GetTextA @285
DbEvent_GetTextW @286
DbEvent_GetType @287
DbEvent_RegisterType @288
-DbModule_Delete @289
Profile_GetNameA @290
Profile_GetNameW @291
Profile_GetPathA @292
diff --git a/src/mir_app/src/options_ei.cpp b/src/mir_app/src/options_ei.cpp
index d38dc19f6a..f9e11d7268 100644
--- a/src/mir_app/src/options_ei.cpp
+++ b/src/mir_app/src/options_ei.cpp
@@ -372,7 +372,7 @@ public:
db_set_w(NULL, MODULE_NAME, setting, extra->getSlot());
}
- DbModule_Delete(NULL, MODULE_NAME "Groups");
+ db_delete_module(NULL, MODULE_NAME "Groups");
db_set_w(NULL, MODULE_NAME "Groups", "Count", groups.getCount());
for (int k = 0; k < groups.getCount(); k++) {
ExtraIconGroup *group = groups[k];
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp
index 5c8edc3d13..d6d5e7ec68 100644
--- a/src/mir_app/src/proto_accs.cpp
+++ b/src/mir_app/src/proto_accs.cpp
@@ -114,7 +114,7 @@ void LoadDbAccounts(void)
WriteDbAccounts();
int anum = accounts.getCount();
- CallService(MS_DB_MODULES_ENUM, 0, (LPARAM)EnumDbModules);
+ db_enum_modules(EnumDbModules);
if (anum != accounts.getCount())
WriteDbAccounts();
}
@@ -144,13 +144,7 @@ void WriteDbAccounts()
{
// enum all old settings to delete
enumDB_ProtoProcParam param = { 0, NULL };
-
- DBCONTACTENUMSETTINGS dbces;
- dbces.pfnEnumProc = enumDB_ProtoProc;
- dbces.szModule = "Protocols";
- dbces.ofsSettings = 0;
- dbces.lParam = (LPARAM)&param;
- CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
+ db_enum_settings(NULL, enumDB_ProtoProc, "Protocols", &param);
// delete all settings
if (param.arrlen) {
@@ -383,12 +377,12 @@ void EraseAccount(const char *pszModuleName)
// remove protocol contacts first
for (MCONTACT hContact = db_find_first(pszModuleName); hContact != NULL;) {
MCONTACT hNext = db_find_next(hContact, pszModuleName);
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ db_delete_contact(hContact);
hContact = hNext;
}
// remove all protocol settings
- DbModule_Delete(NULL, pszModuleName);
+ db_delete_module(NULL, pszModuleName);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp
index 8bac3b89bb..051ce6a32e 100644
--- a/src/mir_core/src/db.cpp
+++ b/src/mir_core/src/db.cpp
@@ -27,6 +27,82 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
MIDatabase *currDb = NULL;
/////////////////////////////////////////////////////////////////////////////////////////
+// database functions
+
+MIR_CORE_DLL(void) db_set_safety_mode(BOOL bNewMode)
+{
+ if (currDb)
+ currDb->SetCacheSafetyMode(bNewMode != 0);
+}
+
+MIR_CORE_DLL(int) db_get_contact_count(void)
+{
+ return (currDb) ? currDb->GetContactCount() : 0;
+}
+
+static int sttEnumVars(const char *szVarName, LPARAM lParam)
+{
+ LIST<char>* vars = (LIST<char>*)lParam;
+ vars->insert(mir_strdup(szVarName));
+ return 0;
+}
+
+MIR_CORE_DLL(int) db_delete_module(MCONTACT hContact, const char *szModuleName)
+{
+ LIST<char> vars(20);
+ db_enum_settings(hContact, sttEnumVars, szModuleName, &vars);
+
+ for (int i = vars.getCount() - 1; i >= 0; i--) {
+ db_unset(hContact, szModuleName, vars[i]);
+ mir_free(vars[i]);
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// contact functions
+
+MIR_CORE_DLL(MCONTACT) db_add_contact(void)
+{
+ MCONTACT hNew = (currDb) ? currDb->AddContact() : 0;
+ Netlib_Logf(NULL, "New contact created: %d", hNew);
+ return hNew;
+}
+
+MIR_CORE_DLL(int) db_delete_contact(MCONTACT hContact)
+{
+ ptrW wszPhoto(db_get_wsa(hContact, "ContactPhoto", "File"));
+ if (wszPhoto != NULL)
+ DeleteFile(wszPhoto);
+
+ Netlib_Logf(NULL, "Contact deleted: %d", hContact);
+ return (currDb) ? currDb->DeleteContact(hContact) : 0;
+}
+
+MIR_CORE_DLL(int) db_is_contact(MCONTACT hContact)
+{
+ return (currDb) ? currDb->IsDbContact(hContact) : 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// enumerators
+
+MIR_CORE_DLL(int) db_enum_modules(DBMODULEENUMPROC pFunc, const void *param)
+{
+ return (currDb) ? currDb->EnumModuleNames(pFunc, param) : 0;
+}
+
+MIR_CORE_DLL(int) db_enum_residents(DBMODULEENUMPROC pFunc, const void *param)
+{
+ return (currDb) ? currDb->EnumResidentSettings(pFunc, param) : 0;
+}
+
+EXTERN_C MIR_CORE_DLL(int) db_enum_settings(MCONTACT hContact, DBSETTINGENUMPROC pFunc, const char *szModule, const void *param)
+{
+ return (currDb) ? currDb->EnumContactSettings(hContact, pFunc, szModule, param) : 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// getting data
MIR_CORE_DLL(int) db_get_b(MCONTACT hContact, const char *szModule, const char *szSetting, int errorValue)
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 3c214307b8..6e1e032d92 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -993,3 +993,12 @@ hex2bin @1149
hex2binW @1150
mir_hmac_sha256 @1151
Utf8toUcs2 @1152
+db_add_contact @1153
+db_delete_contact @1154
+db_enum_modules @1155
+db_enum_residents @1156
+db_enum_settings @1157
+db_get_contact_count @1158
+db_is_contact @1159
+db_set_safety_mode @1160
+db_delete_module @1161
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index e988dcc60b..6e493bb0e9 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -993,3 +993,12 @@ hex2bin @1149
hex2binW @1150
mir_hmac_sha256 @1151
Utf8toUcs2 @1152
+db_add_contact @1153
+db_delete_contact @1154
+db_enum_modules @1155
+db_enum_residents @1156
+db_enum_settings @1157
+db_get_contact_count @1158
+db_is_contact @1159
+db_set_safety_mode @1160
+db_delete_module @1161