summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2012-08-13 10:40:23 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-08-30 13:01:49 +0300
commitc7cd2709d524d8e5d7ee2f6ec1eff2166b4f1239 (patch)
treeee15ed8f7b2a5b994c627504ebaefeb68d389826 /src
parent3754e3487c99d2ddd5a5bd672daeca150fda1398 (diff)
downloadconnman-c7cd2709d524d8e5d7ee2f6ec1eff2166b4f1239.tar.gz
connman-c7cd2709d524d8e5d7ee2f6ec1eff2166b4f1239.tar.bz2
connman-c7cd2709d524d8e5d7ee2f6ec1eff2166b4f1239.zip
session: Add configuration plugin
Diffstat (limited to 'src')
-rw-r--r--src/session.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/session.c b/src/session.c
index 64e18b46..a1341d78 100644
--- a/src/session.c
+++ b/src/session.c
@@ -28,12 +28,15 @@
#include <gdbus.h>
+#include <connman/session.h>
+
#include "connman.h"
static DBusConnection *connection;
static GHashTable *session_hash;
static connman_bool_t sessionmode;
static struct session_info *ecall_info;
+static struct connman_session_config *session_config;
enum connman_session_trigger {
CONNMAN_SESSION_TRIGGER_UNKNOWN = 0,
@@ -1898,6 +1901,98 @@ static struct connman_notifier session_notifier = {
.ipconfig_changed = ipconfig_changed,
};
+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,
+ connman_bool_t val)
+{
+ struct connman_session *session;
+ struct session_info *info;
+
+ session = session_lookup_by_id(id);
+ if (session == NULL)
+ return -EINVAL;
+
+ info = session->info;
+ if (info == NULL)
+ return 0;
+
+ DBG("%s %d", key, val);
+
+ return -EINVAL;
+}
+
+int connman_session_update_string(const char *id, 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;
+
+ info = session->info;
+ if (info == NULL)
+ return 0;
+
+ DBG("%s %s", key, val);
+
+ return -EINVAL;
+}
+
+int connman_session_config_register(struct connman_session_config *config)
+{
+ DBG("name %s", config->name);
+
+ if (session_config != NULL) {
+ connman_warn("A session configuration plugin '%s' is "
+ "already registerd. Skipping registration "
+ "of plugin '%s'",
+ session_config->name, config->name);
+ return -EALREADY;
+ }
+
+ session_config = config;
+
+ return 0;
+}
+
+void connman_session_config_unregister(struct connman_session_config *config)
+{
+ DBG("name %s", config->name);
+
+ if (config != session_config) {
+ connman_warn("Trying to unregister session configuration "
+ "plugin '%s'", config->name);
+ return;
+ }
+
+ session_config = NULL;
+}
+
int __connman_session_init(void)
{
int err;