diff --git a/sflphone-client-gnome/plugin/addressbook/Makefile.am b/sflphone-client-gnome/plugin/addressbook/Makefile.am deleted file mode 100644 index afd10fa06ee669f50d2ba7fe352b6ba14e09d8b8..0000000000000000000000000000000000000000 --- a/sflphone-client-gnome/plugin/addressbook/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -include ../../globals.mak - -noinst_PROGRAMS = libevladdrbook.so - -libevladdrbook_so_SOURCES = eds.c addressbook.c - -libevladdrbook_so_LDFLAGS = --shared $(SFLGLIB_LDFLAGS) $(SFLGTK_CFLAGS) $(LIBEDATASERVER_LDFLAGS) $(LIBEDATASERVERUI_LDFLAGS) $(DBUSGLIB_LDFLAGS) - -# @DBUSGLIB_LDFLAGS@ @LIBNOTIFY_LDFLAGS@ \ -# @SFLGTK_LDFLAGS@ @SFLGLIB_LDFLAGS@ @WEBKIT_LDFLAGS@ @LIBEBOOK_LDFLAGS@ \ -# @LIBEDATASERVER_LDFLAGS@ @LIBEDATASERVERUI_LDFLAGS@ @LIBGNOMEUI_LDFLAGS@ \ -# @GNOMEDOCUTILS_LDFLAGS@ - -libevladdrbook_so_CFLAGS = -fPIC -g -Wall $(SFLGLIB_CFLAGS) $(SFLGTK_CFLAGS) $(LIBEDATASERVER_CFLAGS) $(LIBEDATASERVERUI_CFLAGS) $(DBUSGLIB_CFLAGS) - -# @DBUSGLIB_CFLAGS@ @LIBNOTIFY_CFLAGS@ \ -# @SFLGTK_CFLAGS@ @SFLGLIB_CFLAGS@ @WEBKIT_CFLAGS@ @LIBEBOOK_CFLAGS@ \ -# @LIBEDATASERVER_CFLAGS@ @LIBEDATASERVERUI_CFLAGS@ @LIBGNOMEUI_CFLAGS@ \ -# @GNOMEDOCUTILS_CFLAGS@ - -install-exec-local: install-libplugin_libevladdrbook_so - -install-libplugin_libevladdrbook_so: libevladdrbook.so - $(INSTALL_PROGRAM) libevladdrbook.so $(sflplugindir) diff --git a/sflphone-client-gnome/plugin/addressbook/addressbook.c b/sflphone-client-gnome/plugin/addressbook/addressbook.c deleted file mode 100644 index 26a6f713f6ef32d1e75672a3f5c066d213526320..0000000000000000000000000000000000000000 --- a/sflphone-client-gnome/plugin/addressbook/addressbook.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. - * Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com> - * - * 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 3 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ -#include <string.h> -#include <stdio.h> - -#include "eds.h" -#include "addressbook.h" -#include "searchbar.h" -#include "addressbook-config.h" - -// static void -// handler_async_search (GList *, gpointer); - -/** - * Perform a search on address book - */ -void -addressbook_search (AddrBookHandle *handle, GtkEntry* entry, AddressBook_Config *addressbook_config) -{ - printf("Addressbook: Search"); - - const gchar* query = gtk_entry_get_text (GTK_ENTRY (entry)); - printf("Addressbook: Search %s\n", query); - - // AddressBook_Config *addressbook_config; - - // activateWaitingLayer(); - - // addressbook_config_load_parameters (&addressbook_config); - - search_async_by_contacts (gtk_entry_get_text (GTK_ENTRY (entry)), addressbook_config->max_results, handle->search_cb, addressbook_config); - -} - -/** - * Return addressbook state - */ -gboolean -addressbook_is_enabled() -{ - AddressBook_Config *addressbook_config; - - printf("Addresbook: is enabled\n"); - - // Load the address book parameters - // addressbook_config_load_parameters (&addressbook_config); - - return (guint) addressbook_config->enable; -} - -/** - * Return addressbook state - */ -gboolean -addressbook_is_ready() -{ - printf("Addressbook: is ready\n"); - - return books_ready(); -} - -/** - * Return TRUE if at least one addressbook is active - */ -gboolean -addressbook_is_active() -{ - printf("Addressbook: is active\n"); - return books_active(); -} - -/** - * Get active addressbook from config. - */ -static void -addressbook_config_books(gchar **book_list) -{ - gchar **config_book_uid; - book_data_t *book_data; - gchar **list; - - // Retrieve list of books - // list = (gchar **) dbus_get_addressbook_list(); - - list = NULL; - - if (list == NULL) - return; - - for (config_book_uid = list; *config_book_uid; config_book_uid++) { - - // Get corresponding book data - book_data = books_get_book_data_by_uid (*config_book_uid); - - // If book_data exists - if (book_data == NULL) { - printf("Addressbook: Error: Could not open book (%s:%d)\n", __FILE__, __LINE__); - } else { - book_data->active = TRUE; - } - } - - g_strfreev (list); -} - -/** - * Good method to get books_data - */ -GSList * -addressbook_get_books_data(gchar **book_list) -{ - printf("Addressbook: Get books data\n"); - - // fill_books_data(); - addressbook_config_books(book_list); - determine_default_addressbook(); - - return get_books_data(); -} - -book_data_t * -addressbook_get_book_data_by_uid(gchar *uid) -{ - return books_get_book_data_by_uid (uid); -} - -/** - * Initialize books. - * Set active/inactive status depending on config. - */ -void -addressbook_init(gchar **book_list) -{ - printf("Addressbook: Initialize addressbook\n"); - - init_eds_mutex(); - - fill_books_data(); - addressbook_config_books(book_list); - determine_default_addressbook(); - - // Call books initialization - init_eds(); -} - -/** - * Callback called after all book have been processed - */ -/* -static void -handler_async_search (GList *hits, gpointer user_data) -{ - - GList *i; - GdkPixbuf *photo = NULL; - AddressBook_Config *addressbook_config; - callable_obj_t *j; - - printf("Addressbook: callback async search\n"); - - // freeing calls - while ( (j = (callable_obj_t *) g_queue_pop_tail (contacts->callQueue)) != NULL) { - free_callable_obj_t (j); - } - - // Retrieve the address book parameters - addressbook_config = (AddressBook_Config*) user_data; - - // reset previous results - calltree_reset (contacts); - calllist_reset (contacts); - - for (i = hits; i != NULL; i = i->next) { - - Hit *entry; - entry = i->data; - - if (entry) { - // Get the photo - if (addressbook_display (addressbook_config, - ADDRESSBOOK_DISPLAY_CONTACT_PHOTO)) - photo = entry->photo; - - // Create entry for business phone information - if (addressbook_display (addressbook_config, - ADDRESSBOOK_DISPLAY_PHONE_BUSINESS)) - calllist_add_contact (entry->name, entry->phone_business, - CONTACT_PHONE_BUSINESS, photo); - - // Create entry for home phone information - if (addressbook_display (addressbook_config, - ADDRESSBOOK_DISPLAY_PHONE_HOME)) - calllist_add_contact (entry->name, entry->phone_home, - CONTACT_PHONE_HOME, photo); - - // Create entry for mobile phone iddnformation - if (addressbook_display (addressbook_config, - ADDRESSBOOK_DISPLAY_PHONE_MOBILE)) - calllist_add_contact (entry->name, entry->phone_mobile, - CONTACT_PHONE_MOBILE, photo); - } - - free_hit (entry); - } - - g_list_free (hits); - - // Deactivate waiting image - // deactivateWaitingLayer(); - - - gtk_widget_grab_focus (GTK_WIDGET (contacts->view)); -} -*/ - -void addressbook_set_search_type(AddrbookSearchType searchType) { - -} - -void addressbook_set_current_book(gchar *current) { - -} diff --git a/sflphone-client-gnome/plugin/addressbook/eds.c b/sflphone-client-gnome/plugin/addressbook/eds.c deleted file mode 100644 index b46ceafc7820a1f17e9ad62702ad2721caf8a6e7..0000000000000000000000000000000000000000 --- a/sflphone-client-gnome/plugin/addressbook/eds.c +++ /dev/null @@ -1,811 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com> - * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> - * - * File originally copied from evolution module of deskbar-applet 2.24.1 - * Authors : - * Nigel Tao <nigel.tao@myrealbox.com> - * Raphaël Slinckx <raphael@slinckx.net> - * Mikkel Kamstrup Erlandsen <kamstrup@daimi.au.dk> - * Sebastian Pölsterl <marduk@k-d-w.org> - * - * 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 3 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., 675 Mass Ave, Cambridge, MA 02139, USA. - *e_book - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -#include <glib.h> -#include <glib/gstring.h> -#include <string.h> -#include <pango/pango.h> -#include "eds.h" -#include <addressbook-config.h> -#include <libedataserver/e-source.h> - -#include "config.h" - -/** - * Structure used to store search callback and data - */ -typedef struct _Search_Handler_And_Data { - SearchAsyncHandler search_handler; - gpointer user_data; - GList *hits; - int max_results_remaining; - EBookQuery *equery; -} Search_Handler_And_Data; - -static void -authenticate_source (EBook *); - -/** - * The global addressbook list - */ -GSList *books_data = NULL; -GMutex *books_data_mutex = NULL; - -/** - * Size of image that will be displayed in contact list - */ -static const int pixbuf_size = 32; - -/** - * Current selected addressbook's uri and uid, initialized with default - */ -static gchar *current_uri = NULL; -static gchar *current_uid = NULL; -static gchar *current_name = "Default"; - -static EBookQueryTest current_test = E_BOOK_QUERY_BEGINS_WITH; - - -/** - * Prototypes - */ -void empty_books_data(); - - -/** - * Free a book data - */ -void -free_book_data (book_data_t *data) -{ - g_free (data->name); - g_free (data->uid); - g_free (data->uri); -} - -/** - * Public way to know if we can perform a search - */ -gboolean -books_ready() -{ - gboolean returnValue; - - g_mutex_lock(books_data_mutex); - - if (books_data == NULL) { - g_mutex_unlock(books_data_mutex); - return FALSE; - } - - returnValue = (g_slist_length (books_data) > 0); - g_mutex_unlock(books_data_mutex); - - return returnValue; -} - -/** - * Public way to know if we enable at least one address book - */ -gboolean -books_active() -{ - GSList *book_list_iterator; - book_data_t *book_data; - - g_mutex_lock(books_data_mutex); - - if (books_data == NULL) { - printf("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__); - g_mutex_unlock(books_data_mutex); - return FALSE; - } - - // Iterate throw the list - for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator - = book_list_iterator->next) { - book_data = (book_data_t *) book_list_iterator->data; - - if (book_data->active) { - g_mutex_unlock(books_data_mutex); - return TRUE; - } - } - - g_mutex_unlock(books_data_mutex); - - // If no result - return FALSE; -} -/** - * Get a specific book data by UID - */ -book_data_t * -books_get_book_data_by_uid (gchar *uid) -{ - GSList *book_list_iterator; - book_data_t *book_data; - - g_mutex_lock(books_data_mutex); - - if (books_data == NULL) { - printf("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__); - g_mutex_unlock(books_data_mutex); - return NULL; - } - - printf("Addressbook: Get book data by uid: %s\n", uid); - - // Iterate throw the list - for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator - = book_list_iterator->next) { - book_data = (book_data_t *) book_list_iterator->data; - - if (strcmp (book_data->uid, uid) == 0) { - printf("Addressbook: Book %s found\n", uid); - g_mutex_unlock(books_data_mutex); - return book_data; - } - } - - g_mutex_unlock(books_data_mutex); - - printf("Addressbook: Could not found Book %s\n", uid); - // If no result - return NULL; -} - - -/** - * Create a query which looks for the specified string in a contact's full name, email addresses and - * nick name. - */ -static EBookQuery* -create_query (const char* s, EBookQueryTest test, AddressBook_Config *conf) -{ - - EBookQuery *equery; - EBookQuery *queries[4]; - - // Create the query - int cpt = 0; - - // We could also use E_BOOK_QUERY_IS or E_BOOK_QUERY_BEGINS_WITH instead of E_BOOK_QUERY_CONTAINS - queries[cpt++] = e_book_query_field_test (E_CONTACT_FULL_NAME, test, s); - - if (conf->search_phone_home) { - queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_HOME, test, s); - } - - if (conf->search_phone_business) { - queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_BUSINESS, test, s); - } - - if (conf->search_phone_mobile) { - queries[cpt++] = e_book_query_field_test (E_CONTACT_PHONE_MOBILE, test, s); - } - - equery = e_book_query_or (cpt, queries, TRUE); - - return equery; -} - -/** - * Retrieve the contact's picture - */ -static GdkPixbuf* -pixbuf_from_contact (EContact *contact) -{ - - GdkPixbuf *pixbuf = NULL; - EContactPhoto *photo = e_contact_get (contact, E_CONTACT_PHOTO); - - if (photo) { - GdkPixbufLoader *loader; - - loader = gdk_pixbuf_loader_new(); - - if (photo->type == E_CONTACT_PHOTO_TYPE_INLINED) { - if (gdk_pixbuf_loader_write (loader, (guchar *) photo->data.inlined.data, photo->data.inlined.length, NULL)) { - pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - } - } - - // If pixbuf has been found, check size and resize if needed - if (pixbuf) { - GdkPixbuf *tmp; - gint width = gdk_pixbuf_get_width (pixbuf); - gint height = gdk_pixbuf_get_height (pixbuf); - double scale = 1.0; - - if (height > width) { - scale = pixbuf_size / (double) height; - } else { - scale = pixbuf_size / (double) width; - } - - if (scale < 1.0) { - tmp = gdk_pixbuf_scale_simple (pixbuf, width * scale, height - * scale, GDK_INTERP_BILINEAR); - g_object_unref (pixbuf); - pixbuf = tmp; - } - } - - e_contact_photo_free (photo); - } - - return pixbuf; -} - -/** - * Final callback after all books have been processed. - */ -static void -view_finish_callback (EBookView *book_view, Search_Handler_And_Data *had) -{ - SearchAsyncHandler had_handler = had->search_handler; - GList *had_hits = had->hits; - gpointer had_user_data = had->user_data; - - g_free (had); - - printf("Addressbook: View finish, all book have beem processed\n"); - - if (book_view != NULL) - g_object_unref (book_view); - - // Call display callback - had_handler (had_hits, had_user_data); -} - - -/** - * Callback called after a contact have been found in EDS by search_async_by_contacts. - */ -#ifdef LIBEDATASERVER_VERSION_2_32 -void -eds_query_result_cb (EBook *book, const GError *error, GList *contacts, gpointer user_data) -{ - printf("Addressbook: Search Result callback called\n"); - if (error) { - printf("Addressbook: Error: %s\n", error->message); - return; - } -#else -static void -eds_query_result_cb (EBook *book, EBookStatus status, GList *contacts, gpointer user_data) -{ - printf("Addressbook: Search Result callback called\n"); - - if (status != E_BOOK_ERROR_OK) { - printf("Addressbook: Error: "); - return; - } -#endif - - Search_Handler_And_Data *had = (Search_Handler_And_Data *) user_data; - - if (contacts == NULL) { - printf("Addressbook: No contact found\n"); - had->search_handler (NULL, user_data); - return; - } - - GList *l = NULL; - - // make sure we have a new list of hits - had->hits = NULL; - - l = contacts; - - while (l) { - - Hit *hit = g_new (Hit, 1); - - if (hit) { - - // Get the photo contact - hit->photo = pixbuf_from_contact (E_CONTACT (l->data)); - fetch_information_from_contact (E_CONTACT (l->data), E_CONTACT_PHONE_BUSINESS, &hit->phone_business); - fetch_information_from_contact (E_CONTACT (l->data), E_CONTACT_PHONE_HOME, &hit->phone_home); - fetch_information_from_contact (E_CONTACT (l->data), E_CONTACT_PHONE_MOBILE, &hit->phone_mobile); - hit->name = g_strdup ( (char *) e_contact_get_const (E_CONTACT (l->data), E_CONTACT_NAME_OR_ORG)); - - if (!hit->name) { - hit->name = ""; - } - - if (hit) { - had->hits = g_list_append (had->hits, hit); - } - - had->max_results_remaining--; - if (had->max_results_remaining <= 0) { - break; - } - } - - l = g_list_next (l); - - } - - view_finish_callback (NULL, had); - - g_object_unref (book); -} - - - -/** - * Callback for asynchronous open of books - */ -#ifdef LIBEDATASERVER_VERSION_2_32 -void -eds_async_open_callback (EBook *book, const GError *error, gpointer closure) -{ - printf("Addressbook: Open book callback\n"); - - ESource *source; - const gchar *uri; - - if(error) { - printf("Addressbook: Error: %s\n", error->message); - return; - } -#else -static void -eds_async_open_callback (EBook *book, EBookStatus status, gpointer closure) -{ - ESource *source; - const gchar *uri; - - if(status == E_BOOK_ERROR_OK) { - printf("Addressbook: Error\n"); - return; - } - -#endif - - Search_Handler_And_Data *had = (Search_Handler_And_Data *) closure; - - if (! (source = e_book_get_source (book))) { - printf("Addressbook: Error: while getting source\n"); - } - - if (! (uri = e_book_get_uri (book))) { - printf("Addressbook: Error while getting URI\n"); - } - - authenticate_source (book); - - if (!e_book_is_opened (book)) { - // We must open the addressbook - e_book_open (book, FALSE, NULL); - } - -#ifdef LIBEDATASERVER_VERSION_2_32 - if (!e_book_get_contacts_async (book, had->equery, eds_query_result_cb, had)) - printf("Addressbook: Error: While querying addressbook\n"); -#else - if (e_book_async_get_contacts (book, had->equery, eds_query_result_cb, had)) - printf("Addressbook: Error: While querying addressbook\n"); -#endif - -} - -/** - * Initialize address book - */ -void -init_eds () -{ - GSList *book_list_iterator; - book_data_t *book_data; - - printf ("Addressbook: Init evolution data server\n"); - - g_mutex_lock(books_data_mutex); - - if (books_data == NULL) { - printf ("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__); - g_mutex_unlock(books_data_mutex); - return; - } - - // init current with first addressbook if no default addressbook set - book_list_iterator = books_data; - book_data = (book_data_t *) book_list_iterator->data; - current_uri = book_data->uri; - current_uid = book_data->uid; - current_name = book_data->name; - - // Iterate through list to find default addressbook - for (book_list_iterator = books_data; book_list_iterator != NULL; - book_list_iterator = book_list_iterator->next) { - book_data = (book_data_t *) book_list_iterator->data; - - if (book_data->isdefault) { - current_uri = book_data->uri; - current_uid = book_data->uid; - current_name = book_data->name; - } - } - - printf("END EVOLUTION INIT %s, %s, %s\n", current_uri, current_uid, current_name); - - g_mutex_unlock(books_data_mutex); -} - -void -init_eds_mutex() { - - books_data_mutex = g_mutex_new(); -} - -/** - * Authenticate this addressbook - */ -static void -authenticate_source (EBook *book) -{ - (void) book; /* unused */ - /* - const gchar *auth_domain; - const gchar *password = NULL; - const gchar *component_name; - const gchar *user = NULL; - const gchar *auth; - GError *err = NULL; - const gchar *uri; - ESource *source; - - if ((source = e_book_get_source (book)) == NULL) { - DEBUG ("Addressbook: Error while getting source"); - } - - if ((uri = e_book_get_uri (book)) == NULL) { - DEBUG ("Addressbook: Error while getting URI"); - } - - auth_domain = e_source_get_property (source, "auth-domain"); - - auth = e_source_get_property (source, "auth"); - - if (auth && !strcmp ("ldap/simple-binddn", auth)) { - user = e_source_get_property (source, "binddn"); - } - else if (auth && !strcmp ("plain/password", auth)) { - user = e_source_get_property (source, "user"); - - if (!user) { - user = e_source_get_property (source, "username"); - } - } else { - user = e_source_get_property (source, "email_addr"); - } - - if (!user) { - user = ""; - } - - if (auth) { - component_name = auth_domain ? auth_domain : "Addressbook"; - - password = e_passwords_get_password (component_name, uri); - - if (e_book_authenticate_user (book, user, password, auth, &err)) { - DEBUG ("Addressbook: authentication successfull"); - } - else { - ERROR ("Addressbook: authentication error"); - } - - } -*/ -} - -/** - * Fill book data - */ -void -fill_books_data () -{ - GSList *list, *l; - ESourceList *source_list = NULL; - - printf ("Addressbook: Fill books data\n"); - - source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources"); - - if (source_list == NULL) { - printf ("Addressbook: Error could not initialize source list for addressbook (%s:%d)\n", __FILE__, __LINE__); - return; - } - - list = e_source_list_peek_groups (source_list); - - if (list == NULL) { - printf ("Addressbook: Address Book source groups are missing (%s:%d)! Check your GConf setup.\n", __FILE__, __LINE__); - return; - } - - g_mutex_lock(books_data_mutex); - - if (books_data != NULL) { - empty_books_data(); - books_data = NULL; - } - - for (l = list; l != NULL; l = l->next) { - - ESourceGroup *group = l->data; - GSList *sources = NULL, *m; - gchar *absuri = g_strdup (e_source_group_peek_base_uri (group)); - - sources = e_source_group_peek_sources (group); - - for (m = sources; m != NULL; m = m->next) { - - ESource *source = m->data; - - book_data_t *book_data = g_new (book_data_t, 1); - book_data->active = FALSE; - book_data->name = g_strdup (e_source_peek_name (source)); - book_data->uid = g_strdup (e_source_peek_uid (source)); - - const gchar *property_name = "default"; - const gchar *prop = e_source_get_property (source, property_name); - - if (prop) { - if (strcmp (prop, "true") == 0) { - book_data->isdefault = TRUE; - } else { - book_data->isdefault = FALSE; - } - } else { - book_data->isdefault = FALSE; - } - - book_data->uri = g_strjoin ("", absuri, e_source_peek_relative_uri (source), NULL); - - // authenticate_source (book_data, source); - - books_data = g_slist_prepend (books_data, book_data); - - } - - g_free (absuri); - } - - g_mutex_unlock(books_data_mutex); - - g_object_unref (source_list); -} - -void -determine_default_addressbook() -{ - g_mutex_lock(books_data_mutex); - - GSList *list_element = books_data; - gboolean default_found = FALSE; - - while (list_element && !default_found) { - book_data_t *book_data = list_element->data; - - if (book_data->isdefault) { - default_found = TRUE; - current_uri = book_data->uri; - current_uid = book_data->uid; - current_name = book_data->name; - } - - list_element = g_slist_next (list_element); - } - - // reset loop - list_element = books_data; - - while (list_element && !default_found) { - book_data_t *book_data = list_element->data; - - if (book_data->active) { - default_found = TRUE; - book_data->isdefault = TRUE; - current_uri = book_data->uri; - current_uid = book_data->uid; - current_name = book_data->name; - printf ("Addressbook: No default addressbook found, using %s addressbook as default\n", book_data->name); - } - - list_element = g_slist_next (list_element); - } - - g_mutex_unlock(books_data_mutex); -} - -void -empty_books_data() -{ - GSList *book_list_iterator; - book_data_t *book_data; - - if (books_data == NULL) { - printf ("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__); - return; - } - - // Iterate throw the list - for (book_list_iterator = books_data; book_list_iterator != NULL; - book_list_iterator = book_list_iterator->next) { - book_data = (book_data_t *) book_list_iterator->data; - - free_book_data (book_data); - } -} - -void -search_async_by_contacts (const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data) -{ - GError *err = NULL; - EBook *book = NULL; - - printf ("Addressbook: New search by contacts: %s, max_results %d\n", query, max_results); - - if (strlen (query) < 1) { - printf ("Addressbook: Query is empty\n"); - handler (NULL, user_data); - return; - } - - Search_Handler_And_Data *had = g_new (Search_Handler_And_Data, 1); - - // initialize search data - had->search_handler = handler; - had->user_data = user_data; - had->hits = NULL; - had->max_results_remaining = max_results; - had->equery = create_query (query, current_test, (AddressBook_Config *) (user_data)); - - if (!current_uri) { - printf ("Addressbook: Error: Current addressbook uri not specified\n"); - } - - printf ("Addressbook: Opening addressbook: uri: %s\n", current_uri); - printf ("Addressbook: Opening addressbook: name: %s\n", current_name); - - book = e_book_new_from_uri(current_uri, &err); - - if (err) { - printf ("Addressbook: Error: Could not open new book: %s\n", err->message); - } - - if (book) { - printf ("Addressbook: Created empty book successfully\n"); - -#ifdef LIBEDATASERVER_VERSION_2_32 - e_book_open_async (book, TRUE, eds_async_open_callback, had); -#else - // Asynchronous open - e_book_async_open(book, TRUE, eds_async_open_callback, had); -#endif - - } else { - printf ("Addressbook: Error: No book available\n"); - } - -} - -/** - * Fetch information for a specific contact - */ -void -fetch_information_from_contact (EContact *contact, EContactField field, gchar **info) -{ - gchar *to_fetch; - - to_fetch = g_strdup ( (char*) e_contact_get_const (contact, field)); - - if (!to_fetch) { - to_fetch = g_strdup (EMPTY_ENTRY); - } - - *info = g_strdup (to_fetch); -} - -void -set_current_addressbook (const gchar *name) -{ - - GSList *book_list_iterator; - book_data_t *book_data; - - if(name == NULL) - return; - - g_mutex_lock(books_data_mutex); - - if (!books_data) { - printf ("Addressbook: No books data (%s:%d)\n", __FILE__, __LINE__); - g_mutex_unlock(books_data_mutex); - return; - } - - // Iterate throw the list - for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator - = book_list_iterator->next) { - book_data = (book_data_t *) book_list_iterator->data; - - if (strcmp (book_data->name, name) == 0) { - current_uri = book_data->uri; - current_uid = book_data->uid; - current_name = book_data->name; - } - } - - printf("Addressbook: Set current addressbook %s, %s, %s\n", current_uri, current_uid, current_name); - - g_mutex_unlock(books_data_mutex); -} - - -const gchar * -get_current_addressbook (void) -{ - return current_name; -} - - -void -set_current_addressbook_test (EBookQueryTest test) -{ - current_test = test; -} - -EBookQueryTest -get_current_addressbook_test (void) -{ - return current_test; -} - -GSList * -get_books_data() -{ - return books_data; -} diff --git a/sflphone-client-gnome/plugin/addressbook/eds.h b/sflphone-client-gnome/plugin/addressbook/eds.h deleted file mode 100644 index d276207af3b54bf4c1b785d6db58b135ee66748e..0000000000000000000000000000000000000000 --- a/sflphone-client-gnome/plugin/addressbook/eds.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc. - * Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com> - * - * File originally copied from evolution module of deskbar-applet 2.24.1 - * Authors : - * Nigel Tao <nigel.tao@myrealbox.com> - * Raphaël Slinckx <raphael@slinckx.net> - * Mikkel Kamstrup Erlandsen <kamstrup@daimi.au.dk> - * Sebastian Pölsterl <marduk@k-d-w.org> - * - * 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 3 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -#ifndef __EDS_H__ -#define __EDS_H__ - -#include <glib/gtypes.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <libebook/e-book.h> - -#include "addressbook.h" -#include "sflphone_const.h" - - -#define EMPTY_ENTRY "empty" - -G_BEGIN_DECLS - -/** - * Current search id used to prevent processing - * of previous search - */ -int current_search_id; - -/** - * Represent a contact entry - */ -/* -typedef struct _Hit { - gchar *name; - GdkPixbuf *photo; - gchar *phone_business; - gchar *phone_home; - gchar *phone_mobile; -} Hit; -*/ -/** - * Book structure for "outside world" - */ -/* -typedef struct { - gchar *uid; - gchar *uri; - gchar *name; - gboolean active; - gboolean isdefault; -} book_data_t; -*/ - -/** - * Free a contact entry - */ -void -free_hit (Hit *h); - -/** - * Template callback function for the asynchronous search - */ -typedef void -(* SearchAsyncHandler) (GList *hits, gpointer user_data); - -/** - * Template callback function for the asynchronous open - */ -typedef void -(* OpenAsyncHandler) (); - -/** - * Initialize the address book. - * Connection to evolution data server - */ -void -init_eds (); - -/** - * We need to initialize multi-threading capabilities - * due to asynchronous callbacks - */ -void -init_eds_mutex(void); - -/** - * Fill list of addressbooks - */ -void -fill_books_data (void); - -/** - * Asynchronous query to EDS using get contact method. - */ -void -search_async_by_contacts (const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data); - -/** - * Retrieve the specified information from the contact - */ -void -fetch_information_from_contact (EContact *contact, EContactField field, - gchar **info); - -GSList* -get_books (void); - -book_data_t * -books_get_book_data_by_uid (gchar *uid); - -/** - * Public way to know if we can perform a search - */ -gboolean -books_ready(); - -/** - * Public way to know if we enabled an address book - */ -gboolean -books_active(); - -/** - * Good method to retrieve books_data (handle async) - */ -GSList * -addressbook_get_books_data(); - -/** - * Set the current address book - */ -void -set_current_addressbook (const gchar *name); - -/** - * Return current addressbook name - */ -const gchar * -get_current_addressbook (void); - -void -set_current_addressbook_test (EBookQueryTest test); - -EBookQueryTest -get_current_addressbook_test (void); - -GSList * -get_books_data(); - -void -determine_default_addressbook(); - - -G_END_DECLS - -#endif /* __EDS_H__ */