Merge "Remove unused code" into tizen
[platform/core/connectivity/net-config.git] / src / wifi-config.c
index f6dfe44..aa2ab05 100755 (executable)
 
 #define WIFI_CONFIG_PREFIX      "wifi_"
 #define MAC_ADDRESS_LENGTH             12
-#define WIFI_PREFIX_LENGTH             MAC_ADDRESS_LENGTH + 6  // wifi_485a3f2f506a_
-#define PROFILE_PREFIX_LENGTH  WIFI_PREFIX_LENGTH + 21 // /net/connman/service/wifi_485a3f2f506a_
+#define WIFI_PREFIX_LENGTH             MAC_ADDRESS_LENGTH + 6  /* wifi_485a3f2f506a_ */
+#define PROFILE_PREFIX_LENGTH  WIFI_PREFIX_LENGTH + 21 /* /net/connman/service/wifi_485a3f2f506a_ */
+
+#define WIFI_MAC_ADD_LENGTH            17
+#define WIFI_MAC_ADD_PATH              "/sys/class/net/wlan0/address"
 
 struct wifi_eap_config {
        gchar *anonymous_identity;
@@ -79,6 +82,7 @@ static void __free_wifi_configuration(struct wifi_config *conf)
        g_free(conf->security_type);
        g_free(conf->is_hidden);
        g_free(conf->proxy_address);
+       g_free(conf->last_error);
        if (conf->eap_config) {
                g_free(conf->eap_config->anonymous_identity);
                g_free(conf->eap_config->ca_cert);
@@ -100,19 +104,46 @@ static gboolean __get_mac_address(gchar **mac_address)
        gchar mac[13] = { 0, };
        gint i = 0, j = 0;
 
-       tmp_mac = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
-       if (tmp_mac == NULL) {
-               ERR("vconf_get_str(WIFI_BSSID_ADDRESS) Failed");
-               *mac_address = NULL;
-               return FALSE;
+       if (TIZEN_TV) {
+               FILE *fp = NULL;
+               char buf[WIFI_MAC_ADD_LENGTH + 1];
+               if (0 == access(WIFI_MAC_ADD_PATH, F_OK))
+                       fp = fopen(WIFI_MAC_ADD_PATH, "r");
+
+               if (fp == NULL) {
+                       ERR("Failed to open file %s\n", WIFI_MAC_ADD_PATH);
+                       *mac_address = NULL;
+                       return FALSE;
+               }
+
+               if (fgets(buf, sizeof(buf), fp) == NULL) {
+                       ERR("Failed to get MAC info from %s\n", WIFI_MAC_ADD_PATH);
+                       *mac_address = NULL;
+                       fclose(fp);
+                       return FALSE;
+               }
+               tmp_mac = (char *)g_try_malloc0(WIFI_MAC_ADD_LENGTH + 1);
+               if (tmp_mac == NULL) {
+                       ERR("malloc() failed");
+                       *mac_address = NULL;
+                       fclose(fp);
+                       return FALSE;
+               }
+               g_strlcpy(tmp_mac, buf, WIFI_MAC_ADD_LENGTH + 1);
+               fclose(fp);
+       } else {
+               tmp_mac = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+               if (tmp_mac == NULL) {
+                       ERR("vconf_get_str(WIFI_BSSID_ADDRESS) Failed");
+                       *mac_address = NULL;
+                       return FALSE;
+               }
        }
        tmp = g_ascii_strdown(tmp_mac, (gssize)strlen(tmp_mac));
        g_free(tmp_mac);
-
-       while (tmp[i]) {
-               if (tmp[i] != ':') {
+       while (tmp && tmp[i]) {
+               if (tmp[i] != ':')
                        mac[j++] = tmp[i];
-               }
                i++;
        }
        mac[12] = '\0';
@@ -187,9 +218,10 @@ static GKeyFile *__get_configuration_keyfile(const gchar *group_name)
        keyfile = netconfig_keyfile_load(path);
        if (keyfile == NULL) {
                ERR("keyfile[%s] is NULL", path);
-               g_free(path);
        }
 
+       g_free(path);
+
        return keyfile;
 }
 
@@ -253,6 +285,8 @@ static gboolean _load_configuration(const gchar *config_id, struct wifi_config *
        }
 
        config->name = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_NAME, NULL);
+       DBG("name [%s]", config->name);
+
        ret = __get_security_type(config_id, &config->security_type);
        if (ret != TRUE) {
                ERR("Fail to _get_security_type");
@@ -260,13 +294,18 @@ static gboolean _load_configuration(const gchar *config_id, struct wifi_config *
                g_free(group_name);
                return FALSE;
        }
+       DBG("security_type [%s]", config->security_type);
+
        config->proxy_address = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PROXY_SERVER, NULL);
+       if (config->proxy_address)
+               DBG("proxy_address [%s]", config->proxy_address);
+
        hidden = g_key_file_get_boolean(keyfile, group_name, WIFI_CONFIG_HIDDEN, NULL);
-       if (hidden) {
+       if (hidden)
                config->is_hidden = g_strdup("TRUE");
-       } else {
+       else
                config->is_hidden = g_strdup("FALSE");
-       }
+       DBG("is_hidden [%s]", config->is_hidden);
 
        if (g_strcmp0(config->security_type, WIFI_SECURITY_EAP) == 0) {
                config->eap_config->anonymous_identity = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, NULL);
@@ -277,9 +316,28 @@ static gboolean _load_configuration(const gchar *config_id, struct wifi_config *
                config->eap_config->eap_type = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_TYPE, NULL);
                config->eap_config->eap_auth_type = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_AUTH_TYPE, NULL);
                config->eap_config->subject_match = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_SUBJECT_MATCH, NULL);
+
+               if (config->eap_config->anonymous_identity)
+                       DBG("anonymous_identity [%s]", config->eap_config->anonymous_identity);
+               if (config->eap_config->ca_cert)
+                       DBG("ca_cert [%s]", config->eap_config->ca_cert);
+               if (config->eap_config->client_cert)
+                       DBG("client_cert [%s]", config->eap_config->client_cert);
+               if (config->eap_config->private_key)
+                       DBG("private_key [%s]", config->eap_config->private_key);
+               if (config->eap_config->identity)
+                       DBG("identity [%s]", config->eap_config->identity);
+               if (config->eap_config->eap_type)
+                       DBG("eap_type [%s]", config->eap_config->eap_type);
+               if (config->eap_config->eap_auth_type)
+                       DBG("eap_auth_type [%s]", config->eap_config->eap_auth_type);
+               if (config->eap_config->subject_match)
+                       DBG("subject_match [%s]", config->eap_config->subject_match);
        }
 
        config->last_error = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_FAILURE, NULL);
+       if (config->last_error)
+               DBG("last_error [%s]", config->last_error);
 
        g_key_file_free(keyfile);
        g_free(group_name);
@@ -374,18 +432,18 @@ static gboolean _set_field(const gchar *config_id, const gchar *key, const gchar
        keyfile = __get_configuration_keyfile(group_name);
        if (keyfile == NULL) {
                ERR("Fail to __get_configuration_keyfile");
+               g_free(group_name);
                return FALSE;
        }
 
        if (g_strcmp0(key, WIFI_CONFIG_PROXY_METHOD) == 0) {
                g_key_file_set_string(keyfile, group_name, key, value);
-       }else if (g_strcmp0(key, WIFI_CONFIG_PROXY_SERVER) == 0) {
+       } else if (g_strcmp0(key, WIFI_CONFIG_PROXY_SERVER) == 0) {
                g_key_file_set_string(keyfile, group_name, key, value);
        } else if (g_strcmp0(key, WIFI_CONFIG_HIDDEN) == 0) {
                gboolean hidden = FALSE;
-               if (g_strcmp0(value, "TRUE") == 0) {
+               if (g_strcmp0(value, "TRUE") == 0)
                        hidden = TRUE;
-               }
                g_key_file_set_boolean(keyfile, group_name, key, hidden);
        } else if (g_strcmp0(key, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY) == 0) {
                g_key_file_set_string(keyfile, group_name, key, value);
@@ -434,6 +492,7 @@ static gboolean _get_field(const gchar *config_id, const gchar *key, gchar **val
        keyfile = __get_configuration_keyfile(group_name);
        if (keyfile == NULL) {
                ERR("Fail to __get_configuration_keyfile");
+               g_free(group_name);
                return FALSE;
        }
 
@@ -445,11 +504,10 @@ static gboolean _get_field(const gchar *config_id, const gchar *key, gchar **val
                val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PROXY_SERVER, NULL);
        } else if (g_strcmp0(key, WIFI_CONFIG_HIDDEN) == 0) {
                hidden = g_key_file_get_boolean(keyfile, group_name, WIFI_CONFIG_HIDDEN, NULL);
-               if (hidden) {
+               if (hidden)
                        val = g_strdup("TRUE");
-               } else {
+               else
                        val = g_strdup("FALSE");
-               }
        } else if (g_strcmp0(key, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY) == 0) {
                val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, NULL);
        } else if (g_strcmp0(key, WIFI_CONFIG_EAP_CACERT) == 0) {
@@ -485,7 +543,7 @@ static gboolean _get_field(const gchar *config_id, const gchar *key, gchar **val
 static GSList *_get_list(void)
 {
        GSList *list = NULL;
-       struct dirent *d;
+       struct dirent *dp = NULL;
        DIR *dir;
 
        dir = opendir(CONNMAN_STORAGE);
@@ -494,12 +552,12 @@ static GSList *_get_list(void)
                return NULL;
        }
 
-       while ((d = readdir(dir))) {
-               if (g_strcmp0(d->d_name, ".") == 0 || g_strcmp0(d->d_name, "..") == 0 ||
-                               strncmp(d->d_name, WIFI_CONFIG_PREFIX, strlen(WIFI_CONFIG_PREFIX)) != 0) {
+       while ((dp = readdir(dir)) != NULL) {
+               if (g_strcmp0(dp->d_name, ".") == 0 || g_strcmp0(dp->d_name, "..") == 0 ||
+                               strncmp(dp->d_name, WIFI_CONFIG_PREFIX, strlen(WIFI_CONFIG_PREFIX)) != 0) {
                        continue;
                }
-               gchar *config_id = g_strdup(d->d_name + WIFI_PREFIX_LENGTH);
+               gchar *config_id = g_strdup(dp->d_name + WIFI_PREFIX_LENGTH);
                list = g_slist_append(list, g_strdup(config_id));
                g_free(config_id);
        }
@@ -534,7 +592,7 @@ gboolean wifi_config_remove_configuration(const gchar *config_id)
        return ret;
 }
 
-// dbus method
+/* dbus method */
 gboolean handle_get_config_ids(Wifi *wifi, GDBusMethodInvocation *context)
 {
        guint i = 0;
@@ -561,7 +619,15 @@ gboolean handle_get_config_ids(Wifi *wifi, GDBusMethodInvocation *context)
        config_ids = g_slist_nth(config_ids, 0);
        g_slist_free_full(config_ids, g_free);
 
-       wifi_complete_get_config_ids(wifi, context, (const gchar * const*)result);
+       wifi_complete_get_config_ids(wifi, context, (const gchar * const *)result);
+
+       for (i = 0; i < length; i++)
+               if (result[i])
+                       g_free(result[i]);
+
+       if (result)
+               g_free(result);
+
        return TRUE;
 }
 
@@ -588,19 +654,19 @@ gboolean handle_load_configuration(Wifi *wifi, GDBusMethodInvocation *context,
        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(conf->name));
        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_SECURITY_TYPE, g_variant_new_string(conf->security_type));
        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string(conf->is_hidden));
-       if (conf->proxy_address != NULL) {
+
+       if (conf->proxy_address != NULL)
                g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string(conf->proxy_address));
-               g_free(conf->proxy_address);
-       } else {
+       else
                g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string("NONE"));
-       }
-       if (conf->last_error != NULL) {
+
+       if (conf->last_error != NULL)
                g_variant_builder_add(b, "{sv}", WIFI_CONFIG_FAILURE, g_variant_new_string(conf->last_error));
-               g_free(conf->last_error);
-       } else {
+       else
                g_variant_builder_add(b, "{sv}", WIFI_CONFIG_FAILURE, g_variant_new_string("ERROR_NONE"));
-       }
 
+       g_free(conf->proxy_address);
+       g_free(conf->last_error);
        g_free(conf->name);
        g_free(conf->security_type);
        g_free(conf->is_hidden);
@@ -625,12 +691,9 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
        if ((wifi == NULL) || (config_id == NULL) || (configuration == NULL)) {
                ERR("Invalid parameter");
                netconfig_error_invalid_parameter(context);
-               SLOG(LOG_INFO, "MDM_LOG_USER", "Object=wifi-profile, AccessType=Create, Result=Failed");
                return FALSE;
        }
 
-       ERR("save_configuration [%s]", config_id);
-
        conf = g_new0(struct wifi_config, 1);
 
        g_variant_get(configuration, "a{sv}", &iter);
@@ -638,35 +701,35 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
                if (g_strcmp0(field, WIFI_CONFIG_NAME) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->name = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("name [%s]", conf->name);
+                               DBG("name [%s]", conf->name);
                        } else {
                                conf->name = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_SSID) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->ssid = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("ssid [%s]", conf->ssid);
+                               DBG("ssid [%s]", conf->ssid);
                        } else {
                                conf->ssid = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_PASSPHRASE) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->passphrase = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("passphrase []");
+                               DBG("passphrase []");
                        } else {
                                conf->passphrase = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_HIDDEN) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->is_hidden = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("is_hidden [%s]", conf->is_hidden);
+                               DBG("is_hidden [%s]", conf->is_hidden);
                        } else {
                                conf->is_hidden = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_PROXYADDRESS) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->proxy_address = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("proxy_address [%s]", conf->proxy_address);
+                               DBG("proxy_address [%s]", conf->proxy_address);
                        } else {
                                conf->proxy_address = NULL;
                        }
@@ -677,6 +740,12 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
 
        ret = __get_group_name(WIFI_CONFIG_PREFIX, config_id, &group_name);
        if (ret != TRUE) {
+               g_free(conf->name);
+               g_free(conf->ssid);
+               g_free(conf->passphrase);
+               g_free(conf->is_hidden);
+               g_free(conf->proxy_address);
+               g_free(conf);
                ERR("Fail to get_wifi_config_group_name");
                return FALSE;
        }
@@ -691,7 +760,7 @@ 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);
 
-       // Optional field
+       /* Optional field */
        if (conf->proxy_address != NULL) {
                g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PROXY_METHOD, "manual");
                g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PROXY_SERVER, conf->proxy_address);
@@ -699,18 +768,17 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
 
        if (conf->is_hidden != NULL) {
                gboolean hidden = FALSE;
-               if (g_strcmp0(conf->is_hidden, "TRUE") == 0) {
+               if (g_strcmp0(conf->is_hidden, "TRUE") == 0)
                        hidden = TRUE;
-               }
                g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_HIDDEN, hidden);
        }
 
        ret = _save_configuration(config_id, keyfile);
        if (ret == TRUE) {
-               SLOG(LOG_INFO, "MDM_LOG_USER", "Object=wifi-profile, AccessType=Create, Result=Succeed");
+               INFO("Success to save configuration [%s]", config_id);
                wifi_complete_save_configuration(wifi, context);
        } else {
-               SLOG(LOG_INFO, "MDM_LOG_USER", "Object=wifi-profile, AccessType=Create, Result=Failed");
+               INFO("Fail to save configuration [%s]", config_id);
                netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailSaveConfiguration");
        }
 
@@ -752,59 +820,56 @@ gboolean handle_load_eap_configuration(Wifi *wifi, GDBusMethodInvocation *contex
        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_NAME, g_variant_new_string(conf->name));
        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_SECURITY_TYPE, g_variant_new_string(conf->security_type));
        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string(conf->is_hidden));
-       if (conf->proxy_address != NULL) {
+       if (conf->proxy_address != NULL)
                g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string(conf->proxy_address));
-               g_free(conf->proxy_address);
-       } else {
+       else
                g_variant_builder_add(b, "{sv}", WIFI_CONFIG_PROXYADDRESS, g_variant_new_string("NONE"));
-       }
-       if (conf->last_error != NULL) {
+
+       if (conf->last_error != NULL)
                g_variant_builder_add(b, "{sv}", WIFI_CONFIG_FAILURE, g_variant_new_string(conf->last_error));
-               g_free(conf->last_error);
-       } else {
+       else
                g_variant_builder_add(b, "{sv}", WIFI_CONFIG_FAILURE, g_variant_new_string("ERROR_NONE"));
-       }
+
        if (conf->eap_config != NULL) {
-               if (conf->eap_config->anonymous_identity != NULL) {
+               if (conf->eap_config->anonymous_identity != NULL)
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, g_variant_new_string(conf->eap_config->anonymous_identity));
-               } else {
+               else
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, g_variant_new_string("NONE"));
-               }
-               if (conf->eap_config->ca_cert != NULL) {
+
+               if (conf->eap_config->ca_cert != NULL)
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CACERT, g_variant_new_string(conf->eap_config->ca_cert));
-               } else {
+               else
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CACERT, g_variant_new_string("NONE"));
-               }
-               if (conf->eap_config->client_cert != NULL) {
+
+               if (conf->eap_config->client_cert != NULL)
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CLIENTCERT, g_variant_new_string(conf->eap_config->client_cert));
-               } else {
+               else
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_CLIENTCERT, g_variant_new_string("NONE"));
-               }
-               if (conf->eap_config->private_key != NULL) {
+
+               if (conf->eap_config->private_key != NULL)
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_PRIVATEKEY, g_variant_new_string(conf->eap_config->private_key));
-               } else {
+               else
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_PRIVATEKEY, g_variant_new_string("NONE"));
-               }
-               if (conf->eap_config->identity != NULL) {
+
+               if (conf->eap_config->identity != NULL)
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_IDENTITY, g_variant_new_string(conf->eap_config->identity));
-               } else {
+               else
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_IDENTITY, g_variant_new_string("NONE"));
-               }
-               if (conf->eap_config->eap_type != NULL) {
+
+               if (conf->eap_config->eap_type != NULL)
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_TYPE, g_variant_new_string(conf->eap_config->eap_type));
-               } else {
+               else
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_TYPE, g_variant_new_string("NONE"));
-               }
-               if (conf->eap_config->eap_auth_type != NULL) {
+
+               if (conf->eap_config->eap_auth_type != NULL)
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_AUTH_TYPE, g_variant_new_string(conf->eap_config->eap_auth_type));
-               } else {
+               else
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_AUTH_TYPE, g_variant_new_string("NONE"));
-               }
-               if (conf->eap_config->subject_match != NULL) {
+
+               if (conf->eap_config->subject_match != NULL)
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_SUBJECT_MATCH, g_variant_new_string(conf->eap_config->subject_match));
-               } else {
+               else
                        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_EAP_SUBJECT_MATCH, g_variant_new_string("NONE"));
-               }
        }
 
        __free_wifi_configuration(conf);
@@ -828,12 +893,9 @@ gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *contex
        if ((wifi == NULL) || (config_id == NULL) || (configuration == NULL)) {
                ERR("Invalid parameter");
                netconfig_error_invalid_parameter(context);
-               SLOG(LOG_INFO, "MDM_LOG_USER", "Object=wifi-profile, AccessType=Create, Result=Failed");
                return FALSE;
        }
 
-       INFO("save [%s]", config_id);
-
        conf = g_new0(struct wifi_config, 1);
        conf->eap_config = g_new0(struct wifi_eap_config, 1);
 
@@ -842,91 +904,91 @@ gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *contex
                if (g_strcmp0(field, WIFI_CONFIG_NAME) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->name = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("name [%s]", conf->name);
+                               DBG("name [%s]", conf->name);
                        } else {
                                conf->name = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_SSID) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->ssid = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("ssid [%s]", conf->ssid);
+                               DBG("ssid [%s]", conf->ssid);
                        } else {
                                conf->ssid = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_PASSPHRASE) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->passphrase = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("passphrase [%s]", conf->passphrase);
+                               DBG("passphrase [%s]", conf->passphrase);
                        } else {
                                conf->passphrase = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_HIDDEN) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->is_hidden = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("is_hidden [%s]", conf->is_hidden);
+                               DBG("is_hidden [%s]", conf->is_hidden);
                        } else {
                                conf->is_hidden = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_PROXYADDRESS) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->proxy_address = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("proxy_address [%s]", conf->proxy_address);
+                               DBG("proxy_address [%s]", conf->proxy_address);
                        } else {
                                conf->proxy_address = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->eap_config->anonymous_identity = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("anonymous_identity [%s]", conf->eap_config->anonymous_identity);
+                               DBG("anonymous_identity [%s]", conf->eap_config->anonymous_identity);
                        } else {
                                conf->eap_config->anonymous_identity = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_EAP_CACERT) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->eap_config->ca_cert = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("ca_cert [%s]", conf->eap_config->ca_cert);
+                               DBG("ca_cert [%s]", conf->eap_config->ca_cert);
                        } else {
                                conf->eap_config->ca_cert = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_EAP_CLIENTCERT) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->eap_config->client_cert = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("client_cert [%s]", conf->eap_config->client_cert);
+                               DBG("client_cert [%s]", conf->eap_config->client_cert);
                        } else {
                                conf->eap_config->client_cert = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_EAP_PRIVATEKEY) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->eap_config->private_key = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("private_key [%s]", conf->eap_config->private_key);
+                               DBG("private_key [%s]", conf->eap_config->private_key);
                        } else {
                                conf->eap_config->private_key = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_EAP_IDENTITY) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->eap_config->identity = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("identity [%s]", conf->eap_config->identity);
+                               DBG("identity [%s]", conf->eap_config->identity);
                        } else {
                                conf->eap_config->identity = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_EAP_TYPE) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->eap_config->eap_type = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("eap_type [%s]", conf->eap_config->eap_type);
+                               DBG("eap_type [%s]", conf->eap_config->eap_type);
                        } else {
                                conf->eap_config->eap_type = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_EAP_AUTH_TYPE) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->eap_config->eap_auth_type = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("eap_auth_type [%s]", conf->eap_config->eap_auth_type);
+                               DBG("eap_auth_type [%s]", conf->eap_config->eap_auth_type);
                        } else {
                                conf->eap_config->eap_auth_type = NULL;
                        }
                } else if (g_strcmp0(field, WIFI_CONFIG_EAP_SUBJECT_MATCH) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->eap_config->subject_match = g_strdup(g_variant_get_string(value, NULL));
-                               ERR("subject_match [%s]", conf->eap_config->subject_match);
+                               DBG("subject_match [%s]", conf->eap_config->subject_match);
                        } else {
                                conf->eap_config->subject_match = NULL;
                        }
@@ -952,7 +1014,7 @@ gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *contex
        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);
 
-       // Optional field
+       /* Optional field */
        if (conf->proxy_address != NULL) {
                g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PROXY_METHOD, "manual");
                g_key_file_set_string(keyfile, group_name, WIFI_CONFIG_PROXY_SERVER, conf->proxy_address);
@@ -960,18 +1022,49 @@ gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *contex
 
        if (conf->is_hidden != NULL) {
                gboolean hidden = FALSE;
-               if (g_strcmp0(conf->is_hidden, "TRUE") == 0) {
+               if (g_strcmp0(conf->is_hidden, "TRUE") == 0)
                        hidden = TRUE;
-               }
                g_key_file_set_boolean(keyfile, group_name, WIFI_CONFIG_HIDDEN, hidden);
        }
 
+       if (conf->eap_config->anonymous_identity != NULL)
+               g_key_file_set_string(keyfile, group_name,
+                       WIFI_CONFIG_EAP_ANONYMOUS_IDENTITY, conf->eap_config->anonymous_identity);
+
+       if (conf->eap_config->ca_cert != NULL)
+               g_key_file_set_string(keyfile, group_name,
+                       WIFI_CONFIG_EAP_CACERT, conf->eap_config->ca_cert);
+
+       if (conf->eap_config->client_cert != NULL)
+               g_key_file_set_string(keyfile, group_name,
+                       WIFI_CONFIG_EAP_CLIENTCERT, conf->eap_config->client_cert);
+
+       if (conf->eap_config->private_key != NULL)
+               g_key_file_set_string(keyfile, group_name,
+                       WIFI_CONFIG_EAP_PRIVATEKEY, conf->eap_config->private_key);
+
+       if (conf->eap_config->identity != NULL)
+               g_key_file_set_string(keyfile, group_name,
+                       WIFI_CONFIG_EAP_IDENTITY, conf->eap_config->identity);
+
+       if (conf->eap_config->eap_type != NULL)
+               g_key_file_set_string(keyfile, group_name,
+                       WIFI_CONFIG_EAP_TYPE, conf->eap_config->eap_type);
+
+       if (conf->eap_config->eap_auth_type != NULL)
+               g_key_file_set_string(keyfile, group_name,
+                       WIFI_CONFIG_EAP_AUTH_TYPE, conf->eap_config->eap_auth_type);
+
+       if (conf->eap_config->subject_match != NULL)
+               g_key_file_set_string(keyfile, group_name,
+                       WIFI_CONFIG_EAP_SUBJECT_MATCH, conf->eap_config->subject_match);
+
        ret = _save_configuration(config_id, keyfile);
        if (ret == TRUE) {
-               SLOG(LOG_INFO, "MDM_LOG_USER", "Object=wifi-profile, AccessType=Create, Result=Succeed");
+               INFO("Success to save eap configuration [%s]", config_id);
                wifi_complete_save_eap_configuration(wifi, context);
        } else {
-               SLOG(LOG_INFO, "MDM_LOG_USER", "Object=wifi-profile, AccessType=Create, Result=Failed");
+               INFO("Fail to save eap configuration [%s]", config_id);
                netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_INTERNAL, "FailSaveEapConfiguration");
        }
 
@@ -995,7 +1088,7 @@ gboolean handle_remove_configuration(Wifi *wifi, GDBusMethodInvocation *context,
 
        ret = _remove_configuration(config_id);
        if (ret != TRUE) {
-               // no configuration or error
+               /* no configuration or error */
                ERR("No [%s] configuration", config_id);
                netconfig_error_no_profile(context);
                return FALSE;
@@ -1005,7 +1098,7 @@ gboolean handle_remove_configuration(Wifi *wifi, GDBusMethodInvocation *context,
        return ret;
 }
 
-// config field key / value
+/* config field key / value */
 /*
  * [wifi_macaddress_config_id]
  * Name=name (mandatory)
@@ -1078,7 +1171,7 @@ gboolean handle_set_config_field(Wifi *wifi, GDBusMethodInvocation *context,
        if (keyfile_key != NULL)
                g_free(keyfile_key);
 
-       wifi_complete_set_config_field(wifi,context);
+       wifi_complete_set_config_field(wifi, context);
        return ret;
 }