summaryrefslogtreecommitdiff
path: root/vpn
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-11-30 11:30:37 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-11-30 15:01:18 +0200
commit75ee7a107b39753510bdf4692fd32d4754e9746f (patch)
tree90e5a6b156e66f2bff0beca89b6ad631cbd0eeec /vpn
parent6cca0f6840abec55b330a55b08364aa7f2840305 (diff)
downloadconnman-75ee7a107b39753510bdf4692fd32d4754e9746f.tar.gz
connman-75ee7a107b39753510bdf4692fd32d4754e9746f.tar.bz2
connman-75ee7a107b39753510bdf4692fd32d4754e9746f.zip
vpn: Make VPN plugin connection function async
This is needed as we want to ask user the passwords etc.
Diffstat (limited to 'vpn')
-rw-r--r--vpn/plugins/vpn.c2
-rw-r--r--vpn/vpn-provider.c29
-rw-r--r--vpn/vpn-provider.h4
-rw-r--r--vpn/vpn.h2
4 files changed, 28 insertions, 9 deletions
diff --git a/vpn/plugins/vpn.c b/vpn/plugins/vpn.c
index 66a75d2a..a8603d92 100644
--- a/vpn/plugins/vpn.c
+++ b/vpn/plugins/vpn.c
@@ -412,7 +412,7 @@ static int vpn_connect(struct vpn_provider *provider,
ret = vpn_driver_data->vpn_driver->connect(provider, data->task,
data->if_name, cb, user_data);
- if (ret < 0) {
+ if (ret < 0 && ret != -EINPROGRESS) {
stop_vpn(provider);
connman_task_destroy(data->task);
data->task = NULL;
diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index a5980e6f..c6b86de2 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -440,11 +440,11 @@ static DBusMessage *do_connect(DBusConnection *conn, DBusMessage *msg,
DBG("conn %p provider %p", conn, provider);
- err = __vpn_provider_connect(provider);
+ err = __vpn_provider_connect(provider, msg);
if (err < 0)
return __connman_error_failed(msg, -err);
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ return NULL;
}
static DBusMessage *do_disconnect(DBusConnection *conn, DBusMessage *msg,
@@ -978,19 +978,34 @@ int __vpn_provider_disconnect(struct vpn_provider *provider)
static void connect_cb(struct vpn_provider *provider, void *user_data,
int error)
{
+ DBusMessage *pending = user_data;
+
DBG("provider %p user %p error %d", provider, user_data, error);
+
+ if (error != 0) {
+ DBusMessage *reply = __connman_error_failed(pending, error);
+ if (reply != NULL)
+ g_dbus_send_message(connection, reply);
+
+ vpn_provider_indicate_error(provider,
+ VPN_PROVIDER_ERROR_CONNECT_FAILED);
+ vpn_provider_set_state(provider, VPN_PROVIDER_STATE_FAILURE);
+ } else
+ g_dbus_send_reply(connection, pending, DBUS_TYPE_INVALID);
+
+ dbus_message_unref(pending);
}
-int __vpn_provider_connect(struct vpn_provider *provider)
+int __vpn_provider_connect(struct vpn_provider *provider, DBusMessage *msg)
{
int err;
DBG("provider %p", provider);
- if (provider->driver != NULL && provider->driver->connect != NULL)
- err = provider->driver->connect(provider,
- connect_cb, NULL);
- else
+ if (provider->driver != NULL && provider->driver->connect != NULL) {
+ dbus_message_ref(msg);
+ err = provider->driver->connect(provider, connect_cb, msg);
+ } else
return -EOPNOTSUPP;
return err;
diff --git a/vpn/vpn-provider.h b/vpn/vpn-provider.h
index b3c10483..b290bd1d 100644
--- a/vpn/vpn-provider.h
+++ b/vpn/vpn-provider.h
@@ -108,6 +108,10 @@ const char *vpn_provider_get_path(struct vpn_provider *provider);
typedef void (* vpn_provider_connect_cb_t) (struct vpn_provider *provider,
void *user_data, int error);
+typedef void (* vpn_provider_auth_cb_t) (struct vpn_provider *provider,
+ const char *authenticator,
+ const char *error, void *user_data);
+
struct vpn_provider_driver {
const char *name;
enum vpn_provider_type type;
diff --git a/vpn/vpn.h b/vpn/vpn.h
index 2b36b309..fed66a8c 100644
--- a/vpn/vpn.h
+++ b/vpn/vpn.h
@@ -83,7 +83,7 @@ int __vpn_provider_indicate_state(struct vpn_provider *provider,
enum vpn_provider_state state);
int __vpn_provider_indicate_error(struct vpn_provider *provider,
enum vpn_provider_error error);
-int __vpn_provider_connect(struct vpn_provider *provider);
+int __vpn_provider_connect(struct vpn_provider *provider, DBusMessage *msg);
int __vpn_provider_connect_path(const char *path);
int __vpn_provider_disconnect(struct vpn_provider *provider);
int __vpn_provider_remove(const char *path);