Added to check tdls feature 37/56437/1 accepted/tizen/ivi/20160218.023327 accepted/tizen/mobile/20160113.050256 accepted/tizen/tv/20160113.050320 accepted/tizen/wearable/20160113.050345 submit/tizen/20160108.030209 submit/tizen/20160113.002706 submit/tizen_common/20160218.142243 submit/tizen_ivi/20160217.000000 submit/tizen_ivi/20160217.000002
authorhyunuktak <hyunuk.tak@samsung.com>
Fri, 8 Jan 2016 02:54:19 +0000 (11:54 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Fri, 8 Jan 2016 02:54:45 +0000 (11:54 +0900)
Change-Id: I551a607ad60731953600693da91d0407150278c7
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
include/net_wifi_private.h
packaging/capi-network-wifi.spec
src/libnetwork.c
src/net_wifi.c
test/wifi_test.c

index f5b74e5..210af6b 100755 (executable)
@@ -37,10 +37,19 @@ extern "C" {
 #define WIFI_WARN      3
 
 #define WIFI_FEATURE   "http://tizen.org/feature/network.wifi"
+#define WIFI_TDLS_FEATURE      "http://tizen.org/feature/network.wifi.tdls"
 
-#define CHECK_FEATURE_SUPPORTED(feature_name) \
+typedef enum
+{
+       WIFI_SUPPORTED_FEATURE_WIFI,
+       WIFI_SUPPORTED_FEATURE_WIFI_TDLS,
+       WIFI_SUPPORTED_FEATURE_MAX,
+} wifi_supported_feature_e;
+
+
+#define CHECK_FEATURE_SUPPORTED(...) \
        do { \
-               int rv = _wifi_check_feature_supported(feature_name); \
+               int rv = _wifi_check_feature_supported(__VA_ARGS__, NULL); \
                if( rv != WIFI_ERROR_NONE ) \
                        return rv; \
        } while(0)
@@ -115,7 +124,8 @@ wifi_connection_state_e _wifi_convert_to_ap_state(net_state_type_t state);
 guint _wifi_callback_add(GSourceFunc func, gpointer user_data);
 void _wifi_callback_cleanup(void);
 
-int _wifi_check_feature_supported(const char *feature_name);
+bool __libnet_check_feature_supported(const char *key, wifi_supported_feature_e feature);
+int _wifi_check_feature_supported(const char *feature_name, ...);
 
 int        _wifi_dbus_init(void);
 int        _wifi_dbus_deinit(void);
index 3914d5e..867cb99 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          capi-network-wifi
 Summary:       Network Wi-Fi library in TIZEN C API
-Version:       1.0.64
+Version:       1.0.65
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index b4b0c63..1baa2ce 100755 (executable)
@@ -69,6 +69,8 @@ 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, };
 
 wifi_dbus *g_dbus_h = NULL;
 
@@ -1340,26 +1342,48 @@ void _wifi_callback_cleanup(void)
        managed_idler_list = NULL;
 }
 
-int _wifi_check_feature_supported(const char *feature_name)
+bool __libnet_check_feature_supported(const char *key, wifi_supported_feature_e feature)
 {
-       if (is_feature_checked) {
-               if (!feature_supported) {
-                       LOGE("%s feature is disabled", feature_name);
-                       return WIFI_ERROR_NOT_SUPPORTED;
-               }
-       } else {
-               if (!system_info_get_platform_bool(feature_name, &feature_supported)) {
-                       is_feature_checked = true;
-                       if (!feature_supported) {
-                               LOGE("%s feature is disabled", feature_name);
-                               return WIFI_ERROR_NOT_SUPPORTED;
-                       }
-               } else {
-                       LOGE("Error - Feature getting from System Info");
+       if (!wifi_is_feature_checked[feature]) {
+               if (system_info_get_platform_bool(key, &wifi_feature_supported[feature]) < 0) {
+                       WIFI_LOG(WIFI_ERROR, "Error - Feature getting from System Info");
+                       set_last_result(WIFI_ERROR_OPERATION_FAILED);
                        return WIFI_ERROR_OPERATION_FAILED;
                }
+               wifi_is_feature_checked[feature] = true;
+       }
+       return wifi_feature_supported[feature];
+}
+
+int _wifi_check_feature_supported(const char *feature_name, ...)
+{
+       va_list list;
+       const char *key;
+       bool value = false;
+       bool feature_supported = false;
+
+       va_start(list, feature_name);
+       key = feature_name;
+       while (1) {
+               if (strcmp(key, WIFI_FEATURE) == 0)
+                       value = __libnet_check_feature_supported(key, WIFI_SUPPORTED_FEATURE_WIFI);
+               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;
+       }
+       if (!feature_supported) {
+               WIFI_LOG(WIFI_ERROR, "Error - Feature is not supported");
+               set_last_result(WIFI_ERROR_NOT_SUPPORTED);
+               va_end(list);
+               return WIFI_ERROR_NOT_SUPPORTED;
        }
 
+       va_end(list);
+       set_last_result(WIFI_ERROR_NONE);
        return WIFI_ERROR_NONE;
 }
 
index 43c9fcc..9183603 100755 (executable)
@@ -549,6 +549,7 @@ EXPORT_API int wifi_unset_rssi_level_changed_cb(void)
 EXPORT_API int wifi_tdls_disconnect(const char* peer_mac_addr)
 {
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
 
        if (_wifi_is_init() == false) {
                WIFI_LOG(WIFI_ERROR, "Not initialized");
@@ -574,6 +575,7 @@ EXPORT_API int wifi_tdls_disconnect(const char* peer_mac_addr)
 EXPORT_API int wifi_tdls_get_connected_peer(char** peer_mac_addr)
 {
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
 
        if (_wifi_is_init() == false) {
                WIFI_LOG(WIFI_ERROR, "Not initialized");
@@ -604,11 +606,13 @@ EXPORT_API int wifi_tdls_get_connected_peer(char** peer_mac_addr)
 EXPORT_API int wifi_tdls_set_state_changed_cb(wifi_tdls_state_changed_cb callback, void* user_data)
 {
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
        return WIFI_ERROR_NONE;
 }
 
 EXPORT_API int wifi_tdls_unset_state_changed_cb(void)
 {
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       CHECK_FEATURE_SUPPORTED(WIFI_TDLS_FEATURE);
        return WIFI_ERROR_NONE;
 }
index dacf27e..7b857ef 100755 (executable)
@@ -1630,9 +1630,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("n   - Set configuration proxy and hidden\n");
                printf("o   - Set EAP configuration\n");
                printf("p   - TDLS TearDown\n");
-               printf("q   - TDLS Set Connected Callback\n");
-               printf("r   - TDLS Set Disconnected Callback\n");
-               printf("s   - TDLS Get Connected Peer\n");
+               printf("q   - TDLS Get Connected Peer\n");
                printf("0   - Exit \n");
 
                printf("ENTER  - Show options menu.......\n");
@@ -1714,7 +1712,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'p':
                rv = test_wifi_tdls_disconnect();
                break;
-       case 'r':
+       case 'q':
                rv = test_wifi_tdls_get_connected_peer();
                break;