Commit 85ad9736 authored by Tristan Matthews's avatar Tristan Matthews
Browse files
parents 7ba2bd7b 8ec8d772
...@@ -63,9 +63,10 @@ YamlParser::YamlParser (const char *file) : filename (file) ...@@ -63,9 +63,10 @@ YamlParser::YamlParser (const char *file) : filename (file)
YamlParser::~YamlParser() YamlParser::~YamlParser()
{ {
fclose (fd); if (fd) {
fclose (fd);
yaml_parser_delete (&parser); yaml_parser_delete (&parser);
}
for (int i = 0; i < eventNumber; i++) for (int i = 0; i < eventNumber; i++)
yaml_event_delete (&events[i]); yaml_event_delete (&events[i]);
......
...@@ -98,7 +98,7 @@ void ManagerImpl::init (std::string config_file) ...@@ -98,7 +98,7 @@ void ManagerImpl::init (std::string config_file)
_debug ("Manager: configuration file path: %s", _path.c_str()); _debug ("Manager: configuration file path: %s", _path.c_str());
Conf::YamlParser *parser; Conf::YamlParser *parser = NULL;
try { try {
parser = new Conf::YamlParser (_path.c_str()); parser = new Conf::YamlParser (_path.c_str());
...@@ -107,6 +107,7 @@ void ManagerImpl::init (std::string config_file) ...@@ -107,6 +107,7 @@ void ManagerImpl::init (std::string config_file)
parser->constructNativeData(); parser->constructNativeData();
} catch (Conf::YamlParserException &e) { } catch (Conf::YamlParserException &e) {
_error ("Manager: %s", e.what()); _error ("Manager: %s", e.what());
fflush(stderr);
delete parser; delete parser;
parser = NULL; parser = NULL;
} }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
<listOptionValue builtIn="false" value="/usr/include/libgnome-2.0"/> <listOptionValue builtIn="false" value="/usr/include/libgnome-2.0"/>
<listOptionValue builtIn="false" value="/usr/include/libgnomeui-2.0"/> <listOptionValue builtIn="false" value="/usr/include/libgnomeui-2.0"/>
<listOptionValue builtIn="false" value="/usr/include"/> <listOptionValue builtIn="false" value="/usr/include"/>
<listOptionValue builtIn="false" value="/usr/include/evolution-data-server-2.30"/>
</option> </option>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1676995808" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> <option id="gnu.c.compiler.option.preprocessor.def.symbols.1676995808" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="&quot;ICONS_DIR=&quot;/usr/share/sflphone\&quot;"/> <listOptionValue builtIn="false" value="&quot;ICONS_DIR=&quot;/usr/share/sflphone\&quot;"/>
......
...@@ -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);
...@@ -333,7 +333,7 @@ gboolean sflphone_init (GError **error) ...@@ -333,7 +333,7 @@ gboolean sflphone_init (GError **error)
if (!dbus_connect (error) || !dbus_register (getpid (), "Gtk+ Client", error)) if (!dbus_connect (error) || !dbus_register (getpid (), "Gtk+ Client", error))
return FALSE; return FALSE;
abookfactory_init_factory(); abook_init();
// Init icons factory // Init icons factory
init_icon_factory (); init_icon_factory ();
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "addressbook-config.h" #include "addressbook-config.h"
#include "searchbar.h" #include "searchbar.h"
#include "contacts/addrbookfactory.h" #include "contacts/addrbookfactory.h"
// #include "contacts/addressbook/eds.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -44,44 +43,33 @@ enum { ...@@ -44,44 +43,33 @@ enum {
COLUMN_BOOK_ACTIVE, COLUMN_BOOK_NAME, COLUMN_BOOK_UID COLUMN_BOOK_ACTIVE, COLUMN_BOOK_NAME, COLUMN_BOOK_UID
}; };
void AddressBook_Config *addressbook_config_load_parameters ()
addressbook_config_load_parameters (AddressBook_Config **settings)
{ {
AddressBook_Config *config = g_new0 (AddressBook_Config, 1);
GHashTable *_params = NULL; GHashTable *params = dbus_get_addressbook_settings();
AddressBook_Config *_settings;
if (params == NULL) {
// Allocate a struct config->enable = 1;
_settings = g_new0 (AddressBook_Config, 1); config->max_results = 30;
config->display_contact_photo = 0;
// Fetch the settings from D-Bus config->search_phone_business = 1;
_params = (GHashTable*) dbus_get_addressbook_settings(); config->search_phone_home = 1;
config->search_phone_mobile = 1;
if (_params == NULL) {
DEBUG ("Addressbook: No parameters received, use default");
_settings->enable = 1;
_settings->max_results = 30;
_settings->display_contact_photo = 0;
_settings->search_phone_business = 1;
_settings->search_phone_home = 1;
_settings->search_phone_mobile = 1;
} }
else { else {
_settings->enable = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_ENABLE)); config->enable = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_ENABLE));
_settings->max_results = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_MAX_RESULTS)); config->max_results = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_MAX_RESULTS));
_settings->display_contact_photo = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO)); config->display_contact_photo = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO));
_settings->search_phone_business = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS)); config->search_phone_business = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS));
_settings->search_phone_home = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_HOME)); config->search_phone_home = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_DISPLAY_PHONE_HOME));
_settings->search_phone_mobile = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_MOBILE)); config->search_phone_mobile = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_DISPLAY_PHONE_MOBILE));
} }
DEBUG ("Addressbook: Settings: enabled %d, max_result %d, photo %d, business %d, home %d, mobile %d", DEBUG ("Addressbook: Settings: enabled %d, max_result %d, photo %d, business %d, home %d, mobile %d",
_settings->enable, _settings->max_results, _settings->display_contact_photo, config->enable, config->max_results, config->display_contact_photo,
_settings->search_phone_business, _settings->search_phone_home, _settings->search_phone_mobile); config->search_phone_business, config->search_phone_home, config->search_phone_mobile);
*settings = _settings; return config;
} }
void void
...@@ -211,9 +199,8 @@ addressbook_config_book_active_toggled ( ...@@ -211,9 +199,8 @@ addressbook_config_book_active_toggled (
gchar* name; gchar* name;
gchar* uid; gchar* uid;
if(!abookfactory_is_addressbook_loaded()) { if(!addrbook)
return; return;
}
// Get path of clicked book active toggle box // Get path of clicked book active toggle box
treePath = gtk_tree_path_new_from_string (path); treePath = gtk_tree_path_new_from_string (path);
...@@ -223,8 +210,6 @@ addressbook_config_book_active_toggled ( ...@@ -223,8 +210,6 @@ addressbook_config_book_active_toggled (
return; return;
} }
AddrBookFactory *factory = abookfactory_get_factory();
gtk_tree_model_get_iter (model, &iter, treePath); gtk_tree_model_get_iter (model, &iter, treePath);
// Get active value at iteration // Get active value at iteration
...@@ -240,7 +225,7 @@ addressbook_config_book_active_toggled ( ...@@ -240,7 +225,7 @@ addressbook_config_book_active_toggled (
gtk_tree_path_free (treePath); gtk_tree_path_free (treePath);
// Update current memory stored books data // Update current memory stored books data
book_data = factory->addrbook->get_book_data_by_uid(uid); book_data = addrbook->get_book_data_by_uid(uid);
if(book_data == NULL) { if(book_data == NULL) {
ERROR("Addressbook: Error: Could not find addressbook %s", uid); ERROR("Addressbook: Error: Could not find addressbook %s", uid);
} }
...@@ -292,14 +277,11 @@ addressbook_config_fill_book_list() ...@@ -292,14 +277,11 @@ addressbook_config_fill_book_list()
book_data_t *book_data; book_data_t *book_data;
gchar **book_list; gchar **book_list;
if(!abookfactory_is_addressbook_loaded()) { if(!addrbook)
return; return;
}
AddrBookFactory *factory = abookfactory_get_factory();
book_list = dbus_get_addressbook_list(); book_list = dbus_get_addressbook_list();
GSList *books_data = factory->addrbook->get_books_data(book_list); GSList *books_data = addrbook->get_books_data(book_list);
if (!books_data) { if (!books_data) {
DEBUG ("Addressbook: No valid books data (%s:%d)", __FILE__, __LINE__); DEBUG ("Addressbook: No valid books data (%s:%d)", __FILE__, __LINE__);
...@@ -338,7 +320,7 @@ create_addressbook_settings() ...@@ -338,7 +320,7 @@ create_addressbook_settings()
GtkTreeViewColumn *tree_view_column; GtkTreeViewColumn *tree_view_column;
// Load the user value // Load the user value
addressbook_config_load_parameters (&addressbook_config); addressbook_config = addressbook_config_load_parameters();
ret = gtk_vbox_new (FALSE, 10); ret = gtk_vbox_new (FALSE, 10);
gtk_container_set_border_width (GTK_CONTAINER (ret), 10); gtk_container_set_border_width (GTK_CONTAINER (ret), 10);
......
...@@ -67,12 +67,9 @@ void ...@@ -67,12 +67,9 @@ void
addressbook_config_save_parameters (void); addressbook_config_save_parameters (void);
/** /**
* Initialize the address book structure, and retrieve the saved parameters through D-Bus * Return the saved parameters through D-Bus
*
* @param settings The addressbook structure
*/ */
void AddressBook_Config *addressbook_config_load_parameters();
addressbook_config_load_parameters (AddressBook_Config **settings);
gboolean gboolean
addressbook_display (AddressBook_Config *settings, const gchar *field); addressbook_display (AddressBook_Config *settings, const gchar *field);
......
...@@ -285,7 +285,7 @@ create_general_settings () ...@@ -285,7 +285,7 @@ create_general_settings ()
void void
save_configuration_parameters (void) save_configuration_parameters (void)
{ {
if(abookfactory_is_addressbook_loaded()) { if (addrbook) {
// Address book config // Address book config
addressbook_config_save_parameters (); addressbook_config_save_parameters ();
} }
...@@ -410,7 +410,7 @@ show_preferences_dialog () ...@@ -410,7 +410,7 @@ show_preferences_dialog ()
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new (_ ("Shortcuts"))); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new (_ ("Shortcuts")));
gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab); gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab);
if(abookfactory_is_addressbook_loaded()) { if(addrbook) {
// Addressbook tab // Addressbook tab
tab = create_addressbook_settings (); tab = create_addressbook_settings ();
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new (_ ("Address Book"))); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new (_ ("Address Book")));
...@@ -451,7 +451,7 @@ GtkTreeModel* createModel() ...@@ -451,7 +451,7 @@ GtkTreeModel* createModel()
GError *error = NULL; GError *error = NULL;
gint i, nb_entries; gint i, nb_entries;
nb_entries = abookfactory_is_addressbook_loaded() ? 5 : 4; nb_entries = addrbook ? 5 : 4;
store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
GtkIconTheme* theme = gtk_icon_theme_get_default(); GtkIconTheme* theme = gtk_icon_theme_get_default();
......
...@@ -37,93 +37,8 @@ ...@@ -37,93 +37,8 @@
#include <glib.h> #include <glib.h>
#include <dlfcn.h> #include <dlfcn.h>
static void handler_async_search(GList *hits, gpointer user_data); AddrBookHandle *addrbook = NULL;
AddrBookFactory addressbookFactory = { .addrbook = NULL };
AddrBookFactory *abookfactory_get_factory(void) {
return &addressbookFactory;
}
gboolean abookfactory_is_addressbook_loaded(void) {
return (addressbookFactory.addrbook != NULL) ? TRUE : FALSE;
}
void abookfactory_init_factory() {
abookfactory_load_module(&addressbookFactory);
}
void abookfactory_scan_directory(AddrBookFactory *factory UNUSED) {
}
void abookfactory_load_module(AddrBookFactory *factory)
{
gchar *plugindir = PLUGINS_DIR;
gchar *pluginpath = g_strdup_printf("%s/libevladdrbook.so", plugindir);
DEBUG("AddressbookFactory: Loading addressbook: %s", pluginpath);
void *handle = dlopen(pluginpath, RTLD_LAZY);
g_free(pluginpath);
if(handle == NULL) {
ERROR("AddressbookFactory: Error: Could not load addressbook");
return;
}
AddrBookHandle *ab = g_malloc(sizeof(AddrBookHandle));
ab->init = dlsym(handle, "addressbook_init");
if(ab->init == NULL)
ERROR("AddressbookFactory: Error: Could not load addressbook_init function");
ab->is_ready = dlsym(handle, "addressbook_is_ready");
if(ab->is_ready == NULL)
ERROR("AddressbookFactory: Error: Could not load addressbook addressbook_is_ready function");
ab->is_enabled = dlsym(handle, "addressbook_is_enabled");
if(ab->is_enabled == NULL)
ERROR("AddressbookFactory: Error: Could not load addressbook addressbook_is_enabled function");
ab->is_active = dlsym(handle, "addressbook_is_active");
if(ab->is_active == NULL)
ERROR("AddressbookFactory: Error: Could not load addressbook addressbook_is_active function");
ab->search = dlsym(handle, "addressbook_search");
if(ab->search == NULL)
ERROR("AddressbookFactory: Error: Could not load addressbook addressbook_search function");
ab->get_books_data = dlsym(handle, "addressbook_get_books_data");
if(ab->get_books_data == NULL)
ERROR("AddressbookFactory: Error: Could not load addressbook addressbook_get_books_data function");
ab->get_book_data_by_uid = dlsym(handle, "addressbook_get_book_data_by_uid");
if(ab->get_book_data_by_uid == NULL)
ERROR("AddressbookFactory: Error: Could not load addressbook addressbook_get_books_data_by_uid function");
ab->set_current_book = dlsym(handle, "addressbook_set_current_book");
if(ab->set_current_book == NULL)
ERROR("AddressbookFactory: Error: Could not load addressbook addressbook_ser_current_book");
ab->set_search_type = dlsym(handle, "addressbook_set_search_type");
if(ab->set_search_type == NULL)
ERROR("AddressbookFactory: Error: Could not load addressbook addressbook_set_search_type");
ab->search_cb = handler_async_search;
DEBUG("AddressbookFactory: Loading done");
factory->addrbook = ab;
}
void
free_hit (Hit *h)
{
g_free (h->name);
g_free (h->phone_business);
g_free (h->phone_home);
g_free (h->phone_mobile);
g_free (h);
}
/** /**
* Callback called after all book have been processed * Callback called after all book have been processed
...@@ -131,52 +46,73 @@ free_hit (Hit *h) ...@@ -131,52 +46,73 @@ free_hit (Hit *h)
static void static void
handler_async_search (GList *hits, gpointer user_data) handler_async_search (GList *hits, gpointer user_data)
{ {
GList *i;
// Retrieve the address book parameters
AddressBook_Config *addressbook_config = user_data; AddressBook_Config *addressbook_config = user_data;
// reset previous results
calltree_reset (contacts); calltree_reset (contacts);
calllist_reset (contacts); calllist_reset (contacts);
for (i = hits; i != NULL; i = i->next) { for (GList *i = hits; i != NULL; i = i->next) {
GdkPixbuf *photo = NULL; GdkPixbuf *photo = NULL;
Hit *entry = i->data; Hit *entry = i->data;
if (!entry) if (!entry)
continue; continue;
// Get the photo
if (addressbook_display (addressbook_config, if (addressbook_display (addressbook_config,
ADDRESSBOOK_DISPLAY_CONTACT_PHOTO)) ADDRESSBOOK_DISPLAY_CONTACT_PHOTO))
photo = entry->photo; photo = entry->photo;
// Create entry for business phone information
if (addressbook_display (addressbook_config, if (addressbook_display (addressbook_config,
ADDRESSBOOK_DISPLAY_PHONE_BUSINESS)) ADDRESSBOOK_DISPLAY_PHONE_BUSINESS))
calllist_add_contact (entry->name, entry->phone_business, calllist_add_contact (entry->name, entry->phone_business,
CONTACT_PHONE_BUSINESS, photo); CONTACT_PHONE_BUSINESS, photo);
// Create entry for home phone information
if (addressbook_display (addressbook_config, if (addressbook_display (addressbook_config,
ADDRESSBOOK_DISPLAY_PHONE_HOME)) ADDRESSBOOK_DISPLAY_PHONE_HOME))
calllist_add_contact (entry->name, entry->phone_home, calllist_add_contact (entry->name, entry->phone_home,
CONTACT_PHONE_HOME, photo); CONTACT_PHONE_HOME, photo);
// Create entry for mobile phone iddnformation
if (addressbook_display (addressbook_config, if (addressbook_display (addressbook_config,
ADDRESSBOOK_DISPLAY_PHONE_MOBILE)) ADDRESSBOOK_DISPLAY_PHONE_MOBILE))
calllist_add_contact (entry->name, entry->phone_mobile, calllist_add_contact (entry->name, entry->phone_mobile,
CONTACT_PHONE_MOBILE, photo); CONTACT_PHONE_MOBILE, photo);
free_hit (entry); g_free (entry->name);
g_free (entry->phone_business);
g_free (entry->phone_home);
g_free (entry->phone_mobile);
g_free (entry);
} }
g_list_free (hits); g_list_free (hits);
gtk_widget_grab_focus(GTK_WIDGET (contacts->view));
}
void abook_init()
{
void *handle = dlopen(PLUGINS_DIR"/libevladdrbook.so", RTLD_LAZY);
if(handle == NULL) {
ERROR("Addressbook: Error: Could not load addressbook");
return;
}
addrbook = g_malloc(sizeof(AddrBookHandle));
#define LOAD(func) do { \
addrbook-> func = dlsym(handle, "addressbook_" #func); \
if (addrbook-> func == NULL) \
ERROR("Addressbook: Couldn't load " # func); \
} while(0)
// Deactivate waiting image
// deactivateWaitingLayer();
LOAD(init);
LOAD(is_ready);
LOAD(is_active);
LOAD(search);
LOAD(get_books_data);
LOAD(get_book_data_by_uid);
LOAD(set_current_book);
LOAD(set_search_type);
gtk_widget_grab_focus (GTK_WIDGET (contacts->view)); addrbook->search_cb = handler_async_search;
} }
...@@ -32,24 +32,10 @@ ...@@ -32,24 +32,10 @@
#ifndef __ADDRBOOKFACTORY_H__ #ifndef __ADDRBOOKFACTORY_H__
#define __ADDRBOOKFACTORY_H__ #define __ADDRBOOKFACTORY_H__
#include <dlfcn.h>
#include <gtk/gtk.h>
#include "addressbook.h" #include "addressbook.h"
typedef struct _addrbookfactory { void abook_init();
gboolean is_loaded;
AddrBookHandle *addrbook;
} AddrBookFactory;
void abookfactory_init_factory(); extern AddrBookHandle *addrbook;
AddrBookFactory *abookfactory_get_factory(void);
gboolean abookfactory_is_addressbook_loaded(void);
void abookfactory_scan_directory(AddrBookFactory *);
void abookfactory_load_module(AddrBookFactory *);
void free_hit(Hit *);
#endif #endif
...@@ -39,10 +39,6 @@ ...@@ -39,10 +39,6 @@
#define __ADDRESSBOOK_H__ #define __ADDRESSBOOK_H__
#include <gtk/gtk.h> #include <gtk/gtk.h>
// #include <addressbook/eds.h>
#define EMPTY_ENTRY "empty"
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;
...@@ -84,9 +80,8 @@ typedef struct AddrBookHandle AddrBookHandle; ...@@ -84,9 +80,8 @@ typedef struct AddrBookHandle AddrBookHandle;
struct AddrBookHandle { struct AddrBookHandle {
void (*init) (gchar **); void (*init) (gchar **);
gboolean (*is_ready) (void); gboolean (*is_ready) (void);
gboolean (*is_enabled) (void);
gboolean (*is_active) (void); gboolean (*is_active) (void);
void (*search) (AddrBookHandle *, GtkEntry *, AddressBook_Config *); void (*search) (void (*search_cb)(GList *, gpointer), GtkEntry *, AddressBook_Config *);
GSList *(*get_books_data)(gchar **); GSList *(*get_books_data)(gchar **);
book_data_t *(*get_book_data_by_uid)(gchar *); book_data_t *(*get_book_data_by_uid)(gchar *);
void (*set_current_book)(gchar *); void (*set_current_book)(gchar *);
...@@ -94,41 +89,4 @@ struct AddrBookHandle { ...@@ -94,41 +89,4 @@ struct AddrBookHandle {
void (*search_cb)(GList *, gpointer); void (*search_cb)(GList *, gpointer);
}; };
/**
* Initialize addressbook
*/