Added scan reply logic in scan request function. 33/167233/2 accepted/tizen/unified/20180123.061129 submit/tizen/20180119.051933
authorNiraj Kumar Goit <niraj.g@samsung.com>
Tue, 16 Jan 2018 08:56:24 +0000 (14:26 +0530)
committertaesub kim <taesub.kim@samsung.com>
Wed, 17 Jan 2018 02:21:57 +0000 (11:21 +0900)
Added scan reply logic in scan request function to fix
scan callback issue when previous scan is already in progress.

Change-Id: I1b10b29776389e074719ab0f2f80d539fe7f0083
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
src/network-dbus-request.c

index cdb62f1..9d82da0 100755 (executable)
@@ -387,7 +387,8 @@ static void __net_specific_scan_wifi_reply(GObject *source_object, GAsyncResult
        conn = G_DBUS_CONNECTION(source_object);
        g_dbus_connection_call_finish(conn, res, &error);
        if (error != NULL) {
-               Error = __net_netconfig_error_string_to_enum(error->message);
+               NETWORK_LOG(NETWORK_ERROR, "Specific scan failed. Error [%s]", error->message);
+               Error = __net_error_string_to_enum(error->message);
                g_error_free(error);
        }
 
@@ -701,6 +702,50 @@ int _net_dbus_close_connection(const char* profile_name)
        return Error;
 }
 
+static void __net_scan_reply(GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       GDBusConnection *conn = NULL;
+       GError *error = NULL;
+       net_err_t Error = NET_ERR_NONE;
+       net_event_info_t event_data = { 0, };
+
+       conn = G_DBUS_CONNECTION(source_object);
+       g_dbus_connection_call_finish(conn, res, &error);
+       if (error != NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Scan failed. Error [%s]", error->message);
+               Error = __net_error_string_to_enum(error->message);
+               g_error_free(error);
+       }
+
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR, "Scan failed. Error[%d]", Error);
+
+               if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+                       memset(&request_table[NETWORK_REQUEST_TYPE_SCAN],
+                                       0, sizeof(network_request_table_t));
+
+                       event_data.Event = NET_EVENT_WIFI_SCAN_RSP;
+                       event_data.Datalength = 0;
+                       event_data.Data = NULL;
+                       event_data.Error = Error;
+
+                       _net_dbus_pending_call_unref();
+
+                       _net_client_callback(&event_data);
+
+                       __NETWORK_FUNC_EXIT__;
+                       return;
+               }
+       } else
+               NETWORK_LOG(NETWORK_ERROR, "Scan Request success");
+
+       _net_dbus_pending_call_unref();
+
+       __NETWORK_FUNC_EXIT__;
+}
+
 int _net_dbus_scan_request(void)
 {
        __NETWORK_FUNC_ENTER__;
@@ -711,7 +756,7 @@ int _net_dbus_scan_request(void)
        Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
                        CONNMAN_WIFI_TECHNOLOGY_PREFIX,
                        CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL,
-                       DBUS_REPLY_TIMEOUT, NULL);
+                       DBUS_REPLY_TIMEOUT, __net_scan_reply);
 
        if (Error == NET_ERR_IN_PROGRESS)
                Error = NET_ERR_NONE;