From 7c4dac19371496e8f7cf8cd1ea0ba93709dca239 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 12 Dec 2011 18:57:19 +0100 Subject: [PATCH] ofono: Move cm powered update into a function --- plugins/ofono.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/plugins/ofono.c b/plugins/ofono.c index 378e49d..fa0f808 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -1386,6 +1386,20 @@ static void cm_update_attached(struct modem_data *modem, netreg_get_properties(modem); } +static void cm_update_powered(struct modem_data *modem, + DBusMessageIter *value) +{ + dbus_message_iter_get_basic(value, &modem->cm_powered); + + DBG("%s ConnnectionManager Powered %d", modem->path, + modem->cm_powered); + + if (modem->cm_powered == TRUE) + return; + + cm_set_powered(modem); +} + static gboolean cm_changed(DBusConnection *connection, DBusMessage *message, void *user_data) { @@ -1412,13 +1426,7 @@ static gboolean cm_changed(DBusConnection *connection, DBusMessage *message, if (g_str_equal(key, "Attached") == TRUE) { cm_update_attached(modem, &value); } else if (g_str_equal(key, "Powered") == TRUE) { - dbus_message_iter_get_basic(&value, &modem->cm_powered); - - DBG("%s ConnnectionManager Powered %d", modem->path, - modem->cm_powered); - - if (modem->cm_powered == FALSE) - cm_set_powered(modem); + cm_update_powered(modem, &value); } return TRUE; @@ -1441,13 +1449,7 @@ static void cm_properties_reply(struct modem_data *modem, DBusMessageIter *dict) if (g_str_equal(key, "Attached") == TRUE) { cm_update_attached(modem, &value); } else if (g_str_equal(key, "Powered") == TRUE) { - dbus_message_iter_get_basic(&value, &modem->cm_powered); - - DBG("%s ConnnectionManager Powered %d", modem->path, - modem->cm_powered); - - if (modem->cm_powered == FALSE) - cm_set_powered(modem); + cm_update_powered(modem, &value); } dbus_message_iter_next(dict); -- 2.7.4