summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-04-23 14:20:38 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-04-23 14:20:38 +0300
commit519b59a6aed73060bbe492630cc1820ca3deb83d (patch)
treeb8ea6ba799e7dd5ab5aa4e52640ad4a66da51476
parent677455a7c4b0b48ad95c7736bc626bf5b719e067 (diff)
fixes #3502 (Import: Discord contacts duplicated instead of merged)
-rw-r--r--plugins/Import/src/import.cpp25
-rw-r--r--plugins/Import/src/stdafx.h1
-rw-r--r--plugins/Import/src/version.h4
3 files changed, 27 insertions, 3 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index eb01a4b67f..675d6fbf76 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -100,6 +100,21 @@ MCONTACT CImportBatch::HContactFromID(const char *pszProtoName, const char *pszS
return INVALID_CONTACT_ID;
}
+MCONTACT CImportBatch::HContactFromBlobID(const char *pszProtoName, const char *pszSetting, const DBVARIANT &id)
+{
+ for (MCONTACT hContact = dstDb->FindFirstContact(pszProtoName); hContact; hContact = dstDb->FindNextContact(hContact, pszProtoName)) {
+ DBVARIANT dbv = { DBVT_BLOB };
+ if (db_get_s(hContact, pszProtoName, pszSetting, &dbv, 0))
+ continue;
+
+ bool bEqual = (dbv.cpbVal == id.cpbVal && !memcmp(dbv.pbVal, id.pbVal, id.cpbVal));
+ srcDb->FreeVariant(&dbv);
+ if (bEqual)
+ return hContact;
+ }
+ return INVALID_CONTACT_ID;
+}
+
MCONTACT CImportBatch::HContactFromNumericID(const char *pszProtoName, const char *pszSetting, uint32_t dwID)
{
for (MCONTACT hContact = dstDb->FindFirstContact(pszProtoName); hContact; hContact = dstDb->FindNextContact(hContact, pszProtoName))
@@ -728,7 +743,7 @@ MCONTACT CImportBatch::ImportContact(MCONTACT hSrc)
if (!myGet(hSrc, cc->szProto, (m_pPattern != nullptr) ? "ID" : pszUniqueSetting, &dbv)) {
// Does the contact already exist?
MCONTACT hDst;
- wchar_t id[40];
+ wchar_t id[100];
switch (dbv.type) {
case DBVT_DWORD:
pszUniqueID = _ltow(dbv.dVal, id, 10);
@@ -746,6 +761,14 @@ MCONTACT CImportBatch::ImportContact(MCONTACT hSrc)
hDst = HContactFromID(szDstModuleName, pszUniqueSetting, pszUniqueID);
break;
+ case DBVT_BLOB:
+ if (dbv.cpbVal < _countof(id) / 2) {
+ pszUniqueID = bin2hexW(dbv.pbVal, dbv.cpbVal, id);
+ hDst = HContactFromBlobID(szDstModuleName, pszUniqueSetting, dbv);
+ break;
+ }
+ else __fallthrough;
+
default:
hDst = INVALID_CONTACT_ID;
}
diff --git a/plugins/Import/src/stdafx.h b/plugins/Import/src/stdafx.h
index 3df8c0917a..9427c8a94b 100644
--- a/plugins/Import/src/stdafx.h
+++ b/plugins/Import/src/stdafx.h
@@ -285,6 +285,7 @@ class CImportBatch : public MZeroedObject
PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto, const wchar_t *ptszName, bool bStrict);
MCONTACT HContactFromID(const char *pszProtoName, const char *pszSetting, wchar_t *pwszID);
+ MCONTACT HContactFromBlobID(const char *pszProtoName, const char *pszSetting, const DBVARIANT &dbv);
MCONTACT HContactFromNumericID(const char *pszProtoName, const char *pszSetting, uint32_t dwID);
public:
diff --git a/plugins/Import/src/version.h b/plugins/Import/src/version.h
index f76dfe14a3..3315d47998 100644
--- a/plugins/Import/src/version.h
+++ b/plugins/Import/src/version.h
@@ -1,6 +1,6 @@
#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 95
-#define __RELEASE_NUM 11
+#define __MINOR_VERSION 96
+#define __RELEASE_NUM 3
#define __BUILD_NUM 1
#include <stdver.h>