technology: Add 'Connected' Technology property
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 20 Jan 2012 14:30:38 +0000 (16:30 +0200)
committerDaniel Wagner <daniel.wagner@bmw-carit.de>
Tue, 24 Jan 2012 10:49:16 +0000 (11:49 +0100)
Set Technology property 'Connected' to true if at least one service
for the Technology is connected; false otherwise.

src/connman.h
src/notifier.c
src/technology.c

index 158f51f..8e725f4 100644 (file)
@@ -378,6 +378,8 @@ int __connman_technology_enabled(enum connman_service_type type);
 int __connman_technology_disabled(enum connman_service_type type);
 int __connman_technology_set_offlinemode(connman_bool_t offlinemode);
 connman_bool_t __connman_technology_get_offlinemode(void);
+void __connman_technology_set_connected(enum connman_service_type type,
+                                       connman_bool_t connected);
 
 int __connman_technology_add_rfkill(unsigned int index,
                                        enum connman_service_type type,
index cb6af85..91b52ea 100644 (file)
@@ -123,6 +123,7 @@ static void technology_connected(enum connman_service_type type,
 {
        DBG("type %d connected %d", type, connected);
 
+       __connman_technology_set_connected(type, connected);
        state_changed(connected);
 }
 
index 1f3cdf5..3cf9332 100644 (file)
@@ -59,6 +59,7 @@ struct connman_technology {
        GSList *device_list;
        int enabled;
        char *regdom;
+       connman_bool_t connected;
 
        connman_bool_t tethering;
        char *tethering_ident;
@@ -421,6 +422,10 @@ static void append_properties(DBusMessageIter *iter,
        connman_dbus_dict_append_basic(&dict, "Powered",
                                        DBUS_TYPE_BOOLEAN, &powered);
 
+       connman_dbus_dict_append_basic(&dict, "Connected",
+                                       DBUS_TYPE_BOOLEAN,
+                                       &technology->connected);
+
        connman_dbus_dict_append_basic(&dict, "Tethering",
                                        DBUS_TYPE_BOOLEAN,
                                        &technology->tethering);
@@ -1085,6 +1090,24 @@ int __connman_technology_set_offlinemode(connman_bool_t offlinemode)
        return err;
 }
 
+void __connman_technology_set_connected(enum connman_service_type type,
+               connman_bool_t connected)
+{
+       struct connman_technology *technology;
+
+       technology = technology_find(type);
+       if (technology == NULL)
+               return;
+
+       DBG("technology %p connected %d", technology, connected);
+
+       technology->connected = connected;
+
+       connman_dbus_property_changed_basic(technology->path,
+                       CONNMAN_TECHNOLOGY_INTERFACE, "Connected",
+                       DBUS_TYPE_BOOLEAN, &connected);
+}
+
 int __connman_technology_add_rfkill(unsigned int index,
                                        enum connman_service_type type,
                                                connman_bool_t softblock,