[evolution-patches] patch to e-contact.c



We need this or else we end up writing out empty EMAIL attributes if the
user has entered one and then cleared the text in the contact editor
(the only way to actually delete an email address.)

Chris
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/ChangeLog,v
retrieving revision 1.121
diff -u -r1.121 ChangeLog
--- ChangeLog	7 Apr 2004 23:37:37 -0000	1.121
+++ ChangeLog	13 Apr 2004 03:21:43 -0000
@@ -1,3 +1,9 @@
+2004-04-12  Chris Toshok  <toshok ximian com>
+
+	* libebook/e-contact.c (e_contact_set_property): remove the
+	MULTI_ELEM attribute if the string is NULL or empty.  This keeps
+	us from writing out empty EMAIL attributes.
+
 2004-04-07  Chris Toshok  <toshok ximian com>
 
 	* libebook/e-vcard.h: reorder the EVC_X #defines a bit, and add in
Index: libebook/e-contact.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-contact.c,v
retrieving revision 1.29
diff -u -r1.29 e-contact.c
--- libebook/e-contact.c	2 Apr 2004 07:23:20 -0000	1.29
+++ libebook/e-contact.c	13 Apr 2004 03:21:45 -0000
@@ -694,6 +694,7 @@
 			int num_left = info->list_elem;
 			GList *attrs = e_vcard_get_attributes (E_VCARD (contact));
 			GList *l;
+			char *sval;
 
 			for (l = attrs; l; l = l->next) {
 				const char *name;
@@ -709,17 +710,24 @@
 				}
 			}
 
-			if (found) {
-				/* we found it, overwrite it */
-				e_vcard_attribute_remove_values (attr);
+			sval = g_value_get_string (value);
+			if (sval && *sval) {
+				if (found) {
+					/* we found it, overwrite it */
+					e_vcard_attribute_remove_values (attr);
+				}
+				else {
+					/* we didn't find it - add a new attribute */
+					attr = e_vcard_attribute_new (NULL, info->vcard_field_name);
+					e_vcard_add_attribute (E_VCARD (contact), attr);
+				}
+
+				e_vcard_attribute_add_value (attr, sval);
 			}
 			else {
-				/* we didn't find it - add a new attribute */
-				attr = e_vcard_attribute_new (NULL, info->vcard_field_name);
-				e_vcard_add_attribute (E_VCARD (contact), attr);
+				if (found)
+					e_vcard_remove_attribute (E_VCARD (contact), attr);
 			}
-
-			e_vcard_attribute_add_value (attr, g_value_get_string (value));
 		}
 		else if (info->t & E_CONTACT_FIELD_TYPE_ATTR_TYPE) {
 			/* XXX this is kinda broken - we don't insert


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