[evolution-patches] vcard attribute groups patch for e-d-s



rfc 2425 says:

"Implementations that do not understand or support grouping MAY simply
strip off any text before a "." to the left of the type name and present
the types and values as normal."

Since we don't support grouping of attributes, we need to ignore them,
which we weren't doing before.  This makes more fields from, say,
apple's addressbook show up when the cards are imported.

Chris
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/ChangeLog,v
retrieving revision 1.113
diff -u -r1.113 ChangeLog
--- ChangeLog	31 Mar 2004 22:42:26 -0000	1.113
+++ ChangeLog	31 Mar 2004 22:47:07 -0000
@@ -1,3 +1,15 @@
+2004-03-31  Chris Toshok  <toshok ximian com>
+
+	* libebook/e-contact.c (e_contact_get_first_attr): ignore the
+	attribute's group.
+	(e_contact_set_property): same.
+	(e_contact_find_attribute_with_types): same.
+	(e_contact_get_property): same.
+	(e_contact_get_attributes): same.
+
+	* libebook/e-vcard.c (e_vcard_to_string_vcard_30): ignore the
+	attribute's group when looking for VERSION attributes.
+
 2004-03-30  Chris Toshok  <toshok ximian com>
  
 	[ backend portion of fix for #51977 ]
Index: libebook/e-vcard.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-vcard.c,v
retrieving revision 1.11
diff -u -r1.11 e-vcard.c
--- libebook/e-vcard.c	31 Mar 2004 22:38:22 -0000	1.11
+++ libebook/e-vcard.c	31 Mar 2004 22:47:08 -0000
@@ -692,8 +692,7 @@
 		GString *attr_str;
 		int l;
 
-		if (attr->group == NULL &&
-		    !g_ascii_strcasecmp (attr->name, "VERSION"))
+		if (!g_ascii_strcasecmp (attr->name, "VERSION"))
 			continue;
 
 		attr_str = g_string_new ("");
@@ -722,18 +721,18 @@
 				for (v = param->values; v; v = v->next) {
 					char *value = v->data;
 					char *p = value;
-					gboolean ws = FALSE;
+					gboolean quotes = FALSE;
 					while (*p) {
-						if (g_unichar_isspace (g_utf8_get_char (p))) {
-							ws = TRUE;
+						if (!g_unichar_isalnum (g_utf8_get_char (p))) {
+							quotes = TRUE;
 							break;
 						}
 						p = g_utf8_next_char (p);
 					}
-					if (ws)
+					if (quotes)
 						attr_str = g_string_append_c (attr_str, '"');
 					attr_str = g_string_append (attr_str, value);
-					if (ws)
+					if (quotes)
 						attr_str = g_string_append_c (attr_str, '"');
 					if (v->next)
 						attr_str = g_string_append_c (attr_str, ',');
Index: libebook/e-contact.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-contact.c,v
retrieving revision 1.28
diff -u -r1.28 e-contact.c
--- libebook/e-contact.c	31 Mar 2004 22:42:26 -0000	1.28
+++ libebook/e-contact.c	31 Mar 2004 22:47:10 -0000
@@ -347,13 +347,11 @@
 
 	for (l = attrs; l; l = l->next) {
 		EVCardAttribute *attr = l->data;
-		const char *name, *group;
+		const char *name;
 
-		group = e_vcard_attribute_get_group (attr);
 		name = e_vcard_attribute_get_name (attr);
 
-		/* all the attributes we care about should be in group "" */
-		if ((!group || !*group) && !strcasecmp (name, attr_name))
+		if (!strcasecmp (name, attr_name))
 			return attr;
 	}
 
@@ -698,14 +696,12 @@
 			GList *l;
 
 			for (l = attrs; l; l = l->next) {
-				const char *name, *group;
+				const char *name;
 
 				attr = l->data;
-				group = e_vcard_attribute_get_group (attr);
 				name = e_vcard_attribute_get_name (attr);
 
-				/* all the attributes we care about should be in group "" */
-				if ((!group || !*group) && !strcasecmp (name, info->vcard_field_name)) {
+				if (!strcasecmp (name, info->vcard_field_name)) {
 					if (num_left-- == 0) {
 						found = TRUE;
 						break;
@@ -739,18 +735,16 @@
 			GList *l;
 
 			for (l = attrs; l && !found; l = l->next) {
-				const char *name, *group;
+				const char *name;
 				gboolean found_needed1, found_needed2;
 
 				found_needed1 = (info->attr_type1 == NULL);
 				found_needed2 = (info->attr_type2 == NULL);
 
 				attr = l->data;
-				group = e_vcard_attribute_get_group (attr);
 				name = e_vcard_attribute_get_name (attr);
 
-				/* all the attributes we care about should be in group "" */
-				if ((!group || !*group) && !strcasecmp (name, info->vcard_field_name)) {
+				if (!strcasecmp (name, info->vcard_field_name)) {
 					GList *params;
 
 					for (params = e_vcard_attribute_get_params (attr); params; params = params->next) {
@@ -989,16 +983,14 @@
 
 	for (l = attrs; l; l = l->next) {
 		EVCardAttribute *attr = l->data;
-		const char *name, *group;
+		const char *name;
 
 		found_needed1 = (type_needed1 == NULL);
 		found_needed2 = (type_needed2 == NULL);
 
-		group = e_vcard_attribute_get_group (attr);
 		name = e_vcard_attribute_get_name (attr);
 
-		/* all the attributes we care about should be in group "" */
-		if ((!group || !*group) && !strcasecmp (name, attr_name)) {
+		if (!strcasecmp (name, attr_name)) {
 			GList *params;
 
 			for (params = e_vcard_attribute_get_params (attr); params; params = params->next) {
@@ -1102,13 +1094,11 @@
 
 			for (l = attrs; l; l = l->next) {
 				EVCardAttribute *attr = l->data;
-				const char *name, *group;
+				const char *name;
 
-				group = e_vcard_attribute_get_group (attr);
 				name = e_vcard_attribute_get_name (attr);
 
-				/* all the attributes we care about should be in group "" */
-				if ((!group || !*group) && !strcasecmp (name, info->vcard_field_name)) {
+				if (!strcasecmp (name, info->vcard_field_name)) {
 					GList *v;
 					int count;
 
@@ -1131,13 +1121,11 @@
 
 			for (l = attrs; l; l = l->next) {
 				EVCardAttribute *attr = l->data;
-				const char *name, *group;
+				const char *name;
 
-				group = e_vcard_attribute_get_group (attr);
 				name = e_vcard_attribute_get_name (attr);
 
-				/* all the attributes we care about should be in group "" */
-				if ((!group || !*group) && !strcasecmp (name, info->vcard_field_name)) {
+				if (!strcasecmp (name, info->vcard_field_name)) {
 					if (num_left-- == 0) {
 						GList *v = e_vcard_attribute_get_values (attr);
 
@@ -1248,13 +1236,11 @@
 
 		for (l = attrs; l; l = l->next) {
 			EVCardAttribute *attr = l->data;
-			const char *name, *group;
+			const char *name;
 
-			group = e_vcard_attribute_get_group (attr);
 			name = e_vcard_attribute_get_name (attr);
 
-			/* all the attributes we care about should be in group "" */
-			if ((!group || !*group) && !strcasecmp (name, info->vcard_field_name)) {
+			if (!strcasecmp (name, info->vcard_field_name)) {
 				GList *v;
 				v = e_vcard_attribute_get_values (attr);
 
@@ -1445,12 +1431,11 @@
 
 	for (a = attrs; a; a = a->next) {
 		EVCardAttribute *attr = a->data;
-		const char *name, *group;
+		const char *name;
 
-		group = e_vcard_attribute_get_group (attr);
 		name = e_vcard_attribute_get_name (attr);
 
-		if ((!group || !*group) && !strcasecmp (name, info->vcard_field_name)) {
+		if (!strcasecmp (name, info->vcard_field_name)) {
 			l = g_list_append (l, e_vcard_attribute_copy (attr));
 		}
 	}


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