From 35a2b1771115068077ce6db13860766e70405de1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 12 Apr 2018 18:34:27 +0300 Subject: MIDatabase became pure interface --- plugins/Dbx_mdbx/src/init.cpp | 40 +++++++++++++++++++++------------------- plugins/Import/src/import.cpp | 21 ++++++++++----------- 2 files changed, 31 insertions(+), 30 deletions(-) (limited to 'plugins') diff --git a/plugins/Dbx_mdbx/src/init.cpp b/plugins/Dbx_mdbx/src/init.cpp index f90995b02c..6efe170cb5 100644 --- a/plugins/Dbx_mdbx/src/init.cpp +++ b/plugins/Dbx_mdbx/src/init.cpp @@ -25,8 +25,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. EXTERN_C void NTAPI tls_callback(PVOID module, DWORD reason, PVOID reserved); +HINSTANCE g_hInst = nullptr; int hLangpack; +BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD reason, LPVOID reserved) +{ + g_hInst = hInstDLL; + tls_callback(hInstDLL, reason, reserved); + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////////////////// + static PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), @@ -41,7 +51,13 @@ static PLUGININFOEX pluginInfo = { 0x7c3d0a33, 0x2646, 0x4001, { 0x91, 0x7, 0xf3, 0x5e, 0xa2, 0x99, 0xd2, 0x92 } } }; -HINSTANCE g_hInst = nullptr; + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_DATABASE, MIID_LAST }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -60,7 +76,7 @@ static int grokHeader(const TCHAR *profile) } // returns 0 if all the APIs are injected otherwise, 1 -static MDatabaseCommon* LoadDatabase(const TCHAR *profile, BOOL bReadOnly) +static MDatabaseCommon* loadDatabase(const TCHAR *profile, BOOL bReadOnly) { // set the memory, lists & UTF8 manager mir_getLP(&pluginInfo); @@ -82,32 +98,18 @@ static DATABASELINK dblink = L"MDBX database driver", makeDatabase, grokHeader, - LoadDatabase + loadDatabase }; -///////////////////////////////////////////////////////////////////////////////////////// - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) -{ - return &pluginInfo; -} - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_DATABASE, MIID_LAST }; - extern "C" __declspec(dllexport) int Load(void) { RegisterDatabasePlugin(&dblink); return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" __declspec(dllexport) int Unload(void) { return 0; } - -BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD reason, LPVOID reserved) -{ - g_hInst = hInstDLL; - tls_callback(hInstDLL, reason, reserved); - return TRUE; -} diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 453108ef26..c5b1389ae3 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -73,8 +73,7 @@ static LIST arMetas(10); static HWND hdlgProgress; static DWORD nDupes, nContactsCount, nMessagesCount, nGroupsCount, nSkippedEvents, nSkippedContacts; -static MDatabaseCommon *srcDb; -static MIDatabase *dstDb; +static MDatabaseCommon *srcDb, *dstDb; ///////////////////////////////////////////////////////////////////////////////////////// @@ -632,7 +631,7 @@ static int ImportGroups() DBCachedContact* FindDestMeta(DBCachedContact *ccSrc) { for (MCONTACT hMeta = dstDb->FindFirstContact(META_PROTO); hMeta != 0; hMeta = dstDb->FindNextContact(hMeta, META_PROTO)) { - DBCachedContact *cc = dstDb->m_cache->GetCachedContact(hMeta); + DBCachedContact *cc = dstDb->getCache()->GetCachedContact(hMeta); if (cc->nSubs != ccSrc->nSubs) continue; @@ -660,7 +659,7 @@ MCONTACT FindExistingMeta(DBCachedContact *ccSrc) if (hDestSub == INVALID_CONTACT_ID) continue; - DBCachedContact *cc = dstDb->m_cache->GetCachedContact(hDestSub); + DBCachedContact *cc = dstDb->getCache()->GetCachedContact(hDestSub); if (cc == nullptr || !cc->IsSub()) // check if it's a sub continue; @@ -697,7 +696,7 @@ void ImportMeta(DBCachedContact *ccSrc) db_set_s(hDest, "Protocol", "p", META_PROTO); CopySettings(ccSrc->contactID, META_PROTO, hDest, META_PROTO); - ccDst = dstDb->m_cache->GetCachedContact(hDest); + ccDst = dstDb->getCache()->GetCachedContact(hDest); if (ccDst == nullptr) // normally it shouldn't happen return; @@ -710,7 +709,7 @@ void ImportMeta(DBCachedContact *ccSrc) if (hSub == INVALID_CONTACT_ID) { hSub = db_add_contact(); - DBCachedContact *ccSub = srcDb->m_cache->GetCachedContact(ccSrc->pSubs[i]); + DBCachedContact *ccSub = srcDb->getCache()->GetCachedContact(ccSrc->pSubs[i]); if (ccSub && ccSub->szProto) { Proto_AddToContact(hDest, ccSub->szProto); CopySettings(ccSrc->contactID, ccSub->szProto, hSub, ccSub->szProto); @@ -726,14 +725,14 @@ void ImportMeta(DBCachedContact *ccSrc) db_set_b(hSub, META_PROTO, "IsSubcontact", 1); db_set_dw(hSub, META_PROTO, "ParentMeta", hDest); - DBCachedContact *ccSub = dstDb->m_cache->GetCachedContact(hSub); + DBCachedContact *ccSub = dstDb->getCache()->GetCachedContact(hSub); if (ccSub) ccSub->parentID = hDest; } } } else { // add missing subs - ccDst = dstDb->m_cache->GetCachedContact(hDest); + ccDst = dstDb->getCache()->GetCachedContact(hDest); if (ccDst == nullptr) // normally it shouldn't happen return; @@ -765,7 +764,7 @@ void ImportMeta(DBCachedContact *ccSrc) static MCONTACT ImportContact(MCONTACT hSrc) { // Check what protocol this contact belongs to - DBCachedContact *cc = srcDb->m_cache->GetCachedContact(hSrc); + DBCachedContact *cc = srcDb->getCache()->GetCachedContact(hSrc); if (cc == nullptr || cc->szProto == nullptr) { AddMessage(LPGENW("Skipping contact with no protocol")); return NULL; @@ -879,7 +878,7 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC if (hContact) { // we ignore history import for metacontacts // the metahistory will be generated automatically by gathering subs' histories - DBCachedContact *cc = srcDb->m_cache->GetCachedContact(hContact); + DBCachedContact *cc = srcDb->getCache()->GetCachedContact(hContact); if (cc == nullptr) return; @@ -1020,7 +1019,7 @@ void MirandaImport(HWND hdlg) { hdlgProgress = hdlg; - if ((dstDb = db_get_current()) == nullptr) { + if ((dstDb = (MDatabaseCommon*)db_get_current()) == nullptr) { AddMessage(LPGENW("Error retrieving current profile, exiting.")); return; } -- cgit v1.2.3