[net-config] Notify WiFi Connect failure to libnet-client 24/57324/1
authorSaurav Babu <saurav.babu@samsung.com>
Tue, 19 Jan 2016 04:56:40 +0000 (10:26 +0530)
committerSaurav Babu <saurav.babu@samsung.com>
Tue, 19 Jan 2016 04:56:40 +0000 (10:26 +0530)
Sometimes connman may fail to start WiFi connection, this failure should be
notified to libnet-client so that it can clear its connection flags.
This patch sends a new signal WiFiConnectFail when failure is received
from connman at the time of starting WiFi connection.

Change-Id: I17ec729647ddcd0a045fb3571c4863e4c63fdf58
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
include/wifi.h
src/wifi-agent.c
src/wifi-eap-config.c
src/wifi.c

index 9163ab7..f72d12e 100755 (executable)
@@ -34,6 +34,9 @@ extern "C" {
 #define WIFI_CERT_STORAGEDIR   "/var/lib/wifi/cert"
 #define CONNMAN_STORAGEDIR             "/var/lib/connman"
 
+void __netconfig_wifi_connect_reply(GObject *source_object, GAsyncResult *res,
+               gpointer user_data);
+
 void wifi_object_create_and_init(void);
 void wifi_object_deinit(void);
 
index c4456c7..57f8bf0 100755 (executable)
@@ -282,7 +282,8 @@ gboolean handle_set_field(NetConnmanAgent *connman_agent,
 
        if (updated == TRUE) {
                reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
-                               service, CONNMAN_SERVICE_INTERFACE, "Connect", NULL, NULL);
+                               service, CONNMAN_SERVICE_INTERFACE, "Connect",
+                               NULL, __netconfig_wifi_connect_reply);
                if (reply == TRUE) {
                        g_dbus_method_invocation_return_value (context, NULL);
                } else {
index 72b0636..adaa63d 100755 (executable)
@@ -515,7 +515,8 @@ gboolean handle_create_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
                }
 
                result = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
-                               service, CONNMAN_SERVICE_INTERFACE, "Connect", NULL, NULL);
+                               service, CONNMAN_SERVICE_INTERFACE, "Connect",
+                               NULL, __netconfig_wifi_connect_reply);
 
                if (netconfig_eap_notifier.user_data != NULL) {
                        g_free(netconfig_eap_notifier.user_data);
index 796849c..ea1b2d7 100755 (executable)
@@ -69,6 +69,32 @@ static void _set_wifi_mac_address(void)
        }
 }
 
+void __netconfig_wifi_connect_reply(GObject *source_object, GAsyncResult *res,
+               gpointer user_data)
+{
+       GDBusConnection *conn = NULL;
+       GError *error = NULL;
+
+       DBG("WiFi Connection Reply");
+
+       conn = G_DBUS_CONNECTION(source_object);
+       g_dbus_connection_call_finish(conn, res, &error);
+       if (error != NULL) {
+               ERR("WiFi Connection Error [%s]", error->message);
+               g_error_free(error);
+               if (netconfig_dbus_emit_signal(NULL, NETCONFIG_WIFI_PATH,
+                               NETCONFIG_WIFI_INTERFACE, "WiFiConnectFail",
+                               NULL) == FALSE)
+                       ERR("Failed to emit WiFiConnectFail signal");
+               else
+                       DBG("Successfully sent WiFiConnectFail signal");
+       } else
+               DBG("WiFi Connection has been initiated successfully");
+
+       netconfig_gdbus_pending_call_unref();
+       return;
+}
+
 void wifi_object_create_and_init(void)
 {
        DBG("Create wifi object.");