struct _GSupplicantInterface {
char *path;
+ char *network_path;
unsigned int keymgmt_capa;
unsigned int authalg_capa;
unsigned int proto_capa;
}
supplicant_dbus_property_get_all(path,
- SUPPLICANT_INTERFACE ".Interface.Network",
+ SUPPLICANT_INTERFACE ".Network",
network_property, network);
}
}
supplicant_dbus_property_get_all(path,
- SUPPLICANT_INTERFACE ".Interface.BSS",
+ SUPPLICANT_INTERFACE ".BSS",
bss_property, bss);
}
{ SUPPLICANT_INTERFACE ".Interface", "NetworkAdded", signal_network_added },
{ SUPPLICANT_INTERFACE ".Interface", "NetworkRemoved", signal_network_removed },
- { SUPPLICANT_INTERFACE ".Interface.BSS", "PropertiesChanged", signal_bss_changed },
+ { SUPPLICANT_INTERFACE ".BSS", "PropertiesChanged", signal_bss_changed },
{ }
};
if (interface->scanning == TRUE)
return -EALREADY;
+ switch (interface->state) {
+ case G_SUPPLICANT_STATE_AUTHENTICATING:
+ case G_SUPPLICANT_STATE_ASSOCIATING:
+ case G_SUPPLICANT_STATE_ASSOCIATED:
+ case G_SUPPLICANT_STATE_4WAY_HANDSHAKE:
+ case G_SUPPLICANT_STATE_GROUP_HANDSHAKE:
+ return -EBUSY;
+ case G_SUPPLICANT_STATE_UNKNOWN:
+ case G_SUPPLICANT_STATE_DISCONNECTED:
+ case G_SUPPLICANT_STATE_INACTIVE:
+ case G_SUPPLICANT_STATE_SCANNING:
+ case G_SUPPLICANT_STATE_COMPLETED:
+ break;
+ }
+
data = dbus_malloc0(sizeof(*data));
if (data == NULL)
return -ENOMEM;
static void interface_select_network_result(const char *error,
DBusMessageIter *iter, void *user_data)
{
+ struct interface_connect_data *data = user_data;
+
SUPPLICANT_DBG("");
+
+ dbus_free(data);
}
static void interface_select_network_params(DBusMessageIter *iter,
void *user_data)
{
- char *path = user_data;
+ struct interface_connect_data *data = user_data;
+ GSupplicantInterface *interface = data->interface;
- dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH,
+ &interface->network_path);
}
static void interface_add_network_result(const char *error,
DBusMessageIter *iter, void *user_data)
{
struct interface_connect_data *data = user_data;
- char *path = NULL;
+ GSupplicantInterface *interface = data->interface;
+ const char *path;
if (error != NULL)
- goto done;
+ goto error;
dbus_message_iter_get_basic(iter, &path);
if (path == NULL)
- goto done;
+ goto error;
SUPPLICANT_DBG("PATH: %s", path);
+ g_free(interface->network_path);
+ interface->network_path = g_strdup(path);
+
supplicant_dbus_method_call(data->interface->path,
SUPPLICANT_INTERFACE ".Interface", "SelectNetwork",
interface_select_network_params,
- interface_select_network_result, path);
+ interface_select_network_result, data);
-done:
- dbus_free(data);
+ return;
+
+error:
+ g_free(interface->network_path);
+ interface->network_path = NULL;
+ g_free(data);
}
static void add_network_security_wep(DBusMessageIter *dict,
static void add_network_security_eap(DBusMessageIter *dict,
GSupplicantSSID *ssid)
{
+ char *eap_value;
+
if (ssid->eap == NULL || ssid->identity == NULL)
return;
} else
return;
+ eap_value = g_ascii_strup(ssid->eap, -1);
+
supplicant_dbus_dict_append_basic(dict, "eap",
DBUS_TYPE_STRING,
- &ssid->eap);
+ &eap_value);
supplicant_dbus_dict_append_basic(dict, "identity",
DBUS_TYPE_STRING,
&ssid->identity);
+
+ g_free(eap_value);
}
static void add_network_security(DBusMessageIter *dict, GSupplicantSSID *ssid)
return -EINPROGRESS;
}
-static void interface_disconnect_result(const char *error,
+static void network_remove_result(const char *error,
DBusMessageIter *iter, void *user_data)
{
struct interface_data *data = user_data;
dbus_free(data);
}
+static void network_remove_params(DBusMessageIter *iter, void *user_data)
+{
+ struct interface_data *data = user_data;
+ const char *path = data->interface->network_path;
+
+ SUPPLICANT_DBG("path %s", path);
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path);
+}
+
+static int network_remove(struct interface_data *data)
+{
+ GSupplicantInterface *interface = data->interface;
+
+ SUPPLICANT_DBG("");
+
+ return supplicant_dbus_method_call(interface->path,
+ SUPPLICANT_INTERFACE ".Interface", "RemoveNetwork",
+ network_remove_params, network_remove_result, data);
+}
+
+static void interface_disconnect_result(const char *error,
+ DBusMessageIter *iter, void *user_data)
+{
+ struct interface_data *data = user_data;
+
+ SUPPLICANT_DBG("");
+
+ if (error != NULL && data->callback != NULL) {
+ data->callback(-EIO, data->interface, data->user_data);
+ return;
+ }
+
+ network_remove(data);
+}
+
int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
GSupplicantInterfaceCallback callback,
void *user_data)
static const char *g_supplicant_rule3 = "type=signal,"
"interface=" SUPPLICANT_INTERFACE ".Interface.WPS";
static const char *g_supplicant_rule4 = "type=signal,"
- "interface=" SUPPLICANT_INTERFACE ".Interface.BSS";
+ "interface=" SUPPLICANT_INTERFACE ".BSS";
static const char *g_supplicant_rule5 = "type=signal,"
- "interface=" SUPPLICANT_INTERFACE ".Interface.Network";
-static const char *g_supplicant_rule6 = "type=signal,"
- "interface=" SUPPLICANT_INTERFACE ".Interface.Blob";
+ "interface=" SUPPLICANT_INTERFACE ".Network";
+
+static void invoke_introspect_method(void)
+{
+ DBusMessage *message;
+
+ message = dbus_message_new_method_call(SUPPLICANT_SERVICE,
+ SUPPLICANT_PATH,
+ DBUS_INTERFACE_INTROSPECTABLE,
+ "Introspect");
+
+ if (message == NULL)
+ return;
+
+ dbus_message_set_no_reply(message, TRUE);
+ dbus_connection_send(connection, message, NULL);
+ dbus_message_unref(message);
+}
int g_supplicant_register(const GSupplicantCallbacks *callbacks)
{
dbus_bus_add_match(connection, g_supplicant_rule3, NULL);
dbus_bus_add_match(connection, g_supplicant_rule4, NULL);
dbus_bus_add_match(connection, g_supplicant_rule5, NULL);
- dbus_bus_add_match(connection, g_supplicant_rule6, NULL);
dbus_connection_flush(connection);
if (dbus_bus_name_has_owner(connection,
supplicant_dbus_property_get_all(SUPPLICANT_PATH,
SUPPLICANT_INTERFACE,
service_property, NULL);
- }
+ } else
+ invoke_introspect_method();
return 0;
}
SUPPLICANT_DBG("");
if (connection != NULL) {
- dbus_bus_remove_match(connection, g_supplicant_rule6, NULL);
dbus_bus_remove_match(connection, g_supplicant_rule5, NULL);
dbus_bus_remove_match(connection, g_supplicant_rule4, NULL);
dbus_bus_remove_match(connection, g_supplicant_rule3, NULL);