Merge tag 'upstream/1.40' into tizen.
[platform/upstream/connman.git] / vpn / vpn-config.c
old mode 100644 (file)
new mode 100755 (executable)
index 293c64e..e412b89
@@ -203,7 +203,11 @@ static int load_provider(GKeyFile *keyfile, const char *group,
                                struct vpn_config *config, enum what action)
 {
        struct vpn_config_provider *config_provider;
+#if !defined TIZEN_EXT
        const char *ident, *host, *domain;
+#else
+       const char *ident, *host, *domain, *name;
+#endif
        int err;
 
        /* Strip off "provider_" prefix */
@@ -229,8 +233,14 @@ static int load_provider(GKeyFile *keyfile, const char *group,
 
        host = get_string(config_provider, "Host");
        domain = get_string(config_provider, "Domain");
-       if (host && domain) {
+#if !defined TIZEN_EXT
+       if (host) {
                char *id = __vpn_provider_create_identifier(host, domain);
+#else
+       name = get_string(config_provider, "Name");
+       if (host && name) {
+               char *id = __vpn_provider_create_identifier(host, domain, name);
+#endif
 
                struct vpn_provider *provider;
                provider = __vpn_provider_lookup(id);
@@ -252,7 +262,11 @@ static int load_provider(GKeyFile *keyfile, const char *group,
 
                DBG("provider identifier %s", id);
        } else {
+#if !defined TIZEN_EXT
                DBG("invalid values host %s domain %s", host, domain);
+#else
+               DBG("invalid configuration: no host specified");
+#endif
                err = -EINVAL;
                goto err;
        }
@@ -261,9 +275,6 @@ static int load_provider(GKeyFile *keyfile, const char *group,
        config_provider->config_entry = g_strdup_printf("provider_%s",
                                                config_provider->ident);
 
-       g_hash_table_insert(config->provider_table,
-                               config_provider->ident, config_provider);
-
        err = __vpn_provider_create_from_config(
                                        config_provider->setting_strings,
                                        config_provider->config_ident,
@@ -274,6 +285,10 @@ static int load_provider(GKeyFile *keyfile, const char *group,
                goto err;
        }
 
+       g_hash_table_insert(config->provider_table, config_provider->ident,
+                               config_provider);
+
+
        connman_info("Added provider configuration %s",
                                                config_provider->ident);
        return 0;
@@ -484,12 +499,12 @@ static void config_notify_handler(struct inotify_event *event,
        if (event->mask & IN_CREATE)
                return;
 
-       if (event->mask & IN_DELETE) {
+       if (event->mask & (IN_DELETE | IN_MOVED_FROM)) {
                g_hash_table_remove(config_table, ident);
                return;
        }
 
-       if (event->mask & IN_MODIFY) {
+       if (event->mask & (IN_MODIFY | IN_MOVED_TO)) {
                struct vpn_config *config;
                char *path = get_dir();
 
@@ -579,3 +594,18 @@ char **__vpn_config_get_string_list(GKeyFile *key_file,
 
        return strlist;
 }
+
+bool __vpn_config_get_boolean(GKeyFile *key_file, const char *group_name,
+                       const char *key, bool default_value)
+{
+       GError *error = NULL;
+       bool val;
+
+       val = g_key_file_get_boolean(key_file, group_name, key, &error);
+       if (error) {
+               g_error_free(error);
+               return default_value;
+       }
+
+       return val;
+}