Hook up device type and offline mode notifications
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 11 Mar 2009 20:26:41 +0000 (21:26 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 11 Mar 2009 20:26:41 +0000 (21:26 +0100)
src/connman.h
src/device.c
src/notifier.c

index e9d72ae..128c084 100644 (file)
@@ -204,6 +204,10 @@ int __connman_profile_remove_network(struct connman_network *network);
 int __connman_notifier_init(void);
 void __connman_notifier_cleanup(void);
 
+void __connman_notifier_device_type_increase(enum connman_device_type type);
+void __connman_notifier_device_type_decrease(enum connman_device_type type);
+void __connman_notifier_offline_mode(connman_bool_t enabled);
+
 #include <connman/rtnl.h>
 
 int __connman_rtnl_init(void);
index a07726a..3094038 100644 (file)
@@ -169,16 +169,18 @@ static int set_powered(struct connman_device *device, connman_bool_t powered)
                return -EINVAL;
 
        if (powered == TRUE) {
-               if (driver->enable)
+               if (driver->enable) {
                        err = driver->enable(device);
-               else
+                       __connman_notifier_device_type_increase(device->type);
+               } else
                        err = -EINVAL;
        } else {
                g_hash_table_remove_all(device->networks);
 
-               if (driver->disable)
+               if (driver->disable) {
                        err = driver->disable(device);
-               else
+                       __connman_notifier_device_type_decrease(device->type);
+               } else
                        err = -EINVAL;
        }
 
@@ -615,8 +617,10 @@ static void device_enable(struct connman_device *device)
        if (device->powered == TRUE)
                return;
 
-       if (device->driver->enable)
+       if (device->driver->enable) {
                device->driver->enable(device);
+               __connman_notifier_device_type_increase(device->type);
+       }
 }
 
 static void device_disable(struct connman_device *device)
@@ -631,8 +635,10 @@ static void device_disable(struct connman_device *device)
 
        g_hash_table_remove_all(device->networks);
 
-       if (device->driver->disable)
+       if (device->driver->disable) {
                device->driver->disable(device);
+               __connman_notifier_device_type_decrease(device->type);
+       }
 }
 
 static int setup_device(struct connman_device *device)
@@ -1429,6 +1435,8 @@ int __connman_device_set_offlinemode(connman_bool_t offlinemode)
        __connman_element_foreach(NULL, CONNMAN_ELEMENT_TYPE_DEVICE,
                        set_offlinemode, GUINT_TO_POINTER(offlinemode));
 
+       __connman_notifier_offline_mode(offlinemode);
+
        return 0;
 }
 
index e2dcff8..c23a570 100644 (file)
@@ -66,6 +66,21 @@ void connman_notifier_unregister(struct connman_notifier *notifier)
        notifier_list = g_slist_remove(notifier_list, notifier);
 }
 
+void __connman_notifier_device_type_increase(enum connman_device_type type)
+{
+       DBG("type %d", type);
+}
+
+void __connman_notifier_device_type_decrease(enum connman_device_type type)
+{
+       DBG("type %d", type);
+}
+
+void __connman_notifier_offline_mode(connman_bool_t enabled)
+{
+       DBG("enabled %d", enabled);
+}
+
 int __connman_notifier_init(void)
 {
        DBG("");