This patch handles properly rfkill hardblock so technology is removed from
dbus when it's hardblock (and not listed through GetTechnologies). It's added
when not hardblocked anymore.
---
src/technology.c | 47 +++++++++++++++++++++++++++++++++--------------
1 file changed, 33 insertions(+), 14 deletions(-)
diff --git a/src/technology.c b/src/technology.c
index 6e5da01..b5a9834 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -74,6 +74,7 @@ struct connman_technology {
GSList *scan_pending;
connman_bool_t dbus_registered;
+ connman_bool_t hardblocked;
};
static GSList *driver_list = NULL;
@@ -546,7 +547,8 @@ void __connman_technology_list_struct(DBusMessageIter
*array)
for (list = technology_list; list; list = list->next) {
struct connman_technology *technology = list->data;
- if (technology->path == NULL)
+ if (technology->path == NULL ||
+ technology->hardblocked == TRUE)
continue;
dbus_message_iter_open_container(array, DBUS_TYPE_STRUCT,
@@ -908,7 +910,8 @@ static const GDBusSignalTable technology_signals[] = {
static gboolean technology_dbus_register(struct connman_technology *technology)
{
- if (technology->dbus_registered == TRUE)
+ if (technology->dbus_registered == TRUE ||
+ technology->hardblocked == TRUE)
return TRUE;
if (g_dbus_register_interface(connection, technology->path,
@@ -968,6 +971,10 @@ static struct connman_technology *technology_get(enum
connman_service_type type)
technology->refcount = 1;
+ technology->hardblocked = TRUE;
+ if (type == CONNMAN_SERVICE_TYPE_ETHERNET)
+ technology->hardblocked = FALSE;
+
technology->type = type;
technology->path = g_strdup_printf("%s/technology/%s",
CONNMAN_PATH, str);
@@ -1121,7 +1128,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()
@@ -1132,8 +1141,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,
@@ -1287,6 +1297,21 @@ 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));
+ technology_dbus_unregister(technology);
+ } else
+ technology_dbus_register(technology);
+}
+
int __connman_technology_add_rfkill(unsigned int index,
enum connman_service_type type,
connman_bool_t softblock,
@@ -1319,10 +1344,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.
@@ -1363,16 +1385,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);
--
1.7.12
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman