diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-20 15:56:25 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-20 15:56:25 +0000 |
commit | bfe1bd0fc087be44c70904aee0fe4276643d206d (patch) | |
tree | d5376d7cab1f6e5084a1449dc341c325b6cee45c /src/modules/database/dbintf.cpp | |
parent | 8593e7594773c30b35488bb6a45fcc782ed5df0c (diff) |
- db3x_mmap is completely moved to a class;
- the old nightmare in the core "How to detect a db plugin and load it" is eliminated forever;
- databases are the usual plugins now (loadable via Load)
- dynamic DATABASELINK registration
git-svn-id: http://svn.miranda-ng.org/main/trunk@1082 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/database/dbintf.cpp')
-rw-r--r-- | src/modules/database/dbintf.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/modules/database/dbintf.cpp b/src/modules/database/dbintf.cpp index c3bf4f3b5c..2f7cf4ea72 100644 --- a/src/modules/database/dbintf.cpp +++ b/src/modules/database/dbintf.cpp @@ -23,7 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h"
-MIDatabase* currDb = NULL;
+MIDatabase *currDb = NULL;
+DATABASELINK *currDblink = NULL;
MIR_CORE_DLL(void) db_setCurrent(MIDatabase*);
@@ -159,6 +160,34 @@ 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 wParam,LPARAM lParam)
+{
+ DATABASELINK* pPlug = (DATABASELINK*)lParam;
+ if (pPlug == NULL)
+ return 1;
+
+ arDbPlugins.insert(pPlug);
+ return 0;
+}
+
+static INT_PTR srvFindPlugin(WPARAM wParam,LPARAM lParam)
+{
+ for (int i=0; i < arDbPlugins.getCount(); i++) {
+ int error;
+ if (arDbPlugins[i]->grokHeader((TCHAR*)lParam, &error) == ERROR_SUCCESS)
+ return (INT_PTR)arDbPlugins[i];
+ }
+
+ return NULL;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
int LoadDbintfModule()
{
CreateServiceFunction(MS_DB_SETSAFETYMODE, srvSetSafetyMode);
@@ -194,5 +223,8 @@ int LoadDbintfModule() CreateServiceFunction(MS_DB_CONTACT_ENUMSETTINGS, srvEnumContactSettings);
CreateServiceFunction(MS_DB_SETSETTINGRESIDENT, srvSetSettingResident);
CreateServiceFunction("DB/ResidentSettings/Enum", srvEnumResidentSettings);
+
+ CreateServiceFunction(MS_DB_REGISTER_PLUGIN, srvRegisterPlugin);
+ CreateServiceFunction(MS_DB_FIND_PLUGIN, srvFindPlugin);
return 0;
}
|