summaryrefslogtreecommitdiff
path: root/src/session.c
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2013-06-07 13:41:10 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-06-10 09:48:22 +0300
commit934226962d3caaa538e1424eba9364915bbe7278 (patch)
tree6071f8ac7e5808976dc4e66e23766b16df4b3325 /src/session.c
parent2386b677cb7223094b3348d852514df06d39b16b (diff)
downloadconnman-934226962d3caaa538e1424eba9364915bbe7278.tar.gz
connman-934226962d3caaa538e1424eba9364915bbe7278.tar.bz2
connman-934226962d3caaa538e1424eba9364915bbe7278.zip
session: Use service iterator instead of match/creation callbacks
When a new session is created we need to get the initial list of services which match the session AllowedBearers criteria. As soon the session is running add or removed services are tracked via the notifier interface. We concluded that exposing all the services is not really necessary and therefore we are using currently two callbacks to get the initial list. That exposes implementation details from session to service, that is GSequence. We also need to expose the type 'struct service_entry'. Instead doing so we are using an iterator and keep all the implementation details in session.c.
Diffstat (limited to 'src/session.c')
-rw-r--r--src/session.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/session.c b/src/session.c
index bdb22d0c..98b22db3 100644
--- a/src/session.c
+++ b/src/session.c
@@ -1245,6 +1245,24 @@ static struct service_entry *create_service_entry(struct connman_session * sessi
return entry;
}
+static void iterate_service_cb(struct connman_service *service,
+ const char *name,
+ enum connman_service_state state,
+ void *user_data)
+{
+ struct connman_session *session = user_data;
+ struct service_entry *entry;
+
+ if (service_match(session, service) == FALSE)
+ return;
+
+ entry = create_service_entry(session, service, name, state);
+ if (entry == NULL)
+ return;
+
+ g_sequence_append(session->service_list, entry);
+}
+
static void destroy_service_entry(gpointer data)
{
struct service_entry *entry = data;
@@ -1270,10 +1288,8 @@ static void populate_service_list(struct connman_session *session)
session->service_hash =
g_hash_table_new_full(g_direct_hash, g_direct_equal,
NULL, NULL);
- session->service_list = __connman_service_get_list(session,
- service_match,
- create_service_entry,
- destroy_service_entry);
+ session->service_list = g_sequence_new(destroy_service_entry);
+ __connman_service_iterate_services(iterate_service_cb, session);
g_sequence_sort(session->service_list, sort_services, session);