diff options
author | George Hazan <ghazan@miranda.im> | 2017-11-24 13:15:32 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-11-24 13:15:32 +0300 |
commit | 355c41643beadff74d490dc36f2c0432a2286e4c (patch) | |
tree | 9f5320227208ddc3e767e341af3c632a4a521c9a /plugins/Db3x_mmap | |
parent | 6d6cb956a78b2dbfa7e8d62f4234d8f27b100468 (diff) |
more common database code moved to MDatabaseCommon
Diffstat (limited to 'plugins/Db3x_mmap')
-rw-r--r-- | plugins/Db3x_mmap/src/dbcontacts.cpp | 58 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbcrypt.cpp | 2 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 16 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbsettings.cpp | 17 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/disk.cpp | 2 |
5 files changed, 7 insertions, 88 deletions
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index 55e4aa8c23..b9d1eb614d 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -23,23 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-int CDb3Mmap::CheckProto(DBCachedContact *cc, const char *proto)
-{
- if (cc->szProto == nullptr) {
- char protobuf[MAX_PATH] = { 0 };
- DBVARIANT dbv;
- dbv.type = DBVT_ASCIIZ;
- dbv.pszVal = protobuf;
- dbv.cchVal = sizeof(protobuf);
- if (GetContactSettingStatic(cc->contactID, "Protocol", "p", &dbv) != 0 || (dbv.type != DBVT_ASCIIZ))
- return 0;
-
- cc->szProto = m_cache->GetCachedSetting(nullptr, protobuf, 0, (int)mir_strlen(protobuf));
- }
-
- return !mir_strcmp(cc->szProto, proto);
-}
-
STDMETHODIMP_(LONG) CDb3Mmap::GetContactCount(void)
{
mir_cslock lck(m_csDbAccess);
@@ -51,36 +34,6 @@ STDMETHODIMP_(LONG) CDb3Mmap::GetContactSize(void) return sizeof(DBCachedContact);
}
-STDMETHODIMP_(MCONTACT) CDb3Mmap::FindFirstContact(const char *szProto)
-{
- mir_cslock lck(m_csDbAccess);
- DBCachedContact *cc = m_cache->GetFirstContact();
- if (cc == nullptr)
- return 0;
-
- if (!szProto || CheckProto(cc, szProto))
- return cc->contactID;
-
- return FindNextContact(cc->contactID, szProto);
-}
-
-STDMETHODIMP_(MCONTACT) CDb3Mmap::FindNextContact(MCONTACT contactID, const char *szProto)
-{
- mir_cslock lck(m_csDbAccess);
- while (contactID) {
- DBCachedContact *cc = m_cache->GetNextContact(contactID);
- if (cc == nullptr)
- break;
-
- if (!szProto || CheckProto(cc, szProto))
- return cc->contactID;
-
- contactID = cc->contactID;
- }
-
- return 0;
-}
-
STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(MCONTACT contactID)
{
if (contactID == 0) // global contact cannot be removed
@@ -206,17 +159,6 @@ STDMETHODIMP_(BOOL) CDb3Mmap::IsDbContact(MCONTACT contactID) /////////////////////////////////////////////////////////////////////////////////////////
// metacontacts support
-BOOL CDb3Mmap::MetaDetouchSub(DBCachedContact *cc, int nSub)
-{
- db_delete_module(cc->pSubs[nSub], META_PROTO);
- return 0;
-}
-
-BOOL CDb3Mmap::MetaSetDefault(DBCachedContact *cc)
-{
- return db_set_dw(cc->contactID, META_PROTO, "Default", cc->nDefault);
-}
-
static int SortEvent(const DBEvent *p1, const DBEvent *p2)
{
return (LONG)p1->timestamp - (LONG)p2->timestamp;
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index d2368e5b68..608cfa689d 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -225,7 +225,7 @@ void CDb3Mmap::StoreKey() SecureZeroMemory(pKey, iKeyLength);
}
-void CDb3Mmap::SetPassword(LPCTSTR ptszPassword)
+void CDb3Mmap::SetPassword(const wchar_t *ptszPassword)
{
if (ptszPassword == nullptr || *ptszPassword == 0) {
m_bUsesPassword = false;
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 1a6024bb20..4a194063a7 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -89,13 +89,13 @@ struct ModuleName #include <pshpack1.h>
struct DBHeader
{
- BYTE signature[16]; // 'Miranda ICQ DB',0,26
+ BYTE signature[16]; // 'Miranda ICQ DB',0,26
DWORD version; // as 4 bytes, ie 1.2.3.10 = 0x0102030a
DWORD ofsFileEnd; // offset of the end of the database - place to write new structures
DWORD slackSpace; // a counter of the number of bytes that have been
- // wasted so far due to deleting structures and/or
- // re-making them at the end. We should compact when
- // this gets above a threshold
+ // wasted so far due to deleting structures and/or
+ // re-making them at the end. We should compact when
+ // this gets above a threshold
DWORD contactCount; // number of contacts in the chain,excluding the user
DWORD ofsFirstContact; // offset to first DBContact in the chain
DWORD ofsUser; // offset to DBContact representing the user
@@ -111,7 +111,7 @@ struct DBContact DWORD ofsFirstSettings; // offset to the first DBContactSettings in the chain for this contact.
DWORD eventCount; // number of events in the chain for this contact
DWORD ofsFirstEvent, // offsets to the first and
- ofsLastEvent; // last DBEvent in the chain for this contact
+ ofsLastEvent; // last DBEvent in the chain for this contact
DWORD ofsFirstUnread; // offset to the first (chronological) unread event in the chain, 0 if all are read
DWORD tsFirstUnread; // timestamp of the event at ofsFirstUnread
DWORD dwContactID;
@@ -212,8 +212,6 @@ public: STDMETHODIMP_(void) SetCacheSafetyMode(BOOL);
STDMETHODIMP_(LONG) GetContactCount(void);
- STDMETHODIMP_(MCONTACT) FindFirstContact(const char *szProto = nullptr);
- STDMETHODIMP_(MCONTACT) FindNextContact(MCONTACT contactID, const char *szProto = nullptr);
STDMETHODIMP_(LONG) DeleteContact(MCONTACT contactID);
STDMETHODIMP_(MCONTACT) AddContact(void);
STDMETHODIMP_(BOOL) IsDbContact(MCONTACT contactID);
@@ -239,10 +237,7 @@ public: STDMETHODIMP_(BOOL) DeleteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting);
STDMETHODIMP_(BOOL) EnumContactSettings(MCONTACT hContact, DBSETTINGENUMPROC pfnEnumProc, const char *szModule, void *param);
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
- STDMETHODIMP_(BOOL) IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting);
- STDMETHODIMP_(BOOL) MetaDetouchSub(DBCachedContact *cc, int nSub);
- STDMETHODIMP_(BOOL) MetaSetDefault(DBCachedContact *cc);
STDMETHODIMP_(BOOL) MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub);
STDMETHODIMP_(BOOL) MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub);
@@ -298,7 +293,6 @@ protected: DWORD m_dwFileSize, m_dwMaxContactId;
HANDLE hSettingChangeEvent, hContactDeletedEvent, hContactAddedEvent, hEventMarkedRead;
- int CheckProto(DBCachedContact *cc, const char *proto);
DWORD CreateNewSpace(int bytes);
void DeleteSpace(DWORD ofs, int bytes);
DWORD ReallocSpace(DWORD ofs, int oldSize, int newSize);
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index 76225aec4c..758f80c769 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -27,23 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define VLT(n) ((n == DBVT_UTF8 || n == DBVT_ENCRYPTED) ? DBVT_ASCIIZ : n)
-BOOL CDb3Mmap::IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting)
-{
- if (!_strnicmp(szSetting, "password", 8)) return true;
- if (!mir_strcmp(szSetting, "NLProxyAuthPassword")) return true;
- if (!mir_strcmp(szSetting, "LNPassword")) return true;
- if (!mir_strcmp(szSetting, "FileProxyPassword")) return true;
- if (!mir_strcmp(szSetting, "TokenSecret")) return true;
-
- if (!mir_strcmp(szModule, "SecureIM")) {
- if (!mir_strcmp(szSetting, "pgp")) return true;
- if (!mir_strcmp(szSetting, "pgpPrivKey")) return true;
- }
- return false;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
static bool ValidLookupName(LPCSTR szModule, LPCSTR szSetting)
{
if (!mir_strcmp(szModule, META_PROTO))
diff --git a/plugins/Db3x_mmap/src/dbtool/disk.cpp b/plugins/Db3x_mmap/src/dbtool/disk.cpp index da18f9a1d6..3310c7dd67 100644 --- a/plugins/Db3x_mmap/src/dbtool/disk.cpp +++ b/plugins/Db3x_mmap/src/dbtool/disk.cpp @@ -72,7 +72,7 @@ int CDb3Mmap::ReadSegment(DWORD ofs, PVOID buf, int cbBytes) DWORD CDb3Mmap::WriteSegment(DWORD ofs, PVOID buf, int cbBytes)
{
- DWORD bytesWritten;
+ DWORD bytesWritten;
if (cb->bCheckOnly) return 0xbfbfbfbf;
if (ofs == WSOFS_END) {
ofs = m_dbHeader.ofsFileEnd;
|