summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/connman.h1
-rw-r--r--src/manager.c6
-rw-r--r--src/notifier.c27
3 files changed, 31 insertions, 3 deletions
diff --git a/src/connman.h b/src/connman.h
index 16ded2d0..f3a3050d 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -464,6 +464,7 @@ void __connman_notifier_disconnect(enum connman_service_type type);
void __connman_notifier_offlinemode(connman_bool_t enabled);
void __connman_notifier_default_changed(struct connman_service *service);
+connman_bool_t __connman_notifier_is_registered(enum connman_service_type type);
connman_bool_t __connman_notifier_is_enabled(enum connman_service_type type);
unsigned int __connman_notifier_count_connected(void);
const char *__connman_notifier_get_state(void);
diff --git a/src/manager.c b/src/manager.c
index da0ee53d..6561a78c 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -345,6 +345,9 @@ static DBusMessage *enable_technology(DBusConnection *conn,
else
return __connman_error_invalid_arguments(msg);
+ if (__connman_notifier_is_registered(type) == FALSE)
+ return __connman_error_not_registered(msg);
+
if (__connman_notifier_is_enabled(type) == TRUE)
return __connman_error_already_enabled(msg);
@@ -390,6 +393,9 @@ static DBusMessage *disable_technology(DBusConnection *conn,
else
return __connman_error_invalid_arguments(msg);
+ if (__connman_notifier_is_registered(type) == FALSE)
+ return __connman_error_not_registered(msg);
+
if (__connman_notifier_is_enabled(type) == FALSE)
return __connman_error_already_disabled(msg);
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(&registered[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;