[PATCH 3/4] main: get the country code from connman.conf

jmassot at aldebaran-robotics.com jmassot at aldebaran-robotics.com
Fri Feb 10 01:47:07 PST 2012


From: Julien Massot <jmassot at aldebaran-robotics.com>

---
 include/setting.h |    1 +
 src/main.c        |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/setting.h b/include/setting.h
index 78adad7..fb42992 100644
--- a/include/setting.h
+++ b/include/setting.h
@@ -27,6 +27,7 @@ extern "C" {
 #endif
 
 connman_bool_t connman_setting_get_bool(const char *key);
+const char *connman_setting_get_string(const char *key);
 
 #ifdef __cplusplus
 }
diff --git a/src/main.c b/src/main.c
index 28337af..78530e9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -44,8 +44,10 @@
 
 static struct {
 	connman_bool_t bg_scan;
+	char *reg_dom;
 } connman_settings  = {
 	.bg_scan = TRUE,
+	.reg_dom = NULL,
 };
 
 static GKeyFile *load_config(const char *file)
@@ -75,6 +77,7 @@ static void parse_config(GKeyFile *config)
 {
 	GError *error = NULL;
 	gboolean boolean;
+	char *regdom;
 
 	if (config == NULL)
 		return;
@@ -87,6 +90,13 @@ static void parse_config(GKeyFile *config)
 		connman_settings.bg_scan = boolean;
 
 	g_clear_error(&error);
+
+	regdom = g_key_file_get_string(config, "General",
+						"RegulatoryDomain", &error);
+	if (error == NULL)
+		connman_settings.reg_dom = regdom;
+
+	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;
 }
 
+const char *connman_setting_get_string(const char *key)
+{
+	if (g_str_equal(key, "RegulatoryDomain") == TRUE)
+		return connman_settings.reg_dom;
+
+	return NULL;
+}
+
 int main(int argc, char *argv[])
 {
 	GOptionContext *context;
-- 
1.7.5.4




More information about the connman mailing list