Fixed coding rule issues
[platform/core/connectivity/net-config.git] / src / wifi-background-scan.c
index 28f4f7d..8172fdf 100755 (executable)
@@ -54,8 +54,8 @@ static gboolean netconfig_bgscan_paused = FALSE;
 
 static struct bgscan_timer_data *__netconfig_wifi_bgscan_get_bgscan_data(void)
 {
-       static struct bgscan_timer_data timer_data =
-                                       {SCAN_EXPONENTIAL_MIN, WIFI_BGSCAN_MODE_EXPONENTIAL, 0};
+       static struct bgscan_timer_data timer_data = {
+                                       SCAN_EXPONENTIAL_MIN, WIFI_BGSCAN_MODE_EXPONENTIAL, 0};
 
        return &timer_data;
 }
@@ -85,6 +85,33 @@ static guint __netconfig_wifi_bgscan_get_mode(void)
        return __netconfig_wifi_bgscan_mode(FALSE, -1);
 }
 
+static void __netconfig_wifi_scan_request_reply(GObject *source_object, GAsyncResult *res, gpointer user_data)
+
+{
+       GVariant *reply;
+       GDBusConnection *conn = NULL;
+       GError *error = NULL;
+
+       conn = G_DBUS_CONNECTION(source_object);
+       reply = g_dbus_connection_call_finish(conn, res, &error);
+
+       if (reply == NULL) {
+               if (error != NULL) {
+                       ERR("Fail to request status [%d: %s]", error->code, error->message);
+                       netconfig_wifi_set_scanning(FALSE);
+                       g_error_free(error);
+               } else {
+                       ERR("Fail to request scan");
+                       netconfig_wifi_set_scanning(FALSE);
+               }
+       } else {
+               DBG("Successfully requested");
+       }
+
+       g_variant_unref(reply);
+       netconfig_gdbus_pending_call_unref();
+}
+
 static gboolean __netconfig_wifi_bgscan_request_connman_scan(int retries)
 {
        gboolean reply = FALSE;
@@ -94,7 +121,7 @@ static gboolean __netconfig_wifi_bgscan_request_connman_scan(int retries)
                if (__netconfig_wifi_bgscan_get_mode() == WIFI_BGSCAN_MODE_EXPONENTIAL)
                        return TRUE;
 
-       if (state == NETCONFIG_WIFI_ASSOCIATION ||state == NETCONFIG_WIFI_CONFIGURATION) {
+       if (state == NETCONFIG_WIFI_ASSOCIATION || state == NETCONFIG_WIFI_CONFIGURATION) {
                /* During Wi-Fi connecting, Wi-Fi can be disappeared.
                 * After 1 sec, try scan even if connecting state */
                if (retries < 2)
@@ -105,7 +132,7 @@ static gboolean __netconfig_wifi_bgscan_request_connman_scan(int retries)
 
        reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
                        CONNMAN_WIFI_TECHNOLOGY_PREFIX,
-                       CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL, NULL);
+                       CONNMAN_TECHNOLOGY_INTERFACE, "Scan", NULL, __netconfig_wifi_scan_request_reply);
        if (reply != TRUE)
                netconfig_wifi_set_scanning(FALSE);
 
@@ -198,7 +225,7 @@ static gboolean __netconfig_wifi_bgscan_next_scan(gpointer data)
                return FALSE;
 
        /* In case of LCD off, we don't need Wi-Fi scan */
-       vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
+       netconfig_vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
        if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
                return TRUE;
 
@@ -277,7 +304,7 @@ gboolean handle_set_bgscan(Wifi *wifi, GDBusMethodInvocation *context, guint sca
        int pm_state = VCONFKEY_PM_STATE_NORMAL;
 
        old_mode = __netconfig_wifi_bgscan_get_mode();
-       if (old_mode == scan_mode){
+       if (old_mode == scan_mode) {
                wifi_complete_set_bgscan(wifi, context);
                return TRUE;
        }
@@ -287,7 +314,7 @@ gboolean handle_set_bgscan(Wifi *wifi, GDBusMethodInvocation *context, guint sca
        netconfig_wifi_bgscan_stop();
 
        /* In case of LCD off, we don't need Wi-Fi scan right now */
-       vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
+       netconfig_vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
        if (pm_state >= VCONFKEY_PM_STATE_LCDOFF)
                netconfig_wifi_bgscan_start(FALSE);
        else
@@ -301,7 +328,7 @@ gboolean handle_resume_bgscan(Wifi *wifi, GDBusMethodInvocation *context)
 {
        netconfig_wifi_set_bgscan_pause(FALSE);
 
-       wifi_complete_resume_bgscan (wifi, context);
+       wifi_complete_resume_bgscan(wifi, context);
        return TRUE;
 }