From: Jaehyun Kim Date: Thu, 30 Nov 2023 04:14:48 +0000 (+0900) Subject: Fix "Modified" is missing when saving wifi config X-Git-Tag: accepted/tizen/unified/riscv/20231220.131734^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0b63c0d699f4d7087da73f1d2744ddaad98bf4d4;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git Fix "Modified" is missing when saving wifi config Change-Id: I9c9daeb653a756d564d2d471760cd31a6283a1e5 Signed-off-by: Jaehyun Kim --- diff --git a/src/wifi-config.c b/src/wifi-config.c index c172345..909c5c5 100755 --- a/src/wifi-config.c +++ b/src/wifi-config.c @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -1222,6 +1223,8 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context, gchar *field; gchar *group_name = NULL; int order = 0; + int rv; + struct timeval modified_time; if ((wifi == NULL) || (config_id == NULL) || (configuration == NULL)) { ERR("Invalid parameter"); @@ -1373,31 +1376,22 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context, g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_FAVORITE, conf->favorite); g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_AUTOCONNECT, conf->autoconnect); -#if GLIB_CHECK_VERSION(2,62,0) - gint64 real_time = 0; - GDateTime *dt_real_time = NULL; - - real_time = g_get_real_time(); - dt_real_time = g_date_time_new_from_unix_utc(real_time); - if (dt_real_time) { - gchar *str = g_date_time_format_iso8601(dt_real_time); - g_date_time_unref(dt_real_time); - if (str) { - g_key_file_set_string(keyfile, group_name, - WIFI_CONFIG_MODIFIED, str); - g_free(str); + rv = gettimeofday(&modified_time, NULL); + if (!rv) { + struct tm modified_tm; + char time_buf[255]; + time_t modified_t = modified_time.tv_sec; + + if (localtime_r(&modified_t, &modified_tm)) { + if (strftime(time_buf, sizeof(time_buf), "%FT%TZ", &modified_tm)) { + field = g_strdup(time_buf); + if (field) { + g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_MODIFIED, field); + g_free(field); + } + } } } -#else /* GLIB_CHECK_VERSION(2,62,0) */ - GTimeVal modified; - g_get_current_time(&modified); - gchar *str = g_time_val_to_iso8601(&modified); - if (str) { - g_key_file_set_string(keyfile, group_name, - WIFI_CONFIG_MODIFIED, str); - g_free(str); - } -#endif /* GLIB_CHECK_VERSION(2,62,0) */ /* Optional field */ if (conf->proxy_address != NULL) {