Add support for connection type property
authorMarcel Holtmann <marcel@holtmann.org>
Mon, 5 Jan 2009 22:45:55 +0000 (23:45 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 5 Jan 2009 22:45:55 +0000 (23:45 +0100)
src/connection.c
src/device.c
src/element.c
src/network.c

index 01a84cc..7344cd4 100644 (file)
@@ -205,7 +205,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
        struct connman_element *element = data;
        DBusMessage *reply;
        DBusMessageIter array, dict;
-       const char *method = NULL;
+       const char *type = NULL, *method = NULL;
        const char *address = NULL, *netmask = NULL, *gateway = NULL;
 
        DBG("conn %p", conn);
@@ -221,6 +221,12 @@ static DBusMessage *get_properties(DBusConnection *conn,
                        DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
                        DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
 
+       connman_element_get_static_property(element, "Type", &type);
+
+       if (type != NULL)
+               connman_dbus_dict_append_variant(&dict, "Type",
+                                               DBUS_TYPE_STRING, &type);
+
        if (element->devname != NULL)
                connman_dbus_dict_append_variant(&dict, "Interface",
                                        DBUS_TYPE_STRING, &element->devname);
index c1aa004..f6bad3b 100644 (file)
@@ -682,6 +682,7 @@ struct connman_device *connman_device_create(const char *node,
                                                enum connman_device_type type)
 {
        struct connman_device *device;
+       const char *str;
 
        DBG("node %s type %d", node, type);
 
@@ -700,6 +701,11 @@ struct connman_device *connman_device_create(const char *node,
        device->element.device = device;
        device->element.destruct = device_destruct;
 
+       str = type2string(type);
+       if (str != NULL)
+               connman_element_add_static_property(&device->element,
+                                       "Type", DBUS_TYPE_STRING, &str);
+
        device->type   = type;
        device->mode   = CONNMAN_DEVICE_MODE_UNKNOWN;
        device->policy = CONNMAN_DEVICE_POLICY_AUTO;
index fef78be..03bb5f5 100644 (file)
@@ -1040,6 +1040,10 @@ gboolean connman_element_get_static_property(struct connman_element *element,
 
        __connman_element_unlock(element);
 
+       if (found == FALSE && element->parent != NULL)
+               return connman_element_get_static_property(element->parent,
+                                                               name, value);
+
        return found;
 }
 
index 9ed6dc4..1bfc46d 100644 (file)
@@ -56,6 +56,24 @@ struct connman_network {
        } wifi;
 };
 
+static const char *type2string(enum connman_network_type type)
+{
+       switch (type) {
+       case CONNMAN_NETWORK_TYPE_UNKNOWN:
+       case CONNMAN_NETWORK_TYPE_VENDOR:
+               break;
+       case CONNMAN_NETWORK_TYPE_WIFI:
+               return "wifi";
+       case CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN:
+       case CONNMAN_NETWORK_TYPE_BLUETOOTH_DUN:
+               return "bluetooth";
+       case CONNMAN_NETWORK_TYPE_HSO:
+               return "cellular";
+       }
+
+       return NULL;
+}
+
 static DBusMessage *get_properties(DBusConnection *conn,
                                        DBusMessage *msg, void *data)
 {
@@ -334,6 +352,7 @@ struct connman_network *connman_network_create(const char *identifier,
                                                enum connman_network_type type)
 {
        struct connman_network *network;
+       const char *str;
 
        DBG("identifier %s type %d", identifier, type);
 
@@ -352,6 +371,11 @@ struct connman_network *connman_network_create(const char *identifier,
        network->element.network = network;
        network->element.destruct = network_destruct;
 
+       str = type2string(type);
+       if (str != NULL)
+               connman_element_add_static_property(&network->element,
+                                       "Type", DBUS_TYPE_STRING, &str);
+
        network->type = type;
        network->identifier = g_strdup(identifier);