SET(dependents "dlog glib-2.0 capi-base-common dbus-glib-1 vconf")
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+
INCLUDE(FindPkgConfig)
pkg_check_modules(${fw_name} REQUIRED ${dependents})
FOREACH(flag ${${fw_name}_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
IF("${ARCH}" STREQUAL "arm")
ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
ADD_DEFINITIONS("-DTIZEN_DEBUG")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed -Wl,--rpath=%{_libdir}")
FIND_PROGRAM(MARSHALTOOL NAMES glib-genmarshal)
EXEC_PROGRAM("${MARSHALTOOL}" ARGS "--prefix=marshal ${INC_DIR}/marshal.list --header > ${INC_DIR}/marshal.h")
SET_TARGET_PROPERTIES(${fw_name} PROPERTIES SOVERSION 0.1.0)
-INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
INSTALL(
DIRECTORY ${INC_DIR}/ DESTINATION include/network
FILES_MATCHING
${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
@ONLY
)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
ADD_SUBDIRECTORY(test)
int tethering_get_data_usage(tethering_h tethering, tethering_data_usage_cb callback, void *user_data);
/**
- * @brief Gets the client which is connected by USB tethering.
+ * @brief Gets the clients which are connected.
* @param[in] tethering The handle of tethering
* @param[in] type The type of tethering
* @param[in] callback The callback function to invoke
/**
* @brief Sets the security type of Wi-Fi tethering.
- * @remarks You must set this value when Wi-Fi tethering is disabled.
+ * @remarks This change is applied next time Wi-Fi tethering is enabled
* @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
- * @retval #TETHERING_ERROR_INVALID_OPERATION Invalid operation
- * @pre Wi-Fi tethering must be disabled.
- * @see tethering_is_enabled()
* @see tethering_wifi_get_security_type()
*/
int tethering_wifi_set_security_type(tethering_h tethering, tethering_wifi_security_type_e type);
int tethering_wifi_get_security_type(tethering_h tethering, tethering_wifi_security_type_e *type);
/**
+ * @brief Sets the SSID (service set identifier).
+ * @details If SSID is not set, Device name is used as SSID
+ * @remarks This change is applied next time Wi-Fi tethering is enabled with same @a tethering handle
+ * @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
+ */
+int tethering_wifi_set_ssid(tethering_h tethering, const char *ssid);
+
+/**
* @brief Gets the SSID (service set identifier).
* @remarks @a ssid must be released with free() by you.
* @param[in] tethering The handle of tethering
/**
* @brief Sets the visibility of SSID(service set identifier).
* @details If you set the visibility invisible, then the SSID of this device is hidden. So, Wi-Fi scan can't find your device.
- * @remarks You must set this value when Wi-Fi tethering is disabled.
+ * @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
- * @retval #TETHERING_ERROR_INVALID_OPERATION Invalid operation
- * @pre Wi-Fi tethering must be disabled.
- * @see tethering_is_enabled()
* @see tethering_wifi_get_ssid_visibility()
*/
int tethering_wifi_set_ssid_visibility(tethering_h tethering, bool visible);
/**
* @brief Sets the passphrase.
- * @remarks You must set this value when Wi-Fi tethering is disabled.
+ * @remarks This change is applied next time Wi-Fi tethering is enabled
* @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
* @retval #TETHERING_ERROR_OPERATION_FAILED Operation failed
- * @retval #TETHERING_ERROR_INVALID_OPERATION Invalid operation
- * @pre Wi-Fi tethering must be disabled.
- * @see tethering_is_enabled()
* @see tethering_wifi_get_passphrase()
*/
int tethering_wifi_set_passphrase(tethering_h tethering, const char *passphrase);
#ifndef __TETHERING_PRIVATE_H__
#define __TETHERING_PRIVATE_H__
-#define LOG_TAG "tethering"
+#define LOG_TAG "CAPI_NETWORK_TETHERING"
#include <glib.h>
#include <dbus/dbus-glib.h>
# define DEPRECATED_API __attribute__ ((deprecated))
#endif
-#define DBG(fmt, args...) LOGD("[%s()][Ln:%d] "fmt, __func__, __LINE__, ##args)
-#define WARN(fmt, args...) LOGW("[%s()][Ln:%d] "fmt, __func__, __LINE__, ##args)
-#define ERR(fmt, args...) LOGE("[%s()][Ln:%d] "fmt, __func__, __LINE__, ##args)
+#define DBG(fmt, args...) LOGD(fmt, ##args)
+#define WARN(fmt, args...) LOGW(fmt, ##args)
+#define ERR(fmt, args...) LOGE(fmt, ##args)
#define _warn_if(expr, fmt, arg...) do { \
if (expr) { \
#define TETHERING_BT_IF "bnep0"
#define TETHERING_BT_GATEWAY "192.168.130.1"
+
+#define TETHERING_WIFI_SSID_MAX_LEN 31 /**< Maximum length of ssid */
+#define TETHERING_WIFI_KEY_MIN_LEN 8 /**< Minimum length of wifi key */
+#define TETHERING_WIFI_KEY_MAX_LEN 63 /**< Maximum length of wifi key */
/**
* End of mobileap-agent common values
*/
void *ssid_visibility_user_data;
tethering_wifi_passphrase_changed_cb passphrase_changed_cb;
void *passphrase_user_data;
+
+ char *ssid;
} __tethering_h;
typedef struct {
Name: capi-network-tethering
Summary: Tethering Framework
-Version: 0.0.11
+Version: 0.0.13
Release: 1
Group: TO_BE/FILLED_IN
-License: Apache License Version 2.0
+License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
%setup -q
%build
-cmake . -DCMAKE_INSTALL_PREFIX=/usr
-
+%cmake .
make %{?jobs:-j%jobs}
%install
-rm -rf %{buildroot}
%make_install
%post -p /sbin/ldconfig
%{_libdir}/*.so
%changelog
+* Sat Feb 16 2013 Seungyoun Ju <sy39.ju@samsung.com> 0.0.13-1
+- Wrong linker flags are fixed
+- Add API : tethering_wifi_set_ssid()
+
+* Thu Feb 14 2013 Seungyoun Ju <sy39.ju@samsung.com> 0.0.12-1
+- APIs are exported
+- LOG Format is changed
+- fvisibility=hidden is applied and API's return value is checked
+
* Thu Jan 24 2013 Seungyoun Ju <sy39.ju@samsung.com> 0.0.11-1
- Indications for Wi-Fi tethering setting change are added
- Dbus service / interface / object names are changed
"malloc is failed\n");
memset(th, 0x00, sizeof(__tethering_h));
+#if !GLIB_CHECK_VERSION(2,35,0)
g_type_init();
+#endif
th->client_bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
if (error) {
ERR("Couldn't connect to the System bus[%s]", error->message);
org_tizen_tethering_deinit_async(th->client_bus_proxy, __deinit_cb,
(gpointer)tethering);
+ if (th->ssid)
+ free(th->ssid);
g_object_unref(th->client_bus_proxy);
dbus_g_connection_unref(th->client_bus);
memset(th, 0x00, sizeof(__tethering_h));
* @see tethering_is_enabled()
* @see tethering_disable()
*/
-int tethering_enable(tethering_h tethering, tethering_type_e type)
+API int tethering_enable(tethering_h tethering, tethering_type_e type)
{
DBG("+\n");
dbus_g_proxy_disconnect_signal(proxy, SIGNAL_NAME_WIFI_TETHER_ON,
G_CALLBACK(__handle_wifi_tether_on),
(gpointer)tethering);
- org_tizen_tethering_enable_wifi_tethering_async(proxy, "", "", false,
+ org_tizen_tethering_enable_wifi_tethering_async(proxy,
+ th->ssid ? th->ssid : "", "", false,
__cfm_cb, (gpointer)tethering);
break;
dbus_g_proxy_disconnect_signal(proxy, SIGNAL_NAME_WIFI_TETHER_ON,
G_CALLBACK(__handle_wifi_tether_on),
(gpointer)tethering);
- org_tizen_tethering_enable_wifi_tethering_async(proxy, "", "", false,
+ org_tizen_tethering_enable_wifi_tethering_async(proxy,
+ th->ssid ? th->ssid : "", "", false,
__cfm_cb, (gpointer)tethering);
/* TETHERING_TYPE_BT */
* @see tethering_is_enabled()
* @see tethering_enable()
*/
-int tethering_get_mac_address(tethering_h tethering, tethering_type_e type, char **mac_address)
+API int tethering_get_mac_address(tethering_h tethering, tethering_type_e type, char **mac_address)
{
_retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"parameter(tethering) is NULL\n");
* @see tethering_is_enabled()
* @see tethering_enable()
*/
-int tethering_get_subnet_mask(tethering_h tethering, tethering_type_e type, tethering_address_family_e address_family, char **subnet_mask)
+API int tethering_get_subnet_mask(tethering_h tethering, tethering_type_e type, tethering_address_family_e address_family, char **subnet_mask)
{
_retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"parameter(tethering) is NULL\n");
/**
* @brief Sets the security type of Wi-Fi tethering.
- * @remarks You must set this value when Wi-Fi tethering is disabled.
+ * @remarks This change is applied next time Wi-Fi tethering is enabled
* @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
- * @retval #TETHERING_ERROR_INVALID_OPERATION Invalid operation
- * @pre Wi-Fi tethering must be disabled.
- * @see tethering_is_enabled()
* @see tethering_wifi_get_security_type()
*/
API int tethering_wifi_set_security_type(tethering_h tethering, tethering_wifi_security_type_e type)
}
/**
+ * @brief Sets the SSID (service set identifier).
+ * @details If SSID is not set, Device name is used as SSID
+ * @remarks This change is applied next time Wi-Fi tethering is enabled with same @a tethering handle
+ * @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_set_ssid(tethering_h tethering, const char *ssid)
+{
+ _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;
+ int ssid_len;
+
+ 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);
+ _retvm_if(p_ssid == NULL, TETHERING_ERROR_OUT_OF_MEMORY,
+ "strdup is failed\n");
+
+ if (th->ssid)
+ free(th->ssid);
+ th->ssid = p_ssid;
+
+ return TETHERING_ERROR_NONE;
+}
+
+/**
* @brief Gets the SSID (service set identifier).
* @remarks @a ssid must be released with free() by you.
* @param[in] tethering The handle of tethering
GError *error = NULL;
char *ssid_buf = NULL;
+ if (tethering_is_enabled(NULL, TETHERING_TYPE_WIFI) == false &&
+ th->ssid != NULL) {
+ DBG("Private SSID is set : %s\n", th->ssid);
+ *ssid = strdup(th->ssid);
+ if (*ssid == NULL) {
+ ERR("Memory allocation failed\n");
+ return TETHERING_ERROR_OUT_OF_MEMORY;
+ }
+ DBG("-\n");
+ return TETHERING_ERROR_NONE;
+ }
+
org_tizen_tethering_get_wifi_tethering_ssid(proxy, &ssid_buf, &error);
if (error != NULL) {
ERR("dbus fail : %s\n", error->message);
/**
* @brief Sets the visibility of SSID(service set identifier).
* @details If you set the visibility invisible, then the SSID of this device is hidden. So, Wi-Fi scan can't find your device.
- * @remarks You must set this value when Wi-Fi tethering is disabled.
+ * @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
- * @retval #TETHERING_ERROR_INVALID_OPERATION Invalid operation
- * @pre Wi-Fi tethering must be disabled.
- * @see tethering_is_enabled()
* @see tethering_wifi_get_ssid_visibility()
*/
-int tethering_wifi_set_ssid_visibility(tethering_h tethering, bool visible)
+API int tethering_wifi_set_ssid_visibility(tethering_h tethering, bool visible)
{
_retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"parameter(tethering) is NULL\n");
/**
* @brief Sets the passphrase.
- * @remarks You must set this value when Wi-Fi tethering is disabled.
+ * @remarks This change is applied next time Wi-Fi tethering is enabled
* @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
* @retval #TETHERING_ERROR_OPERATION_FAILED Operation failed
- * @retval #TETHERING_ERROR_INVALID_OPERATION Invalid operation
- * @pre Wi-Fi tethering must be disabled.
- * @see tethering_is_enabled()
* @see tethering_wifi_get_passphrase()
*/
API int tethering_wifi_set_passphrase(tethering_h tethering, const char *passphrase)
__tethering_h *th = (__tethering_h *)tethering;
DBusGProxy *proxy = th->client_bus_proxy;
+ int passphrase_len;
+
+ 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;
+ }
dbus_g_proxy_disconnect_signal(proxy, SIGNAL_NAME_PASSPHRASE_CHANGED,
G_CALLBACK(__handle_passphrase_changed),
(gpointer)tethering);
org_tizen_tethering_set_wifi_tethering_passphrase_async(proxy,
- passphrase, strlen(passphrase),
+ passphrase, passphrase_len,
__wifi_set_passphrase_cb, (gpointer)tethering);
DBG("-\n");
#include <string.h>
#include "tethering_private.h"
-int tethering_client_clone(tethering_client_h *dest, tethering_client_h origin)
+API int tethering_client_clone(tethering_client_h *dest, tethering_client_h origin)
{
_retvm_if(dest == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"Parameter(dest) is NULL\n");
return TETHERING_ERROR_NONE;
}
-int tethering_client_destroy(tethering_client_h client)
+API int tethering_client_destroy(tethering_client_h client)
{
_retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"Parameter(client) is NULL\n");
return TETHERING_ERROR_NONE;
}
-int tethering_client_get_tethering_type(tethering_client_h client, tethering_type_e *type)
+API int tethering_client_get_tethering_type(tethering_client_h client, tethering_type_e *type)
{
_retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"Parameter(client) is NULL\n");
return TETHERING_ERROR_NONE;
}
-int tethering_client_get_name(tethering_client_h client, char **name)
+API int tethering_client_get_name(tethering_client_h client, char **name)
{
_retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"Parameter(client) is NULL\n");
return TETHERING_ERROR_NONE;
}
-int tethering_client_get_ip_address(tethering_client_h client, tethering_address_family_e address_family, char **ip_address)
+API int tethering_client_get_ip_address(tethering_client_h client, tethering_address_family_e address_family, char **ip_address)
{
_retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"Parameter(client) is NULL\n");
return TETHERING_ERROR_NONE;
}
-int tethering_client_get_mac_address(tethering_client_h client, char **mac_address)
+API int tethering_client_get_mac_address(tethering_client_h client, char **mac_address)
{
_retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"Parameter(client) is NULL\n");
#include "tethering.h"
-#define INPUT_BUF_LEN 32
+#define INPUT_BUF_LEN 128
#define DISABLE_REASON_TEXT_LEN 64
#define COMMON_STR_BUF_LEN 32
g_print("\nTo get Wi-Fi tethering setting, enter 'get wifi_setting'");
g_print("\nTo set Wi-Fi tethering setting, enter '[set_security_type | set_visibility] [0 | 1]'");
g_print("\nTo set Wi-Fi tethering passphrase, enter 'set_passphrase [passphrase]'");
+ g_print("\nTo set Wi-Fi tethering SSID, enter 'set_ssid [SSID]'");
g_print("\nTo quit, enter 'quit'\n> ");
return;
}
#else
GError *err = NULL;
+ GIOStatus ios;
- g_io_channel_read_chars(channel, buf, INPUT_BUF_LEN, &read, &err);
+ ios = g_io_channel_read_chars(channel, buf, INPUT_BUF_LEN, &read, &err);
if (err != NULL) {
- g_print("g_io_channel_read is failed : %s\n", err->message);
+ g_print("g_io_channel_read_chars is failed : %s\n",
+ err->message);
g_error_free(err);
return FALSE;
+ } else if (ios != G_IO_STATUS_NORMAL) {
+ g_print("g_io_channel_read_chars is failed : %d\n", ios);
+ return FALSE;
}
#endif
goto DONE;
}
+ if (!strcmp(cmd, "set_ssid")) {
+ error = tethering_wifi_set_ssid(th, param);
+ if (error != TETHERING_ERROR_NONE)
+ g_print("tethering_wifi_set_ssid is failed [0x%X]\n",
+ error);
+ goto DONE;
+ }
+
/* One parameter(type) */
if (!strcmp(param, "USB"))
type = TETHERING_TYPE_USB;
__connection_state_changed_cb, __security_type_changed_cb,
__ssid_visibility_changed_cb, __passphrase_changed_cb};
+#if !GLIB_CHECK_VERSION(2,35,0)
g_type_init();
+#endif
/* Create tethering handle */
ret = tethering_create(&th);