summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/connman.h5
-rw-r--r--src/device.c65
-rw-r--r--src/manager.c8
-rw-r--r--src/technology.c58
4 files changed, 67 insertions, 69 deletions
diff --git a/src/connman.h b/src/connman.h
index 945d8e88..272b3341 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -314,8 +314,11 @@ void __connman_technology_list(DBusMessageIter *iter, void *user_data);
int __connman_technology_add_device(struct connman_device *device);
int __connman_technology_remove_device(struct connman_device *device);
+int __connman_technology_enabled(enum connman_service_type type);
int __connman_technology_enable(enum connman_service_type type);
+int __connman_technology_disabled(enum connman_service_type type);
int __connman_technology_disable(enum connman_service_type type);
+
int __connman_technology_add_rfkill(unsigned int index,
enum connman_service_type type,
connman_bool_t softblock,
@@ -342,8 +345,6 @@ void __connman_device_list(DBusMessageIter *iter, void *user_data);
enum connman_service_type __connman_device_get_service_type(struct connman_device *device);
struct connman_device *__connman_device_find_device(enum connman_service_type type);
int __connman_device_request_scan(enum connman_service_type type);
-int __connman_device_enable_technology(enum connman_service_type type);
-int __connman_device_disable_technology(enum connman_service_type type);
connman_bool_t __connman_device_isfiltered(const char *devname);
diff --git a/src/device.c b/src/device.c
index 12fa49a0..be184e1f 100644
--- a/src/device.c
+++ b/src/device.c
@@ -246,7 +246,7 @@ int __connman_device_enable(struct connman_device *device)
__connman_profile_set_offlinemode(FALSE, FALSE);
type = __connman_device_get_service_type(device);
- __connman_technology_enable(type);
+ __connman_technology_enabled(type);
return 0;
}
@@ -286,7 +286,7 @@ int __connman_device_disable(struct connman_device *device)
device->powered = FALSE;
type = __connman_device_get_service_type(device);
- __connman_technology_disable(type);
+ __connman_technology_disabled(type);
return 0;
}
@@ -680,9 +680,9 @@ int connman_device_set_powered(struct connman_device *device,
type = __connman_device_get_service_type(device);
if (device->powered == TRUE)
- __connman_technology_enable(type);
+ __connman_technology_enabled(type);
else
- __connman_technology_disable(type);
+ __connman_technology_disabled(type);
if (device->offlinemode == TRUE && powered == TRUE)
return connman_device_set_powered(device, FALSE);
@@ -1321,63 +1321,6 @@ int __connman_device_request_scan(enum connman_service_type type)
return 0;
}
-static int set_technology(enum connman_service_type type, connman_bool_t enable)
-{
- GSList *list;
- int err;
-
- DBG("type %d enable %d", type, enable);
-
- switch (type) {
- case CONNMAN_SERVICE_TYPE_UNKNOWN:
- case CONNMAN_SERVICE_TYPE_SYSTEM:
- case CONNMAN_SERVICE_TYPE_GPS:
- case CONNMAN_SERVICE_TYPE_VPN:
- case CONNMAN_SERVICE_TYPE_GADGET:
- return 0;
- case CONNMAN_SERVICE_TYPE_ETHERNET:
- case CONNMAN_SERVICE_TYPE_WIFI:
- case CONNMAN_SERVICE_TYPE_WIMAX:
- case CONNMAN_SERVICE_TYPE_BLUETOOTH:
- case CONNMAN_SERVICE_TYPE_CELLULAR:
- break;
- }
-
- for (list = device_list; list != NULL; list = list->next) {
- struct connman_device *device = list->data;
- enum connman_service_type service_type =
- __connman_device_get_service_type(device);
-
- if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
- service_type != type) {
- continue;
- }
-
- if (enable == TRUE)
- err = __connman_device_enable_persistent(device);
- else
- err = __connman_device_disable_persistent(device);
-
- if (err < 0 && err != -EINPROGRESS) {
- DBG("err %d", err);
- /* XXX maybe only a continue? */
- return err;
- }
- }
-
- return 0;
-}
-
-int __connman_device_enable_technology(enum connman_service_type type)
-{
- return set_technology(type, TRUE);
-}
-
-int __connman_device_disable_technology(enum connman_service_type type)
-{
- return set_technology(type, FALSE);
-}
-
connman_bool_t __connman_device_isfiltered(const char *devname)
{
char **pattern;
diff --git a/src/manager.c b/src/manager.c
index d5542fd8..a276e0b2 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -343,8 +343,8 @@ static DBusMessage *enable_technology(DBusConnection *conn,
technology_enabled = TRUE;
technology_pending = dbus_message_ref(msg);
- err = __connman_device_enable_technology(type);
- if (err < 0 && err != -EINPROGRESS)
+ err = __connman_technology_enable(type);
+ if (err < 0)
technology_reply(-err);
else
technology_timeout = g_timeout_add_seconds(15,
@@ -391,8 +391,8 @@ static DBusMessage *disable_technology(DBusConnection *conn,
technology_enabled = FALSE;
technology_pending = dbus_message_ref(msg);
- err = __connman_device_disable_technology(type);
- if (err < 0 && err != -EINPROGRESS)
+ err = __connman_technology_disable(type);
+ if (err < 0)
technology_reply(-err);
else
technology_timeout = g_timeout_add_seconds(10,
diff --git a/src/technology.c b/src/technology.c
index c68a649a..cb065e2b 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -675,7 +675,7 @@ int __connman_technology_remove_device(struct connman_device *device)
return 0;
}
-int __connman_technology_enable(enum connman_service_type type)
+int __connman_technology_enabled(enum connman_service_type type)
{
struct connman_technology *technology;
@@ -696,7 +696,37 @@ int __connman_technology_enable(enum connman_service_type type)
return 0;
}
-int __connman_technology_disable(enum connman_service_type type)
+int __connman_technology_enable(enum connman_service_type type)
+{
+ struct connman_technology *technology;
+ GSList *list;
+ int err;
+ int ret = -ENODEV;
+
+ DBG("type %d enable", type);
+
+ technology = technology_find(type);
+ if (technology == NULL)
+ return -ENXIO;
+
+ for (list = technology->device_list; list; list = list->next) {
+ struct connman_device *device = list->data;
+
+ err = __connman_device_enable_persistent(device);
+ /*
+ * err = 0 : Device was enabled right away.
+ * err = -EINPROGRESS : DBus call was successful.
+ * If atleast one device gets enabled, we consider
+ * the technology to be enabled.
+ */
+ if (err == 0 || err == -EINPROGRESS)
+ ret = 0;
+ }
+
+ return ret;
+}
+
+int __connman_technology_disabled(enum connman_service_type type)
{
struct connman_technology *technology;
GSList *list;
@@ -725,6 +755,30 @@ int __connman_technology_disable(enum connman_service_type type)
return 0;
}
+int __connman_technology_disable(enum connman_service_type type)
+{
+ struct connman_technology *technology;
+ GSList *list;
+ int err;
+ int ret = -ENODEV;
+
+ DBG("type %d disable", type);
+
+ technology = technology_find(type);
+ if (technology == NULL)
+ return -ENXIO;
+
+ for (list = technology->device_list; list; list = list->next) {
+ struct connman_device *device = list->data;
+
+ err = __connman_device_disable_persistent(device);
+ if (err == 0 || err == -EINPROGRESS)
+ ret = 0;
+ }
+
+ return ret;
+}
+
static void technology_blocked(struct connman_technology *technology,
connman_bool_t blocked)
{