Add to get passphrase string from config 65/208365/2 accepted/tizen/unified/20190703.110716 submit/tizen/20190702.113133
authorhyunuktak <hyunuk.tak@samsung.com>
Mon, 24 Jun 2019 01:36:50 +0000 (10:36 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Mon, 24 Jun 2019 03:33:59 +0000 (12:33 +0900)
Change-Id: Idb2a16d46551edf765d8fc8a100def5ef5eb0268
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
include/wifi-config.h
packaging/net-config.spec
src/wifi-config.c

index 6dd783b..97f2740 100755 (executable)
@@ -34,6 +34,7 @@ extern "C" {
 #define WIFI_CONFIG_FAVORITE                   "Favorite"
 #define WIFI_CONFIG_AUTOCONNECT                "AutoConnect"
 #define WIFI_CONFIG_HIDDEN                             "Hidden"
+#define WIFI_CONFIG_CREATED                            "Created"
 #define WIFI_CONFIG_IPV4_METHOD                        "IPv4.method"
 #define WIFI_CONFIG_IPV6_METHOD                        "IPv6.method"
 #define WIFI_CONFIG_IPV4_DNS_METHOD                    "Nameservers.IPv4method"
index 60a14a7..a89412d 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          net-config
 Summary:       TIZEN Network Configuration service
-Version:       1.1.144
+Version:       1.1.145
 Release:       3
 Group:         System/Network
 License:       Apache-2.0
index 943a6cf..5c5082b 100755 (executable)
@@ -86,6 +86,7 @@ struct wifi_config {
        gboolean favorite;
        gboolean autoconnect;
        gchar *is_hidden;
+       gboolean is_created;
        gchar *proxy_address;
        struct wifi_eap_config *eap_config;
        wifi_ip_info_s *ip_info;
@@ -336,6 +337,9 @@ static gboolean _load_configuration(const gchar *config_id, struct wifi_config *
        }
        DBG("security_type [%s]", config->security_type);
 
+       config->passphrase = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PASSPHRASE, NULL);
+       DBG("passphrase []");
+
        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);
@@ -1072,6 +1076,7 @@ gboolean handle_load_configuration(Wifi *wifi, GDBusMethodInvocation *context,
        b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
        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_PASSPHRASE, g_variant_new_string(conf->passphrase));
        g_variant_builder_add(b, "{sv}", WIFI_CONFIG_HIDDEN, g_variant_new_string(conf->is_hidden));
 
        if (conf->proxy_address != NULL)
@@ -1192,6 +1197,13 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
                        } else {
                                conf->is_hidden = NULL;
                        }
+               } else if (g_strcmp0(field, WIFI_CONFIG_CREATED) == 0) {
+                       if (g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) {
+                               conf->is_created = g_variant_get_boolean(value);
+                               DBG("is_created [%d]", conf->is_created);
+                       } else {
+                               conf->is_created = FALSE;
+                       }
                } else if (g_strcmp0(field, WIFI_CONFIG_IPV4_METHOD) == 0) {
                        if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
                                conf->ip_info->ip_type = g_strdup(g_variant_get_string(value, NULL));
@@ -1269,7 +1281,11 @@ gboolean handle_save_configuration(Wifi *wifi, GDBusMethodInvocation *context,
 
        if (conf->passphrase != NULL) {
                gchar *enc_data = NULL;
-               enc_data = _netconfig_encrypt_passphrase(conf->passphrase);
+
+               if (conf->is_created == true)
+                       enc_data = _netconfig_encrypt_passphrase(conf->passphrase);
+               else
+                       enc_data = g_strdup(conf->passphrase);
 
                if (!enc_data) {
                        ERR("Failed to encrypt the passphrase");
@@ -1494,6 +1510,13 @@ gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *contex
                        } else {
                                conf->is_hidden = NULL;
                        }
+               } else if (g_strcmp0(field, WIFI_CONFIG_CREATED) == 0) {
+                       if (g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) {
+                               conf->is_created = g_variant_get_boolean(value);
+                               DBG("is_created [%d]", conf->is_created);
+                       } else {
+                               conf->is_created = FALSE;
+                       }
                } 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));
@@ -1582,7 +1605,11 @@ gboolean handle_save_eap_configuration(Wifi *wifi, GDBusMethodInvocation *contex
 
        if (conf->passphrase != NULL) {
                gchar *enc_data = NULL;
-               enc_data = _netconfig_encrypt_passphrase(conf->passphrase);
+
+               if (conf->is_created == true)
+                       enc_data = _netconfig_encrypt_passphrase(conf->passphrase);
+               else
+                       enc_data = g_strdup(conf->passphrase);
 
                if (!enc_data) {
                        ERR("Failed to encrypt the passphrase");