[Commits] parser.c 1.4 1.5 parser.h 1.1 1.2

miras at claws-mail.org miras at claws-mail.org
Tue Oct 4 22:21:43 CEST 2011


Update of /home/claws-mail/contacts/xmllib
In directory claws-mail:/tmp/cvs-serv4887/xmllib

Modified Files:
	parser.c parser.h 
Log Message:
2011-10-04 [mir]	0.6.0cvs20

	* dbus-client/client.c
	* plugins/example/example-plugin.c
	* plugins/ldap/ldap-plugin.c
	* plugins/xml/plugin-init.c
	* plugins/xml/xml-plugin.c
	* src/about.c
	* src/callbacks.c
	* src/claws-contacts.c
	* src/contactwindow.c
	* src/gtk-utils.c
	* src/mainwindow.c
	* src/plugin-loader.c
	* src/plugin-loader.h
	* src/plugin.h
	* src/printing.c
	* src/utils.c
	* src/utils.h
	* src/dbus/dbus-service.c
	* src/dbus/server-object.c
	* xmllib/parser.c
	* xmllib/parser.h
	    - Implemented forgotten functionality to reactivate closed
	    address books.
	    - Fix a ton of bugs.
	    - Extended plugin API so that it is possible to get a list
	      of closed address books as well as splitting attributes
	      in mandatory and optional.
	    - Provide plugins a way to have a fixed set of attributes.
	      Eg. LDAP has a finite set of attributes while XML supports
	      an infinite set of attributes. 

Index: parser.c
===================================================================
RCS file: /home/claws-mail/contacts/xmllib/parser.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- parser.c	20 Sep 2011 21:58:44 -0000	1.4
+++ parser.c	4 Oct 2011 20:21:40 -0000	1.5
@@ -427,12 +427,15 @@
 	return books;
 }
 
-void parse_addr_book(AddressBook* abook, gchar** error) {
+void addr_book_set_name(AddressBook* abook, gchar** error) {
 	xmlDocPtr doc;
 	xmlNodePtr cur;
 	xmlChar *key;
 	xmlAttr* attribs;
 
+	if (abook->abook_name && strlen(abook->abook_name) > 0)
+		return;
+
 	if (init_document(BOOKFILE, abook->URL, &doc, &cur, error)) {
 		return;
 	}
@@ -456,7 +459,20 @@
 		//abook->abook_name = g_strdup(_("Missing name"));
 		abook->abook_name = NULL;
 	}
-	
+}
+
+void parse_addr_book(AddressBook* abook, gchar** error) {
+	xmlDocPtr doc;
+	xmlNodePtr cur;
+
+	if (init_document(BOOKFILE, abook->URL, &doc, &cur, error)) {
+		return;
+	}
+
+	addr_book_set_name(abook, error);
+	if (*error)
+		return;
+
 	cur = cur->xmlChildrenNode;
 	while (cur != NULL) {
 		if ((cur->name && !xmlStrcmp(cur->name, (const xmlChar *) "person"))) {
@@ -494,14 +510,34 @@
 		gchar* name = get_abook_name(doc, cur);
 		if (name) {
 			xmlSetProp(cur, (const xmlChar *) "name", xmlCharStrdup(name));
+			new->abook_name = g_strdup(name);
 			g_free(name);
 		}
-		else
-			xmlSetProp(cur, (const xmlChar *) "name", xmlCharStrdup(""));
+		else {
+			if (old->abook_name) {
+				xmlSetProp(cur, (const xmlChar *) "name", xmlCharStrdup(old->abook_name));
+				new->abook_name = g_strdup(old->abook_name);
+			}
+			else {
+				xmlSetProp(cur, (const xmlChar *) "name", xmlCharStrdup(""));
+				new->abook_name = g_strdup("");
+			}
+		}
 	}
 	else {
-		if (! old->abook_name || strcmp(new->abook_name, old->abook_name) != 0) {
+		if (old->abook_name) {
+			if (strcmp(new->abook_name, old->abook_name) != 0) {
+				xmlSetProp(cur, (const xmlChar *) "name", xmlCharStrdup(new->abook_name));
+				new->abook_name = g_strdup(new->abook_name);
+			}
+			else {
+				xmlSetProp(cur, (const xmlChar *) "name", xmlCharStrdup(old->abook_name));
+				new->abook_name = g_strdup(old->abook_name);
+			}
+		}
+		else {
 			xmlSetProp(cur, (const xmlChar *) "name", xmlCharStrdup(new->abook_name));
+			new->abook_name = g_strdup(new->abook_name);
 		}
 	}
 	

Index: parser.h
===================================================================
RCS file: /home/claws-mail/contacts/xmllib/parser.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- parser.h	7 Sep 2011 17:35:29 -0000	1.1
+++ parser.h	4 Oct 2011 20:21:40 -0000	1.2
@@ -51,6 +51,7 @@
 } Attribute;
 
 GSList* parse_index_file(gchar* docname, gchar** error);
+void addr_book_set_name(AddressBook* abook, gchar** error);
 void parse_addr_book(AddressBook* abook, gchar** error);
 
 gboolean addr_book_update_config(AddressBook* new,



More information about the Commits mailing list