[PATCH 3/6] use __connman_service_connect in join()

Martin Xu martin.xu at intel.com
Mon Jul 13 23:03:42 PDT 2009


---
 src/device.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/device.c b/src/device.c
index 563bf2d..477d380 100644
--- a/src/device.c
+++ b/src/device.c
@@ -540,6 +540,7 @@ static DBusMessage *join_network(DBusConnection *conn,
 {
 	struct connman_device *device = data;
 	struct connman_network *network, *found_network;
+	struct connman_service *service;
 	enum connman_network_type type;
 	unsigned int ssid_size;
 	const char *group, *mode, *security, *address;
@@ -643,15 +644,25 @@ static DBusMessage *join_network(DBusConnection *conn,
 
 	connman_network_set_protocol(network, CONNMAN_NETWORK_PROTOCOL_IP);
 
-	if (connman_device_get_disconnected(device) == FALSE)
-		__connman_device_disconnect(device);
+	connman_device_add_network(device, network);
 
-	err = device->driver->join(device, network);
+	connman_network_set_available(network, TRUE);
 
-	connman_network_unref(network);
+	service = __connman_service_lookup_from_network(network);
 
-	if (err < 0)
-		return __connman_error_failed(msg, -err);
+	if (__connman_service_set_pending(service, msg) == -EINPROGRESS)
+		return __connman_error_in_progress(msg);
+
+	err = __connman_service_connect(service);
+	if (err < 0) {
+		if (err != -EINPROGRESS) {
+			__connman_service_clear_pending(service);
+
+			return __connman_error_failed(msg, -err);
+		}
+
+		return NULL;
+	}
 
 	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
-- 
1.6.1.3



More information about the connman mailing list