From: Daniel Wagner <[email protected]>
Create new config objects per file found under
/var/lib/connman/policy_session_ivi.
---
plugins/session_policy_ivi.c | 63 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/plugins/session_policy_ivi.c b/plugins/session_policy_ivi.c
index 9401754..e5ead6a 100644
--- a/plugins/session_policy_ivi.c
+++ b/plugins/session_policy_ivi.c
@@ -24,6 +24,7 @@
#endif
#include <errno.h>
+#include <string.h>
#include <glib.h>
@@ -36,6 +37,8 @@
#include <connman/session.h>
#include <connman/dbus.h>
+#define POLICYDIR STORAGEDIR "/session_policy_ivi"
+
static DBusConnection *connection;
static GHashTable *session_hash;
@@ -48,6 +51,7 @@ struct create_data {
};
struct policy_data {
+ char *ident;
struct connman_session *session;
struct connman_session_config *config;
@@ -61,6 +65,7 @@ static void cleanup_policy(struct policy_data *policy)
if (policy->config != NULL)
connman_session_free_bearers(policy->config->allowed_bearers);
+ g_free(policy->ident);
g_free(policy->config);
g_free(policy);
}
@@ -197,6 +202,62 @@ static struct connman_session_policy session_policy_ivi = {
.destroy = policy_ivi_destroy,
};
+static int load_policy(struct policy_data *policy)
+{
+ return 0;
+}
+
+static struct policy_data *create_policy(const char *ident)
+{
+ struct policy_data *policy;
+
+ DBG("ident %s", ident);
+
+ policy = g_hash_table_lookup(ident_hash, ident);
+ if (policy != NULL)
+ return policy;
+
+ policy = g_try_new0(struct policy_data, 1);
+ if (policy == NULL)
+ return NULL;
+
+ policy->ident = g_strdup(ident);
+ policy->config = connman_session_create_default_config();
+
+ if (policy->ident == NULL || policy->config == NULL) {
+ cleanup_policy(policy);
+ return NULL;
+ }
+
+ g_hash_table_replace(ident_hash, g_strdup(ident), policy);
+
+ return policy;
+}
+
+static int read_policies(void)
+{
+ GDir *dir;
+
+ 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)
+ load_policy(policy);
+ }
+
+ g_dir_close(dir);
+ }
+
+ return 0;
+}
+
static int session_policy_ivi_init(void)
{
int err;
@@ -225,6 +286,8 @@ static int session_policy_ivi_init(void)
goto err;
}
+ read_policies();
+
return 0;
err:
--
1.8.0.rc0
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman