provider: Removed the connect part from the create() function
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Mon, 12 Nov 2012 12:07:41 +0000 (14:07 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 23 Nov 2012 10:58:51 +0000 (12:58 +0200)
The connect operation is done separately from create operation
in connman-vpnd so change the function to reflect that.

vpn/vpn-manager.c
vpn/vpn-provider.c
vpn/vpn.h

index cd8516519734762c6528c2d639b73afe23711270..1ba745b406eb94880c5828d92a81430d238add05 100644 (file)
@@ -43,7 +43,7 @@ static DBusMessage *create(DBusConnection *conn, DBusMessage *msg, void *data)
 
        DBG("conn %p", conn);
 
-       err = __vpn_provider_create_and_connect(msg);
+       err = __vpn_provider_create(msg);
        if (err < 0) {
                if (err == -EINPROGRESS) {
                        connman_error("Invalid return code (%d) "
index 72bf68630532a3fbea2f6c689b775f185f107551..300ce85a7608b991d3a3dfc8ea2a0d03913e652d 100644 (file)
@@ -75,7 +75,6 @@ struct vpn_provider {
        GSList *user_networks;
        GResolv *resolv;
        char **host_ip;
-       DBusMessage *pending_msg;
        struct vpn_ipconfig *ipconfig_ipv4;
        struct vpn_ipconfig *ipconfig_ipv6;
        char **nameservers;
@@ -1543,7 +1542,7 @@ static void provider_create_all_from_type(const char *provider_type)
        g_strfreev(providers);
 }
 
-int __vpn_provider_create_and_connect(DBusMessage *msg)
+int __vpn_provider_create(DBusMessage *msg)
 {
        struct vpn_provider *provider;
        DBusMessageIter iter, array;
@@ -1650,32 +1649,22 @@ int __vpn_provider_create_and_connect(DBusMessage *msg)
 
        g_free(ident);
 
-       provider->pending_msg = dbus_message_ref(msg);
-
-       DBG("provider %p pending %p", provider, provider->pending_msg);
-
-       if (provider->index > 0) {
-               DBG("provider already connected");
-       } else {
-               err = __vpn_provider_connect(provider);
-               if (err < 0 && err != -EINPROGRESS)
-                       goto failed;
-       }
-
        vpn_provider_save(provider);
 
-       return 0;
+       err = provider_register(provider);
+       if (err != 0 && err != -EALREADY)
+               return err;
 
-failed:
-       DBG("Can not connect (%d), deleting provider %p %s", err, provider,
-               provider->identifier);
+       connection_register(provider);
 
-       vpn_provider_indicate_error(provider,
-                               VPN_PROVIDER_ERROR_CONNECT_FAILED);
+       DBG("provider %p index %d path %s", provider, provider->index,
+                                                       provider->path);
 
-       g_hash_table_remove(provider_hash, provider->identifier);
+       g_dbus_send_reply(connection, msg,
+                               DBUS_TYPE_OBJECT_PATH, &provider->path,
+                               DBUS_TYPE_INVALID);
 
-       return err;
+       return 0;
 }
 
 static void append_connection_structs(DBusMessageIter *iter, void *user_data)
@@ -1801,17 +1790,7 @@ void vpn_provider_set_data(struct vpn_provider *provider, void *data)
 
 void vpn_provider_set_index(struct vpn_provider *provider, int index)
 {
-       DBG("index %d provider %p pending %p", index, provider,
-               provider->pending_msg);
-
-       if (provider->pending_msg != NULL) {
-               g_dbus_send_reply(connection, provider->pending_msg,
-                               DBUS_TYPE_STRING, &provider->identifier,
-                               DBUS_TYPE_INT32, &index,
-                               DBUS_TYPE_INVALID);
-               dbus_message_unref(provider->pending_msg);
-               provider->pending_msg = NULL;
-       }
+       DBG("index %d provider %p", index, provider);
 
        if (provider->ipconfig_ipv4 == NULL) {
                provider->ipconfig_ipv4 = __vpn_ipconfig_create(index,
index 96f4e8711e0d38a02678e04e8f8092c7515ef56e..598c86dd7cb0865a1713550c4b7077d9ed16004c 100644 (file)
--- a/vpn/vpn.h
+++ b/vpn/vpn.h
@@ -76,7 +76,7 @@ int __vpn_provider_append_user_route(struct vpn_provider *provider,
                        int family, const char *network, const char *netmask);
 void __vpn_provider_append_properties(struct vpn_provider *provider, DBusMessageIter *iter);
 void __vpn_provider_list(DBusMessageIter *iter, void *user_data);
-int __vpn_provider_create_and_connect(DBusMessage *msg);
+int __vpn_provider_create(DBusMessage *msg);
 DBusMessage *__vpn_provider_get_connections(DBusMessage *msg);
 const char * __vpn_provider_get_ident(struct vpn_provider *provider);
 int __vpn_provider_indicate_state(struct vpn_provider *provider,