diff options
Diffstat (limited to 'plugins/Db3x_mmap/src')
-rw-r--r-- | plugins/Db3x_mmap/src/database.cpp | 18 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbevents.cpp | 4 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 3 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintfm.cpp | 14 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbsettings.cpp | 28 |
5 files changed, 43 insertions, 24 deletions
diff --git a/plugins/Db3x_mmap/src/database.cpp b/plugins/Db3x_mmap/src/database.cpp index 4a0357d680..fd88e98b6f 100644 --- a/plugins/Db3x_mmap/src/database.cpp +++ b/plugins/Db3x_mmap/src/database.cpp @@ -119,3 +119,21 @@ void CDb3Base::DatabaseCorruption(TCHAR *text) Sleep(INFINITE);
}
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef DBLOGGING
+void DBLog(const char *file,int line,const char *fmt,...)
+{
+ FILE *fp;
+ va_list vararg;
+ char str[1024];
+
+ va_start(vararg,fmt);
+ mir_vsnprintf(str,sizeof(str),fmt,vararg);
+ va_end(vararg);
+ fp=fopen("c:\\mirandadatabase.log.txt","at");
+ fprintf(fp,"%u: %s %d: %s\n",GetTickCount(),file,line,str);
+ fclose(fp);
+}
+#endif
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index c499361557..ef72fd3ebc 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -149,7 +149,7 @@ STDMETHODIMP_(BOOL) CDb3Base::DeleteEvent(HANDLE hContact, HANDLE hDbEvent) return 1;
lck.unlock();
- log1("delete event @ %08x",wParam);
+ log1("delete event @ %08x", hContact);
//call notifier while outside mutex
NotifyEventHooks(hEventDeletedEvent,(WPARAM)hContact, (LPARAM)hDbEvent);
@@ -271,7 +271,7 @@ STDMETHODIMP_(BOOL) CDb3Base::MarkEventRead(HANDLE hContact, HANDLE hDbEvent) if ((dbe->flags & DBEF_READ) || (dbe->flags & DBEF_SENT))
return (INT_PTR)dbe->flags;
- log1("mark read @ %08x",wParam);
+ log1("mark read @ %08x", hContact);
dbe->flags |= DBEF_READ;
DBWrite((DWORD)hDbEvent,dbe,sizeof(DBEvent));
BOOL ret = dbe->flags;
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index c3a14c0c01..e77658767e 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -205,6 +205,7 @@ protected: STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
protected:
+ virtual DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc,DWORD ofsContact,DWORD ofsModuleName) = 0;
virtual void DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes) = 0;
virtual PBYTE DBRead(DWORD ofs, int bytesRequired, int *bytesAvail) = 0;
virtual void DBWrite(DWORD ofs, PVOID pData, int bytes) = 0;
@@ -261,7 +262,6 @@ protected: LIST<char> m_lSettings, m_lResidentSettings;
HANDLE hSettingChangeEvent, hContactDeletedEvent, hContactAddedEvent;
- DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc,DWORD ofsModuleName);
char* InsertCachedSetting(const char* szName, size_t cbNameLen);
char* GetCachedSetting(const char *szModuleName,const char *szSettingName, int moduleNameLen, int settingNameLen);
void SetCachedVariant(DBVARIANT* s, DBVARIANT* d);
@@ -295,6 +295,7 @@ struct CDb3Mmap : public CDb3Base ~CDb3Mmap();
protected:
+ virtual DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc,DWORD ofsContact,DWORD ofsModuleName);
virtual void DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes);
virtual PBYTE DBRead(DWORD ofs, int bytesRequired, int *bytesAvail);
virtual void DBWrite(DWORD ofs, PVOID pData, int bytes);
diff --git a/plugins/Db3x_mmap/src/dbintfm.cpp b/plugins/Db3x_mmap/src/dbintfm.cpp index 654165e924..2f34f4e371 100644 --- a/plugins/Db3x_mmap/src/dbintfm.cpp +++ b/plugins/Db3x_mmap/src/dbintfm.cpp @@ -40,3 +40,17 @@ CDb3Mmap::~CDb3Mmap() if (m_pNull)
free(m_pNull);
}
+
+DWORD CDb3Mmap::GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc,DWORD ofsContact,DWORD ofsModuleName)
+{
+ DWORD ofsThis = dbc->ofsFirstSettings;
+ while (ofsThis) {
+ DBContactSettings *dbcs = (DBContactSettings*)DBRead(ofsThis,sizeof(DBContactSettings),NULL);
+ if (dbcs->signature != DBCONTACTSETTINGS_SIGNATURE) DatabaseCorruption(NULL);
+ if (dbcs->ofsModuleName == ofsModuleName)
+ return ofsThis;
+
+ ofsThis = dbcs->ofsNext;
+ }
+ return 0;
+}
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index dac7f88b18..4f3a2e5516 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -28,20 +28,6 @@ DBCachedContactValueList* AddToCachedContactList(HANDLE hContact, int index); int DBPreset_QuerySetting(const char *szModule, const char *szSetting, DBVARIANT *dbv, BOOL isStatic);
-DWORD CDb3Base::GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc,DWORD ofsModuleName)
-{
- DWORD ofsThis = dbc->ofsFirstSettings;
- while (ofsThis) {
- DBContactSettings *dbcs = (DBContactSettings*)DBRead(ofsThis,sizeof(DBContactSettings),NULL);
- if (dbcs->signature != DBCONTACTSETTINGS_SIGNATURE) DatabaseCorruption(NULL);
- if (dbcs->ofsModuleName == ofsModuleName)
- return ofsThis;
-
- ofsThis = dbcs->ofsNext;
- }
- return 0;
-}
-
DWORD __forceinline GetSettingValueLength(PBYTE pSetting)
{
if (pSetting[0] & DBVTF_VARIABLELENGTH)
@@ -203,7 +189,6 @@ DBVARIANT* CDb3Base::GetCachedValuePtr( HANDLE hContact, char* szSetting, int bA int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs,int isStatic)
{
- DBContact *dbc;
DWORD ofsModuleName,ofsContact,ofsSettingsGroup,ofsBlobPtr;
int settingNameLen,moduleNameLen;
int bytesRemaining;
@@ -277,11 +262,12 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs ofsModuleName = GetModuleNameOfs(dbcgs->szModule);
if (hContact == NULL) ofsContact = m_dbHeader.ofsUser;
else ofsContact = (DWORD)hContact;
- dbc = (DBContact*)DBRead(ofsContact,sizeof(DBContact),NULL);
- if (dbc->signature != DBCONTACT_SIGNATURE)
+
+ DBContact dbc = *(DBContact*)DBRead(ofsContact,sizeof(DBContact),NULL);
+ if (dbc.signature != DBCONTACT_SIGNATURE)
return 1;
- ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc,ofsModuleName);
+ ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc,ofsContact,ofsModuleName);
if (ofsSettingsGroup) {
ofsBlobPtr = ofsSettingsGroup+offsetof(DBContactSettings,blob);
pBlob = DBRead(ofsBlobPtr,sizeof(DBContactSettings),&bytesRemaining);
@@ -624,7 +610,7 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT log0("write setting");
//make sure the module group exists
- ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc,ofsModuleName);
+ ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc,ofsContact,ofsModuleName);
if (ofsSettingsGroup == 0) { //module group didn't exist - make it
if (tmp.value.type&DBVTF_VARIABLELENGTH) {
if (tmp.value.type == DBVT_ASCIIZ || tmp.value.type == DBVT_UTF8) bytesRequired = (int)strlen(tmp.value.pszVal)+2;
@@ -826,7 +812,7 @@ STDMETHODIMP_(BOOL) CDb3Base::DeleteContactSetting(HANDLE hContact, DBCONTACTGET return 1;
//make sure the module group exists
- ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc,ofsModuleName);
+ ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc,(DWORD)hContact,ofsModuleName);
if (ofsSettingsGroup == 0)
return 1;
@@ -900,7 +886,7 @@ STDMETHODIMP_(BOOL) CDb3Base::EnumContactSettings(HANDLE hContact, DBCONTACTENUM if (dbc->signature != DBCONTACT_SIGNATURE)
return -1;
- dbces->ofsSettings = GetSettingsGroupOfsByModuleNameOfs(dbc,ofsModuleName);
+ dbces->ofsSettings = GetSettingsGroupOfsByModuleNameOfs(dbc,ofsContact,ofsModuleName);
if ( !dbces->ofsSettings)
return -1;
|