[PATCH v3 05/15] session: Update sessions on config updates

Daniel Wagner wagi at monom.org
Fri Nov 2 09:26:14 PDT 2012


From: Daniel Wagner <daniel.wagner at bmw-carit.de>

Give a policy plugin a way to inform the session core that
some of the config values have changed.

This could be done in a more clever way, e.g. figure out only
to update the necessary info entries but we keep it for now
as simple and assume everthing has changed.
---
 include/session.h |  2 ++
 src/session.c     | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/include/session.h b/include/session.h
index b93fbc7..cbed939 100644
--- a/include/session.h
+++ b/include/session.h
@@ -75,6 +75,8 @@ struct connman_session_policy {
 int connman_session_policy_register(struct connman_session_policy *config);
 void connman_session_policy_unregister(struct connman_session_policy *config);
 
+void connman_session_config_update(struct connman_session *session);
+
 struct connman_session_config *connman_session_create_default_config(void);
 
 #ifdef __cplusplus
diff --git a/src/session.c b/src/session.c
index 77a6c85..ff12a35 100644
--- a/src/session.c
+++ b/src/session.c
@@ -1341,6 +1341,44 @@ static void session_changed(struct connman_session *session,
 	session_notify(session);
 }
 
+void connman_session_config_update(struct connman_session *session)
+{
+	struct session_info *info = session->info;
+	GSList *allowed_bearers;
+	int err;
+
+	DBG("session %p", session);
+
+	/*
+	 * We update all configuration even though only one entry
+	 * might have changed. We can still optimize this later.
+	 */
+
+	err = apply_policy_on_bearers(
+		session->policy_config->allowed_bearers,
+		info->config.allowed_bearers,
+		&allowed_bearers);
+	if (err < 0)
+		return;
+
+	g_slist_free(info->config.allowed_bearers);
+	info->config.allowed_bearers = allowed_bearers;
+
+	info->config.type = apply_policy_on_type(
+				session->policy_config->type,
+				info->config.type);
+
+	info->config.roaming_policy = session->policy_config->roaming_policy;
+
+	info->config.ecall = session->policy_config->ecall;
+	if (info->config.ecall == TRUE)
+		ecall_session = session;
+
+	info->config.priority = session->policy_config->priority;
+
+	session_changed(session, CONNMAN_SESSION_TRIGGER_SETTING);
+}
+
 static DBusMessage *connect_session(DBusConnection *conn,
 					DBusMessage *msg, void *user_data)
 {
-- 
1.7.11.7




More information about the connman mailing list