Add Device and Network property to connection interface
authorMarcel Holtmann <marcel@holtmann.org>
Sat, 10 Jan 2009 01:36:34 +0000 (02:36 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 10 Jan 2009 01:36:34 +0000 (02:36 +0100)
doc/connection-api.txt
src/connection.c
src/connman.h
src/element.c

index a0c97da..8e2e8bc 100644 (file)
@@ -39,6 +39,18 @@ Properties   string Type [readonly]
                        Indicates if it is a default connection. It is
                        possible to have multiple default connections.
 
+               object Device [readonly]
+
+                       The object path of the device this connection has
+                       been established with.
+
+               object Network [readonly]
+
+                       The object path of the network this connection
+                       belongs to.
+
+                       This property is optional and not always present.
+
                string IPv4.Method [readonly]
 
                        Indicates the way how the IPv4 settings were
index ad38147..980b770 100644 (file)
@@ -206,6 +206,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
        DBusMessage *reply;
        DBusMessageIter array, dict;
        connman_uint8_t strength = 0;
+       const char *device, *network;
        const char *type = NULL, *method = NULL;
        const char *address = NULL, *netmask = NULL, *gateway = NULL;
 
@@ -244,6 +245,16 @@ static DBusMessage *get_properties(DBusConnection *conn,
        connman_dbus_dict_append_variant(&dict, "Default",
                                        DBUS_TYPE_BOOLEAN, &element->enabled);
 
+       device = __connman_element_get_device(element);
+       if (device != NULL)
+               connman_dbus_dict_append_variant(&dict, "Device",
+                                       DBUS_TYPE_OBJECT_PATH, &device);
+
+       network = __connman_element_get_network(element);
+       if (network != NULL)
+               connman_dbus_dict_append_variant(&dict, "Network",
+                                       DBUS_TYPE_OBJECT_PATH, &network);
+
        connman_element_get_value(element,
                                CONNMAN_PROPERTY_ID_IPV4_METHOD, &method);
 
index cca7ea8..545183e 100644 (file)
@@ -117,6 +117,9 @@ void __connman_element_list(struct connman_element *element,
 int __connman_element_count(struct connman_element *element,
                                        enum connman_element_type type);
 
+const char *__connman_element_get_device(struct connman_element *element);
+const char *__connman_element_get_network(struct connman_element *element);
+
 const char *__connman_element_type2string(enum connman_element_type type);
 
 static inline void __connman_element_lock(struct connman_element *element)
index fb11f79..2baeb1a 100644 (file)
@@ -427,6 +427,30 @@ int __connman_element_count(struct connman_element *element,
        return data.count;
 }
 
+const char *__connman_element_get_device(struct connman_element *element)
+{
+       if (element->type == CONNMAN_ELEMENT_TYPE_DEVICE &&
+                                               element->device != NULL)
+               return element->path;
+
+       if (element->parent == NULL)
+               return NULL;
+
+       return __connman_element_get_device(element->parent);
+}
+
+const char *__connman_element_get_network(struct connman_element *element)
+{
+       if (element->type == CONNMAN_ELEMENT_TYPE_NETWORK &&
+                                               element->network != NULL)
+               return element->path;
+
+       if (element->parent == NULL)
+               return NULL;
+
+       return __connman_element_get_network(element->parent);
+}
+
 static gint compare_priority(gconstpointer a, gconstpointer b)
 {
        const struct connman_driver *driver1 = a;