summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-05-26 17:34:10 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-05-26 21:03:15 -0500
commitadefe451a24e9156ba84b820853262004dbac074 (patch)
tree13af75a6f1abcc8f5ab83406b6c1039f0f1bc05b /src
parent7b778882172ce17c3091958364a311e4d779aab0 (diff)
downloadofono-adefe451a24e9156ba84b820853262004dbac074.tar.bz2
Refactor: Break up set_online_callback
- Break up into two functions, one for online and one for offline - No longer the need for online_pending variable
Diffstat (limited to 'src')
-rw-r--r--src/modem.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/modem.c b/src/modem.c
index d78415da..a2c5d4f8 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -69,7 +69,6 @@ struct ofono_modem {
ofono_bool_t powered_pending;
guint timeout;
ofono_bool_t online;
- ofono_bool_t online_pending;
GHashTable *properties;
struct ofono_sim *sim;
unsigned int sim_watch;
@@ -417,32 +416,35 @@ static void modem_change_state(struct ofono_modem *modem,
}
}
-static void set_online_callback(const struct ofono_error *error,
- void *data)
+static void online_cb(const struct ofono_error *error, void *data)
{
struct ofono_modem *modem = data;
- DBusMessage *reply = NULL;
- ofono_bool_t online = modem->online_pending;
+ DBusMessage *reply;
- if (error && error->type != OFONO_ERROR_TYPE_NO_ERROR) {
- reply = __ofono_error_failed(modem->pending);
- online = modem->online;
- } else if (online && modem->modem_state < MODEM_STATE_OFFLINE) {
- reply = __ofono_error_failed(modem->pending);
- online = FALSE;
- } else
+ if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
reply = dbus_message_new_method_return(modem->pending);
+ else
+ reply = __ofono_error_failed(modem->pending);
__ofono_dbus_pending_reply(&modem->pending, reply);
- modem->online_pending = online;
+ if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
+ modem_change_state(modem, MODEM_STATE_ONLINE);
+}
- if (modem->online == online)
- return;
+static void offline_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_modem *modem = data;
+ DBusMessage *reply;
- if (online)
- modem_change_state(modem, MODEM_STATE_ONLINE);
+ if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
+ reply = dbus_message_new_method_return(modem->pending);
else
+ reply = __ofono_error_failed(modem->pending);
+
+ __ofono_dbus_pending_reply(&modem->pending, reply);
+
+ if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
modem_change_state(modem, MODEM_STATE_OFFLINE);
}
@@ -468,9 +470,9 @@ static DBusMessage *set_property_online(struct ofono_modem *modem,
return __ofono_error_busy(msg);
modem->pending = dbus_message_ref(msg);
- modem->online_pending = online;
- driver->set_online(modem, online, set_online_callback, modem);
+ driver->set_online(modem, online,
+ online ? online_cb : offline_cb, modem);
return NULL;
}