diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-11-12 14:07:41 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-11-23 12:58:51 +0200 |
commit | efcc517183f672af421d8a09dedef5c9c0d16f64 (patch) | |
tree | 0285627feef0036c0a6cab936d00fb48fa703a64 /vpn | |
parent | 42104cd4b9cf6a782ce489a229e306c17772e9bd (diff) | |
download | connman-efcc517183f672af421d8a09dedef5c9c0d16f64.tar.gz connman-efcc517183f672af421d8a09dedef5c9c0d16f64.tar.bz2 connman-efcc517183f672af421d8a09dedef5c9c0d16f64.zip |
provider: Removed the connect part from the create() function
The connect operation is done separately from create operation
in connman-vpnd so change the function to reflect that.
Diffstat (limited to 'vpn')
-rw-r--r-- | vpn/vpn-manager.c | 2 | ||||
-rw-r--r-- | vpn/vpn-provider.c | 45 | ||||
-rw-r--r-- | vpn/vpn.h | 2 |
3 files changed, 14 insertions, 35 deletions
diff --git a/vpn/vpn-manager.c b/vpn/vpn-manager.c index cd851651..1ba745b4 100644 --- a/vpn/vpn-manager.c +++ b/vpn/vpn-manager.c @@ -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) " diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c index 72bf6863..300ce85a 100644 --- a/vpn/vpn-provider.c +++ b/vpn/vpn-provider.c @@ -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, @@ -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, |