Add Type property to generic device driver
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 24 Dec 2008 12:34:45 +0000 (13:34 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 24 Dec 2008 12:34:45 +0000 (13:34 +0100)
include/device.h
src/device.c

index 48363957a4aa1184c92693bcafd81a6e2e86d5a5..ba7fe1e01793f6a1f9f6666bbeb9f44d41639360 100644 (file)
@@ -42,6 +42,7 @@ enum connman_device_type {
        CONNMAN_DEVICE_TYPE_WIMAX     = CONNMAN_ELEMENT_SUBTYPE_WIMAX,
        CONNMAN_DEVICE_TYPE_MODEM     = CONNMAN_ELEMENT_SUBTYPE_MODEM,
        CONNMAN_DEVICE_TYPE_BLUETOOTH = CONNMAN_ELEMENT_SUBTYPE_BLUETOOTH,
+       CONNMAN_DEVICE_TYPE_VENDOR    = 42,
 };
 
 enum connman_device_capabilities {
@@ -64,6 +65,7 @@ struct connman_device_driver;
 
 struct connman_device {
        struct connman_element *element;
+       enum connman_device_type type;
        unsigned long capabilities;
        enum connman_device_policy policy;
        enum connman_device_state state;
index 2c07a17207ccdf11132d437bd8c455764174cbe2..de6861835781ae14017424475fa0648e424bee6e 100644 (file)
 
 #include "connman.h"
 
+static const char *type2string(enum connman_device_type type)
+{
+       switch (type) {
+       case CONNMAN_DEVICE_TYPE_ETHERNET:
+               return "ethernet";
+       case CONNMAN_DEVICE_TYPE_WIFI:
+               return "wifi";
+       case CONNMAN_DEVICE_TYPE_WIMAX:
+               return "wimax";
+       case CONNMAN_DEVICE_TYPE_MODEM:
+               return "modem";
+       case CONNMAN_DEVICE_TYPE_BLUETOOTH:
+               return "bluetooth";
+       default:
+               return NULL;
+       }
+}
+
 static int set_powered(struct connman_device *device, gboolean powered)
 {
        struct connman_device_driver *driver = device->driver;
@@ -59,6 +77,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
        struct connman_device *device = data;
        DBusMessage *reply;
        DBusMessageIter array, dict;
+       const char *str;
 
        DBG("conn %p", conn);
 
@@ -73,6 +92,11 @@ static DBusMessage *get_properties(DBusConnection *conn,
                        DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
                        DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
 
+       str = type2string(device->type);
+       if (str != NULL)
+               connman_dbus_dict_append_variant(&dict, "Type",
+                                               DBUS_TYPE_STRING, &str);
+
        connman_dbus_dict_append_variant(&dict, "Powered",
                                        DBUS_TYPE_BOOLEAN, &device->powered);
 
@@ -346,6 +370,7 @@ static int device_probe(struct connman_element *element)
                return -ENOMEM;
 
        device->element = element;
+       device->type = element->subtype;
 
        connman_element_set_data(element, device);