From 3e6995b377ef331e8e15267f6be357e7a958203a Mon Sep 17 00:00:00 2001 From: Forest Bond Date: Tue, 11 May 2010 20:56:06 -0400 Subject: Fail immediately enabling/disabling unregistered technology Previously, calling EnableTechnology or DisableTechnology with an unregistered technology type caused the call to fail silently and eventually timeout. With this patch, a "Not Registered" error is returned immediately instead. --- src/notifier.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/notifier.c') diff --git a/src/notifier.c b/src/notifier.c index 2777783d..95794ac1 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -401,10 +401,8 @@ void __connman_notifier_offlinemode(connman_bool_t enabled) } } -connman_bool_t __connman_notifier_is_enabled(enum connman_service_type type) +static connman_bool_t technology_supported(enum connman_service_type type) { - DBG("type %d", type); - switch (type) { case CONNMAN_SERVICE_TYPE_UNKNOWN: case CONNMAN_SERVICE_TYPE_SYSTEM: @@ -419,6 +417,29 @@ connman_bool_t __connman_notifier_is_enabled(enum connman_service_type type) break; } + return TRUE; +} + +connman_bool_t __connman_notifier_is_registered(enum connman_service_type type) +{ + DBG("type %d", type); + + if (technology_supported(type) == FALSE) + return FALSE; + + if (g_atomic_int_get(®istered[type]) > 0) + return TRUE; + + return FALSE; +} + +connman_bool_t __connman_notifier_is_enabled(enum connman_service_type type) +{ + DBG("type %d", type); + + if (technology_supported(type) == FALSE) + return FALSE; + if (g_atomic_int_get(&enabled[type]) > 0) return TRUE; -- cgit v1.2.3