diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c index b2b03e21377990c6c778c444ac98a7a88fdc0a67..b623a2b8c50970c4d595fd1eda8a4b51c1c8506c 100644 --- a/sflphone-gtk/src/calltree.c +++ b/sflphone-gtk/src/calltree.c @@ -208,7 +208,6 @@ toggle_contacts(GtkToggleToolButton *toggle_tool_button UNUSED, GtkTreeSelection *sel; GList *results; GList *i; - char ext[30]; printf("EDS : %s\n",gtk_entry_get_text(GTK_ENTRY(filter_entry))); @@ -234,11 +233,7 @@ toggle_contacts(GtkToggleToolButton *toggle_tool_button UNUSED, call_t * call; call = g_new0 (call_t, 1); - call->accountID = g_strdup("Account:1235677223"); - call->callID = g_new0(gchar, 30); - g_sprintf(call->callID, "%d", rand()); - sprintf(ext, "%d", rand()%100 + 100); - call->from = g_strconcat("\"" , entry->text, "\"<", ext, ">", NULL); + call->from = g_strconcat("\"" , entry->name, "\"<", entry->phone, ">", NULL); call->state = CALL_STATE_RECORD; call->history_state = OUTGOING; diff --git a/sflphone-gtk/src/contactlist/.deps/libcontact_la-eds.Tpo b/sflphone-gtk/src/contactlist/.deps/libcontact_la-eds.Tpo deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/sflphone-gtk/src/contactlist/eds.c b/sflphone-gtk/src/contactlist/eds.c index fb075514e7cf6395af6fd6febf331a0d2a38f49b..fbcd39eeff1bf8df58b7d7523739a1827f35905a 100644 --- a/sflphone-gtk/src/contactlist/eds.c +++ b/sflphone-gtk/src/contactlist/eds.c @@ -5,67 +5,16 @@ #include <string.h> #include "eds.h" -typedef struct _Handler_And_Data { - SearchAsyncHandler handler; - gpointer user_data; - GList *hits; - int max_results_remaining; - int book_views_remaining; -} Handler_And_Data; - static GSList *books = NULL; -static int pixbuf_size = 16; -static EContactField search_fields[] = { E_CONTACT_FULL_NAME, E_CONTACT_EMAIL, E_CONTACT_NICKNAME, 0 }; +static EContactField search_fields[] = { E_CONTACT_FULL_NAME, E_CONTACT_PHONE_BUSINESS, E_CONTACT_NICKNAME, 0 }; static int n_search_fields = G_N_ELEMENTS (search_fields) - 1; - - -/* -int -main (int argc, char *argv[]) -{ - GList *results; - GList *i; - - gtk_init (&argc, &argv); - init(); - results = search_sync ("sch", 50); - -if(results == NULL) -{ - printf("null\n"); - return -1; -} - -for (i = results; i != NULL; i = i->next) -{ - Hit *entry; - entry = i->data; - printf("entree\n"); - if (i->data) { - printf("email : %s\n", entry->email); - printf("text : %s\n", entry->text); - } -} - -printf("fini\n"); - - -return 0; -} -*/ - - - - - void free_hit (Hit *h, gpointer unused) { - g_free (h->text); - g_free (h->email); - g_free (h->uri); + g_free (h->name); + g_free (h->phone); g_free (h); } @@ -136,103 +85,6 @@ create_query (const char* s) return query; } -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) { - 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; -} - -static void -view_finish (EBookView *book_view, Handler_And_Data *had) -{ - SearchAsyncHandler had_handler = had->handler; - GList *had_hits = had->hits; - gpointer had_user_data = had->user_data; - g_free (had); - - g_return_if_fail (book_view != NULL); - g_object_unref (book_view); - - had_handler (had_hits, had_user_data); -} - -static void -view_contacts_added_cb (EBookView *book_view, GList *contacts, gpointer user_data) -{ - Handler_And_Data *had = (Handler_And_Data *) user_data; - if (had->max_results_remaining <= 0) { - e_book_view_stop (book_view); - had->book_views_remaining--; - if (had->book_views_remaining == 0) { - view_finish (book_view, had); - return; - } - } - for (; contacts != NULL; contacts = g_list_next (contacts)) { - EContact *contact; - Hit *hit; - - contact = E_CONTACT (contacts->data); - hit = g_new (Hit, 1); - hit->email = g_strdup ((char*) e_contact_get_const (contact, E_CONTACT_EMAIL_1)); - hit->text = g_strdup_printf ("%s <%s>", (char*)e_contact_get_const (contact, E_CONTACT_NAME_OR_ORG), hit->email); - hit->pixbuf = pixbuf_from_contact (contact); - - had->hits = g_list_append (had->hits, hit); - had->max_results_remaining--; - if (had->max_results_remaining <= 0) { - e_book_view_stop (book_view); - had->book_views_remaining--; - if (had->book_views_remaining == 0) { - view_finish (book_view, had); - } - break; - } - } -} - -static void -view_completed_cb (EBookView *book_view, EBookViewStatus status, gpointer user_data) -{ - Handler_And_Data *had = (Handler_And_Data *) user_data; - had->book_views_remaining--; - if (had->book_views_remaining == 0) { - view_finish (book_view, had); - } -} - void init (void) { @@ -251,103 +103,17 @@ init (void) sources = e_source_group_peek_sources (group); for (m = sources; m != NULL; m = m->next) { ESource *source = m->data; - const char *p; - - /*p = e_source_get_property (source, "completion");*/ - - /*if (p != NULL && strcmp (p, "true") == 0) {*/ - if (1) { - EBook *book = e_book_new (source, NULL); - if (book != NULL) { - books = g_slist_prepend (books, book); - e_book_open(book, TRUE, NULL); - } - } - } - } - - g_object_unref (source_list); -} - -int -num_address_books_with_completion (void) -{ - int result = 0; - GSList *list, *l; - ESourceList *source_list; - - source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources"); - if (source_list == NULL) { - return 0; - } - - list = e_source_list_peek_groups (source_list); - - for (l = list; l != NULL; l = l->next) { - ESourceGroup *group = l->data; - GSList *sources = NULL, *m; - sources = e_source_group_peek_sources (group); - for (m = sources; m != NULL; m = m->next) { - ESource *source = m->data; - const char *p; - - p = e_source_get_property (source, "completion"); - - if (p != NULL && strcmp (p, "true") == 0) { - result++; + EBook *book = e_book_new (source, NULL); + if (book != NULL) { + books = g_slist_prepend (books, book); + e_book_open(book, TRUE, NULL); } } } g_object_unref (source_list); - return result; } -void -set_pixbuf_size (int size) -{ - pixbuf_size = size; -} - -void -search_async (const char *query, - int max_results, - SearchAsyncHandler handler, - gpointer user_data) -{ - GSList *iter; - - EBookQuery* book_query = create_query (query); - - Handler_And_Data *had = g_new (Handler_And_Data, 1); - had->handler = handler; - had->user_data = user_data; - had->hits = NULL; - had->max_results_remaining = max_results; - had->book_views_remaining = 0; - for (iter = books; iter != NULL; iter = iter->next) { - EBook *book = (EBook *) iter->data; - EBookView *book_view = NULL; - e_book_get_book_view (book, book_query, NULL, max_results, &book_view, NULL); - if (book_view != NULL) { - had->book_views_remaining++; - g_signal_connect (book_view, "contacts_added", (GCallback) view_contacts_added_cb, had); - g_signal_connect (book_view, "sequence_complete", (GCallback) view_completed_cb, had); - e_book_view_start (book_view); - } - } - if (had->book_views_remaining == 0) { - g_free (had); - } - - e_book_query_unref (book_query); -} - -/* - * Note: you may get a message "WARNING **: FIXME: wait for completion unimplemented" - * if you call search_sync but are not running the gobject main loop. - * This appears to be harmless: http://bugzilla.gnome.org/show_bug.cgi?id=314544 - */ GList * search_sync (const char *query, int max_results) @@ -355,6 +121,7 @@ search_sync (const char *query, GSList *iter = NULL; GList *contacts = NULL; GList *hits = NULL; + char ext[30]; EBookQuery* book_query = create_query (query); for (iter = books; iter != NULL; iter = iter->next) { @@ -366,30 +133,22 @@ search_sync (const char *query, for (; contacts != NULL; contacts = g_list_next (contacts)) { EContact *contact; Hit *hit; - const char *uid; - ESource *source; - const char *source_uid; contact = E_CONTACT (contacts->data); hit = g_new (Hit, 1); - if (e_contact_get (contact, E_CONTACT_IS_LIST)){ - GList *emailList = e_contact_get (contact, E_CONTACT_EMAIL); - int i=0; - hit->email = (gchar*)g_list_nth(emailList,i)->data; - for (i=1; g_list_nth(emailList,i) != NULL; i++) - hit->email = g_strjoin(",",hit->email,((gchar*)g_list_nth(emailList,i)->data), NULL); - g_list_foreach(emailList, (GFunc)g_free, NULL); - g_list_free(emailList); + + hit->phone = g_strdup ((char*) e_contact_get_const (contact, E_CONTACT_PHONE_BUSINESS)); + if(! hit->phone) + { + // Temporary fix for empty phone numbers + sprintf(ext, "%d", rand()%100 + 100); + hit->phone = g_strdup(ext); + //hit->phone = ""; } - else - hit->email = g_strdup ((char*) e_contact_get_const (contact, E_CONTACT_EMAIL_1)); - hit->text = g_strdup ((char*) e_contact_get_const (contact, E_CONTACT_NAME_OR_ORG)); - hit->pixbuf = pixbuf_from_contact (contact); - uid = e_contact_get_const (contact, E_CONTACT_UID); - source = e_book_get_source (book); - source_uid = e_source_peek_uid (source); - hit->uri = g_strdup_printf ("contacts:///?source-uid=%s&contact-uid=%s", source_uid, uid); + hit->name = g_strdup ((char*) e_contact_get_const (contact, E_CONTACT_NAME_OR_ORG)); + if(! hit->name) + hit->name = ""; hits = g_list_append (hits, hit); max_results--; diff --git a/sflphone-gtk/src/contactlist/eds.h b/sflphone-gtk/src/contactlist/eds.h index 91975fe4955da42c596f684796a17d95c321faf1..859132ebde4503041ecafccf136076781224760a 100644 --- a/sflphone-gtk/src/contactlist/eds.h +++ b/sflphone-gtk/src/contactlist/eds.h @@ -8,25 +8,14 @@ G_BEGIN_DECLS typedef struct _Hit { - gchar *text; - gchar *email; - GdkPixbuf *pixbuf; - gchar *uri; + gchar *name; + gchar *phone; } Hit; void free_hit (Hit *hit, gpointer unused); -typedef void (* SearchAsyncHandler) (GList *hits, gpointer user_data); - void init (void); -void set_pixbuf_size (int size); - -void search_async (const char *query, - int max_results, - SearchAsyncHandler handler, - gpointer user_data); - GList * search_sync (const char *query, int max_results);