[Commits] xml-plugin.c 1.6 1.7

miras at claws-mail.org miras at claws-mail.org
Sun Nov 20 22:24:22 CET 2011


Update of /home/claws-mail/contacts/plugins/xml
In directory claws-mail:/tmp/cvs-serv324/plugins/xml

Modified Files:
	xml-plugin.c 
Log Message:
2011-11-20 [mir]	0.6.0cvs22

	* plugins/example/example-plugin.c
	* plugins/ldap/ldap-plugin.c
	* plugins/xml/xml-plugin.c
	* src/callbacks.c
	* src/callbacks.h
	* src/contactwindow.c
	* src/mainwindow.h
	* src/plugin-loader.c
	* src/plugin-loader.h
	* src/plugin.h
	* src/utils.c
	* src/utils.h
	    Lots of bug fixes, some feature enhancements and complete
	    read-only support for LDAP with advanced search
	    capabilities. 

Index: xml-plugin.c
===================================================================
RCS file: /home/claws-mail/contacts/plugins/xml/xml-plugin.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- xml-plugin.c	14 Nov 2011 22:06:43 -0000	1.6
+++ xml-plugin.c	20 Nov 2011 21:24:20 -0000	1.7
@@ -53,12 +53,13 @@
 	gchar* image;
 } Image;
 
+/*
 typedef struct {
 	GHashTable* hash;
 	gboolean	is_and;
 	gint		equal;
 } Compare;
-
+*/
 static Plugin* self = NULL;
 static PluginFeature* feature = NULL;
 static const gchar subtype[] = "Claws-mail native addressbook";
@@ -595,186 +596,6 @@
 	}
 }
 
-static GSList* get_basic_attributes(Contact* contact) {
-	GSList *list = NULL, *cur;
-	gchar* value;
-	
-	extract_data(contact->data, "nick-name", (void **) &value);
-	list = g_slist_prepend(list, g_strdup(value));
-	g_free(value);
-	extract_data(contact->data, "first-name", (void **) &value);
-	list = g_slist_prepend(list, g_strdup(value));
-	g_free(value);
-	extract_data(contact->data, "last-name", (void **) &value);
-	list = g_slist_prepend(list, g_strdup(value));
-	g_free(value);
-	extract_data(contact->data, "cn", (void **) &value);
-	list = g_slist_prepend(list, g_strdup(value));
-	g_free(value);
-	
-	for (cur = contact->emails; cur; cur = g_slist_next(cur)) {
-		Email* e = (Email *) cur->data;
-		list = g_slist_prepend(list, g_strdup(e->alias));		
-		list = g_slist_prepend(list, g_strdup(e->email));		
-	}
-	
-	return list;
-}
-
-static gboolean match_string_pattern(const gchar* pattern,
-									 const gchar* haystack,
-									 gboolean case_aware) {
-	const gchar *txt, *source;
-	gunichar ch = 0, cp;
-	gboolean in_str = FALSE, error = FALSE, has_source;
-	
-	if (! pattern || ! haystack)
-		return FALSE;
-	
-	if (!*pattern && !*haystack)
-		return TRUE;
-	
-	if (g_utf8_validate(pattern, -1, NULL) &&
-			g_utf8_validate(haystack, -1, NULL)) {
-
-		if (g_utf8_strlen(pattern, -1) == 1 && (
-			*pattern == '*' || (*pattern == '?' &&
-			g_utf8_strlen(haystack, -1) < 2)))
-			return TRUE;
-		
-		if (*pattern && g_utf8_strlen(haystack, -1) < 1)
-			return FALSE;
-		
-		txt = pattern;
-		source = haystack;
-
-		while (*txt && *source && !error) {
-			ch = g_utf8_get_char(txt);
-			cp = g_utf8_get_char(source);
-			switch (ch) {
-				case '*':
-					in_str = TRUE;
-					break;
-				case '?':
-					break;
-				default:
-					if (! case_aware) {
-						cp = g_unichar_toupper(cp);
-						ch = g_unichar_toupper(ch);
-					}
-					if (in_str) {
-						while (ch != cp && *source) {
-							source = g_utf8_find_next_char(source, NULL);
-							cp = g_utf8_get_char(source);
-							if (! case_aware)
-								cp = g_unichar_toupper(cp);
-						}
-						in_str = FALSE;
-					}
-					else
-						error = (cp == ch) ? FALSE : TRUE;
-					break;
-			}
-			if (!error) {
-				has_source = FALSE;
-				if (*source && !in_str) {
-					has_source = TRUE;
-					source = g_utf8_find_next_char(source, NULL);
-				}
-				if (*source || has_source)
-					txt = g_utf8_find_next_char(txt, NULL);
-			}
-		}
-		if (!*source && (ch = g_utf8_get_char(txt)) != 0) {
-			if (ch != '*') {
-				if (ch == '?' && g_utf8_strlen(txt, -1) == 1) {
-					/* keep value of error */
-				}
-				else {
-					if (g_utf8_strlen(txt, -1) > 1)
-						error = TRUE;
-				}
-			}
-		}
-		else if (*source && !g_utf8_get_char(txt)) {
-			if (ch != '*') {
-				if (ch == '?' && g_utf8_strlen(source, -1) < 1) {
-					/* keep value of error */
-				}
-				else
-					error = TRUE;
-			}
-		}
-		else {
-			/* Keep value of error */
-		}
-	}
-	
-	return (!error);
-}
-
-static void contact_compare_values(gpointer key, gpointer value, gpointer data) {
-	Compare* comp = (Compare *) data;
-	AttribDef* attr;
-	
-	if (debug_get_mode()) {
-		Contact* c = g_new0(Contact, 1);
-		c->data = comp->hash;
-		contact_dump(c, stderr);
-		fprintf(stderr, "Key: %s - Value: %s\n", (gchar *) key, (gchar *) value);
-		g_free(c);
-	}
-	if ((comp->is_and && comp->equal) ||
-		(!comp->is_and && (comp->equal < 0 || comp->equal == 0))) {
-		attr = g_hash_table_lookup(comp->hash, key);
-		if (attr) {
-			if (attr->type == ATTRIB_TYPE_STRING) {
-				comp->equal = match_string_pattern(
-					value, attr->value.string, TRUE);
-			}
-			else if (attr->type == ATTRIB_TYPE_CHAR) {
-				gchar* ch = g_strdup_printf("%c", attr->value.character);
-				comp->equal = match_string_pattern(value, ch, TRUE);
-				g_free(ch);
-			}
-			else {
-				/* TODO. How to compare int and boolean */
-				comp->equal = FALSE;
-			}
-		}
-	}
-	else
-		comp->equal = FALSE;
-}
-
-static gboolean email_compare_values(GSList* a, GSList* b, gboolean is_and) {
-	GSList *cur1, *cur2;
-	gint equal = -1;
-	
-	for (cur1 = a; cur1; cur1 = g_slist_next(cur1)) {
-		Email* e1 = (Email *) cur1->data;
-		for (cur2 = b; cur2; cur2 = g_slist_next(cur2)) {
-			Email* e2 = (Email *) cur2->data;
-			if (e1->alias) {
-				equal = match_string_pattern(e1->alias, e2->alias, TRUE);
-				if ((!equal && is_and) || (equal && !is_and))
-					break;
-			}
-			if (e1->email) { 
-				equal = match_string_pattern(e1->email, e2->email, TRUE);
-				if ((!equal && is_and) || (equal && !is_and))
-					break;
-			}
-			if (e1->remarks) 
-				equal = match_string_pattern(e1->remarks, e2->remarks, TRUE);
-		}
-		if (equal && !is_and)
-			break;
-	}
-	
-	return equal;
-}
-
 static void reactivate_attribs(gpointer key, gpointer value, gpointer data) {
 	GSList** new_list = (GSList**) data;
 	GSList *cur;
@@ -1087,7 +908,7 @@
 							  gboolean is_and,
 							  gchar** error) {
 	GList* cur;
-	GSList *contacts = NULL/*, *list*/;
+	GSList *contacts = NULL;
 	Contact* contact = NULL;
 	Compare* comp;
 	
@@ -1212,6 +1033,23 @@
 	return books;
 }
 
+GSList* plugin_addrbook_names_all() {
+	GList *list;
+	GSList* names = NULL;
+	
+	for (list = abooks; list; list = g_list_next(list)) {
+		AddressBook* book = (AddressBook *) list->data;
+		names = g_slist_prepend(names, g_strdup(book->abook_name));
+	}
+
+	for (list = closed_books; list; list = g_list_next(list)) {
+		AddressBook* book = (AddressBook *) list->data;
+		names = g_slist_prepend(names, g_strdup(book->abook_name));
+	}
+	
+	return names;
+}
+
 gboolean plugin_abook_set_config(AddressBook* old,
 								 AddressBook* new,
 								 gchar** error) {



More information about the Commits mailing list