From a43d5bcb1e0bdafb0193662168976aac989ed922 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 9 Feb 2022 17:40:09 +0300 Subject: db_is_module_empty & db_copy_module - new database helpers --- .../UserInfoEx/src/ex_import/dlg_ExImModules.cpp | 4 ++-- plugins/UserInfoEx/src/mir_db.cpp | 28 ---------------------- plugins/UserInfoEx/src/mir_db.h | 2 -- plugins/UserInfoEx/src/psp_options.cpp | 8 +++---- 4 files changed, 6 insertions(+), 36 deletions(-) (limited to 'plugins/UserInfoEx/src') diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp index 46abcece72..666fd84b78 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp @@ -274,7 +274,7 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar { for (auto &hContact: Contacts()) { // ignore empty modules - if (!DB::Module::IsEmpty(hContact, p)) { + if (!db_is_module_empty(hContact, p)) { pszProto = Proto_GetBaseAccountName(hContact); // Filter by mode switch (pDat->ExImContact->Typ) { @@ -311,7 +311,7 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar } // end TRUE = All Contacts // module must exist in the selected contact - else if (!DB::Module::IsEmpty(pDat->ExImContact->hContact, p) && (!pDat->ExImContact->hContact || mir_strcmpi(p, pszProto)) && mir_strcmpi(p, USERINFO)) { + else if (!db_is_module_empty(pDat->ExImContact->hContact, p) && (!pDat->ExImContact->hContact || mir_strcmpi(p, pszProto)) && mir_strcmpi(p, USERINFO)) { ExportTree_AddItem(hTree, hItemOptional, (LPSTR)p, bImagesLoaded, 1); } } diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp index f10a850566..ad76d4b4c5 100644 --- a/plugins/UserInfoEx/src/mir_db.cpp +++ b/plugins/UserInfoEx/src/mir_db.cpp @@ -55,21 +55,6 @@ uint32_t WhenAdded(uint32_t dwUIN, LPCSTR) namespace Module { -/** -* Deletes all settings in the module. -* @param hContact - handle to the contact -* @param pszModule - the module to delete the setting from (e.g. USERINFO) -* return: nothing -**/ - -void Delete(MCONTACT hContact, LPCSTR pszModule) -{ - CEnumList Settings; - if (!Settings.EnumSettings(hContact, pszModule)) - for (auto &it : Settings) - db_unset(hContact, pszModule, it); -} - /** * Enum Proc for DBModule_IsEmpty * @param pszSetting - the setting @@ -82,19 +67,6 @@ static int IsEmptyEnumProc(LPCSTR, void*) return 1; } -/** -* This function tests, whether a module is empty for the given contact or not -* @param hContact - handle to the contact -* @param pszModule - the module to read the setting from (e.g. USERINFO) -* @retval TRUE - the module is empty -* @retval FALSE - the module contains settings -**/ - -bool IsEmpty(MCONTACT hContact, LPCSTR pszModule) -{ - return 0 > db_enum_settings(hContact, IsEmptyEnumProc, pszModule); -} - /** * This function tests, whether a module belongs to a metacontact protocol * @param pszModule - the module to read the setting from (e.g. USERINFO) diff --git a/plugins/UserInfoEx/src/mir_db.h b/plugins/UserInfoEx/src/mir_db.h index 6ede82c18f..e00052a450 100644 --- a/plugins/UserInfoEx/src/mir_db.h +++ b/plugins/UserInfoEx/src/mir_db.h @@ -33,8 +33,6 @@ namespace Contact { } /* namespace Contact */ namespace Module { - void Delete(MCONTACT hContact, LPCSTR pszModule); - bool IsEmpty(MCONTACT hContact, LPCSTR pszModule); bool IsMeta(LPCSTR pszModule); bool IsMetaAndScan(LPCSTR pszModule); diff --git a/plugins/UserInfoEx/src/psp_options.cpp b/plugins/UserInfoEx/src/psp_options.cpp index dac4bbee06..26838261ec 100644 --- a/plugins/UserInfoEx/src/psp_options.cpp +++ b/plugins/UserInfoEx/src/psp_options.cpp @@ -419,8 +419,8 @@ static INT_PTR CALLBACK DlgProc_AdvancedOpts(HWND hDlg, UINT uMsg, WPARAM wParam db_unset(0, "SkinIcons", s); // delete global settings - DB::Module::Delete(NULL, USERINFO"Ex"); - DB::Module::Delete(NULL, USERINFO"ExW"); + db_delete_module(NULL, USERINFO"Ex"); + db_delete_module(NULL, USERINFO"ExW"); // delete old contactsettings for (auto &hContact : Contacts()) { @@ -434,8 +434,8 @@ static INT_PTR CALLBACK DlgProc_AdvancedOpts(HWND hDlg, UINT uMsg, WPARAM wParam db_unset(hContact, USERINFO, "RemindDaysErlier"); db_unset(hContact, USERINFO, "vCardPath"); - DB::Module::Delete(hContact, USERINFO"Ex"); - DB::Module::Delete(hContact, USERINFO"ExW"); + db_delete_module(hContact, USERINFO"Ex"); + db_delete_module(hContact, USERINFO"ExW"); } SendMessage(GetParent(hDlg), PSM_FORCECHANGED, NULL, NULL); -- cgit v1.2.3