summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-08-09 23:07:38 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2010-08-09 23:09:02 +0200
commit5a44160d91e5214c0506cae8c79e13d994031200 (patch)
tree98c635919a07fa7cb7a3e790f05f97174cee471f
parentae3b3b3ea9df42424964cb18df943747367271eb (diff)
downloadconnman-5a44160d91e5214c0506cae8c79e13d994031200.tar.gz
connman-5a44160d91e5214c0506cae8c79e13d994031200.tar.bz2
connman-5a44160d91e5214c0506cae8c79e13d994031200.zip
Add BLOCKED technology state
A technology is in BLOCKED state if all of its devices are rfkill blocked.
-rw-r--r--doc/technology-api.txt4
-rw-r--r--src/connman.h1
-rw-r--r--src/device.c5
-rw-r--r--src/technology.c30
4 files changed, 35 insertions, 5 deletions
diff --git a/doc/technology-api.txt b/doc/technology-api.txt
index 6e65a19f..84084547 100644
--- a/doc/technology-api.txt
+++ b/doc/technology-api.txt
@@ -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]
diff --git a/src/connman.h b/src/connman.h
index d5c4e53d..b1502ad4 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -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);
diff --git a/src/device.c b/src/device.c
index 813e3bcd..7633cee9 100644
--- a/src/device.c
+++ b/src/device.c
@@ -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)
diff --git a/src/technology.c b/src/technology.c
index 8d1be5c0..47ce6924 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -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;
}