summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2012-09-19 13:37:14 +0200
committerDaniel Wagner <daniel.wagner@bmw-carit.de>2012-09-27 10:28:28 +0200
commita5e3f919ed56b1aba3893abc780039ad32debb90 (patch)
tree68e32af56ab7b129d6fcfc7c2cf234fa126cd4b5
parentdc7095e240c3a4ca50805e7f2d2249e6cecd4e78 (diff)
downloadconnman-a5e3f919ed56b1aba3893abc780039ad32debb90.tar.gz
connman-a5e3f919ed56b1aba3893abc780039ad32debb90.tar.bz2
connman-a5e3f919ed56b1aba3893abc780039ad32debb90.zip
session: Use session pointer instead of string id
Instead of passing in some string to identify we can use the connman_session pointer. This allows us to keep the way sessions are identfied away from the core, e.g. using the D-Bus owner id or something else.
-rw-r--r--include/session.h13
-rw-r--r--plugins/session_policy.c10
-rw-r--r--src/session.c36
3 files changed, 16 insertions, 43 deletions
diff --git a/include/session.h b/include/session.h
index 2871d509..3c6e6ff0 100644
--- a/include/session.h
+++ b/include/session.h
@@ -34,22 +34,21 @@ extern "C" {
struct connman_session;
-/*
- * The session are identified through the pid is only a temporary solution
- */
struct connman_session_policy {
const char *name;
int priority;
- int (*get_bool) (const char *id, const char *key, connman_bool_t *val);
- int (*get_string) (const char *id, const char *key, char **val);
+ int (*get_bool) (struct connman_session *session,
+ const char *key, connman_bool_t *val);
+ int (*get_string) (struct connman_session *session,
+ const char *key, char **val);
};
int connman_session_policy_register(struct connman_session_policy *config);
void connman_session_policy_unregister(struct connman_session_policy *config);
-int connman_session_update_bool(const char *id, const char *key,
+int connman_session_update_bool(struct connman_session *session, const char *key,
connman_bool_t val);
-int connman_session_update_string(const char *id, const char *key,
+int connman_session_update_string(struct connman_session *session, const char *key,
const char *val);
#ifdef __cplusplus
diff --git a/plugins/session_policy.c b/plugins/session_policy.c
index acbf154a..906cc229 100644
--- a/plugins/session_policy.c
+++ b/plugins/session_policy.c
@@ -33,9 +33,10 @@
#include <connman/log.h>
#include <connman/session.h>
-static int policy_get_bool(const char *id, const char *key, connman_bool_t *val)
+static int policy_get_bool(struct connman_session *session,
+ const char *key, connman_bool_t *val)
{
- DBG("id %s key %s", id, key);
+ DBG("sesion %p key %s", session, key);
if (g_str_equal(key, "Priority") == TRUE)
*val = FALSE;
@@ -47,9 +48,10 @@ static int policy_get_bool(const char *id, const char *key, connman_bool_t *val)
return 0;
}
-static int policy_get_string(const char *id, const char *key, char **val)
+static int policy_get_string(struct connman_session *session,
+ const char *key, char **val)
{
- DBG("id %s key %s", id, key);
+ DBG("session %p key %s", session, key);
if (g_str_equal(key, "RoamingPolicy") == TRUE)
*val = "default";
diff --git a/src/session.c b/src/session.c
index cc9d5491..2cde189b 100644
--- a/src/session.c
+++ b/src/session.c
@@ -262,7 +262,7 @@ static int policy_get_bool(struct connman_session *session, const char *id,
return -EINVAL;
}
- return (*session->policy->get_bool)(id, key, val);
+ return (*session->policy->get_bool)(session, key, val);
}
static int policy_get_string(struct connman_session *session, const char *id,
@@ -273,7 +273,7 @@ static int policy_get_string(struct connman_session *session, const char *id,
return -EINVAL;
}
- return (*session->policy->get_string)(id, key, val);
+ return (*session->policy->get_string)(session, key, val);
}
static int assign_policy_plugin(struct connman_session *session)
@@ -344,37 +344,11 @@ static gint compare_priority(gconstpointer a, gconstpointer b)
return policy2->priority - policy1->priority;
}
-static struct connman_session *session_lookup_by_id(const char *id)
-{
- struct connman_session *session;
- GHashTableIter iter;
- gpointer key, value;
-
- DBG("id %s", id);
-
- g_hash_table_iter_init(&iter, session_hash);
-
- while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
- session = value;
-
- if (g_strcmp0(session->owner, id) == FALSE)
- continue;
-
- return session;
- }
-
- DBG("No session found by id %s", id);
-
- return NULL;
-}
-
-int connman_session_update_bool(const char *id, const char *key,
+int connman_session_update_bool(struct connman_session *session, const char *key,
connman_bool_t val)
{
- struct connman_session *session;
struct session_info *info;
- session = session_lookup_by_id(id);
if (session == NULL)
return -EINVAL;
@@ -387,13 +361,11 @@ int connman_session_update_bool(const char *id, const char *key,
return -EINVAL;
}
-int connman_session_update_string(const char *id, const char *key,
+int connman_session_update_string(struct connman_session *session, const char *key,
const char *val)
{
- struct connman_session *session;
struct session_info *info;
- session = session_lookup_by_id(id);
if (session == NULL)
return -EINVAL;