Add debug logs
[platform/core/connectivity/net-config.git] / src / wifi-dpp.c
old mode 100644 (file)
new mode 100755 (executable)
index fdf7a8f..1133191
@@ -228,7 +228,7 @@ static char *__netconfig_dpp_get_supplicant_interface()
        if (if_path)
                return if_path;
 
-       if_path = netconfig_wifi_get_supplicant_interface();
+       if_path = netconfig_wifi_get_supplicant_interface_path(NULL);
 
        return if_path;
 }
@@ -330,7 +330,8 @@ static gchar *__netconfig_get_p2p_address(const char *if_path)
 {
        GVariant *params = NULL;
        GVariant *message = NULL;
-       GVariant *temp = NULL;
+       GVariant *temp1 = NULL;
+       GVariant *temp2 = NULL;
        guchar p2p_addr[MACADDR_LEN] = {0,};
        gchar address_str[MACSTR_LEN] = {0,};
 
@@ -348,10 +349,14 @@ static gchar *__netconfig_get_p2p_address(const char *if_path)
        }
        DEBUG_G_VARIANT("reply:", message);
 
-       temp = g_variant_get_child_value(message, 0);
-       temp = g_variant_get_child_value(temp, 0);
-       DEBUG_G_VARIANT("temp:", temp);
-       __ws_unpack_ay(p2p_addr, temp, MACADDR_LEN);
+       temp1 = g_variant_get_child_value(message, 0);
+       temp2 = g_variant_get_child_value(temp1, 0);
+       DEBUG_G_VARIANT("temp2:", temp2);
+       __ws_unpack_ay(p2p_addr, temp2, MACADDR_LEN);
+       g_variant_unref(temp1);
+       g_variant_unref(temp2);
+       g_variant_unref(message);
+
        g_snprintf(address_str, MACSTR_LEN, MACSTR, MAC2STR(p2p_addr));
 
        DBG("P2P address %s", address_str);
@@ -797,7 +802,7 @@ static gboolean __netconfig_wifi_dpp_invoke_connman_scan()
        return netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
                        CONNMAN_WIFI_TECHNOLOGY_PREFIX,
                        CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL,
-                       __wifi_dpp_connman_scan_request_reply);
+                       __wifi_dpp_connman_scan_request_reply, NULL);
 }
 
 
@@ -810,7 +815,7 @@ static gboolean __netconfig_wifi_invoke_flush_bss()
 
        DBG("[TizenMW-->WPAS]: Wi-Fi Flush BSS Request: ");
 
-       if_path = netconfig_wifi_get_supplicant_interface();
+       if_path = netconfig_wifi_get_supplicant_interface_path(NULL);
        if (if_path == NULL) {
                ERR("Fail to get wpa_supplicant DBus path");
                return FALSE;
@@ -1394,6 +1399,7 @@ gboolean __save_passphrase(GKeyFile *keyfile, gchar *group_name, gchar *key, gch
                ret = FALSE;
        } else {
                g_key_file_set_string(keyfile, group_name, key, enc_data);
+               g_free(enc_data);
        }
 
        return ret;
@@ -1427,7 +1433,8 @@ gboolean __save_credentials(GKeyFile *keyfile, gchar *group_name, wifi_dpp_conf_
 }
 
 
-static gboolean __save_configuration_object(wifi_dpp_conf_obj *conf_obj)
+static gboolean __save_configuration_object(const char *interface_name,
+               wifi_dpp_conf_obj *conf_obj)
 {
        gchar ssid_hex[65] = {0,};
        gchar *config_id = NULL;
@@ -1451,7 +1458,7 @@ static gboolean __save_configuration_object(wifi_dpp_conf_obj *conf_obj)
 
        netconfig_convert_bytes_to_hexstr(conf_obj->ssid, strlen(conf_obj->ssid), ssid_hex);
        config_id = g_strdup_printf("%s_managed_%s", ssid_hex, conf_obj->akm);
-       ret = wifi_config_get_group_name("wifi_", config_id, &group_name);
+       ret = wifi_config_get_group_name("wifi_", interface_name, config_id, &group_name);
        if (!ret) {
                ERR("Failed to get Wi-Fi config group name");
                g_free(config_id);
@@ -1472,7 +1479,7 @@ static gboolean __save_configuration_object(wifi_dpp_conf_obj *conf_obj)
        g_key_file_set_boolean(keyfile, group_name, "Favorite", TRUE);
        g_key_file_set_boolean(keyfile, group_name, "AutoConnect", TRUE);
 
-       ret = wifi_config_save_configuration(config_id, keyfile);
+       ret = wifi_config_save_configuration(interface_name, config_id, keyfile);
        if (ret == TRUE)
                INFO("Success to save configuration [%s]", config_id);
        else
@@ -1486,7 +1493,7 @@ static gboolean __save_configuration_object(wifi_dpp_conf_obj *conf_obj)
 
 }
 
-void netconfig_wifi_dpp_conf_obj_event(GVariant *message)
+void netconfig_wifi_dpp_conf_obj_event(const char *interface_name, GVariant *message)
 {
        GVariantIter *iter = NULL;
        gchar *key = NULL;
@@ -1516,7 +1523,7 @@ void netconfig_wifi_dpp_conf_obj_event(GVariant *message)
                        g_variant_get(value, "&s", &conf_obj.net_access_key);
        }
 
-       if (!__save_configuration_object(&conf_obj) || !__netconfig_wifi_invoke_flush_bss()) {
+       if (!__save_configuration_object(interface_name, &conf_obj) || !__netconfig_wifi_invoke_flush_bss()) {
                g_variant_iter_free(iter);
                __netconfig_wifi_dpp_notify_dpp_failed(p_dpp_info);
                return;