config: Add configuration protected flag
authorSamuel Ortiz <sameo@linux.intel.com>
Fri, 8 Apr 2011 18:08:33 +0000 (20:08 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 11 Apr 2011 10:02:44 +0000 (12:02 +0200)
doc/config-format.txt
src/config.c

index f3c8f01..7f23c76 100644 (file)
@@ -16,6 +16,9 @@ These files can have an optional global entry describing the actual file.
 The 2 allowed fields for that entry are:
 - Name: Name of the network.
 - Description: Description of the network.
+- Protected: Configuration protection against being removed, modified or
+overwritten by a Manager.ProvisionService() call. By default, a configuration
+is not protected.
 
 
 Service entry [service_*]
index d27fb73..98da9d0 100644 (file)
@@ -54,6 +54,7 @@ struct connman_config {
        char *ident;
        char *name;
        char *description;
+       connman_bool_t protected;
        GHashTable *service_table;
 };
 
@@ -69,6 +70,7 @@ static uint inotify_watch = 0;
 /* Definition of possible strings in the .config files */
 #define CONFIG_KEY_NAME                "Name"
 #define CONFIG_KEY_DESC                "Description"
+#define CONFIG_KEY_PROT                "Protected"
 
 #define SERVICE_KEY_TYPE               "Type"
 #define SERVICE_KEY_NAME               "Name"
@@ -86,6 +88,7 @@ static uint inotify_watch = 0;
 static const char *config_possible_keys[] = {
        CONFIG_KEY_NAME,
        CONFIG_KEY_DESC,
+       CONFIG_KEY_PROT,
        NULL,
 };
 
@@ -323,6 +326,7 @@ static int load_config(struct connman_config *config)
        gsize length;
        char **groups;
        char *str;
+       gboolean protected;
        int i;
 
        DBG("config %p", config);
@@ -346,6 +350,10 @@ static int load_config(struct connman_config *config)
                config->description = str;
        }
 
+       protected = g_key_file_get_boolean(keyfile, "global",
+                                       CONFIG_KEY_PROT, NULL);
+       config->protected = protected;
+
        groups = g_key_file_get_groups(keyfile, &length);
 
        for (i = 0; groups[i] != NULL; i++) {