diff options
Diffstat (limited to 'plugins/Db3x_mmap')
-rw-r--r-- | plugins/Db3x_mmap/src/dbcontacts.cpp | 27 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbevents.cpp | 12 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 8 |
3 files changed, 30 insertions, 17 deletions
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index 9946fe2f9a..b1c842448a 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -46,6 +46,11 @@ STDMETHODIMP_(LONG) CDb3Mmap::GetContactCount(void) return m_dbHeader.contactCount;
}
+STDMETHODIMP_(LONG) CDb3Mmap::GetContactSize(void)
+{
+ return sizeof(DBCachedContact);
+}
+
STDMETHODIMP_(MCONTACT) CDb3Mmap::FindFirstContact(const char *szProto)
{
mir_cslock lck(m_csDbAccess);
@@ -175,7 +180,7 @@ STDMETHODIMP_(MCONTACT) CDb3Mmap::AddContact() }
DBCachedContact *cc = m_cache->AddContactToCache(dbc.dwContactID);
- cc->dwDriverData = ofsNew;
+ cc->dwOfsContact = ofsNew;
NotifyEventHooks(hContactAddedEvent, dbc.dwContactID, 0);
return dbc.dwContactID;
@@ -188,7 +193,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::IsDbContact(MCONTACT contactID) return FALSE;
mir_cslock lck(m_csDbAccess);
- DBContact *dbc = (DBContact*)DBRead(cc->dwDriverData, NULL);
+ DBContact *dbc = (DBContact*)DBRead(cc->dwOfsContact, NULL);
if (dbc->signature == DBCONTACT_SIGNATURE) {
m_cache->AddContactToCache(contactID);
return TRUE;
@@ -219,8 +224,8 @@ static int SortEvent(const DBEvent *p1, const DBEvent *p2) BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
{
mir_cslock lck(m_csDbAccess);
- DBContact *dbMeta = (DBContact*)DBRead(ccMeta->dwDriverData, NULL);
- DBContact *dbSub = (DBContact*)DBRead(ccSub->dwDriverData, NULL);
+ DBContact *dbMeta = (DBContact*)DBRead(ccMeta->dwOfsContact, NULL);
+ DBContact *dbSub = (DBContact*)DBRead(ccSub->dwOfsContact, NULL);
if (dbMeta->signature != DBCONTACT_SIGNATURE || dbSub->signature != DBCONTACT_SIGNATURE)
return 1;
@@ -303,8 +308,8 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
{
mir_cslock lck(m_csDbAccess);
- DBContact dbMeta = *(DBContact*)DBRead(ccMeta->dwDriverData, NULL);
- DBContact dbSub = *(DBContact*)DBRead(ccSub->dwDriverData, NULL);
+ DBContact dbMeta = *(DBContact*)DBRead(ccMeta->dwOfsContact, NULL);
+ DBContact dbSub = *(DBContact*)DBRead(ccSub->dwOfsContact, NULL);
if (dbMeta.signature != DBCONTACT_SIGNATURE || dbSub.signature != DBCONTACT_SIGNATURE)
return 1;
@@ -366,8 +371,8 @@ BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) dwOffset = dwNext;
}
- DBWrite(ccSub->dwDriverData, &dbSub, sizeof(DBContact));
- DBWrite(ccMeta->dwDriverData, &dbMeta, sizeof(DBContact));
+ DBWrite(ccSub->dwOfsContact, &dbSub, sizeof(DBContact));
+ DBWrite(ccMeta->dwOfsContact, &dbMeta, sizeof(DBContact));
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
@@ -409,7 +414,7 @@ void CDb3Mmap::FillContacts() else dwContactID = m_dwMaxContactId++;
DBCachedContact *cc = m_cache->AddContactToCache(dwContactID);
- cc->dwDriverData = dwOffset;
+ cc->dwOfsContact = dwOffset;
CheckProto(cc, "");
DBVARIANT dbv; dbv.type = DBVT_DWORD;
@@ -480,7 +485,7 @@ void CDb3Mmap::FillContacts() // we don't need it anymore
if (!GetContactSetting(hContact, META_PROTO, "MetaID", &dbv)) {
DeleteContactSetting(hContact, META_PROTO, "MetaID");
- WipeContactHistory((DBContact*)DBRead(ccMeta->dwDriverData, NULL));
+ WipeContactHistory((DBContact*)DBRead(ccMeta->dwOfsContact, NULL));
}
for (int k = 0; k < ccMeta->nSubs; k++) {
@@ -502,5 +507,5 @@ DWORD CDb3Mmap::GetContactOffset(MCONTACT contactID, DBCachedContact **pcc) DBCachedContact *cc = m_cache->GetCachedContact(contactID);
if (pcc) *pcc = cc;
- return (cc == NULL) ? 0 : cc->dwDriverData;
+ return (cc == NULL) ? 0 : cc->dwOfsContact;
}
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index ee5f449288..7a79bd4327 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -142,7 +142,7 @@ STDMETHODIMP_(MEVENT) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) else neednotify = m_safetyMode;
if (ccSub != NULL) {
- DBContact *pSub = (DBContact*)DBRead(ccSub->dwDriverData, NULL);
+ DBContact *pSub = (DBContact*)DBRead(ccSub->dwOfsContact, NULL);
pSub->eventCount++;
}
@@ -174,7 +174,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent) else cc = NULL;
mir_cslockfull lck(m_csDbAccess);
- DWORD ofsContact = (cc) ? cc->dwDriverData : m_dbHeader.ofsUser;
+ DWORD ofsContact = (cc) ? cc->dwOfsContact : m_dbHeader.ofsUser;
DBContact dbc = *(DBContact*)DBRead(ofsContact, NULL);
DBEvent dbe = *(DBEvent*)DBRead((DWORD)hDbEvent, NULL);
if (dbc.signature != DBCONTACT_SIGNATURE || dbe.signature != DBEVENT_SIGNATURE)
@@ -318,7 +318,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) else cc = NULL;
mir_cslockfull lck(m_csDbAccess);
- DWORD ofsContact = (cc) ? cc->dwDriverData : m_dbHeader.ofsUser;
+ DWORD ofsContact = (cc) ? cc->dwOfsContact : m_dbHeader.ofsUser;
DBContact dbc = *(DBContact*)DBRead(ofsContact, NULL);
DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, NULL);
if (dbe->signature != DBEVENT_SIGNATURE || dbc.signature != DBCONTACT_SIGNATURE)
@@ -376,7 +376,7 @@ STDMETHODIMP_(MEVENT) CDb3Mmap::FindFirstEvent(MCONTACT contactID) if ((cc = m_cache->GetCachedContact(cc->parentID)) == NULL)
return NULL;
- dbc = (DBContact*)DBRead(cc->dwDriverData, NULL);
+ dbc = (DBContact*)DBRead(cc->dwOfsContact, NULL);
if (dbc->signature != DBCONTACT_SIGNATURE)
return NULL;
@@ -405,7 +405,7 @@ STDMETHODIMP_(MEVENT) CDb3Mmap::FindFirstUnreadEvent(MCONTACT contactID) if ((cc = m_cache->GetCachedContact(cc->parentID)) == NULL)
return NULL;
- dbc = (DBContact*)DBRead(cc->dwDriverData, NULL);
+ dbc = (DBContact*)DBRead(cc->dwOfsContact, NULL);
if (dbc->signature != DBCONTACT_SIGNATURE)
return NULL;
@@ -434,7 +434,7 @@ STDMETHODIMP_(MEVENT) CDb3Mmap::FindLastEvent(MCONTACT contactID) if ((cc = m_cache->GetCachedContact(cc->parentID)) == NULL)
return NULL;
- dbc = (DBContact*)DBRead(cc->dwDriverData, NULL);
+ dbc = (DBContact*)DBRead(cc->dwOfsContact, NULL);
if (dbc->signature != DBCONTACT_SIGNATURE)
return NULL;
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index df3d1cd949..761c28ede9 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -21,6 +21,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#define OWN_CACHED_CONTACT
+
#include <m_db_int.h>
/* tree diagram
@@ -174,6 +176,11 @@ struct DBEvent #include <poppack.h>
+struct DBCachedContact : public DBCachedContactBase
+{
+ DWORD dwOfsContact;
+};
+
struct CDb3Mmap : public MIDatabase, public MIDatabaseChecker, public MZeroedObject
{
CDb3Mmap(const TCHAR *tszFileName, int mode);
@@ -209,6 +216,7 @@ public: 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);
|