summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Db3x_mmap/src/dbintf.cpp17
-rw-r--r--plugins/Db3x_mmap/src/dbintfm.cpp6
-rw-r--r--plugins/Db3x_mmap/src/dbtool/finaltasks.cpp12
-rw-r--r--plugins/Db3x_mmap/src/dbtool/initialchecks.cpp8
-rw-r--r--plugins/Db3x_mmap/src/init.cpp4
-rw-r--r--plugins/DbChecker/src/worker.cpp4
-rw-r--r--src/modules/database/database.cpp4
-rw-r--r--src/modules/database/dbintf.cpp7
8 files changed, 25 insertions, 37 deletions
diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp
index 0efc944518..549f32d357 100644
--- a/plugins/Db3x_mmap/src/dbintf.cpp
+++ b/plugins/Db3x_mmap/src/dbintf.cpp
@@ -127,13 +127,16 @@ int CDb3Base::Load(bool bSkipInit)
m_bReadOnly = false;
- hContactDeletedEvent = CreateHookableEvent(ME_DB_CONTACT_DELETED);
- hContactAddedEvent = CreateHookableEvent(ME_DB_CONTACT_ADDED);
- hSettingChangeEvent = CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
-
- hEventAddedEvent = CreateHookableEvent(ME_DB_EVENT_ADDED);
- hEventDeletedEvent = CreateHookableEvent(ME_DB_EVENT_DELETED);
- hEventFilterAddedEvent = CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
+ // 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);
+
+ hEventAddedEvent = CreateHookableEvent(ME_DB_EVENT_ADDED);
+ hEventDeletedEvent = CreateHookableEvent(ME_DB_EVENT_DELETED);
+ hEventFilterAddedEvent = CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
+ }
}
return 0;
}
diff --git a/plugins/Db3x_mmap/src/dbintfm.cpp b/plugins/Db3x_mmap/src/dbintfm.cpp
index 15c52654ac..d917ef300d 100644
--- a/plugins/Db3x_mmap/src/dbintfm.cpp
+++ b/plugins/Db3x_mmap/src/dbintfm.cpp
@@ -39,10 +39,8 @@ CDb3Mmap::~CDb3Mmap()
int CDb3Mmap::Load(bool bSkipInit)
{
int res = CDb3Base::Load(bSkipInit);
- if (!res) {
- if (!bSkipInit)
- if (InitCrypt()) return 1;
- }
+ if (!res && !bSkipInit)
+ if (InitCrypt()) return 1;
return res;
}
diff --git a/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp b/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp
index a7f9c8ef46..dc1e05463c 100644
--- a/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/finaltasks.cpp
@@ -27,17 +27,5 @@ int CDb3Base::WorkFinalTasks(int firstTime)
if (WriteSegment(0, &m_dbHeader, sizeof(m_dbHeader)) == WS_ERROR)
return ERROR_WRITE_FAULT;
- if (m_hDbFile) {
- CloseHandle(m_hDbFile);
- m_hDbFile = NULL;
- }
- if (m_pDbCache) {
- UnmapViewOfFile(m_pDbCache);
- m_pDbCache = NULL;
- }
- if (m_hMap) {
- CloseHandle(m_hMap);
- m_hMap = NULL;
- }
return ERROR_NO_MORE_ITEMS;
}
diff --git a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp
index 2d9dfae04c..4501162263 100644
--- a/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp
+++ b/plugins/Db3x_mmap/src/dbtool/initialchecks.cpp
@@ -48,14 +48,6 @@ int CDb3Base::WorkInitialChecks(int firstTime)
if (res)
return res;
- m_hMap = CreateFileMapping(m_hDbFile, NULL, cb->bAggressive ? PAGE_WRITECOPY : PAGE_READONLY, 0, 0, NULL);
- if (m_hMap)
- m_pDbCache = (BYTE*)MapViewOfFile(m_hMap, cb->bAggressive ? FILE_MAP_COPY : FILE_MAP_READ, 0, 0, 0);
- else {
- cb->pfnAddLogMessage(STATUS_FATAL, TranslateT("Can't create file mapping (%u)"), GetLastError());
- return ERROR_ACCESS_DENIED;
- }
-
if (!m_pDbCache) {
cb->pfnAddLogMessage(STATUS_FATAL, TranslateT("Can't create map view of file (%u)"), GetLastError());
return ERROR_ACCESS_DENIED;
diff --git a/plugins/Db3x_mmap/src/init.cpp b/plugins/Db3x_mmap/src/init.cpp
index 461b64be1d..4938ae9cba 100644
--- a/plugins/Db3x_mmap/src/init.cpp
+++ b/plugins/Db3x_mmap/src/init.cpp
@@ -89,8 +89,8 @@ static int UnloadDatabase(MIDatabase* db)
MIDatabaseChecker* CheckDb(const TCHAR* profile, int *error)
{
- std::auto_ptr<CDb3Mmap> db( new CDb3Mmap(profile));
- if (db->Load(true) != ERROR_SUCCESS) {
+ std::auto_ptr<CDb3Mmap> db(new CDb3Mmap(profile));
+ if (db->Load(false) != ERROR_SUCCESS) {
*error = EGROKPRF_CANTREAD;
return NULL;
}
diff --git a/plugins/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp
index 7bd1d692b7..a20dfaef6b 100644
--- a/plugins/DbChecker/src/worker.cpp
+++ b/plugins/DbChecker/src/worker.cpp
@@ -64,11 +64,11 @@ static void Finalize(time_t& ts)
AddToStatus(STATUS_WARNING,TranslateT("Unable to rename original file"));
}
else if (!opts.bCheckOnly)
- if ( !DeleteFile(opts.filename))
+ if (!DeleteFile(opts.filename))
AddToStatus(STATUS_WARNING,TranslateT("Unable to delete original file"));
if (!opts.bCheckOnly)
- if ( !MoveFile(opts.outputFilename,opts.filename))
+ if (!MoveFile(opts.outputFilename, opts.filename))
AddToStatus(STATUS_WARNING,TranslateT("Unable to rename output file"));
}
diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp
index 21a958ecd4..2e2adf9b50 100644
--- a/src/modules/database/database.cpp
+++ b/src/modules/database/database.cpp
@@ -32,6 +32,8 @@ TCHAR g_profileDir[MAX_PATH], g_profileName[MAX_PATH], g_shortProfileName[MAX_PA
TCHAR* g_defaultProfile;
void EnsureCheckerLoaded(bool);
+void LoadDatabaseServices();
+
bool fileExist(TCHAR* fname)
{
if (*fname == 0)
@@ -437,6 +439,8 @@ int LoadDatabaseModule(void)
_tchdir(szProfile);
szProfile[0] = 0;
+ LoadDatabaseServices();
+
// find out which profile to load
if (!getProfile(szProfile, SIZEOF(szProfile)))
return 1;
diff --git a/src/modules/database/dbintf.cpp b/src/modules/database/dbintf.cpp
index 58b86606b6..14e02c7430 100644
--- a/src/modules/database/dbintf.cpp
+++ b/src/modules/database/dbintf.cpp
@@ -145,8 +145,6 @@ static INT_PTR srvDestroyInstance(WPARAM wParam,LPARAM lParam)
int LoadDbintfModule()
{
- CreateServiceFunction(MS_DB_SETSAFETYMODE, srvSetSafetyMode);
-
CreateServiceFunction(MS_DB_CONTACT_GETCOUNT, srvGetContactCount);
CreateServiceFunction(MS_DB_CONTACT_DELETE, srvDeleteContact);
CreateServiceFunction(MS_DB_CONTACT_ADD, srvAddContact);
@@ -166,3 +164,8 @@ int LoadDbintfModule()
CreateServiceFunction(MS_DB_DESTROY_INSTANCE, srvDestroyInstance);
return 0;
}
+
+void LoadDatabaseServices()
+{
+ CreateServiceFunction(MS_DB_SETSAFETYMODE, srvSetSafetyMode);
+}