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;
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);
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)
DBG("network %p", network);
- if (connman_network_get_index(network) >= 0)
- return -EISCONN;
-
device = connman_network_get_device(network);
if (device == NULL)
return -ENODEV;
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)
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)
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)
{