[wfd-manager]: Added method to get the WPA status 74/69474/2
authorManeesh Jain <maneesh.jain@samsung.com>
Fri, 13 May 2016 09:43:34 +0000 (15:13 +0530)
committerManeesh Jain <maneesh.jain@samsung.com>
Fri, 13 May 2016 09:45:02 +0000 (02:45 -0700)
Change-Id: Ibccbee12646e0de38e3aff8281c069caa0486e3e
Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
oem/wifi-direct-oem.h
plugin/wpasupplicant/ctrl_iface_dbus/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/ctrl_iface_dbus/wfd-plugin-wpasupplicant.c
plugin/wpasupplicant/ctrl_iface_sock/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/ctrl_iface_sock/wfd-plugin-wpasupplicant.c
plugin/wpasupplicant/emul/include/wfd-plugin-wpasupplicant.h
plugin/wpasupplicant/emul/wfd-plugin-wpasupplicant-emul.c

index 6d7006c..228e42c 100755 (executable)
@@ -499,6 +499,7 @@ typedef struct _wfd_oem_ops_s {
        int (*save_config) (void);
        int (*set_operating_channel)(int channel);
        int (*remove_all_network)(void);
+       int (*get_wpa_status)(int *wpa_status);
 
 
 } wfd_oem_ops_s;
index 7a3fd3a..627a53e 100755 (executable)
@@ -443,6 +443,8 @@ int ws_refresh();
 int ws_save_config(void);
 int ws_set_operating_channel(int channel);
 int ws_remove_all_network(void);
+int ws_get_wpa_status(int *wpa_status);
+
 
 
 #endif /* __WFD_PLUGIN_WPASUPPLICANT_H__ */
index b764dc0..1dfe392 100755 (executable)
@@ -130,6 +130,7 @@ static wfd_oem_ops_s supplicant_ops = {
        .save_config =  ws_save_config,
        .set_operating_channel = ws_set_operating_channel,
        .remove_all_network = ws_remove_all_network,
+       .get_wpa_status = ws_get_wpa_status,
 
        };
 
@@ -5337,3 +5338,105 @@ int ws_remove_all_network(void)
        return res;
 }
 
+int ws_get_wpa_status(int *wpa_status)
+{
+       __WDP_LOG_FUNC_ENTER__;
+       GDBusConnection *g_dbus = NULL;
+       GVariant *param = NULL;
+       GVariant *reply = NULL;
+       GError *error = NULL;
+
+       if (!wpa_status) {
+               WDP_LOGE("Invalid parameter");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       *wpa_status = WFD_OEM_WPA_STATE_MAX;
+
+       g_dbus = g_pd->g_dbus;
+       if (!g_dbus) {
+               WDP_LOGE("DBus connection is NULL");
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       param = g_variant_new("(s)", SUPPLICANT_IFACE);
+
+       reply = g_dbus_connection_call_sync (
+                       g_pd->g_dbus,
+                       SUPPLICANT_SERVICE, /* bus name */
+                       g_pd->iface_path, /* object path */
+                       DBUS_PROPERTIES_INTERFACE, /* interface name */
+                       DBUS_PROPERTIES_METHOD_GETALL, /* method name */
+                       param, /* GVariant *params */
+                       NULL, /* reply_type */
+                       G_DBUS_CALL_FLAGS_NONE, /* flags */
+                       SUPPLICANT_TIMEOUT , /* timeout */
+                       NULL, /* cancellable */
+                       &error); /* error */
+
+       if(error != NULL) {
+               WDP_LOGE("Error! Failed to get properties: [%s]",
+                                                       error->message);
+               g_error_free(error);
+               if (reply)
+                       g_variant_unref(reply);
+               __WDP_LOG_FUNC_EXIT__;
+               return -1;
+       }
+
+       gchar *reply_str = NULL;
+       if (reply)
+               reply_str = g_variant_print(reply, TRUE);
+       WDP_LOGE("reply [%s]", reply_str ? reply_str : "NULL");
+       g_free(reply_str);
+
+       if(reply != NULL) {
+               GVariantIter *iter = NULL;
+               g_variant_get(reply, "(a{sv})", &iter);
+
+               if (iter != NULL) {
+                       gchar *key = NULL;
+                       GVariant *value = NULL;
+
+                       while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+                               if(g_strcmp0(key, "State") == 0) {
+                                       const gchar *state = NULL;
+                                       g_variant_get(value, "&s", &state);
+                                       WDP_LOGI("state : [%s]", state);
+
+                                       if (g_strcmp0(state, "disconnected") == 0)
+                                               *wpa_status = WFD_OEM_WPA_STATE_DISCONNECTED;
+                                       else if (g_strcmp0(state, "inactive") == 0)
+                                               *wpa_status = WFD_OEM_WPA_STATE_INACTIVE;
+                                       else if (g_strcmp0(state, "scanning") == 0)
+                                               *wpa_status = WFD_OEM_WPA_STATE_SCANNING;
+                                       else if (g_strcmp0(state, "authenticating") == 0)
+                                               *wpa_status = WFD_OEM_WPA_STATE_AUTHENTICATING;
+                                       else if (g_strcmp0(state, "associating") == 0)
+                                               *wpa_status = WFD_OEM_WPA_STATE_ASSOCIATING;
+                                       else if (g_strcmp0(state, "associated") == 0)
+                                               *wpa_status = WFD_OEM_WPA_STATE_ASSOCIATED;
+                                       else if (g_strcmp0(state, "4way_handshake") == 0)
+                                               *wpa_status = WFD_OEM_WPA_STATE_4WAY_HANDSHAKE;
+                                       else if (g_strcmp0(state, "group_handshake") == 0)
+                                               *wpa_status = WFD_OEM_WPA_STATE_GROUP_HANDSHAKE;
+                                       else if (g_strcmp0(state, "completed") == 0)
+                                               *wpa_status = WFD_OEM_WPA_STATE_COMPLETED;
+                                       else
+                                               *wpa_status = WFD_OEM_WPA_STATE_MAX;
+                               }
+                       }
+                       g_variant_iter_free(iter);
+               }
+               g_variant_unref(reply);
+       } else {
+               WDP_LOGD("No properties");
+       }
+
+       WDP_LOGI("wpa_status : [%d]", *wpa_status);
+
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
index 7fa9914..c3fa648 100755 (executable)
@@ -582,5 +582,7 @@ int ws_refresh();
 int ws_save_config(void);
 int ws_set_operating_channel(int channel);
 int ws_remove_all_network(void);
+int ws_get_wpa_status(int *wpa_status);
+
 
 #endif /* __WFD_PLUGIN_WPASUPPLICANT_H__ */
index 46dc249..7ef3e42 100755 (executable)
@@ -273,6 +273,7 @@ static wfd_oem_ops_s supplicant_ops = {
        .save_config = ws_save_config,
        .set_operating_channel = ws_set_operating_channel,
        .remove_all_network = ws_remove_all_network,
+       .get_wpa_status = ws_get_wpa_status,
 
        };
 
@@ -4915,3 +4916,10 @@ int ws_remove_all_network()
        return 0;
 }
 
+int ws_get_wpa_status(int *wpa_status)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       __WDP_LOG_FUNC_EXIT__;
+       return 0;
+}
index 9de97fd..1a6d68a 100755 (executable)
@@ -121,6 +121,8 @@ int ws_refresh();
 int ws_save_config(void);
 int ws_set_operating_channel(int channel);
 int ws_remove_all_network(void);
+int ws_get_wpa_status(int *wpa_status);
+
 
 
 #endif /* __WFD_PLUGIN_WPASUPPLICANT_H__ */
index c686239..031e8dc 100755 (executable)
@@ -71,6 +71,7 @@ static wfd_oem_ops_s supplicant_ops = {
        .save_config = ws_save_config,
        .set_operating_channel = ws_set_operating_channel,
        .remove_all_network = ws_remove_all_network,
+       .get_wpa_status = ws_get_wpa_status,
 
        };
 
@@ -464,3 +465,10 @@ int ws_remove_all_network()
        return -1;
 }
 
+int ws_get_wpa_status(int *wpa_status)
+{
+       __WDP_LOG_FUNC_ENTER__;
+
+       __WDP_LOG_FUNC_EXIT__;
+       return -1;
+}