- DBG("conn %p", conn);
-
- switch (device->mode) {
- case CONNMAN_DEVICE_MODE_UNKNOWN:
- case CONNMAN_DEVICE_MODE_TRANSPORT_IP:
- return __connman_error_not_supported(msg);
- case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
- case CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE:
- break;
- }
-
- if (!device->driver || !device->driver->scan)
- return __connman_error_not_supported(msg);
-
- if (device->powered == FALSE)
- return __connman_error_failed(msg, EINVAL);
-
- err = device->driver->scan(device);
- if (err < 0)
- return __connman_error_failed(msg, -err);
-
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-}
-
-static GDBusMethodTable device_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
- { "SetProperty", "sv", "", set_property,
- G_DBUS_METHOD_FLAG_ASYNC },
- { "JoinNetwork", "a{sv}", "", join_network },
- { "CreateNetwork", "a{sv}", "o", create_network },
- { "RemoveNetwork", "o", "", remove_network },
- { "ProposeScan", "", "", propose_scan },
- { },
-};
-
-static GDBusSignalTable device_signals[] = {
- { "PropertyChanged", "sv" },
- { },
-};
-
-static void append_devices(DBusMessageIter *entry)
-{
- DBusMessageIter value, iter;
- const char *key = "Devices";
-
- dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &key);
-
- dbus_message_iter_open_container(entry, DBUS_TYPE_VARIANT,
- DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING,
- &value);
-
- dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter);
- __connman_element_list(NULL, CONNMAN_ELEMENT_TYPE_DEVICE, &iter);
- dbus_message_iter_close_container(&value, &iter);
-
- dbus_message_iter_close_container(entry, &value);
-}
-
-static void emit_devices_signal(void)
-{
- DBusMessage *signal;
- DBusMessageIter entry;
-
- signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH,
- CONNMAN_MANAGER_INTERFACE, "PropertyChanged");
- if (signal == NULL)
- return;
-
- dbus_message_iter_init_append(signal, &entry);
-
- append_devices(&entry);
-
- g_dbus_send_message(connection, signal);
-}
-
-static int register_interface(struct connman_element *element)
-{
- struct connman_device *device = element->device;
-
- DBG("element %p name %s", element, element->name);
-
- if (g_dbus_register_interface(connection, element->path,
- CONNMAN_DEVICE_INTERFACE,
- device_methods, device_signals,
- NULL, device, NULL) == FALSE) {
- connman_error("Failed to register %s device", element->path);
- return -EIO;
- }
-
- device->registered = TRUE;
-
- emit_devices_signal();
-
- return 0;
-}
-
-static void unregister_interface(struct connman_element *element)
-{
- struct connman_device *device = element->device;
-
- DBG("element %p name %s", element, element->name);
-
- device->registered = FALSE;
-
- emit_devices_signal();
-
- g_dbus_unregister_interface(connection, element->path,
- CONNMAN_DEVICE_INTERFACE);
-}
-
-static void device_enable(struct connman_device *device)
-{