diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-03-11 21:52:10 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-03-11 21:52:10 +0100 |
commit | 76ca29341f8c68a7345c0b09f7097debf759d585 (patch) | |
tree | fd954753a55e1c9309d93c94d6f73abdd5a1e2ac /src/notifier.c | |
parent | c23a88af4f9b3e55d7c76dcf0c25070d05ba8cf1 (diff) | |
download | connman-76ca29341f8c68a7345c0b09f7097debf759d585.tar.gz connman-76ca29341f8c68a7345c0b09f7097debf759d585.tar.bz2 connman-76ca29341f8c68a7345c0b09f7097debf759d585.zip |
Add implementation for notifier hooks
Diffstat (limited to 'src/notifier.c')
-rw-r--r-- | src/notifier.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/notifier.c b/src/notifier.c index c23a5702..9092b24d 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -66,19 +66,80 @@ void connman_notifier_unregister(struct connman_notifier *notifier) notifier_list = g_slist_remove(notifier_list, notifier); } +static void device_enabled(enum connman_device_type type, + connman_bool_t enabled) +{ + GSList *list; + + for (list = notifier_list; list; list = list->next) { + struct connman_notifier *notifier = list->data; + + if (notifier->device_enabled) + notifier->device_enabled(type, enabled); + } + +} + +static volatile gint enabled[10]; + void __connman_notifier_device_type_increase(enum connman_device_type type) { DBG("type %d", type); + + switch (type) { + case CONNMAN_DEVICE_TYPE_UNKNOWN: + case CONNMAN_DEVICE_TYPE_HSO: + case CONNMAN_DEVICE_TYPE_NOZOMI: + case CONNMAN_DEVICE_TYPE_HUAWEI: + case CONNMAN_DEVICE_TYPE_NOVATEL: + case CONNMAN_DEVICE_TYPE_VENDOR: + return; + case CONNMAN_DEVICE_TYPE_ETHERNET: + case CONNMAN_DEVICE_TYPE_WIFI: + case CONNMAN_DEVICE_TYPE_WIMAX: + case CONNMAN_DEVICE_TYPE_BLUETOOTH: + case CONNMAN_DEVICE_TYPE_GPS: + if (g_atomic_int_exchange_and_add(&enabled[type], 1) == 0) + device_enabled(type, TRUE); + break; + } } void __connman_notifier_device_type_decrease(enum connman_device_type type) { DBG("type %d", type); + + switch (type) { + case CONNMAN_DEVICE_TYPE_UNKNOWN: + case CONNMAN_DEVICE_TYPE_HSO: + case CONNMAN_DEVICE_TYPE_NOZOMI: + case CONNMAN_DEVICE_TYPE_HUAWEI: + case CONNMAN_DEVICE_TYPE_NOVATEL: + case CONNMAN_DEVICE_TYPE_VENDOR: + return; + case CONNMAN_DEVICE_TYPE_ETHERNET: + case CONNMAN_DEVICE_TYPE_WIFI: + case CONNMAN_DEVICE_TYPE_WIMAX: + case CONNMAN_DEVICE_TYPE_BLUETOOTH: + case CONNMAN_DEVICE_TYPE_GPS: + if (g_atomic_int_dec_and_test(&enabled[type]) == TRUE) + device_enabled(type, FALSE); + break; + } } void __connman_notifier_offline_mode(connman_bool_t enabled) { + GSList *list; + DBG("enabled %d", enabled); + + for (list = notifier_list; list; list = list->next) { + struct connman_notifier *notifier = list->data; + + if (notifier->offline_mode) + notifier->offline_mode(enabled); + } } int __connman_notifier_init(void) |