From: Seungyoun Ju Date: Tue, 15 Jan 2013 07:22:07 +0000 (+0900) Subject: Wi-Fi tethering settings are set asynchronously X-Git-Tag: submit/tizen_2.1/20130424.230634~1^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9614750718c24f0ade89f6b80016e1818bc5fa6a;p=platform%2Fcore%2Fapi%2Ftethering.git Wi-Fi tethering settings are set asynchronously - Issues Wi-Fi tethering setting APIs are failed while Wi-Fi tethering is being enabled. - Fix description Wi-Fi tethering settings can be modified after Wi-Fi tethering is disabled automatically. It makes Wi-Fi tethering settings to be modified while Wi-Fi tethering is being disabled. But because Wi-Fi tethering state is checked when setting APIs are called, setting APIs are failed. It is better not to check Wi-Fi tethering state and to provide the way to re-load configuration. This change only includes "Wi-Fi tethering state is not checked when settings are modified". Reload configuration change should be provided later. Change-Id: Iae0514af227fd707773653bde4400cac030b3763 --- diff --git a/include/tethering_private.h b/include/tethering_private.h index 56e55ac..5e68375 100644 --- a/include/tethering_private.h +++ b/include/tethering_private.h @@ -83,24 +83,9 @@ extern "C" { * from mobileap_lib.h */ -/** -* WiFi tethering configuration -*/ -#define TETHERING_WIFI_CHANNEL 7 /**< Channel number */ -#define TETHERING_WIFI_BSSID_LEN 6 /**< BSSID Length */ -#define TETHERING_WIFI_PASSPHRASE_MIN_LEN 8 /**< Minimum length of wifi key */ -#define TETHERING_WIFI_PASSPHRASE_MAX_LEN 63 /**< Maximum length of wifi key */ - /** * Common configuration */ -#define TETHERING_MAX_WIFI_STA 8 -#define TETHERING_MAX_BT_STA 7 -#define TETHERING_MAX_USB_STA 1 -#define TETHERING_MAX_CONNECTED_STA 16 /**< Maximum connected station. 8(Wi-Fi) + 7(BT) + 1(USB) */ - -#define TETHERING_NAME_UNKNOWN "UNKNOWN" - #define TETHERING_TYPE_MAX 4 /**< All, USB, Wi-Fi, BT */ #define TETHERING_STR_INFO_LEN 20 /**< length of the ip or mac address */ #define TETHERING_STR_HOSTNAME_LEN 32 /**< length of the hostname */ @@ -192,6 +177,7 @@ typedef enum { #define SIGNAL_NAME_DHCP_STATUS "dhcp_status" #define SIGNAL_MSG_NOT_AVAIL_INTERFACE "Interface is not available" +#define SIGNAL_MSG_TIMEOUT "There is no connection for a while" /* Network Interface */ #define TETHERING_SUBNET_MASK "255.255.255.0" diff --git a/packaging/capi-network-tethering.spec b/packaging/capi-network-tethering.spec index c43b978..a6f4f7f 100644 --- a/packaging/capi-network-tethering.spec +++ b/packaging/capi-network-tethering.spec @@ -1,9 +1,9 @@ Name: capi-network-tethering Summary: Tethering Framework -Version: 0.0.9 +Version: 0.0.10 Release: 1 Group: TO_BE/FILLED_IN -License: TO_BE/FILLED_IN +License: Apache License Version 2.0 Source0: %{name}-%{version}.tar.gz Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -53,6 +53,9 @@ rm -rf %{buildroot} %{_libdir}/*.so %changelog +* Tue Jan 15 2013 Seungyoun Ju 0.0.10-1 +- Wi-Fi tethering state is not checked when its settings are modified + * Fri Nov 02 2012 Seungyoun Ju 0.0.9-1 - Manifest file is added for SMACK diff --git a/src/tethering.c b/src/tethering.c index e2ebbfa..bb6e892 100644 --- a/src/tethering.c +++ b/src/tethering.c @@ -235,6 +235,9 @@ static void __handle_wifi_tether_off(DBusGProxy *proxy, const char *value_name, if (!g_strcmp0(value_name, SIGNAL_MSG_NOT_AVAIL_INTERFACE)) code = TETHERING_DISABLED_BY_WIFI_ON; + else if (!g_strcmp0(value_name, SIGNAL_MSG_TIMEOUT)) + code = TETHERING_DISABLED_BY_TIMEOUT; + dcb(TETHERING_ERROR_NONE, type, code, data); return; @@ -279,6 +282,7 @@ static void __handle_usb_tether_off(DBusGProxy *proxy, const char *value_name, g if (!g_strcmp0(value_name, SIGNAL_MSG_NOT_AVAIL_INTERFACE)) code = TETHERING_DISABLED_BY_USB_DISCONNECTION; + dcb(TETHERING_ERROR_NONE, type, code, data); return; @@ -323,6 +327,9 @@ static void __handle_bt_tether_off(DBusGProxy *proxy, const char *value_name, gp if (!g_strcmp0(value_name, SIGNAL_MSG_NOT_AVAIL_INTERFACE)) code = TETHERING_DISABLED_BY_BT_OFF; + else if (!g_strcmp0(value_name, SIGNAL_MSG_TIMEOUT)) + code = TETHERING_DISABLED_BY_TIMEOUT; + dcb(TETHERING_ERROR_NONE, type, code, data); return; @@ -416,6 +423,7 @@ static void __cfm_cb(DBusGProxy *remoteobj, guint event, guint info, if (g_error) { ERR("DBus error [%s]\n", g_error->message); + g_error_free(g_error); return; } @@ -650,6 +658,58 @@ static bool __get_gateway_addr(tethering_type_e type, char *buf, unsigned int le return true; } +static void __deinit_cb(DBusGProxy *remoteobj, + GError *error, gpointer user_data) +{ + _retm_if(user_data == NULL, "parameter(user_data) is NULL\n"); + + if (error) { + ERR("DBus fail [%s]\n", error->message); + g_error_free(error); + } + + return; +} + +static void __wifi_set_security_type_cb(DBusGProxy *remoteobj, + GError *error, gpointer user_data) +{ + _retm_if(user_data == NULL, "parameter(user_data) is NULL\n"); + + if (error) { + ERR("DBus fail [%s]\n", error->message); + g_error_free(error); + } + + return; +} + +static void __wifi_set_ssid_visibility_cb(DBusGProxy *remoteobj, + GError *error, gpointer user_data) +{ + _retm_if(user_data == NULL, "parameter(user_data) is NULL\n"); + + if (error) { + ERR("DBus fail [%s]\n", error->message); + g_error_free(error); + } + + return; +} + +static void __wifi_set_passphrase_cb(DBusGProxy *remoteobj, + GError *error, gpointer user_data) +{ + _retm_if(user_data == NULL, "parameter(user_data) is NULL\n"); + + if (error) { + ERR("DBus fail [%s]\n", error->message); + g_error_free(error); + } + + return; +} + /** * @brief Creates the handle of tethering. * @remarks The @a tethering must be released tethering_destroy() by you. @@ -715,16 +775,13 @@ API int tethering_destroy(tethering_h tethering) "parameter(tethering) is NULL\n"); __tethering_h *th = (__tethering_h *)tethering; - GError *error = NULL; DBG("Tethering Handle : 0x%X\n", th); - com_samsung_mobileap_deinit(th->client_bus_proxy, &error); - if (error) { - ERR("tethering_destroy is failed [%s]", error->message); - g_error_free(error); - } __disconnect_signals(tethering); + com_samsung_mobileap_deinit_async(th->client_bus_proxy, __deinit_cb, + (gpointer)tethering); + g_object_unref(th->client_bus_proxy); dbus_g_connection_unref(th->client_bus); memset(th, 0x00, sizeof(__tethering_h)); @@ -1479,14 +1536,10 @@ API int tethering_wifi_set_security_type(tethering_h tethering, tethering_wifi_s { _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER, "parameter(tethering) is NULL\n"); - _retvm_if(tethering_is_enabled(tethering, TETHERING_TYPE_WIFI) == true, - TETHERING_ERROR_INVALID_OPERATION, - "Wi-Fi tethering is enabled\n"); DBG("+\n"); __tethering_h *th = (__tethering_h *)tethering; DBusGProxy *proxy = th->client_bus_proxy; - GError *error = NULL; char *type_str = NULL; if (type == TETHERING_WIFI_SECURITY_TYPE_NONE) { @@ -1498,12 +1551,8 @@ API int tethering_wifi_set_security_type(tethering_h tethering, tethering_wifi_s return TETHERING_ERROR_INVALID_PARAMETER; } - com_samsung_mobileap_set_wifi_tethering_security_type(proxy, type_str, &error); - if (error != NULL) { - ERR("DBus fail : %s\n", error->message); - g_error_free(error); - return TETHERING_ERROR_OPERATION_FAILED; - } + com_samsung_mobileap_set_wifi_tethering_security_type_async(proxy, type_str, + __wifi_set_security_type_cb, (gpointer)tethering); DBG("-\n"); return TETHERING_ERROR_NONE; @@ -1624,14 +1673,10 @@ int tethering_wifi_set_ssid_visibility(tethering_h tethering, bool visible) { _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER, "parameter(tethering) is NULL\n"); - _retvm_if(tethering_is_enabled(tethering, TETHERING_TYPE_WIFI) == true, - TETHERING_ERROR_INVALID_OPERATION, - "Wi-Fi tethering is enabled\n"); DBG("+\n"); __tethering_h *th = (__tethering_h *)tethering; DBusGProxy *proxy = th->client_bus_proxy; - GError *error = NULL; int hide_mode = 0; if (visible) @@ -1639,12 +1684,8 @@ int tethering_wifi_set_ssid_visibility(tethering_h tethering, bool visible) else hide_mode = VCONFKEY_MOBILE_AP_HIDE_ON; - com_samsung_mobileap_set_wifi_tethering_hide_mode(proxy, hide_mode, &error); - if (error != NULL) { - ERR("dbus fail : %s\n", error->message); - g_error_free(error); - return TETHERING_ERROR_OPERATION_FAILED; - } + com_samsung_mobileap_set_wifi_tethering_hide_mode_async(proxy, hide_mode, + __wifi_set_ssid_visibility_cb, (gpointer)tethering); DBG("-\n"); return TETHERING_ERROR_NONE; @@ -1666,7 +1707,7 @@ API int tethering_wifi_get_ssid_visibility(tethering_h tethering, bool *visible) _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER, "parameter(tethering) is NULL\n"); _retvm_if(visible == NULL, TETHERING_ERROR_INVALID_PARAMETER, - "parameter(enabled) is NULL\n"); + "parameter(visible) is NULL\n"); DBG("+\n"); __tethering_h *th = (__tethering_h *)tethering; @@ -1709,24 +1750,17 @@ API int tethering_wifi_set_passphrase(tethering_h tethering, const char *passphr { _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER, "parameter(tethering) is NULL\n"); - _retvm_if(tethering_is_enabled(tethering, TETHERING_TYPE_WIFI) == true, - TETHERING_ERROR_INVALID_OPERATION, - "Wi-Fi tethering is enabled\n"); _retvm_if(passphrase == NULL, TETHERING_ERROR_INVALID_PARAMETER, "parameter(passphrase) is NULL\n"); DBG("+\n"); __tethering_h *th = (__tethering_h *)tethering; DBusGProxy *proxy = th->client_bus_proxy; - GError *error = NULL; - com_samsung_mobileap_set_wifi_tethering_passphrase(proxy, - passphrase, strlen(passphrase), &error); - if (error != NULL) { - ERR("dbus fail : %s\n", error->message); - g_error_free(error); - return TETHERING_ERROR_OPERATION_FAILED; - } + + com_samsung_mobileap_set_wifi_tethering_passphrase_async(proxy, + passphrase, strlen(passphrase), + __wifi_set_passphrase_cb, (gpointer)tethering); DBG("-\n"); return TETHERING_ERROR_NONE;