summaryrefslogtreecommitdiff
path: root/src/technology.c
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2012-10-02 12:27:10 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-10-03 13:15:51 +0300
commit2e592053410a01d4aa99366f81b8fc783ab03efb (patch)
treef1a282fc613e72659d37b3f6a0b813784f84300a /src/technology.c
parent9a8f7ff3e9ba7e5f56605c7b4f7508a2ebe30b98 (diff)
downloadconnman-2e592053410a01d4aa99366f81b8fc783ab03efb.tar.gz
connman-2e592053410a01d4aa99366f81b8fc783ab03efb.tar.bz2
connman-2e592053410a01d4aa99366f81b8fc783ab03efb.zip
technology: Handle rfkill hardblock
Diffstat (limited to 'src/technology.c')
-rw-r--r--src/technology.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/technology.c b/src/technology.c
index 001208d6..14861222 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -72,6 +72,8 @@ struct connman_technology {
guint pending_timeout;
GSList *scan_pending;
+
+ connman_bool_t hardblocked;
};
static GSList *driver_list = NULL;
@@ -962,6 +964,11 @@ static struct connman_technology *technology_get(enum connman_service_type type)
technology->refcount = 1;
+ if (type == CONNMAN_SERVICE_TYPE_ETHERNET)
+ technology->hardblocked = FALSE;
+ else
+ technology->hardblocked = TRUE;
+
technology->type = type;
technology->path = g_strdup_printf("%s/technology/%s",
CONNMAN_PATH, str);
@@ -1111,7 +1118,9 @@ int __connman_technology_add_device(struct connman_device *device)
return -ENXIO;
}
- if (technology->enable_persistent && !global_offlinemode) {
+ if (technology->enable_persistent &&
+ global_offlinemode == FALSE &&
+ technology->hardblocked == FALSE) {
int err = __connman_device_enable(device);
/*
* connman_technology_add_device() calls __connman_device_enable()
@@ -1122,8 +1131,9 @@ int __connman_technology_add_device(struct connman_device *device)
if (err == -EALREADY)
__connman_technology_enabled(type);
}
- /* if technology persistent state is offline */
- if (!technology->enable_persistent)
+ /* if technology persistent state is offline or hardblocked */
+ if (technology->enable_persistent == FALSE ||
+ technology->hardblocked == TRUE)
__connman_device_disable(device);
technology->device_list = g_slist_prepend(technology->device_list,
@@ -1277,6 +1287,18 @@ void __connman_technology_set_connected(enum connman_service_type type,
DBUS_TYPE_BOOLEAN, &connected);
}
+static void technology_apply_hardblock_change(struct connman_technology *technology,
+ connman_bool_t hardblock)
+{
+ if (technology->hardblocked == hardblock)
+ return;
+
+ technology->hardblocked = hardblock;
+
+ if (hardblock == TRUE)
+ DBG("%s is switched off.", get_name(technology->type));
+}
+
int __connman_technology_add_rfkill(unsigned int index,
enum connman_service_type type,
connman_bool_t softblock,
@@ -1309,10 +1331,7 @@ done:
if (technology == NULL)
return -ENXIO;
- if (hardblock) {
- DBG("%s is switched off.", get_name(type));
- return 0;
- }
+ technology_apply_hardblock_change(technology, hardblock);
/*
* If Offline mode is on, we softblock the device if it isnt already.
@@ -1353,16 +1372,13 @@ int __connman_technology_update_rfkill(unsigned int index,
rfkill->softblock = softblock;
rfkill->hardblock = hardblock;
- if (hardblock) {
- DBG("%s is switched off.", get_name(type));
- return 0;
- }
-
technology = technology_find(type);
/* If there is no driver for this type, ignore it. */
if (technology == NULL)
return -ENXIO;
+ technology_apply_hardblock_change(technology, hardblock);
+
if (!global_offlinemode) {
if (technology->enable_persistent && softblock)
return __connman_rfkill_block(type, FALSE);