Fix dbus method return value
[platform/core/connectivity/net-config.git] / src / wifi-agent.c
index f8c317e..4ac5bfd 100755 (executable)
@@ -162,7 +162,7 @@ gboolean handle_set_field(NetConnmanAgent *connman_agent,
        gboolean updated = FALSE;
        gboolean reply = FALSE;
 
-       g_return_val_if_fail(connman_agent != NULL, FALSE);
+       g_return_val_if_fail(connman_agent != NULL, TRUE);
 
        DBG("Set agent fields for %s", service);
 
@@ -174,7 +174,7 @@ gboolean handle_set_field(NetConnmanAgent *connman_agent,
                g_dbus_method_invocation_return_gerror(context, error);
                g_clear_error(&error);
 
-               return reply;
+               return TRUE;
        }
 
        __netconfig_agent_clear_fields();
@@ -271,7 +271,9 @@ gboolean handle_set_field(NetConnmanAgent *connman_agent,
                reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
                                service, CONNMAN_SERVICE_INTERFACE, "Connect",
                                NULL, __netconfig_wifi_connect_reply);
-               if (reply != TRUE) {
+               if (reply == TRUE) {
+                       g_dbus_method_invocation_return_value(context, NULL);
+               } else {
                        ERR("Fail to connect Wi-Fi");
                        __netconfig_agent_clear_fields();
                        error = g_error_new(G_DBUS_ERROR,
@@ -280,8 +282,6 @@ gboolean handle_set_field(NetConnmanAgent *connman_agent,
 
                        g_dbus_method_invocation_return_gerror(context, error);
                        g_clear_error(&error);
-                       g_variant_iter_free(iter);
-                       return reply;
                }
        } else {
                error = g_error_new(G_DBUS_ERROR,
@@ -290,14 +290,16 @@ gboolean handle_set_field(NetConnmanAgent *connman_agent,
 
                g_dbus_method_invocation_return_gerror(context, error);
                g_clear_error(&error);
-               g_variant_iter_free(iter);
-               return reply;
        }
 
+       if (reply != TRUE) {
+               ERR("Fail to connect Wi-Fi");
+               __netconfig_agent_clear_fields();
+       }
        g_variant_iter_free(iter);
 
        net_connman_agent_complete_set_field(connman_agent, context);
-       return reply;
+       return TRUE;
 }
 
 gboolean handle_request_input(NetConnmanAgent *connman_agent,
@@ -310,7 +312,7 @@ gboolean handle_request_input(NetConnmanAgent *connman_agent,
        gboolean updated = FALSE;
        GVariantBuilder *builder = NULL;
 
-       g_return_val_if_fail(connman_agent != NULL, FALSE);
+       g_return_val_if_fail(connman_agent != NULL, TRUE);
 
        if (NULL == service)
                return FALSE;
@@ -384,7 +386,7 @@ gboolean handle_request_input(NetConnmanAgent *connman_agent,
        if (NULL == out_table) {
                net_connman_agent_complete_request_input(connman_agent, context, out_table);
 
-               return FALSE;
+               return TRUE;
        }
 
        if (updated == TRUE)
@@ -401,23 +403,21 @@ gboolean handle_request_input(NetConnmanAgent *connman_agent,
 
        __netconfig_agent_clear_fields();
 
-       return updated;
+       return TRUE;
 }
 
 
 gboolean handle_report_error(NetConnmanAgent *connman_agent,
                GDBusMethodInvocation *context, const gchar *service, const gchar *error)
 {
-       gboolean ret = TRUE;
-
-       g_return_val_if_fail(connman_agent != NULL, FALSE);
+       g_return_val_if_fail(connman_agent != NULL, TRUE);
 
        net_connman_agent_complete_report_error(connman_agent, context);
        DBG("Agent error for service[%s] - [%s]", service, error);
 
        /* Do something when it failed to make a connection */
 
-       return ret;
+       return TRUE;
 }
 
 #if defined TIZEN_CAPTIVE_PORTAL
@@ -586,11 +586,10 @@ gboolean handle_request_browser(NetConnmanAgent *connman_agent,
                GDBusMethodInvocation *context, const gchar *service, const gchar *url)
 {
 #if defined TIZEN_CAPTIVE_PORTAL
-       gboolean ret = FALSE;
        gboolean ignore_portal = FALSE;
        const char * ssid = NULL;
 
-       g_return_val_if_fail(connman_agent != NULL, FALSE);
+       g_return_val_if_fail(connman_agent != NULL, TRUE);
 
        DBG("service[%s] - url[%s]", service, url);
 
@@ -598,7 +597,7 @@ gboolean handle_request_browser(NetConnmanAgent *connman_agent,
        if (ssid == NULL) {
                ERR("Connected AP name is NULL!!");
                net_connman_agent_complete_request_browser(connman_agent, context);
-               return FALSE;
+               return TRUE;
        }
 
        ignore_portal = __check_ignore_portal_list(ssid);
@@ -613,13 +612,13 @@ gboolean handle_request_browser(NetConnmanAgent *connman_agent,
                is_monitor_notifier_registered = TRUE;
        }
 
-       ret = netconfig_send_notification_to_net_popup(NETCONFIG_ADD_PORTAL_NOTI, ssid);
+       netconfig_send_notification_to_net_popup(NETCONFIG_ADD_PORTAL_NOTI, ssid);
 
        timer_data.time_elapsed = 0;
        __netconfig_wifi_portal_login_timer_start(&timer_data);
 
        net_connman_agent_complete_request_browser(connman_agent, context);
-       return ret;
+       return TRUE;
 #else
        GError *error = NULL;
        error = g_error_new(G_DBUS_ERROR,
@@ -629,6 +628,6 @@ gboolean handle_request_browser(NetConnmanAgent *connman_agent,
        g_dbus_method_invocation_return_gerror(context, error);
        g_clear_error(&error);
 
-       return FALSE;
+       return TRUE;
 #endif
 }