Commit 14287d8a authored by Rafaël Carré's avatar Rafaël Carré
Browse files

* #5695: addressbook: simplify

parent 0b998639
...@@ -138,7 +138,7 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count) ...@@ -138,7 +138,7 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count)
static gboolean _is_direct_call (callable_obj_t * c) static gboolean _is_direct_call (callable_obj_t * c)
{ {
if (g_strcasecmp (c->_accountID, EMPTY_ENTRY) == 0) { if (g_strcasecmp (c->_accountID, "empty") == 0) {
if (!g_str_has_prefix (c->_peer_number, "sip:")) { if (!g_str_has_prefix (c->_peer_number, "sip:")) {
gchar * new_number = g_strconcat ("sip:", c->_peer_number, NULL); gchar * new_number = g_strconcat ("sip:", c->_peer_number, NULL);
g_free (c->_peer_number); g_free (c->_peer_number);
......
...@@ -47,7 +47,7 @@ gint is_callID_callstruct(gconstpointer a, gconstpointer b) ...@@ -47,7 +47,7 @@ gint is_callID_callstruct(gconstpointer a, gconstpointer b)
void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_type_t type, GdkPixbuf *photo) void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_type_t type, GdkPixbuf *photo)
{ {
/* Check if the information is valid */ /* Check if the information is valid */
if (g_strcasecmp (contact_phone, "empty") == 0) if (!contact_phone)
return; return;
callable_obj_t *new_call = create_new_call (CONTACT, CALL_STATE_DIALING, "", "", contact_name, contact_phone); callable_obj_t *new_call = create_new_call (CONTACT, CALL_STATE_DIALING, "", "", contact_name, contact_phone);
......
...@@ -39,10 +39,10 @@ ...@@ -39,10 +39,10 @@
void void
addressbook_search (void (*search_cb)(GList *, gpointer), GtkEntry* entry, AddressBook_Config *addressbook_config) addressbook_search (void (*search_cb)(GList *, gpointer), GtkEntry* entry, AddressBook_Config *addressbook_config)
{ {
const gchar* query = gtk_entry_get_text (GTK_ENTRY (entry)); search_async_by_contacts (gtk_entry_get_text(entry),
printf("Addressbook: Search %s\n", query); addressbook_config->max_results,
search_cb,
search_async_by_contacts (gtk_entry_get_text (GTK_ENTRY (entry)), addressbook_config->max_results, search_cb, addressbook_config); addressbook_config);
} }
/** /**
...@@ -69,25 +69,10 @@ addressbook_is_active() ...@@ -69,25 +69,10 @@ addressbook_is_active()
static void static void
addressbook_config_books(gchar **book_list) addressbook_config_books(gchar **book_list)
{ {
gchar **config_book_uid; for (gchar **book = book_list; book && *book; book++) {
book_data_t *book_data; book_data_t *book_data = books_get_book_data_by_uid(*book);
if (book_data)
if (book_list == NULL) {
printf("Addresbook: Error: Book list is NULL (%s:%d)\n", __FILE__, __LINE__);
return;
}
for (config_book_uid = book_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; book_data->active = TRUE;
}
} }
} }
...@@ -97,9 +82,6 @@ addressbook_config_books(gchar **book_list) ...@@ -97,9 +82,6 @@ addressbook_config_books(gchar **book_list)
GSList * GSList *
addressbook_get_books_data(gchar **book_list) addressbook_get_books_data(gchar **book_list)
{ {
printf("Addressbook: Get books data\n");
// fill_books_data();
addressbook_config_books(book_list); addressbook_config_books(book_list);
determine_default_addressbook(); determine_default_addressbook();
...@@ -119,8 +101,6 @@ addressbook_get_book_data_by_uid(gchar *uid) ...@@ -119,8 +101,6 @@ addressbook_get_book_data_by_uid(gchar *uid)
void void
addressbook_init(gchar **book_list) addressbook_init(gchar **book_list)
{ {
printf("Addressbook: Initialize addressbook\n");
fill_books_data(); fill_books_data();
addressbook_config_books(book_list); addressbook_config_books(book_list);
determine_default_addressbook(); determine_default_addressbook();
...@@ -130,20 +110,16 @@ addressbook_init(gchar **book_list) ...@@ -130,20 +110,16 @@ addressbook_init(gchar **book_list)
} }
void addressbook_set_search_type(AddrbookSearchType searchType) { void addressbook_set_search_type(AddrbookSearchType searchType) {
switch(searchType) { if (searchType > ABOOK_QUERY_CONTAINS)
case ABOOK_QUERY_IS: return;
set_current_addressbook_test(E_BOOK_QUERY_IS);
break; static const EBookQueryTest map[] = {
case ABOOK_QUERY_BEGINS_WITH: [ABOOK_QUERY_IS] = E_BOOK_QUERY_IS,
set_current_addressbook_test(E_BOOK_QUERY_BEGINS_WITH); [ABOOK_QUERY_BEGINS_WITH] = E_BOOK_QUERY_BEGINS_WITH,
break; [ABOOK_QUERY_CONTAINS] = E_BOOK_QUERY_CONTAINS
case ABOOK_QUERY_CONTAINS: };
set_current_addressbook_test(E_BOOK_QUERY_CONTAINS);
break; set_current_addressbook_test(map[searchType]);
default:
printf("Addressbook: Error: Unsupported search type");
break;
}
} }
void addressbook_set_current_book(gchar *current) { void addressbook_set_current_book(gchar *current) {
......
...@@ -40,7 +40,11 @@ ...@@ -40,7 +40,11 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
typedef enum {ABOOK_QUERY_IS, ABOOK_QUERY_BEGINS_WITH, ABOOK_QUERY_CONTAINS} AddrbookSearchType; typedef enum {
ABOOK_QUERY_IS,
ABOOK_QUERY_BEGINS_WITH,
ABOOK_QUERY_CONTAINS
} AddrbookSearchType;
/** /**
* Represent a contact entry * Represent a contact entry
......
This diff is collapsed.
...@@ -72,13 +72,6 @@ fill_books_data (void); ...@@ -72,13 +72,6 @@ fill_books_data (void);
void void
search_async_by_contacts (const char *query, int max_results, SearchAsyncHandler handler, gpointer user_data); 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* GSList*
get_books (void); get_books (void);
...@@ -109,18 +102,9 @@ addressbook_get_books_data(); ...@@ -109,18 +102,9 @@ addressbook_get_books_data();
void void
set_current_addressbook (const gchar *name); set_current_addressbook (const gchar *name);
/**
* Return current addressbook name
*/
const gchar *
get_current_addressbook (void);
void void
set_current_addressbook_test (EBookQueryTest test); set_current_addressbook_test (EBookQueryTest test);
EBookQueryTest
get_current_addressbook_test (void);
GSList * GSList *
get_books_data(); get_books_data();
......
...@@ -21,7 +21,7 @@ else ...@@ -21,7 +21,7 @@ else
CFLAGS="$CFLAGS -Wall -Wextra" CFLAGS="$CFLAGS -Wall -Wextra"
fi fi
AC_PROG_CC AC_PROG_CC_C99
AC_PROG_INSTALL AC_PROG_INSTALL
AC_HEADER_STDC AC_HEADER_STDC
LT_INIT LT_INIT
...@@ -32,7 +32,10 @@ AM_GCONF_SOURCE_2 ...@@ -32,7 +32,10 @@ AM_GCONF_SOURCE_2
PKG_CHECK_MODULES(SFLGTK, gtk+-2.0 > 2.2) PKG_CHECK_MODULES(SFLGTK, gtk+-2.0 > 2.2)
PKG_CHECK_MODULES(SFLGLIB, glib-2.0 >= 2.2) PKG_CHECK_MODULES(SFLGLIB, glib-2.0 >= 2.2)
PKG_CHECK_MODULES(LIBEBOOK, libebook-1.2 >= 1.4) PKG_CHECK_MODULES(LIBEBOOK, libebook-1.2 >= 1.4)
PKG_CHECK_MODULES([LIBEDATASERVER], [libedataserver-1.2 >= 2.32], [AC_DEFINE([LIBEDATASERVER_VERSION_2_32], [], [Using libedataserver-1.2 version 2.32 or higher])],[PKG_CHECK_MODULES([LIBEDATASERVER], [libedataserver-1.2 >= 1.4])]) PKG_CHECK_MODULES([LIBEDATASERVER], [libedataserver-1.2 >= 2.32],
[AC_DEFINE([LIBEDATASERVER_VERSION_2_32], [], [Using libedataserver-1.2 version 2.32 or higher])],
[PKG_CHECK_MODULES([LIBEDATASERVER], [libedataserver-1.2 >= 1.4])]
)
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile Makefile
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment