main: Add 'PreferredTechnologies' configuration file option
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Thu, 5 Apr 2012 19:38:40 +0000 (22:38 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 11 Apr 2012 12:25:29 +0000 (15:25 +0300)
The main.conf 'PreferredTechnologies' is a list of service
type strings but converted to a list of service type enums.
Thus the configuration option is accessible via the function
connman_setting_get_uint_list().

src/main.c

index 354734d..9feab70 100644 (file)
@@ -46,10 +46,12 @@ static struct {
        connman_bool_t bg_scan;
        char **pref_timeservers;
        unsigned int *auto_connect;
+       unsigned int *preferred_techs;
 } connman_settings  = {
        .bg_scan = TRUE,
        .pref_timeservers = NULL,
        .auto_connect = NULL,
+       .preferred_techs = NULL,
 };
 
 static GKeyFile *load_config(const char *file)
@@ -146,6 +148,17 @@ static void parse_config(GKeyFile *config)
        g_strfreev(str_list);
 
        g_clear_error(&error);
+
+       str_list = g_key_file_get_string_list(config, "General",
+                       "PreferredTechnologies", &len, &error);
+
+       if (error == NULL)
+               connman_settings.preferred_techs =
+                       parse_service_types(str_list, len);
+
+       g_strfreev(str_list);
+
+       g_clear_error(&error);
 }
 
 static GMainLoop *main_loop = NULL;
@@ -309,6 +322,9 @@ unsigned int *connman_setting_get_uint_list(const char *key)
        if (g_str_equal(key, "DefaultAutoConnectTechnologies") == TRUE)
                return connman_settings.auto_connect;
 
+       if (g_str_equal(key, "PreferredTechnologies") == TRUE)
+               return connman_settings.preferred_techs;
+
        return NULL;
 }
 
@@ -497,6 +513,7 @@ int main(int argc, char *argv[])
                g_strfreev(connman_settings.pref_timeservers);
 
        g_free(connman_settings.auto_connect);
+       g_free(connman_settings.preferred_techs);
 
        g_free(option_debug);