Modified to get wifi state 51/58151/1 accepted/tizen/ivi/20160223.231820 accepted/tizen/mobile/20160223.231726 accepted/tizen/tv/20160223.231741 accepted/tizen/wearable/20160223.231759 submit/tizen/20160211.015108 submit/tizen/20160223.060827
authorhyunuktak <hyunuk.tak@samsung.com>
Thu, 28 Jan 2016 02:48:51 +0000 (11:48 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Thu, 28 Jan 2016 02:48:54 +0000 (11:48 +0900)
Change-Id: Iab3141c11bfa226c58da1a22a47cabd5ad2d31db
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
packaging/capi-network-wifi.spec
src/libnetwork.c
test/wifi_test.c

index 867cb99..bf63c64 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          capi-network-wifi
 Summary:       Network Wi-Fi library in TIZEN C API
-Version:       1.0.65
+Version:       1.0.66
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index 1baa2ce..aa5669e 100755 (executable)
@@ -66,8 +66,6 @@ static __thread struct _wifi_cb_s wifi_callbacks = { 0, };
 static __thread struct _profile_list_s profile_iterator = { 0, NULL };
 static __thread struct _profile_list_s specific_profile_iterator = {0, NULL};
 static __thread char specific_profile_essid[NET_WLAN_ESSID_LEN + 1] = { 0, };
-static __thread bool is_feature_checked = false;
-static __thread bool feature_supported = false;
 static __thread GSList *managed_idler_list = NULL;
 static __thread bool wifi_is_feature_checked[WIFI_SUPPORTED_FEATURE_MAX] = {0, };
 static __thread bool wifi_feature_supported[WIFI_SUPPORTED_FEATURE_MAX] = {0, };
@@ -876,40 +874,40 @@ int _wifi_libnet_get_wifi_device_state(wifi_device_state_e *device_state)
 
 int _wifi_libnet_get_wifi_state(wifi_connection_state_e *connection_state)
 {
-       wifi_dbus *dbus_h = NULL;
-       GError *error = NULL;
-       GVariant *result = NULL;
-       gint state = 0;
-
-       dbus_h = _wifi_get_dbus_handle();
-       if (dbus_h == NULL) {
-               WIFI_LOG(WIFI_ERROR, "Not initialized for wifi dbus connection");
-               return WIFI_ERROR_INVALID_OPERATION;
-       }
+       int rv;
+       net_wifi_state_t wlan_state = 0;
 
-       result = g_dbus_connection_call_sync(dbus_h->dbus_conn,
-                                            NETCONFIG_SERVICE,
-                                            NETCONFIG_WIFI_PATH,
-                                            NETCONFIG_IWIFI,
-                                            "GetWifiState",
-                                            g_variant_new("()"),
-                                            NULL, G_DBUS_CALL_FLAGS_NONE,
-                                            DBUS_REPLY_TIMEOUT, dbus_h->ca,
-                                            &error);
-
-       if (error) {
-               WIFI_LOG(WIFI_ERROR, "Fail to GetWifiState [%d: %s]", error->code, error->message);
-               g_error_free(error);
+       rv = net_get_wifi_state(&wlan_state);
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               WIFI_LOG(WIFI_ERROR, "Access denied");
+               return WIFI_ERROR_PERMISSION_DENIED;
+       } else if (rv != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get Wi-Fi state");
                return WIFI_ERROR_OPERATION_FAILED;
        }
 
-       if (result != NULL) {
-               g_variant_get(result, "(i)", &state);
-               g_variant_unref(result);
+       switch (wlan_state) {
+       case WIFI_OFF:
+       case WIFI_ON:
+               *connection_state = WIFI_CONNECTION_STATE_DISCONNECTED;
+               break;
+       case WIFI_ASSOCIATION:
+               *connection_state = WIFI_CONNECTION_STATE_ASSOCIATION;
+               break;
+       case WIFI_CONFIGURATION:
+               *connection_state = WIFI_CONNECTION_STATE_CONFIGURATION;
+               break;
+       case WIFI_CONNECTED:
+               *connection_state = WIFI_CONNECTION_STATE_CONNECTED;
+               break;
+       case WIFI_DISCONNECTING:
+               *connection_state = WIFI_CONNECTION_STATE_CONNECTED;
+               break;
+       default:
+               WIFI_LOG(WIFI_ERROR, "Unknown state");
+               return WIFI_ERROR_OPERATION_FAILED;
        }
 
-       *connection_state = state;
-
        return WIFI_ERROR_NONE;
 }
 
@@ -1370,7 +1368,6 @@ int _wifi_check_feature_supported(const char *feature_name, ...)
                else if (strcmp(key, WIFI_TDLS_FEATURE) == 0)
                        value = __libnet_check_feature_supported(key, WIFI_SUPPORTED_FEATURE_WIFI_TDLS);
 
-               SECURE_WIFI_LOG(WIFI_INFO, "%s feature is %s", key, (value ? "true" : "false"));
                feature_supported |= value;
                key = va_arg(list, const char *);
                if (!key) break;
index 7b857ef..a3cfddc 100755 (executable)
 #include <wifi.h>
 #include <tizen_error.h>
 
+#define LOG_RED "\033[0;31m"
+#define LOG_GREEN "\033[0;32m"
+#define LOG_BROWN "\033[0;33m"
+#define LOG_BLUE "\033[0;34m"
+#define LOG_END "\033[0;m"
 
 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
 
@@ -1605,18 +1610,18 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        if (a[0] == '\n' || a[0] == '\r') {
                printf("\n\n Network Connection API Test App\n\n");
                printf("Options..\n");
-               printf("1   - Wi-Fi init and set callbacks\n");
+               printf(LOG_GREEN "1   - Wi-Fi init and set callbacks\n" LOG_END);
                printf("2   - Wi-Fi deinit(unset callbacks automatically)\n");
-               printf("3   - Activate Wi-Fi device\n");
+               printf(LOG_GREEN "3   - Activate Wi-Fi device\n" LOG_END);
                printf("4   - Deactivate Wi-Fi device\n");
                printf("5   - Is Wi-Fi activated?\n");
                printf("6   - Get connection state\n");
                printf("7   - Get MAC address\n");
                printf("8   - Get Wi-Fi interface name\n");
-               printf("9   - Scan request\n");
+               printf(LOG_GREEN "9   - Scan request\n" LOG_END);
                printf("a   - Get Connected AP\n");
                printf("b   - Get AP list\n");
-               printf("c   - Connect\n");
+               printf(LOG_GREEN "c   - Connect\n" LOG_END);
                printf("d   - Disconnect\n");
                printf("e   - Connect by wps pbc\n");
                printf("f   - Forget an AP\n");
@@ -1631,7 +1636,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("o   - Set EAP configuration\n");
                printf("p   - TDLS TearDown\n");
                printf("q   - TDLS Get Connected Peer\n");
-               printf("0   - Exit \n");
+               printf(LOG_RED "0   - Exit \n" LOG_END);
 
                printf("ENTER  - Show options menu.......\n");
        }