diff options
author | Jeonghoon Park <jh1979.park@samsung.com> | 2018-06-14 07:32:17 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.ap-northeast-2.compute.internal> | 2018-06-14 07:32:17 +0000 |
commit | 767f6b79716ae0d66aa23af898c7ee48f9dcef7d (patch) | |
tree | 5377b24ad4da4b0fd5ad3bdc96f97eb4a00b3a6c /daemon | |
parent | 6f78bdb92c89484e76d9f2936d36d85bb4c453bf (diff) | |
parent | f33611b0edde5ba79c9fbf483ffb0cd2927262e8 (diff) | |
download | tizen-things-daemon-767f6b79716ae0d66aa23af898c7ee48f9dcef7d.tar.gz tizen-things-daemon-767f6b79716ae0d66aa23af898c7ee48f9dcef7d.tar.bz2 tizen-things-daemon-767f6b79716ae0d66aa23af898c7ee48f9dcef7d.zip |
Merge "apply config module"
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/include/ttd-config.h | 1 | ||||
-rw-r--r-- | daemon/src/tizen-things-daemon.c | 6 | ||||
-rw-r--r-- | daemon/src/ttd-config.c | 40 |
3 files changed, 25 insertions, 22 deletions
diff --git a/daemon/include/ttd-config.h b/daemon/include/ttd-config.h index ed5abab..71f9c28 100644 --- a/daemon/include/ttd-config.h +++ b/daemon/include/ttd-config.h @@ -19,7 +19,6 @@ #include <stdbool.h> -#define CONFIG_PATH_MAX 1024 #define TTD_SETTING_INFO "setting" #define TTD_SETTING_DISCONNECTED_LIMIT_TIME "network_disconnected_limit" diff --git a/daemon/src/tizen-things-daemon.c b/daemon/src/tizen-things-daemon.c index 880c1c2..6e6dc54 100644 --- a/daemon/src/tizen-things-daemon.c +++ b/daemon/src/tizen-things-daemon.c @@ -181,6 +181,7 @@ int main(int argc, char* argv[]) d_data = calloc(1, sizeof(ttd_data)); ttd_log_init(TTD_LOG_TYPE_ALL); + ttd_config_init(); d_data->mainloop = g_main_loop_new(NULL, FALSE); @@ -190,8 +191,9 @@ int main(int argc, char* argv[]) vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, __system_time_changed, d_data); - ttd_conn_mgr_init(); ttd_http_init(); + ttd_conn_mgr_init(); + ttd_cloud_conn_state_set(TTD_CLOUD_CONN_STATE_DISCONNECTED); ttd_worker_interface_init(&(d_data->worker_itf_h)); @@ -215,7 +217,7 @@ int main(int argc, char* argv[]) ttd_conn_mgr_fini(); ttd_http_fini(); - + ttd_config_fini(); ttd_log_fini(); return 0; diff --git a/daemon/src/ttd-config.c b/daemon/src/ttd-config.c index 699c7cf..0ba9dc3 100644 --- a/daemon/src/ttd-config.c +++ b/daemon/src/ttd-config.c @@ -26,22 +26,20 @@ #define CONF_FILE_NAME "ttd.conf" #define CONF_PATH tzplatform_mkpath3(TZ_SYS_ETC, "ttd", "ttd.conf") -GKeyFile *gkf = NULL; -int is_initialized = 0; +static GKeyFile *gkf = NULL; int ttd_config_init(void) { - gkf = g_key_file_new(); - retv_if(!gkf, -1); + GKeyFile *tmp_gkf = NULL; + tmp_gkf = g_key_file_new(); + retv_if(!tmp_gkf, -1); - if (!g_key_file_load_from_file(gkf, CONF_PATH, G_KEY_FILE_NONE, NULL)) { + if (!g_key_file_load_from_file(tmp_gkf, CONF_PATH, G_KEY_FILE_NONE, NULL)) { _E("Failed to load conf file"); - ttd_config_fini(); + g_key_file_free(tmp_gkf); return -1; } - - is_initialized = 1; - + gkf = tmp_gkf; return 0; } @@ -49,6 +47,8 @@ void ttd_config_fini(void) { if (gkf) g_key_file_free(gkf); + + gkf = NULL; } int ttd_config_read_integer(const char *group, const char *key, int *value) @@ -58,8 +58,9 @@ int ttd_config_read_integer(const char *group, const char *key, int *value) retv_if(!group, -1); retv_if(!key, -1); + retv_if(!value, -1); - if (!is_initialized) { + if (!gkf) { if (ttd_config_init() < 0) { _E("Failed to initialize configure"); return -1; @@ -85,8 +86,9 @@ int ttd_config_read_boolean(const char *group, const char *key, bool *value) retv_if(!group, -1); retv_if(!key, -1); + retv_if(!value, -1); - if (!is_initialized) { + if (!gkf) { if (ttd_config_init() < 0) { _E("Failed to initialize configure"); return -1; @@ -112,8 +114,9 @@ int ttd_config_read_string(const char *group, const char *key, char **value) retv_if(!group, -1); retv_if(!key, -1); + retv_if(!value, -1); - if (!is_initialized) { + if (!gkf) { if (ttd_config_init() < 0) { _E("Failed to initialize configure"); return -1; @@ -136,9 +139,8 @@ int ttd_config_write_integer(const char *group, const char *key, int value) { retv_if(!group, -1); retv_if(!key, -1); - retv_if(!value, -1); - if (!is_initialized) { + if (!gkf) { if (ttd_config_init() < 0) { _E("Failed to initialize configure"); return -1; @@ -154,9 +156,8 @@ int ttd_config_write_boolean(const char *group, const char *key, bool value) { retv_if(!group, -1); retv_if(!key, -1); - retv_if(!value, -1); - if (!is_initialized) { + if (!gkf) { if (ttd_config_init() < 0) { _E("Failed to initialize configure"); return -1; @@ -174,7 +175,7 @@ int ttd_config_write_string(const char *group, const char *key, const char *valu retv_if(!key, -1); retv_if(!value, -1); - if (!is_initialized) { + if (!gkf) { if (ttd_config_init() < 0) { _E("Failed to initialize configure"); return -1; @@ -193,7 +194,7 @@ int ttd_config_remove_group(const char *group) retv_if(!group, -1); - if (!is_initialized) { + if (!gkf) { if (ttd_config_init() < 0) { _E("Failed to initialize configure"); return -1; @@ -215,9 +216,10 @@ int ttd_config_remove_key(const char *group, const char *key) gboolean ret = FALSE; GError *error = NULL; + retv_if(!group, -1); retv_if(!key, -1); - if (!is_initialized) { + if (!gkf) { if (ttd_config_init() < 0) { _E("Failed to initialize configure"); return -1; |