From 838e712a151514f228eac2901aed8c452e45c019 Mon Sep 17 00:00:00 2001 From: Henri Bragge Date: Wed, 2 Mar 2011 16:43:35 +0100 Subject: [PATCH] ofono: Connect when context activation is requested ConnMan should connect the corresponding network/service after a successful response to context activation request. If the context was already active, connecting has to happen this way instead of waiting for active property going up (it already is up). In case the context was inactive before activation, it will not have network index yet and connecting will happen later when activation is ready. This patch removes the reply handler for context inactivation because it would have no other use than logging. --- plugins/ofono.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/plugins/ofono.c b/plugins/ofono.c index 02c6d9e..51997c8 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -408,6 +408,9 @@ static gboolean pending_network_is_available(struct connman_network *network) return TRUE; } +static void set_connected(struct network_info *info, + connman_bool_t connected); + static void set_active_reply(DBusPendingCall *call, void *user_data) { char const *path = user_data; @@ -435,7 +438,8 @@ static void set_active_reply(DBusPendingCall *call, void *user_data) CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL); dbus_error_free(&error); - } + } else if (connman_network_get_index(info->network) >= 0) + set_connected(info, TRUE); done: dbus_message_unref(reply); @@ -443,23 +447,34 @@ done: dbus_pending_call_unref(call); } -static int set_network_active(struct connman_network *network, - dbus_bool_t active) +static int set_network_active(struct connman_network *network) { - int error; - + dbus_bool_t value = TRUE; const char *path = connman_network_get_string(network, "Path"); - DBG("network %p, path %s, active %d", network, path, active); + DBG("network %p, path %s", network, path); - error = set_property(path, OFONO_CONTEXT_INTERFACE, - "Active", DBUS_TYPE_BOOLEAN, &active, + return set_property(path, OFONO_CONTEXT_INTERFACE, + "Active", DBUS_TYPE_BOOLEAN, &value, set_active_reply, g_strdup(path), g_free); +} + +static int set_network_inactive(struct connman_network *network) +{ + int err; + dbus_bool_t value = FALSE; + const char *path = connman_network_get_string(network, "Path"); + + DBG("network %p, path %s", network, path); - if (active == FALSE && error == -EINPROGRESS) - error = 0; + err = set_property(path, OFONO_CONTEXT_INTERFACE, + "Active", DBUS_TYPE_BOOLEAN, &value, + NULL, NULL, NULL); - return error; + if (err == -EINPROGRESS) + err = 0; + + return err; } static int network_connect(struct connman_network *network) @@ -469,9 +484,6 @@ static int network_connect(struct connman_network *network) DBG("network %p", network); - if (connman_network_get_index(network) >= 0) - return -EISCONN; - device = connman_network_get_device(network); if (device == NULL) return -ENODEV; @@ -489,7 +501,7 @@ static int network_connect(struct connman_network *network) if (modem->roaming_allowed == FALSE && modem->roaming == TRUE) return -ENOLINK; - return set_network_active(network, TRUE); + return set_network_active(network); } static int network_disconnect(struct connman_network *network) @@ -501,7 +513,7 @@ static int network_disconnect(struct connman_network *network) connman_network_set_associating(network, FALSE); - return set_network_active(network, FALSE); + return set_network_inactive(network); } static void network_remove(struct connman_network *network) @@ -525,9 +537,6 @@ static struct connman_network_driver network_driver = { static void update_settings(DBusMessageIter *array, struct network_info *info); -static void set_connected(struct network_info *info, - connman_bool_t connected); - static int add_network(struct connman_device *device, const char *path, DBusMessageIter *dict) { -- 2.7.4