Commit 8a6390ec authored by spiiroin's avatar spiiroin

[config] Send D-Bus change notifications on setting changes

Changing setting values and broadcasting changes on D-Bus are handled
separately. This leads to a situation where some code paths that modify
settings do it silently without sending D-Bus notifications.

Send setting change notification from configuration layer, so that each
and every setting change does result in D-Bus notification signal.

Remove all case-by-case signal emitting code made redundant by these
changes.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent b5a8e8b0
......@@ -415,6 +415,7 @@ set_config_result_t config_set_config_setting(const char *entry, const char *key
if( g_strcmp0(prev, value) ) {
g_key_file_set_string(active_ini, entry, key, value);
ret = SET_CONFIG_UPDATED;
umdbus_send_config_signal(entry, key, value);
}
/* Filter out dynamic data that matches static values */
......@@ -436,7 +437,11 @@ set_config_result_t config_set_mode_setting(const char *mode)
if (strcmp(mode, MODE_ASK) && common_valid_mode(mode))
return SET_CONFIG_ERROR;
return config_set_config_setting(MODE_SETTING_ENTRY, MODE_SETTING_KEY, mode);
int ret = config_set_config_setting(MODE_SETTING_ENTRY,
MODE_SETTING_KEY, mode);
return ret;
}
/* Builds the string used for hidden modes, when hide set to one builds the
......@@ -588,9 +593,7 @@ set_config_result_t config_set_mode_in_whitelist(const char *mode, int allowed)
char *whitelist = config_make_modes_string(MODE_WHITELIST_KEY, mode, allowed);
if (whitelist) {
ret = config_set_mode_whitelist(whitelist);
}
ret = config_set_mode_whitelist(whitelist ?: "");
g_free(whitelist);
......
......@@ -57,6 +57,7 @@ typedef void (*usb_moded_get_name_owner_fn)(const char *owner);
* UMDBUS
* ------------------------------------------------------------------------- */
void umdbus_send_config_signal (const char *section, const char *key, const char *value);
DBusConnection *umdbus_get_connection (void);
gboolean umdbus_init_connection (void);
gboolean umdbus_init_service (void);
......
......@@ -59,7 +59,7 @@
* UMDBUS
* ------------------------------------------------------------------------- */
static void umdbus_send_config_signal (const char *section, const char *key, const char *value);
void umdbus_send_config_signal (const char *section, const char *key, const char *value);
static DBusHandlerResult umdbus_msg_handler (DBusConnection *const connection, DBusMessage *const msg, gpointer const user_data);
DBusConnection *umdbus_get_connection (void);
gboolean umdbus_init_connection (void);
......@@ -233,7 +233,7 @@ static const char umdbus_introspect_usbmoded[] =
/**
* Issues "sig_usb_config_ind" signal.
*/
static void umdbus_send_config_signal(const char *section, const char *key, const char *value)
void umdbus_send_config_signal(const char *section, const char *key, const char *value)
{
LOG_REGISTER_CONTEXT;
......@@ -384,8 +384,6 @@ static DBusHandlerResult umdbus_msg_handler(DBusConnection *const connection, DB
{
/* error checking is done when setting configuration */
int ret = config_set_mode_setting(config);
if (ret == SET_CONFIG_UPDATED)
umdbus_send_config_signal(MODE_SETTING_ENTRY, MODE_SETTING_KEY, config);
if (SET_CONFIG_OK(ret))
{
if((reply = dbus_message_new_method_return(msg)))
......@@ -407,8 +405,6 @@ static DBusHandlerResult umdbus_msg_handler(DBusConnection *const connection, DB
{
/* error checking is done when setting configuration */
int ret = config_set_hide_mode_setting(config);
if (ret == SET_CONFIG_UPDATED)
umdbus_send_config_signal(MODE_SETTING_ENTRY, MODE_HIDE_KEY, config);
if (SET_CONFIG_OK(ret))
{
if((reply = dbus_message_new_method_return(msg)))
......@@ -430,8 +426,6 @@ static DBusHandlerResult umdbus_msg_handler(DBusConnection *const connection, DB
{
/* error checking is done when setting configuration */
int ret = config_set_unhide_mode_setting(config);
if (ret == SET_CONFIG_UPDATED)
umdbus_send_config_signal(MODE_SETTING_ENTRY, MODE_HIDE_KEY, config);
if (SET_CONFIG_OK(ret))
{
if((reply = dbus_message_new_method_return(msg)))
......@@ -462,8 +456,6 @@ static DBusHandlerResult umdbus_msg_handler(DBusConnection *const connection, DB
{
/* error checking is done when setting configuration */
int ret = config_set_network_setting(config, setting);
if (ret == SET_CONFIG_UPDATED)
umdbus_send_config_signal(NETWORK_ENTRY, config, setting);
if (SET_CONFIG_OK(ret))
{
if((reply = dbus_message_new_method_return(msg)))
......@@ -549,8 +541,6 @@ static DBusHandlerResult umdbus_msg_handler(DBusConnection *const connection, DB
else
{
int ret = config_set_mode_whitelist(whitelist);
if (ret == SET_CONFIG_UPDATED)
umdbus_send_config_signal(MODE_SETTING_ENTRY, MODE_WHITELIST_KEY, whitelist);
if (SET_CONFIG_OK(ret))
{
if ((reply = dbus_message_new_method_return(msg)))
......@@ -572,14 +562,6 @@ static DBusHandlerResult umdbus_msg_handler(DBusConnection *const connection, DB
else
{
int ret = config_set_mode_in_whitelist(mode, enabled);
if (ret == SET_CONFIG_UPDATED)
{
char *whitelist = config_get_mode_whitelist();
if (!whitelist)
whitelist = g_strdup(MODE_UNDEFINED);
umdbus_send_config_signal(MODE_SETTING_ENTRY, MODE_WHITELIST_KEY, whitelist);
g_free(whitelist);
}
if (SET_CONFIG_OK(ret))
reply = dbus_message_new_method_return(msg);
else
......
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