diff options
author | George Hazan <george.hazan@gmail.com> | 2016-09-14 18:01:49 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-09-14 18:01:49 +0000 |
commit | 7bdb598e26e7e98788933af43090d34027166969 (patch) | |
tree | 65c215c0693c86134e471f0746e9726b645b51bb /src/mir_core | |
parent | 9f285a935709f4dda1065d6450739476168c43af (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/mir_core')
-rw-r--r-- | src/mir_core/src/db.cpp | 76 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 9 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 9 |
3 files changed, 94 insertions, 0 deletions
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
|