From c428442146285cac169ea7a29b0fe7d928fda997 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Fri, 2 Nov 2012 17:26:22 +0100 Subject: [PATCH] session_policy_ivi: Add hash table to track idents Introduce the second hash table which tracks the config object lifetime based on the file existens. The parsing of the file and creation of the config object is part of the next patch. --- plugins/session_policy_ivi.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/plugins/session_policy_ivi.c b/plugins/session_policy_ivi.c index b5c3685..039f3b4 100644 --- a/plugins/session_policy_ivi.c +++ b/plugins/session_policy_ivi.c @@ -24,6 +24,7 @@ #endif #include +#include #include @@ -35,6 +36,8 @@ #include #include +#define POLICYDIR STORAGEDIR "/session_policy_ivi" + static DBusConnection *connection; static GHashTable *policy_hash; @@ -238,6 +241,42 @@ static struct connman_session_policy session_policy_ivi = { .destroy = policy_ivi_destroy, }; +static int load_policy(struct policy_data *policy) +{ + return 0; +} + +static int read_policies(void) +{ + GDir *dir; + int err = 0; + + DBG(""); + + dir = g_dir_open(POLICYDIR, 0, NULL); + if (dir != NULL) { + const gchar *file; + + while ((file = g_dir_read_name(dir)) != NULL) { + struct policy_data *policy; + + policy = create_policy(file); + if (policy == NULL) { + err = -ENOMEM; + break; + } + + err = load_policy(policy); + if (err < 0) + break; + } + + g_dir_close(dir); + } + + return err; +} + static int session_policy_ivi_init(void) { int err; @@ -266,6 +305,10 @@ static int session_policy_ivi_init(void) goto err; } + err = read_policies(); + if (err < 0) + goto err; + return 0; err: -- 2.7.4