[evolution-patches] [Conduits:AddressBook] Fix for #269342



Hi,

Attached patch fixes #269342. ChangeLog explains the fix.

Let me know your comments.

Thanks,

V. Varadhan
Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.2016
diff -u -p -r1.2016 ChangeLog
--- addressbook/ChangeLog	10 Dec 2005 09:52:22 -0000	1.2016
+++ addressbook/ChangeLog	12 Dec 2005 18:39:46 -0000
@@ -1,3 +1,9 @@
+2005-12-12  Veerapuram Varadhan <vvaradhan novell com>
+
+	* conduit/addressbook-conduit.c (local_record_from_ecard): Handle
+	different parts of a name properly. Fixes #269342
+	Shutdown few compiler warnings.
+	
 2005-12-10  Sushma Rai  <rsushma novell com>
 
 	* gui/contact-editor/e-contact-editor.c (fill_in_address_textview):
@@ -6,10 +12,10 @@
 
 2005-12-06  Veerapuram Varadhan <vvaradhan novell com>
 	
-	* conduits/addressbook-conduit.c: (pre_sync):
+	* conduit/addressbook-conduit.c: (pre_sync):
 	Authenticate by reading the store-password for calendars that has
 	"auth" property set.
-	* conduits/addressbook-conduit.c: (addressbook_authenticate):
+	* conduit/addressbook-conduit.c: (addressbook_authenticate):
 	Implement authentication using e-passwords.
 	
 2005-11-26  Tor Lillqvist  <tml novell com>
Index: addressbook/conduit/address-conduit.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/conduit/address-conduit.c,v
retrieving revision 1.88
diff -u -p -r1.88 address-conduit.c
--- addressbook/conduit/address-conduit.c	6 Dec 2005 08:43:37 -0000	1.88
+++ addressbook/conduit/address-conduit.c	12 Dec 2005 18:39:58 -0000
@@ -818,6 +818,9 @@ local_record_from_ecard (EAddrLocalRecor
 	EContactField field;
 	gboolean syncable;
 	int i;
+	EContactName *name = NULL; 
+	char *firstname = NULL;
+	char *midlastname = NULL;
 	
 	g_return_if_fail (local != NULL);
 	g_return_if_fail (contact != NULL);
@@ -860,11 +863,58 @@ local_record_from_ecard (EAddrLocalRecor
 		}
 	}
 
-	local->addr->entry[entryFirstname] = e_pilot_utf8_to_pchar (e_contact_get_const (contact, E_CONTACT_GIVEN_NAME));
-	local->addr->entry[entryLastname] = e_pilot_utf8_to_pchar (e_contact_get_const (contact, E_CONTACT_FAMILY_NAME));
+	/*
+	  Handle different parts of a name, viz., Prefix, First,
+	  Middle, Last and Suffix properly.
+	 */
+	name = e_contact_get (contact, E_CONTACT_NAME);	
+	if (name) {
+		char *names[4];
+		int i = 0;
+		
+		if (strlen (name->prefixes) > 0) {
+			names[i] = name->prefixes;
+			i++;
+		}
+		if (strlen (name->given) > 0) {
+			names[i] = name->given;
+			i++;
+		}
+		if (strlen (name->additional) > 0) {
+			names[i] = name->additional;
+			i++;
+		}
+		names[i] = NULL;
+
+		firstname = g_strjoinv (" ", names);
+		
+		i = 0;
+		if (strlen (name->family) > 0) {
+			names[i] = name->family;
+			i++;
+		}
+
+		if (strlen (name->suffixes) > 0) {
+			names[i] = name->suffixes;
+			i++;
+		}
+		names[i] = NULL;		
+
+		midlastname = g_strjoinv (" ", names);
+		
+		e_contact_name_free (name);
+	} else {
+		firstname = e_contact_get (contact, E_CONTACT_GIVEN_NAME);
+		midlastname = e_contact_get (contact, E_CONTACT_FAMILY_NAME);
+	}
+	local->addr->entry[entryFirstname] = e_pilot_utf8_to_pchar (firstname);
+	local->addr->entry[entryLastname] = e_pilot_utf8_to_pchar (midlastname);
 	local->addr->entry[entryCompany] = e_pilot_utf8_to_pchar (e_contact_get_const (contact, E_CONTACT_ORG));
 	local->addr->entry[entryTitle] = e_pilot_utf8_to_pchar (e_contact_get_const (contact, E_CONTACT_TITLE));
 	
+	g_free (firstname);
+	g_free (midlastname);
+	
 	/* See if the default has something in it */
 	if ((address = e_contact_get (contact, ctxt->cfg->default_address))) {
 		field = ctxt->cfg->default_address;
@@ -1162,13 +1212,13 @@ static void
 addressbook_authenticate (EBook *book, 
 			  gpointer data)
 {
-	gchar *auth;
-	gchar *user;
-	gchar *passwd;
-	gchar *str_uri;
-	gchar *pass_key;
-	gchar *auth_domain;
-	gchar *component_name;
+	const char *auth;
+	const char *user;
+	char *passwd;
+	char *str_uri;
+	char *pass_key;
+	const char *auth_domain;
+	const char *component_name;
 	EUri *e_uri;
 
 	ESource *source = (ESource *)data;
@@ -1215,7 +1265,7 @@ pre_sync (GnomePilotConduit *conduit,
 	unsigned char *buf;
 	char *filename;
 	char *change_id;
-	char *auth;
+	const char *auth;
 	gint num_records, add_records = 0, mod_records = 0, del_records = 0;
 
 	abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]