Replace deprecated APIs of Glib v2.62.3 with suggested GLib APIs
[platform/core/connectivity/net-config.git] / src / wifi-config.c
index e81bc43..97b9c6d 100755 (executable)
@@ -87,7 +87,6 @@ struct wifi_config {
        gchar *security_type;
        gboolean favorite;
        gboolean autoconnect;
-       GTimeVal modified;
        gchar *is_hidden;
        gboolean is_created;
        gchar *proxy_address;
@@ -1301,13 +1300,32 @@ 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);
-       g_get_current_time(&conf->modified);
-       gchar *str = g_time_val_to_iso8601(&conf->modified);
+
+#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);
+               }
+       }
+#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);
+                                     WIFI_CONFIG_MODIFIED, str);
                g_free(str);
        }
+#endif /* GLIB_CHECK_VERSION(2,62,0) */
 
        /* Optional field */
        if (conf->proxy_address != NULL) {
@@ -1374,7 +1392,7 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
                                        if (__remove_configuration(profileName) != TRUE)
                                                DBG("Failed to remove profile: [%s]", profileName);
                                } else
-                                       ERR("Profile: [%s] does not exist", profileName);
+                                       ERR("Profile: [%s] does not exist", file);
 
                                g_free(profileName);
                        }