Bug 83782 - Copied addresses in kaddressbook won't sync into Palm
Summary: Copied addresses in kaddressbook won't sync into Palm
Status: RESOLVED FIXED
Alias: None
Product: kpilot
Classification: Applications
Component: Contacts Conduit (show other bugs)
Version: unspecified
Platform: Mandrake RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: groot
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-21 18:33 UTC by Michel Bouissou
Modified: 2009-03-16 15:27 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Bouissou 2004-06-21 18:33:56 UTC
Version:           3.2 (using KDE KDE 3.2.1KDE 1.2)
Installed from:    Mandrake RPMsMandrake RPMs
OS:                Linux

When, in kadddressbook, a new entry is created by copying/pasting an existing one, and then changing some elements inside it (for several people in the same family for example), then the "pasted" entry will never be synced to a Palm using kpilot.

Does the new entry inherit the same record number as the old one, a bad status flag or something like this ?

Even modifying the "pasted" entry again won't let it sync to the Palm.
Comment 1 Tobias Koenig 2004-07-17 15:57:09 UTC
KAddressBook gives the pasted entry a new uid, I don't know whether KPilot does some magic there...
Comment 2 Reinhold Kainhofer 2004-07-26 13:12:55 UTC
Yes, kpilot also stores the record ID together with the addressee, so although the addressee has a new uid, there will still be two entries with the same record ID (i.e. the same palm entry assigned to it). This is a problem similar to the one of bug #75372 for the calendar.

Cheers,
Reinhold
Comment 3 Jason 'vanRijn' Kasper 2005-05-15 07:59:52 UTC
I believe I've just fixed this little guy.  I'm going to mark it as fixed.  Michel, if possible, I'd greatly appreciate you helping me make sure this bug is fixed.  You'll need to update to the latest svn source from the 3.4 branch.

From the commit comments....

- copy/paste in kaddressbook resulted in X-KPILOT-RecordID being carried
  over to the new (pasted) contact/addressee.  this means that only one got
  synced to the pilot, looking a whole lot like data loss to the user.
- we now check for duplicate X-KPILOT-RecordID's as part of our loading
  process, and if we find one, we wipe out this custom field in the
  addressee, which causes a new pilot id to be assigned to it when it's
  synced to the pilot later.

the diff....

Index: conduits/abbrowserconduit/abbrowser-conduit.h
===================================================================
--- conduits/abbrowserconduit/abbrowser-conduit.h	(revision 413979)
+++ conduits/abbrowserconduit/abbrowser-conduit.h	(working copy)
@@ -99,7 +99,7 @@
 
 	/* Given a list of contacts, creates the pilot id to contact key map
 	 * and a list of new contacts in O(n) time (single pass) */
-	void _mapContactsToPilot( QMap < recordid_t, QString> &idContactMap) const;
+	void _mapContactsToPilot( QMap < recordid_t, QString> &idContactMap);
 	/* Do the preperations before doSync or doBackup.
 	 * Load contacts, set the pilot */
 	bool _prepare();
Index: conduits/abbrowserconduit/abbrowser-conduit.cc
===================================================================
--- conduits/abbrowserconduit/abbrowser-conduit.cc	(revision 413979)
+++ conduits/abbrowserconduit/abbrowser-conduit.cc	(working copy)
@@ -118,7 +118,7 @@
 
 /* Builds the map which links record ids to uid's of Addressee
 */
-void AbbrowserConduit::_mapContactsToPilot(QMap < recordid_t, QString > &idContactMap) const
+void AbbrowserConduit::_mapContactsToPilot(QMap < recordid_t, QString > &idContactMap)
 {
 	FUNCTIONSETUP;
 
@@ -132,7 +132,26 @@
 		if(!recid.isEmpty())
 		{
 			recordid_t id = recid.toULong();
-			idContactMap.insert(id, aContact.uid());
+			// safety check:  make sure that we don't already have a map for this pilot id.
+			// if we do (this can come from a copy/paste in kaddressbook, etc.), then we need
+			// to reset our Addressee so that we can assign him a new pilot Id later and sync
+			// him properly.  if we don't do this, we'll lose one of these on the pilot.
+			if (!idContactMap.contains(id))
+			{
+				idContactMap.insert(id, aContact.uid());
+			}
+			else
+			{
+#ifdef DEBUG
+		DEBUGCONDUIT << fname << ": found duplicate pilot key: ["
+						<< id << "], removing pilot id from addressee: ["
+						<< aContact.realName() << "]" << endl;
+#endif
+				aBook->removeAddressee(aContact);
+				aContact.removeCustom(appString, idString);
+				aBook->insertAddressee(aContact);
+				abChanged = true;
+			}
 		}
 	}
 #ifdef DEBUG