diff --git a/sflphone-gtk/src/addressbook-config.c b/sflphone-gtk/src/addressbook-config.c index 7e289488c8e4c62c77e65148f14059a1f6be6c27..c0ffa251f13f03e4dd95da298a861a961c26f256 100644 --- a/sflphone-gtk/src/addressbook-config.c +++ b/sflphone-gtk/src/addressbook-config.c @@ -19,6 +19,8 @@ #include "addressbook-config.h" +AddressBook_Config *addressbook_config; + void addressbook_load_parameters (AddressBook_Config **settings) { GHashTable *_params = NULL; @@ -38,53 +40,64 @@ void addressbook_load_parameters (AddressBook_Config **settings) { _settings->search_phone_mobile = 1; } else { - _settings->max_results = (guint)(g_hash_table_lookup (_params, "ADDRESSBOOK_MAX_RESULTS")); - _settings->display_contact_photo = (guint) (g_hash_table_lookup (_params, "ADDRESSBOOK_DISPLAY_CONTACT_PHOTO")); - _settings->search_phone_business = (guint) (g_hash_table_lookup (_params, "ADDRESSBOOK_SEARCH_PHONE_BUSINESS")); - _settings->search_phone_home = (guint) (g_hash_table_lookup (_params, "ADDRESSBOOK_SEARCH_PHONE_HOME")); - _settings->search_phone_mobile = (guint) (g_hash_table_lookup (_params, "ADDRESSBOOK_SEARCH_PHONE_MOBILE")); + _settings->max_results = (guint)(g_hash_table_lookup (_params, ADDRESSBOOK_MAX_RESULTS)); + _settings->display_contact_photo = (guint) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO)); + _settings->search_phone_business = (guint) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS)); + _settings->search_phone_home = (guint) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_HOME)); + _settings->search_phone_mobile = (guint) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_MOBILE)); } *settings = _settings; } +void addressbook_save_parameters (void) { + + GHashTable *params = NULL; + + params = g_hash_table_new (NULL, g_str_equal); + g_hash_table_replace (params, (gpointer)ADDRESSBOOK_MAX_RESULTS, (gpointer)addressbook_config->max_results); + g_hash_table_replace (params, (gpointer)ADDRESSBOOK_DISPLAY_CONTACT_PHOTO, (gpointer)addressbook_config->display_contact_photo); + g_hash_table_replace (params, (gpointer)ADDRESSBOOK_DISPLAY_PHONE_BUSINESS, (gpointer)addressbook_config->search_phone_business); + g_hash_table_replace (params, (gpointer)ADDRESSBOOK_DISPLAY_PHONE_HOME, (gpointer)addressbook_config->search_phone_home); + g_hash_table_replace (params, (gpointer)ADDRESSBOOK_DISPLAY_PHONE_MOBILE, (gpointer)addressbook_config->search_phone_mobile); + + dbus_set_addressbook_settings (params); + + // Decrement the reference count + g_hash_table_unref (params); +} + static void max_results_cb (GtkRange* scale, gpointer user_data) { - AddressBook_Config *settings = (AddressBook_Config*)user_data; - settings->max_results = (guint) gtk_range_get_value (GTK_RANGE (scale)); + addressbook_config->max_results = (guint) gtk_range_get_value (GTK_RANGE (scale)); } -static void display_contact_photo_cb (GtkWidget *widget, gpointer user_data) { +static void display_contact_photo_cb (GtkWidget *widget) { - AddressBook_Config *settings = (AddressBook_Config*)user_data; - settings->display_contact_photo = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); + addressbook_config->display_contact_photo = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); } -static void search_phone_business_cb (GtkWidget *widget, gpointer user_data) { +static void search_phone_business_cb (GtkWidget *widget) { - AddressBook_Config *settings = (AddressBook_Config*)user_data; - settings->search_phone_business = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); + addressbook_config->search_phone_business = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); } -static void search_phone_home_cb (GtkWidget *widget, gpointer user_data) { +static void search_phone_home_cb (GtkWidget *widget) { - AddressBook_Config *settings = (AddressBook_Config*)user_data; - settings->search_phone_home = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); + addressbook_config->search_phone_home = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); } -static void search_phone_mobile_cb (GtkWidget *widget, gpointer user_data) { +static void search_phone_mobile_cb (GtkWidget *widget) { - AddressBook_Config *settings = (AddressBook_Config*)user_data; - settings->search_phone_mobile = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); + addressbook_config->search_phone_mobile = (guint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); } GtkWidget* create_addressbook_settings () { GtkWidget *ret, *result_frame, *box, *value, *label, *photo, *item; - AddressBook_Config *settings; // Load the user value - addressbook_load_parameters (&settings); + addressbook_load_parameters (&addressbook_config); ret = gtk_vbox_new(FALSE, 10); gtk_container_set_border_width(GTK_CONTAINER(ret), 10); @@ -104,32 +117,32 @@ GtkWidget* create_addressbook_settings () { gtk_label_set_mnemonic_widget (GTK_LABEL (label), value); gtk_scale_set_digits (GTK_SCALE(value) , 0); gtk_scale_set_value_pos (GTK_SCALE(value) , GTK_POS_RIGHT); - gtk_range_set_value (GTK_RANGE( value ) , settings->max_results); + gtk_range_set_value (GTK_RANGE( value ) , addressbook_config->max_results); gtk_box_pack_start (GTK_BOX(box) , value , TRUE , TRUE , 0); - g_signal_connect (G_OBJECT (value) , "value-changed" , G_CALLBACK(max_results_cb) , settings); + g_signal_connect (G_OBJECT (value) , "value-changed" , G_CALLBACK(max_results_cb), NULL ); // PHOTO DISPLAY photo = gtk_check_button_new_with_mnemonic( _("_Display contact photo if available")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(photo), settings->display_contact_photo); - g_signal_connect (G_OBJECT(photo) , "clicked" , G_CALLBACK (display_contact_photo_cb) , settings); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(photo), addressbook_config->display_contact_photo); + g_signal_connect (G_OBJECT(photo) , "clicked" , G_CALLBACK (display_contact_photo_cb), NULL); gtk_box_pack_start (GTK_BOX(box) , photo , TRUE , TRUE , 1); label = gtk_label_new (_("Search for and display: ")); gtk_box_pack_start (GTK_BOX(box) , label , FALSE , FALSE , 1); item = gtk_check_button_new_with_mnemonic( _("_Business phone")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(item), settings->search_phone_business); - g_signal_connect (G_OBJECT(item) , "clicked" , G_CALLBACK (search_phone_business_cb) , settings); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(item), addressbook_config->search_phone_business); + g_signal_connect (G_OBJECT(item) , "clicked" , G_CALLBACK (search_phone_business_cb) , NULL); gtk_box_pack_start (GTK_BOX(box) , item , TRUE , TRUE , 1); item = gtk_check_button_new_with_mnemonic( _("_Home phone")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(item), settings->search_phone_home); - g_signal_connect (G_OBJECT(item) , "clicked" , G_CALLBACK (search_phone_home_cb) , settings); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(item), addressbook_config->search_phone_home); + g_signal_connect (G_OBJECT(item) , "clicked" , G_CALLBACK (search_phone_home_cb) , NULL); gtk_box_pack_start (GTK_BOX(box) , item , TRUE , TRUE , 1); item = gtk_check_button_new_with_mnemonic( _("_Mobile phone")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(item), settings->search_phone_mobile); - g_signal_connect (G_OBJECT(item) , "clicked" , G_CALLBACK (search_phone_mobile_cb) , settings); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(item), addressbook_config->search_phone_mobile); + g_signal_connect (G_OBJECT(item) , "clicked" , G_CALLBACK (search_phone_mobile_cb) , NULL); gtk_box_pack_start (GTK_BOX(box) , item , TRUE , TRUE , 1); gtk_widget_show_all(ret); @@ -137,3 +150,25 @@ GtkWidget* create_addressbook_settings () { return ret; } + +gboolean addressbook_display (AddressBook_Config *settings, const gchar *field) { + + gboolean display = FALSE; + + if (g_strcasecmp (field, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO) == 0) + display = (settings->display_contact_photo == 1)? TRUE : FALSE; + + else if (g_strcasecmp (field, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS) == 0) + display = (settings->search_phone_business == 1)? TRUE : FALSE; + + else if (g_strcasecmp (field, ADDRESSBOOK_DISPLAY_PHONE_HOME) == 0) + display = (settings->search_phone_home == 1)? TRUE : FALSE; + + else if (g_strcasecmp (field, ADDRESSBOOK_DISPLAY_PHONE_MOBILE) == 0) + display = (settings->search_phone_mobile == 1)? TRUE : FALSE; + + else + display = FALSE; + + return display; +} diff --git a/sflphone-gtk/src/addressbook-config.h b/sflphone-gtk/src/addressbook-config.h index ac4cf8948be3348f06d5d896505ba29066c68a9d..f880d726bb33500eca10b4f3b302eb26195fe001 100644 --- a/sflphone-gtk/src/addressbook-config.h +++ b/sflphone-gtk/src/addressbook-config.h @@ -27,6 +27,12 @@ G_BEGIN_DECLS +#define ADDRESSBOOK_MAX_RESULTS "ADDRESSBOOK_MAX_RESULTS" +#define ADDRESSBOOK_DISPLAY_CONTACT_PHOTO "ADDRESSBOOK_DISPLAY_CONTACT_PHOTO" +#define ADDRESSBOOK_DISPLAY_PHONE_BUSINESS "ADDRESSBOOK_DISPLAY_PHONE_BUSINESS" +#define ADDRESSBOOK_DISPLAY_PHONE_HOME "ADDRESSBOOK_DISPLAY_PHONE_HOME" +#define ADDRESSBOOK_DISPLAY_PHONE_MOBILE "ADDRESSBOOK_DISPLAY_PHONE_MOBILE" + typedef struct _AddressBook_Config { guint max_results; guint display_contact_photo; @@ -35,13 +41,22 @@ typedef struct _AddressBook_Config { guint search_phone_mobile; } AddressBook_Config; -void set_addressbook_config (AddressBook_Config); +/** + * Save the parameters through D-BUS + */ +void addressbook_save_parameters (void); -AddressBook_Config get_addressbook_config (void); +/** + * Initialize the address book structure, and retrieve the saved parameters through D-Bus + * + * @param settings The addressbook structure + */ +void addressbook_load_parameters (AddressBook_Config **settings); + +gboolean addressbook_display (AddressBook_Config *settings, const gchar *field); GtkWidget* create_addressbook_settings (); G_END_DECLS #endif // _ADDRESS_BOOK_CONFIG - diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c index c4d6117b3991a02843ce25f93e42257d873de917..23d3161e4bfbcac8631655fcaa1eca41bfeade9f 100644 --- a/sflphone-gtk/src/calltree.c +++ b/sflphone-gtk/src/calltree.c @@ -28,7 +28,7 @@ #include <menus.h> #include <dbus.h> #include <contactlist/eds.h> - +#include "addressbook-config.h" GtkWidget * toolbar; GtkToolItem * pickupButton; @@ -229,7 +229,11 @@ handler_async_search (GList *hits, gpointer user_data) { GtkTreeSelection *sel; GList *i; - GdkPixbuf *photo; + GdkPixbuf *photo = NULL; + AddressBook_Config *addressbook_config; + + // Load the parameters + addressbook_load_parameters (&addressbook_config); for (i = hits; i != NULL; i = i->next) { @@ -238,13 +242,17 @@ handler_async_search (GList *hits, gpointer user_data) { if (entry) { /* Get the photo */ - photo = entry->photo; + if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO)) + photo = entry->photo; /* Create entry for business phone information */ - create_new_entry_in_contactlist (entry->name, entry->phone_business, CONTACT_PHONE_BUSINESS, photo); + if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS)) + create_new_entry_in_contactlist (entry->name, entry->phone_business, CONTACT_PHONE_BUSINESS, photo); /* Create entry for home phone information */ - create_new_entry_in_contactlist (entry->name, entry->phone_home, CONTACT_PHONE_HOME, photo); + if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_PHONE_HOME)) + create_new_entry_in_contactlist (entry->name, entry->phone_home, CONTACT_PHONE_HOME, photo); /* Create entry for mobile phone information */ - create_new_entry_in_contactlist (entry->name, entry->phone_mobile, CONTACT_PHONE_MOBILE, photo); + if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_PHONE_MOBILE)) + create_new_entry_in_contactlist (entry->name, entry->phone_mobile, CONTACT_PHONE_MOBILE, photo); } free_hit(entry); } diff --git a/sflphone-gtk/src/configurationmanager-glue.h b/sflphone-gtk/src/configurationmanager-glue.h index 9eacf35be80279d5589fa5261bccdaa6e1a86437..194b6f27be4b6511492afa23c77d8b40d12f0ba0 100644 --- a/sflphone-gtk/src/configurationmanager-glue.h +++ b/sflphone-gtk/src/configurationmanager-glue.h @@ -2263,6 +2263,43 @@ org_sflphone_SFLphone_ConfigurationManager_get_addressbook_settings_async (DBusG stuff->userdata = userdata; return dbus_g_proxy_begin_call (proxy, "getAddressbookSettings", org_sflphone_SFLphone_ConfigurationManager_get_addressbook_settings_async_callback, stuff, g_free, G_TYPE_INVALID); } +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings (DBusGProxy *proxy, const GHashTable* IN_settings, GError **error) + +{ + return dbus_g_proxy_call (proxy, "setAddressbookSettings", error, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_INT), IN_settings, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings_async (DBusGProxy *proxy, const GHashTable* IN_settings, org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "setAddressbookSettings", org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings_async_callback, stuff, g_free, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_INT), IN_settings, G_TYPE_INVALID); +} #endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_sflphone_SFLphone_ConfigurationManager */ G_END_DECLS diff --git a/sflphone-gtk/src/configwindow.c b/sflphone-gtk/src/configwindow.c index c2cac168d3fb4edf128389ddcc5b9b4392382dc0..81063f99aa69c8020d0464c99f56a06df48b6b4e 100644 --- a/sflphone-gtk/src/configwindow.c +++ b/sflphone-gtk/src/configwindow.c @@ -739,6 +739,7 @@ show_config_window () GtkDialog * dialog; GtkWidget * notebook; GtkWidget * tab; + guint result; dialogOpen = TRUE; @@ -782,7 +783,9 @@ show_config_window () gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook) , 1); - gtk_dialog_run(dialog); + result = gtk_dialog_run(dialog); + + save_configuration_parameters (); dialogOpen = FALSE; @@ -849,3 +852,9 @@ void config_window_set_stun_visible() { gtk_widget_set_sensitive( GTK_WIDGET(stunFrame), TRUE ); } + +void save_configuration_parameters (void) { + + addressbook_save_parameters (); + +} diff --git a/sflphone-gtk/src/configwindow.h b/sflphone-gtk/src/configwindow.h index ffb212706be5b3b48d2b125dc139bb2c6ade23df..4585b99ff665943f58a990346aeaa0b59ba5723c 100644 --- a/sflphone-gtk/src/configwindow.h +++ b/sflphone-gtk/src/configwindow.h @@ -116,4 +116,6 @@ void show_accounts_window(); void config_window_set_stun_visible(); +void save_configuration_parameters (void); + #endif diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c index 5c761225dd79a5402ce4610a396fc9b8280a9d4d..6ba104f322087ce976e6a63ae3ecd49bf19037b0 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -1467,7 +1467,17 @@ GHashTable* dbus_get_addressbook_settings (void) { return results; } +void dbus_set_addressbook_settings (GHashTable * settings){ + GError *error = NULL; + g_print ("Calling org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings\n"); + + org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings (configurationManagerProxy, settings, &error); + if (error){ + g_print ("Error calling org_sflphone_SFLphone_ConfigurationManager_set_addressbook_settings\n"); + g_error_free (error); + } +} diff --git a/sflphone-gtk/src/dbus.h b/sflphone-gtk/src/dbus.h index 1afdff273bf8b55d218fc4eb8297ef342dec160b..7eac089d8ae3d9768301b2ac134e5cb77e10eb4f 100644 --- a/sflphone-gtk/src/dbus.h +++ b/sflphone-gtk/src/dbus.h @@ -448,9 +448,17 @@ gchar* dbus_get_record_path (void); /** * Encapsulate all the address book-related configuration + * Get the configuration */ GHashTable* dbus_get_addressbook_settings (void); +/** + * Encapsulate all the address book-related configuration + * Set the configuration + */ +void dbus_set_addressbook_settings (GHashTable *); + + #endif diff --git a/src/dbus/configurationmanager-glue.h b/src/dbus/configurationmanager-glue.h index eb64b7496479b674a4e2963db5781713c553f10e..3c9eacbf7a2558bafadec844bb1056c7939a9211 100644 --- a/src/dbus/configurationmanager-glue.h +++ b/src/dbus/configurationmanager-glue.h @@ -80,6 +80,7 @@ public: register_method(ConfigurationManager_adaptor, enableStun, _enableStun_stub); register_method(ConfigurationManager_adaptor, isStunEnabled, _isStunEnabled_stub); register_method(ConfigurationManager_adaptor, getAddressbookSettings, _getAddressbookSettings_stub); + register_method(ConfigurationManager_adaptor, setAddressbookSettings, _setAddressbookSettings_stub); } ::DBus::IntrospectedInterface *const introspect() const @@ -379,6 +380,11 @@ public: { "settings", "a{si}", false }, { 0, 0, 0 } }; + static ::DBus::IntrospectedArgument setAddressbookSettings_args[] = + { + { "settings", "a{si}", true }, + { 0, 0, 0 } + }; static ::DBus::IntrospectedArgument parametersChanged_args[] = { { "list", "a{ss}", false }, @@ -455,6 +461,7 @@ public: { "enableStun", enableStun_args }, { "isStunEnabled", isStunEnabled_args }, { "getAddressbookSettings", getAddressbookSettings_args }, + { "setAddressbookSettings", setAddressbookSettings_args }, { 0, 0 } }; static ::DBus::IntrospectedMethod ConfigurationManager_adaptor_signals[] = @@ -549,6 +556,7 @@ public: virtual void enableStun() = 0; virtual int32_t isStunEnabled() = 0; virtual std::map< std::string, int32_t > getAddressbookSettings() = 0; + virtual void setAddressbookSettings(const std::map< std::string, int32_t >& settings) = 0; public: @@ -1148,6 +1156,15 @@ private: wi << argout1; return reply; } + ::DBus::Message _setAddressbookSettings_stub(const ::DBus::CallMessage &call) + { + ::DBus::MessageIter ri = call.reader(); + + std::map< std::string, int32_t > argin1; ri >> argin1; + setAddressbookSettings(argin1); + ::DBus::ReturnMessage reply(call); + return reply; + } }; } } } diff --git a/src/dbus/configurationmanager-introspec.xml b/src/dbus/configurationmanager-introspec.xml index 13c12f55055337ad001c411660ec4526c5343b62..6f897c2c2a0fd1082fa27fd4534bc3ac34f3c45c 100644 --- a/src/dbus/configurationmanager-introspec.xml +++ b/src/dbus/configurationmanager-introspec.xml @@ -247,6 +247,10 @@ <arg type="a{si}" name="settings" direction="out"/> </method> + <method name="setAddressbookSettings"> + <arg type="a{si}" name="settings" direction="in"/> + </method> + <!-- ///////////////////////////// --> <signal name="parametersChanged"> <arg type="a{ss}" name="list" direction="out"/> diff --git a/src/dbus/configurationmanager.cpp b/src/dbus/configurationmanager.cpp index 18493bf6caec728df082b454ab0a381d75d71e6e..ac26ec4a42491e654ec61ef4e14c1aad2a207382 100644 --- a/src/dbus/configurationmanager.cpp +++ b/src/dbus/configurationmanager.cpp @@ -429,3 +429,7 @@ int32_t ConfigurationManager::isStunEnabled (void) std::map<std::string, int32_t> ConfigurationManager::getAddressbookSettings (void) { return Manager::instance().getAddressbookSettings (); } + +void ConfigurationManager::setAddressbookSettings (const std::map<std::string, int32_t>& settings) { + Manager::instance().setAddressbookSettings (settings); +} diff --git a/src/dbus/configurationmanager.h b/src/dbus/configurationmanager.h index eb231c4ddad10e535eeca50af7a2f4897d0d127c..ebbc728d1d99807b4f7d106f2fd8033af4d3d6d6 100644 --- a/src/dbus/configurationmanager.h +++ b/src/dbus/configurationmanager.h @@ -105,6 +105,7 @@ public: int32_t isStunEnabled (void); std::map<std::string, int32_t> getAddressbookSettings (void); + void setAddressbookSettings (const std::map<std::string, int32_t>& settings); }; diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index c6a8ee3969c89395e6941524abafcd3857d65217..44473af2cba726d8a264b0c50b7377954f27cc4c 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -1068,10 +1068,10 @@ ManagerImpl::initConfigFile ( bool load_user_value ) section = ADDRESSBOOK; fill_config_int (ADDRESSBOOK_MAX_RESULTS, "25"); - fill_config_int (ADDRESSBOOK_DISPLAY_CONTACT_PHOTO, YES_STR); + fill_config_int (ADDRESSBOOK_DISPLAY_CONTACT_PHOTO, NO_STR); fill_config_int (ADDRESSBOOK_DISPLAY_PHONE_BUSINESS, YES_STR); - fill_config_int (ADDRESSBOOK_DISPLAY_PHONE_HOME, YES_STR); - fill_config_int (ADDRESSBOOK_DISPLAY_PHONE_MOBILE, YES_STR); + fill_config_int (ADDRESSBOOK_DISPLAY_PHONE_HOME, NO_STR); + fill_config_int (ADDRESSBOOK_DISPLAY_PHONE_MOBILE, NO_STR); // Loads config from ~/.sflphone/sflphonedrc or so.. if (createSettingsPath() == 1 && load_user_value) { @@ -2398,6 +2398,18 @@ std::map<std::string, int32_t> ManagerImpl::getAddressbookSettings () { return settings; } +void ManagerImpl::setAddressbookSettings (const std::map<std::string, int32_t>& settings){ + + setConfig(ADDRESSBOOK, ADDRESSBOOK_MAX_RESULTS, (*settings.find("ADDRESSBOOK_MAX_RESULTS")).second); + setConfig(ADDRESSBOOK, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO , (*settings.find("ADDRESSBOOK_DISPLAY_CONTACT_PHOTO")).second); + setConfig(ADDRESSBOOK, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS , (*settings.find("ADDRESSBOOK_DISPLAY_PHONE_BUSINESS")).second); + setConfig(ADDRESSBOOK, ADDRESSBOOK_DISPLAY_PHONE_HOME , (*settings.find("ADDRESSBOOK_DISPLAY_PHONE_HOME")).second); + setConfig(ADDRESSBOOK, ADDRESSBOOK_DISPLAY_PHONE_MOBILE , (*settings.find("ADDRESSBOOK_DISPLAY_PHONE_MOBILE")).second); + + // Write it to the configuration file + saveConfig (); +} + #ifdef TEST /** diff --git a/src/managerimpl.h b/src/managerimpl.h index 206f58e562bdf671231ecabdee48cf4183534b1b..9d27ea402be3c75e4404ee9637f82733cec879e9 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -559,6 +559,11 @@ class ManagerImpl { */ std::map<std::string, int32_t> getAddressbookSettings (void); + /** + * Addressbook configuration + */ + void setAddressbookSettings (const std::map<std::string, int32_t>& settings); + /** * Get the audio manager * @return int The audio manager