summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/device.h2
-rw-r--r--src/device.c33
-rw-r--r--src/network.c4
3 files changed, 39 insertions, 0 deletions
diff --git a/include/device.h b/include/device.h
index abd62cfb..0f30100b 100644
--- a/include/device.h
+++ b/include/device.h
@@ -91,6 +91,8 @@ extern int connman_device_set_carrier(struct connman_device *device,
connman_bool_t carrier);
extern int connman_device_set_scanning(struct connman_device *device,
connman_bool_t scanning);
+extern int connman_device_set_disconnected(struct connman_device *device,
+ connman_bool_t disconnected);
extern int connman_device_set_string(struct connman_device *device,
const char *key, const char *value);
diff --git a/src/device.c b/src/device.c
index a2a29beb..293055b5 100644
--- a/src/device.c
+++ b/src/device.c
@@ -36,6 +36,7 @@ struct connman_device {
connman_bool_t powered;
connman_bool_t carrier;
connman_bool_t scanning;
+ connman_bool_t disconnected;
connman_uint8_t priority;
char *name;
char *node;
@@ -1187,6 +1188,9 @@ int connman_device_set_scanning(struct connman_device *device,
if (device->connections > 0)
return 0;
+ if (device->disconnected == TRUE)
+ return 0;
+
if (device->policy != CONNMAN_DEVICE_POLICY_AUTO)
return 0;
@@ -1196,6 +1200,35 @@ int connman_device_set_scanning(struct connman_device *device,
}
/**
+ * connman_device_set_disconnected:
+ * @device: device structure
+ * @disconnected: disconnected state
+ *
+ * Change disconnected state of device (only for device with networks)
+ */
+int connman_device_set_disconnected(struct connman_device *device,
+ connman_bool_t disconnected)
+{
+ DBG("driver %p disconnected %d", device, disconnected);
+
+ switch (device->mode) {
+ case CONNMAN_DEVICE_MODE_UNKNOWN:
+ case CONNMAN_DEVICE_MODE_TRANSPORT_IP:
+ return -EINVAL;
+ case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
+ case CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE:
+ break;
+ }
+
+ if (device->disconnected == disconnected)
+ return -EALREADY;
+
+ device->disconnected = disconnected;
+
+ return 0;
+}
+
+/**
* connman_device_set_string:
* @device: device structure
* @key: unique identifier
diff --git a/src/network.c b/src/network.c
index 4a7b8f2d..45213a9b 100644
--- a/src/network.c
+++ b/src/network.c
@@ -245,6 +245,8 @@ static DBusMessage *do_connect(DBusConnection *conn,
} else
network->connected = TRUE;
+ connman_device_set_disconnected(network->device, FALSE);
+
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
@@ -272,6 +274,8 @@ static DBusMessage *do_disconnect(DBusConnection *conn,
} else
network->connected = FALSE;
+ connman_device_set_disconnected(network->device, TRUE);
+
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}