[Commits] vcard-utils.c 1.4 1.5

miras at claws-mail.org miras at claws-mail.org
Thu Oct 4 01:53:24 CEST 2012


Update of /home/claws-mail/contacts/libversit
In directory srv:/tmp/cvs-serv11578/libversit

Modified Files:
	vcard-utils.c 
Log Message:
2012-10-03 [mir]	0.6.0cvs89

	* libversit/vcard-utils.c
	    Support for email alias when importing
	    and exporting contacts. 

Index: vcard-utils.c
===================================================================
RCS file: /home/claws-mail/contacts/libversit/vcard-utils.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- vcard-utils.c	7 Aug 2012 17:52:33 -0000	1.4
+++ vcard-utils.c	3 Oct 2012 23:53:22 -0000	1.5
@@ -404,15 +404,38 @@
 				}
 			}
 			else if (strcmp(attrib, "email") == 0) {
+				Email* e = g_new0(Email, 1);
+				gboolean has_attr = FALSE;
+				VObjectIterator email_iter;
+				
+				initPropIterator(&email_iter, prop);
+				while (! e->alias && moreIteration(&email_iter)) {
+					has_attr = TRUE;
+					VObject *eachProp = nextVObject(&email_iter);
+					const gchar* attr = vObjectName(eachProp);
+					if (attr) {
+						if (strcasecmp("WORK", attr) == 0)
+							e->alias = g_strdup(attr);
+						else if (strcasecmp("HOME", attr) == 0)
+							e->alias = g_strdup(attr);
+						else if (strcasecmp("OTHER", attr) == 0)
+							e->alias = g_strdup(attr);
+					}
+				}
+				if (has_attr && ! e->alias)
+					e->alias = g_strdup("OTHER");
 				value = vcard_value(prop);
 				if (value) {
-					Email* e = g_new0(Email, 1);
 					e->email = g_strdup(value);
+					g_free(value);
+				}
+				if (has_attr || e->email) {
 					if (debug_get_mode())
 						email_dump(e, stderr);
 					contact->emails = g_slist_append(contact->emails, e);
-					g_free(value);
 				}
+				else
+					email_free(e);
 			}
 			else if (strcmp(attrib, "image") == 0) {
 				value = vcard_value(prop);
@@ -565,10 +588,10 @@
 		else if (strcasecmp(e->alias, "home") == 0)
 			attr = g_strconcat(VCEmailAddressProp, ";HOME", NULL);
 		else
-			attr = g_strconcat(VCEmailAddressProp, ";INTERNET", NULL);
+			attr = g_strconcat(VCEmailAddressProp, ";OTHER", NULL);
 	}
 	else
-		attr = g_strconcat(VCEmailAddressProp, ";INTERNET", NULL);
+		attr = g_strconcat(VCEmailAddressProp, ";OTHER", NULL);
 		
 	addPropValue(o, attr, e->email);
 	g_free(attr);		



More information about the Commits mailing list