summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-01-08 20:50:42 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-01-08 20:50:42 +0300
commitcbe4e96467fe7ef3c3e7147526f55d1de9564f2b (patch)
treed6d12836456ed21275e712c93a64edcc029056f5 /plugins
parent7748903e5c28d9e30a3970dfaaf464f163da2a1d (diff)
database options dialog also went into the core
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Db3x_mmap/db3x_mmap.vcxproj1
-rw-r--r--plugins/Db3x_mmap/db3x_mmap.vcxproj.filters3
-rw-r--r--plugins/Db3x_mmap/res/db3x_mmap.rc32
-rw-r--r--plugins/Db3x_mmap/src/dbcrypt.cpp6
-rw-r--r--plugins/Db3x_mmap/src/dbintf.cpp4
-rw-r--r--plugins/Db3x_mmap/src/dbintf.h15
-rw-r--r--plugins/Db3x_mmap/src/resource.h6
-rw-r--r--plugins/Db3x_mmap/src/ui.cpp82
-rw-r--r--plugins/Dbx_mdbx/res/dbx_mdbx.rc17
-rw-r--r--plugins/Dbx_mdbx/src/dbcrypt.cpp11
-rw-r--r--plugins/Dbx_mdbx/src/dbintf.h12
-rw-r--r--plugins/Dbx_mdbx/src/ui.cpp52
-rw-r--r--plugins/Dbx_sqlite/src/dbcrypt.cpp8
-rwxr-xr-xplugins/Dbx_sqlite/src/dbintf.h1
14 files changed, 34 insertions, 216 deletions
diff --git a/plugins/Db3x_mmap/db3x_mmap.vcxproj b/plugins/Db3x_mmap/db3x_mmap.vcxproj
index 4018dd621c..f28649acc8 100644
--- a/plugins/Db3x_mmap/db3x_mmap.vcxproj
+++ b/plugins/Db3x_mmap/db3x_mmap.vcxproj
@@ -39,7 +39,6 @@
<ClCompile Include="src\stdafx.cxx">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
- <ClCompile Include="src\ui.cpp" />
<ClInclude Include="src\database.h" />
<ClInclude Include="src\dbintf.h" />
<ClInclude Include="src\resource.h" />
diff --git a/plugins/Db3x_mmap/db3x_mmap.vcxproj.filters b/plugins/Db3x_mmap/db3x_mmap.vcxproj.filters
index 2ffffc35c5..989f5c0d3a 100644
--- a/plugins/Db3x_mmap/db3x_mmap.vcxproj.filters
+++ b/plugins/Db3x_mmap/db3x_mmap.vcxproj.filters
@@ -35,9 +35,6 @@
<ClCompile Include="src\stdafx.cxx">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\ui.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\database.h">
diff --git a/plugins/Db3x_mmap/res/db3x_mmap.rc b/plugins/Db3x_mmap/res/db3x_mmap.rc
index 2f9a539203..71859ae0f9 100644
--- a/plugins/Db3x_mmap/res/db3x_mmap.rc
+++ b/plugins/Db3x_mmap/res/db3x_mmap.rc
@@ -18,38 +18,6 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_OPTIONS DIALOGEX 0, 0, 318, 176
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 0, 0, 0x1
-BEGIN
- GROUPBOX "Database encryption mode",IDC_STATIC,6,22,305,125
- CONTROL "Standard",IDC_STANDARD,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,12,38,292,12
- CONTROL "Total",IDC_TOTAL,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,95,292,12
- LTEXT "Only critical data are encrypted (passwords, security tokens, etc). All other settings and history remains unencrypted. Fast and effective, suitable for the most cases",IDC_STATIC,22,54,284,37
- LTEXT "All string settings and all events in histories are encrypted. It also makes Miranda much slower and creates a risk of losing everything you've stored in a database in case of losing password. Recommended only for paranoid users",IDC_STATIC,22,110,284,33
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
-BEGIN
- IDD_OPTIONS, DIALOG
- BEGIN
- END
-END
-#endif // APSTUDIO_INVOKED
-
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
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);
-}
diff --git a/plugins/Dbx_mdbx/res/dbx_mdbx.rc b/plugins/Dbx_mdbx/res/dbx_mdbx.rc
index d727349410..e52335b93f 100644
--- a/plugins/Dbx_mdbx/res/dbx_mdbx.rc
+++ b/plugins/Dbx_mdbx/res/dbx_mdbx.rc
@@ -20,23 +20,6 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
/////////////////////////////////////////////////////////////////////////////
//
-// Dialog
-//
-
-IDD_OPTIONS DIALOGEX 0, 0, 318, 176
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
-EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg", 0, 0, 0x1
-BEGIN
- GROUPBOX "Database encryption mode",IDC_STATIC,6,22,305,125
- CONTROL "Standard",IDC_STANDARD,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,12,38,292,12
- CONTROL "Total",IDC_TOTAL,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,95,292,12
- LTEXT "Only critical data are encrypted (passwords, security tokens, etc). All other settings and history remains unencrypted. Fast and effective, suitable for the most cases",IDC_STATIC,22,54,284,37
- LTEXT "All string settings and all events in histories are encrypted. It also makes Miranda much slower and creates a risk of losing everything you've stored in a database in case of losing password. Recommended only for paranoid users",IDC_STATIC,22,110,284,33
-END
-
-/////////////////////////////////////////////////////////////////////////////
-//
// Icon
//
diff --git a/plugins/Dbx_mdbx/src/dbcrypt.cpp b/plugins/Dbx_mdbx/src/dbcrypt.cpp
index 9f41b534e5..fc2803eadd 100644
--- a/plugins/Dbx_mdbx/src/dbcrypt.cpp
+++ b/plugins/Dbx_mdbx/src/dbcrypt.cpp
@@ -94,17 +94,16 @@ STDMETHODIMP_(BOOL) CDbxMDBX::StoreProvider(CRYPTO_PROVIDER *pProv)
/////////////////////////////////////////////////////////////////////////////////////////
-int CDbxMDBX::EnableEncryption(bool bEncrypted)
+STDMETHODIMP_(BOOL) CDbxMDBX::EnableEncryption(BOOL bEncrypted)
{
if (m_bEncrypted == bEncrypted)
- return 0;
+ return TRUE;
std::vector<MEVENT> lstEvents;
MDBX_stat st;
mdbx_dbi_stat(StartTran(), m_dbEvents, &st, sizeof(st));
lstEvents.reserve(st.ms_entries);
-
{
MDBX_val key, data;
cursor_ptr pCursor(StartTran(), m_dbEvents);
@@ -157,7 +156,7 @@ int CDbxMDBX::EnableEncryption(bool bEncrypted)
memcpy(pNewDBEvent + 1, pNewBlob, nNewBlob);
if (mdbx_put(trnlck, m_dbEvents, &key, &data, MDBX_UPSERT) != MDBX_SUCCESS)
- return 1;
+ return FALSE;
}
}
@@ -169,10 +168,10 @@ int CDbxMDBX::EnableEncryption(bool bEncrypted)
txn_ptr trnlck(this);
MDBX_val key = { DBKey_Crypto_IsEncrypted, sizeof(DBKey_Crypto_IsEncrypted) }, value = { &bEncrypted, sizeof(bool) };
if (mdbx_put(trnlck, m_dbCrypto, &key, &value, MDBX_UPSERT) != MDBX_SUCCESS)
- return 1;
+ return FALSE;
}
DBFlush();
m_bEncrypted = bEncrypted;
- return 0;
+ return TRUE;
}
diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h
index 502b126ff4..ce7ecda46e 100644
--- a/plugins/Dbx_mdbx/src/dbintf.h
+++ b/plugins/Dbx_mdbx/src/dbintf.h
@@ -231,7 +231,6 @@ public:
int Check(void);
void DBFlush(bool bForce = false);
- int EnableEncryption(bool bEnable);
int Load();
int Map();
@@ -273,13 +272,14 @@ public:
STDMETHODIMP_(BOOL) MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) override;
STDMETHODIMP_(BOOL) MetaRemoveSubHistory(DBCachedContact *ccSub) override;
- STDMETHODIMP_(CRYPTO_PROVIDER*) ReadProvider(void);
- STDMETHODIMP_(BOOL) StoreProvider(CRYPTO_PROVIDER*);
+ STDMETHODIMP_(CRYPTO_PROVIDER*) ReadProvider(void) override;
+ STDMETHODIMP_(BOOL) StoreProvider(CRYPTO_PROVIDER*) override;
- STDMETHODIMP_(BOOL) ReadEncryption(void);
+ STDMETHODIMP_(BOOL) EnableEncryption(BOOL) override;
+ STDMETHODIMP_(BOOL) ReadEncryption(void) override;
- STDMETHODIMP_(BOOL) ReadCryptoKey(MBinBuffer&);
- STDMETHODIMP_(BOOL) StoreCryptoKey(void);
+ STDMETHODIMP_(BOOL) ReadCryptoKey(MBinBuffer&) override;
+ STDMETHODIMP_(BOOL) StoreCryptoKey(void) override;
STDMETHODIMP_(BOOL) Compact();
STDMETHODIMP_(BOOL) Backup(const wchar_t*);
diff --git a/plugins/Dbx_mdbx/src/ui.cpp b/plugins/Dbx_mdbx/src/ui.cpp
index e32df8d296..ced24c801d 100644
--- a/plugins/Dbx_mdbx/src/ui.cpp
+++ b/plugins/Dbx_mdbx/src/ui.cpp
@@ -37,63 +37,15 @@ static INT_PTR CompactMe(void* obj, WPARAM, LPARAM)
/////////////////////////////////////////////////////////////////////////////////////////
-class COptionsDialog : public CDlgBase
-{
- CCtrlCheck m_chkStandart;
- CCtrlCheck m_chkTotal;
- CDbxMDBX *m_db;
-
- bool OnInitDialog() override
- {
- m_chkStandart.SetState(!m_db->isEncrypted());
- m_chkTotal.SetState(m_db->isEncrypted());
- return true;
- }
-
- bool OnApply() override
- {
- SetCursor(LoadCursor(nullptr, IDC_WAIT));
- m_db->EnableEncryption(m_chkTotal.GetState() != 0);
- SetCursor(LoadCursor(nullptr, IDC_ARROW));
- m_chkStandart.SetState(!m_db->isEncrypted());
- m_chkTotal.SetState(m_db->isEncrypted());
- return true;
- }
-
-public:
- COptionsDialog(CDbxMDBX *db) :
- CDlgBase(g_plugin, IDD_OPTIONS),
- m_chkStandart(this, IDC_STANDARD),
- m_chkTotal(this, IDC_TOTAL),
- m_db(db)
- {
- }
-};
-
-static int OnOptionsInit(PVOID obj, WPARAM wParam, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = { sizeof(odp) };
- odp.position = -790000000;
- odp.flags = ODPF_BOLDGROUPS;
- odp.szTitle.a = LPGEN("Database");
- odp.pDialog = new COptionsDialog((CDbxMDBX*)obj);
- g_plugin.addOptions(wParam, &odp);
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
static IconItem iconList[] =
{
{ LPGEN("Compact"), "compact", IDI_COMPACT }
};
-static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM)
+static int OnModulesLoaded(WPARAM, LPARAM)
{
g_plugin.registerIcon(LPGEN("Database"), iconList, "mdbx");
- HookEventObj(ME_OPT_INITIALISE, OnOptionsInit, obj);
-
// main menu item
CMenuItem mi(&g_plugin);
mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Database"), 500000000, 0);
@@ -113,5 +65,5 @@ void CDbxMDBX::InitDialogs()
{
hService[0] = CreateServiceFunctionObj(MS_DB_COMPACT, CompactMe, this);
- hHook = HookEventObj(ME_SYSTEM_MODULESLOADED, OnModulesLoaded, this);
+ hHook = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
}
diff --git a/plugins/Dbx_sqlite/src/dbcrypt.cpp b/plugins/Dbx_sqlite/src/dbcrypt.cpp
index af4aa22682..8ba9ae64fa 100644
--- a/plugins/Dbx_sqlite/src/dbcrypt.cpp
+++ b/plugins/Dbx_sqlite/src/dbcrypt.cpp
@@ -67,3 +67,11 @@ STDMETHODIMP_(BOOL) CDbxSQLite::StoreProvider(CRYPTO_PROVIDER *pProvider)
WriteContactSetting(0, &dbcws);
return TRUE;
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Toggles full/partial encryption mode
+
+STDMETHODIMP_(BOOL) CDbxSQLite::EnableEncryption(BOOL)
+{
+ return FALSE;
+}
diff --git a/plugins/Dbx_sqlite/src/dbintf.h b/plugins/Dbx_sqlite/src/dbintf.h
index 88638623a5..e3e2fc46d7 100755
--- a/plugins/Dbx_sqlite/src/dbintf.h
+++ b/plugins/Dbx_sqlite/src/dbintf.h
@@ -97,6 +97,7 @@ public:
STDMETHODIMP_(CRYPTO_PROVIDER*) ReadProvider() override;
STDMETHODIMP_(BOOL) StoreProvider(CRYPTO_PROVIDER*) override;
+ STDMETHODIMP_(BOOL) EnableEncryption(BOOL) override;
STDMETHODIMP_(BOOL) ReadEncryption() override;
STDMETHODIMP_(BOOL) WriteContactSettingWorker(MCONTACT contactID, DBCONTACTWRITESETTING &dbcws) override;