[Commits] example-plugin.c 1.5 1.6
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/example
In directory claws-mail:/tmp/cvs-serv324/plugins/example
Modified Files:
example-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: example-plugin.c
===================================================================
RCS file: /home/claws-mail/contacts/plugins/example/example-plugin.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- example-plugin.c 14 Nov 2011 22:06:43 -0000 1.5
+++ example-plugin.c 20 Nov 2011 21:24:20 -0000 1.6
@@ -140,7 +140,8 @@
GSList* plugin_get_contact(
AddressBook* abook, const gchar* search_token, gchar** error) {
GList* cur;
- GSList *contacts = NULL;
+ GSList *contacts = NULL, *basic, *list;
+ gboolean found = FALSE;
Contact* contact = NULL;
if (abook && search_token) {
@@ -148,10 +149,19 @@
contact = (Contact *) cur->data;
if (! contact)
continue;
- /*
- * Iterate contacts in AddressBook and compare basic
- * attributes to search_token
- */
+
+ list = get_basic_attributes(contact);
+ for (basic = list; !found && basic; basic = g_slist_next(basic)) {
+ gchar* attr = (gchar *) basic->data;
+ if (attr) {
+ found = match_string_pattern(search_token, attr, FALSE);
+ }
+ }
+ gslist_free(&list, g_free);
+ if (found) {
+ contacts = g_slist_prepend(contacts, contact);
+ found = FALSE;
+ }
}
}
@@ -173,17 +183,32 @@
GList* cur;
GSList *contacts = NULL;
Contact* contact = NULL;
+ Compare* comp;
if (abook && search_tokens && (search_tokens->data || search_tokens->emails)) {
+ comp = g_new0(Compare, 1);
for (cur = abook->contacts; cur; cur = g_list_next(cur)) {
contact = (Contact *) cur->data;
if (! contact)
continue;
- /*
- * Iterate contacts in AddressBook and compare
- * all attributes to search_token
- */
+
+ comp->hash = contact->data;
+ comp->is_and = is_and;
+ comp->equal = -1;
+
+ g_hash_table_foreach(search_tokens->data,
+ contact_compare_values, comp);
+ if ((comp->is_and && comp->equal > 0) ||
+ (comp->equal < 1 && !comp->is_and)) {
+ gint res = email_compare_values(
+ search_tokens->emails, contact->emails, is_and);
+ if (res != -1)
+ comp->equal = res;
+ }
+ if (comp->equal > 0)
+ contacts = g_slist_prepend(contacts, contact);
}
+ g_free(comp);
}
return contacts;
@@ -320,6 +345,27 @@
}
/**
+ * Get list of all address book names.
+ * @return GSList* List of AddressBook names
+ */
+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;
+}
+
+/**
* Save config for an address book. If new is NULL write config for
* new address book update otherwise.
* @param old Pointer to AddressBook
More information about the Commits
mailing list