summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-01-09 11:17:16 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-01-09 11:17:16 +0300
commitc1137914b90fd115909178ba8e037281708cfd9a (patch)
tree8541542c8ddd138537c74292824e4f5647e1b8e8
parent1c81465a63439cb37c3fbedb0ced3a839ded4a46 (diff)
UnregisterDatabasePlugin - a function to unload database driver on the flow
-rw-r--r--include/m_db_int.h3
-rw-r--r--libs/win32/mir_app.libbin290496 -> 290506 bytes
-rw-r--r--libs/win64/mir_app.libbin290204 -> 290214 bytes
-rw-r--r--plugins/Import/src/dbrw/dbrw.cpp5
-rw-r--r--plugins/Import/src/dbrw/dbrw.h1
-rw-r--r--plugins/Import/src/main.cpp8
-rw-r--r--plugins/Import/src/mcontacts.cpp5
-rw-r--r--plugins/Import/src/stdafx.h5
-rw-r--r--plugins/Import/src/textjson.cpp5
-rw-r--r--src/mir_app/src/db_intf.cpp7
-rw-r--r--src/mir_app/src/mir_app.def3
-rw-r--r--src/mir_app/src/mir_app64.def3
12 files changed, 43 insertions, 2 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h
index 5d4d870bb5..1657a13d05 100644
--- a/include/m_db_int.h
+++ b/include/m_db_int.h
@@ -400,6 +400,9 @@ EXTERN_C MIR_CORE_DLL(void) db_setCurrent(MDatabaseCommon *_db);
// registers a database plugin
EXTERN_C MIR_APP_DLL(void) RegisterDatabasePlugin(DATABASELINK *pDescr);
+// unregisters a database plugin
+EXTERN_C MIR_APP_DLL(void) UnregisterDatabasePlugin(DATABASELINK *pDescr);
+
// looks for a database plugin by its short name
// returns DATABASELINK* of the required plugin or nullptr on error
EXTERN_C MIR_APP_DLL(DATABASELINK*) GetDatabasePlugin(const char *pszDriverName);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 84516634ca..2d8394173c 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 9648bae33d..d2e9e3988b 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/Import/src/dbrw/dbrw.cpp b/plugins/Import/src/dbrw/dbrw.cpp
index 0faa76150c..78a9f5697c 100644
--- a/plugins/Import/src/dbrw/dbrw.cpp
+++ b/plugins/Import/src/dbrw/dbrw.cpp
@@ -103,3 +103,8 @@ void RegisterDbrw()
{
RegisterDatabasePlugin(&dblink);
}
+
+void UnregisterDbrw()
+{
+ UnregisterDatabasePlugin(&dblink);
+}
diff --git a/plugins/Import/src/dbrw/dbrw.h b/plugins/Import/src/dbrw/dbrw.h
index 0d93bc8c47..37c5fe09fa 100644
--- a/plugins/Import/src/dbrw/dbrw.h
+++ b/plugins/Import/src/dbrw/dbrw.h
@@ -28,3 +28,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DBRW_HEADER_STR "SQLite format 3"
void RegisterDbrw();
+void UnregisterDbrw();
diff --git a/plugins/Import/src/main.cpp b/plugins/Import/src/main.cpp
index 875bb59419..8426b289ff 100644
--- a/plugins/Import/src/main.cpp
+++ b/plugins/Import/src/main.cpp
@@ -158,3 +158,11 @@ int CMPlugin::Load()
RegisterJson();
return 0;
}
+
+int CMPlugin::Unload()
+{
+ UnregisterDbrw();
+ UnregisterMContacts();
+ UnregisterJson();
+ return 0;
+}
diff --git a/plugins/Import/src/mcontacts.cpp b/plugins/Import/src/mcontacts.cpp
index deb180203f..8f09c0feb0 100644
--- a/plugins/Import/src/mcontacts.cpp
+++ b/plugins/Import/src/mcontacts.cpp
@@ -320,3 +320,8 @@ void RegisterMContacts()
{
RegisterDatabasePlugin(&dblink);
}
+
+void UnregisterMContacts()
+{
+ UnregisterDatabasePlugin(&dblink);
+}
diff --git a/plugins/Import/src/stdafx.h b/plugins/Import/src/stdafx.h
index b2c4cf6f1e..57511c051c 100644
--- a/plugins/Import/src/stdafx.h
+++ b/plugins/Import/src/stdafx.h
@@ -104,6 +104,7 @@ public:
CMPlugin();
int Load() override;
+ int Unload() override;
};
// Keys
@@ -320,7 +321,11 @@ extern CImportBatch *g_pBatch;
extern HWND g_hwndWizard, g_hwndAccMerge;
void RegisterIcons(void);
+
void RegisterMContacts();
+void UnregisterMContacts();
+
void RegisterJson();
+void UnregisterJson();
INT_PTR ImportContact(WPARAM hContact, LPARAM);
diff --git a/plugins/Import/src/textjson.cpp b/plugins/Import/src/textjson.cpp
index 74c44c9ad7..1c03beca4c 100644
--- a/plugins/Import/src/textjson.cpp
+++ b/plugins/Import/src/textjson.cpp
@@ -412,3 +412,8 @@ void RegisterJson()
{
RegisterDatabasePlugin(&dblink);
}
+
+void UnregisterJson()
+{
+ UnregisterDatabasePlugin(&dblink);
+}
diff --git a/src/mir_app/src/db_intf.cpp b/src/mir_app/src/db_intf.cpp
index c3279fc13b..6207dedeab 100644
--- a/src/mir_app/src/db_intf.cpp
+++ b/src/mir_app/src/db_intf.cpp
@@ -35,6 +35,13 @@ MIR_APP_DLL(void) RegisterDatabasePlugin(DATABASELINK *pDescr)
arDbPlugins.insert(pDescr);
}
+MIR_APP_DLL(void) UnregisterDatabasePlugin(DATABASELINK *pDescr)
+{
+ int idx = arDbPlugins.indexOf(pDescr);
+ if (idx != -1)
+ arDbPlugins.remove(idx);
+}
+
MIR_APP_DLL(DATABASELINK*) GetDatabasePlugin(const char *pszDriverName)
{
for (auto &it : arDbPlugins)
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 960ee9e602..f7ca388bde 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -214,7 +214,8 @@ Profile_GetPathW @293
Profile_SetDefault @294
Chat_GetDefaultEventDescr @295
FindDatabasePlugin @296
-RegisterDatabasePlugin @298
+RegisterDatabasePlugin @297
+UnregisterDatabasePlugin @298
Chat_CustomizeApi @299
Clist_FindItem @314 NONAME
Colour_Get @315
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 071500ff5d..6714b366cb 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -214,7 +214,8 @@ Profile_GetPathW @293
Profile_SetDefault @294
Chat_GetDefaultEventDescr @295
FindDatabasePlugin @296
-RegisterDatabasePlugin @298
+RegisterDatabasePlugin @297
+UnregisterDatabasePlugin @298
Chat_CustomizeApi @299
Clist_FindItem @314 NONAME
Colour_Get @315