Merge "Added support to set and get IP configuration details." into tizen
[platform/core/connectivity/net-config.git] / src / wifi.c
index bf1f836..d47a352 100755 (executable)
@@ -18,6 +18,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <vconf.h>
 #include <vconf-keys.h>
 #include "neterror.h"
 #include "wifi-eap.h"
 #include "wifi-wps.h"
+#include "wifi-bssid-scan.h"
+#include "wifi-netlink-scan.h"
 #include "wifi-power.h"
 #include "wifi-state.h"
 #include "wifi-agent.h"
 #include "wifi-firmware.h"
-#include "wifi-ssid-scan.h"
 #include "wifi-passpoint.h"
 #include "wifi-eap-config.h"
 #include "wifi-background-scan.h"
+#include "ip-conflict-detect.h"
 #include "wifi-config.h"
 #include "wifi-tdls.h"
+#include "wifi-key-encryption.h"
+#include "wifi-extension.h"
 
-#if defined TIZEN_WLAN_BOARD_SPRD
 #define SPRD_CP2_FIRMWARE_PATH "/usr/bin/cp2-downloader"
 static int is_wifi_firmware_downloaded = FALSE;
-#endif
 
 static Wifi *wifi_object = NULL;
 static NetConnmanAgent *connman_agent_object = NULL;
@@ -70,7 +73,7 @@ static void _set_wifi_mac_address(void)
        if (mac_addr != NULL) {
                if (strlen(mac_addr) == 0)
                        netconfig_set_mac_address_from_file();
-               g_free(mac_addr);
+               free(mac_addr);
        }
 }
 
@@ -86,6 +89,14 @@ void __netconfig_wifi_connect_reply(GObject *source_object, GAsyncResult *res,
        g_dbus_connection_call_finish(conn, res, &error);
        if (error != NULL) {
                ERR("WiFi Connection Error [%s]", error->message);
+               /* No need to emit WiFiConnectFail signal if Connection is
+                * in progress */
+               if (error->code == G_IO_ERROR_TIMED_OUT) {
+                       g_error_free(error);
+                       DBG("WiFi Connection in Progress");
+                       netconfig_gdbus_pending_call_unref();
+                       return;
+               }
                g_error_free(error);
                if (netconfig_dbus_emit_signal(NULL, NETCONFIG_WIFI_PATH,
                                NETCONFIG_WIFI_INTERFACE, "WiFiConnectFail",
@@ -100,7 +111,6 @@ void __netconfig_wifi_connect_reply(GObject *source_object, GAsyncResult *res,
        return;
 }
 
-#if defined TIZEN_WLAN_BOARD_SPRD
 int wifi_firmware_download(void)
 {
        int rv = 0;
@@ -120,7 +130,6 @@ int wifi_firmware_download(void)
 
        return 0;
 }
-#endif
 
 void wifi_object_create_and_init(void)
 {
@@ -155,10 +164,18 @@ void wifi_object_create_and_init(void)
                        G_CALLBACK(handle_get_wifi_state), NULL);
 
        /* WIFI scan */
-       g_signal_connect(wifi_object, "handle-request-specific-scan",
-                       G_CALLBACK(handle_request_specific_scan), NULL);
-       g_signal_connect(wifi_object, "handle-request-wps-scan",
-                       G_CALLBACK(handle_request_wps_scan), NULL);
+       g_signal_connect(wifi_object, "handle-request-bssid-scan",
+                       G_CALLBACK(handle_request_bssid_scan), NULL);
+       g_signal_connect(wifi_object, "handle-get-bssid-list",
+                       G_CALLBACK(handle_get_bssid_list), NULL);
+       g_signal_connect(wifi_object, "handle-netlink-scan",
+                       G_CALLBACK(handle_netlink_scan), NULL);
+
+       /* WPS Connect */
+       g_signal_connect(wifi_object, "handle-request-wps-connect",
+                       G_CALLBACK(handle_request_wps_connect), NULL);
+       g_signal_connect(wifi_object, "handle-request-wps-cancel",
+                       G_CALLBACK(handle_request_wps_cancel), NULL);
 
        /* WIFI direct */
        g_signal_connect(wifi_object, "handle-launch-direct",
@@ -170,6 +187,26 @@ void wifi_object_create_and_init(void)
        g_signal_connect(wifi_object, "handle-delete-eap-config",
                        G_CALLBACK(handle_delete_eap_config), NULL);
 
+       /* VSIE methods */
+       g_signal_connect(wifi_object, "handle-add-vsie",
+                       G_CALLBACK(handle_add_vsie), NULL);
+       g_signal_connect(wifi_object, "handle-get-vsie",
+                       G_CALLBACK(handle_get_vsie), NULL);
+       g_signal_connect(wifi_object, "handle-remove-vsie",
+                       G_CALLBACK(handle_remove_vsie), NULL);
+
+       /* IP conflict methods */
+       g_signal_connect(wifi_object, "handle-ip-conflict-set-enable",
+                       G_CALLBACK(handle_ip_conflict_set_enable), NULL);
+       g_signal_connect(wifi_object, "handle-is-ip-conflict-detect-enabled",
+                       G_CALLBACK(handle_is_ip_conflict_detect_enabled), NULL);
+       g_signal_connect(wifi_object, "handle-set-ip-conflict-period",
+                       G_CALLBACK(handle_set_ip_conflict_period), NULL);
+       g_signal_connect(wifi_object, "handle-get-ip-conflict-state",
+                       G_CALLBACK(handle_get_ip_conflict_state), NULL);
+       g_signal_connect(wifi_object, "handle-get-ip-conflict-period",
+                       G_CALLBACK(handle_get_ip_conflict_period), NULL);
+
        /* WIFI configuration */
        g_signal_connect(wifi_object, "handle-save-configuration",
                        G_CALLBACK(handle_save_configuration), NULL);
@@ -183,6 +220,7 @@ void wifi_object_create_and_init(void)
                        G_CALLBACK(handle_set_config_field), NULL);
        g_signal_connect(wifi_object, "handle-get-config-passphrase",
                        G_CALLBACK(handle_get_config_passphrase), NULL);
+
        /* WIFI EAP configuration */
        g_signal_connect(wifi_object, "handle-save-eap-configuration",
                        G_CALLBACK(handle_save_eap_configuration), NULL);
@@ -196,6 +234,18 @@ void wifi_object_create_and_init(void)
                        G_CALLBACK(handle_resume_bgscan), NULL);
        g_signal_connect(wifi_object, "handle-pause-bgscan",
                        G_CALLBACK(handle_pause_bgscan), NULL);
+       g_signal_connect(wifi_object, "handle-reset-bgscan-interval",
+                       G_CALLBACK(handle_reset_bgscan_interval), NULL);
+
+       /* Auto Scan Mode */
+       g_signal_connect(wifi_object, "handle-get-autoscan",
+                       G_CALLBACK(handle_get_autoscan), NULL);
+       g_signal_connect(wifi_object, "handle-get-autoscanmode",
+                       G_CALLBACK(handle_get_autoscanmode), NULL);
+
+       /* Extension API methods */
+       g_signal_connect(wifi_object, "handle-flush-bss",
+                       G_CALLBACK(handle_flush_bss), NULL);
 
        /* Passpoint */
        g_signal_connect(wifi_object, "handle-set-passpoint",
@@ -224,6 +274,20 @@ void wifi_object_create_and_init(void)
                        G_CALLBACK(handle_tdls_disconnect), NULL);
        g_signal_connect(wifi_object, "handle-tdls-connected-peer",
                        G_CALLBACK(handle_tdls_connected_peer), NULL);
+       g_signal_connect(wifi_object, "handle-tdls-discover",
+                       G_CALLBACK(handle_tdls_discover), NULL);
+       g_signal_connect(wifi_object, "handle-tdls-connect",
+                       G_CALLBACK(handle_tdls_connect), NULL);
+       g_signal_connect(wifi_object, "handle-tdls-channel-switch",
+                       G_CALLBACK(handle_tdls_channel_switch), NULL);
+       g_signal_connect(wifi_object, "handle-tdls-cancel-channel-switch",
+                       G_CALLBACK(handle_tdls_cancel_channel_switch), NULL);
+
+       /* Passphrase Encryption */
+       g_signal_connect(wifi_object, "handle-encrypt-passphrase",
+                       G_CALLBACK(handle_encrypt_passphrase), NULL);
+       g_signal_connect(wifi_object, "handle-decrypt-passphrase",
+                       G_CALLBACK(handle_decrypt_passphrase), NULL);
 
        if (!g_dbus_interface_skeleton_export(interface_wifi, connection,
                        NETCONFIG_WIFI_PATH, NULL)) {