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

* #5695: addressbook: simplify

parent 0b998639
......@@ -138,7 +138,7 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count)
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:")) {
gchar * new_number = g_strconcat ("sip:", c->_peer_number, NULL);
g_free (c->_peer_number);
......
......@@ -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)
{
/* Check if the information is valid */
if (g_strcasecmp (contact_phone, "empty") == 0)
if (!contact_phone)
return;
callable_obj_t *new_call = create_new_call (CONTACT, CALL_STATE_DIALING, "", "", contact_name, contact_phone);
......
......@@ -39,10 +39,10 @@
void
addressbook_search (void (*search_cb)(GList *, gpointer), GtkEntry* entry, AddressBook_Config *addressbook_config)
{
const gchar* query = gtk_entry_get_text (GTK_ENTRY (entry));
printf("Addressbook: Search %s\n", query);
search_async_by_contacts (gtk_entry_get_text (GTK_ENTRY (entry)), addressbook_config->max_results, search_cb, addressbook_config);
search_async_by_contacts (gtk_entry_get_text(entry),
addressbook_config->max_results,
search_cb,
addressbook_config);
}
/**
......@@ -69,25 +69,10 @@ addressbook_is_active()
static void
addressbook_config_books(gchar **book_list)
{
gchar **config_book_uid;
book_data_t *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 {
for (gchar **book = book_list; book && *book; book++) {
book_data_t *book_data = books_get_book_data_by_uid(*book);
if (book_data)
book_data->active = TRUE;
}
}
}
......@@ -97,9 +82,6 @@ addressbook_config_books(gchar **book_list)
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();
......@@ -119,8 +101,6 @@ addressbook_get_book_data_by_uid(gchar *uid)
void
addressbook_init(gchar **book_list)
{
printf("Addressbook: Initialize addressbook\n");
fill_books_data();
addressbook_config_books(book_list);
determine_default_addressbook();
......@@ -130,20 +110,16 @@ addressbook_init(gchar **book_list)
}
void addressbook_set_search_type(AddrbookSearchType searchType) {
switch(searchType) {
case ABOOK_QUERY_IS:
set_current_addressbook_test(E_BOOK_QUERY_IS);
break;
case ABOOK_QUERY_BEGINS_WITH:
set_current_addressbook_test(E_BOOK_QUERY_BEGINS_WITH);
break;
case ABOOK_QUERY_CONTAINS:
set_current_addressbook_test(E_BOOK_QUERY_CONTAINS);
break;
default:
printf("Addressbook: Error: Unsupported search type");
break;
}
if (searchType > ABOOK_QUERY_CONTAINS)
return;
static const EBookQueryTest map[] = {
[ABOOK_QUERY_IS] = E_BOOK_QUERY_IS,
[ABOOK_QUERY_BEGINS_WITH] = E_BOOK_QUERY_BEGINS_WITH,
[ABOOK_QUERY_CONTAINS] = E_BOOK_QUERY_CONTAINS
};
set_current_addressbook_test(map[searchType]);
}
void addressbook_set_current_book(gchar *current) {
......
......@@ -40,7 +40,11 @@
#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
......
This diff is collapsed.
......@@ -72,13 +72,6 @@ fill_books_data (void);
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);
......@@ -109,18 +102,9 @@ addressbook_get_books_data();
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();
......
......@@ -21,7 +21,7 @@ else
CFLAGS="$CFLAGS -Wall -Wextra"
fi
AC_PROG_CC
AC_PROG_CC_C99
AC_PROG_INSTALL
AC_HEADER_STDC
LT_INIT
......@@ -32,7 +32,10 @@ AM_GCONF_SOURCE_2
PKG_CHECK_MODULES(SFLGTK, gtk+-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([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([
Makefile
......
Markdown is supported
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