summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src/dbintf.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-02-19 11:48:12 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-02-19 11:48:12 +0000
commit8dc7456651251bc112b9edd9b5fd1c4849d7c83d (patch)
tree3e2e376197c49e77488c109a129ea269b08cb38f /plugins/Db3x_mmap/src/dbintf.cpp
parent8d428350dc3307f8ada75fafece2049cca84e969 (diff)
import to open a database in read-only mode
git-svn-id: http://svn.miranda-ng.org/main/trunk@8172 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src/dbintf.cpp')
-rw-r--r--plugins/Db3x_mmap/src/dbintf.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp
index e17dd576f2..2a6b3be65c 100644
--- a/plugins/Db3x_mmap/src/dbintf.cpp
+++ b/plugins/Db3x_mmap/src/dbintf.cpp
@@ -43,10 +43,10 @@ static int stringCompare2(const char *p1, const char *p2)
return strcmp(p1, p2);
}
-CDb3Mmap::CDb3Mmap(const TCHAR *tszFileName) :
+CDb3Mmap::CDb3Mmap(const TCHAR *tszFileName, bool bReadOnly) :
m_hDbFile(INVALID_HANDLE_VALUE),
m_safetyMode(true),
- m_bReadOnly(true),
+ m_bReadOnly(bReadOnly),
m_dwMaxContactId(1),
m_lMods(50, ModCompare),
m_lOfs(50, OfsCompare),
@@ -113,7 +113,7 @@ int CDb3Mmap::Load(bool bSkipInit)
log0("DB logging running");
DWORD dummy = 0;
- if (bSkipInit)
+ if (m_bReadOnly)
m_hDbFile = CreateFile(m_tszProfileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
else
m_hDbFile = CreateFile(m_tszProfileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL);
@@ -129,33 +129,33 @@ int CDb3Mmap::Load(bool bSkipInit)
memcpy(&m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature));
if (!bSkipInit) {
- m_bReadOnly = false;
-
if (InitMap()) return 1;
if (InitModuleNames()) return 1;
if (InitCrypt()) return EGROKPRF_CANTREAD;
// everything is ok, go on
- if (m_dbHeader.version < DB_095_VERSION) {
- ConvertContacts();
-
- m_dbHeader.version = DB_095_VERSION;
- DBWrite(sizeof(dbSignatureU), &m_dbHeader.version, sizeof(m_dbHeader.version));
+ if (!m_bReadOnly) {
+ if (m_dbHeader.version < DB_095_VERSION) {
+ ConvertContacts();
+
+ m_dbHeader.version = DB_095_VERSION;
+ DBWrite(sizeof(dbSignatureU), &m_dbHeader.version, sizeof(m_dbHeader.version));
+ }
+
+ // we don't need events in the service mode
+ if (ServiceExists(MS_DB_SETSAFETYMODE)) {
+ hContactDeletedEvent = CreateHookableEvent(ME_DB_CONTACT_DELETED);
+ hContactAddedEvent = CreateHookableEvent(ME_DB_CONTACT_ADDED);
+ hSettingChangeEvent = CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
+ hEventMarkedRead = CreateHookableEvent(ME_DB_EVENT_MARKED_READ);
+
+ hEventAddedEvent = CreateHookableEvent(ME_DB_EVENT_ADDED);
+ hEventDeletedEvent = CreateHookableEvent(ME_DB_EVENT_DELETED);
+ hEventFilterAddedEvent = CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
+ }
}
FillContacts();
-
- // we don't need events in the service mode
- if (ServiceExists(MS_DB_SETSAFETYMODE)) {
- hContactDeletedEvent = CreateHookableEvent(ME_DB_CONTACT_DELETED);
- hContactAddedEvent = CreateHookableEvent(ME_DB_CONTACT_ADDED);
- hSettingChangeEvent = CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
- hEventMarkedRead = CreateHookableEvent(ME_DB_EVENT_MARKED_READ);
-
- hEventAddedEvent = CreateHookableEvent(ME_DB_EVENT_ADDED);
- hEventDeletedEvent = CreateHookableEvent(ME_DB_EVENT_DELETED);
- hEventFilterAddedEvent = CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
- }
}
return ERROR_SUCCESS;