diff options
author | George Hazan <ghazan@miranda.im> | 2018-08-07 22:15:18 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-08-07 22:15:18 +0300 |
commit | 624642196708533e1939263498725a3e8a18e2a4 (patch) | |
tree | 1389360a1ba9ed571af9a33ee05a06790dfff9d3 | |
parent | 96ac250c28999ca22ee4b75631911f96012e6136 (diff) |
MDatabaseReadonly - base class for all read-only database drivers
-rw-r--r-- | include/m_db_int.h | 58 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 173102 -> 179902 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 168200 -> 175132 bytes | |||
-rw-r--r-- | plugins/Import/src/mcontacts.cpp | 29 | ||||
-rw-r--r-- | src/mir_app/src/MDatabaseReadonly.cpp | 126 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 22 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 22 |
7 files changed, 217 insertions, 40 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h index aa75e8eb2a..50b8279e23 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_core.h>
#endif
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// basic database interface
struct DBCachedGlobalValue
@@ -132,7 +132,10 @@ interface MIR_APP_EXPORT MIDatabase /////////////////////////////////////////////////////////////////////////////////////////
-class MIR_APP_EXPORT MDatabaseCommon : public MIDatabase
+#pragma warning(push)
+#pragma warning(disable:4275)
+
+class MIR_APP_EXPORT MDatabaseCommon : public MIDatabase, public MNonCopyable
{
HANDLE m_hLock = nullptr;
@@ -177,12 +180,51 @@ public: STDMETHODIMP_(BOOL) Backup(LPCWSTR);
};
-///////////////////////////////////////////////////////////////////////////////
+#pragma warning(pop)
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Read-only database, that cannot add/modify information in a profile
+
+class MIR_APP_EXPORT MDatabaseReadonly : public MDatabaseCommon
+{
+public:
+ MDatabaseReadonly();
+
+ STDMETHODIMP_(BOOL) IsRelational(void) override;
+
+ STDMETHODIMP_(void) SetCacheSafetyMode(BOOL) override;
+
+ STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC, void*) override;
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ STDMETHODIMP_(MCONTACT) AddContact(void) override;
+ STDMETHODIMP_(LONG) DeleteContact(MCONTACT) override;
+ STDMETHODIMP_(BOOL) IsDbContact(MCONTACT contactID) override;
+ STDMETHODIMP_(LONG) GetContactSize(void) override;
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ STDMETHODIMP_(MEVENT) AddEvent(MCONTACT, DBEVENTINFO*) override;
+ STDMETHODIMP_(BOOL) DeleteEvent(MCONTACT, MEVENT) override;
+ STDMETHODIMP_(LONG) GetBlobSize(MEVENT) override;
+ STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT, MEVENT) override;
+ STDMETHODIMP_(MCONTACT) GetEventContact(MEVENT) override;
+ STDMETHODIMP_(MEVENT) FindFirstUnreadEvent(MCONTACT) override;
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ STDMETHODIMP_(BOOL) GetContactSettingWorker(MCONTACT, LPCSTR, LPCSTR, DBVARIANT*, int) override;
+ STDMETHODIMP_(BOOL) WriteContactSetting(MCONTACT, DBCONTACTWRITESETTING*) override;
+ STDMETHODIMP_(BOOL) DeleteContactSetting(MCONTACT, LPCSTR, LPCSTR) override;
+ STDMETHODIMP_(BOOL) EnumContactSettings(MCONTACT, DBSETTINGENUMPROC, const char*, void*) override;
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+ STDMETHODIMP_(BOOL) MetaMergeHistory(DBCachedContact*, DBCachedContact*) override;
+ STDMETHODIMP_(BOOL) MetaSplitHistory(DBCachedContact*, DBCachedContact*) override;
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Each database plugin should register itself using this structure
-/*
- Codes for DATABASELINK functions
-*/
+// Codes for DATABASELINK functions
// grokHeader() error codes
#define EGROKPRF_NOERROR 0
@@ -232,12 +274,12 @@ struct DATABASELINK MDatabaseCommon* (*Load)(const wchar_t *profile, BOOL bReadOnly);
};
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// cache access function
EXTERN_C MIR_CORE_DLL(DBCachedContact*) db_get_contact(MCONTACT);
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// Database list's functions
EXTERN_C MIR_CORE_DLL(MDatabaseCommon*) db_get_current(void);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 4599d4306e..9fa8bba928 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 3cb917428d..88e1d25819 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/Import/src/mcontacts.cpp b/plugins/Import/src/mcontacts.cpp index 2e33a47d9b..9aaf04454a 100644 --- a/plugins/Import/src/mcontacts.cpp +++ b/plugins/Import/src/mcontacts.cpp @@ -60,7 +60,7 @@ struct MC_MsgHeader #pragma pack(pop) -class CDbxMc : public MDatabaseCommon, public MZeroedObject +class CDbxMc : public MDatabaseReadonly, public MZeroedObject { HANDLE m_hFile = INVALID_HANDLE_VALUE; @@ -125,8 +125,6 @@ public: return memcmp(&m_hdr.signature, HEADER_STR, 2) ? EGROKPRF_UNKHEADER : EGROKPRF_NOERROR; } - STDMETHODIMP_(BOOL) IsRelational(void) override { return FALSE; } - // mcontacts format always store history for one contact only STDMETHODIMP_(LONG) GetContactCount(void) override { @@ -168,19 +166,6 @@ public: return 0; } - STDMETHODIMP_(void) SetCacheSafetyMode(BOOL) override {}; - - STDMETHODIMP_(LONG) DeleteContact(MCONTACT) override { return 1; } - STDMETHODIMP_(MCONTACT) AddContact(void) override { return 0; } - STDMETHODIMP_(BOOL) IsDbContact(MCONTACT contactID) override { return contactID == 1; } - STDMETHODIMP_(LONG) GetContactSize(void) override { return sizeof(DBCachedContact); } - - STDMETHODIMP_(MEVENT) AddEvent(MCONTACT, DBEVENTINFO*) override { return 0; } - STDMETHODIMP_(BOOL) DeleteEvent(MCONTACT, MEVENT) override { return 1; } - STDMETHODIMP_(LONG) GetBlobSize(MEVENT) override { return 0; } - STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT, MEVENT) override { return 1; } - STDMETHODIMP_(MCONTACT) GetEventContact(MEVENT) override { return 0; } - STDMETHODIMP_(MEVENT) FindFirstEvent(MCONTACT) override { m_curr = m_events.begin(); @@ -210,18 +195,6 @@ public: --m_curr; return *m_curr; } - - STDMETHODIMP_(MEVENT) FindFirstUnreadEvent(MCONTACT) override { return 0; } - - STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC, void *) override { return 0; } - - STDMETHODIMP_(BOOL) GetContactSettingWorker(MCONTACT, LPCSTR, LPCSTR, DBVARIANT*, int) override { return 1; } - STDMETHODIMP_(BOOL) WriteContactSetting(MCONTACT, DBCONTACTWRITESETTING*) override { return 1; } - STDMETHODIMP_(BOOL) DeleteContactSetting(MCONTACT, LPCSTR, LPCSTR) override { return 1; } - STDMETHODIMP_(BOOL) EnumContactSettings(MCONTACT, DBSETTINGENUMPROC, const char*, void*) override { return 1; } - - STDMETHODIMP_(BOOL) MetaMergeHistory(DBCachedContact*, DBCachedContact*) override { return 1; } - STDMETHODIMP_(BOOL) MetaSplitHistory(DBCachedContact*, DBCachedContact*) override { return 1; } }; static int mc_grokHeader(const wchar_t *profile) diff --git a/src/mir_app/src/MDatabaseReadonly.cpp b/src/mir_app/src/MDatabaseReadonly.cpp new file mode 100644 index 0000000000..49fb2ecc51 --- /dev/null +++ b/src/mir_app/src/MDatabaseReadonly.cpp @@ -0,0 +1,126 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (C) 2012-18 Miranda NG team, +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" +#include "database.h" + +BOOL MDatabaseReadonly::IsRelational(void) +{ + return FALSE; +} + +void MDatabaseReadonly::SetCacheSafetyMode(BOOL) +{} + +BOOL MDatabaseReadonly::EnumModuleNames(DBMODULEENUMPROC, void*) +{ + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +MCONTACT MDatabaseReadonly::AddContact(void) +{ + return 0; +} + +LONG MDatabaseReadonly::DeleteContact(MCONTACT) +{ + return 1; +} + +BOOL MDatabaseReadonly::IsDbContact(MCONTACT contactID) +{ + return contactID == 1; +} + +LONG MDatabaseReadonly::GetContactSize(void) +{ + return sizeof(DBCachedContact); +} + +///////////////////////////////////////////////////////////////////////////////////////// + +MEVENT MDatabaseReadonly::AddEvent(MCONTACT, DBEVENTINFO*) +{ + return 0; +} + +BOOL MDatabaseReadonly::DeleteEvent(MCONTACT, MEVENT) +{ + return 1; +} + +LONG MDatabaseReadonly::GetBlobSize(MEVENT) +{ + return 0; +} + +MEVENT MDatabaseReadonly::FindFirstUnreadEvent(MCONTACT) +{ + return 0; +} + +BOOL MDatabaseReadonly::MarkEventRead(MCONTACT, MEVENT) +{ + return 1; +} + +MCONTACT MDatabaseReadonly::GetEventContact(MEVENT) +{ + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +BOOL MDatabaseReadonly::GetContactSettingWorker(MCONTACT, LPCSTR, LPCSTR, DBVARIANT*, int) +{ + return 1; +} + +BOOL MDatabaseReadonly::WriteContactSetting(MCONTACT, DBCONTACTWRITESETTING*) +{ + return 1; +} + +BOOL MDatabaseReadonly::DeleteContactSetting(MCONTACT, LPCSTR, LPCSTR) +{ + return 1; +} + +BOOL MDatabaseReadonly::EnumContactSettings(MCONTACT, DBSETTINGENUMPROC, const char*, void*) +{ + return 1; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +BOOL MDatabaseReadonly::MetaMergeHistory(DBCachedContact*, DBCachedContact*) +{ + return 1; +} + +BOOL MDatabaseReadonly::MetaSplitHistory(DBCachedContact*, DBCachedContact*) +{ + return 1; +} diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 656bdab2ff..334fb522f5 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -441,12 +441,10 @@ Skin_PlaySoundFile @463 Clist_SetStatusMode @464
??0CProtoIntDlgBase@@QAE@$$QAV0@@Z @465 NONAME
??0MDatabaseCommon@@QAE@XZ @466 NONAME
-??0MDatabaseCommon@@QAE@ABV0@@Z @468 NONAME
??0MIDatabase@@QAE@$$QAU0@@Z @469 NONAME
??0MIDatabase@@QAE@ABU0@@Z @470 NONAME
??0MIDatabase@@QAE@XZ @471 NONAME
??1MDatabaseCommon@@UAE@XZ @472 NONAME
-??4MDatabaseCommon@@QAEAAV0@ABV0@@Z @476 NONAME
??4MIDatabase@@QAEAAU0@$$QAU0@@Z @477 NONAME
??4MIDatabase@@QAEAAU0@ABU0@@Z @478 NONAME
??_7MDatabaseCommon@@6B@ @480 NONAME
@@ -630,3 +628,23 @@ Netlib_SetUserSettingsByName @659 ?addFrame@CMPluginBase@@QAEHPBUCLISTFrame@@@Z @661 NONAME
Menu_SetVisible @662
Miranda_WaitOnHandleEx @663
+??1MDatabaseReadonly@@UAE@XZ @664 NONAME
+?AddContact@MDatabaseReadonly@@UAGIXZ @665 NONAME
+?AddEvent@MDatabaseReadonly@@UAGIIPAUDBEVENTINFO@@@Z @666 NONAME
+?DeleteContact@MDatabaseReadonly@@UAGJI@Z @667 NONAME
+?DeleteContactSetting@MDatabaseReadonly@@UAGHIPBD0@Z @668 NONAME
+?DeleteEvent@MDatabaseReadonly@@UAGHII@Z @669 NONAME
+?EnumContactSettings@MDatabaseReadonly@@UAGHIP6AHPBDPAX@Z01@Z @670 NONAME
+?EnumModuleNames@MDatabaseReadonly@@UAGHP6AHPBDPAX@Z1@Z @671 NONAME
+?FindFirstUnreadEvent@MDatabaseReadonly@@UAGII@Z @672 NONAME
+?GetBlobSize@MDatabaseReadonly@@UAGJI@Z @673 NONAME
+?GetContactSettingWorker@MDatabaseReadonly@@UAGHIPBD0PAUDBVARIANT@@H@Z @674 NONAME
+?GetContactSize@MDatabaseReadonly@@UAGJXZ @675 NONAME
+?GetEventContact@MDatabaseReadonly@@UAGII@Z @676 NONAME
+?IsDbContact@MDatabaseReadonly@@UAGHI@Z @677 NONAME
+?IsRelational@MDatabaseReadonly@@UAGHXZ @678 NONAME
+?MarkEventRead@MDatabaseReadonly@@UAGHII@Z @679 NONAME
+?MetaMergeHistory@MDatabaseReadonly@@UAGHPAUDBCachedContact@@0@Z @680 NONAME
+?MetaSplitHistory@MDatabaseReadonly@@UAGHPAUDBCachedContact@@0@Z @681 NONAME
+?SetCacheSafetyMode@MDatabaseReadonly@@UAGXH@Z @682 NONAME
+?WriteContactSetting@MDatabaseReadonly@@UAGHIPAUDBCONTACTWRITESETTING@@@Z @683 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 2a08500a71..5fdb5ecfaf 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -441,12 +441,10 @@ Skin_PlaySoundFile @463 Clist_SetStatusMode @464
??0CProtoIntDlgBase@@QEAA@$$QEAV0@@Z @465 NONAME
??0MDatabaseCommon@@QEAA@XZ @466 NONAME
-??0MDatabaseCommon@@QEAA@AEBV0@@Z @468 NONAME
??0MIDatabase@@QEAA@$$QEAU0@@Z @469 NONAME
??0MIDatabase@@QEAA@AEBU0@@Z @470 NONAME
??0MIDatabase@@QEAA@XZ @471 NONAME
??1MDatabaseCommon@@UEAA@XZ @472 NONAME
-??4MDatabaseCommon@@QEAAAEAV0@AEBV0@@Z @476 NONAME
??4MIDatabase@@QEAAAEAU0@$$QEAU0@@Z @477 NONAME
??4MIDatabase@@QEAAAEAU0@AEBU0@@Z @478 NONAME
??_7MDatabaseCommon@@6B@ @480 NONAME
@@ -630,3 +628,23 @@ Netlib_SetUserSettingsByName @659 ?addFrame@CMPluginBase@@QEAAHPEBUCLISTFrame@@@Z @661 NONAME
Menu_SetVisible @662
Miranda_WaitOnHandleEx @663
+??1MDatabaseReadonly@@UEAA@XZ @664 NONAME
+?AddContact@MDatabaseReadonly@@UEAAIXZ @665 NONAME
+?AddEvent@MDatabaseReadonly@@UEAAIIPEAUDBEVENTINFO@@@Z @666 NONAME
+?DeleteContact@MDatabaseReadonly@@UEAAJI@Z @667 NONAME
+?DeleteContactSetting@MDatabaseReadonly@@UEAAHIPEBD0@Z @668 NONAME
+?DeleteEvent@MDatabaseReadonly@@UEAAHII@Z @669 NONAME
+?EnumContactSettings@MDatabaseReadonly@@UEAAHIP6AHPEBDPEAX@Z01@Z @670 NONAME
+?EnumModuleNames@MDatabaseReadonly@@UEAAHP6AHPEBDPEAX@Z1@Z @671 NONAME
+?FindFirstUnreadEvent@MDatabaseReadonly@@UEAAII@Z @672 NONAME
+?GetBlobSize@MDatabaseReadonly@@UEAAJI@Z @673 NONAME
+?GetContactSettingWorker@MDatabaseReadonly@@UEAAHIPEBD0PEAUDBVARIANT@@H@Z @674 NONAME
+?GetContactSize@MDatabaseReadonly@@UEAAJXZ @675 NONAME
+?GetEventContact@MDatabaseReadonly@@UEAAII@Z @676 NONAME
+?IsDbContact@MDatabaseReadonly@@UEAAHI@Z @677 NONAME
+?IsRelational@MDatabaseReadonly@@UEAAHXZ @678 NONAME
+?MarkEventRead@MDatabaseReadonly@@UEAAHII@Z @679 NONAME
+?MetaMergeHistory@MDatabaseReadonly@@UEAAHPEAUDBCachedContact@@0@Z @680 NONAME
+?MetaSplitHistory@MDatabaseReadonly@@UEAAHPEAUDBCachedContact@@0@Z @681 NONAME
+?SetCacheSafetyMode@MDatabaseReadonly@@UEAAXH@Z @682 NONAME
+?WriteContactSetting@MDatabaseReadonly@@UEAAHIPEAUDBCONTACTWRITESETTING@@@Z @683 NONAME
|