From: Marcel Holtmann Date: Wed, 24 Dec 2008 11:20:06 +0000 (+0100) Subject: Add support for scanning property of devices X-Git-Tag: 0.6~155 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=27da31329144c6a2473db49798d96f53f25a5fc5;p=platform%2Fupstream%2Fconnman.git Add support for scanning property of devices --- diff --git a/include/device.h b/include/device.h index 4985f6e..4836395 100644 --- a/include/device.h +++ b/include/device.h @@ -68,6 +68,7 @@ struct connman_device { enum connman_device_policy policy; enum connman_device_state state; gboolean powered; + gboolean scanning; struct connman_device_driver *driver; void *driver_data; @@ -77,6 +78,8 @@ struct connman_device { extern int connman_device_set_powered(struct connman_device *device, gboolean powered); +extern int connman_device_set_scanning(struct connman_device *device, + gboolean scanning); static inline void *connman_device_get_data(struct connman_device *device) { diff --git a/src/device.c b/src/device.c index 23fd1b1..2c07a17 100644 --- a/src/device.c +++ b/src/device.c @@ -76,6 +76,10 @@ static DBusMessage *get_properties(DBusConnection *conn, connman_dbus_dict_append_variant(&dict, "Powered", DBUS_TYPE_BOOLEAN, &device->powered); + if (device->driver && device->driver->scan) + connman_dbus_dict_append_variant(&dict, "Scanning", + DBUS_TYPE_BOOLEAN, &device->scanning); + dbus_message_iter_close_container(&array, &dict); return reply; @@ -271,6 +275,51 @@ int connman_device_set_powered(struct connman_device *device, return 0; } +/** + * connman_device_set_scanning: + * @device: device structure + * + * Change scanning state of device + */ +int connman_device_set_scanning(struct connman_device *device, + gboolean scanning) +{ + DBusMessage *signal; + DBusMessageIter entry, value; + const char *key = "Scanning"; + + DBG("driver %p scanning %d", device, scanning); + + if (!device->driver) + return -EINVAL; + + if (!device->driver->scan) + return -EINVAL; + + if (device->scanning == scanning) + return -EALREADY; + + device->scanning = scanning; + + signal = dbus_message_new_signal(device->element->path, + CONNMAN_DEVICE_INTERFACE, "PropertyChanged"); + if (signal == NULL) + return 0; + + dbus_message_iter_init_append(signal, &entry); + + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); + + dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, + DBUS_TYPE_BOOLEAN_AS_STRING, &value); + dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN, &scanning); + dbus_message_iter_close_container(&entry, &value); + + g_dbus_send_message(connection, signal); + + return 0; +} + static gboolean match_driver(struct connman_device *device, struct connman_device_driver *driver) {