diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Import/src/import.cpp | 52 | ||||
-rw-r--r-- | plugins/Import/src/import.h | 1 |
2 files changed, 49 insertions, 4 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 634e6b716e..403cf703ec 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -40,7 +40,23 @@ static int CompareAccs(const AccountMap *p1, const AccountMap *p2) { return stricmp(p1->szSrcAcc, p2->szSrcAcc);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct ContactMap
+{
+ ContactMap(MCONTACT _src, MCONTACT _dst) :
+ srcID(_src),
+ dstID(_dst)
+ {}
+
+ MCONTACT srcID, dstID;
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static OBJLIST<AccountMap> arAccountMap(5, CompareAccs);
+static OBJLIST<ContactMap> arContactMap(50, NumericKeySortT);
+static LIST<DBCachedContact> arMetas(10);
/////////////////////////////////////////////////////////////////////////////////////////
// local data
@@ -191,7 +207,8 @@ static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto) if (lstrcmpA(pa->szProtoName, szBaseProto))
continue;
- if (pa->bOldProto)
+ // these protocols have no accounts, and their name match -> success
+ if (pa->bOldProto || pa->bIsVirtual || pa->bDynDisabled)
return pa;
char *pszUniqueSetting = (char*)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
@@ -297,6 +314,8 @@ static MCONTACT AddContact(HWND hdlgProgress, char* szProto, char* pszUniqueSett return hContact;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static int ImportGroup(const char* szSettingName, LPARAM lParam)
{
int *pnGroups = (int*)lParam;
@@ -310,8 +329,6 @@ static int ImportGroup(const char* szSettingName, LPARAM lParam) return 0;
}
-/////////////////////////////////////////////////////////////////////////////////////////
-
static int ImportGroups()
{
int nGroups = 0;
@@ -324,6 +341,15 @@ static int ImportGroups() return nGroups;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void ImportMeta(DBCachedContact *cc)
+{
+
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static MCONTACT ImportContact(MCONTACT hSrc)
{
TCHAR id[40], *pszUniqueID;
@@ -335,6 +361,11 @@ static MCONTACT ImportContact(MCONTACT hSrc) return NULL;
}
+ if (cc->IsMeta()) {
+ arMetas.insert(cc);
+ return NULL;
+ }
+
AccountMap *pda = arAccountMap.find((AccountMap*)&cc->szProto);
if (pda == NULL) {
AddMessage(LPGENT("Skipping contact, account %S cannot be mapped."), cc->szProto);
@@ -354,7 +385,11 @@ static MCONTACT ImportContact(MCONTACT hSrc) }
DBVARIANT dbv;
- if (myGet(hSrc, cc->szProto, pszUniqueSetting, &dbv)) {
+ if (!strcmp(cc->szProto, META_PROTO)) {
+ dbv.type = DBVT_DWORD;
+ dbv.dVal = hSrc;
+ }
+ else if (myGet(hSrc, cc->szProto, pszUniqueSetting, &dbv)) {
AddMessage(LPGENT("Skipping %S contact, ID not found"), cc->szProto);
return NULL;
}
@@ -387,6 +422,8 @@ static MCONTACT ImportContact(MCONTACT hSrc) hDst = AddContact(hdlgProgress, pda->szDstAcc, pszUniqueSetting, &dbv, pszUniqueID, tszNick, tszGroup);
mir_free(tszGroup), mir_free(tszNick);
+ arContactMap.insert(new ContactMap(hSrc, hDst));
+
if (hDst != INVALID_CONTACT_ID) {
// Hidden?
if (!myGet(hSrc, "CList", "Hidden", &dbv)) {
@@ -673,6 +710,9 @@ void MirandaImport(HWND hdlg) // Get next contact in chain
hContact = srcDb->FindNextContact(hContact);
}
+
+ for (i = 0; i < arMetas.getCount(); i++)
+ ImportMeta(arMetas[i]);
}
else AddMessage(LPGENT("Skipping new contacts import."));
AddMessage(_T(""));
@@ -736,4 +776,8 @@ void MirandaImport(HWND hdlg) LPGENT("Skipped %d duplicates and %d filtered events.") : LPGENT("Skipped %d duplicates."),
nDupes, nSkippedEvents);
}
+
+ arMetas.destroy();
+ arAccountMap.destroy();
+ arContactMap.destroy();
}
diff --git a/plugins/Import/src/import.h b/plugins/Import/src/import.h index 81daba0722..f20ae8300c 100644 --- a/plugins/Import/src/import.h +++ b/plugins/Import/src/import.h @@ -42,6 +42,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_icolib.h>
#include <m_clist.h>
#include <m_db_int.h>
+#include <m_metacontacts.h>
#include "version.h"
#include "resource.h"
|