summaryrefslogtreecommitdiff
path: root/src/session.c
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2012-10-31 10:33:31 +0100
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-11-05 14:43:33 +0200
commit571da6449e813c3cf1a3f9515818d69bbc2e264d (patch)
treedfdbeece268dd464411fa722ca41a4f3aef3f58b /src/session.c
parenta475f99d89f5f9615c31400f4a7126be871c3152 (diff)
downloadconnman-571da6449e813c3cf1a3f9515818d69bbc2e264d.tar.gz
connman-571da6449e813c3cf1a3f9515818d69bbc2e264d.tar.bz2
connman-571da6449e813c3cf1a3f9515818d69bbc2e264d.zip
session: Add callback to policy create()
Instead returning directly a config when create() is called in policy plugin, use a callback function for handing over a valid configuration from the plugin to the session core. This prepares support for asynchronous create call.
Diffstat (limited to 'src/session.c')
-rw-r--r--src/session.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/session.c b/src/session.c
index 2b06e3f3..247ff066 100644
--- a/src/session.c
+++ b/src/session.c
@@ -231,21 +231,23 @@ static int assign_policy_plugin(struct connman_session *session)
return 0;
}
-static int create_policy_config(struct connman_session *session)
+static int create_policy_config(struct connman_session *session,
+ connman_session_config_cb callback,
+ void *user_data)
{
struct connman_session_config *config;
- if (session->policy == NULL)
+ if (session->policy == NULL) {
config = connman_session_create_default_config();
- else
- config = (*session->policy->create)(session);
+ if (config == NULL)
+ return -ENOMEM;
- if (config == NULL)
- return -ENOMEM;
+ session->policy_config = config;
- session->policy_config = config;
+ return 0;
+ }
- return 0;
+ return (*session->policy->create)(session, callback, user_data);
}
static void destroy_policy_config(struct connman_session *session)
@@ -1580,6 +1582,18 @@ static const GDBusMethodTable session_methods[] = {
{ },
};
+static void session_create_cb(struct connman_session *session,
+ struct connman_session_config *config,
+ void *user_data, int err)
+{
+ DBG("session %p config %p", session, config);
+
+ if (err != 0)
+ return;
+
+ session->policy_config = config;
+}
+
int __connman_session_create(DBusMessage *msg)
{
const char *owner, *notify_path;
@@ -1696,7 +1710,7 @@ int __connman_session_create(DBusMessage *msg)
err = assign_policy_plugin(session);
if (err < 0)
goto err;
- err = create_policy_config(session);
+ err = create_policy_config(session, session_create_cb, NULL);
if (err < 0)
goto err;