notifier: Change __connman_notifier_count_connected() to *_is_connected()
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Thu, 19 Apr 2012 09:58:22 +0000 (11:58 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 19 Apr 2012 11:38:08 +0000 (13:38 +0200)
No caller is interested in the number of connected services, only
if there is one or more or none.

src/connman.h
src/notifier.c
src/service.c

index 4bf534f..80afffe 100644 (file)
@@ -701,7 +701,7 @@ void __connman_notifier_service_state_changed(struct connman_service *service,
 void __connman_notifier_ipconfig_changed(struct connman_service *service,
                                        struct connman_ipconfig *ipconfig);
 
-unsigned int __connman_notifier_count_connected(void);
+connman_bool_t __connman_notifier_is_connected(void);
 const char *__connman_notifier_get_state(void);
 
 #include <connman/rtnl.h>
index 7d4b1e8..10f1692 100644 (file)
@@ -91,17 +91,17 @@ static unsigned int notifier_count_online(void)
        return count;
 }
 
-unsigned int __connman_notifier_count_connected(void)
+connman_bool_t __connman_notifier_is_connected(void)
 {
-       unsigned int i, count = 0;
+       unsigned int i;
 
        __sync_synchronize();
        for (i = 0; i < MAX_TECHNOLOGIES; i++) {
                if (connected[i] > 0)
-                       count++;
+                       return TRUE;
        }
 
-       return count;
+       return FALSE;
 }
 
 static const char *evaluate_notifier_state(void)
@@ -112,8 +112,7 @@ static const char *evaluate_notifier_state(void)
        if (count > 0)
                return "online";
 
-       count = __connman_notifier_count_connected();
-       if (count > 0)
+       if (__connman_notifier_is_connected() == TRUE)
                return "ready";
 
        if ( __connman_technology_get_offlinemode() == TRUE)
index 04be98e..35b7aba 100644 (file)
@@ -4549,7 +4549,7 @@ static int service_indicate_state(struct connman_service *service)
        } else if (new_state == CONNMAN_SERVICE_STATE_DISCONNECT) {
                def_service = __connman_service_get_default();
 
-               if (__connman_notifier_count_connected() == 0 &&
+               if (__connman_notifier_is_connected() == FALSE &&
                        def_service != NULL &&
                                def_service->provider != NULL)
                        __connman_provider_disconnect(def_service->provider);