main: Parse FallbackTimeservers list from main.conf
authorAlok Barsode <alok.barsode@linux.intel.com>
Thu, 5 Apr 2012 10:20:23 +0000 (13:20 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Thu, 5 Apr 2012 15:56:43 +0000 (18:56 +0300)
include/setting.h
src/main.c

index 78adad7..3ea631a 100644 (file)
@@ -27,6 +27,7 @@ extern "C" {
 #endif
 
 connman_bool_t connman_setting_get_bool(const char *key);
+char **connman_setting_get_string_list(const char *key);
 
 #ifdef __cplusplus
 }
index ded3bb1..6e0d64d 100644 (file)
 
 static struct {
        connman_bool_t bg_scan;
+       char **pref_timeservers;
 } connman_settings  = {
        .bg_scan = TRUE,
+       .pref_timeservers = NULL,
 };
 
 static GKeyFile *load_config(const char *file)
@@ -75,6 +77,7 @@ static void parse_config(GKeyFile *config)
 {
        GError *error = NULL;
        gboolean boolean;
+       char **timeservers;
 
        if (config == NULL)
                return;
@@ -87,6 +90,13 @@ static void parse_config(GKeyFile *config)
                connman_settings.bg_scan = boolean;
 
        g_clear_error(&error);
+
+       timeservers = g_key_file_get_string_list(config, "General",
+                                               "FallbackTimeservers", NULL, &error);
+       if (error == NULL)
+               connman_settings.pref_timeservers = timeservers;
+
+       g_clear_error(&error);
 }
 
 static GMainLoop *main_loop = NULL;
@@ -237,6 +247,14 @@ connman_bool_t connman_setting_get_bool(const char *key)
        return FALSE;
 }
 
+char **connman_setting_get_string_list(const char *key)
+{
+       if (g_str_equal(key, "FallbackTimeservers") == TRUE)
+               return connman_settings.pref_timeservers;
+
+       return NULL;
+}
+
 int main(int argc, char *argv[])
 {
        GOptionContext *context;
@@ -419,6 +437,9 @@ int main(int argc, char *argv[])
        if (config)
                g_key_file_free(config);
 
+       if (connman_settings.pref_timeservers != NULL)
+               g_strfreev(connman_settings.pref_timeservers);
+
        g_free(option_debug);
 
        return 0;