Add BLOCKED technology state
authorSamuel Ortiz <sameo@linux.intel.com>
Mon, 9 Aug 2010 21:07:38 +0000 (23:07 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 9 Aug 2010 21:09:02 +0000 (23:09 +0200)
A technology is in BLOCKED state if all of its devices are rfkill blocked.

doc/technology-api.txt
src/connman.h
src/device.c
src/technology.c

index 6e65a19..8408454 100644 (file)
@@ -21,8 +21,8 @@ Properties    string State [readonly]
 
                        The technology state information.
 
-                       Valid states are "offline", "available", "enabled"
-                       and "connected".
+                       Valid states are "offline", "available", "blocked",
+                       "enabled "and "connected".
 
                string Name [readonly]
 
index d5c4e53..b1502ad 100644 (file)
@@ -339,6 +339,7 @@ void __connman_device_set_phyindex(struct connman_device *device,
                                                        int phyindex);
 int __connman_device_set_blocked(struct connman_device *device,
                                                connman_bool_t blocked);
+connman_bool_t __connman_device_get_blocked(struct connman_device *device);
 
 void __connman_device_increase_connections(struct connman_device *device);
 void __connman_device_decrease_connections(struct connman_device *device);
index 813e3bc..7633cee 100644 (file)
@@ -1062,6 +1062,11 @@ int __connman_device_set_blocked(struct connman_device *device,
        return set_powered(device, powered);
 }
 
+connman_bool_t __connman_device_get_blocked(struct connman_device *device)
+{
+       return device->blocked;
+}
+
 int __connman_device_scan(struct connman_device *device)
 {
        if (!device->driver || !device->driver->scan)
index 8d1be5c..47ce692 100644 (file)
@@ -42,8 +42,9 @@ enum connman_technology_state {
        CONNMAN_TECHNOLOGY_STATE_UNKNOWN   = 0,
        CONNMAN_TECHNOLOGY_STATE_OFFLINE   = 1,
        CONNMAN_TECHNOLOGY_STATE_AVAILABLE = 2,
-       CONNMAN_TECHNOLOGY_STATE_ENABLED   = 3,
-       CONNMAN_TECHNOLOGY_STATE_CONNECTED = 4,
+       CONNMAN_TECHNOLOGY_STATE_BLOCKED   = 3,
+       CONNMAN_TECHNOLOGY_STATE_ENABLED   = 4,
+       CONNMAN_TECHNOLOGY_STATE_CONNECTED = 5,
 };
 
 struct connman_technology {
@@ -263,6 +264,8 @@ static const char *state2string(enum connman_technology_state state)
                return "offline";
        case CONNMAN_TECHNOLOGY_STATE_AVAILABLE:
                return "available";
+       case CONNMAN_TECHNOLOGY_STATE_BLOCKED:
+               return "blocked";
        case CONNMAN_TECHNOLOGY_STATE_ENABLED:
                return "enabled";
        case CONNMAN_TECHNOLOGY_STATE_CONNECTED:
@@ -493,8 +496,18 @@ int __connman_technology_add_device(struct connman_device *device)
        g_hash_table_insert(device_table, device, technology);
 
        if (technology->device_list == NULL) {
-               technology->state = CONNMAN_TECHNOLOGY_STATE_AVAILABLE;
+               if (__connman_device_get_blocked(device) == TRUE)
+                       technology->state = CONNMAN_TECHNOLOGY_STATE_BLOCKED;
+               else
+                       technology->state = CONNMAN_TECHNOLOGY_STATE_AVAILABLE;
+
                state_changed(technology);
+       } else {
+               if (technology->state == CONNMAN_TECHNOLOGY_STATE_BLOCKED &&
+                               __connman_device_get_blocked(device) == FALSE) {
+                       technology->state = CONNMAN_TECHNOLOGY_STATE_AVAILABLE;
+                       state_changed(technology);
+               }
        }
 
        technology->device_list = g_slist_append(technology->device_list,
@@ -559,6 +572,7 @@ int __connman_technology_disable_device(struct connman_device *device)
 {
        struct connman_technology *technology;
        enum connman_service_type type;
+       GSList *list;
 
        DBG("device %p", device);
 
@@ -574,6 +588,16 @@ int __connman_technology_disable_device(struct connman_device *device)
                state_changed(technology);
        }
 
+       for (list = technology->device_list; list; list = list->next) {
+               struct connman_device *device = list->data;
+
+               if (__connman_device_get_blocked(device) == FALSE)
+                       return 0;
+       }
+
+       technology->state = CONNMAN_TECHNOLOGY_STATE_BLOCKED;
+       state_changed(technology);
+
        return 0;
 }