* @since_tizen 2.3
*/
typedef enum {
- TETHERING_TYPE_ALL = 0, /**< All type except for TETHERING_TYPE_RESERVED */
+ TETHERING_TYPE_ALL = 0, /**< All type */
TETHERING_TYPE_USB, /**< USB type */
TETHERING_TYPE_WIFI, /**< Wi-Fi type */
TETHERING_TYPE_BT, /**< BT type */
- TETHERING_TYPE_RESERVED, /**< Reserved type */
} tethering_type_e;
/**
typedef void (*tethering_wifi_settings_reloaded_cb)(tethering_error_e result, void *user_data);
/**
- * @brief Called when Wi-Fi AP settings are reloaded.
- * @since_tizen 2.3
- * @param[in] result The result of reloading the settings
- * @param[in] user_data The user data passed from the request function
- * @pre tethering_wifi_ap_reload_settings() will invoke this callback.
- */
-typedef void (*tethering_wifi_ap_settings_reloaded_cb)(tethering_error_e result, void *user_data);
-
-/**
* @brief Creates the handle for tethering.
* @since_tizen 2.3
* @privlevel platform
* @return 0 on success, otherwise negative error value
* @retval #TETHERING_ERROR_NONE Successful
* @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @see tethering_wifi_ap_set_channel()
+ * @see tethering_wifi_set_channel()
*/
int tethering_wifi_get_channel(tethering_h tethering, int *channel);
int tethering_wifi_get_mode(tethering_h tethering, tethering_wifi_mode_type_e *type);
/**
- * @brief Sets the security type of Wi-Fi AP.
- * @details If security type is not set, WPA2_PSK is used.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/tethering.admin
- * @param[in] tethering The tethering handle
- * @param[in] type The security type
- * @return 0 on success, otherwise negative error value
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OPERATION_FAILED Operation failed
- * @see tethering_wifi_ap_get_security_type()
- */
-int tethering_wifi_ap_set_security_type(tethering_h tethering, tethering_wifi_security_type_e type);
-
-/**
- * @brief Gets the security type of Wi-Fi AP.
- * @details If security type is not set, WPA2_PSK is used.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/tethering.admin
- * @param[in] tethering The tethering handle
- * @param[out] type The security type
- * @return 0 on success, otherwise negative error value
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @see tethering_wifi_ap_set_security_type()
- */
-int tethering_wifi_ap_get_security_type(tethering_h tethering, tethering_wifi_security_type_e *type);
-
-/**
- * @brief Sets the SSID (service set identifier) for Wi-Fi AP.
- * @details The SSID cannot exceed 32 bytes. If SSID is not set, device name is used as SSID.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/tethering.admin
- * @param[in] tethering The tethering handle
- * @param[in] ssid The SSID
- * @return 0 on success, otherwise negative error value
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OUT_OF_MEMORY Out of memory
- */
-int tethering_wifi_ap_set_ssid(tethering_h tethering, const char *ssid);
-
-/**
- * @brief Gets the SSID (service set identifier) for Wi-Fi AP.
- * @details If SSID is not set, Device name is used as SSID.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/tethering.admin
- * @remarks @a ssid must be released using free().
- * @param[in] tethering The tethering handle
- * @param[out] ssid The SSID
- * @return 0 on success, otherwise negative error value
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OUT_OF_MEMORY Out of memory
- */
-int tethering_wifi_ap_get_ssid(tethering_h tethering, char **ssid);
-
-/**
- * @brief Sets the visibility of SSID (service set identifier) for Wi-Fi AP.
- * @details If you set the visibility to invisible, then the SSID of this device is hidden and Wi-Fi scan won't find your device.
- * @details By default visibility is set to @c true.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/tethering.admin
- * @remarks This change is applied next time Wi-Fi tethering is enabled.
- * @param[in] tethering The tethering handle
- * @param[in] visible The visibility of SSID: (@c true = visible, @c false = invisible)
- * @return 0 on success, otherwise negative error value
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OPERATION_FAILED Operation failed
- * @see tethering_wifi_ap_get_ssid_visibility()
- */
-int tethering_wifi_ap_set_ssid_visibility(tethering_h tethering, bool visible);
-
-/**
- * @brief Gets the visibility of SSID (service set identifier) for Wi-Fi AP.
- * @details If the visibility is set to invisible, then the SSID of this device is hidden and Wi-Fi scan won't find your device.
- * @details By default visibility is set to @c true.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/tethering.admin
- * @param[in] tethering The tethering handle
- * @param[out] visible The visibility of SSID: (@c true = visible, @c false = invisible)
- * @return 0 on success, otherwise negative error value
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @see tethering_wifi_ap_set_ssid_visibility()
- */
-int tethering_wifi_ap_get_ssid_visibility(tethering_h tethering, bool *visible);
-
-/**
- * @brief Sets the passphrase for Wi-Fi AP.
- * @details If the passphrase is not set, random string of 8 characters will be used.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/tethering.admin
- * @param[in] tethering The tethering handle
- * @param[in] passphrase The passphrase
- * @return 0 on success, otherwise negative error value
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @see tethering_wifi_ap_get_passphrase()
- */
-int tethering_wifi_ap_set_passphrase(tethering_h tethering, const char *passphrase);
-
-/**
- * @brief Gets the passphrase for Wi-Fi AP.
- * @details If the passphrase is not set, random string of 8 characters will be used.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/tethering.admin
- * @remarks @a passphrase must be released using free().
- * @param[in] tethering The tethering handle
- * @param[out] passphrase The passphrase
- * @return 0 on success, otherwise negative error value
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OUT_OF_MEMORY Out of memory
- * @see tethering_wifi_ap_set_passphrase()
- */
-int tethering_wifi_ap_get_passphrase(tethering_h tethering, char **passphrase);
-
-/**
- * @brief Reloads the settings (SSID / Passphrase / Security type / SSID visibility) for Wi-Fi AP.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege %http://tizen.org/privilege/tethering.admin
- * @remarks Devices connected via MobileAP will be disconnected when the settings are reloaded.
- * @param[in] tethering The tethering handle
- * @param[in] callback The callback function to invoke
- * @param[in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise negative error value
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OPERATION_FAILED Operation failed
- */
-int tethering_wifi_ap_reload_settings(tethering_h tethering, tethering_wifi_ap_settings_reloaded_cb callback, void *user_data);
-/**
* @}
*/
const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
GVariant *parameters, gpointer user_data);
-static void __handle_wifi_ap_on(GDBusConnection *connection, const gchar *sender_name,
- const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
- GVariant *parameters, gpointer user_data);
-
-static void __handle_wifi_ap_off(GDBusConnection *connection, const gchar *sender_name,
- const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
- GVariant *parameters, gpointer user_data);
-
static void __handle_net_closed(GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
GVariant *parameters, gpointer user_data);
{0, SIGNAL_NAME_USB_TETHER_OFF, __handle_usb_tether_off},
{0, SIGNAL_NAME_BT_TETHER_ON, __handle_bt_tether_on},
{0, SIGNAL_NAME_BT_TETHER_OFF, __handle_bt_tether_off},
- {0, SIGNAL_NAME_WIFI_AP_ON, __handle_wifi_ap_on},
- {0, SIGNAL_NAME_WIFI_AP_OFF, __handle_wifi_ap_off},
{0, SIGNAL_NAME_NO_DATA_TIMEOUT, __handle_no_data_timeout},
{0, SIGNAL_NAME_LOW_BATTERY_MODE, __handle_low_battery_mode},
{0, SIGNAL_NAME_FLIGHT_MODE, __handle_flight_mode},
{
if (tethering_is_enabled(tethering, TETHERING_TYPE_USB) ||
tethering_is_enabled(tethering, TETHERING_TYPE_WIFI) ||
- tethering_is_enabled(tethering, TETHERING_TYPE_BT) ||
- tethering_is_enabled(tethering, TETHERING_TYPE_RESERVED))
+ tethering_is_enabled(tethering, TETHERING_TYPE_BT))
return true;
return false;
type = TETHERING_TYPE_WIFI;
else if (ap_type == MOBILE_AP_TYPE_BT)
type = TETHERING_TYPE_BT;
- else if (ap_type == MOBILE_AP_TYPE_WIFI_AP) {
- type = TETHERING_TYPE_RESERVED;
- } else {
+ else {
ERR("Not supported tethering type [%d]\n", ap_type);
goto DONE;
}
DBG("-\n");
}
-static void __handle_wifi_ap_on(GDBusConnection *connection, const gchar *sender_name,
- const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
- GVariant *parameters, gpointer user_data)
-{
- DBG("+\n");
-
- _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
-
- __tethering_h *th = (__tethering_h *)user_data;
- tethering_type_e type = TETHERING_TYPE_RESERVED;
- bool is_requested = false;
- tethering_enabled_cb ecb = NULL;
- void *data = NULL;
-
- ecb = th->enabled_cb[type];
- if (ecb == NULL)
- return;
- data = th->enabled_user_data[type];
-
- ecb(TETHERING_ERROR_NONE, type, is_requested, data);
- DBG("-\n");
-}
-
-static void __handle_wifi_ap_off(GDBusConnection *connection, const gchar *sender_name,
- const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
- GVariant *parameters, gpointer user_data)
-{
- DBG("+\n");
-
- _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
-
- __tethering_h *th = (__tethering_h *)user_data;
- tethering_type_e type = TETHERING_TYPE_RESERVED;
- tethering_disabled_cause_e code = TETHERING_DISABLED_BY_OTHERS;
- tethering_disabled_cb dcb = NULL;
- void *data = NULL;
- char *buf = NULL;
-
- dcb = th->disabled_cb[type];
- if (dcb == NULL)
- return;
- data = th->disabled_user_data[type];
- g_variant_get(parameters, "(s)", &buf);
- if (!g_strcmp0(buf, SIGNAL_MSG_NOT_AVAIL_INTERFACE))
- code = TETHERING_DISABLED_BY_WIFI_ON;
- else if (!g_strcmp0(buf, SIGNAL_MSG_TIMEOUT))
- code = TETHERING_DISABLED_BY_TIMEOUT;
- g_free(buf);
-
- dcb(TETHERING_ERROR_NONE, type, code, data);
-
- DBG("-\n");
-}
-
static void __handle_no_data_timeout(GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
GVariant *parameters, gpointer user_data)
void *data = NULL;
tethering_disabled_cause_e code = TETHERING_DISABLED_BY_LOW_BATTERY;
- for (type = TETHERING_TYPE_USB; type <= TETHERING_TYPE_RESERVED; type++) {
+ for (type = TETHERING_TYPE_USB; type <= TETHERING_TYPE_BT; type++) {
dcb = th->disabled_cb[type];
if (dcb == NULL)
continue;
void *data = NULL;
tethering_disabled_cause_e code = TETHERING_DISABLED_BY_FLIGHT_MODE;
- for (type = TETHERING_TYPE_USB; type <= TETHERING_TYPE_RESERVED; type++) {
+ for (type = TETHERING_TYPE_USB; type <= TETHERING_TYPE_BT; type++) {
dcb = th->disabled_cb[type];
if (dcb == NULL)
continue;
DBG("-\n");
}
-static void __wifi_ap_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
- gpointer user_data)
-{
- DBG("+\n");
-
- _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
- __tethering_h *th = (__tethering_h *)user_data;
- GError *g_error = NULL;
- GVariant *g_var;
- guint info;
- tethering_error_e error;
- tethering_enabled_cb ecb = th->enabled_cb[TETHERING_TYPE_RESERVED];
- void *data = th->enabled_user_data[TETHERING_TYPE_RESERVED];
-
- g_var = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
- if (g_error) {
- ERR("DBus error [%s]\n", g_error->message);
- if (g_error->code == G_DBUS_ERROR_NO_REPLY &&
- ++retry < TETHERING_ERROR_RECOVERY_MAX) {
- g_error_free(g_error);
- tethering_enable((tethering_h)th, TETHERING_TYPE_RESERVED);
- DBG("-\n");
- return;
- }
- if (g_error->code == G_DBUS_ERROR_ACCESS_DENIED)
- error = TETHERING_ERROR_PERMISSION_DENIED;
- else
- error = TETHERING_ERROR_OPERATION_FAILED;
- g_error_free(g_error);
- } else {
- g_variant_get(g_var, "(u)", &info);
- g_variant_unref(g_var);
- error = __get_error(info);
- }
- retry = 0;
-
- sigs[E_SIGNAL_WIFI_AP_ON].sig_id = g_dbus_connection_signal_subscribe(th->client_bus,
- NULL, TETHERING_SERVICE_INTERFACE, sigs[E_SIGNAL_WIFI_AP_ON].name,
- TETHERING_SERVICE_OBJECT_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
- sigs[E_SIGNAL_WIFI_AP_ON].cb, (gpointer)th, NULL);
-
- if (!ecb) {
- DBG("-\n");
- return;
- }
-
- ecb(error, TETHERING_TYPE_RESERVED, true, data);
- DBG("-\n");
-}
-
static void __disabled_cfm_cb(GObject *source_object, GAsyncResult *res,
gpointer user_data)
{
dcb(error, type, code, data);
break;
- case MOBILE_AP_DISABLE_WIFI_AP_CFM:
- sigs[E_SIGNAL_WIFI_AP_OFF].sig_id = g_dbus_connection_signal_subscribe(th->client_bus,
- NULL, TETHERING_SERVICE_INTERFACE, sigs[E_SIGNAL_WIFI_AP_OFF].name,
- TETHERING_SERVICE_OBJECT_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
- sigs[E_SIGNAL_WIFI_AP_OFF].cb, (gpointer)th, NULL);
-
- type = TETHERING_TYPE_RESERVED;
- dcb = th->disabled_cb[type];
- data = th->disabled_user_data[type];
- if (dcb)
- dcb(error, type, code, data);
- break;
-
case MOBILE_AP_DISABLE_CFM:
sigs[E_SIGNAL_WIFI_TETHER_OFF].sig_id = g_dbus_connection_signal_subscribe(th->client_bus,
DBG("-\n");
}
-static void __ap_settings_reloaded_cb(GObject *source_object, GAsyncResult *res,
- gpointer user_data)
-{
- DBG("+\n");
-
- _retm_if(user_data == NULL, "parameter(user_data) is NULL\n");
- GError *g_error = NULL;
- GVariant *g_var;
- guint info;
- __tethering_h *th = (__tethering_h *)user_data;
- tethering_error_e tethering_error;
-
- g_var = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
- if (g_error) {
- ERR("DBus fail [%s]\n", g_error->message);
- if (g_error->code == G_DBUS_ERROR_ACCESS_DENIED)
- tethering_error = TETHERING_ERROR_PERMISSION_DENIED;
- else
- tethering_error = TETHERING_ERROR_OPERATION_FAILED;
- g_error_free(g_error);
- }
- if (th->ap_settings_reloaded_cb == NULL) {
- DBG("There is no settings_reloaded_cb\n-\n");
- return;
- }
- g_variant_get(g_var, "(u)", &info);
- tethering_error = __get_error(info);
- g_variant_unref(g_var);
-
- th->ap_settings_reloaded_cb(tethering_error,
- th->ap_settings_reloaded_user_data);
-
- th->ap_settings_reloaded_cb = NULL;
- th->ap_settings_reloaded_user_data = NULL;
- DBG("-\n");
-}
-
static void __connect_signals(tethering_h tethering)
{
DBG("+\n");
g_strlcpy(buf, TETHERING_BT_IF, len);
break;
- case TETHERING_TYPE_RESERVED:
- g_strlcpy(buf, TETHERING_WIFI_IF, len);
- break;
-
default:
ERR("Not supported type : %d\n", type);
return false;
g_strlcpy(buf, TETHERING_BT_GATEWAY, len);
break;
- case TETHERING_TYPE_RESERVED:
- g_strlcpy(buf, TETHERING_WIFI_GATEWAY, len);
- break;
-
default:
ERR("Not supported type : %d\n", type);
return false;
return TETHERING_ERROR_NONE;
}
-static int __prepare_wifi_ap_settings(tethering_h tethering, _softap_settings_t *set)
-{
- DBG("+\n");
-
- __tethering_h *th = (__tethering_h *)tethering;
-
- if (th == NULL || set == NULL) {
- ERR("null parameter\n");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
-
- g_strlcpy(set->ssid, th->ap_ssid, sizeof(set->ssid));
- set->sec_type = th->sec_type;
- set->visibility = th->visibility;
-
- if (set->sec_type == TETHERING_WIFI_SECURITY_TYPE_NONE)
- g_strlcpy(set->key, "", sizeof(set->key));
- else
- g_strlcpy(set->key, th->passphrase, sizeof(set->key));
-
- DBG("-\n");
- return TETHERING_ERROR_NONE;
-}
-
static bool __check_precondition(tethering_type_e type)
{
int dnet_state = 0;
return TETHERING_ERROR_OPERATION_FAILED;
}
- th->ap_ssid = g_strdup(ssid);
- if (th->ap_ssid == NULL) {
- ERR("g_strdup failed\n");
- free(th);
- return TETHERING_ERROR_OPERATION_FAILED;
- }
-
#if !GLIB_CHECK_VERSION(2, 36, 0)
g_type_init();
#endif
g_error_free(error);
g_cancellable_cancel(cancellable);
g_object_unref(cancellable);
- g_free(th->ap_ssid);
free(th);
return TETHERING_ERROR_OPERATION_FAILED;
}
g_cancellable_cancel(th->cancellable);
g_object_unref(th->cancellable);
g_object_unref(th->client_bus);
- g_free(th->ap_ssid);
free(th);
return TETHERING_ERROR_OPERATION_FAILED;
}
if (th->ssid)
free(th->ssid);
- if (th->ap_ssid)
- free(th->ap_ssid);
g_object_unref(th->cancellable);
g_object_unref(th->client_bus_proxy);
g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_INFINITE);
- if (type != TETHERING_TYPE_RESERVED
- && __check_precondition(type) == FALSE) {
+ if (__check_precondition(type) == FALSE) {
DBG("-\n");
return TETHERING_ERROR_OPERATION_FAILED;
}
break;
- case TETHERING_TYPE_RESERVED: {
- _softap_settings_t set = {"", "", "", 0, false};
-
- ret = __prepare_wifi_ap_settings(tethering, &set);
- if (ret != TETHERING_ERROR_NONE) {
- ERR("softap settings initialization failed\n");
- return TETHERING_ERROR_OPERATION_FAILED;
- }
-
- g_dbus_connection_signal_unsubscribe(connection,
- sigs[E_SIGNAL_WIFI_AP_ON].sig_id);
-
- g_dbus_proxy_call(proxy, "enable_wifi_ap",
- g_variant_new("(ssii)", set.ssid, set.key, set.visibility, set.sec_type),
- G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable, (GAsyncReadyCallback) __wifi_ap_enabled_cfm_cb, (gpointer)tethering);
- break;
- }
case TETHERING_TYPE_ALL: {
_softap_settings_t set = {"", "", "", 0, false};
(GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
break;
- case TETHERING_TYPE_RESERVED:
- g_dbus_connection_signal_unsubscribe(connection,
- sigs[E_SIGNAL_WIFI_AP_OFF].sig_id);
-
- g_dbus_proxy_call(proxy, "disable_wifi_ap",
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
- (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
- break;
-
case TETHERING_TYPE_ALL:
g_dbus_connection_signal_unsubscribe(connection,
sigs[E_SIGNAL_USB_TETHER_OFF].sig_id);
vconf_type = VCONFKEY_MOBILE_HOTSPOT_MODE_BT;
break;
- case TETHERING_TYPE_RESERVED:
- vconf_type = VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP;
- break;
-
default:
ERR("Not supported type : %d\n", type);
break;
client.interface = TETHERING_TYPE_WIFI;
else if (interface == MOBILE_AP_TYPE_BT)
client.interface = TETHERING_TYPE_BT;
- else if (interface == MOBILE_AP_TYPE_WIFI_AP)
- client.interface = TETHERING_TYPE_RESERVED;
else {
ERR("Invalid interface\n");
g_free(key);
break;
}
DBG("interface is %d\n", client.interface);
- if (client.interface != type && (TETHERING_TYPE_ALL != type &&
- client.interface != TETHERING_TYPE_RESERVED)) {
+ if (client.interface != type && (TETHERING_TYPE_ALL != type)) {
g_free(key);
g_variant_unref(value);
break;
return TETHERING_ERROR_NONE;
}
-
-/**
- * @internal
- * @brief Sets the security type of Wi-Fi AP.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege http://tizen.org/privilege/tethering.admin
- * @details If security type is not set, WPA2_PSK is used
- * @param[in] tethering The handle of tethering
- * @param[in] type The security type
- * @return 0 on success, otherwise negative error value.
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OPERATION_FAILED Operation failed
- * @see tethering_wifi_ap_get_security_type()
- */
-API int tethering_wifi_ap_set_security_type(tethering_h tethering, tethering_wifi_security_type_e type)
-{
- CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
-
- _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(tethering) is NULL\n");
-
- __tethering_h *th = (__tethering_h *)tethering;
- th->sec_type = type;
- return TETHERING_ERROR_NONE;
-}
-
-/**
- * @internal
- * @brief Gets the security type of Wi-Fi AP.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege http://tizen.org/privilege/tethering.admin
- * @details If security type is not set, WPA2_PSK is used
- * @param[in] tethering The handle of tethering
- * @param[out] type The security type
- * @return 0 on success, otherwise negative error value.
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @see tethering_wifi_ap_set_security_type()
- */
-API int tethering_wifi_ap_get_security_type(tethering_h tethering, tethering_wifi_security_type_e *type)
-{
- CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
-
- _retvm_if(type == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(type) is NULL\n");
-
- __tethering_h *th = (__tethering_h *)tethering;
-
- *type = th->sec_type;
- return TETHERING_ERROR_NONE;
-}
-
-/**
- * @internal
- * @brief Sets the SSID (service set identifier) for Wi-Fi AP. The SSID cannot exceed 32 bytes.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege http://tizen.org/privilege/tethering.admin
- * @details If SSID is not set, Device name is used as SSID
- * @param[in] tethering The handle of tethering
- * @param[in] ssid The SSID
- * @return 0 on success, otherwise negative error value.
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OUT_OF_MEMORY Out of memory
- */
-API int tethering_wifi_ap_set_ssid(tethering_h tethering, const char *ssid)
-{
- CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
-
- _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(tethering) is NULL\n");
- _retvm_if(ssid == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(ssid) is NULL\n");
-
- __tethering_h *th = (__tethering_h *)tethering;
- char *p_ssid = NULL;
- int ssid_len = 0;
-
- ssid_len = strlen(ssid);
- if (ssid_len > TETHERING_WIFI_SSID_MAX_LEN) {
- ERR("parameter(ssid) is too long");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
-
- p_ssid = strdup(ssid);
- if (p_ssid == NULL) {
- ERR("strdup failed\n");
- return TETHERING_ERROR_OUT_OF_MEMORY;
- }
-
- if (th->ap_ssid)
- g_free(th->ap_ssid);
- th->ap_ssid = p_ssid;
-
- return TETHERING_ERROR_NONE;
-}
-
-/**
- * @internal
- * @brief Gets the SSID (service set identifier) for Wi-Fi AP.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege http://tizen.org/privilege/tethering.admin
- * @details If SSID is not set, Device name is used as SSID
- * @remarks @a ssid must be released with free() by you.
- * @param[in] tethering The handle of tethering
- * @param[out] ssid The SSID
- * @return 0 on success, otherwise negative error value.
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OUT_OF_MEMORY Out of memory
- */
-API int tethering_wifi_ap_get_ssid(tethering_h tethering, char **ssid)
-{
- CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
-
- _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(tethering) is NULL\n");
- _retvm_if(ssid == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(ssid) is NULL\n");
-
- __tethering_h *th = (__tethering_h *)tethering;
-
- *ssid = g_strdup(th->ap_ssid);
- if (*ssid == NULL) {
- ERR("strdup failed\n");
- return TETHERING_ERROR_OUT_OF_MEMORY;
- }
-
- return TETHERING_ERROR_NONE;
-}
-
-/**
- * @internal
- * @brief Sets the visibility of SSID(service set identifier) for Wi-Fi AP.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege http://tizen.org/privilege/tethering.admin
- * @details If you set the visibility invisible, then the SSID of this device is hidden. So, Wi-Fi scan can't find your device.
- * @details by default visibility is set to true.
- * @remarks This change is applied next time Wi-Fi tethering is enabled
- * @param[in] tethering The handle of tethering
- * @param[in] visible The visibility of SSID: (@c true = visible, @c false = invisible)
- * @return 0 on success, otherwise negative error value.
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OPERATION_FAILED Operation failed
- * @see tethering_wifi_ap_get_ssid_visibility()
- */
-API int tethering_wifi_ap_set_ssid_visibility(tethering_h tethering, bool visible)
-{
- CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
-
- _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(tethering) is NULL\n");
-
- __tethering_h *th = (__tethering_h *)tethering;
- th->visibility = visible;
- return TETHERING_ERROR_NONE;
-}
-
-/**
- * @internal
- * @brief Gets the visibility of SSID(service set identifier) for Wi-Fi AP.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege http://tizen.org/privilege/tethering.admin
- * @details If the visibility is set invisible, then the SSID of this device is hidden. So, Wi-Fi scan can't find your device.
- * @details by default visibility is set to true.
- * @param[in] tethering The handle of tethering
- * @param[out] visible The visibility of SSID: (@c true = visible, @c false = invisible)
- * @return 0 on success, otherwise negative error value.
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @see tethering_wifi_ap_set_ssid_visibility()
- */
-API int tethering_wifi_ap_get_ssid_visibility(tethering_h tethering, bool *visible)
-{
- CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
-
- _retvm_if(visible == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(visible) is NULL\n");
-
- __tethering_h *th = (__tethering_h *)tethering;
-
- *visible = th->visibility;
- return TETHERING_ERROR_NONE;
-}
-
-/**
- * @internal
- * @brief Sets the passphrase for Wi-Fi AP.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege http://tizen.org/privilege/tethering.admin
- * @details If the passphrase is not set, random string of 8 alphabets will be used.
- * @param[in] tethering The handle of tethering
- * @param[in] passphrase The passphrase
- * @return 0 on success, otherwise negative error value.
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @see tethering_wifi_ap_get_passphrase()
- */
-API int tethering_wifi_ap_set_passphrase(tethering_h tethering, const char *passphrase)
-{
- CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
-
- _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(tethering) is NULL\n");
- _retvm_if(passphrase == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(passphrase) is NULL\n");
-
- __tethering_h *th = (__tethering_h *)tethering;
- int passphrase_len = 0;
-
- passphrase_len = strlen(passphrase);
-
- if (passphrase_len < TETHERING_WIFI_KEY_MIN_LEN ||
- passphrase_len > TETHERING_WIFI_KEY_MAX_LEN) {
- ERR("parameter(passphrase) is too short or long\n");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
-
- if (!g_strcmp0(passphrase, th->passphrase))
- return TETHERING_ERROR_NONE;
-
- g_strlcpy(th->passphrase, passphrase, sizeof(th->passphrase));
- return TETHERING_ERROR_NONE;
-}
-
-/**
- * @internal
- * @brief Gets the passphrase for Wi-Fi AP.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege http://tizen.org/privilege/tethering.admin
- * @details If the passphrase is not set, random string of 8 alphabets will be used.
- * @remarks @a passphrase must be released with free() by you.
- * @param[in] tethering The handle of tethering
- * @param[out] passphrase The passphrase
- * @return 0 on success, otherwise negative error value.
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OUT_OF_MEMORY Out of memory
- * @see tethering_wifi_ap_set_passphrase()
- */
-API int tethering_wifi_ap_get_passphrase(tethering_h tethering, char **passphrase)
-{
- CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
-
- _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(tethering) is NULL\n");
- _retvm_if(passphrase == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(passphrase) is NULL\n");
-
- __tethering_h *th = (__tethering_h *)tethering;
-
- *passphrase = g_strdup(th->passphrase);
- if (*passphrase == NULL) {
- ERR("strdup is failed\n");
- return TETHERING_ERROR_OUT_OF_MEMORY;
- }
-
- return TETHERING_ERROR_NONE;
-}
-
-/**
- * @internal
- * @brief Reload the settings (SSID / Passphrase / Security type / SSID visibility) for Wi-Fi AP.
- * @since_tizen 2.3
- * @privlevel platform
- * @privilege http://tizen.org/privilege/tethering.admin
- * @remarks Connected devices via MobileAP will be disconnected when the settings are reloaded
- * @param[in] tethering The handle of tethering
- * @param[in] callback The callback function to invoke
- * @param[in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise negative error value.
- * @retval #TETHERING_ERROR_NONE Successful
- * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #TETHERING_ERROR_OPERATION_FAILED Operation failed
- */
-API int tethering_wifi_ap_reload_settings(tethering_h tethering, tethering_wifi_ap_settings_reloaded_cb callback, void *user_data)
-
-{
- CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
-
- _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(tethering) is NULL\n");
- _retvm_if(callback == NULL, TETHERING_ERROR_INVALID_PARAMETER,
- "parameter(callback) is NULL\n");
-
- __tethering_h *th = (__tethering_h *)tethering;
- _softap_settings_t set = {"", "", "", 0, false};
- GDBusProxy *proxy = th->client_bus_proxy;
- int ret = 0;
-
- DBG("+\n");
-
- if (th->ap_settings_reloaded_cb) {
- ERR("Operation in progress\n");
- return TETHERING_ERROR_OPERATION_FAILED;
- }
-
- ret = __prepare_wifi_ap_settings(tethering, &set);
- if (ret != TETHERING_ERROR_NONE) {
- ERR("softap settings initialization failed\n");
- return TETHERING_ERROR_OPERATION_FAILED;
- }
-
- th->ap_settings_reloaded_cb = callback;
- th->ap_settings_reloaded_user_data = user_data;
-
- g_dbus_proxy_call(proxy, "reload_wifi_ap_settings",
- g_variant_new("(ssii)", set.ssid, set.key, set.visibility, set.sec_type),
- G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
- (GAsyncReadyCallback) __ap_settings_reloaded_cb, (gpointer)tethering);
-
- return TETHERING_ERROR_NONE;
-}
g_strlcpy(str_buf, "Bluetooth Tethering", sizeof(str_buf));
break;
- case TETHERING_TYPE_RESERVED:
- g_strlcpy(str_buf, "Wi-Fi AP", sizeof(str_buf));
- break;
-
default:
g_strlcpy(str_buf, "Unknown", sizeof(str_buf));
break;
if (__is_err(ret) == true)
g_print("tethering_set_enabled_cb is failed\n");
- ret = tethering_set_enabled_cb(th, TETHERING_TYPE_RESERVED,
- cbs->enabled_cb, user_data);
- if (__is_err(ret) == true)
- g_print("tethering_set_enabled_cb is failed\n");
-
ret = tethering_set_disabled_cb(th, TETHERING_TYPE_ALL,
cbs->disabled_cb, user_data);
if (__is_err(ret) == true)
g_print("tethering_set_disabled_cb is failed\n");
- ret = tethering_set_disabled_cb(th, TETHERING_TYPE_RESERVED,
- cbs->disabled_cb, user_data);
- if (__is_err(ret) == true)
- g_print("tethering_set_disabled_cb is failed\n");
-
ret = tethering_set_connection_state_changed_cb(th, TETHERING_TYPE_ALL,
cbs->changed_cb, user_data);
if (__is_err(ret) == true)
g_print("tethering_set_connection_state_changed_cb is failed\n");
- ret = tethering_set_connection_state_changed_cb(th, TETHERING_TYPE_RESERVED,
- cbs->changed_cb, user_data);
- if (__is_err(ret) == true)
- g_print("tethering_set_connection_state_changed_cb is failed\n");
-
ret = tethering_wifi_set_security_type_changed_cb(th,
cbs->security_type_changed_cb, user_data);
if (__is_err(ret) == true)
if (__is_err(ret) == true)
g_print("tethering_unset_enabled_cb is failed\n");
- ret = tethering_unset_enabled_cb(th, TETHERING_TYPE_RESERVED);
- if (__is_err(ret) == true)
- g_print("tethering_unset_enabled_cb is failed\n");
-
ret = tethering_unset_disabled_cb(th, TETHERING_TYPE_ALL);
if (__is_err(ret) == true)
g_print("tethering_unset_disabled_cb is failed\n");
- ret = tethering_unset_disabled_cb(th, TETHERING_TYPE_RESERVED);
- if (__is_err(ret) == true)
- g_print("tethering_unset_disabled_cb is failed\n");
-
ret = tethering_unset_connection_state_changed_cb(th, TETHERING_TYPE_ALL);
if (__is_err(ret) == true)
g_print("tethering_unset_connection_state_changed_cb is failed\n");
- ret = tethering_unset_connection_state_changed_cb(th, TETHERING_TYPE_RESERVED);
- if (__is_err(ret) == true)
- g_print("tethering_unset_connection_state_changed_cb is failed\n");
-
ret = tethering_wifi_unset_security_type_changed_cb(th);
if (__is_err(ret) == true)
g_print("tethering_wifi_unset_security_type_changed_cb is failed\n");
return;
}
-static void __print_wifi_ap_setting(tethering_h th)
-{
- char *ssid = NULL;
- char *passphrase = NULL;
- bool visibility = false;
- tethering_wifi_security_type_e security_type = TETHERING_WIFI_SECURITY_TYPE_NONE;
-
- int error = TETHERING_ERROR_NONE;
-
- error = tethering_wifi_ap_get_ssid(th, &ssid);
- if (error != TETHERING_ERROR_NONE)
- __is_err(error);
- else
- g_print("\n\t** WiFi AP SSID : %s\n", ssid);
-
- error = tethering_wifi_ap_get_passphrase(th, &passphrase);
- if (error != TETHERING_ERROR_NONE)
- __is_err(error);
- else
- g_print("\t** WiFi AP passphrase : %s\n", passphrase);
-
- error = tethering_wifi_ap_get_ssid_visibility(th, &visibility);
- if (error != TETHERING_ERROR_NONE)
- __is_err(error);
- else
- g_print("\t** WiFi AP ssid visibility : %s\n",
- visibility ? "visible" : "invisible");
-
- error = tethering_wifi_ap_get_security_type(th, &security_type);
- if (error != TETHERING_ERROR_NONE)
- __is_err(error);
- else
- g_print("\t** WiFi AP security_type : %s\n",
- security_type ==
- TETHERING_WIFI_SECURITY_TYPE_NONE ?
- "open" : "wpa2-psk");
-
- if (ssid)
- free(ssid);
- if (passphrase)
- free(passphrase);
-
- return;
-}
-
bool __get_tethering_type(tethering_type_e *type)
{
int sel;
int ret;
- printf("Select tethering type (1:Wi-Fi, 2:BT, 3:USB 4:WiFi AP, 5:ALL)\n");
+ printf("Select tethering type (1:Wi-Fi, 2:BT, 3:USB 4:ALL)\n");
ret = scanf("%9d", &sel);
if (ret < 0) {
printf("scanf is failed!!\n");
*type = TETHERING_TYPE_USB;
break;
case 4:
- *type = TETHERING_TYPE_RESERVED;
- break;
- case 5:
*type = TETHERING_TYPE_ALL;
break;
default:
return 1;
}
-static int test_tethering_wifi_ap_get_setting(void)
-{
- __print_wifi_ap_setting(th);
- return 1;
-}
-
static int test_tethering_wifi_set_ssid(void)
{
int ret;
return 1;
}
-static int test_tethering_wifi_ap_set_ssid(void)
-{
- int ret;
- char ssid[100];
-
- printf("Input SSID for Wi-Fi AP tethering: ");
- ret = scanf("%99s", ssid);
- if (ret < 0) {
- printf("scanf is failed!!\n");
- return -1;
- }
-
- ret = tethering_wifi_ap_set_ssid(th, ssid);
- if (__is_err(ret) == true) {
- printf("Fail to set wifi ap ssid!!\n");
- return -1;
- }
- return 1;
-}
-
-static int test_tethering_wifi_ap_set_security_type(void)
-{
- int ret;
- int security_type;
-
- printf("Input security type for Wi-Fi AP tethering (0:NONE, 1:WPA2_PSK)");
- ret = scanf("%9d", &security_type);
- if (ret < 0) {
- printf("scanf is failed!!\n");
- return -1;
- }
-
- ret = tethering_wifi_ap_set_security_type(th, security_type);
- if (__is_err(ret) == true) {
- printf("Fail to set security type!!\n");
- return -1;
- }
- return 1;
-}
-
-static int test_tethering_wifi_ap_set_visibility(void)
-{
- int ret;
- int visibility;
-
- printf("Input security type for Wi-Fi tethering (0:invisible, 1:visible)");
- ret = scanf("%9d", &visibility);
- if (ret < 0) {
- printf("scanf is failed!!\n");
- return -1;
- }
-
- ret = tethering_wifi_ap_set_ssid_visibility(th, visibility);
- if (__is_err(ret) == true) {
- printf("Fail to set visibility!!\n");
- return -1;
- }
- return 1;
-}
-
-static int test_tethering_wifi_ap_set_passphrase(void)
-{
- int ret;
- char passphrase[100];
-
- printf("Input passphrase for Wi-Fi tethering: ");
- ret = scanf("%99s", passphrase);
- if (ret < 0) {
- printf("scanf is failed!!\n");
- return -1;
- }
-
- ret = tethering_wifi_ap_set_passphrase(th, passphrase);
- if (__is_err(ret) == true) {
- printf("Fail to set passphrase!!\n");
- return -1;
- }
- return 1;
-}
-
static int test_tethering_wifi_reload_settings(void)
{
int ret = tethering_wifi_reload_settings(th, __settings_reloaded_cb, NULL);
return 1;
}
-static int test_tethering_wifi_ap_reload_settings(void)
-{
- int ret = tethering_wifi_ap_reload_settings(th, __settings_reloaded_cb, NULL);
-
- if (__is_err(ret) == true) {
- printf("Fail to reload wifi tethering!!\n");
- return -1;
- }
- return 1;
-}
-
int main(int argc, char **argv)
{
GMainLoop *mainloop;
printf("6 - Get interface information\n");
printf("7 - Get data usage\n");
printf("8 - Get Wi-Fi tethering setting\n");
- printf("9 - Get Wi-Fi AP setting\n");
printf("a - Set Wi-Fi tethering SSID\n");
printf("b - Set Wi-Fi tethering security type\n");
printf("c - Set Wi-Fi tethering visibility\n");
printf("d - Set Wi-Fi tethering passphrase\n");
printf("e - Set Wi-Fi tethering mac filtering\n");
printf("f - Add/Remove MAC adress to/from allowed/blocked list\n");
- printf("g - Set Wi-Fi AP SSID\n");
- printf("h - Set Wi-Fi AP security type\n");
- printf("i - Set Wi-Fi AP visibility\n");
- printf("j - Set Wi-Fi AP passphrase\n");
printf("k - Reload Wi-Fi tethering\n");
- printf("l - Reload Wi-Fi AP\n");
printf("m - Set Wi-Fi channel\n");
printf("n - Set Wi-Fi hw_mode\n");
printf("o - Enable dhcp server\n");
case '8':
rv = test_tethering_wifi_get_setting();
break;
- case '9':
- rv = test_tethering_wifi_ap_get_setting();
- break;
case 'a':
rv = test_tethering_wifi_set_ssid();
break;
case 'f':
rv = test_tethering_manage_mac_list();
break;
- case 'g':
- rv = test_tethering_wifi_ap_set_ssid();
- break;
- case 'h':
- rv = test_tethering_wifi_ap_set_security_type();
- break;
- case 'i':
- rv = test_tethering_wifi_ap_set_visibility();
- break;
- case 'j':
- rv = test_tethering_wifi_ap_set_passphrase();
- break;
case 'k':
rv = test_tethering_wifi_reload_settings();
break;
- case 'l':
- rv = test_tethering_wifi_ap_reload_settings();
- break;
case 'm':
rv = test_tethering_wifi_set_channel();
break;