[PATCH v3 08/15] session: Store user AllowedBearers configuration

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


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

Don't overwrite the user provided AllowedBearers
configuration. Instead just store it at session level. So we always
will apply the bearer filter on the user input.

Obviously, this might need some more improvements on how we want
to handle the AllowedBearers behavior when the policy plugin and
the application provide a configuration. For exmaple should
we update the AllowedBearers if the policy changes or just always
show only the user input. This patch is not perfect but it
improves the situation clearly.
---
 src/session.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/session.c b/src/session.c
index a7dbe50..a896503 100644
--- a/src/session.c
+++ b/src/session.c
@@ -89,6 +89,7 @@ struct connman_session {
 	struct session_info *info;
 	struct session_info *info_last;
 	struct connman_session_config *policy_config;
+	GSList *user_allowed_bearers;
 
 	connman_bool_t ecall;
 
@@ -867,6 +868,7 @@ static void cleanup_session(gpointer user_data)
 
 	DBG("remove %s", session->session_path);
 
+	g_slist_free(session->user_allowed_bearers);
 	g_hash_table_destroy(session->service_hash);
 	g_sequence_free(session->service_list);
 
@@ -1382,7 +1384,7 @@ void connman_session_config_update(struct connman_session *session)
 
 	err = apply_policy_on_bearers(
 		session->policy_config->allowed_bearers,
-		info->config.allowed_bearers,
+		session->user_allowed_bearers,
 		&allowed_bearers);
 	if (err < 0)
 		return;
@@ -1477,12 +1479,13 @@ static DBusMessage *change_session(DBusConnection *conn,
 				return __connman_error_failed(msg, err);
 
 			g_slist_free(info->config.allowed_bearers);
+			session->user_allowed_bearers = allowed_bearers;
+
 			err = apply_policy_on_bearers(
 					session->policy_config->allowed_bearers,
-					allowed_bearers,
+					session->user_allowed_bearers,
 					&info->config.allowed_bearers);
 
-			g_slist_free(allowed_bearers);
 			if (err < 0)
 				return __connman_error_failed(msg, err);
 		} else {
@@ -1624,9 +1627,11 @@ static void session_create_cb(struct connman_session *session,
 	info->config.roaming_policy = session->policy_config->roaming_policy;
 	info->entry = NULL;
 
+	session->user_allowed_bearers = user_config->allowed_bearers;
+
 	err = apply_policy_on_bearers(
 			session->policy_config->allowed_bearers,
-			user_config->allowed_bearers,
+			session->user_allowed_bearers,
 			&info->config.allowed_bearers);
 	if (err < 0)
 		goto out;
@@ -1669,7 +1674,6 @@ out:
 	}
 
 	dbus_message_unref(user_config->pending);
-	g_slist_free(user_config->allowed_bearers);
 	g_free(user_config);
 }
 
-- 
1.7.11.7




More information about the connman mailing list