From cbe4e96467fe7ef3c3e7147526f55d1de9564f2b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 8 Jan 2021 20:50:42 +0300 Subject: database options dialog also went into the core --- plugins/Db3x_mmap/src/dbcrypt.cpp | 6 ++- plugins/Db3x_mmap/src/dbintf.cpp | 4 +- plugins/Db3x_mmap/src/dbintf.h | 15 +++---- plugins/Db3x_mmap/src/resource.h | 6 --- plugins/Db3x_mmap/src/ui.cpp | 82 --------------------------------------- 5 files changed, 12 insertions(+), 101 deletions(-) delete mode 100644 plugins/Db3x_mmap/src/ui.cpp (limited to 'plugins/Db3x_mmap/src') diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index 2cb8fd7c9d..b32db5408a 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -127,8 +127,11 @@ STDMETHODIMP_(BOOL) CDb3Mmap::StoreProvider(CRYPTO_PROVIDER *pProvider) ///////////////////////////////////////////////////////////////////////////////////////// -void CDb3Mmap::ToggleEncryption() +STDMETHODIMP_(BOOL) CDb3Mmap::EnableEncryption(BOOL bEnable) { + if (bEnable == m_bEncrypted) + return TRUE; + HANDLE hSave1 = g_hevSettingChanged; g_hevSettingChanged = nullptr; HANDLE hSave2 = g_hevEventAdded; g_hevEventAdded = nullptr; HANDLE hSave3 = g_hevEventDeleted; g_hevEventDeleted = nullptr; @@ -154,6 +157,7 @@ void CDb3Mmap::ToggleEncryption() g_hevEventAdded = hSave2; g_hevEventDeleted = hSave3; g_hevEventFiltered = hSave4; + return TRUE; } void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID) diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp index 121d5a3d72..6a93e801f7 100644 --- a/plugins/Db3x_mmap/src/dbintf.cpp +++ b/plugins/Db3x_mmap/src/dbintf.cpp @@ -116,13 +116,11 @@ int CDb3Mmap::Load(bool bSkipInit) if (InitMap()) return 1; if (InitModuleNames()) return 1; if (InitCrypt()) return EGROKPRF_CANTREAD; - InitDialogs(); // everything is ok, go on - if (!m_bReadOnly) { + if (!m_bReadOnly) if (m_dbHeader.version < DB_095_1_VERSION) return EGROKPRF_CANTREAD; - } FillContacts(); } diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index d1206c9483..0b3582131d 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -192,8 +192,6 @@ struct CDb3Mmap : public MDatabaseCommon, public MZeroedObject int CreateDbHeaders(const DBSignature&); int CheckDbHeaders(bool bInteractive); - void ToggleEncryption(void); - void DatabaseCorruption(wchar_t *text); void WriteSignature(DBSignature&); @@ -225,13 +223,14 @@ public: STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam) override; - STDMETHODIMP_(BOOL) ReadCryptoKey(MBinBuffer&); - STDMETHODIMP_(BOOL) StoreCryptoKey(void); + STDMETHODIMP_(BOOL) ReadCryptoKey(MBinBuffer&) override; + STDMETHODIMP_(BOOL) StoreCryptoKey(void) override; - STDMETHODIMP_(BOOL) ReadEncryption(void); + STDMETHODIMP_(BOOL) EnableEncryption(BOOL) override; + STDMETHODIMP_(BOOL) ReadEncryption(void) override; - STDMETHODIMP_(CRYPTO_PROVIDER*) ReadProvider(); - STDMETHODIMP_(BOOL) StoreProvider(CRYPTO_PROVIDER*); + STDMETHODIMP_(CRYPTO_PROVIDER*) ReadProvider() override; + STDMETHODIMP_(BOOL) StoreProvider(CRYPTO_PROVIDER*) override; STDMETHODIMP_(BOOL) GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic) override; STDMETHODIMP_(BOOL) WriteContactSettingWorker(MCONTACT contactID, DBCONTACTWRITESETTING &dbcws) override; @@ -320,6 +319,4 @@ protected: int InitCrypt(void); void ToggleEventsEncryption(MCONTACT contactID); void ToggleSettingsEncryption(MCONTACT contactID); - - void InitDialogs(); }; diff --git a/plugins/Db3x_mmap/src/resource.h b/plugins/Db3x_mmap/src/resource.h index e9f022d2f3..b696e9603f 100644 --- a/plugins/Db3x_mmap/src/resource.h +++ b/plugins/Db3x_mmap/src/resource.h @@ -3,12 +3,6 @@ // Используется D:\Others\SVN\MirandaNG\trunk\plugins\Db3x_mmap\res\db3x_mmap.rc // #define IDREMOVE 3 -#define IDI_LOGO 101 -#define IDD_OPTIONS 105 -#define IDD_SELECT_CRYPTOPROVIDER 106 -#define IDC_HEADERBAR 1001 -#define IDC_STANDARD 1007 -#define IDC_TOTAL 1008 // Next default values for new objects // diff --git a/plugins/Db3x_mmap/src/ui.cpp b/plugins/Db3x_mmap/src/ui.cpp deleted file mode 100644 index ced14b5168..0000000000 --- a/plugins/Db3x_mmap/src/ui.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (C) 2012-20 Miranda NG team (https://miranda-ng.org) -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" - -///////////////////////////////////////////////////////////////////////////////////////// - -INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - CDb3Mmap *db = (CDb3Mmap *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - - db = (CDb3Mmap*)lParam; - CheckRadioButton(hwndDlg, IDC_STANDARD, IDC_TOTAL, IDC_STANDARD + db->isEncrypted()); - return TRUE; - - case WM_COMMAND: - if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus()) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - - case WM_NOTIFY: - if (((LPNMHDR)lParam)->code == PSN_APPLY) { - if (IsDlgButtonChecked(hwndDlg, IDC_TOTAL) != (UINT)db->isEncrypted()) { - db->ToggleEncryption(); - CheckRadioButton(hwndDlg, IDC_STANDARD, IDC_TOTAL, IDC_STANDARD + db->isEncrypted()); - } - break; - } - break; - } - - return FALSE; -} - -static int OnOptionsInit(PVOID obj, WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = {}; - odp.position = -790000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); - odp.flags = ODPF_BOLDGROUPS; - odp.szTitle.a = LPGEN("Database"); - odp.pfnDlgProc = DlgProcOptions; - odp.dwInitParam = (LPARAM)obj; - g_plugin.addOptions(wParam, &odp); - return 0; -} - -static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM) -{ - HookEventObj(ME_OPT_INITIALISE, OnOptionsInit, obj); - return 0; -} - -void CDb3Mmap::InitDialogs() -{ - hHook = HookEventObj(ME_SYSTEM_MODULESLOADED, OnModulesLoaded, this); -} -- cgit v1.2.3