summaryrefslogtreecommitdiff
path: root/plugins/Dbx_kyoto/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-04-03 20:34:27 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-04-03 20:34:27 +0000
commitb8da724473d63de288f27af5d81a07ce29ce2d90 (patch)
treee2076737ba2227ab058b562e2e7c5d99696b6d34 /plugins/Dbx_kyoto/src
parent2dda26c2d63fb543d06f046a5908ba43a5fd716e (diff)
unique class name
git-svn-id: http://svn.miranda-ng.org/main/trunk@12591 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_kyoto/src')
-rw-r--r--plugins/Dbx_kyoto/src/commonheaders.h2
-rw-r--r--plugins/Dbx_kyoto/src/dbcontacts.cpp26
-rw-r--r--plugins/Dbx_kyoto/src/dbcrypt.cpp18
-rw-r--r--plugins/Dbx_kyoto/src/dbevents.cpp28
-rw-r--r--plugins/Dbx_kyoto/src/dbintf.cpp76
-rw-r--r--plugins/Dbx_kyoto/src/dbintf.h20
-rw-r--r--plugins/Dbx_kyoto/src/dbmodulechain.cpp12
-rw-r--r--plugins/Dbx_kyoto/src/dbsettings.cpp22
-rw-r--r--plugins/Dbx_kyoto/src/init.cpp14
-rw-r--r--plugins/Dbx_kyoto/src/ui.cpp18
10 files changed, 116 insertions, 120 deletions
diff --git a/plugins/Dbx_kyoto/src/commonheaders.h b/plugins/Dbx_kyoto/src/commonheaders.h
index d8662967e9..a8a6e11b8b 100644
--- a/plugins/Dbx_kyoto/src/commonheaders.h
+++ b/plugins/Dbx_kyoto/src/commonheaders.h
@@ -52,7 +52,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "version.h"
extern HINSTANCE g_hInst;
-extern LIST<CDbxKV> g_Dbs;
+extern LIST<CDbxKyoto> g_Dbs;
class cursor_ptr
{
diff --git a/plugins/Dbx_kyoto/src/dbcontacts.cpp b/plugins/Dbx_kyoto/src/dbcontacts.cpp
index c7b74bc038..5a707b9f36 100644
--- a/plugins/Dbx_kyoto/src/dbcontacts.cpp
+++ b/plugins/Dbx_kyoto/src/dbcontacts.cpp
@@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
-int CDbxKV::CheckProto(DBCachedContact *cc, const char *proto)
+int CDbxKyoto::CheckProto(DBCachedContact *cc, const char *proto)
{
if (cc->szProto == NULL) {
char protobuf[MAX_PATH] = { 0 };
@@ -40,18 +40,18 @@ int CDbxKV::CheckProto(DBCachedContact *cc, const char *proto)
return !strcmp(cc->szProto, proto);
}
-STDMETHODIMP_(LONG) CDbxKV::GetContactCount(void)
+STDMETHODIMP_(LONG) CDbxKyoto::GetContactCount(void)
{
mir_cslock lck(m_csDbAccess);
return m_contactCount;
}
-STDMETHODIMP_(LONG) CDbxKV::GetContactSize(void)
+STDMETHODIMP_(LONG) CDbxKyoto::GetContactSize(void)
{
return sizeof(DBCachedContact);
}
-STDMETHODIMP_(MCONTACT) CDbxKV::FindFirstContact(const char *szProto)
+STDMETHODIMP_(MCONTACT) CDbxKyoto::FindFirstContact(const char *szProto)
{
mir_cslock lck(m_csDbAccess);
DBCachedContact *cc = m_cache->GetFirstContact();
@@ -68,7 +68,7 @@ STDMETHODIMP_(MCONTACT) CDbxKV::FindFirstContact(const char *szProto)
return FindNextContact(cc->contactID, szProto);
}
-STDMETHODIMP_(MCONTACT) CDbxKV::FindNextContact(MCONTACT contactID, const char *szProto)
+STDMETHODIMP_(MCONTACT) CDbxKyoto::FindNextContact(MCONTACT contactID, const char *szProto)
{
mir_cslock lck(m_csDbAccess);
while (contactID) {
@@ -85,7 +85,7 @@ STDMETHODIMP_(MCONTACT) CDbxKV::FindNextContact(MCONTACT contactID, const char *
return NULL;
}
-STDMETHODIMP_(LONG) CDbxKV::DeleteContact(MCONTACT contactID)
+STDMETHODIMP_(LONG) CDbxKyoto::DeleteContact(MCONTACT contactID)
{
if (contactID == 0) // global contact cannot be removed
return 1;
@@ -99,7 +99,7 @@ STDMETHODIMP_(LONG) CDbxKV::DeleteContact(MCONTACT contactID)
return 0;
}
-STDMETHODIMP_(MCONTACT) CDbxKV::AddContact()
+STDMETHODIMP_(MCONTACT) CDbxKyoto::AddContact()
{
DWORD dwContactId;
{
@@ -115,7 +115,7 @@ STDMETHODIMP_(MCONTACT) CDbxKV::AddContact()
return dwContactId;
}
-STDMETHODIMP_(BOOL) CDbxKV::IsDbContact(MCONTACT contactID)
+STDMETHODIMP_(BOOL) CDbxKyoto::IsDbContact(MCONTACT contactID)
{
DBCachedContact *cc = m_cache->GetCachedContact(contactID);
return (cc != NULL);
@@ -124,20 +124,20 @@ STDMETHODIMP_(BOOL) CDbxKV::IsDbContact(MCONTACT contactID)
/////////////////////////////////////////////////////////////////////////////////////////
// metacontacts support
-BOOL CDbxKV::MetaDetouchSub(DBCachedContact *cc, int nSub)
+BOOL CDbxKyoto::MetaDetouchSub(DBCachedContact *cc, int nSub)
{
CallService(MS_DB_MODULE_DELETE, cc->pSubs[nSub], (LPARAM)META_PROTO);
return 0;
}
-BOOL CDbxKV::MetaSetDefault(DBCachedContact *cc)
+BOOL CDbxKyoto::MetaSetDefault(DBCachedContact *cc)
{
return db_set_dw(cc->contactID, META_PROTO, "Default", cc->nDefault);
}
/////////////////////////////////////////////////////////////////////////////////////////
-BOOL CDbxKV::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
+BOOL CDbxKyoto::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
{
DBEventSortingKey keyVal = { ccSub->contactID, 0, 0 }, insVal = { ccMeta->contactID, 0, 0 };
cursor_ptr cursor(m_dbEventsSort);
@@ -166,7 +166,7 @@ BOOL CDbxKV::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
/////////////////////////////////////////////////////////////////////////////////////////
-BOOL CDbxKV::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
+BOOL CDbxKyoto::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
{
DBEventSortingKey keyVal = { ccSub->contactID, 0, 0 }, delVal = { ccMeta->contactID, 0, 0 };
@@ -212,7 +212,7 @@ void DBCachedContact::Advance(DWORD id, DBEvent &dbe)
/////////////////////////////////////////////////////////////////////////////////////////
// initial cycle to fill the contacts' cache
-void CDbxKV::FillContacts()
+void CDbxKyoto::FillContacts()
{
m_contactCount = 0;
diff --git a/plugins/Dbx_kyoto/src/dbcrypt.cpp b/plugins/Dbx_kyoto/src/dbcrypt.cpp
index b79639fa61..27eb2a35f9 100644
--- a/plugins/Dbx_kyoto/src/dbcrypt.cpp
+++ b/plugins/Dbx_kyoto/src/dbcrypt.cpp
@@ -63,7 +63,7 @@ struct VarDescr
struct SettingUgraderParam
{
- CDbxKV *db;
+ CDbxKyoto *db;
LPCSTR szModule;
MCONTACT contactID;
OBJLIST<VarDescr>* pList;
@@ -85,7 +85,7 @@ int sttSettingUgrader(const char *szSetting, LPARAM lParam)
return 0;
}
-void sttContactEnum(MCONTACT contactID, const char *szModule, CDbxKV *db)
+void sttContactEnum(MCONTACT contactID, const char *szModule, CDbxKyoto *db)
{
OBJLIST<VarDescr> arSettings(1);
SettingUgraderParam param = { db, szModule, contactID, &arSettings };
@@ -115,7 +115,7 @@ void sttContactEnum(MCONTACT contactID, const char *szModule, CDbxKV *db)
int sttModuleEnum(const char *szModule, DWORD, LPARAM lParam)
{
- CDbxKV *db = (CDbxKV*)lParam;
+ CDbxKyoto *db = (CDbxKyoto*)lParam;
sttContactEnum(NULL, szModule, db);
for (MCONTACT contactID = db->FindFirstContact(); contactID; contactID = db->FindNextContact(contactID))
@@ -126,7 +126,7 @@ int sttModuleEnum(const char *szModule, DWORD, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
-int CDbxKV::InitCrypt()
+int CDbxKyoto::InitCrypt()
{
CRYPTO_PROVIDER *pProvider;
bool bMissingKey = false;
@@ -195,7 +195,7 @@ int CDbxKV::InitCrypt()
return 0;
}
-void CDbxKV::StoreKey()
+void CDbxKyoto::StoreKey()
{
size_t iKeyLength = m_crypto->getKeyLength();
BYTE *pKey = (BYTE*)_alloca(iKeyLength);
@@ -210,7 +210,7 @@ void CDbxKV::StoreKey()
SecureZeroMemory(pKey, iKeyLength);
}
-void CDbxKV::SetPassword(LPCTSTR ptszPassword)
+void CDbxKyoto::SetPassword(LPCTSTR ptszPassword)
{
if (ptszPassword == NULL || *ptszPassword == 0) {
m_bUsesPassword = false;
@@ -225,7 +225,7 @@ void CDbxKV::SetPassword(LPCTSTR ptszPassword)
/////////////////////////////////////////////////////////////////////////////////////////
-void CDbxKV::ToggleEncryption()
+void CDbxKyoto::ToggleEncryption()
{
HANDLE hSave1 = hSettingChangeEvent; hSettingChangeEvent = NULL;
HANDLE hSave2 = hEventAddedEvent; hEventAddedEvent = NULL;
@@ -254,10 +254,10 @@ void CDbxKV::ToggleEncryption()
hEventFilterAddedEvent = hSave4;
}
-void CDbxKV::ToggleSettingsEncryption(MCONTACT contactID)
+void CDbxKyoto::ToggleSettingsEncryption(MCONTACT contactID)
{
}
-void CDbxKV::ToggleEventsEncryption(MCONTACT contactID)
+void CDbxKyoto::ToggleEventsEncryption(MCONTACT contactID)
{
}
diff --git a/plugins/Dbx_kyoto/src/dbevents.cpp b/plugins/Dbx_kyoto/src/dbevents.cpp
index c39848241b..cf47287eed 100644
--- a/plugins/Dbx_kyoto/src/dbevents.cpp
+++ b/plugins/Dbx_kyoto/src/dbevents.cpp
@@ -23,13 +23,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
-STDMETHODIMP_(LONG) CDbxKV::GetEventCount(MCONTACT contactID)
+STDMETHODIMP_(LONG) CDbxKyoto::GetEventCount(MCONTACT contactID)
{
DBCachedContact *cc = m_cache->GetCachedContact(contactID);
return (cc == NULL) ? 0 : cc->dbc.dwEventCount;
}
-STDMETHODIMP_(MEVENT) CDbxKV::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
+STDMETHODIMP_(MEVENT) CDbxKyoto::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
{
if (dbei == NULL || dbei->cbSize != sizeof(DBEVENTINFO)) return 0;
if (dbei->timestamp == 0) return 0;
@@ -107,7 +107,7 @@ STDMETHODIMP_(MEVENT) CDbxKV::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei)
return dwEventId;
}
-STDMETHODIMP_(BOOL) CDbxKV::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent)
+STDMETHODIMP_(BOOL) CDbxKyoto::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent)
{
if (hDbEvent == 0) return INVALID_CONTACT_ID;
@@ -142,7 +142,7 @@ STDMETHODIMP_(BOOL) CDbxKV::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent)
return 0;
}
-STDMETHODIMP_(LONG) CDbxKV::GetBlobSize(MEVENT hDbEvent)
+STDMETHODIMP_(LONG) CDbxKyoto::GetBlobSize(MEVENT hDbEvent)
{
DBEvent dbe;
if (-1 == m_dbEvents.get((LPCSTR)&hDbEvent, sizeof(MEVENT), (LPSTR)&dbe, sizeof(dbe)))
@@ -151,7 +151,7 @@ STDMETHODIMP_(LONG) CDbxKV::GetBlobSize(MEVENT hDbEvent)
return (dbe.dwSignature == DBEVENT_SIGNATURE) ? dbe.cbBlob : 0;
}
-STDMETHODIMP_(BOOL) CDbxKV::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
+STDMETHODIMP_(BOOL) CDbxKyoto::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
{
if (hDbEvent == 0 || dbei == NULL || dbei->cbSize != sizeof(DBEVENTINFO)) return 1;
if (dbei->cbBlob > 0 && dbei->pBlob == NULL) {
@@ -192,7 +192,7 @@ STDMETHODIMP_(BOOL) CDbxKV::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
return 0;
}
-void CDbxKV::FindNextUnread(DBCachedContact *cc, DBEventSortingKey &key2)
+void CDbxKyoto::FindNextUnread(DBCachedContact *cc, DBEventSortingKey &key2)
{
key2.dwEventId++;
@@ -213,7 +213,7 @@ void CDbxKV::FindNextUnread(DBCachedContact *cc, DBEventSortingKey &key2)
cc->dbc.dwFirstUnread = cc->dbc.tsFirstUnread = 0;
}
-STDMETHODIMP_(BOOL) CDbxKV::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent)
+STDMETHODIMP_(BOOL) CDbxKyoto::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent)
{
if (hDbEvent == 0) return -1;
@@ -245,7 +245,7 @@ STDMETHODIMP_(BOOL) CDbxKV::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent)
return dbe->flags;
}
-STDMETHODIMP_(MCONTACT) CDbxKV::GetEventContact(MEVENT hDbEvent)
+STDMETHODIMP_(MCONTACT) CDbxKyoto::GetEventContact(MEVENT hDbEvent)
{
if (hDbEvent == 0) return INVALID_CONTACT_ID;
@@ -257,7 +257,7 @@ STDMETHODIMP_(MCONTACT) CDbxKV::GetEventContact(MEVENT hDbEvent)
return (dbe->dwSignature == DBEVENT_SIGNATURE) ? dbe->contactID : INVALID_CONTACT_ID;
}
-STDMETHODIMP_(MEVENT) CDbxKV::FindFirstEvent(MCONTACT contactID)
+STDMETHODIMP_(MEVENT) CDbxKyoto::FindFirstEvent(MCONTACT contactID)
{
DBEventSortingKey keyVal = { contactID, 0, 0 };
cursor_ptr cursor(m_dbEventsSort);
@@ -274,13 +274,13 @@ STDMETHODIMP_(MEVENT) CDbxKV::FindFirstEvent(MCONTACT contactID)
return m_evLast;
}
-STDMETHODIMP_(MEVENT) CDbxKV::FindFirstUnreadEvent(MCONTACT contactID)
+STDMETHODIMP_(MEVENT) CDbxKyoto::FindFirstUnreadEvent(MCONTACT contactID)
{
DBCachedContact *cc = m_cache->GetCachedContact(contactID);
return (cc == NULL) ? 0 : cc->dbc.dwFirstUnread;
}
-STDMETHODIMP_(MEVENT) CDbxKV::FindLastEvent(MCONTACT contactID)
+STDMETHODIMP_(MEVENT) CDbxKyoto::FindLastEvent(MCONTACT contactID)
{
DBEventSortingKey keyVal = { contactID, 0xFFFFFFFF, 0xFFFFFFFF };
cursor_ptr cursor(m_dbEventsSort);
@@ -297,7 +297,7 @@ STDMETHODIMP_(MEVENT) CDbxKV::FindLastEvent(MCONTACT contactID)
return m_evLast;
}
-STDMETHODIMP_(MEVENT) CDbxKV::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent)
+STDMETHODIMP_(MEVENT) CDbxKyoto::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent)
{
if (hDbEvent == 0) return m_evLast = 0;
@@ -327,7 +327,7 @@ STDMETHODIMP_(MEVENT) CDbxKV::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent)
return m_evLast;
}
-STDMETHODIMP_(MEVENT) CDbxKV::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent)
+STDMETHODIMP_(MEVENT) CDbxKyoto::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent)
{
if (hDbEvent == 0) return m_evLast = 0;
@@ -360,7 +360,7 @@ STDMETHODIMP_(MEVENT) CDbxKV::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent)
/////////////////////////////////////////////////////////////////////////////////////////
// low-level history cleaner
-int CDbxKV::WipeContactHistory(DBContact*)
+int CDbxKyoto::WipeContactHistory(DBContact*)
{
// drop subContact's history if any
return 0;
diff --git a/plugins/Dbx_kyoto/src/dbintf.cpp b/plugins/Dbx_kyoto/src/dbintf.cpp
index 4b3859eb63..e02fa083f6 100644
--- a/plugins/Dbx_kyoto/src/dbintf.cpp
+++ b/plugins/Dbx_kyoto/src/dbintf.cpp
@@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
+#define DBHEADER_SIGNATURE _T("KyotoCabinet")
+
struct SettingsComparator : public Comparator
{
SettingsComparator() {}
@@ -85,7 +87,7 @@ static int stringCompare2(const char *p1, const char *p2)
return strcmp(p1, p2);
}
-CDbxKV::CDbxKV(const TCHAR *tszFileName, int iMode) :
+CDbxKyoto::CDbxKyoto(const TCHAR *tszFileName, int iMode) :
m_safetyMode(true),
m_bReadOnly((iMode & DBMODE_READONLY) != 0),
m_bShared((iMode & DBMODE_SHARED) != 0),
@@ -101,8 +103,14 @@ CDbxKV::CDbxKV(const TCHAR *tszFileName, int iMode) :
m_hModHeap = HeapCreate(0, 0, 0);
}
-CDbxKV::~CDbxKV()
+CDbxKyoto::~CDbxKyoto()
{
+ m_dbContacts.close();
+ m_dbModules.close();
+ m_dbEvents.close();
+ m_dbEventsSort.close();
+ m_dbSettings.close();
+
// destroy modules
HeapDestroy(m_hModHeap);
@@ -126,7 +134,7 @@ CDbxKV::~CDbxKV()
mir_free(m_tszProfileName);
}
-int CDbxKV::Load(bool bSkipInit)
+int CDbxKyoto::Load(bool bSkipInit)
{
if (!bSkipInit) {
int iFlags = TreeDB::OREADER | TreeDB::ONOREPAIR;
@@ -134,10 +142,6 @@ int CDbxKV::Load(bool bSkipInit)
iFlags |= TreeDB::OWRITER;
std::string szFilename((char*)_T2A(m_tszProfileName));
- m_dbGlobal.tune_map(16384);
- if (!m_dbGlobal.open(szFilename, iFlags))
- return EGROKPRF_DAMAGED;
-
m_dbContacts.tune_map(256 * 1024);
if (!m_dbContacts.open(szFilename + ".cnt", iFlags))
return EGROKPRF_DAMAGED;
@@ -158,17 +162,20 @@ int CDbxKV::Load(bool bSkipInit)
if (!m_dbSettings.open(szFilename + ".set", iFlags))
return EGROKPRF_DAMAGED;
- DWORD keyVal = 1;
- if (-1 != m_dbGlobal.get((LPCSTR)&keyVal, sizeof(keyVal), (LPSTR)&m_header, sizeof(m_header))) {
- if (m_header.dwSignature != DBHEADER_SIGNATURE)
- DatabaseCorruption(NULL);
+ if (_taccess(m_tszProfileName, 0) == 0) {
+ TCHAR buf[100];
+ if (0 == GetPrivateProfileString(_T("Database"), _T("Signature"), _T(""), buf, SIZEOF(buf), m_tszProfileName))
+ return EGROKPRF_CANTREAD;
+ if (_tcscmp(buf, DBHEADER_SIGNATURE))
+ return EGROKPRF_DAMAGED;
+
+ m_dwVersion = GetPrivateProfileInt(_T("Database"), _T("Version"), 1, m_tszProfileName);
}
else {
- m_header.dwSignature = DBHEADER_SIGNATURE;
- m_header.dwVersion = 1;
- m_dbGlobal.set((LPCSTR)&keyVal, sizeof(keyVal), (LPCSTR)&m_header, sizeof(m_header));
+ WritePrivateProfileString(_T("Database"), _T("Version"), _T("1"), m_tszProfileName);
+ WritePrivateProfileString(_T("Database"), _T("Signature"), DBHEADER_SIGNATURE, m_tszProfileName);
- keyVal = 0;
+ DWORD keyVal = 0;
DBContact dbc = { DBCONTACT_SIGNATURE, 0, 0, 0 };
m_dbContacts.set((LPCSTR)&keyVal, sizeof(keyVal), (LPCSTR)&dbc, sizeof(dbc));
}
@@ -197,14 +204,16 @@ int CDbxKV::Load(bool bSkipInit)
return ERROR_SUCCESS;
}
-int CDbxKV::Create(void)
+int CDbxKyoto::Create(void)
{
int iFlags = TreeDB::OREADER | TreeDB::OCREATE;
if (!m_bReadOnly)
iFlags |= TreeDB::OWRITER;
+ WritePrivateProfileString(_T("Database"), _T("Version"), _T("1"), m_tszProfileName);
+ WritePrivateProfileString(_T("Database"), _T("Signature"), DBHEADER_SIGNATURE, m_tszProfileName);
+
std::string szFilename((char*)_T2A(m_tszProfileName));
- if (!m_dbGlobal.open(szFilename, iFlags)) return EGROKPRF_DAMAGED;
if (!m_dbContacts.open(szFilename + ".cnt", iFlags)) return EGROKPRF_DAMAGED;
if (!m_dbModules.open(szFilename + ".mod", iFlags)) return EGROKPRF_DAMAGED;
if (!m_dbEvents.open(szFilename + ".evt", iFlags)) return EGROKPRF_DAMAGED;
@@ -213,30 +222,27 @@ int CDbxKV::Create(void)
return 0;
}
-int CDbxKV::Check(void)
+int CDbxKyoto::Check(void)
{
- HANDLE hFile = CreateFile(m_tszProfileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
+ if (_taccess(m_tszProfileName, 0) != 0)
return EGROKPRF_CANTREAD;
- DWORD dummy = 0;
- char buf[32];
- if (!ReadFile(hFile, buf, sizeof(buf), &dummy, NULL)) {
- CloseHandle(hFile);
- return EGROKPRF_CANTREAD;
- }
+ TCHAR buf[100];
+ if (0 == GetPrivateProfileString(_T("Database"), _T("Signature"), _T(""), buf, SIZEOF(buf), m_tszProfileName))
+ return EGROKPRF_UNKHEADER;
+ if (_tcscmp(buf, DBHEADER_SIGNATURE))
+ return EGROKPRF_UNKHEADER;
- CloseHandle(hFile);
- return (memcmp(buf, "\x4B\x43\x0A\x00", 4)) ? EGROKPRF_UNKHEADER : 0;
+ return 0;
}
-int CDbxKV::PrepareCheck(int*)
+int CDbxKyoto::PrepareCheck(int*)
{
InitModuleNames();
return InitCrypt();
}
-STDMETHODIMP_(void) CDbxKV::SetCacheSafetyMode(BOOL bIsSet)
+STDMETHODIMP_(void) CDbxKyoto::SetCacheSafetyMode(BOOL bIsSet)
{
mir_cslock lck(m_csDbAccess);
m_safetyMode = bIsSet != 0;
@@ -264,7 +270,7 @@ void __cdecl dbpanic(void *)
TerminateProcess(GetCurrentProcess(), 255);
}
-void CDbxKV::DatabaseCorruption(const TCHAR *text)
+void CDbxKyoto::DatabaseCorruption(const TCHAR *text)
{
int kill = 0;
@@ -292,22 +298,22 @@ void CDbxKV::DatabaseCorruption(const TCHAR *text)
///////////////////////////////////////////////////////////////////////////////
// MIDatabaseChecker
-typedef int (CDbxKV::*CheckWorker)(int);
+typedef int (CDbxKyoto::*CheckWorker)(int);
-int CDbxKV::Start(DBCHeckCallback *callback)
+int CDbxKyoto::Start(DBCHeckCallback *callback)
{
cb = callback;
return ERROR_SUCCESS;
}
-int CDbxKV::CheckDb(int, int)
+int CDbxKyoto::CheckDb(int, int)
{
return ERROR_OUT_OF_PAPER;
// return (this->*Workers[phase])(firstTime);
}
-void CDbxKV::Destroy()
+void CDbxKyoto::Destroy()
{
delete this;
}
diff --git a/plugins/Dbx_kyoto/src/dbintf.h b/plugins/Dbx_kyoto/src/dbintf.h
index cbf2510f19..3d05288d26 100644
--- a/plugins/Dbx_kyoto/src/dbintf.h
+++ b/plugins/Dbx_kyoto/src/dbintf.h
@@ -21,7 +21,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <kchashdb.h>
+#include <kchashdb.h>
using namespace kyotocabinet;
/* tree diagram
@@ -61,13 +61,6 @@ struct ModuleName
#include <pshpack1.h>
-#define DBHEADER_SIGNATURE 0x40DECADEu
-struct DBHeader
-{
- DWORD dwSignature;
- DWORD dwVersion; // database format version
-};
-
#define DBCONTACT_SIGNATURE 0x43DECADEu
struct DBContact
{
@@ -133,10 +126,10 @@ struct CTable : public TreeDB
}
};
-struct CDbxKV : public MIDatabase, public MIDatabaseChecker, public MZeroedObject
+struct CDbxKyoto : public MIDatabase, public MIDatabaseChecker, public MZeroedObject
{
- CDbxKV(const TCHAR *tszFileName, int mode);
- ~CDbxKV();
+ CDbxKyoto(const TCHAR *tszFileName, int mode);
+ ~CDbxKyoto();
int Load(bool bSkipInit);
int Create(void);
@@ -227,11 +220,8 @@ public:
MICryptoEngine *m_crypto;
protected:
- CTable m_dbGlobal;
- DBHeader m_header;
-
HANDLE hSettingChangeEvent, hContactDeletedEvent, hContactAddedEvent, hEventMarkedRead;
-
+ DWORD m_dwVersion;
mir_cs m_csDbAccess;
int CheckProto(DBCachedContact *cc, const char *proto);
diff --git a/plugins/Dbx_kyoto/src/dbmodulechain.cpp b/plugins/Dbx_kyoto/src/dbmodulechain.cpp
index 9416f5305d..78df791887 100644
--- a/plugins/Dbx_kyoto/src/dbmodulechain.cpp
+++ b/plugins/Dbx_kyoto/src/dbmodulechain.cpp
@@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
-void CDbxKV::AddToList(char *name, DWORD ofs)
+void CDbxKyoto::AddToList(char *name, DWORD ofs)
{
ModuleName *mn = (ModuleName*)HeapAlloc(m_hModHeap, 0, sizeof(ModuleName));
mn->name = name;
@@ -38,7 +38,7 @@ void CDbxKV::AddToList(char *name, DWORD ofs)
m_lOfs.insert(mn);
}
-int CDbxKV::InitModuleNames(void)
+int CDbxKyoto::InitModuleNames(void)
{
m_maxModuleID = 0;
@@ -65,7 +65,7 @@ int CDbxKV::InitModuleNames(void)
return 0;
}
-DWORD CDbxKV::FindExistingModuleNameOfs(const char *szName)
+DWORD CDbxKyoto::FindExistingModuleNameOfs(const char *szName)
{
ModuleName mn = { (char*)szName, 0 };
@@ -77,7 +77,7 @@ DWORD CDbxKV::FindExistingModuleNameOfs(const char *szName)
}
// will create the offset if it needs to
-DWORD CDbxKV::GetModuleNameOfs(const char *szName)
+DWORD CDbxKyoto::GetModuleNameOfs(const char *szName)
{
DWORD ofsExisting = FindExistingModuleNameOfs(szName);
if (ofsExisting)
@@ -105,7 +105,7 @@ DWORD CDbxKV::GetModuleNameOfs(const char *szName)
return -1;
}
-char* CDbxKV::GetModuleNameByOfs(DWORD ofs)
+char* CDbxKyoto::GetModuleNameByOfs(DWORD ofs)
{
ModuleName mn = { NULL, ofs };
int index = m_lOfs.getIndex(&mn);
@@ -115,7 +115,7 @@ char* CDbxKV::GetModuleNameByOfs(DWORD ofs)
return NULL;
}
-STDMETHODIMP_(BOOL) CDbxKV::EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam)
+STDMETHODIMP_(BOOL) CDbxKyoto::EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam)
{
for (int i = 0; i < m_lMods.getCount(); i++) {
ModuleName *pmn = m_lMods[i];
diff --git a/plugins/Dbx_kyoto/src/dbsettings.cpp b/plugins/Dbx_kyoto/src/dbsettings.cpp
index 4f1e0579b1..c1b4eea707 100644
--- a/plugins/Dbx_kyoto/src/dbsettings.cpp
+++ b/plugins/Dbx_kyoto/src/dbsettings.cpp
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define VLT(n) ((n == DBVT_UTF8 || n == DBVT_ENCRYPTED)?DBVT_ASCIIZ:n)
-BOOL CDbxKV::IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting)
+BOOL CDbxKyoto::IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting)
{
if (!_strnicmp(szSetting, "password", 8)) return true;
if (!strcmp(szSetting, "NLProxyAuthPassword")) return true;
@@ -53,7 +53,7 @@ static bool ValidLookupName(LPCSTR szModule, LPCSTR szSetting)
return true;
}
-int CDbxKV::GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic)
+int CDbxKyoto::GetContactSettingWorker(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic)
{
if (szSetting == NULL || szModule == NULL)
return 1;
@@ -222,7 +222,7 @@ LBL_Seek:
return 0;
}
-STDMETHODIMP_(BOOL) CDbxKV::GetContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
+STDMETHODIMP_(BOOL) CDbxKyoto::GetContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
dbv->type = 0;
if (GetContactSettingWorker(contactID, szModule, szSetting, dbv, 0))
@@ -257,7 +257,7 @@ STDMETHODIMP_(BOOL) CDbxKV::GetContactSetting(MCONTACT contactID, LPCSTR szModul
return 0;
}
-STDMETHODIMP_(BOOL) CDbxKV::GetContactSettingStr(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
+STDMETHODIMP_(BOOL) CDbxKyoto::GetContactSettingStr(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
int iSaveType = dbv->type;
@@ -304,7 +304,7 @@ STDMETHODIMP_(BOOL) CDbxKV::GetContactSettingStr(MCONTACT contactID, LPCSTR szMo
return 0;
}
-STDMETHODIMP_(BOOL) CDbxKV::GetContactSettingStatic(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
+STDMETHODIMP_(BOOL) CDbxKyoto::GetContactSettingStatic(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv)
{
if (GetContactSettingWorker(contactID, szModule, szSetting, dbv, 1))
return 1;
@@ -317,7 +317,7 @@ STDMETHODIMP_(BOOL) CDbxKV::GetContactSettingStatic(MCONTACT contactID, LPCSTR s
return 0;
}
-STDMETHODIMP_(BOOL) CDbxKV::FreeVariant(DBVARIANT *dbv)
+STDMETHODIMP_(BOOL) CDbxKyoto::FreeVariant(DBVARIANT *dbv)
{
if (dbv == 0) return 1;
@@ -337,7 +337,7 @@ STDMETHODIMP_(BOOL) CDbxKV::FreeVariant(DBVARIANT *dbv)
return 0;
}
-STDMETHODIMP_(BOOL) CDbxKV::SetSettingResident(BOOL bIsResident, const char *pszSettingName)
+STDMETHODIMP_(BOOL) CDbxKyoto::SetSettingResident(BOOL bIsResident, const char *pszSettingName)
{
char *szSetting = m_cache->GetCachedSetting(NULL, pszSettingName, 0, (int)strlen(pszSettingName));
szSetting[-1] = (char)bIsResident;
@@ -354,7 +354,7 @@ STDMETHODIMP_(BOOL) CDbxKV::SetSettingResident(BOOL bIsResident, const char *psz
return 0;
}
-STDMETHODIMP_(BOOL) CDbxKV::WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws)
+STDMETHODIMP_(BOOL) CDbxKyoto::WriteContactSetting(MCONTACT contactID, DBCONTACTWRITESETTING *dbcws)
{
if (dbcws == NULL || dbcws->szSetting == NULL || dbcws->szModule == NULL || m_bReadOnly)
return 1;
@@ -511,7 +511,7 @@ STDMETHODIMP_(BOOL) CDbxKV::WriteContactSetting(MCONTACT contactID, DBCONTACTWRI
return 0;
}
-STDMETHODIMP_(BOOL) CDbxKV::DeleteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting)
+STDMETHODIMP_(BOOL) CDbxKyoto::DeleteContactSetting(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting)
{
if (!szModule || !szSetting)
return 1;
@@ -557,7 +557,7 @@ STDMETHODIMP_(BOOL) CDbxKV::DeleteContactSetting(MCONTACT contactID, LPCSTR szMo
return 0;
}
-STDMETHODIMP_(BOOL) CDbxKV::EnumContactSettings(MCONTACT contactID, DBCONTACTENUMSETTINGS* dbces)
+STDMETHODIMP_(BOOL) CDbxKyoto::EnumContactSettings(MCONTACT contactID, DBCONTACTENUMSETTINGS* dbces)
{
if (!dbces->szModule)
return -1;
@@ -588,7 +588,7 @@ STDMETHODIMP_(BOOL) CDbxKV::EnumContactSettings(MCONTACT contactID, DBCONTACTENU
return result;
}
-STDMETHODIMP_(BOOL) CDbxKV::EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam)
+STDMETHODIMP_(BOOL) CDbxKyoto::EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam)
{
for (int i = 0; i < m_lResidentSettings.getCount(); i++) {
int ret = pFunc(m_lResidentSettings[i], 0, (LPARAM)pParam);
diff --git a/plugins/Dbx_kyoto/src/init.cpp b/plugins/Dbx_kyoto/src/init.cpp
index e9e3247fd8..a78c4f91ad 100644
--- a/plugins/Dbx_kyoto/src/init.cpp
+++ b/plugins/Dbx_kyoto/src/init.cpp
@@ -42,21 +42,21 @@ static PLUGININFOEX pluginInfo =
HINSTANCE g_hInst = NULL;
-LIST<CDbxKV> g_Dbs(1, HandleKeySortT);
+LIST<CDbxKyoto> g_Dbs(1, HandleKeySortT);
/////////////////////////////////////////////////////////////////////////////////////////
// returns 0 if the profile is created, EMKPRF*
static int makeDatabase(const TCHAR *profile)
{
- std::auto_ptr<CDbxKV> db(new CDbxKV(profile, 0));
+ std::auto_ptr<CDbxKyoto> db(new CDbxKyoto(profile, 0));
return db->Create();
}
// returns 0 if the given profile has a valid header
static int grokHeader(const TCHAR *profile)
{
- std::auto_ptr<CDbxKV> db(new CDbxKV(profile, DBMODE_SHARED | DBMODE_READONLY));
+ std::auto_ptr<CDbxKyoto> db(new CDbxKyoto(profile, DBMODE_SHARED | DBMODE_READONLY));
return db->Check();
}
@@ -66,7 +66,7 @@ static MIDatabase* LoadDatabase(const TCHAR *profile, BOOL bReadOnly)
// set the memory, lists & UTF8 manager
mir_getLP(&pluginInfo);
- std::auto_ptr<CDbxKV> db(new CDbxKV(profile, (bReadOnly) ? DBMODE_READONLY : 0));
+ std::auto_ptr<CDbxKyoto> db(new CDbxKyoto(profile, (bReadOnly) ? DBMODE_READONLY : 0));
if (db->Load(false) != ERROR_SUCCESS)
return NULL;
@@ -76,14 +76,14 @@ static MIDatabase* LoadDatabase(const TCHAR *profile, BOOL bReadOnly)
static int UnloadDatabase(MIDatabase *db)
{
- g_Dbs.remove((CDbxKV*)db);
- delete (CDbxKV*)db;
+ g_Dbs.remove((CDbxKyoto*)db);
+ delete (CDbxKyoto*)db;
return 0;
}
MIDatabaseChecker* CheckDb(const TCHAR *profile, int *error)
{
- std::auto_ptr<CDbxKV> db(new CDbxKV(profile, DBMODE_READONLY));
+ std::auto_ptr<CDbxKyoto> db(new CDbxKyoto(profile, DBMODE_READONLY));
if (db->Load(true) != ERROR_SUCCESS) {
*error = ERROR_ACCESS_DENIED;
return NULL;
diff --git a/plugins/Dbx_kyoto/src/ui.cpp b/plugins/Dbx_kyoto/src/ui.cpp
index a4ba3d12c5..7e033eaa6b 100644
--- a/plugins/Dbx_kyoto/src/ui.cpp
+++ b/plugins/Dbx_kyoto/src/ui.cpp
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct DlgChangePassParam
{
- CDbxKV *db;
+ CDbxKyoto *db;
TCHAR newPass[100];
int wrongPass;
};
@@ -117,7 +117,7 @@ static INT_PTR CALLBACK sttEnterPassword(HWND hwndDlg, UINT uMsg, WPARAM wParam,
return FALSE;
}
-bool CDbxKV::EnterPassword(const BYTE *pKey, const size_t keyLen)
+bool CDbxKyoto::EnterPassword(const BYTE *pKey, const size_t keyLen)
{
DlgChangePassParam param = { this };
while (true) {
@@ -138,7 +138,7 @@ bool CDbxKV::EnterPassword(const BYTE *pKey, const size_t keyLen)
/////////////////////////////////////////////////////////////////////////////////////////
-static bool CheckOldPassword(HWND hwndDlg, CDbxKV *db)
+static bool CheckOldPassword(HWND hwndDlg, CDbxKyoto *db)
{
if (db->usesPassword()) {
TCHAR buf[100];
@@ -238,7 +238,7 @@ static INT_PTR CALLBACK sttChangePassword(HWND hwndDlg, UINT uMsg, WPARAM wParam
static INT_PTR ChangePassword(void* obj, WPARAM, LPARAM)
{
- CDbxKV *db = (CDbxKV*)obj;
+ CDbxKyoto *db = (CDbxKyoto*)obj;
DlgChangePassParam param = { db };
DialogBoxParam(g_hInst, MAKEINTRESOURCE(db->usesPassword() ? IDD_CHANGEPASS : IDD_NEWPASS), 0, sttChangePassword, (LPARAM)&param);
return 0;
@@ -248,14 +248,14 @@ static INT_PTR ChangePassword(void* obj, WPARAM, LPARAM)
INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- CDbxKV *db = (CDbxKV *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ CDbxKyoto *db = (CDbxKyoto *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- db = (CDbxKV*)lParam;
+ db = (CDbxKyoto*)lParam;
CheckRadioButton(hwndDlg, IDC_STANDARD, IDC_TOTAL, IDC_STANDARD + db->isEncrypted());
return TRUE;
@@ -298,7 +298,7 @@ static int OnOptionsInit(PVOID obj, WPARAM wParam, LPARAM)
/////////////////////////////////////////////////////////////////////////////////////////
-void CDbxKV::UpdateMenuItem()
+void CDbxKyoto::UpdateMenuItem()
{
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_NAME;
@@ -309,7 +309,7 @@ void CDbxKV::UpdateMenuItem()
static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM)
{
- CDbxKV *db = (CDbxKV*)obj;
+ CDbxKyoto *db = (CDbxKyoto*)obj;
Icon_Register(g_hInst, LPGEN("Database"), iconList, SIZEOF(iconList), "mmap");
@@ -333,7 +333,7 @@ static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM)
/////////////////////////////////////////////////////////////////////////////////////////
-void CDbxKV::InitDialogs()
+void CDbxKyoto::InitDialogs()
{
hService = CreateServiceFunctionObj(MS_DB_CHANGEPASSWORD, ChangePassword, this);
hHook = HookEventObj(ME_SYSTEM_MODULESLOADED, OnModulesLoaded, this);