summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_db_int.h125
-rw-r--r--plugins/Db3x_mmap/dbintf.cpp36
-rw-r--r--plugins/Db3x_mmap/dbintf.h66
-rw-r--r--src/mir_core/db.cpp128
-rw-r--r--src/modules/database/dbintf.cpp198
5 files changed, 500 insertions, 53 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h
new file mode 100644
index 0000000000..f666ffcbd5
--- /dev/null
+++ b/include/m_db_int.h
@@ -0,0 +1,125 @@
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright 2012 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.
+*/
+
+#ifndef M_DB_INT_H__
+#define M_DB_INT_H__ 1
+
+#ifndef M_CORE_H__
+ #include <m_core.h>
+#endif
+
+interface MIDatabase
+{
+ STDMETHOD_(void,SetCacheSafetyMode)(BOOL) PURE;
+
+ STDMETHOD_(LONG,GetContactCount)(void) PURE;
+ STDMETHOD_(HANDLE,FindFirstContact)(const char* szProto = NULL) PURE;
+ STDMETHOD_(HANDLE,FindNextContact)(HANDLE hContact, const char* szProto = NULL) PURE;
+
+ STDMETHOD_(LONG,DeleteContact)(HANDLE hContact) PURE;
+ STDMETHOD_(HANDLE,AddContact)(void) PURE;
+ STDMETHOD_(BOOL,IsDbContact)(HANDLE hContact) PURE;
+
+ STDMETHOD_(LONG,GetEventCount)(HANDLE hContact) PURE;
+ STDMETHOD_(HANDLE,AddEvent)(HANDLE hContact, DBEVENTINFO *dbe) PURE;
+ STDMETHOD_(BOOL,DeleteEvent)(HANDLE hContact, HANDLE hDbEvent) PURE;
+ STDMETHOD_(LONG,GetBlobSize)(HANDLE hDbEvent) PURE;
+ STDMETHOD_(BOOL,GetEvent)(HANDLE hDbEvent, DBEVENTINFO *dbe) PURE;
+ STDMETHOD_(BOOL,MarkEventRead)(HANDLE hContact, HANDLE hDbEvent) PURE;
+ STDMETHOD_(HANDLE,GetEventContact)(HANDLE hDbEvent) PURE;
+ STDMETHOD_(HANDLE,FindFirstEvent)(HANDLE hContact) PURE;
+ STDMETHOD_(HANDLE,FindFirstUnreadEvent)(HANDLE hContact) PURE;
+ STDMETHOD_(HANDLE,FindLastEvent)(HANDLE hContact) PURE;
+ STDMETHOD_(HANDLE,FindNextEvent)(HANDLE hDbEvent) PURE;
+ STDMETHOD_(HANDLE,FindPrevEvent)(HANDLE hDbEvent) PURE;
+
+ STDMETHOD_(BOOL,EnumModuleNames)(DBMODULEENUMPROC pFunc, void *pParam) PURE;
+
+ STDMETHOD_(BOOL,GetContactSetting)(HANDLE hContact, DBCONTACTGETSETTING *dbcgs) PURE;
+ STDMETHOD_(BOOL,GetContactSettingStr)(HANDLE hContact, DBCONTACTGETSETTING *dbcgs) PURE;
+ STDMETHOD_(BOOL,GetContactSettingStatic)(HANDLE hContact, DBCONTACTGETSETTING *dbcgs) PURE;
+ STDMETHOD_(BOOL,FreeVariant)(DBVARIANT *dbv) PURE;
+ STDMETHOD_(BOOL,WriteContactSetting)(HANDLE hContact, DBCONTACTWRITESETTING *dbcws) PURE;
+ STDMETHOD_(BOOL,DeleteContactSetting)(HANDLE hContact, DBCONTACTGETSETTING *dbcgs) PURE;
+ STDMETHOD_(BOOL,EnumContactSettings)(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces) PURE;
+ STDMETHOD_(BOOL,SetSettingResident)(BOOL bIsResident, const char *pszSettingName) PURE;
+ STDMETHOD_(BOOL,EnumResidentSettings)(DBMODULEENUMPROC pFunc, void *pParam) PURE;
+};
+
+typedef struct {
+ int cbSize;
+
+ /*
+ returns what the driver can do given the flag
+ */
+ int (*getCapability) (int flag);
+
+ /*
+ buf: pointer to a string buffer
+ cch: length of buffer
+ shortName: if true, the driver should return a short but descriptive name, e.g. "3.xx profile"
+ Affect: The database plugin must return a "friendly name" into buf and not exceed cch bytes,
+ e.g. "Database driver for 3.xx profiles"
+ Returns: 0 on success, non zero on failure
+ */
+ int (*getFriendlyName) (TCHAR *buf, size_t cch, int shortName);
+
+ /*
+ profile: pointer to a string which contains full path + name
+ Affect: The database plugin should create the profile, the filepath will not exist at
+ the time of this call, profile will be C:\..\<name>.dat
+ Note: Do not prompt the user in anyway about this operation.
+ Note: Do not initialise internal data structures at this point!
+ Returns: 0 on success, non zero on failure - error contains extended error information, see EMKPRF_*
+ */
+ int (*makeDatabase) (TCHAR *profile, int * error);
+
+ /*
+ profile: [in] a null terminated string to file path of selected profile
+ error: [in/out] pointer to an int to set with error if any
+ Affect: Ask the database plugin if it supports the given profile, if it does it will
+ return 0, if it doesnt return 1, with the error set in error -- EGROKPRF_* can be valid error
+ condition, most common error would be [EGROKPRF_UNKHEADER]
+ Note: Just because 1 is returned, doesnt mean the profile is not supported, the profile might be damaged
+ etc.
+ Returns: 0 on success, non zero on failure
+ */
+ int (*grokHeader) (TCHAR *profile, int * error);
+
+ /*
+ Affect: Tell the database to create all services/hooks that a 3.xx legecy database might support into link,
+ which is a PLUGINLINK structure
+ Returns: 0 on success, nonzero on failure
+ */
+ MIDatabase* (*Load) (TCHAR *profile);
+
+ /*
+ Affect: The database plugin should shutdown, unloading things from the core and freeing internal structures
+ Returns: 0 on success, nonzero on failure
+ Note: Unload() might be called even if Load(void) was never called, wasLoaded is set to 1 if Load(void) was ever called.
+ */
+ int (*Unload) (int wasLoaded);
+
+} DATABASELINK;
+
+#endif // M_DB_INT_H__
diff --git a/plugins/Db3x_mmap/dbintf.cpp b/plugins/Db3x_mmap/dbintf.cpp
new file mode 100644
index 0000000000..c2074b3e84
--- /dev/null
+++ b/plugins/Db3x_mmap/dbintf.cpp
@@ -0,0 +1,36 @@
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright 2012 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 "commonheaders.h"
+
+CDdxMmap::CDdxMmap(const TCHAR* tszFileName)
+{
+}
+
+STDMETHODIMP_(void) CDdxMmap::SetCacheSafetyMode(BOOL bIsSet)
+{
+ { mir_cslock lck(csDbAccess);
+ safetyMode = bIsSet;
+ }
+ DBFlush(1);
+}
diff --git a/plugins/Db3x_mmap/dbintf.h b/plugins/Db3x_mmap/dbintf.h
new file mode 100644
index 0000000000..518d6b4e22
--- /dev/null
+++ b/plugins/Db3x_mmap/dbintf.h
@@ -0,0 +1,66 @@
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright 2012 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 <m_db_int.h>
+
+struct CDdxMmap : public MIDatabase
+{
+ CDdxMmap(const TCHAR* tszFileName);
+
+ STDMETHODIMP_(void) SetCacheSafetyMode(BOOL);
+
+ STDMETHODIMP_(LONG) GetContactCount(void);
+ STDMETHODIMP_(HANDLE) FindFirstContact(const char* szProto = NULL);
+ STDMETHODIMP_(HANDLE) FindNextContact(HANDLE hContact, const char* szProto = NULL);
+ STDMETHODIMP_(LONG) DeleteContact(HANDLE hContact);
+ STDMETHODIMP_(HANDLE) AddContact(void);
+ STDMETHODIMP_(BOOL) IsDbContact(HANDLE hContact);
+
+ STDMETHODIMP_(LONG) GetEventCount(HANDLE hContact);
+ STDMETHODIMP_(HANDLE) AddEvent(HANDLE hContact, DBEVENTINFO *dbe);
+ STDMETHODIMP_(BOOL) DeleteEvent(HANDLE hContact, HANDLE hDbEvent);
+ STDMETHODIMP_(LONG) GetBlobSize(HANDLE hDbEvent);
+ STDMETHODIMP_(BOOL) GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbe);
+ STDMETHODIMP_(BOOL) MarkEventRead(HANDLE hContact, HANDLE hDbEvent);
+ STDMETHODIMP_(HANDLE) GetEventContact(HANDLE hDbEvent);
+ STDMETHODIMP_(HANDLE) FindFirstEvent(HANDLE hContact);
+ STDMETHODIMP_(HANDLE) FindFirstUnreadEvent(HANDLE hContact);
+ STDMETHODIMP_(HANDLE) FindLastEvent(HANDLE hContact);
+ STDMETHODIMP_(HANDLE) FindNextEvent(HANDLE hDbEvent);
+ STDMETHODIMP_(HANDLE) FindPrevEvent(HANDLE hDbEvent);
+
+ STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam);
+
+ STDMETHODIMP_(BOOL) GetContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
+ STDMETHODIMP_(BOOL) GetContactSettingStr(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
+ STDMETHODIMP_(BOOL) GetContactSettingStatic(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
+ STDMETHODIMP_(BOOL) FreeVariant(DBVARIANT *dbv);
+ STDMETHODIMP_(BOOL) WriteContactSetting(HANDLE hContact, DBCONTACTWRITESETTING *dbcws);
+ STDMETHODIMP_(BOOL) DeleteContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs);
+ STDMETHODIMP_(BOOL) EnumContactSettings(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces);
+ STDMETHODIMP_(BOOL) SetSettingResident(BOOL bIsResident, const char *pszSettingName);
+ STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
+
+private:
+ int CheckProto(HANDLE hContact, const char *proto);
+};
diff --git a/src/mir_core/db.cpp b/src/mir_core/db.cpp
index 36902702ff..f18f288d33 100644
--- a/src/mir_core/db.cpp
+++ b/src/mir_core/db.cpp
@@ -27,71 +27,80 @@ static MIDatabase* currDb = NULL;
MIR_CORE_DLL(int) db_get_b(HANDLE hContact, const char *szModule, const char *szSetting, int errorValue)
{
- DBVARIANT dbv;
- DBCONTACTGETSETTING cgs;
- cgs.szModule = szModule;
- cgs.szSetting = szSetting;
- cgs.pValue = &dbv;
- if ( !CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&cgs))
- switch(dbv.type) {
- case DBVT_BYTE: return dbv.bVal;
- case DBVT_WORD: return BYTE(dbv.wVal);
- case DBVT_DWORD: return BYTE(dbv.dVal);
- }
+ if (currDb != NULL) {
+ DBVARIANT dbv;
+ DBCONTACTGETSETTING cgs;
+ cgs.szModule = szModule;
+ cgs.szSetting = szSetting;
+ cgs.pValue = &dbv;
+ if ( !currDb->GetContactSetting(hContact, &cgs))
+ switch(dbv.type) {
+ case DBVT_BYTE: return dbv.bVal;
+ case DBVT_WORD: return BYTE(dbv.wVal);
+ case DBVT_DWORD: return BYTE(dbv.dVal);
+ }
+ }
return errorValue;
}
MIR_CORE_DLL(int) db_get_w(HANDLE hContact, const char *szModule, const char *szSetting, int errorValue)
{
- DBVARIANT dbv;
- DBCONTACTGETSETTING cgs;
- cgs.szModule = szModule;
- cgs.szSetting = szSetting;
- cgs.pValue = &dbv;
- if ( !CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&cgs))
- switch(dbv.type) {
- case DBVT_BYTE: return dbv.bVal;
- case DBVT_WORD: return dbv.wVal;
- case DBVT_DWORD: return WORD(dbv.dVal);
- }
+ if (currDb != NULL) {
+ DBVARIANT dbv;
+ DBCONTACTGETSETTING cgs;
+ cgs.szModule = szModule;
+ cgs.szSetting = szSetting;
+ cgs.pValue = &dbv;
+ if ( !currDb->GetContactSetting(hContact, &cgs))
+ switch(dbv.type) {
+ case DBVT_BYTE: return dbv.bVal;
+ case DBVT_WORD: return dbv.wVal;
+ case DBVT_DWORD: return WORD(dbv.dVal);
+ }
+ }
return errorValue;
}
MIR_CORE_DLL(DWORD) db_get_dw(HANDLE hContact, const char *szModule, const char *szSetting, DWORD errorValue)
{
- DBVARIANT dbv;
- DBCONTACTGETSETTING cgs;
- cgs.szModule = szModule;
- cgs.szSetting = szSetting;
- cgs.pValue = &dbv;
- if ( !CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&cgs))
- switch(dbv.type) {
- case DBVT_BYTE: return dbv.bVal;
- case DBVT_WORD: return dbv.wVal;
- case DBVT_DWORD: return dbv.dVal;
- }
+ if (currDb != NULL) {
+ DBVARIANT dbv;
+ DBCONTACTGETSETTING cgs;
+ cgs.szModule = szModule;
+ cgs.szSetting = szSetting;
+ cgs.pValue = &dbv;
+ if ( !currDb->GetContactSetting(hContact, &cgs))
+ switch(dbv.type) {
+ case DBVT_BYTE: return dbv.bVal;
+ case DBVT_WORD: return dbv.wVal;
+ case DBVT_DWORD: return dbv.dVal;
+ }
+ }
return errorValue;
}
MIR_CORE_DLL(INT_PTR) db_get(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv)
{
+ if (currDb == NULL) return 1;
+
DBCONTACTGETSETTING cgs;
cgs.szModule = szModule;
cgs.szSetting = szSetting;
cgs.pValue = dbv;
-
- return CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&cgs);
+ return currDb->GetContactSetting(hContact, &cgs);
}
MIR_CORE_DLL(INT_PTR) db_get_s(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType)
{
+ if (currDb == NULL) return 1;
+
DBCONTACTGETSETTING cgs;
cgs.szModule = szModule;
cgs.szSetting = szSetting;
cgs.pValue = dbv;
dbv->type = (BYTE)nType;
- return CallService(MS_DB_CONTACT_GETSETTING_STR, (WPARAM)hContact, (LPARAM)&cgs);
+ return currDb->GetContactSettingStr(hContact, &cgs);
}
MIR_CORE_DLL(char*) db_get_sa(HANDLE hContact, const char *szModule, const char *szSetting)
@@ -101,7 +110,7 @@ MIR_CORE_DLL(char*) db_get_sa(HANDLE hContact, const char *szModule, const char
db_get_s(hContact, szModule, szSetting, &dbv, DBVT_ASCIIZ);
if (dbv.type == DBVT_ASCIIZ)
str = mir_strdup(dbv.pszVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
return str;
}
@@ -112,97 +121,110 @@ MIR_CORE_DLL(wchar_t*) db_get_wsa(HANDLE hContact, const char *szModule, const c
db_get_s(hContact, szModule, szSetting, &dbv, DBVT_WCHAR);
if (dbv.type == DBVT_WCHAR)
str = mir_wstrdup(dbv.pwszVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
return str;
}
MIR_CORE_DLL(INT_PTR) db_free(DBVARIANT *dbv)
{
- return CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)dbv);
+ if (currDb == NULL) return 1;
+
+ return currDb->FreeVariant(dbv);
}
MIR_CORE_DLL(INT_PTR) db_unset(HANDLE hContact, const char *szModule, const char *szSetting)
{
+ if (currDb == NULL) return 1;
+
DBCONTACTGETSETTING cgs;
cgs.szModule = szModule;
cgs.szSetting = szSetting;
- return CallService(MS_DB_CONTACT_DELETESETTING, (WPARAM)hContact, (LPARAM)&cgs);
+ return currDb->DeleteContactSetting(hContact, &cgs);
}
MIR_CORE_DLL(INT_PTR) db_set_b(HANDLE hContact, const char *szModule, const char *szSetting, BYTE val)
{
+ if (currDb == NULL) return 1;
+
DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
cws.szSetting = szSetting;
cws.value.type = DBVT_BYTE;
cws.value.bVal = val;
- return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws);
+ return currDb->WriteContactSetting(hContact, &cws);
}
MIR_CORE_DLL(INT_PTR) db_set_w(HANDLE hContact, const char *szModule, const char *szSetting, WORD val)
{
- DBCONTACTWRITESETTING cws;
+ if (currDb == NULL) return 1;
+ DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
cws.szSetting = szSetting;
cws.value.type = DBVT_WORD;
cws.value.wVal = val;
- return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws);
+ return currDb->WriteContactSetting(hContact, &cws);
}
MIR_CORE_DLL(INT_PTR) db_set_dw(HANDLE hContact, const char *szModule, const char *szSetting, DWORD val)
{
+ if (currDb == NULL) return 1;
+
DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
cws.szSetting = szSetting;
cws.value.type = DBVT_DWORD;
cws.value.dVal = val;
- return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws);
+ return currDb->WriteContactSetting(hContact, &cws);
}
MIR_CORE_DLL(INT_PTR) db_set_s(HANDLE hContact, const char *szModule, const char *szSetting, const char *val)
{
- DBCONTACTWRITESETTING cws;
+ if (currDb == NULL) return 1;
+ DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
cws.szSetting = szSetting;
cws.value.type = DBVT_ASCIIZ;
cws.value.pszVal = (char*)val;
- return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws);
+ return currDb->WriteContactSetting(hContact, &cws);
}
MIR_CORE_DLL(INT_PTR) db_set_ws(HANDLE hContact, const char *szModule, const char *szSetting, const WCHAR *val)
{
- DBCONTACTWRITESETTING cws;
+ if (currDb == NULL) return 1;
+ DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
cws.szSetting = szSetting;
cws.value.type = DBVT_WCHAR;
cws.value.pwszVal = (WCHAR*)val;
- return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws);
+ return currDb->WriteContactSetting(hContact, &cws);
}
MIR_CORE_DLL(INT_PTR) db_set_utf(HANDLE hContact, const char *szModule, const char *szSetting, const char *val)
{
- DBCONTACTWRITESETTING cws;
+ if (currDb == NULL) return 1;
+ DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
cws.szSetting = szSetting;
cws.value.type = DBVT_UTF8;
cws.value.pszVal = (char*)val;
- return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws);
+ return currDb->WriteContactSetting(hContact, &cws);
}
MIR_CORE_DLL(INT_PTR) db_set_blob(HANDLE hContact, const char *szModule, const char *szSetting, void *val, unsigned len)
{
- DBCONTACTWRITESETTING cws;
+ if (currDb == NULL) return 1;
+ DBCONTACTWRITESETTING cws;
cws.szModule = szModule;
cws.szSetting = szSetting;
cws.value.type = DBVT_BLOB;
- cws.value.cpbVal = (WORD)len;
+ cws.value.cpbVal = (WORD)len;
cws.value.pbVal = (unsigned char*)val;
- return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws);
+ return currDb->WriteContactSetting(hContact, &cws);
}
MIR_CORE_DLL(void) db_setCurrent(MIDatabase* _db)
diff --git a/src/modules/database/dbintf.cpp b/src/modules/database/dbintf.cpp
new file mode 100644
index 0000000000..c3bf4f3b5c
--- /dev/null
+++ b/src/modules/database/dbintf.cpp
@@ -0,0 +1,198 @@
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright 2012 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 "..\..\core\commonheaders.h"
+
+MIDatabase* currDb = 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;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Events
+
+static INT_PTR srvFindFirstContact(WPARAM, LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->FindFirstContact((LPCSTR)lParam) : 0;
+}
+
+static INT_PTR srvFindNextContact(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->FindNextContact((HANDLE)wParam, (LPCSTR)lParam) : 0;
+}
+
+static INT_PTR srvDeleteContact(WPARAM wParam, LPARAM)
+{ return (currDb) ? currDb->DeleteContact((HANDLE)wParam) : 0;
+}
+
+static INT_PTR srvAddContact(WPARAM wParam, LPARAM)
+{ return (currDb) ? (INT_PTR)currDb->AddContact() : 0;
+}
+
+static INT_PTR srvIsDbContact(WPARAM wParam, LPARAM)
+{ return (currDb) ? currDb->IsDbContact((HANDLE)wParam) : 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Events
+
+static INT_PTR srvGetEventCount(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? currDb->GetEventCount((HANDLE)wParam) : 0;
+}
+
+static INT_PTR srvAddEvent(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->AddEvent((HANDLE)wParam, (DBEVENTINFO*)lParam) : 0;
+}
+
+static INT_PTR srvDeleteEvent(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? currDb->DeleteEvent((HANDLE)wParam, (HANDLE)lParam) : 0;
+}
+
+static INT_PTR srvGetBlobSize(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? currDb->GetBlobSize((HANDLE)wParam) : 0;
+}
+
+static INT_PTR srvGetEvent(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->GetEvent((HANDLE)wParam, (DBEVENTINFO*)lParam) : 0;
+}
+
+static INT_PTR srvMarkEventRead(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? currDb->MarkEventRead((HANDLE)wParam, (HANDLE)lParam) : 0;
+}
+
+static INT_PTR srvGetEventContact(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->GetEventContact((HANDLE)wParam) : 0;
+}
+
+static INT_PTR srvFindFirstEvent(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->FindFirstEvent((HANDLE)wParam) : 0;
+}
+
+static INT_PTR srvFindFirstUnreadEvent(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->FindFirstUnreadEvent((HANDLE)wParam) : 0;
+}
+
+static INT_PTR srvFindLastEvent(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->FindLastEvent((HANDLE)wParam) : 0;
+}
+
+static INT_PTR srvFindNextEvent(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->FindNextEvent((HANDLE)wParam) : 0;
+}
+
+static INT_PTR srvFindPrevEvent(WPARAM wParam, LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->FindPrevEvent((HANDLE)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 srvGetContactSetting(WPARAM wParam,LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->GetContactSetting((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0;
+}
+
+static INT_PTR srvGetContactSettingStr(WPARAM wParam,LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->GetContactSettingStr((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0;
+}
+
+static INT_PTR srvGetContactSettingStatic(WPARAM wParam,LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->GetContactSettingStatic((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0;
+}
+
+static INT_PTR srvFreeVariant(WPARAM wParam,LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->FreeVariant((DBVARIANT*)lParam) : 0;
+}
+
+static INT_PTR srvWriteContactSetting(WPARAM wParam,LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->WriteContactSetting((HANDLE)wParam, (DBCONTACTWRITESETTING*)lParam) : 0;
+}
+
+static INT_PTR srvDeleteContactSetting(WPARAM wParam,LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->DeleteContactSetting((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0;
+}
+
+static INT_PTR srvEnumContactSettings(WPARAM wParam,LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->EnumContactSettings((HANDLE)wParam, (DBCONTACTENUMSETTINGS*)lParam) : 0;
+}
+
+static INT_PTR srvSetSettingResident(WPARAM wParam,LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->SetSettingResident(wParam, (char*)lParam) : 0;
+}
+
+static INT_PTR srvEnumResidentSettings(WPARAM wParam,LPARAM lParam)
+{ return (currDb) ? (INT_PTR)currDb->EnumResidentSettings((DBMODULEENUMPROC)wParam, (void*)lParam) : 0;
+}
+
+int LoadDbintfModule()
+{
+ CreateServiceFunction(MS_DB_SETSAFETYMODE, srvSetSafetyMode);
+
+ CreateServiceFunction(MS_DB_CONTACT_GETCOUNT, srvGetContactCount);
+ CreateServiceFunction(MS_DB_CONTACT_FINDFIRST, srvFindFirstContact);
+ CreateServiceFunction(MS_DB_CONTACT_FINDNEXT, srvFindNextContact);
+ CreateServiceFunction(MS_DB_CONTACT_DELETE, srvDeleteContact);
+ CreateServiceFunction(MS_DB_CONTACT_ADD, srvAddContact);
+ CreateServiceFunction(MS_DB_CONTACT_IS, srvIsDbContact);
+
+ CreateServiceFunction(MS_DB_EVENT_GETCOUNT, srvGetEventCount);
+ CreateServiceFunction(MS_DB_EVENT_ADD, srvAddEvent);
+ CreateServiceFunction(MS_DB_EVENT_DELETE, srvDeleteEvent);
+ CreateServiceFunction(MS_DB_EVENT_GETBLOBSIZE, srvGetBlobSize);
+ CreateServiceFunction(MS_DB_EVENT_GET, srvGetEvent);
+ CreateServiceFunction(MS_DB_EVENT_MARKREAD, srvMarkEventRead);
+ CreateServiceFunction(MS_DB_EVENT_GETCONTACT, srvGetEventContact);
+ CreateServiceFunction(MS_DB_EVENT_FINDFIRST, srvFindFirstEvent);
+ CreateServiceFunction(MS_DB_EVENT_FINDFIRSTUNREAD, srvFindFirstUnreadEvent);
+ CreateServiceFunction(MS_DB_EVENT_FINDLAST, srvFindLastEvent);
+ CreateServiceFunction(MS_DB_EVENT_FINDNEXT, srvFindNextEvent);
+ CreateServiceFunction(MS_DB_EVENT_FINDPREV, srvFindPrevEvent);
+
+ CreateServiceFunction(MS_DB_MODULES_ENUM, srvEnumModuleNames);
+
+ CreateServiceFunction(MS_DB_CONTACT_GETSETTING, srvGetContactSetting);
+ CreateServiceFunction(MS_DB_CONTACT_GETSETTING_STR, srvGetContactSettingStr);
+ CreateServiceFunction(MS_DB_CONTACT_GETSETTINGSTATIC, srvGetContactSettingStatic);
+ CreateServiceFunction(MS_DB_CONTACT_FREEVARIANT, srvFreeVariant);
+ CreateServiceFunction(MS_DB_CONTACT_WRITESETTING, srvWriteContactSetting);
+ CreateServiceFunction(MS_DB_CONTACT_DELETESETTING, srvDeleteContactSetting);
+ CreateServiceFunction(MS_DB_CONTACT_ENUMSETTINGS, srvEnumContactSettings);
+ CreateServiceFunction(MS_DB_SETSETTINGRESIDENT, srvSetSettingResident);
+ CreateServiceFunction("DB/ResidentSettings/Enum", srvEnumResidentSettings);
+ return 0;
+}