diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-30 16:47:09 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-30 16:47:09 +0300 |
commit | 0a8a140351a533e2fb895228589efd2846b9c697 (patch) | |
tree | ea9b92130b2f6ab7304e496f20f8b88e0d7ca78f /plugins/Dbx_mdbx/src/dbintf.h | |
parent | 3166b70501ec138496e04140f82147ea23d82420 (diff) |
fix for asynchronous database flush to fix unsaved data
Diffstat (limited to 'plugins/Dbx_mdbx/src/dbintf.h')
-rw-r--r-- | plugins/Dbx_mdbx/src/dbintf.h | 130 |
1 files changed, 64 insertions, 66 deletions
diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h index d858deeb3e..a1e4c992c7 100644 --- a/plugins/Dbx_mdbx/src/dbintf.h +++ b/plugins/Dbx_mdbx/src/dbintf.h @@ -129,17 +129,10 @@ struct EventItem MEVENT eventId;
};
-struct CDbxMDBX : public MDatabaseCommon, public MZeroedObject
+class CDbxMDBX : public MDatabaseCommon, public MZeroedObject
{
friend class MDBXEventCursor;
- CDbxMDBX(const TCHAR *tszFileName, int mode);
- virtual ~CDbxMDBX();
-
- int Load(bool bSkipInit);
- int Create(void);
- int Check(void);
-
__forceinline MDBX_txn* StartTran() const
{
MDBX_txn *res = 0;
@@ -150,66 +143,17 @@ struct CDbxMDBX : public MDatabaseCommon, public MZeroedObject return res;
}
- void StoreKey(void);
- void SetPassword(const wchar_t *ptszPassword);
- void UpdateMenuItem(void);
-
+ void FillContacts(void);
+ int Map();
int PrepareCheck();
+ void UpdateMenuItem(void);
- __forceinline LPSTR GetMenuTitle() const { return m_bUsesPassword ? (char*)LPGEN("Change/remove password") : (char*)LPGEN("Set password"); }
-
- __forceinline bool isEncrypted() const { return m_bEncrypted; }
- __forceinline bool usesPassword() const { return m_bUsesPassword; }
- int EnableEncryption(bool bEnable);
-public:
- STDMETHODIMP_(BOOL) IsRelational(void) { return TRUE; }
- STDMETHODIMP_(void) SetCacheSafetyMode(BOOL);
-
- STDMETHODIMP_(LONG) GetContactCount(void);
- STDMETHODIMP_(LONG) DeleteContact(MCONTACT contactID);
- STDMETHODIMP_(MCONTACT) AddContact(void);
- STDMETHODIMP_(BOOL) IsDbContact(MCONTACT contactID);
- STDMETHODIMP_(LONG) GetContactSize(void);
-
- STDMETHODIMP_(LONG) GetEventCount(MCONTACT contactID);
- STDMETHODIMP_(MEVENT) AddEvent(MCONTACT contactID, DBEVENTINFO *dbe);
- STDMETHODIMP_(BOOL) DeleteEvent(MCONTACT contactID, MEVENT hDbEvent);
- STDMETHODIMP_(LONG) GetBlobSize(MEVENT hDbEvent);
- STDMETHODIMP_(BOOL) GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbe);
- STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT contactID, MEVENT hDbEvent);
- STDMETHODIMP_(MCONTACT) GetEventContact(MEVENT hDbEvent);
- STDMETHODIMP_(MEVENT) FindFirstEvent(MCONTACT contactID);
- STDMETHODIMP_(MEVENT) FindFirstUnreadEvent(MCONTACT contactID);
- STDMETHODIMP_(MEVENT) FindLastEvent(MCONTACT contactID);
- STDMETHODIMP_(MEVENT) FindNextEvent(MCONTACT contactID, MEVENT hDbEvent);
- STDMETHODIMP_(MEVENT) FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent);
-
- STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam);
-
- STDMETHODIMP_(BOOL) GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic);
- STDMETHODIMP_(BOOL) WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws);
- STDMETHODIMP_(BOOL) DeleteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting);
- STDMETHODIMP_(BOOL) EnumContactSettings(MCONTACT hContact, DBSETTINGENUMPROC pfnEnumProc, const char *szModule, void *param);
-
- STDMETHODIMP_(BOOL) MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub);
- STDMETHODIMP_(BOOL) MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub);
-
-protected:
-
- void FillContacts(void);
-
- int Map();
+ ////////////////////////////////////////////////////////////////////////////
+ // database stuff
-protected:
TCHAR* m_tszProfileName;
bool m_safetyMode, m_bReadOnly, m_bShared, m_bEncrypted, m_bUsesPassword;
- ////////////////////////////////////////////////////////////////////////////
- // database stuff
-public:
- MICryptoEngine *m_crypto;
-
-protected:
MDBX_env *m_env;
CMDBX_txn_ro m_txn_ro;
@@ -241,7 +185,7 @@ protected: ////////////////////////////////////////////////////////////////////////////
// events
- MDBX_dbi m_dbEvents, m_dbEventsSort;
+ MDBX_dbi m_dbEvents, m_dbEventsSort;
MDBX_cursor *m_curEvents, *m_curEventsSort;
MEVENT m_dwMaxEventId;
@@ -254,11 +198,11 @@ protected: MDBX_dbi m_dbModules;
MDBX_cursor *m_curModules;
-
+
std::map<uint32_t, std::string> m_Modules;
int InitModules();
-
+
uint32_t GetModuleID(const char *szName);
char* GetModuleName(uint32_t dwId);
@@ -271,4 +215,58 @@ protected: CRYPTO_PROVIDER* SelectProvider();
void InitDialogs();
-};
\ No newline at end of file +
+public:
+ CDbxMDBX(const TCHAR *tszFileName, int mode);
+ virtual ~CDbxMDBX();
+
+ int Check(void);
+ int Create(void);
+ void DBFlush(bool bForce = false);
+ int EnableEncryption(bool bEnable);
+ int Load(bool bSkipInit);
+ void StoreKey(void);
+ void SetPassword(const wchar_t *ptszPassword);
+
+ __forceinline LPSTR GetMenuTitle() const { return m_bUsesPassword ? (char*)LPGEN("Change/remove password") : (char*)LPGEN("Set password"); }
+
+ __forceinline bool isEncrypted() const { return m_bEncrypted; }
+ __forceinline bool usesPassword() const { return m_bUsesPassword; }
+
+public:
+ STDMETHODIMP_(BOOL) IsRelational(void) { return TRUE; }
+ STDMETHODIMP_(void) SetCacheSafetyMode(BOOL);
+
+ STDMETHODIMP_(LONG) GetContactCount(void);
+ STDMETHODIMP_(LONG) DeleteContact(MCONTACT contactID);
+ STDMETHODIMP_(MCONTACT) AddContact(void);
+ STDMETHODIMP_(BOOL) IsDbContact(MCONTACT contactID);
+ STDMETHODIMP_(LONG) GetContactSize(void);
+
+ STDMETHODIMP_(LONG) GetEventCount(MCONTACT contactID);
+ STDMETHODIMP_(MEVENT) AddEvent(MCONTACT contactID, DBEVENTINFO *dbe);
+ STDMETHODIMP_(BOOL) DeleteEvent(MCONTACT contactID, MEVENT hDbEvent);
+ STDMETHODIMP_(LONG) GetBlobSize(MEVENT hDbEvent);
+ STDMETHODIMP_(BOOL) GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbe);
+ STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT contactID, MEVENT hDbEvent);
+ STDMETHODIMP_(MCONTACT) GetEventContact(MEVENT hDbEvent);
+ STDMETHODIMP_(MEVENT) FindFirstEvent(MCONTACT contactID);
+ STDMETHODIMP_(MEVENT) FindFirstUnreadEvent(MCONTACT contactID);
+ STDMETHODIMP_(MEVENT) FindLastEvent(MCONTACT contactID);
+ STDMETHODIMP_(MEVENT) FindNextEvent(MCONTACT contactID, MEVENT hDbEvent);
+ STDMETHODIMP_(MEVENT) FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent);
+
+ STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam);
+
+ STDMETHODIMP_(BOOL) GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic);
+ STDMETHODIMP_(BOOL) WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws);
+ STDMETHODIMP_(BOOL) DeleteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting);
+ STDMETHODIMP_(BOOL) EnumContactSettings(MCONTACT hContact, DBSETTINGENUMPROC pfnEnumProc, const char *szModule, void *param);
+
+ STDMETHODIMP_(BOOL) MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub);
+ STDMETHODIMP_(BOOL) MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub);
+
+public:
+ MICryptoEngine *m_crypto;
+ UINT_PTR m_timerId; // timer to flush unsaved data
+};
|