Possible Errors: [service].Error.InvalidArguments
+ void RequestScan(string type)
+
+ Request to trigger a scan for the specified
+ technology. The empty string "" triggers scanning
+ on all technologies.
+
+ Possible Errors: [service].Error.InvalidArguments
+
void RegisterAgent(object path)
Register new agent for handling user requests.
const char *__connman_element_get_network_path(struct connman_element *element);
struct connman_device *__connman_element_find_device(enum connman_device_type type);
+int __connman_element_request_scan(enum connman_device_type type);
const char *__connman_element_type2string(enum connman_element_type type);
void __connman_device_set_network(struct connman_device *device,
struct connman_network *network);
+int __connman_device_scan(struct connman_device *device);
int __connman_device_connect(struct connman_device *device);
int __connman_device_disconnect(struct connman_device *device);
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);
+ err = __connman_device_scan(device);
if (err < 0)
return __connman_error_failed(msg, -err);
return set_carrier(device, device->carrier);
}
+int __connman_device_scan(struct connman_device *device)
+{
+ if (!device->driver || !device->driver->scan)
+ return -EOPNOTSUPP;
+
+ if (device->powered == FALSE)
+ return -ENOLINK;
+
+ return device->driver->scan(device);
+}
+
int __connman_device_connect(struct connman_device *device)
{
DBG("device %p", device);
return data.device;
}
+static gboolean request_scan(GNode *node, gpointer user_data)
+{
+ struct connman_element *element = node->data;
+ struct find_data *data = user_data;
+ enum connman_device_type type;
+
+ if (element->type != CONNMAN_ELEMENT_TYPE_DEVICE)
+ return FALSE;
+
+ if (element->device == NULL)
+ return FALSE;
+
+ type = connman_device_get_type(element->device);
+
+ switch (type) {
+ case CONNMAN_DEVICE_TYPE_UNKNOWN:
+ case CONNMAN_DEVICE_TYPE_VENDOR:
+ case CONNMAN_DEVICE_TYPE_ETHERNET:
+ case CONNMAN_DEVICE_TYPE_BLUETOOTH:
+ case CONNMAN_DEVICE_TYPE_GPS:
+ case CONNMAN_DEVICE_TYPE_MBM:
+ case CONNMAN_DEVICE_TYPE_HSO:
+ case CONNMAN_DEVICE_TYPE_NOZOMI:
+ case CONNMAN_DEVICE_TYPE_HUAWEI:
+ case CONNMAN_DEVICE_TYPE_NOVATEL:
+ return FALSE;
+ case CONNMAN_DEVICE_TYPE_WIFI:
+ case CONNMAN_DEVICE_TYPE_WIMAX:
+ if (data->type != CONNMAN_DEVICE_TYPE_UNKNOWN &&
+ data->type != type)
+ return FALSE;
+ break;
+ }
+
+ __connman_device_scan(element->device);
+
+ return FALSE;
+}
+
+int __connman_element_request_scan(enum connman_device_type type)
+{
+ struct find_data data = { .type = type, .device = NULL };
+
+ g_node_traverse(element_root, G_PRE_ORDER,
+ G_TRAVERSE_ALL, -1, request_scan, &data);
+
+ return 0;
+}
+
static gint compare_priority(gconstpointer a, gconstpointer b)
{
const struct connman_driver *driver1 = a;
return __connman_error_not_supported(msg);
}
+static DBusMessage *request_scan(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ enum connman_device_type type;
+ const char *str;
+ int err;
+
+ DBG("conn %p", conn);
+
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &str,
+ DBUS_TYPE_INVALID);
+
+ if (g_strcmp0(str, "") == 0)
+ type = CONNMAN_DEVICE_TYPE_UNKNOWN;
+ else if (g_strcmp0(str, "wifi") == 0)
+ type = CONNMAN_DEVICE_TYPE_WIFI;
+ else if (g_strcmp0(str, "wimax") == 0)
+ type = CONNMAN_DEVICE_TYPE_WIMAX;
+ else
+ return __connman_error_invalid_arguments(msg);
+
+ err = __connman_element_request_scan(type);
+ if (err < 0) {
+ if (err == -EINPROGRESS) {
+ connman_error("Invalid return code from scan");
+ err = -EINVAL;
+ }
+
+ return __connman_error_failed(msg, -err);
+ }
+
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
static DBusMessage *connect_service(DBusConnection *conn,
DBusMessage *msg, void *data)
{
err = __connman_service_create_and_connect(msg);
if (err < 0) {
if (err == -EINPROGRESS) {
- connman_error("Invalid return code from callbacks");
+ connman_error("Invalid return code from connect");
err = -EINVAL;
}
{ "SetProperty", "sv", "", set_property },
{ "AddProfile", "s", "o", add_profile },
{ "RemoveProfile", "o", "", remove_profile },
+ { "RequestScan", "s", "", request_scan },
{ "ConnectService", "a{sv}", "o", connect_service,
G_DBUS_METHOD_FLAG_ASYNC },
{ "RegisterAgent", "o", "", register_agent },