diff options
author | George Hazan <ghazan@miranda.im> | 2021-01-08 20:50:42 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-01-08 20:50:42 +0300 |
commit | cbe4e96467fe7ef3c3e7147526f55d1de9564f2b (patch) | |
tree | d6d12836456ed21275e712c93a64edcc029056f5 /plugins/Dbx_mdbx | |
parent | 7748903e5c28d9e30a3970dfaaf464f163da2a1d (diff) |
database options dialog also went into the core
Diffstat (limited to 'plugins/Dbx_mdbx')
-rw-r--r-- | plugins/Dbx_mdbx/res/dbx_mdbx.rc | 17 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/dbcrypt.cpp | 11 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/dbintf.h | 12 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/ui.cpp | 52 |
4 files changed, 13 insertions, 79 deletions
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);
}
|