From a5203bc356d9186a4e0c18704537d25f33d57595 Mon Sep 17 00:00:00 2001 From: Niraj Kumar Goit Date: Fri, 18 Sep 2020 00:32:47 +0530 Subject: [PATCH] Added APIs to set and get Wi-Fi Sharing flag. Change-Id: Ib721e2038f7702e8ccc328603be7a4b9ae159401 Signed-off-by: Niraj Kumar Goit --- include/tethering.h | 25 +++++++++++++++++++++++++ include/tethering_private.h | 1 + packaging/capi-network-tethering.spec | 2 +- src/tethering.c | 31 +++++++++++++++++++++++++++++++ tests/tethering-gtest-wifi.cpp | 26 ++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 1 deletion(-) diff --git a/include/tethering.h b/include/tethering.h index a8cf64e..fb9d874 100644 --- a/include/tethering.h +++ b/include/tethering.h @@ -1420,6 +1420,31 @@ int tethering_wifi_set_wps_pin(tethering_h tethering, const char *wps_pin); */ int tethering_wifi_is_sharing_supported(tethering_h tethering, bool *supported); +/** + * @brief Sets the wifi-sharing flag. + * @since_tizen 6.0 + * @privlevel platform + * @param[in] tethering The tethering handle + * @param[in] sharing @c true if wifi-sharing is set, \n @c false if wifi-sharing is unset + * @return 0 on success, otherwise a negative error value + * @retval #TETHERING_ERROR_NONE Successful + * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #TETHERING_ERROR_NOT_SUPPORTED API is not supported + */ +int tethering_wifi_set_sharing(tethering_h tethering, bool sharing); + +/** + * @brief Gets the wifi-sharing flag. + * @since_tizen 6.0 + * @privlevel platform + * @param[in] tethering The tethering handle + * @param[out] sharing @c true if wifi-sharing is set, \n @c otherwise false. + * @return 0 on success, otherwise a negative error value + * @retval #TETHERING_ERROR_NONE Successful + * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #TETHERING_ERROR_NOT_SUPPORTED API is not supported + */ +int tethering_wifi_get_sharing(tethering_h tethering, bool *sharing); /** * @} diff --git a/include/tethering_private.h b/include/tethering_private.h index d7bca36..1f87420 100644 --- a/include/tethering_private.h +++ b/include/tethering_private.h @@ -300,6 +300,7 @@ typedef struct { bool port_forwarding; bool port_filtering; bool dhcp_enabled; + bool wifi_sharing; int channel; int wifi_max_connected; unsigned int txpower; diff --git a/packaging/capi-network-tethering.spec b/packaging/capi-network-tethering.spec index f8b4f84..c7aa33b 100644 --- a/packaging/capi-network-tethering.spec +++ b/packaging/capi-network-tethering.spec @@ -1,6 +1,6 @@ Name: capi-network-tethering Summary: Tethering Framework -Version: 1.1.2 +Version: 1.1.3 Release: 1 Group: System/Network License: Apache-2.0 diff --git a/src/tethering.c b/src/tethering.c index 84a18e7..6c0ba3e 100755 --- a/src/tethering.c +++ b/src/tethering.c @@ -1490,6 +1490,7 @@ API int tethering_create(tethering_h *tethering) th->sec_type = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK; th->visibility = true; th->mac_filter = false; + th->wifi_sharing = false; th->channel = TETHERING_WIFI_CHANNEL; th->mode_type = TETHERING_WIFI_MODE_TYPE_G; th->wifi_max_connected = TETHERING_WIFI_MAX_STA; @@ -4670,3 +4671,33 @@ API int tethering_wifi_is_sharing_supported(tethering_h tethering, bool *support error: return ret; } + +API int tethering_wifi_set_sharing(tethering_h tethering, bool sharing) +{ + CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE); + CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE); + + _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER, + "parameter(tethering) is NULL\n"); + + __tethering_h *th = (__tethering_h *)tethering; + th->wifi_sharing = sharing; + + return TETHERING_ERROR_NONE; +} + +API int tethering_wifi_get_sharing(tethering_h tethering, bool *sharing) +{ + CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE); + CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE); + + _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER, + "parameter(tethering) is NULL\n"); + _retvm_if(sharing == NULL, TETHERING_ERROR_INVALID_PARAMETER, + "parameter(sharing) is NULL\n"); + + __tethering_h *th = (__tethering_h *)tethering; + *sharing = th->wifi_sharing; + + return TETHERING_ERROR_NONE; +} diff --git a/tests/tethering-gtest-wifi.cpp b/tests/tethering-gtest-wifi.cpp index c813f29..5a53e1e 100755 --- a/tests/tethering-gtest-wifi.cpp +++ b/tests/tethering-gtest-wifi.cpp @@ -800,3 +800,29 @@ TEST_F(WiFiTetheringTest, SetWpsPinP) { EXPECT_EQ(TETHERING_ERROR_NONE, tethering_wifi_set_wps_pin(handle, "1234567")); } + +TEST_F(WiFiTetheringTest, SetSharingN) +{ + EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_wifi_set_sharing(NULL, true)); +} + +TEST_F(WiFiTetheringTest, SetSharingP) +{ + EXPECT_EQ(TETHERING_ERROR_NONE, tethering_wifi_set_sharing(handle, true)); +} + +TEST_F(WiFiTetheringTest, GetSharingN) +{ + bool sharing; + + EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_wifi_get_sharing(NULL, &sharing)); + EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_wifi_get_sharing(handle, NULL)); + EXPECT_EQ(TETHERING_ERROR_INVALID_PARAMETER, tethering_wifi_get_sharing(NULL, NULL)); +} + +TEST_F(WiFiTetheringTest, GetSharingP) +{ + bool sharing; + + EXPECT_EQ(TETHERING_ERROR_NONE, tethering_wifi_get_ssid_visibility(handle, &sharing)); +} -- 2.7.4