diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Db3x_mmap/src/dbcontacts.cpp | 113 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbcrypt.cpp | 39 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbevents.cpp | 76 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 50 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbsettings.cpp | 67 | ||||
-rw-r--r-- | plugins/Dbx_tree/src/Compatibility.cpp | 149 | ||||
-rw-r--r-- | plugins/Dbx_tree/src/DataBase.cpp | 5 | ||||
-rw-r--r-- | plugins/Dbx_tree/src/DataBase.h | 36 | ||||
-rw-r--r-- | plugins/Dbx_tree/src/Services.cpp | 2 | ||||
-rw-r--r-- | plugins/Import/src/import.cpp | 235 |
10 files changed, 385 insertions, 387 deletions
diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index c96f888178..de426f5b65 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -23,19 +23,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
-int CDb3Mmap::CheckProto(HANDLE hContact, const char *proto)
+int CDb3Mmap::CheckProto(DBCachedContact *cc, const char *proto)
{
- DBCachedContact *cc = m_cache->GetCachedContact(hContact);
- if (cc == NULL)
- cc = m_cache->AddContactToCache(hContact);
-
if (cc->szProto == NULL) {
char protobuf[MAX_PATH] = { 0 };
DBVARIANT dbv;
dbv.type = DBVT_ASCIIZ;
dbv.pszVal = protobuf;
dbv.cchVal = sizeof(protobuf);
- if (GetContactSettingStatic(hContact, "Protocol", "p", &dbv) != 0 || (dbv.type != DBVT_ASCIIZ))
+ if (GetContactSettingStatic(cc->contactID, "Protocol", "p", &dbv) != 0 || (dbv.type != DBVT_ASCIIZ))
return 0;
cc->szProto = m_cache->GetCachedSetting(NULL, protobuf, 0, (int)strlen(protobuf));
@@ -50,57 +46,51 @@ STDMETHODIMP_(LONG) CDb3Mmap::GetContactCount(void) return m_dbHeader.contactCount;
}
-STDMETHODIMP_(HANDLE) CDb3Mmap::FindFirstContact(const char *szProto)
+STDMETHODIMP_(MCONTACT) CDb3Mmap::FindFirstContact(const char *szProto)
{
mir_cslock lck(m_csDbAccess);
- HANDLE ret = (HANDLE)m_dbHeader.ofsFirstContact;
- if (szProto && !CheckProto(ret, szProto))
- ret = FindNextContact(ret, szProto);
- return ret;
+ DBCachedContact *cc = m_cache->GetFirstContact();
+ if (cc == NULL)
+ return NULL;
+
+ if (!szProto || CheckProto(cc, szProto))
+ return cc->contactID;
+
+ return FindNextContact(cc->contactID, szProto);
}
-STDMETHODIMP_(HANDLE) CDb3Mmap::FindNextContact(HANDLE hContact, const char *szProto)
+STDMETHODIMP_(MCONTACT) CDb3Mmap::FindNextContact(MCONTACT contactID, const char *szProto)
{
mir_cslock lck(m_csDbAccess);
- while (hContact) {
- DBCachedContact *VL = m_cache->GetCachedContact(hContact);
- if (VL != NULL) {
- if (VL->hNext != NULL) {
- if (!szProto || CheckProto(VL->hNext, szProto))
- return VL->hNext;
-
- hContact = VL->hNext;
- continue;
- } }
-
- DBContact *dbc = (DBContact*)DBRead(hContact, sizeof(DBContact), NULL);
- if (dbc->signature != DBCONTACT_SIGNATURE)
+ while (contactID) {
+ DBCachedContact *cc = m_cache->GetNextContact(contactID);
+ if (cc == NULL)
break;
- if (VL == NULL)
- VL = m_cache->AddContactToCache(hContact);
+ if (!szProto || CheckProto(cc, szProto))
+ return cc->contactID;
- VL->hNext = (HANDLE)dbc->ofsNext;
- if (VL->hNext != NULL && (!szProto || CheckProto(VL->hNext, szProto)))
- return VL->hNext;
-
- hContact = VL->hNext;
+ contactID = cc->contactID;
}
return NULL;
}
-STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(HANDLE hContact)
+STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(MCONTACT contactID)
{
- if (hContact == NULL)
+ if (contactID == NULL)
return 1;
mir_cslockfull lck(m_csDbAccess);
- DBContact *dbc = (DBContact*)DBRead(hContact, sizeof(DBContact), NULL);
+ DBCachedContact *cc = m_cache->GetNextContact(contactID);
+ if (cc == NULL)
+ return 1;
+
+ DBContact *dbc = (DBContact*)DBRead(cc->dwDriverData, sizeof(DBContact), NULL);
if (dbc->signature != DBCONTACT_SIGNATURE)
return 1;
- if (hContact == (HANDLE)m_dbHeader.ofsUser) {
+ if (cc->dwDriverData == m_dbHeader.ofsUser) {
log0("FATAL: del of user chain attempted.");
return 1;
}
@@ -109,16 +99,15 @@ STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(HANDLE hContact) log0("del contact");
// call notifier while outside mutex
- NotifyEventHooks(hContactDeletedEvent, (WPARAM)hContact, 0);
+ NotifyEventHooks(hContactDeletedEvent, contactID, 0);
// get back in
lck.lock();
- m_cache->FreeCachedContact(hContact);
- if (hContact == m_hLastCachedContact)
+ m_cache->FreeCachedContact(contactID);
+ if (contactID == m_hLastCachedContact)
m_hLastCachedContact = NULL;
- dbc = (DBContact*)DBRead(hContact, sizeof(DBContact), NULL);
// delete settings chain
DWORD ofsThis = dbc->ofsFirstSettings;
DWORD ofsFirstEvent = dbc->ofsFirstEvent;
@@ -137,8 +126,8 @@ STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(HANDLE hContact) ofsThis = ofsNext;
}
//find previous contact in chain and change ofsNext
- dbc = (DBContact*)DBRead(hContact, sizeof(DBContact), NULL);
- if (m_dbHeader.ofsFirstContact == (DWORD)hContact) {
+ dbc = (DBContact*)DBRead(cc->dwDriverData, sizeof(DBContact), NULL);
+ if (m_dbHeader.ofsFirstContact == cc->dwDriverData) {
m_dbHeader.ofsFirstContact = dbc->ofsNext;
DBWrite(0, &m_dbHeader, sizeof(m_dbHeader));
}
@@ -146,7 +135,7 @@ STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(HANDLE hContact) DWORD ofsNext = dbc->ofsNext;
ofsThis = m_dbHeader.ofsFirstContact;
DBContact *dbcPrev = (DBContact*)DBRead(ofsThis,sizeof(DBContact),NULL);
- while (dbcPrev->ofsNext != (DWORD)hContact) {
+ while (dbcPrev->ofsNext != cc->dwDriverData) {
if (dbcPrev->ofsNext == 0) DatabaseCorruption(NULL);
ofsThis = dbcPrev->ofsNext;
dbcPrev = (DBContact*)DBRead(ofsThis,sizeof(DBContact),NULL);
@@ -156,7 +145,7 @@ STDMETHODIMP_(LONG) CDb3Mmap::DeleteContact(HANDLE hContact) }
//delete contact
- DeleteSpace((DWORD)hContact, sizeof(DBContact));
+ DeleteSpace(cc->dwDriverData, sizeof(DBContact));
//decrement contact count
m_dbHeader.contactCount--;
DBWrite(0, &m_dbHeader, sizeof(m_dbHeader));
@@ -168,12 +157,13 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddContact() {
DWORD ofsNew;
log0("add contact");
+
+ DBContact dbc = { 0 };
+ dbc.signature = DBCONTACT_SIGNATURE;
{
mir_cslock lck(m_csDbAccess);
ofsNew = CreateNewSpace(sizeof(DBContact));
- DBContact dbc = { 0 };
- dbc.signature = DBCONTACT_SIGNATURE;
dbc.ofsNext = m_dbHeader.ofsFirstContact;
dbc.dwContactID = m_dwMaxContactId++;
m_dbHeader.ofsFirstContact = ofsNew;
@@ -182,21 +172,24 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddContact() DBWrite(0, &m_dbHeader, sizeof(m_dbHeader));
DBFlush(0);
}
- m_cache->AddContactToCache((HANDLE)ofsNew);
+
+ DBCachedContact *cc = m_cache->AddContactToCache(dbc.dwContactID);
+ cc->dwDriverData = ofsNew;
- NotifyEventHooks(hContactAddedEvent, (WPARAM)ofsNew, 0);
+ NotifyEventHooks(hContactAddedEvent, dbc.dwContactID, 0);
return (HANDLE)ofsNew;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::IsDbContact(HANDLE hContact)
+STDMETHODIMP_(BOOL) CDb3Mmap::IsDbContact(MCONTACT contactID)
{
- if (m_cache->GetCachedContact(hContact))
- return TRUE;
+ DBCachedContact *cc = m_cache->GetCachedContact(contactID);
+ if (cc == NULL)
+ return FALSE;
mir_cslock lck(m_csDbAccess);
- DBContact *dbc = (DBContact*)DBRead(hContact, sizeof(DBContact), NULL);
+ DBContact *dbc = (DBContact*)DBRead(cc->dwDriverData, sizeof(DBContact), NULL);
if (dbc->signature == DBCONTACT_SIGNATURE) {
- m_cache->AddContactToCache(hContact);
+ m_cache->AddContactToCache(contactID);
return TRUE;
}
@@ -241,7 +234,19 @@ void CDb3Mmap::FillContacts() if (p->dwContactID > m_dwMaxContactId)
m_dwMaxContactId = p->dwContactID + 1;
- CheckProto((HANDLE)dwOffset, "");
+ DBCachedContact *cc = m_cache->AddContactToCache(p->dwContactID);
+ cc->dwDriverData = dwOffset;
+ CheckProto(cc, "");
+
dwOffset = p->ofsNext;
}
}
+
+DWORD CDb3Mmap::GetContactOffset(MCONTACT contactID)
+{
+ if (contactID == 0)
+ return m_dbHeader.ofsUser;
+
+ DBCachedContact *cc = m_cache->GetCachedContact(contactID);
+ return (cc == NULL) ? 0 : cc->dwDriverData;
+}
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index 6e3207adf9..7b0d1af539 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -65,7 +65,7 @@ struct SettingUgraderParam {
CDb3Mmap *db;
LPCSTR szModule;
- HANDLE hContact;
+ MCONTACT contactID;
OBJLIST<VarDescr>* pList;
};
@@ -74,7 +74,7 @@ int sttSettingUgrader(const char *szSetting, LPARAM lParam) SettingUgraderParam *param = (SettingUgraderParam*)lParam;
if (param->db->IsSettingEncrypted(param->szModule, szSetting)) {
DBVARIANT dbv = { DBVT_UTF8 };
- if (!param->db->GetContactSettingStr(param->hContact, param->szModule, szSetting, &dbv)) {
+ if (!param->db->GetContactSettingStr(param->contactID, param->szModule, szSetting, &dbv)) {
if (dbv.type == DBVT_UTF8) {
DecodeString(dbv.pszVal);
param->pList->insert(new VarDescr(szSetting, (LPCSTR)dbv.pszVal));
@@ -85,10 +85,10 @@ int sttSettingUgrader(const char *szSetting, LPARAM lParam) return 0;
}
-void sttContactEnum(HANDLE hContact, const char *szModule, CDb3Mmap *db)
+void sttContactEnum(MCONTACT contactID, const char *szModule, CDb3Mmap *db)
{
OBJLIST<VarDescr> arSettings(1);
- SettingUgraderParam param = { db, szModule, hContact, &arSettings };
+ SettingUgraderParam param = { db, szModule, contactID, &arSettings };
DBCONTACTENUMSETTINGS dbces = { 0 };
dbces.pfnEnumProc = sttSettingUgrader;
@@ -106,7 +106,7 @@ void sttContactEnum(HANDLE hContact, const char *szModule, CDb3Mmap *db) dbcws.value.type = DBVT_ENCRYPTED;
dbcws.value.pbVal = pResult;
dbcws.value.cpbVal = (WORD)len;
- db->WriteContactSetting(hContact, &dbcws);
+ db->WriteContactSetting(contactID, &dbcws);
mir_free(pResult);
}
@@ -118,8 +118,8 @@ int sttModuleEnum(const char *szModule, DWORD, LPARAM lParam) CDb3Mmap *db = (CDb3Mmap*)lParam;
sttContactEnum(NULL, szModule, db);
- for (HANDLE hContact = db->FindFirstContact(); hContact; hContact = db->FindNextContact(hContact))
- sttContactEnum(hContact, szModule, db);
+ for (MCONTACT contactID = db->FindFirstContact(); contactID; contactID = db->FindNextContact(contactID))
+ sttContactEnum(contactID, szModule, db);
return 0;
}
@@ -242,9 +242,9 @@ void CDb3Mmap::ToggleEncryption() ToggleSettingsEncryption(NULL);
ToggleEventsEncryption(NULL);
- for (HANDLE hContact = FindFirstContact(); hContact; hContact = FindNextContact(hContact)) {
- ToggleSettingsEncryption(hContact);
- ToggleEventsEncryption(hContact);
+ for (MCONTACT contactID = FindFirstContact(); contactID; contactID = FindNextContact(contactID)) {
+ ToggleSettingsEncryption(contactID);
+ ToggleEventsEncryption(contactID);
}
m_bEncrypted = !m_bEncrypted;
@@ -260,12 +260,13 @@ void CDb3Mmap::ToggleEncryption() hEventFilterAddedEvent = hSave4;
}
-void CDb3Mmap::ToggleSettingsEncryption(HANDLE hContact)
+void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID)
{
- if (!hContact)
- hContact = (HANDLE)m_dbHeader.ofsUser;
+ DWORD ofsContact = GetContactOffset(contactID);
+ if (ofsContact == 0)
+ return;
- DBContact *contact = (DBContact*)DBRead((DWORD)hContact, sizeof(DBContact), NULL);
+ DBContact *contact = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
if (contact->ofsFirstSettings == 0)
return;
@@ -340,7 +341,7 @@ void CDb3Mmap::ToggleSettingsEncryption(HANDLE hContact) dbcws.value.type = DBVT_ENCRYPTED;
dbcws.value.pbVal = pResult;
dbcws.value.cpbVal = (WORD)len;
- WriteContactSetting(hContact, &dbcws);
+ WriteContactSetting(contactID, &dbcws);
mir_free(pResult);
}
@@ -353,7 +354,7 @@ void CDb3Mmap::ToggleSettingsEncryption(HANDLE hContact) dbcws.value.type = DBVT_UNENCRYPTED;
dbcws.value.pszVal = decoded;
dbcws.value.cchVal = (WORD)realLen;
- WriteContactSetting(hContact, &dbcws);
+ WriteContactSetting(contactID, &dbcws);
}
}
}
@@ -367,9 +368,11 @@ void CDb3Mmap::ToggleSettingsEncryption(HANDLE hContact) }
}
-void CDb3Mmap::ToggleEventsEncryption(HANDLE hContact)
+void CDb3Mmap::ToggleEventsEncryption(MCONTACT contactID)
{
- DWORD ofsContact = (hContact) ? (DWORD)hContact : m_dbHeader.ofsUser;
+ DWORD ofsContact = GetContactOffset(contactID);
+ if (ofsContact == 0)
+ return;
DBContact contact = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
if (contact.ofsFirstEvent == 0 || contact.signature != DBCONTACT_SIGNATURE)
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index fe323e6bad..6afab80691 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -28,21 +28,19 @@ char *GetModuleNameByOfs(DWORD ofs); static HANDLE hEventDeletedEvent, hEventAddedEvent, hEventFilterAddedEvent;
-STDMETHODIMP_(LONG) CDb3Mmap::GetEventCount(HANDLE hContact)
+STDMETHODIMP_(LONG) CDb3Mmap::GetEventCount(MCONTACT contactID)
{
mir_cslock lck(m_csDbAccess);
- if (hContact == 0)
- hContact = (HANDLE)m_dbHeader.ofsUser;
-
- DBContact *dbc = (DBContact*)DBRead(hContact, sizeof(DBContact), NULL);
+ DBContact *dbc = (DBContact*)DBRead(GetContactOffset(contactID), sizeof(DBContact), NULL);
return (dbc->signature != DBCONTACT_SIGNATURE) ? -1 : dbc->eventCount;
}
-STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(HANDLE hContact, DBEVENTINFO *dbei)
+STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
{
if (dbei == NULL || dbei->cbSize != sizeof(DBEVENTINFO)) return 0;
if (dbei->timestamp == 0) return 0;
- if (NotifyEventHooks(hEventFilterAddedEvent, (WPARAM)hContact, (LPARAM)dbei))
+
+ if (NotifyEventHooks(hEventFilterAddedEvent, contactID, (LPARAM)dbei))
return 0;
DBEvent dbe;
@@ -67,7 +65,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(HANDLE hContact, DBEVENTINFO *dbei) bool neednotify;
mir_cslockfull lck(m_csDbAccess);
- DWORD ofsContact = (hContact == 0) ? m_dbHeader.ofsUser : (DWORD)hContact;
+ DWORD ofsContact = GetContactOffset(contactID);
DBContact dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
if (dbc.signature != DBCONTACT_SIGNATURE)
return 0;
@@ -77,7 +75,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(HANDLE hContact, DBEVENTINFO *dbei) dbe.ofsModuleName = GetModuleNameOfs(dbei->szModule);
// find where to put it - sort by timestamp
if (dbc.eventCount == 0) {
- dbe.ofsPrev = (DWORD)hContact;
+ dbe.ofsPrev = ofsContact;
dbe.ofsNext = 0;
dbe.flags |= DBEF_FIRST;
dbc.ofsFirstEvent = dbc.ofsLastEvent = ofsNew;
@@ -86,7 +84,7 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(HANDLE hContact, DBEVENTINFO *dbei) DBEvent *dbeTest = (DBEvent*)DBRead(dbc.ofsFirstEvent, sizeof(DBEvent), NULL);
// Should new event be placed before first event in chain?
if (dbe.timestamp < dbeTest->timestamp) {
- dbe.ofsPrev = (DWORD)hContact;
+ dbe.ofsPrev = ofsContact;
dbe.ofsNext = dbc.ofsFirstEvent;
dbe.flags |= DBEF_FIRST;
dbc.ofsFirstEvent = ofsNew;
@@ -143,18 +141,17 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::AddEvent(HANDLE hContact, DBEVENTINFO *dbei) // Notify only in safe mode or on really new events
if (neednotify)
- NotifyEventHooks(hEventAddedEvent, (WPARAM)hContact, (LPARAM)ofsNew);
+ NotifyEventHooks(hEventAddedEvent, contactID, (LPARAM)ofsNew);
return (HANDLE)ofsNew;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(HANDLE hContact, HANDLE hDbEvent)
+STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent)
{
mir_cslockfull lck(m_csDbAccess);
-
- DWORD ofsContact = (hContact == 0) ? m_dbHeader.ofsUser : (DWORD)hContact;
+ DWORD ofsContact = GetContactOffset(contactID);
DBContact dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
- DBEvent dbe = *(DBEvent*)DBRead(hDbEvent, sizeof(DBEvent), NULL);
+ DBEvent dbe = *(DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL);
if (dbc.signature != DBCONTACT_SIGNATURE || dbe.signature != DBEVENT_SIGNATURE)
return 1;
@@ -162,12 +159,12 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(HANDLE hContact, HANDLE hDbEvent) log1("delete event @ %08x", hContact);
//call notifier while outside mutex
- NotifyEventHooks(hEventDeletedEvent, (WPARAM)hContact, (LPARAM)hDbEvent);
+ NotifyEventHooks(hEventDeletedEvent, contactID, (LPARAM)hDbEvent);
//get back in
lck.lock();
dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
- dbe = *(DBEvent*)DBRead(hDbEvent, sizeof(DBEvent), NULL);
+ dbe = *(DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL);
//check if this was the first unread, if so, recalc the first unread
if (dbc.ofsFirstUnreadEvent == (DWORD)hDbEvent) {
@@ -229,7 +226,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteEvent(HANDLE hContact, HANDLE hDbEvent) STDMETHODIMP_(LONG) CDb3Mmap::GetBlobSize(HANDLE hDbEvent)
{
mir_cslock lck(m_csDbAccess);
- DBEvent *dbe = (DBEvent*)DBRead(hDbEvent, sizeof(DBEvent), NULL);
+ DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL);
return (dbe->signature != DBEVENT_SIGNATURE) ? -1 : dbe->cbBlob;
}
@@ -242,7 +239,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbei) }
mir_cslock lck(m_csDbAccess);
- DBEvent *dbe = (DBEvent*)DBRead(hDbEvent, sizeof(DBEvent), NULL);
+ DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL);
if (dbe->signature != DBEVENT_SIGNATURE)
return 1;
@@ -271,13 +268,12 @@ STDMETHODIMP_(BOOL) CDb3Mmap::GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbei) return 0;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(HANDLE hContact, HANDLE hDbEvent)
+STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(MCONTACT contactID, HANDLE hDbEvent)
{
mir_cslock lck(m_csDbAccess);
- if (hContact == 0)
- hContact = (HANDLE)m_dbHeader.ofsUser;
- DBContact dbc = *(DBContact*)DBRead(hContact, sizeof(DBContact), NULL);
- DBEvent *dbe = (DBEvent*)DBRead(hDbEvent, sizeof(DBEvent), NULL);
+ DWORD ofsContact = GetContactOffset(contactID);
+ DBContact dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
+ DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL);
if (dbe->signature != DBEVENT_SIGNATURE || dbc.signature != DBCONTACT_SIGNATURE)
return -1;
@@ -304,7 +300,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(HANDLE hContact, HANDLE hDbEvent) }
}
}
- DBWrite((DWORD)hContact, &dbc, sizeof(DBContact));
+ DBWrite(ofsContact, &dbc, sizeof(DBContact));
DBFlush(0);
return ret;
}
@@ -312,7 +308,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::MarkEventRead(HANDLE hContact, HANDLE hDbEvent) STDMETHODIMP_(HANDLE) CDb3Mmap::GetEventContact(HANDLE hDbEvent)
{
mir_cslock lck(m_csDbAccess);
- DBEvent *dbe = (DBEvent*)DBRead(hDbEvent, sizeof(DBEvent), NULL);
+ DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL);
if (dbe->signature != DBEVENT_SIGNATURE)
return (HANDLE)-1;
@@ -322,47 +318,41 @@ STDMETHODIMP_(HANDLE) CDb3Mmap::GetEventContact(HANDLE hDbEvent) return (HANDLE)dbe->ofsPrev;
}
-STDMETHODIMP_(HANDLE) CDb3Mmap::FindFirstEvent(HANDLE hContact)
+STDMETHODIMP_(HANDLE) CDb3Mmap::FindFirstEvent(MCONTACT contactID)
{
mir_cslock lck(m_csDbAccess);
- if (hContact == 0)
- hContact = (HANDLE)m_dbHeader.ofsUser;
-
- DBContact *dbc = (DBContact*)DBRead(hContact, sizeof(DBContact), NULL);
+ DWORD ofsContact = GetContactOffset(contactID);
+ DBContact *dbc = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
return (dbc->signature != DBCONTACT_SIGNATURE) ? 0 : (HANDLE)dbc->ofsFirstEvent;
}
-STDMETHODIMP_(HANDLE) CDb3Mmap::FindFirstUnreadEvent(HANDLE hContact)
+STDMETHODIMP_(HANDLE) CDb3Mmap::FindFirstUnreadEvent(MCONTACT contactID)
{
mir_cslock lck(m_csDbAccess);
- if (hContact == 0)
- hContact = (HANDLE)m_dbHeader.ofsUser;
-
- DBContact *dbc = (DBContact*)DBRead(hContact, sizeof(DBContact), NULL);
+ DWORD ofsContact = GetContactOffset(contactID);
+ DBContact *dbc = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
return (dbc->signature != DBCONTACT_SIGNATURE) ? 0 : (HANDLE)dbc->ofsFirstUnreadEvent;
}
-STDMETHODIMP_(HANDLE) CDb3Mmap::FindLastEvent(HANDLE hContact)
+STDMETHODIMP_(HANDLE) CDb3Mmap::FindLastEvent(MCONTACT contactID)
{
mir_cslock lck(m_csDbAccess);
- if (hContact == 0)
- hContact = (HANDLE)m_dbHeader.ofsUser;
-
- DBContact *dbc = (DBContact*)DBRead(hContact, sizeof(DBContact), NULL);
+ DWORD ofsContact = GetContactOffset(contactID);
+ DBContact *dbc = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
return (dbc->signature != DBCONTACT_SIGNATURE) ? 0 : (HANDLE)dbc->ofsLastEvent;
}
STDMETHODIMP_(HANDLE) CDb3Mmap::FindNextEvent(HANDLE hDbEvent)
{
mir_cslock lck(m_csDbAccess);
- DBEvent *dbe = (DBEvent*)DBRead(hDbEvent, sizeof(DBEvent), NULL);
+ DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL);
return (dbe->signature != DBEVENT_SIGNATURE) ? 0 : (HANDLE)dbe->ofsNext;
}
STDMETHODIMP_(HANDLE) CDb3Mmap::FindPrevEvent(HANDLE hDbEvent)
{
mir_cslock lck(m_csDbAccess);
- DBEvent *dbe = (DBEvent*)DBRead(hDbEvent, sizeof(DBEvent), NULL);
+ DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, sizeof(DBEvent), NULL);
if (dbe->signature != DBEVENT_SIGNATURE) return 0;
return (dbe->flags & DBEF_FIRST) ? 0 : (HANDLE)dbe->ofsPrev;
}
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 284a5842d9..629b2972f8 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -185,34 +185,34 @@ public: STDMETHODIMP_(void) SetCacheSafetyMode(BOOL);
STDMETHODIMP_(LONG) GetContactCount(void);
- STDMETHODIMP_(HANDLE) FindFirstContact(const char* szProto = NULL);
- STDMETHODIMP_(HANDLE) FindNextContact(HANDLE hContact, const char* szProto = NULL);
- STDMETHODIMP_(LONG) DeleteContact(HANDLE hContact);
+ 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(HANDLE hContact);
+ STDMETHODIMP_(BOOL) IsDbContact(MCONTACT contactID);
- STDMETHODIMP_(LONG) GetEventCount(HANDLE hContact);
- STDMETHODIMP_(HANDLE) AddEvent(HANDLE hContact, DBEVENTINFO *dbe);
- STDMETHODIMP_(BOOL) DeleteEvent(HANDLE hContact, HANDLE hDbEvent);
+ STDMETHODIMP_(LONG) GetEventCount(MCONTACT contactID);
+ STDMETHODIMP_(HANDLE) AddEvent(MCONTACT contactID, DBEVENTINFO *dbe);
+ STDMETHODIMP_(BOOL) DeleteEvent(MCONTACT contactID, HANDLE hDbEvent);
STDMETHODIMP_(LONG) GetBlobSize(HANDLE hDbEvent);
STDMETHODIMP_(BOOL) GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbe);
- STDMETHODIMP_(BOOL) MarkEventRead(HANDLE hContact, HANDLE hDbEvent);
+ STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT contactID, HANDLE hDbEvent);
STDMETHODIMP_(HANDLE) GetEventContact(HANDLE hDbEvent);
- STDMETHODIMP_(HANDLE) FindFirstEvent(HANDLE hContact);
- STDMETHODIMP_(HANDLE) FindFirstUnreadEvent(HANDLE hContact);
- STDMETHODIMP_(HANDLE) FindLastEvent(HANDLE hContact);
+ STDMETHODIMP_(HANDLE) FindFirstEvent(MCONTACT contactID);
+ STDMETHODIMP_(HANDLE) FindFirstUnreadEvent(MCONTACT contactID);
+ STDMETHODIMP_(HANDLE) FindLastEvent(MCONTACT contactID);
STDMETHODIMP_(HANDLE) FindNextEvent(HANDLE hDbEvent);
STDMETHODIMP_(HANDLE) FindPrevEvent(HANDLE hDbEvent);
STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam);
- STDMETHODIMP_(BOOL) GetContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
- STDMETHODIMP_(BOOL) GetContactSettingStr(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
- STDMETHODIMP_(BOOL) GetContactSettingStatic(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+ STDMETHODIMP_(BOOL) GetContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+ STDMETHODIMP_(BOOL) GetContactSettingStr(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+ STDMETHODIMP_(BOOL) GetContactSettingStatic(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
STDMETHODIMP_(BOOL) FreeVariant(DBVARIANT *dbv);
- STDMETHODIMP_(BOOL) WriteContactSetting(HANDLE hContact, DBCONTACTWRITESETTING *dbcws);
- STDMETHODIMP_(BOOL) DeleteContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting);
- STDMETHODIMP_(BOOL) EnumContactSettings(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces);
+ 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) SetSettingResident(BOOL bIsResident, const char *pszSettingName);
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
STDMETHODIMP_(BOOL) IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting);
@@ -271,15 +271,11 @@ protected: CRITICAL_SECTION m_csDbAccess;
- int CheckProto(HANDLE hContact, const char *proto);
+ 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);
-
- __forceinline PBYTE DBRead(HANDLE hContact, int bytesRequired, int *bytesAvail)
- {
- return DBRead((DWORD)hContact, bytesRequired, bytesAvail);
- }
+ DWORD GetContactOffset(MCONTACT contactID);
////////////////////////////////////////////////////////////////////////////
// settings
@@ -293,7 +289,7 @@ protected: LIST<ModuleName> m_lMods, m_lOfs;
LIST<char> m_lResidentSettings;
HANDLE hEventAddedEvent, hEventDeletedEvent, hEventFilterAddedEvent;
- HANDLE m_hLastCachedContact;
+ MCONTACT m_hLastCachedContact;
ModuleName *m_lastmn;
void AddToList(char *name, DWORD len, DWORD ofs);
@@ -314,7 +310,7 @@ protected: DWORD ConvertModuleNameOfs(DWORD ofsOld);
void ConvertOldEvent(DBEvent*& dbei);
- int GetContactSettingWorker(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic);
+ 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);
@@ -331,8 +327,8 @@ protected: void ConvertContacts(void);
int InitCrypt(void);
- void ToggleEventsEncryption(HANDLE hContact);
- void ToggleSettingsEncryption(HANDLE hContact);
+ void ToggleEventsEncryption(MCONTACT contactID);
+ void ToggleSettingsEncryption(MCONTACT contactID);
void InitDialogs();
bool EnterPassword(const BYTE *pKey, const size_t keyLen);
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index 4ea08ca479..fed42bf395 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
DWORD GetModuleNameOfs(const char *szName);
-DBCachedContact* AddToCachedContactList(HANDLE hContact, int index);
+DBCachedContact* AddToCachedContactList(MCONTACT contactID, int index);
#define VLT(n) ((n == DBVT_UTF8 || n == DBVT_ENCRYPTED)?DBVT_ASCIIZ:n)
@@ -45,7 +45,7 @@ BOOL CDb3Mmap::IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting) /////////////////////////////////////////////////////////////////////////////////////////
-int CDb3Mmap::GetContactSettingWorker(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic)
+int CDb3Mmap::GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic)
{
if (szSetting == NULL || szModule == NULL)
return 1;
@@ -71,7 +71,7 @@ int CDb3Mmap::GetContactSettingWorker(HANDLE hContact, LPCSTR szModule, LPCSTR s char *szCachedSettingName = m_cache->GetCachedSetting(szModule, szSetting, moduleNameLen, settingNameLen);
log3("get [%08p] %s (%p)", hContact, szCachedSettingName, szCachedSettingName);
- DBVARIANT *pCachedValue = m_cache->GetCachedValuePtr(hContact, szCachedSettingName, 0);
+ DBVARIANT *pCachedValue = m_cache->GetCachedValuePtr(contactID, szCachedSettingName, 0);
if (pCachedValue != NULL) {
if (pCachedValue->type == DBVT_ASCIIZ || pCachedValue->type == DBVT_UTF8) {
int cbOrigLen = dbv->cchVal;
@@ -106,8 +106,8 @@ int CDb3Mmap::GetContactSettingWorker(HANDLE hContact, LPCSTR szModule, LPCSTR s return 1;
DWORD ofsModuleName = GetModuleNameOfs(szModule);
- DWORD ofsContact = (hContact == NULL) ? m_dbHeader.ofsUser : (DWORD)hContact;
-
+ DWORD ofsContact = GetContactOffset(contactID);
+
DBContact dbc = *(DBContact*)DBRead(ofsContact,sizeof(DBContact),NULL);
if (dbc.signature != DBCONTACT_SIGNATURE)
return 1;
@@ -202,7 +202,7 @@ int CDb3Mmap::GetContactSettingWorker(HANDLE hContact, LPCSTR szModule, LPCSTR s /**** add to cache **********************/
if (iType != DBVT_BLOB && iType != DBVT_ENCRYPTED) {
- DBVARIANT *pCachedValue = m_cache->GetCachedValuePtr(hContact, szCachedSettingName, 1);
+ DBVARIANT *pCachedValue = m_cache->GetCachedValuePtr(contactID, szCachedSettingName, 1);
if (pCachedValue != NULL) {
m_cache->SetCachedVariant(dbv, pCachedValue);
log3("set cached [%08p] %s (%p)", hContact, szCachedSettingName, pCachedValue);
@@ -223,10 +223,10 @@ int CDb3Mmap::GetContactSettingWorker(HANDLE hContact, LPCSTR szModule, LPCSTR s return 1;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::GetContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
+STDMETHODIMP_(BOOL) CDb3Mmap::GetContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
dbv->type = 0;
- if (GetContactSettingWorker(hContact, szModule, szSetting, dbv, 0))
+ if (GetContactSettingWorker(contactID, szModule, szSetting, dbv, 0))
return 1;
if (dbv->type == DBVT_UTF8 ) {
@@ -258,11 +258,11 @@ STDMETHODIMP_(BOOL) CDb3Mmap::GetContactSetting(HANDLE hContact, LPCSTR szModule return 0;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::GetContactSettingStr(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
+STDMETHODIMP_(BOOL) CDb3Mmap::GetContactSettingStr(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
int iSaveType = dbv->type;
- if (GetContactSettingWorker(hContact, szModule, szSetting, dbv, 0))
+ if (GetContactSettingWorker(contactID, szModule, szSetting, dbv, 0))
return 1;
if (iSaveType == 0 || iSaveType == dbv->type)
@@ -305,9 +305,9 @@ STDMETHODIMP_(BOOL) CDb3Mmap::GetContactSettingStr(HANDLE hContact, LPCSTR szMod return 0;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::GetContactSettingStatic(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
+STDMETHODIMP_(BOOL) CDb3Mmap::GetContactSettingStatic(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
- if (GetContactSettingWorker(hContact, szModule, szSetting, dbv, 1))
+ if (GetContactSettingWorker(contactID, szModule, szSetting, dbv, 1))
return 1;
if (dbv->type == DBVT_UTF8) {
@@ -355,7 +355,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::SetSettingResident(BOOL bIsResident, const char *p return 0;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSetting(HANDLE hContact, DBCONTACTWRITESETTING *dbcws)
+STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws)
{
if (dbcws == NULL || dbcws->szSetting == NULL || dbcws->szModule == NULL || m_bReadOnly)
return 1;
@@ -376,6 +376,10 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT return 1;
}
+ DBCachedContact *cc = m_cache->GetCachedContact(contactID);
+ if (cc == NULL)
+ return 1;
+
// used for notifications
DBCONTACTWRITESETTING dbcwNotif = *dbcws;
if (dbcwNotif.value.type == DBVT_WCHAR) {
@@ -439,7 +443,7 @@ LBL_WriteString: // we don't cache blobs and passwords
if (dbcwWork.value.type != DBVT_BLOB && dbcwWork.value.type != DBVT_ENCRYPTED && !bIsEncrypted) {
- DBVARIANT *pCachedValue = m_cache->GetCachedValuePtr(hContact, szCachedSettingName, 1);
+ DBVARIANT *pCachedValue = m_cache->GetCachedValuePtr(contactID, szCachedSettingName, 1);
if (pCachedValue != NULL) {
bool bIsIdentical = false;
if (pCachedValue->type == dbcwWork.value.type) {
@@ -458,16 +462,16 @@ LBL_WriteString: if (szCachedSettingName[-1] != 0) {
lck.unlock();
log2(" set resident as %s (%p)", printVariant(&dbcwWork.value), pCachedValue);
- NotifyEventHooks(hSettingChangeEvent, (WPARAM)hContact, (LPARAM)&dbcwWork);
+ NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)&dbcwWork);
return 0;
}
}
- else m_cache->GetCachedValuePtr(hContact, szCachedSettingName, -1);
+ else m_cache->GetCachedValuePtr(contactID, szCachedSettingName, -1);
log1(" write database as %s", printVariant(&dbcwWork.value));
DWORD ofsModuleName = GetModuleNameOfs(dbcwWork.szModule);
- DWORD ofsBlobPtr, ofsContact = (hContact == 0) ? m_dbHeader.ofsUser : (DWORD)hContact;
+ DWORD ofsBlobPtr, ofsContact = (contactID == 0) ? m_dbHeader.ofsUser : cc->dwDriverData;
DBContact dbc = *(DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
if (dbc.signature != DBCONTACT_SIGNATURE)
return 1;
@@ -567,7 +571,7 @@ LBL_WriteString: DBFlush(1);
lck.unlock();
// notify
- NotifyEventHooks(hSettingChangeEvent, (WPARAM)hContact, (LPARAM)&dbcwNotif);
+ NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)&dbcwNotif);
return 0;
}
}
@@ -667,11 +671,11 @@ LBL_WriteString: lck.unlock();
// notify
- NotifyEventHooks(hSettingChangeEvent, (WPARAM)hContact, (LPARAM)&dbcwNotif);
+ NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)&dbcwNotif);
return 0;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting)
+STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting)
{
if (!szModule || !szSetting)
return 1;
@@ -692,20 +696,18 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(HANDLE hContact, LPCSTR szMod return 1;
}
- WPARAM saveWparam = (WPARAM)hContact;
+ MCONTACT saveContact = contactID;
char *szCachedSettingName = m_cache->GetCachedSetting(szModule, szSetting, moduleNameLen, settingNameLen);
if (szCachedSettingName[-1] == 0) { // it's not a resident variable
mir_cslock lck(m_csDbAccess);
DWORD ofsModuleName = GetModuleNameOfs(szModule);
- if (hContact == 0)
- hContact = (HANDLE)m_dbHeader.ofsUser;
-
- DBContact *dbc = (DBContact*)DBRead(hContact, sizeof(DBContact), NULL);
+ DWORD ofsContact = GetContactOffset(contactID);
+ DBContact *dbc = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
if (dbc->signature != DBCONTACT_SIGNATURE)
return 1;
// make sure the module group exists
- DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc, (DWORD)hContact, ofsModuleName);
+ DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsContact, ofsModuleName);
if (ofsSettingsGroup == 0)
return 1;
@@ -744,30 +746,33 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(HANDLE hContact, LPCSTR szMod DBFlush(1);
}
- m_cache->GetCachedValuePtr((HANDLE)saveWparam, szCachedSettingName, -1);
+ m_cache->GetCachedValuePtr(saveContact, szCachedSettingName, -1);
// notify
DBCONTACTWRITESETTING dbcws = { 0 };
dbcws.szModule = szModule;
dbcws.szSetting = szSetting;
dbcws.value.type = DBVT_DELETED;
- NotifyEventHooks(hSettingChangeEvent, saveWparam, (LPARAM)&dbcws);
+ NotifyEventHooks(hSettingChangeEvent, saveContact, (LPARAM)&dbcws);
return 0;
}
-STDMETHODIMP_(BOOL) CDb3Mmap::EnumContactSettings(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces)
+STDMETHODIMP_(BOOL) CDb3Mmap::EnumContactSettings(MCONTACT contactID, DBCONTACTENUMSETTINGS* dbces)
{
if (!dbces->szModule)
return -1;
mir_cslock lck(m_csDbAccess);
- DWORD ofsModuleName = GetModuleNameOfs(dbces->szModule);
- DWORD ofsContact = (hContact == 0) ? m_dbHeader.ofsUser : (DWORD)hContact;
+ DWORD ofsContact = GetContactOffset(contactID);
+ if (ofsContact == 0)
+ return -1;
+
DBContact *dbc = (DBContact*)DBRead(ofsContact, sizeof(DBContact), NULL);
if (dbc->signature != DBCONTACT_SIGNATURE)
return -1;
+ DWORD ofsModuleName = GetModuleNameOfs(dbces->szModule);
dbces->ofsSettings = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsContact, ofsModuleName);
if (!dbces->ofsSettings)
return -1;
diff --git a/plugins/Dbx_tree/src/Compatibility.cpp b/plugins/Dbx_tree/src/Compatibility.cpp index d8d119fc25..18b9b6571e 100644 --- a/plugins/Dbx_tree/src/Compatibility.cpp +++ b/plugins/Dbx_tree/src/Compatibility.cpp @@ -37,19 +37,15 @@ HANDLE hEventDeletedEvent, hContactDeletedEvent,
hContactAddedEvent;
-int CDataBase::CheckProto(HANDLE hContact, const char *proto)
+int CDataBase::CheckProto(DBCachedContact *cc, const char *proto)
{
- DBCachedContact *cc = m_cache->GetCachedContact(hContact);
- if (cc == NULL)
- cc = m_cache->AddContactToCache(hContact);
-
if (cc->szProto == NULL) {
char protobuf[MAX_PATH] = {0};
DBVARIANT dbv;
dbv.type = DBVT_ASCIIZ;
dbv.pszVal = protobuf;
dbv.cchVal = sizeof(protobuf);
- if (GetContactSettingStatic(hContact, "Protocol", "p", &dbv) != 0 || (dbv.type != DBVT_ASCIIZ))
+ if (GetContactSettingStatic(cc->contactID, "Protocol", "p", &dbv) != 0 || (dbv.type != DBVT_ASCIIZ))
return 0;
cc->szProto = m_cache->GetCachedSetting(NULL, protobuf, 0, (int)strlen(protobuf));
@@ -68,27 +64,29 @@ STDMETHODIMP_(HANDLE) CDataBase::AddContact(void) if (res == DBT_INVALIDPARAM)
return (HANDLE)1;
+ m_cache->AddContactToCache(res);
+
NotifyEventHooks(hContactAddedEvent, res, 0);
return (HANDLE)res;
}
-STDMETHODIMP_(LONG) CDataBase::DeleteContact(HANDLE hContact)
+STDMETHODIMP_(LONG) CDataBase::DeleteContact(MCONTACT contactID)
{
- NotifyEventHooks(hContactDeletedEvent, (WPARAM)hContact, 0);
+ NotifyEventHooks(hContactDeletedEvent, contactID, 0);
- int res = DBEntityDelete((WPARAM)hContact, 0);
+ int res = DBEntityDelete(contactID, 0);
if (res == DBT_INVALIDPARAM)
return 1;
if (res == 0)
- m_cache->FreeCachedContact(hContact);
+ m_cache->FreeCachedContact(contactID);
return res;
}
-STDMETHODIMP_(BOOL) CDataBase::IsDbContact(HANDLE hContact)
+STDMETHODIMP_(BOOL) CDataBase::IsDbContact(MCONTACT contactID)
{
- int flags = DBEntityGetFlags((WPARAM)hContact, 0);
+ int flags = DBEntityGetFlags(contactID, 0);
return (flags != DBT_INVALIDPARAM) &&
((flags & DBT_NFM_SpecialEntity) == 0);
}
@@ -118,36 +116,32 @@ STDMETHODIMP_(LONG) CDataBase::GetContactCount(void) return c;
}
-STDMETHODIMP_(HANDLE) CDataBase::FindFirstContact(const char* szProto)
+STDMETHODIMP_(MCONTACT) CDataBase::FindFirstContact(const char* szProto)
{
- HANDLE hContact = (HANDLE)getEntities().compFirstContact();
- if (!szProto || CheckProto(hContact, szProto))
- return hContact;
+ DBCachedContact *cc = m_cache->GetFirstContact();
+ if (cc == NULL)
+ return NULL;
+
+ if (!szProto || CheckProto(cc, szProto))
+ return cc->contactID;
- return FindNextContact(hContact, szProto);
+ return FindNextContact(cc->contactID, szProto);
}
-STDMETHODIMP_(HANDLE) CDataBase::FindNextContact(HANDLE hContact, const char* szProto)
+STDMETHODIMP_(MCONTACT) CDataBase::FindNextContact(MCONTACT contactID, const char* szProto)
{
- while (hContact) {
- DBCachedContact *VL = m_cache->GetCachedContact(hContact);
- if (VL == NULL)
- VL = m_cache->AddContactToCache(hContact);
+ while (contactID) {
+ DBCachedContact *cc = m_cache->GetNextContact(contactID);
+ if (cc == NULL)
+ break;
- if (VL->hNext != NULL) {
- if (!szProto || CheckProto(VL->hNext, szProto))
- return VL->hNext;
+ if (!szProto || CheckProto(cc, szProto))
+ return cc->contactID;
- hContact = VL->hNext;
- continue;
- }
-
- VL->hNext = (HANDLE)getEntities().compNextContact((WPARAM)hContact);
- if (VL->hNext != NULL && (!szProto || CheckProto(VL->hNext, szProto)))
- return VL->hNext;
-
- hContact = VL->hNext;
+ contactID = cc->contactID;
+ continue;
}
+
return NULL;
}
@@ -189,7 +183,7 @@ __forceinline void DecodeString(LPSTR buf) /////////////////////////////////////////////////////////////////////////////////////////
-STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
+STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
dbv->type = 0;
@@ -208,7 +202,7 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(HANDLE hContact, LPCSTR szModul TDBTSettingDescriptor desc = {0,0,0,0,0,0,0,0};
TDBTSetting set = {0,0,0,0};
desc.cbSize = sizeof(desc);
- desc.Entity = (WPARAM)hContact;
+ desc.Entity = contactID;
desc.pszSettingName = namebuf;
set.cbSize = sizeof(set);
@@ -277,7 +271,7 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(HANDLE hContact, LPCSTR szModul return 0;
}
-STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
+STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
if ((dbv->type & DBVTF_VARIABLELENGTH) == 0)
{
@@ -296,7 +290,7 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, LPCSTR szMo TDBTSettingDescriptor desc = {0,0,0,0,0,0,0,0};
TDBTSetting set = {0,0,0,0};
desc.cbSize = sizeof(desc);
- desc.Entity = (WPARAM)hContact;
+ desc.Entity = contactID;
desc.pszSettingName = namebuf;
set.cbSize = sizeof(set);
@@ -376,7 +370,7 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, LPCSTR szMo return 0;
}
-STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
+STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
char namebuf[512];
namebuf[0] = 0;
@@ -389,7 +383,7 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, LPCSTR s TDBTSettingDescriptor desc = {0,0,0,0,0,0,0,0};
TDBTSetting set = {0,0,0,0};
desc.cbSize = sizeof(desc);
- desc.Entity = (WPARAM)hContact;
+ desc.Entity = contactID;
desc.pszSettingName = namebuf;
set.cbSize = sizeof(set);
@@ -504,7 +498,7 @@ STDMETHODIMP_(BOOL) CDataBase::FreeVariant(DBVARIANT *dbv) return 0;
}
-STDMETHODIMP_(BOOL) CDataBase::WriteContactSetting(HANDLE hContact, DBCONTACTWRITESETTING *dbcws)
+STDMETHODIMP_(BOOL) CDataBase::WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws)
{
char namebuf[512];
namebuf[0] = 0;
@@ -517,7 +511,7 @@ STDMETHODIMP_(BOOL) CDataBase::WriteContactSetting(HANDLE hContact, DBCONTACTWRI TDBTSettingDescriptor desc = {0,0,0,0,0,0,0,0};
TDBTSetting set = {0,0,0,0};
desc.cbSize = sizeof(desc);
- desc.Entity = (WPARAM)hContact;
+ desc.Entity = contactID;
desc.pszSettingName = namebuf;
set.cbSize = sizeof(set);
@@ -586,17 +580,17 @@ STDMETHODIMP_(BOOL) CDataBase::WriteContactSetting(HANDLE hContact, DBCONTACTWRI dbcws->value.type = DBVT_UTF8;
wchar_t * tmp = dbcws->value.pwszVal;
dbcws->value.pszVal = mir_utf8encodeW(dbcws->value.pwszVal);
- NotifyEventHooks(hSettingChangeEvent, (WPARAM)hContact, (LPARAM)dbcws);
+ NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)dbcws);
mir_free(dbcws->value.pszVal);
dbcws->value.type = DBVT_WCHAR;
dbcws->value.pwszVal = tmp;
}
- else NotifyEventHooks(hSettingChangeEvent, (WPARAM)hContact, (LPARAM)dbcws);
+ else NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)dbcws);
return 0;
}
-STDMETHODIMP_(BOOL) CDataBase::DeleteContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting)
+STDMETHODIMP_(BOOL) CDataBase::DeleteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting)
{
char namebuf[512];
namebuf[0] = 0;
@@ -608,7 +602,7 @@ STDMETHODIMP_(BOOL) CDataBase::DeleteContactSetting(HANDLE hContact, LPCSTR szMo TDBTSettingDescriptor desc = {0,0,0,0,0,0,0,0};
desc.cbSize = sizeof(desc);
- desc.Entity = (WPARAM)hContact;
+ desc.Entity = contactID;
desc.pszSettingName = namebuf;
if (DBSettingDelete(reinterpret_cast<WPARAM>(&desc), 0) == DBT_INVALIDPARAM)
@@ -619,17 +613,17 @@ STDMETHODIMP_(BOOL) CDataBase::DeleteContactSetting(HANDLE hContact, LPCSTR szMo tmp.szModule = szModule;
tmp.szSetting = szSetting;
tmp.value.type = 0;
- NotifyEventHooks(hSettingChangeEvent, (WPARAM)hContact, (LPARAM)&tmp);
+ NotifyEventHooks(hSettingChangeEvent, contactID, (LPARAM)&tmp);
}
return 0;
}
-STDMETHODIMP_(BOOL) CDataBase::EnumContactSettings(HANDLE hContact, DBCONTACTENUMSETTINGS* pces)
+STDMETHODIMP_(BOOL) CDataBase::EnumContactSettings(MCONTACT contactID, DBCONTACTENUMSETTINGS* pces)
{
TDBTSettingDescriptor desc = {0,0,0,0,0,0,0,0};
desc.cbSize = sizeof(desc);
- desc.Entity = (WPARAM)hContact;
+ desc.Entity = contactID;
char namebuf[512];
namebuf[0] = 0;
@@ -640,7 +634,7 @@ STDMETHODIMP_(BOOL) CDataBase::EnumContactSettings(HANDLE hContact, DBCONTACTENU TDBTSettingIterFilter filter = {0,0,0,0,0,0,0,0};
filter.cbSize = sizeof(filter);
filter.Descriptor = &desc;
- filter.hEntity = (WPARAM)(WPARAM)hContact;
+ filter.hEntity = (WPARAM)contactID;
filter.NameStart = namebuf;
TDBTSettingIterationHandle hiter = DBSettingIterInit(reinterpret_cast<WPARAM>(&filter), 0);
@@ -675,26 +669,25 @@ STDMETHODIMP_(BOOL) CDataBase::EnumContactSettings(HANDLE hContact, DBCONTACTENU return res;
}
-STDMETHODIMP_(LONG) CDataBase::GetEventCount(HANDLE hContact)
+STDMETHODIMP_(LONG) CDataBase::GetEventCount(MCONTACT contactID)
{
- if (hContact == 0)
- hContact = (HANDLE)getEntities().getRootEntity();
+ if (contactID == 0)
+ contactID = getEntities().getRootEntity();
- return DBEventGetCount((WPARAM)hContact, 0);
+ return DBEventGetCount(contactID, 0);
}
-STDMETHODIMP_(HANDLE) CDataBase::AddEvent(HANDLE hContact, DBEVENTINFO *dbei)
+STDMETHODIMP_(HANDLE) CDataBase::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
{
if (dbei->cbSize < sizeof(DBEVENTINFO))
return (HANDLE)-1;
- int tmp = NotifyEventHooks(hEventFilterAddedEvent, (WPARAM)hContact, (LPARAM)dbei);
+ int tmp = NotifyEventHooks(hEventFilterAddedEvent, contactID, (LPARAM)dbei);
if (tmp != 0)
return (HANDLE)tmp;
- if (hContact == 0)
- hContact = (HANDLE)getEntities().getRootEntity();
-
+ if (contactID == 0)
+ contactID = getEntities().getRootEntity();
TDBTEvent ev = {0,0,0,0,0,0,0};
ev.cbSize = sizeof(ev);
@@ -707,21 +700,21 @@ STDMETHODIMP_(HANDLE) CDataBase::AddEvent(HANDLE hContact, DBEVENTINFO *dbei) ev.cbBlob = dbei->cbBlob;
ev.pBlob = dbei->pBlob;
- int res = DBEventAdd((WPARAM)hContact, reinterpret_cast<LPARAM>(&ev));
+ int res = DBEventAdd(contactID, reinterpret_cast<LPARAM>(&ev));
if (res != DBT_INVALIDPARAM)
{
- NotifyEventHooks(hEventAddedEvent, (WPARAM)hContact, res);
+ NotifyEventHooks(hEventAddedEvent, contactID, res);
return (HANDLE)res;
}
return NULL;
}
-STDMETHODIMP_(BOOL) CDataBase::DeleteEvent(HANDLE hContact, HANDLE hDbEvent)
+STDMETHODIMP_(BOOL) CDataBase::DeleteEvent(MCONTACT contactID, HANDLE hDbEvent)
{
- int res = NotifyEventHooks(hEventDeletedEvent, (WPARAM)hContact, (WPARAM)hDbEvent);
+ int res = NotifyEventHooks(hEventDeletedEvent, contactID, (WPARAM)hDbEvent);
- if (hContact == 0)
- hContact = (HANDLE)getEntities().getRootEntity();
+ if (contactID == 0)
+ contactID = getEntities().getRootEntity();
if (res == 0)
return DBEventDelete((WPARAM)hDbEvent, 0);
@@ -773,7 +766,7 @@ STDMETHODIMP_(BOOL) CDataBase::GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbei) return res;
}
-STDMETHODIMP_(BOOL) CDataBase::MarkEventRead(HANDLE hContact, HANDLE hDbEvent)
+STDMETHODIMP_(BOOL) CDataBase::MarkEventRead(MCONTACT contactID, HANDLE hDbEvent)
{
int res = DBEventMarkRead((WPARAM)hDbEvent, 0);
if ((res != DBT_INVALIDPARAM) && (res & DBEF_SENT))
@@ -790,26 +783,26 @@ STDMETHODIMP_(HANDLE) CDataBase::GetEventContact(HANDLE hDbEvent) return (HANDLE)res;
}
-STDMETHODIMP_(HANDLE) CDataBase::FindFirstEvent(HANDLE hContact)
+STDMETHODIMP_(HANDLE) CDataBase::FindFirstEvent(MCONTACT contactID)
{
- if (hContact == 0)
- hContact = (HANDLE)getEntities().getRootEntity();
+ if (contactID == 0)
+ contactID = getEntities().getRootEntity();
- return (HANDLE)getEvents().compFirstEvent((WPARAM)hContact);
+ return (HANDLE)getEvents().compFirstEvent(contactID);
}
-STDMETHODIMP_(HANDLE) CDataBase::FindFirstUnreadEvent(HANDLE hContact)
+STDMETHODIMP_(HANDLE) CDataBase::FindFirstUnreadEvent(MCONTACT contactID)
{
- if (hContact == 0)
- hContact = (HANDLE)getEntities().getRootEntity();
- return (HANDLE)getEvents().compFirstUnreadEvent((WPARAM)hContact);
+ if (contactID == 0)
+ contactID = getEntities().getRootEntity();
+ return (HANDLE)getEvents().compFirstUnreadEvent(contactID);
}
-STDMETHODIMP_(HANDLE) CDataBase::FindLastEvent(HANDLE hContact)
+STDMETHODIMP_(HANDLE) CDataBase::FindLastEvent(MCONTACT contactID)
{
- if (hContact == 0)
- hContact = (HANDLE)getEntities().getRootEntity();
- return (HANDLE)getEvents().compLastEvent((WPARAM)hContact);
+ if (contactID == 0)
+ contactID = getEntities().getRootEntity();
+ return (HANDLE)getEvents().compLastEvent(contactID);
}
STDMETHODIMP_(HANDLE) CDataBase::FindNextEvent(HANDLE hDbEvent)
diff --git a/plugins/Dbx_tree/src/DataBase.cpp b/plugins/Dbx_tree/src/DataBase.cpp index 683f0b66a8..465ceae643 100644 --- a/plugins/Dbx_tree/src/DataBase.cpp +++ b/plugins/Dbx_tree/src/DataBase.cpp @@ -243,6 +243,11 @@ int CDataBase::OpenDB() *m_Entities,
*m_Settings);
+ for (MCONTACT id = m_Entities->compFirstContact(); id != 0; id = m_Entities->compNextContact(id)) {
+ DBCachedContact *cc = m_cache->AddContactToCache(id);
+ CheckProto(cc, "");
+ }
+
return 0;
}
diff --git a/plugins/Dbx_tree/src/DataBase.h b/plugins/Dbx_tree/src/DataBase.h index 0cff291944..b19ceebb1c 100644 --- a/plugins/Dbx_tree/src/DataBase.h +++ b/plugins/Dbx_tree/src/DataBase.h @@ -196,37 +196,37 @@ protected: // to be compatible with the standard Miranda databases STDMETHODIMP_(void) SetCacheSafetyMode(BOOL);
STDMETHODIMP_(LONG) GetContactCount(void);
- STDMETHODIMP_(HANDLE) FindFirstContact(const char* szProto = NULL);
- STDMETHODIMP_(HANDLE) FindNextContact(HANDLE hContact, const char* szProto = NULL);
- STDMETHODIMP_(LONG) DeleteContact(HANDLE hContact);
+ 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(HANDLE hContact);
+ STDMETHODIMP_(BOOL) IsDbContact(MCONTACT contactID);
- STDMETHODIMP_(LONG) GetEventCount(HANDLE hContact);
- STDMETHODIMP_(HANDLE) AddEvent(HANDLE hContact, DBEVENTINFO *dbe);
- STDMETHODIMP_(BOOL) DeleteEvent(HANDLE hContact, HANDLE hDbEvent);
+ STDMETHODIMP_(LONG) GetEventCount(MCONTACT contactID);
+ STDMETHODIMP_(HANDLE) AddEvent(MCONTACT contactID, DBEVENTINFO *dbe);
+ STDMETHODIMP_(BOOL) DeleteEvent(MCONTACT contactID, HANDLE hDbEvent);
STDMETHODIMP_(LONG) GetBlobSize(HANDLE hDbEvent);
STDMETHODIMP_(BOOL) GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbe);
- STDMETHODIMP_(BOOL) MarkEventRead(HANDLE hContact, HANDLE hDbEvent);
+ STDMETHODIMP_(BOOL) MarkEventRead(MCONTACT contactID, HANDLE hDbEvent);
STDMETHODIMP_(HANDLE) GetEventContact(HANDLE hDbEvent);
- STDMETHODIMP_(HANDLE) FindFirstEvent(HANDLE hContact);
- STDMETHODIMP_(HANDLE) FindFirstUnreadEvent(HANDLE hContact);
- STDMETHODIMP_(HANDLE) FindLastEvent(HANDLE hContact);
+ STDMETHODIMP_(HANDLE) FindFirstEvent(MCONTACT contactID);
+ STDMETHODIMP_(HANDLE) FindFirstUnreadEvent(MCONTACT contactID);
+ STDMETHODIMP_(HANDLE) FindLastEvent(MCONTACT contactID);
STDMETHODIMP_(HANDLE) FindNextEvent(HANDLE hDbEvent);
STDMETHODIMP_(HANDLE) FindPrevEvent(HANDLE hDbEvent);
STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam);
- STDMETHODIMP_(BOOL) GetContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
- STDMETHODIMP_(BOOL) GetContactSettingStr(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
- STDMETHODIMP_(BOOL) GetContactSettingStatic(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+ STDMETHODIMP_(BOOL) GetContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+ STDMETHODIMP_(BOOL) GetContactSettingStr(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
+ STDMETHODIMP_(BOOL) GetContactSettingStatic(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv);
STDMETHODIMP_(BOOL) FreeVariant(DBVARIANT *dbv);
- STDMETHODIMP_(BOOL) WriteContactSetting(HANDLE hContact, DBCONTACTWRITESETTING *dbcws);
- STDMETHODIMP_(BOOL) DeleteContactSetting(HANDLE hContact, LPCSTR szModule, LPCSTR szSetting);
- STDMETHODIMP_(BOOL) EnumContactSettings(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces);
+ 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) SetSettingResident(BOOL bIsResident, const char *pszSettingName);
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
STDMETHODIMP_(BOOL) IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting);
- int CheckProto(HANDLE hContact, const char *proto);
+ int CheckProto(DBCachedContact *cc, const char *proto);
};
diff --git a/plugins/Dbx_tree/src/Services.cpp b/plugins/Dbx_tree/src/Services.cpp index f7495e2225..412b05d76b 100644 --- a/plugins/Dbx_tree/src/Services.cpp +++ b/plugins/Dbx_tree/src/Services.cpp @@ -369,7 +369,7 @@ void CDataBase::CreateDbService(const char* szService, DbServiceFunc serviceProc bool CDataBase::RegisterServices()
{
- CreateDbService(MS_DBT_ENTITY_GETROOT, &CDataBase::DBEntityGetRoot);
+ CreateDbService(MS_DBT_ENTITY_GETROOT, &CDataBase::DBEntityGetRoot);
CreateDbService(MS_DBT_ENTITY_CHILDCOUNT, &CDataBase::DBEntityChildCount);
CreateDbService(MS_DBT_ENTITY_GETPARENT, &CDataBase::DBEntityGetParent);
CreateDbService(MS_DBT_ENTITY_MOVE, &CDataBase::DBEntityMove);
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 7d15029661..dbb6e5a02b 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -31,26 +31,26 @@ static MIDatabase *srcDb, *dstDb; /////////////////////////////////////////////////////////////////////////////////////////
-static int myGet(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv)
+static int myGet(MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv)
{
dbv->type = 0;
return srcDb->GetContactSetting(hContact, szModule, szSetting, dbv);
}
-static TCHAR* myGetWs(HANDLE hContact, const char *szModule, const char *szSetting)
+static TCHAR* myGetWs(MCONTACT hContact, const char *szModule, const char *szSetting)
{
DBVARIANT dbv = { DBVT_TCHAR };
return srcDb->GetContactSettingStr(hContact, szModule, szSetting, &dbv) ? NULL : dbv.ptszVal;
}
-static BOOL myGetS(HANDLE hContact, const char *szModule, const char *szSetting, char* dest)
+static BOOL myGetS(MCONTACT hContact, const char *szModule, const char *szSetting, char* dest)
{
DBVARIANT dbv = { DBVT_ASCIIZ };
dbv.pszVal = dest; dbv.cchVal = 100;
return srcDb->GetContactSettingStatic(hContact, szModule, szSetting, &dbv);
}
-static void mySet(HANDLE hContact, const char *module, const char *var, DBVARIANT *dbv)
+static void mySet(MCONTACT hContact, const char *module, const char *var, DBVARIANT *dbv)
{
DBCONTACTWRITESETTING dbw;
dbw.szModule = module;
@@ -61,79 +61,79 @@ static void mySet(HANDLE hContact, const char *module, const char *var, DBVARIAN /////////////////////////////////////////////////////////////////////////////////////////
-static HANDLE HContactFromNumericID(char* pszProtoName, char* pszSetting, DWORD dwID)
+static MCONTACT HContactFromNumericID(char *pszProtoName, char *pszSetting, DWORD dwID)
{
- HANDLE hContact = dstDb->FindFirstContact();
+ MCONTACT hContact = dstDb->FindFirstContact();
while (hContact != NULL) {
- if ( db_get_dw(hContact, pszProtoName, pszSetting, 0) == dwID) {
- char* szProto = GetContactProto(hContact);
+ if ( db_get_dw((HANDLE)hContact, pszProtoName, pszSetting, 0) == dwID) {
+ char* szProto = GetContactProto((HANDLE)hContact);
if (szProto != NULL && !lstrcmpA(szProto, pszProtoName))
return hContact;
}
- hContact = dstDb->FindNextContact(hContact);
+ hContact = dstDb->FindNextContact((MCONTACT)hContact);
}
- return INVALID_HANDLE_VALUE;
+ return INVALID_CONTACT_ID;
}
-static HANDLE HContactFromID(char* pszProtoName, char* pszSetting, TCHAR* pwszID)
+static MCONTACT HContactFromID(char *pszProtoName, char *pszSetting, TCHAR *pwszID)
{
- HANDLE hContact = dstDb->FindFirstContact();
+ MCONTACT hContact = dstDb->FindFirstContact();
while (hContact != NULL) {
- char* szProto = GetContactProto(hContact);
+ char* szProto = GetContactProto((HANDLE)hContact);
if ( !lstrcmpA(szProto, pszProtoName)) {
- ptrW id( db_get_tsa(hContact, pszProtoName, pszSetting));
+ ptrW id(db_get_tsa((HANDLE)hContact, pszProtoName, pszSetting));
if ( !lstrcmp(pwszID, id))
return hContact;
}
- hContact = dstDb->FindNextContact(hContact);
+ hContact = (MCONTACT)dstDb->FindNextContact(hContact);
}
- return INVALID_HANDLE_VALUE;
+ return INVALID_CONTACT_ID;
}
-static HANDLE HistoryImportFindContact(HWND hdlgProgress, char* szModuleName, DWORD uin, int addUnknown)
+static MCONTACT HistoryImportFindContact(HWND hdlgProgress, char* szModuleName, DWORD uin, int addUnknown)
{
- HANDLE hContact = HContactFromNumericID(szModuleName, "UIN", uin);
+ MCONTACT hContact = HContactFromNumericID(szModuleName, "UIN", uin);
if (hContact == NULL) {
AddMessage( LPGENT("Ignored event from/to self"));
- return INVALID_HANDLE_VALUE;
+ return INVALID_CONTACT_ID;
}
- if (hContact != INVALID_HANDLE_VALUE)
+ if (hContact != INVALID_CONTACT_ID)
return hContact;
if (!addUnknown)
- return INVALID_HANDLE_VALUE;
+ return INVALID_CONTACT_ID;
- hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)szModuleName);
- db_set_dw(hContact, szModuleName, "UIN", uin);
+ hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)szModuleName);
+ db_set_dw((HANDLE)hContact, szModuleName, "UIN", uin);
AddMessage( LPGENT("Added contact %u (found in history)"), uin );
return hContact;
}
/////////////////////////////////////////////////////////////////////////////////////////
-static HANDLE AddContact(HWND hdlgProgress, char* szProto, char* pszUniqueSetting, DBVARIANT* id, const TCHAR* pszUserID, TCHAR *nick, TCHAR *group)
+static MCONTACT AddContact(HWND hdlgProgress, char* szProto, char* pszUniqueSetting, DBVARIANT* id, const TCHAR* pszUserID, TCHAR *nick, TCHAR *group)
{
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
- if ( CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)szProto) != 0) {
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
- AddMessage( LPGENT("Failed to add %S contact %s"), szProto, pszUserID );
- return INVALID_HANDLE_VALUE;
+ MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ if (CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)szProto) != 0) {
+ CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ AddMessage(LPGENT("Failed to add %S contact %s"), szProto, pszUserID);
+ return INVALID_CONTACT_ID;
}
- mySet( hContact, szProto, pszUniqueSetting, id );
+ mySet(hContact, szProto, pszUniqueSetting, id);
- CreateGroup(group, hContact);
+ CreateGroup(group, (HANDLE)hContact);
if (nick && *nick) {
- db_set_ws(hContact, "CList", "MyHandle", nick );
- AddMessage( LPGENT("Added %S contact %s, '%s'"), szProto, pszUserID, nick);
+ db_set_ws((HANDLE)hContact, "CList", "MyHandle", nick);
+ AddMessage(LPGENT("Added %S contact %s, '%s'"), szProto, pszUserID, nick);
}
- else AddMessage( LPGENT("Added %S contact %s"), szProto, pszUserID);
+ else AddMessage(LPGENT("Added %S contact %s"), szProto, pszUserID);
- srcDb->FreeVariant( id );
+ srcDb->FreeVariant(id);
return hContact;
}
@@ -164,33 +164,33 @@ static int ImportGroups() return nGroups;
}
-static HANDLE ImportContact(HANDLE hSrc)
+static MCONTACT ImportContact(MCONTACT hSrc)
{
- HANDLE hDst;
+ MCONTACT hDst;
TCHAR id[ 40 ], *pszUniqueID;
char szProto[100];
// Check what protocol this contact belongs to
- if ( myGetS(hSrc, "Protocol", "p", szProto)) {
- AddMessage( LPGENT("Skipping contact with no protocol"));
+ if (myGetS(hSrc, "Protocol", "p", szProto)) {
+ AddMessage(LPGENT("Skipping contact with no protocol"));
return NULL;
}
- if ( !IsProtocolLoaded(szProto)) {
- AddMessage( LPGENT("Skipping contact, %S not installed."), szProto);
+ if (!IsProtocolLoaded(szProto)) {
+ AddMessage(LPGENT("Skipping contact, %S not installed."), szProto);
return NULL;
}
// Skip protocols with no unique id setting (some non IM protocols return NULL)
char* pszUniqueSetting = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if ( !pszUniqueSetting || (INT_PTR)pszUniqueSetting == CALLSERVICE_NOTFOUND ) {
- AddMessage( LPGENT("Skipping non-IM contact (%S)"), szProto );
+ if (!pszUniqueSetting || (INT_PTR)pszUniqueSetting == CALLSERVICE_NOTFOUND) {
+ AddMessage(LPGENT("Skipping non-IM contact (%S)"), szProto);
return NULL;
}
DBVARIANT dbv;
- if ( myGet(hSrc, szProto, pszUniqueSetting, &dbv)) {
- AddMessage( LPGENT("Skipping %S contact, ID not found"), szProto);
+ if (myGet(hSrc, szProto, pszUniqueSetting, &dbv)) {
+ AddMessage(LPGENT("Skipping %S contact, ID not found"), szProto);
return NULL;
}
@@ -198,11 +198,11 @@ static HANDLE ImportContact(HANDLE hSrc) switch (dbv.type) {
case DBVT_DWORD:
pszUniqueID = _ltot(dbv.dVal, id, 10);
- hDst = HContactFromNumericID( szProto, pszUniqueSetting, dbv.dVal );
+ hDst = HContactFromNumericID(szProto, pszUniqueSetting, dbv.dVal);
break;
case DBVT_ASCIIZ:
- pszUniqueID = NEWTSTR_ALLOCA( _A2T(dbv.pszVal));
+ pszUniqueID = NEWTSTR_ALLOCA(_A2T(dbv.pszVal));
hDst = HContactFromID(szProto, pszUniqueSetting, pszUniqueID);
break;
@@ -212,9 +212,9 @@ static HANDLE ImportContact(HANDLE hSrc) break;
}
- if (hDst != INVALID_HANDLE_VALUE) {
- AddMessage( LPGENT("Skipping duplicate %S contact %s"), szProto, pszUniqueID );
- srcDb->FreeVariant( &dbv );
+ if (hDst != INVALID_CONTACT_ID) {
+ AddMessage(LPGENT("Skipping duplicate %S contact %s"), szProto, pszUniqueID);
+ srcDb->FreeVariant(&dbv);
return NULL;
}
@@ -225,56 +225,56 @@ static HANDLE ImportContact(HANDLE hSrc) hDst = AddContact(hdlgProgress, szProto, pszUniqueSetting, &dbv, pszUniqueID, tszNick, tszGroup);
mir_free(tszGroup), mir_free(tszNick);
- if ( hDst != INVALID_HANDLE_VALUE) {
+ if (hDst != INVALID_CONTACT_ID) {
// Hidden?
- if ( !myGet(hSrc, "CList", "Hidden", &dbv )) {
+ if (!myGet(hSrc, "CList", "Hidden", &dbv)) {
mySet(hDst, "CList", "Hidden", &dbv);
srcDb->FreeVariant(&dbv);
}
// Ignore settings
- if ( !myGet(hSrc, "Ignore", "Mask1", &dbv )) {
- mySet( hDst, "Ignore", "Mask1", &dbv );
+ if (!myGet(hSrc, "Ignore", "Mask1", &dbv)) {
+ mySet(hDst, "Ignore", "Mask1", &dbv);
srcDb->FreeVariant(&dbv);
}
// Apparent mode
- if ( !myGet(hSrc, szProto, "ApparentMode", &dbv )) {
- mySet( hDst, szProto, "ApparentMode", &dbv );
+ if (!myGet(hSrc, szProto, "ApparentMode", &dbv)) {
+ mySet(hDst, szProto, "ApparentMode", &dbv);
srcDb->FreeVariant(&dbv);
}
// Nick
- if ( !myGet(hSrc, szProto, "Nick", &dbv )) {
- mySet( hDst, szProto, "Nick", &dbv );
+ if (!myGet(hSrc, szProto, "Nick", &dbv)) {
+ mySet(hDst, szProto, "Nick", &dbv);
srcDb->FreeVariant(&dbv);
}
// Myhandle
- if ( !myGet(hSrc, szProto, "MyHandle", &dbv )) {
- mySet( hDst, szProto, "MyHandle", &dbv );
+ if (!myGet(hSrc, szProto, "MyHandle", &dbv)) {
+ mySet(hDst, szProto, "MyHandle", &dbv);
srcDb->FreeVariant(&dbv);
}
// First name
- if ( !myGet(hSrc, szProto, "FirstName", &dbv )) {
- mySet( hDst, szProto, "FirstName", &dbv );
+ if (!myGet(hSrc, szProto, "FirstName", &dbv)) {
+ mySet(hDst, szProto, "FirstName", &dbv);
srcDb->FreeVariant(&dbv);
}
// Last name
- if ( !myGet(hSrc, szProto, "LastName", &dbv )) {
- mySet( hDst, szProto, "LastName", &dbv );
+ if (!myGet(hSrc, szProto, "LastName", &dbv)) {
+ mySet(hDst, szProto, "LastName", &dbv);
srcDb->FreeVariant(&dbv);
}
// About
- if ( !myGet(hSrc, szProto, "About", &dbv )) {
- mySet( hDst, szProto, "About", &dbv );
+ if (!myGet(hSrc, szProto, "About", &dbv)) {
+ mySet(hDst, szProto, "About", &dbv);
srcDb->FreeVariant(&dbv);
}
}
- else AddMessage( LPGENT("Unknown error while adding %S contact %s"), szProto, pszUniqueID );
+ else AddMessage(LPGENT("Unknown error while adding %S contact %s"), szProto, pszUniqueID);
return hDst;
}
@@ -284,28 +284,28 @@ static HANDLE ImportContact(HANDLE hSrc) // would only be a repetition of the messages printed during contact
// import.
-static HANDLE convertContact(HANDLE hContact)
+static MCONTACT convertContact(MCONTACT hContact)
{
// Check what protocol this contact belongs to
char szProto[100];
- if ( myGetS(hContact, "Protocol", "p", szProto))
- return INVALID_HANDLE_VALUE;
+ if (myGetS(hContact, "Protocol", "p", szProto))
+ return INVALID_CONTACT_ID;
// Protocol installed?
- if ( !IsProtocolLoaded(szProto))
- return INVALID_HANDLE_VALUE;
+ if (!IsProtocolLoaded(szProto))
+ return INVALID_CONTACT_ID;
// Is contact in database?
char* pszUniqueSetting = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
// Skip protocols with no unique id setting (some non IM protocols return NULL)
- HANDLE hDst = INVALID_HANDLE_VALUE;
- if ( pszUniqueSetting && ( INT_PTR )pszUniqueSetting != CALLSERVICE_NOTFOUND ) {
+ MCONTACT hDst = INVALID_CONTACT_ID;
+ if (pszUniqueSetting && (INT_PTR)pszUniqueSetting != CALLSERVICE_NOTFOUND) {
DBVARIANT dbv;
- if ( !myGet(hContact, szProto, pszUniqueSetting, &dbv)) {
+ if (!myGet(hContact, szProto, pszUniqueSetting, &dbv)) {
switch (dbv.type) {
case DBVT_DWORD:
- hDst = HContactFromNumericID( szProto, pszUniqueSetting, dbv.dVal );
+ hDst = HContactFromNumericID(szProto, pszUniqueSetting, dbv.dVal);
break;
case DBVT_ASCIIZ:
@@ -316,19 +316,19 @@ static HANDLE convertContact(HANDLE hContact) hDst = HContactFromID(szProto, pszUniqueSetting, dbv.ptszVal);
break;
}
- srcDb->FreeVariant( &dbv );
+ srcDb->FreeVariant(&dbv);
}
}
return hDst;
}
-static void ImportHistory(HANDLE hContact, PROTOACCOUNT **protocol, int protoCount)
+static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoCount)
{
// Is it contats history import?
- HANDLE hDst = (protoCount == 0) ? convertContact(hContact) : NULL; //system history import
+ MCONTACT hDst = (protoCount == 0) ? convertContact(hContact) : NULL; //system history import
// OK to import this chain?
- if (hDst == INVALID_HANDLE_VALUE) {
+ if (hDst == INVALID_CONTACT_ID) {
nSkippedContacts++;
return;
}
@@ -347,17 +347,17 @@ static void ImportHistory(HANDLE hContact, PROTOACCOUNT **protocol, int protoCou DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.cbBlob = srcDb->GetBlobSize(hEvent);
if (dbei.cbBlob > cbAlloc) {
- cbAlloc = dbei.cbBlob + 4096 - dbei.cbBlob%4096;
+ cbAlloc = dbei.cbBlob + 4096 - dbei.cbBlob % 4096;
eventBuf = (PBYTE)mir_realloc(eventBuf, cbAlloc);
}
dbei.pBlob = eventBuf;
- if ( !srcDb->GetEvent(hEvent, &dbei)) {
+ if (!srcDb->GetEvent(hEvent, &dbei)) {
// check protocols during system history import
if (hDst == NULL) {
skipAll = 1;
for (int i = 0; i < protoCount; i++)
- if ( !strcmp(dbei.szModule, protocol[i]->szModuleName)) {
+ if (!strcmp(dbei.szModule, protocol[i]->szModuleName)) {
skipAll = 0;
break;
}
@@ -375,7 +375,7 @@ static void ImportHistory(HANDLE hContact, PROTOACCOUNT **protocol, int protoCou if (!skip) {
if (hDst) {
skip = 1;
- switch(dbei.eventType) {
+ switch (dbei.eventType) {
case EVENTTYPE_MESSAGE:
if ((sent ? IOPT_MSGSENT : IOPT_MSGRECV) & nCustomOptions)
skip = 0;
@@ -394,7 +394,7 @@ static void ImportHistory(HANDLE hContact, PROTOACCOUNT **protocol, int protoCou break;
}
}
- else if ( !( nCustomOptions & IOPT_SYSTEM ))
+ else if (!(nCustomOptions & IOPT_SYSTEM))
skip = 1;
}
@@ -404,29 +404,30 @@ static void ImportHistory(HANDLE hContact, PROTOACCOUNT **protocol, int protoCou if (!skip) {
// Check for duplicate entries
- if ( !IsDuplicateEvent( hDst, dbei )) {
+ if (!IsDuplicateEvent((HANDLE)hDst, dbei)) {
// Add dbevent
if (!bIsVoidContact)
dbei.flags &= ~DBEF_FIRST;
if (dstDb->AddEvent(hDst, &dbei) != NULL)
nMessagesCount++;
else
- AddMessage( LPGENT("Failed to add message"));
+ AddMessage(LPGENT("Failed to add message"));
}
else
nDupes++;
}
}
- if ( !( i%10 )) {
+ if (!(i % 10)) {
MSG msg;
- if ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
- } }
+ }
+ }
// skip this chain if needed
- if ( skipAll )
+ if (skipAll)
break;
// Get next event
@@ -446,20 +447,20 @@ void MirandaImport(HWND hdlg) // Just to keep the macros happy
hdlgProgress = hdlg;
if ((dstDb = GetCurrentDatabase()) == NULL) {
- AddMessage( LPGENT("Error retrieving current profile, exiting."));
+ AddMessage(LPGENT("Error retrieving current profile, exiting."));
return;
}
DATABASELINK* dblink = FindDatabasePlugin(importFile);
if (dblink == NULL) {
- AddMessage( LPGENT("There's no database driver to open the input file, exiting."));
+ AddMessage(LPGENT("There's no database driver to open the input file, exiting."));
return;
}
if ((srcDb = dblink->Load(importFile)) == NULL) {
- AddMessage( LPGENT("Error loading source file, exiting."));
+ AddMessage(LPGENT("Error loading source file, exiting."));
return;
- }
+ }
// Reset statistics
nSkippedEvents = 0;
@@ -472,8 +473,8 @@ void MirandaImport(HWND hdlg) // Get number of contacts
int nNumberOfContacts = srcDb->GetContactCount();
- AddMessage( LPGENT("Number of contacts in database: %d"), nNumberOfContacts );
- AddMessage( _T(""));
+ AddMessage(LPGENT("Number of contacts in database: %d"), nNumberOfContacts);
+ AddMessage(_T(""));
// Configure database for fast writing
dstDb->SetCacheSafetyMode(FALSE);
@@ -483,22 +484,22 @@ void MirandaImport(HWND hdlg) // Import Groups
if (nImportOption == IMPORT_ALL || (nCustomOptions & IOPT_GROUPS)) {
- AddMessage( LPGENT("Importing groups."));
+ AddMessage(LPGENT("Importing groups."));
nGroupsCount = ImportGroups();
if (nGroupsCount == -1)
- AddMessage( LPGENT("Group import failed."));
+ AddMessage(LPGENT("Group import failed."));
- AddMessage( _T(""));
+ AddMessage(_T(""));
}
// End of Import Groups
// Import Contacts
if (nImportOption != IMPORT_CUSTOM || (nCustomOptions & IOPT_CONTACTS)) {
- AddMessage( LPGENT("Importing contacts."));
+ AddMessage(LPGENT("Importing contacts."));
int i = 1;
- HANDLE hContact = srcDb->FindFirstContact();
+ MCONTACT hContact = srcDb->FindFirstContact();
while (hContact != NULL) {
- if ( ImportContact(hContact))
+ if (ImportContact(hContact))
nContactsCount++;
// Update progress bar
@@ -515,15 +516,15 @@ void MirandaImport(HWND hdlg) hContact = srcDb->FindNextContact(hContact);
}
}
- else AddMessage( LPGENT("Skipping new contacts import."));
- AddMessage( _T(""));
+ else AddMessage(LPGENT("Skipping new contacts import."));
+ AddMessage(_T(""));
// End of Import Contacts
// Import history
if (nImportOption != IMPORT_CONTACTS) {
// Import NULL contact message chain
if (nImportOption == IMPORT_ALL || (nCustomOptions & IOPT_SYSTEM)) {
- AddMessage( LPGENT("Importing system history."));
+ AddMessage(LPGENT("Importing system history."));
int protoCount;
PROTOACCOUNT **accs;
@@ -532,24 +533,24 @@ void MirandaImport(HWND hdlg) if (protoCount > 0)
ImportHistory(NULL, accs, protoCount);
}
- else AddMessage( LPGENT("Skipping system history import."));
+ else AddMessage(LPGENT("Skipping system history import."));
- AddMessage( _T(""));
+ AddMessage(_T(""));
// Import other contact messages
if (nImportOption == IMPORT_ALL || (nCustomOptions & 2046)) { // 2 - 1024 types
- AddMessage( LPGENT("Importing history."));
- HANDLE hContact = srcDb->FindFirstContact();
- for (int i=1; hContact != NULL; i++) {
+ AddMessage(LPGENT("Importing history."));
+ MCONTACT hContact = srcDb->FindFirstContact();
+ for (int i = 1; hContact != NULL; i++) {
ImportHistory(hContact, NULL, NULL);
SetProgress(100 * i / nNumberOfContacts);
hContact = srcDb->FindNextContact(hContact);
}
}
- else AddMessage( LPGENT("Skipping history import."));
+ else AddMessage(LPGENT("Skipping history import."));
- AddMessage( _T(""));
+ AddMessage(_T(""));
}
// End of Import History
@@ -563,15 +564,15 @@ void MirandaImport(HWND hdlg) dwTimer = time(NULL) - dwTimer;
// Print statistics
- AddMessage( LPGENT("Import completed in %d seconds."), dwTimer );
+ AddMessage(LPGENT("Import completed in %d seconds."), dwTimer);
SetProgress(100);
AddMessage((nImportOption == IMPORT_CONTACTS) ?
LPGENT("Added %d contacts and %d groups.") : LPGENT("Added %d contacts, %d groups and %d events."),
nContactsCount, nGroupsCount, nMessagesCount);
- if ( nImportOption != IMPORT_CONTACTS ) {
+ if (nImportOption != IMPORT_CONTACTS) {
if (nSkippedContacts)
- AddMessage( LPGENT("Skipped %d contacts."), nSkippedContacts );
+ AddMessage(LPGENT("Skipped %d contacts."), nSkippedContacts);
AddMessage((nImportOption == IMPORT_CUSTOM) ?
LPGENT("Skipped %d duplicates and %d filtered events.") : LPGENT("Skipped %d duplicates."),
|