summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src/dbintf.h
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-02-25 19:51:01 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-02-25 19:51:01 +0000
commitd84c40216b5e60224eb365f633b5f142d459fc9e (patch)
treec64402a3813b8c452f8bb80bb9c13bf5b6529e18 /plugins/Db3x_mmap/src/dbintf.h
parentf8ad8c89b9b308a79ad1f4081a478338eb504c26 (diff)
merge from branch
git-svn-id: http://svn.miranda-ng.org/main/trunk@8274 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src/dbintf.h')
-rw-r--r--plugins/Db3x_mmap/src/dbintf.h177
1 files changed, 94 insertions, 83 deletions
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h
index ff42141458..6cb02f0344 100644
--- a/plugins/Db3x_mmap/src/dbintf.h
+++ b/plugins/Db3x_mmap/src/dbintf.h
@@ -47,6 +47,7 @@ DBHeader
#define DB_OLD_VERSION 0x00000700u
#define DB_094_VERSION 0x00000701u
#define DB_095_VERSION 0x00000800u
+#define DB_095_1_VERSION 0x00000801u
#define DB_SETTINGS_RESIZE_GRANULARITY 128
@@ -81,37 +82,31 @@ struct ModuleName
#include <pshpack1.h>
struct DBHeader
{
- BYTE signature[16]; // 'Miranda ICQ DB',0,26
- DWORD version; //as 4 bytes, ie 1.2.3.10 = 0x0102030a
- //this version is 0x00000700
- 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
- 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
- DWORD ofsFirstModuleName; //offset to first struct DBModuleName in the chain
+ 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
+ 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
+ DWORD ofsModuleNames; // offset to first struct DBModuleName in the chain
};
#define DBCONTACT_SIGNATURE 0x43DECADEu
-
struct DBContact
{
DWORD signature;
- DWORD ofsNext; //offset to the next contact in the chain. zero if
- //this is the 'user' contact or the last contact
- //in the chain
- 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, ofsLastEvent; //offsets to the first and last DBEvent in
- //the chain for this contact
- DWORD ofsFirstUnreadEvent; //offset to the first (chronological) unread event
- //in the chain, 0 if all are read
- DWORD timestampFirstUnread; //timestamp of the event at ofsFirstUnreadEvent
+ DWORD ofsNext; // offset to the next contact in the chain. zero if
+ // this is the 'user' contact or the last contact in the chain
+ 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
+ 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;
};
@@ -119,45 +114,59 @@ struct DBContact
struct DBModuleName
{
DWORD signature;
- DWORD ofsNext; //offset to the next module name in the chain
- BYTE cbName; //number of characters in this module name
- char name[1]; //name, no nul terminator
+ DWORD ofsNext; // offset to the next module name in the chain
+ BYTE cbName; // number of characters in this module name
+ char name[1]; // name, no nul terminator
};
#define DBCONTACTSETTINGS_SIGNATURE 0x53DECADEu
struct DBContactSettings
{
DWORD signature;
- DWORD ofsNext; //offset to the next contactsettings in the chain
- DWORD ofsModuleName; //offset to the DBModuleName of the owner of these
- //settings
- DWORD cbBlob; //size of the blob in bytes. May be larger than the
- //actual size for reducing the number of moves
- //required using granularity in resizing
- BYTE blob[1]; //the blob. a back-to-back sequence of DBSetting
- //structs, the last has cbName = 0
+ DWORD ofsNext; // offset to the next contactsettings in the chain
+ DWORD ofsModuleName; // offset to the DBModuleName of the owner of these settings
+ DWORD cbBlob; // size of the blob in bytes. May be larger than the
+ // actual size for reducing the number of moves
+ // required using granularity in resizing
+ BYTE blob[1]; // the blob. a back-to-back sequence of DBSetting
+ // structs, the last has cbName = 0
};
#define DBEVENT_SIGNATURE 0x45DECADEu
+struct DBEvent_094 // previous event storage format
+{
+ DWORD signature;
+ DWORD ofsPrev, ofsNext; // offset to the previous and next events in the
+ // chain. Chain is sorted chronologically
+ DWORD ofsModuleName; // offset to a DBModuleName struct of the name of
+ // the owner of this event
+ DWORD timestamp; // seconds since 00:00:00 01/01/1970
+ DWORD flags; // see m_database.h, db/event/add
+ WORD wEventType; // module-defined event type
+ DWORD cbBlob; // number of bytes in the blob
+ BYTE blob[1]; // the blob. module-defined formatting
+};
+
struct DBEvent
{
DWORD signature;
- DWORD ofsPrev, ofsNext; //offset to the previous and next events in the
- //chain. Chain is sorted chronologically
- DWORD ofsModuleName; //offset to a DBModuleName struct of the name of
- //the owner of this event
- DWORD timestamp; //seconds since 00:00:00 01/01/1970
- DWORD flags; //see m_database.h, db/event/add
- WORD eventType; //module-defined event type
- DWORD cbBlob; //number of bytes in the blob
- BYTE blob[1]; //the blob. module-defined formatting
+ MCONTACT contactID; // a contact this event belongs to
+ DWORD ofsPrev, ofsNext; // offset to the previous and next events in the
+ // chain. Chain is sorted chronologically
+ DWORD ofsModuleName; // offset to a DBModuleName struct of the name of
+ // the owner of this event
+ DWORD timestamp; // seconds since 00:00:00 01/01/1970
+ DWORD flags; // see m_database.h, db/event/add
+ WORD wEventType; // module-defined event type
+ DWORD cbBlob; // number of bytes in the blob
+ BYTE blob[1]; // the blob. module-defined formatting
};
#include <poppack.h>
struct CDb3Mmap : public MIDatabase, public MIDatabaseChecker, public MZeroedObject
{
- CDb3Mmap(const TCHAR* tszFileName, bool bReadOnly);
+ CDb3Mmap(const TCHAR *tszFileName, bool bReadOnly);
~CDb3Mmap();
int Load(bool bSkipInit);
@@ -185,8 +194,8 @@ public:
STDMETHODIMP_(void) SetCacheSafetyMode(BOOL);
STDMETHODIMP_(LONG) GetContactCount(void);
- STDMETHODIMP_(MCONTACT) FindFirstContact(const char* szProto = NULL);
- STDMETHODIMP_(MCONTACT) FindNextContact(MCONTACT contactID, const char* szProto = NULL);
+ STDMETHODIMP_(MCONTACT) FindFirstContact(const char *szProto = NULL);
+ STDMETHODIMP_(MCONTACT) FindNextContact(MCONTACT contactID, const char *szProto = NULL);
STDMETHODIMP_(LONG) DeleteContact(MCONTACT contactID);
STDMETHODIMP_(HANDLE) AddContact(void);
STDMETHODIMP_(BOOL) IsDbContact(MCONTACT contactID);
@@ -212,7 +221,7 @@ public:
STDMETHODIMP_(BOOL) FreeVariant(DBVARIANT *dbv);
STDMETHODIMP_(BOOL) WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws);
STDMETHODIMP_(BOOL) DeleteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting);
- STDMETHODIMP_(BOOL) EnumContactSettings(MCONTACT contactID, DBCONTACTENUMSETTINGS* dbces);
+ STDMETHODIMP_(BOOL) EnumContactSettings(MCONTACT contactID, DBCONTACTENUMSETTINGS *dbces);
STDMETHODIMP_(BOOL) SetSettingResident(BOOL bIsResident, const char *pszSettingName);
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
STDMETHODIMP_(BOOL) IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting);
@@ -271,65 +280,67 @@ protected:
CRITICAL_SECTION m_csDbAccess;
- 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);
- DWORD GetContactOffset(MCONTACT contactID);
+ 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);
+ DWORD GetContactOffset(MCONTACT contactID);
////////////////////////////////////////////////////////////////////////////
// settings
- int m_codePage;
+ int m_codePage;
////////////////////////////////////////////////////////////////////////////
// modules
- HANDLE m_hModHeap;
+ HANDLE m_hModHeap;
LIST<ModuleName> m_lMods, m_lOfs;
LIST<char> m_lResidentSettings;
- HANDLE hEventAddedEvent, hEventDeletedEvent, hEventFilterAddedEvent;
+ HANDLE hEventAddedEvent, hEventDeletedEvent, hEventFilterAddedEvent;
MCONTACT m_hLastCachedContact;
ModuleName *m_lastmn;
- void AddToList(char *name, DWORD len, DWORD ofs);
- DWORD FindExistingModuleNameOfs(const char *szName);
- int InitModuleNames(void);
- DWORD GetModuleNameOfs(const char *szName);
- char *GetModuleNameByOfs(DWORD ofs);
+ void AddToList(char *name, DWORD len, DWORD ofs);
+ DWORD FindExistingModuleNameOfs(const char *szName);
+ int InitModuleNames(void);
+ DWORD GetModuleNameOfs(const char *szName);
+ char* GetModuleNameByOfs(DWORD ofs);
////////////////////////////////////////////////////////////////////////////
// checker
- int PeekSegment(DWORD ofs, PVOID buf, int cbBytes);
- int ReadSegment(DWORD ofs, PVOID buf, int cbBytes);
- int ReadWrittenSegment(DWORD ofs, PVOID buf, int cbBytes);
- int SignatureValid(DWORD ofs, DWORD signature);
- void FreeModuleChain();
+ int PeekSegment(DWORD ofs, PVOID buf, int cbBytes);
+ int ReadSegment(DWORD ofs, PVOID buf, int cbBytes);
+ int ReadWrittenSegment(DWORD ofs, PVOID buf, int cbBytes);
+ int SignatureValid(DWORD ofs, DWORD signature);
+ void FreeModuleChain();
- DWORD ConvertModuleNameOfs(DWORD ofsOld);
- void ConvertOldEvent(DBEvent*& dbei);
+ DWORD ConvertModuleNameOfs(DWORD ofsOld);
+ void ConvertOldEvent(DBEvent*& dbei);
- int GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic);
- int WorkSettingsChain(DWORD ofsContact, DBContact *dbc, int firstTime);
- int WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime);
+ int GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic);
+ int WorkSettingsChain(DWORD ofsContact, DBContact *dbc, int firstTime);
+ int WorkEventChain(DWORD ofsContact, DBContact *dbc, int firstTime);
- DWORD WriteSegment(DWORD ofs, PVOID buf, int cbBytes);
- DWORD WriteEvent(DBEvent *dbe);
- void WriteOfsNextToPrevious(DWORD ofsPrev, DBContact *dbc, DWORD ofsNext);
- void FinishUp(DWORD ofsLast, DBContact *dbc);
+ DWORD WriteSegment(DWORD ofs, PVOID buf, int cbBytes);
+ DWORD WriteEvent(DBEvent *dbe);
+ void WriteOfsNextToPrevious(DWORD ofsPrev, DBContact *dbc, DWORD ofsNext);
+ void FinishUp(DWORD ofsLast, DBContact *dbc);
DBCHeckCallback *cb;
- DWORD sourceFileSize, ofsAggrCur;
+ DWORD sourceFileSize, ofsAggrCur;
////////////////////////////////////////////////////////////////////////////
// encryption
- void ConvertContacts(void);
- int InitCrypt(void);
- void ToggleEventsEncryption(MCONTACT contactID);
- void ToggleSettingsEncryption(MCONTACT contactID);
+ void ConvertContacts(void);
+ void ConvertContactEvents(DBContact *dbc);
+ void ConvertEvents(void);
+ int InitCrypt(void);
+ void ToggleEventsEncryption(MCONTACT contactID);
+ void ToggleSettingsEncryption(MCONTACT contactID);
- void InitDialogs();
- bool EnterPassword(const BYTE *pKey, const size_t keyLen);
+ void InitDialogs();
+ bool EnterPassword(const BYTE *pKey, const size_t keyLen);
};