summaryrefslogtreecommitdiff
path: root/plugins/Dbx_sqlite/src/main.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-02-16 22:01:27 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-02-16 22:01:27 +0300
commit72348ec753695b71234631f4c358ca4505a1d737 (patch)
tree7877ec2c315878cec15e6090eb6b9705c2d2e97a /plugins/Dbx_sqlite/src/main.cpp
parent9cc1ea5f3c117a5416ea5baf213bb691c0a5e9eb (diff)
fixes #2745 (Dbx_sqlite: wrong behaviour when launching second Miranda with the same profile)
Diffstat (limited to 'plugins/Dbx_sqlite/src/main.cpp')
-rw-r--r--plugins/Dbx_sqlite/src/main.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/plugins/Dbx_sqlite/src/main.cpp b/plugins/Dbx_sqlite/src/main.cpp
index e3fe8b51d9..6c0f75b741 100644
--- a/plugins/Dbx_sqlite/src/main.cpp
+++ b/plugins/Dbx_sqlite/src/main.cpp
@@ -27,14 +27,38 @@ CMPlugin::CMPlugin() :
/////////////////////////////////////////////////////////////////////////////////////////
+// returns 0 if the profile is created, EMKPRF*
+static int makeDatabase(const wchar_t *profile)
+{
+ std::unique_ptr<CDbxSQLite> db(new CDbxSQLite(profile, false, false));
+ return db->Create();
+}
+
+// returns 0 if the given profile has a valid header
+static int grokHeader(const wchar_t *profile)
+{
+ std::unique_ptr<CDbxSQLite> db(new CDbxSQLite(profile, true, true));
+ return db->Check();
+}
+
+// returns 0 if all the APIs are injected otherwise, 1
+static MDatabaseCommon* loadDatabase(const wchar_t *profile, BOOL bReadOnly)
+{
+ std::unique_ptr<CDbxSQLite> db(new CDbxSQLite(profile, bReadOnly, false));
+ if (db->Load() != ERROR_SUCCESS)
+ return nullptr;
+
+ return db.release();
+}
+
static DATABASELINK dblink =
{
MDB_CAPS_CREATE | MDB_CAPS_COMPACT,
"dbx_sqlite",
L"SQLite database driver",
- &CDbxSQLite::Create,
- &CDbxSQLite::Check,
- &CDbxSQLite::Load,
+ makeDatabase,
+ grokHeader,
+ loadDatabase ,
};
STDMETHODIMP_(DATABASELINK *) CDbxSQLite::GetDriver()