* Evolution integration plugin for Purple * Copyright (C) 2004 Henry Jen. * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA gevo_addrbooks_model_new() return GTK_TREE_MODEL(gtk_list_store_new(NUM_ADDRBOOK_COLUMNS, G_TYPE_STRING, G_TYPE_STRING)); gevo_addrbooks_model_unref(GtkTreeModel *model) g_return_if_fail(model != NULL); g_return_if_fail(GTK_IS_LIST_STORE(model)); if (!gtk_tree_model_get_iter_first(model, &iter)) gevo_addrbooks_model_populate(GtkTreeModel *model) ESourceRegistry *registry; g_return_if_fail(model != NULL); g_return_if_fail(GTK_IS_LIST_STORE(model)); list = GTK_LIST_STORE(model); registry = e_source_registry_new_sync(NULL, &err); purple_debug_error("evolution", "Unable to fetch list of address books."); gtk_list_store_append(list, &iter); gtk_list_store_set(list, &iter, ADDRBOOK_COLUMN_NAME, _("None"), ADDRBOOK_COLUMN_UID, NULL, -1); sources = e_source_registry_list_sources(registry, E_SOURCE_EXTENSION_ADDRESS_BOOK); g_object_unref(registry); gtk_list_store_append(list, &iter); gtk_list_store_set(list, &iter, ADDRBOOK_COLUMN_NAME, _("None"), ADDRBOOK_COLUMN_UID, NULL, -1); for (s = sources; s != NULL; s = s->next) { ESource *source = E_SOURCE(s->data); gtk_list_store_append(list, &iter); gtk_list_store_set(list, &iter, ADDRBOOK_COLUMN_NAME, e_source_get_display_name(source), ADDRBOOK_COLUMN_UID, e_source_get_uid(source), -1); g_object_unref(registry); g_list_free_full(sources, g_object_unref); gevo_run_query_in_source(ESource *source, EBookQuery *query) if (!gevo_load_addressbook_from_source(source, &book, &err)) { purple_debug_error("evolution", "Error retrieving addressbook: %s\n", err->message); status = e_book_get_contacts(book, query, &cards, NULL); purple_debug_error("evolution", "Error %d in getting card list\n", EContact *contact = E_CONTACT(cards->data); GList *cards2 = cards->next; /* Break off the first contact and free the rest. */ g_list_free_full(cards2, g_object_unref); /* Free the whole list. */ * Search for a buddy in the Evolution contacts. * @param buddy The buddy to search for. * @param query An optional query. This function takes ownership of @a query, * so callers must e_book_query_ref() it in advance (to obtain a * second reference) if they want to reuse @a query. gevo_search_buddy_in_contacts(PurpleBuddy *buddy, EBookQuery *query) ESourceRegistry *registry; EContactField protocol_field = gevo_protocol_get_field(purple_buddy_get_account(buddy), buddy); queries[1] = e_book_query_field_test(protocol_field, E_BOOK_QUERY_IS, purple_buddy_get_name(buddy)); purple_debug_error("evolution", "Error in creating protocol query\n"); e_book_query_unref(query); full_query = e_book_query_and(2, queries, TRUE); full_query = e_book_query_field_test(protocol_field, E_BOOK_QUERY_IS, purple_buddy_get_name(buddy)); purple_debug_error("evolution", "Error in creating protocol query\n"); registry = e_source_registry_new_sync(NULL, &err); purple_debug_error("evolution", "Unable to fetch list of address books.\n"); e_book_query_unref(full_query); sources = e_source_registry_list_sources(registry, E_SOURCE_EXTENSION_ADDRESS_BOOK); for (s = sources; s != NULL; s = s->next) { result = gevo_run_query_in_source(E_SOURCE(s->data), g_object_unref(registry); g_list_free_full(sources, g_object_unref); e_book_query_unref(full_query); g_object_unref(registry); g_list_free_full(sources, g_object_unref); e_book_query_unref(full_query);