From 8200c91aa4224800421ceedf66d29d454b4a89d7 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 12 Dec 2011 18:32:53 +0100 Subject: [PATCH] ofono: Move netreg strength update into a function --- plugins/ofono.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/plugins/ofono.c b/plugins/ofono.c index 4909e03..f8f3b24 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -1240,6 +1240,20 @@ static void netreg_update_name(struct modem_data *modem, connman_network_update(modem->network); } +static void netreg_update_strength(struct modem_data *modem, + DBusMessageIter *value) +{ + dbus_message_iter_get_basic(value, &modem->strength); + + DBG("%s Strength %d", modem->path, modem->strength); + + if (modem->network == NULL) + return; + + connman_network_set_strength(modem->network, modem->strength); + connman_network_update(modem->network); +} + static gboolean netreg_changed(DBusConnection *connection, DBusMessage *message, void *user_data) { @@ -1266,15 +1280,7 @@ static gboolean netreg_changed(DBusConnection *connection, DBusMessage *message, if (g_str_equal(key, "Name") == TRUE) { netreg_update_name(modem, &value); } else if (g_str_equal(key, "Strength") == TRUE) { - dbus_message_iter_get_basic(&value, &modem->strength); - - DBG("%s Strength %d", modem->path, modem->strength); - - if (modem->network == NULL) - return TRUE; - - connman_network_set_strength(modem->network, modem->strength); - connman_network_update(modem->network); + netreg_update_strength(modem, &value); } return TRUE; @@ -1298,16 +1304,7 @@ static void netreg_properties_reply(struct modem_data *modem, if (g_str_equal(key, "Name") == TRUE) { netreg_update_name(modem, &value); } else if (g_str_equal(key, "Strength") == TRUE) { - dbus_message_iter_get_basic(&value, &modem->strength); - - DBG("%s Strength %d", modem->path, - modem->strength); - - if (modem->network != NULL) { - connman_network_set_strength(modem->network, - modem->strength); - connman_network_update(modem->network); - } + netreg_update_strength(modem, &value); } dbus_message_iter_next(dict); -- 2.7.4