summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-11-12 14:07:43 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-11-23 12:58:52 +0200
commit9c1129aa6a665f7663fcbf73b20994c8592e46d5 (patch)
tree78a7d3dfb3f067841155be11bce6c6f65dbbe50a /src
parentae693881d0d2bac1d9edea534918b6cc238b06ce (diff)
downloadconnman-9c1129aa6a665f7663fcbf73b20994c8592e46d5.tar.gz
connman-9c1129aa6a665f7663fcbf73b20994c8592e46d5.tar.bz2
connman-9c1129aa6a665f7663fcbf73b20994c8592e46d5.zip
provider: Add callback when creating vpn provider
Because the vpnd Create() in manager API only creates and does not connect the vpn, we must do the connect part after the vpn is created. This requires a callback which is called when the connection is established. Eventually this patch becomes obsolete because the CreateProvider() connman API is deprecated.
Diffstat (limited to 'src')
-rw-r--r--src/provider.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/provider.c b/src/provider.c
index cd11db97..665ef2ed 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -335,6 +335,41 @@ int connman_provider_create_service(struct connman_provider *provider)
return 0;
}
+static struct connman_provider *provider_lookup(const char *identifier)
+{
+ return g_hash_table_lookup(provider_hash, identifier);
+}
+
+static void connection_ready(DBusMessage *msg, int error_code, void *user_data)
+{
+ DBusMessage *reply;
+ const char *identifier = user_data;
+
+ DBG("msg %p error %d", msg, error_code);
+
+ if (error_code != 0) {
+ reply = __connman_error_failed(msg, -error_code);
+ if (g_dbus_send_message(connection, reply) == FALSE)
+ DBG("reply %p send failed", reply);
+ } else {
+ const char *path;
+ struct connman_provider *provider;
+
+ provider = provider_lookup(identifier);
+ if (provider == NULL) {
+ reply = __connman_error_failed(msg, -EINVAL);
+ g_dbus_send_message(connection, reply);
+ return;
+ }
+
+ path = __connman_service_get_path(provider->vpn_service);
+
+ g_dbus_send_reply(connection, msg,
+ DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+ }
+}
+
int __connman_provider_create_and_connect(DBusMessage *msg)
{
struct connman_provider_driver *driver;
@@ -346,12 +381,9 @@ int __connman_provider_create_and_connect(DBusMessage *msg)
if (driver == NULL || driver->create == NULL)
return -EINVAL;
- /*
- * XXX: we need a callback here which is called when connection
- * is ready
- */
+ DBG("msg %p", msg);
- return driver->create(msg);
+ return driver->create(msg, connection_ready);
}
const char * __connman_provider_get_ident(struct connman_provider *provider)