From 3a4aec44402f1d508703a473502f84d2eb6b03d2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 12 Oct 2014 19:59:19 +0000 Subject: fix for metaimport git-svn-id: http://svn.miranda-ng.org/main/trunk@10773 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Import/src/import.cpp | 2 +- plugins/Import/src/utils.cpp | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) (limited to 'plugins/Import') diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 43ca275ae6..dca01e591c 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -506,7 +506,7 @@ void ImportMeta(DBCachedContact *ccSrc) for (int i = 0; i < ccSrc->nSubs; i++) { MCONTACT hDstSub = MapContact(ccSrc->pSubs[i]); if (db_mc_getMeta(hDstSub) == NULL) // add a sub if needed - CallService(MS_MC_ADDTOMETA, hDest, hDstSub); + CallService(MS_MC_ADDTOMETA, hDstSub, hDest); } } diff --git a/plugins/Import/src/utils.cpp b/plugins/Import/src/utils.cpp index 8ab913ecf9..84fe165a26 100644 --- a/plugins/Import/src/utils.cpp +++ b/plugins/Import/src/utils.cpp @@ -36,7 +36,7 @@ bool IsProtocolLoaded(const char *pszProtocolName) // ------------------------------------------------ // Returns 1 if successful and 0 when it fails. -int CreateGroup(const TCHAR* group, MCONTACT hContact) +int CreateGroup(const TCHAR *group, MCONTACT hContact) { if (group == NULL) return 0; @@ -49,22 +49,18 @@ int CreateGroup(const TCHAR* group, MCONTACT hContact) // Check for duplicate & find unused id char groupIdStr[11]; for (int groupId = 0;; groupId++) { - DBVARIANT dbv; itoa(groupId, groupIdStr, 10); - if (db_get_ts(NULL, "CListGroups", groupIdStr, &dbv)) + ptrT tszDbGroup(db_get_tsa(NULL, "CListGroups", groupIdStr)); + if (tszDbGroup == NULL) break; - if (!lstrcmp(dbv.ptszVal + 1, tszGrpName + 1)) { + if (!lstrcmp((TCHAR*)tszDbGroup+1, tszGrpName+1)) { if (hContact) db_set_ts(hContact, "CList", "Group", tszGrpName + 1); else AddMessage(LPGENT("Skipping duplicate group %s."), tszGrpName + 1); - - db_free(&dbv); return 0; } - - db_free(&dbv); } db_set_ts(NULL, "CListGroups", groupIdStr, tszGrpName); @@ -90,16 +86,14 @@ bool IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei) static MCONTACT hPreviousContact = INVALID_CONTACT_ID; static HANDLE hPreviousDbEvent = NULL; - HANDLE hExistingDbEvent; - DWORD dwEventTimeStamp; - // get last event - if (!(hExistingDbEvent = db_event_last(hContact))) + HANDLE hExistingDbEvent = db_event_last(hContact); + if (hExistingDbEvent == NULL) return FALSE; DBEVENTINFO dbeiExisting = { sizeof(dbeiExisting) }; db_event_get(hExistingDbEvent, &dbeiExisting); - dwEventTimeStamp = dbeiExisting.timestamp; + DWORD dwEventTimeStamp = dbeiExisting.timestamp; // compare with last timestamp if (dbei.timestamp > dwEventTimeStamp) { @@ -129,7 +123,6 @@ bool IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei) // remember event dwPreviousTimeStamp = dwEventTimeStamp; hPreviousDbEvent = hExistingDbEvent; - if (dbei.timestamp != dwEventTimeStamp) return FALSE; } @@ -225,8 +218,9 @@ bool IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO dbei) ///////////////////////////////////////////////////////////////////////////////////////// // icons -static IconItem iconList[] = { - { LPGEN("Import..."), "import_main", IDI_IMPORT } +static IconItem iconList[] = +{ + { LPGEN("Import..."), "import_main", IDI_IMPORT } }; HICON GetIcon(int iIconId) -- cgit v1.2.3