typedef void *tethering_ext_h;
typedef enum {
- TETHERING_EXT_SSID = 1,
- TETHERING_EXT_PASSPHRASE = 2,
- TETHERING_EXT_SECURITY_TYPE = 4,
- TETHERING_EXT_CHANNEL = 8,
- TETHERING_EXT_VISIBLE = 16,
- TETHERING_EXT_SHARED = 32,
- TETHERING_EXT_ALL = 63
+ TETHERING_EXT_SSID = 1,
+ TETHERING_EXT_PASSPHRASE = 2,
+ TETHERING_EXT_SECURITY_TYPE = 4,
+ TETHERING_EXT_CHANNEL = 8,
+ TETHERING_EXT_VISIBLE = 16,
+ TETHERING_EXT_SHARED = 32,
+ TETHERING_EXT_ALL = 63
} tethering_ext_config_e;
// Maps in value to tethering_disabled_cause_e
typedef enum {
- TETHERING_EXT_DISABLED_BY_FLIGHT_MODE = 1, /**< Disabled due to flight mode */
- TETHERING_EXT_DISABLED_BY_LOW_BATTERY, /**< Disabled due to low battery */
- TETHERING_EXT_DISABLED_BY_NETWORK_CLOSE, /**< Disabled due to pdp network close */
- TETHERING_EXT_DISABLED_BY_TIMEOUT, /**< Disabled due to timeout */
- TETHERING_EXT_DISABLED_BY_OTHERS, /**< Disabled by other apps */
- TETHERING_EXT_DISABLED_BY_REQUEST, /**< Disabled by your request */
- TETHERING_EXT_DISABLED_BY_WIFI_ON, /**< Disabled due to Wi-Fi on */
+ TETHERING_EXT_DISABLED_BY_FLIGHT_MODE = 1, /**< Disabled due to flight mode */
+ TETHERING_EXT_DISABLED_BY_LOW_BATTERY, /**< Disabled due to low battery */
+ TETHERING_EXT_DISABLED_BY_NETWORK_CLOSE, /**< Disabled due to pdp network close */
+ TETHERING_EXT_DISABLED_BY_TIMEOUT, /**< Disabled due to timeout */
+ TETHERING_EXT_DISABLED_BY_OTHERS, /**< Disabled by other apps */
+ TETHERING_EXT_DISABLED_BY_REQUEST, /**< Disabled by your request */
+ TETHERING_EXT_DISABLED_BY_WIFI_ON, /**< Disabled due to Wi-Fi on */
} tethering_ext_disabled_cause_e;
typedef struct {
- char ssid[TETHERING_EXT_WIFI_SSID_MAX_LEN + 1];
- char passphrase[TETHERING_EXT_WIFI_KEY_MAX_LEN + 1];
- int security_type;
- int mode_type;
- bool visibility;
- bool wifi_sharing;
- int channel;
- int wifi_max_connected;
- char ipaddr[TETHERING_EXT_IPV4_ADDRESS_MAX_LEN + 1];
+ char ssid[TETHERING_EXT_WIFI_SSID_MAX_LEN + 1];
+ char passphrase[TETHERING_EXT_WIFI_KEY_MAX_LEN + 1];
+ int security_type;
+ int mode_type;
+ bool visibility;
+ bool wifi_sharing;
+ int channel;
+ int wifi_max_connected;
+ char ipaddr[TETHERING_EXT_IPV4_ADDRESS_MAX_LEN + 1];
} tethering_ext_config_h;
typedef void *tethering_ext_client_h;
/* Common */
#define TETHERING_EXT_SIGNAL_NAME_LEN 64
-GVariant *_invoke_dbus_method(_tethering_ext_h *tethering_ctx, const char *dest, const char *path, const char *interface_name,
- const char *method, GVariant *params, int *dbus_error);
+GVariant *_invoke_dbus_method(_tethering_ext_h *tethering_ctx, const char *dest, const char *path, const char *interface_name, const char *method, GVariant *params, int *dbus_error);
int _tethering_ext_dbus_set_wifi_tethering_mode(_tethering_ext_h *tethering_ctx, bool enable);
int _tethering_ext_dbus_set_wifi_tethering_mode_with_params(_tethering_ext_h *tethering_ctx, bool enable);
#define TETHERING_EXT_STR_INFO_LEN 40
typedef enum {
- TETHERING_EXT_STATE_DISABLED = 0,
- TETHERING_EXT_STATE_ENABLED = 1
+ TETHERING_EXT_STATE_DISABLED = 0,
+ TETHERING_EXT_STATE_ENABLED = 1
} _tethering_ext_state_e;
typedef enum {
- TETHERING_EXT_POWER_IND = 0
+ TETHERING_EXT_POWER_IND = 0
} _tethering_ext_event_e;
typedef enum {
} _tethering_ext_callback_e;
typedef struct {
- tethering_ext_enabled_cb enabled_cb;
- void *enabled_user_data;
- tethering_ext_disabled_cb disabled_cb;
- void *disabled_user_data;
- tethering_ext_connection_state_changed_cb changed_cb;
- void *changed_user_data;
+ tethering_ext_enabled_cb enabled_cb;
+ void *enabled_user_data;
+ tethering_ext_disabled_cb disabled_cb;
+ void *disabled_user_data;
+ tethering_ext_connection_state_changed_cb changed_cb;
+ void *changed_user_data;
} _tethering_ext_callback_h;
typedef struct {
- GDBusConnection *tethering_ext_client;
- GCancellable *tethering_ext_cancellable;
- guint subscribe_id_wifi_tethering_state;
- _tethering_ext_state_e tethering_ext_state;
- _tethering_ext_state_changed_cb tethering_ext_state_changed_cb;
- void *tethering_ext_state_changed_user_data;
- _tethering_ext_event_cb tethering_ext_event_cb;
- void *tethering_ext_user_data;
- tethering_ext_config_h tethering_ext_config;
- _tethering_ext_callback_h *tethering_ext_callbacks;
+ GDBusConnection *tethering_ext_client;
+ GCancellable *tethering_ext_cancellable;
+ guint subscribe_id_wifi_tethering_state;
+ _tethering_ext_state_e tethering_ext_state;
+ _tethering_ext_state_changed_cb tethering_ext_state_changed_cb;
+ void *tethering_ext_state_changed_user_data;
+ _tethering_ext_event_cb tethering_ext_event_cb;
+ void *tethering_ext_user_data;
+ tethering_ext_config_h tethering_ext_config;
+ _tethering_ext_callback_h *tethering_ext_callbacks;
} _tethering_ext_h;
int _tethering_ext_create_context(tethering_ext_h *tethering_context);
#include <tethering_ext.h>
#include <tethering_ext_internal.h>
-
#define DISABLE_REASON_TEXT_LEN 64
#define TETHERING_GET_CONFIG(context, value, config, retval)\
do {\
- if (!context || !value) {\
- TETHERING_EXT_ERR("Invalid paramater, exiting");\
- retval = TETHERING_ERROR_INVALID_PARAMETER;\
- } else {\
- int rv = _tethering_ext_get_config(context, (void *) (value), config);\
- if (rv != TETHERING_EXT_ERR_NONE) {\
- TETHERING_EXT_ERR("%s failed with error code %d", __FUNCTION__, rv);\
- retval = TETHERING_ERROR_OPERATION_FAILED;\
- } else {\
- retval = TETHERING_ERROR_NONE;\
- }\
- }\
+ if (!context || !value) {\
+ TETHERING_EXT_ERR("Invalid paramater, exiting");\
+ retval = TETHERING_ERROR_INVALID_PARAMETER;\
+ } else {\
+ int rv = _tethering_ext_get_config(context, (void *) (value), config);\
+ if (rv != TETHERING_EXT_ERR_NONE) {\
+ TETHERING_EXT_ERR("%s failed with error code %d", __FUNCTION__, rv);\
+ retval = TETHERING_ERROR_OPERATION_FAILED;\
+ } else {\
+ retval = TETHERING_ERROR_NONE;\
+ }\
+ }\
} while (0);
-static tethering_error_e convert_tethering_ext_err(_tethering_ext_err_e error) {
+static tethering_error_e convert_tethering_ext_err(_tethering_ext_err_e error)
+{
tethering_error_e tethering_error = TETHERING_ERROR_NONE;
switch (error) {
- case TETHERING_EXT_ERR_INVALID_OPERATION:
- tethering_error = TETHERING_ERROR_INVALID_OPERATION;
+ case TETHERING_EXT_ERR_INVALID_OPERATION:
+ tethering_error = TETHERING_ERROR_INVALID_OPERATION;
break;
- case TETHERING_EXT_ERR_INVALID_PARAM:
- tethering_error = TETHERING_ERROR_INVALID_PARAMETER;
+ case TETHERING_EXT_ERR_INVALID_PARAM:
+ tethering_error = TETHERING_ERROR_INVALID_PARAMETER;
break;
- case TETHERING_EXT_ERR_OUT_OF_MEMORY:
- tethering_error = TETHERING_ERROR_OUT_OF_MEMORY;
+ case TETHERING_EXT_ERR_OUT_OF_MEMORY:
+ tethering_error = TETHERING_ERROR_OUT_OF_MEMORY;
break;
- case TETHERING_EXT_ERR_NOT_SUPPORTED:
- tethering_error = TETHERING_ERROR_NOT_SUPPORT_API;
+ case TETHERING_EXT_ERR_NOT_SUPPORTED:
+ tethering_error = TETHERING_ERROR_NOT_SUPPORT_API;
break;
- default:
- tethering_error = TETHERING_ERROR_OPERATION_FAILED;
+ default:
+ tethering_error = TETHERING_ERROR_OPERATION_FAILED;
break;
}
return tethering_error;
}
-API int tethering_ext_initialize(tethering_ext_h *tethering_context) {
+API int tethering_ext_initialize(tethering_ext_h * tethering_context)
+{
// __TETHERING_EXT_CAPI_FUNC_ENTER__;
int rv;
// __TETHERING_EXT_CAPI_FUNC_EXIT__;
return TETHERING_ERROR_INVALID_PARAMETER;
}
-
// TETHERING_EXT_LOCK;
if (_tethering_ext_check_context(*tethering_context)) {
// __TETHERING_EXT_CAPI_FUNC_EXIT__;
return TETHERING_ERROR_OPERATION_FAILED;
}
-
// _tethering_ext_callback_h callbacks = {__enabled_cb, NULL, __disabled_cb, NULL, __connection_state_changed_cb, NULL};
// _tethering_ext_register_callbacks(tethering_context, callbacks);
// TETHERING_EXT_UNLOCK;
// __TETHERING_EXT_CAPI_FUNC_EXIT__;
- return TETHERING_ERROR_NONE;
+ return TETHERING_ERROR_NONE;
}
-API int tethering_ext_deinitialize(tethering_ext_h tethering_context) {
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+API int tethering_ext_deinitialize(tethering_ext_h tethering_context)
+{
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
// TETHERING_EXT_LOCK;
_tethering_ext_unregister_dbus(tethering_context);
_tethering_ext_destroy_context(tethering_context);
- return TETHERING_ERROR_NONE;
+ return TETHERING_ERROR_NONE;
}
-API int tethering_ext_set_enabled_cb(tethering_ext_h tethering_context, tethering_ext_enabled_cb callback, void *user_data) {
+API int tethering_ext_set_enabled_cb(tethering_ext_h tethering_context, tethering_ext_enabled_cb callback, void *user_data)
+{
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(tethering_context);
- int rv = _tethering_ext_register_callback(tethering_context, TETHERING_EXT_ENABLED_CALLBACK, (void *) callback, user_data);
+ int rv = _tethering_ext_register_callback(tethering_context, TETHERING_EXT_ENABLED_CALLBACK, (void *)callback, user_data);
if (rv != TETHERING_EXT_ERR_NONE) {
- tethering_error_e err = convert_tethering_ext_err(rv);
- TETHERING_EXT_ERR("tethering_ext_set_enabled_cb: error value %d", err);
- return err;
+ tethering_error_e err = convert_tethering_ext_err(rv);
+ TETHERING_EXT_ERR("tethering_ext_set_enabled_cb: error value %d", err);
+ return err;
}
return TETHERING_ERROR_NONE;
}
-API int tethering_ext_unset_enabled_cb(tethering_ext_h tethering_context) {
+API int tethering_ext_unset_enabled_cb(tethering_ext_h tethering_context)
+{
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(tethering_context);
int rv = _tethering_ext_unregister_callback(tethering_context, TETHERING_EXT_ENABLED_CALLBACK);
if (rv != TETHERING_EXT_ERR_NONE) {
- tethering_error_e err = convert_tethering_ext_err(rv);
- TETHERING_EXT_ERR("tethering_ext_set_enabled_cb: error value %d", err);
- return err;
+ tethering_error_e err = convert_tethering_ext_err(rv);
+ TETHERING_EXT_ERR("tethering_ext_set_enabled_cb: error value %d", err);
+ return err;
}
return TETHERING_ERROR_NONE;
}
-API int tethering_ext_set_disabled_cb(tethering_ext_h tethering_context, tethering_ext_disabled_cb callback, void *user_data) {
+API int tethering_ext_set_disabled_cb(tethering_ext_h tethering_context, tethering_ext_disabled_cb callback, void *user_data)
+{
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(tethering_context);
- int rv = _tethering_ext_register_callback(tethering_context, TETHERING_EXT_DISABLED_CALLBACK, (void *) callback, user_data);
+ int rv = _tethering_ext_register_callback(tethering_context, TETHERING_EXT_DISABLED_CALLBACK, (void *)callback, user_data);
if (rv != TETHERING_EXT_ERR_NONE) {
- tethering_error_e err = convert_tethering_ext_err(rv);
- TETHERING_EXT_ERR("tethering_ext_set_disabled_cb: error value %d", err);
- return err;
+ tethering_error_e err = convert_tethering_ext_err(rv);
+ TETHERING_EXT_ERR("tethering_ext_set_disabled_cb: error value %d", err);
+ return err;
}
return TETHERING_ERROR_NONE;
}
-API int tethering_ext_unset_disabled_cb(tethering_ext_h tethering_context) {
+API int tethering_ext_unset_disabled_cb(tethering_ext_h tethering_context)
+{
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(tethering_context);
int rv = _tethering_ext_unregister_callback(tethering_context, TETHERING_EXT_DISABLED_CALLBACK);
if (rv != TETHERING_EXT_ERR_NONE) {
- tethering_error_e err = convert_tethering_ext_err(rv);
- TETHERING_EXT_ERR("tethering_ext_set_enabled_cb: error value %d", err);
- return err;
+ tethering_error_e err = convert_tethering_ext_err(rv);
+ TETHERING_EXT_ERR("tethering_ext_set_enabled_cb: error value %d", err);
+ return err;
}
return TETHERING_ERROR_NONE;
}
-API int tethering_ext_set_connection_state_changed_cb(tethering_ext_h tethering_context, tethering_ext_connection_state_changed_cb callback, void *user_data) {
+API int tethering_ext_set_connection_state_changed_cb(tethering_ext_h tethering_context, tethering_ext_connection_state_changed_cb callback, void *user_data)
+{
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(tethering_context);
- int rv = _tethering_ext_register_callback(tethering_context, TETHERING_EXT_CONNECTION_STATE_CHANGED_CALLBACK, (void *) callback, user_data);
+ int rv = _tethering_ext_register_callback(tethering_context, TETHERING_EXT_CONNECTION_STATE_CHANGED_CALLBACK, (void *)callback, user_data);
if (rv != TETHERING_EXT_ERR_NONE) {
- tethering_error_e err = convert_tethering_ext_err(rv);
- TETHERING_EXT_ERR("tethering_ext_set_connection_state_changed_cb: error value %d", err);
- return err;
+ tethering_error_e err = convert_tethering_ext_err(rv);
+ TETHERING_EXT_ERR("tethering_ext_set_connection_state_changed_cb: error value %d", err);
+ return err;
}
return TETHERING_ERROR_NONE;
}
-API int tethering_ext_unset_connection_state_changed_cb(tethering_ext_h tethering_context) {
+API int tethering_ext_unset_connection_state_changed_cb(tethering_ext_h tethering_context)
+{
RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(tethering_context);
int rv = _tethering_ext_unregister_callback(tethering_context, TETHERING_EXT_CONNECTION_STATE_CHANGED_CALLBACK);
if (rv != TETHERING_EXT_ERR_NONE) {
- tethering_error_e err = convert_tethering_ext_err(rv);
- TETHERING_EXT_ERR("tethering_ext_set_enabled_cb: error value %d", err);
- return err;
+ tethering_error_e err = convert_tethering_ext_err(rv);
+ TETHERING_EXT_ERR("tethering_ext_set_enabled_cb: error value %d", err);
+ return err;
}
return TETHERING_ERROR_NONE;
}
-
-
-API int tethering_ext_activate(tethering_ext_h tethering_context) {
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+API int tethering_ext_activate(tethering_ext_h tethering_context)
+{
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
int rv = 0;
return TETHERING_ERROR_PERMISSION_DENIED;
} else if (rv == TETHERING_EXT_ERR_INVALID_OPERATION) {
return TETHERING_ERROR_INVALID_OPERATION;
- } else if (rv != TETHERING_EXT_ERR_NONE) {
- TETHERING_EXT_ERR("Failed to set tethering mode");
+ } else if (rv != TETHERING_EXT_ERR_NONE) {
+ TETHERING_EXT_ERR("Failed to activate P2P tethering");
return TETHERING_ERROR_OPERATION_FAILED;
}
- return TETHERING_ERROR_NONE;
+ return TETHERING_ERROR_NONE;
}
-API int tethering_ext_deactivate(tethering_ext_h tethering_context) {
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+API int tethering_ext_deactivate(tethering_ext_h tethering_context)
+{
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
int rv = 0;
return TETHERING_ERROR_PERMISSION_DENIED;
} else if (rv == TETHERING_EXT_ERR_INVALID_OPERATION) {
return TETHERING_ERROR_INVALID_OPERATION;
- } else if (rv != TETHERING_EXT_ERR_NONE) {
- TETHERING_EXT_ERR("Failed to set tethering mode");
+ } else if (rv != TETHERING_EXT_ERR_NONE) {
+ TETHERING_EXT_ERR("Failed to deactivate P2P tethering");
return TETHERING_ERROR_OPERATION_FAILED;
}
- return TETHERING_ERROR_NONE;
+ return TETHERING_ERROR_NONE;
}
-API int tethering_ext_is_enabled(tethering_ext_h tethering_context, bool *is_enabled) {
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+API int tethering_ext_is_enabled(tethering_ext_h tethering_context, bool *is_enabled)
+{
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
int rv = TETHERING_ERROR_NONE;
return rv;
}
-API int tethering_ext_set_ssid(tethering_ext_h tethering_context, const char *ssid) {
+API int tethering_ext_set_ssid(tethering_ext_h tethering_context, const char *ssid)
+{
size_t length = strlen(ssid);
if (length > TETHERING_EXT_WIFI_SSID_MAX_LEN) {
return TETHERING_ERROR_INVALID_PARAMETER;
}
- _tethering_ext_data_h ssid_data = {length, ssid};
- return _tethering_ext_set_config(tethering_context, (void *) &ssid_data, TETHERING_EXT_SSID);
+ _tethering_ext_data_h ssid_data = { length, ssid };
+ return _tethering_ext_set_config(tethering_context, (void *)&ssid_data, TETHERING_EXT_SSID);
}
-API int tethering_ext_set_passphrase(tethering_ext_h tethering_context, const char *passphrase) {
+API int tethering_ext_set_passphrase(tethering_ext_h tethering_context, const char *passphrase)
+{
size_t length = strlen(passphrase);
if (length > TETHERING_EXT_WIFI_KEY_MAX_LEN) {
return TETHERING_ERROR_INVALID_PARAMETER;
}
- _tethering_ext_data_h passphrase_data = {length, passphrase};
- return _tethering_ext_set_config(tethering_context, (void *) &passphrase_data, TETHERING_EXT_PASSPHRASE);
+ _tethering_ext_data_h passphrase_data = { length, passphrase };
+ return _tethering_ext_set_config(tethering_context, (void *)&passphrase_data, TETHERING_EXT_PASSPHRASE);
}
-API int tethering_ext_set_channel(tethering_ext_h tethering_context, int channel) {
- return _tethering_ext_set_config(tethering_context, (void *) &channel, TETHERING_EXT_CHANNEL);
+API int tethering_ext_set_channel(tethering_ext_h tethering_context, int channel)
+{
+ return _tethering_ext_set_config(tethering_context, (void *)&channel, TETHERING_EXT_CHANNEL);
}
-API int tethering_ext_get_tethering_info(tethering_ext_h tethering_context, void *tethering_info) {
+API int tethering_ext_get_tethering_info(tethering_ext_h tethering_context, void *tethering_info)
+{
int ret;
TETHERING_GET_CONFIG(tethering_context, tethering_info, TETHERING_EXT_SSID | TETHERING_EXT_PASSPHRASE, ret);
return ret;
}
-API int tethering_ext_get_channel(tethering_ext_h tethering_context, int *channel) {
+API int tethering_ext_get_channel(tethering_ext_h tethering_context, int *channel)
+{
int ret;
TETHERING_GET_CONFIG(tethering_context, channel, TETHERING_EXT_CHANNEL, ret);
return ret;
}
-API int tethering_ext_get_security(tethering_ext_h tethering_context, int *security) {
+API int tethering_ext_get_security(tethering_ext_h tethering_context, int *security)
+{
int ret;
TETHERING_GET_CONFIG(tethering_context, security, TETHERING_EXT_SECURITY_TYPE, ret);
return ret;
}
-API int tethering_ext_get_visibility(tethering_ext_h tethering_context, int *visibility) {
+API int tethering_ext_get_visibility(tethering_ext_h tethering_context, int *visibility)
+{
int ret;
TETHERING_GET_CONFIG(tethering_context, visibility, TETHERING_EXT_VISIBLE, ret);
return ret;
}
-API int tethering_ext_get_sharing(tethering_ext_h tethering_context, bool *sharing) {
+API int tethering_ext_get_sharing(tethering_ext_h tethering_context, bool *sharing)
+{
int ret;
TETHERING_GET_CONFIG(tethering_context, sharing, TETHERING_EXT_SHARED, ret);
return ret;
}
-API int tethering_ext_client_clone(tethering_ext_client_h *dest, tethering_ext_client_h origin) {
- // CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+API int tethering_ext_client_clone(tethering_ext_client_h * dest, tethering_ext_client_h origin)
+{
+ // CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
if (dest == NULL) {
- TETHERING_EXT_ERR("Parameter(dest) is NULL\n");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
-
- if (origin == NULL) {
- TETHERING_EXT_ERR("Parameter(origin) is NULL\n");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
+ TETHERING_EXT_ERR("Parameter(dest) is NULL\n");
+ return TETHERING_ERROR_INVALID_PARAMETER;
+ }
+
+ if (origin == NULL) {
+ TETHERING_EXT_ERR("Parameter(origin) is NULL\n");
+ return TETHERING_ERROR_INVALID_PARAMETER;
+ }
_tethering_ext_client_info_h *si = NULL;
_tethering_ext_client_info_h *source = NULL;
- source = (_tethering_ext_client_info_h *)origin;
+ source = (_tethering_ext_client_info_h *) origin;
si = malloc(sizeof(_tethering_ext_client_info_h));
if (si == NULL) {
return TETHERING_ERROR_OUT_OF_MEMORY;
}
- *dest = (tethering_ext_client_h)si;
+ *dest = (tethering_ext_client_h) si;
return TETHERING_ERROR_NONE;
}
API int tethering_ext_client_get_name(tethering_ext_client_h client, char **name)
{
- if(client == NULL) {
- TETHERING_EXT_ERR("Parameter(client) is NULL\n");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
- if(name == NULL) {
- TETHERING_EXT_ERR("Parameter(name) is NULL\n");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
+ if (client == NULL) {
+ TETHERING_EXT_ERR("Parameter(client) is NULL\n");
+ return TETHERING_ERROR_INVALID_PARAMETER;
+ }
+ if (name == NULL) {
+ TETHERING_EXT_ERR("Parameter(name) is NULL\n");
+ return TETHERING_ERROR_INVALID_PARAMETER;
+ }
- _tethering_ext_client_info_h *si = (_tethering_ext_client_info_h *)client;
+ _tethering_ext_client_info_h *si = (_tethering_ext_client_info_h *) client;
*name = strdup(si->hostname);
if (*name == NULL) {
{
// CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
- if(client == NULL) {
- TETHERING_EXT_ERR("Parameter(client) is NULL\n");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
- if(ip_address == NULL) {
- TETHERING_EXT_ERR("Parameter(ip_address) is NULL\n");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
+ if (client == NULL) {
+ TETHERING_EXT_ERR("Parameter(client) is NULL\n");
+ return TETHERING_ERROR_INVALID_PARAMETER;
+ }
+ if (ip_address == NULL) {
+ TETHERING_EXT_ERR("Parameter(ip_address) is NULL\n");
+ return TETHERING_ERROR_INVALID_PARAMETER;
+ }
- _tethering_ext_client_info_h *si = (_tethering_ext_client_info_h *)client;
+ _tethering_ext_client_info_h *si = (_tethering_ext_client_info_h *) client;
*ip_address = strdup(si->ip);
if (*ip_address == NULL) {
{
// CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
- if(client == NULL) {
- TETHERING_EXT_ERR("Parameter(client) is NULL\n");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
- if(mac_address == NULL) {
- TETHERING_EXT_ERR("Parameter(mac_address) is NULL\n");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
+ if (client == NULL) {
+ TETHERING_EXT_ERR("Parameter(client) is NULL\n");
+ return TETHERING_ERROR_INVALID_PARAMETER;
+ }
+ if (mac_address == NULL) {
+ TETHERING_EXT_ERR("Parameter(mac_address) is NULL\n");
+ return TETHERING_ERROR_INVALID_PARAMETER;
+ }
- _tethering_ext_client_info_h *si = (_tethering_ext_client_info_h *)client;
+ _tethering_ext_client_info_h *si = (_tethering_ext_client_info_h *) client;
*mac_address = strdup(si->mac);
if (*mac_address == NULL) {
{
// CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
- if(client == NULL){
- TETHERING_EXT_ERR("Parameter(client) is NULL\n");
- return TETHERING_ERROR_INVALID_PARAMETER;
- }
+ if (client == NULL) {
+ TETHERING_EXT_ERR("Parameter(client) is NULL\n");
+ return TETHERING_ERROR_INVALID_PARAMETER;
+ }
_tethering_ext_client_info_h *si = NULL;
- si = (_tethering_ext_client_info_h *)client;
+ si = (_tethering_ext_client_info_h *) client;
g_free(si->hostname);
static GSList *tethering_ctx_list = NULL;
-int _tethering_ext_create_context(tethering_ext_h *tethering_context)
+int _tethering_ext_create_context(tethering_ext_h * tethering_context)
{
- _tethering_ext_h *tethering_ctx = g_try_malloc0(sizeof(_tethering_ext_h));
- if (!tethering_ctx) {
- TETHERING_EXT_ERR("Failed to create tethering_ctx : %d", TETHERING_ERROR_OUT_OF_MEMORY);
- return TETHERING_ERROR_OUT_OF_MEMORY;
- }
- tethering_ctx->tethering_ext_callbacks = g_try_malloc0(sizeof(_tethering_ext_callback_h));
- memset(tethering_ctx->tethering_ext_config.ssid, 0, TETHERING_EXT_WIFI_SSID_MAX_LEN + 1);
- memset(tethering_ctx->tethering_ext_config.passphrase, 0, TETHERING_EXT_WIFI_KEY_MAX_LEN + 1);
- *tethering_context = tethering_ctx;
-
- TETHERING_EXT_DBG("New tethering_ctx create[%p]", *tethering_context);
-
- return TETHERING_EXT_ERR_NONE;
+ _tethering_ext_h *tethering_ctx = g_try_malloc0(sizeof(_tethering_ext_h));
+ if (!tethering_ctx) {
+ TETHERING_EXT_ERR("Failed to create tethering_ctx : %d", TETHERING_ERROR_OUT_OF_MEMORY);
+ return TETHERING_ERROR_OUT_OF_MEMORY;
+ }
+ tethering_ctx->tethering_ext_callbacks = g_try_malloc0(sizeof(_tethering_ext_callback_h));
+ memset(tethering_ctx->tethering_ext_config.ssid, 0, TETHERING_EXT_WIFI_SSID_MAX_LEN + 1);
+ memset(tethering_ctx->tethering_ext_config.passphrase, 0, TETHERING_EXT_WIFI_KEY_MAX_LEN + 1);
+ *tethering_context = tethering_ctx;
+
+ TETHERING_EXT_DBG("New tethering_ctx create[%p]", *tethering_context);
+
+ return TETHERING_EXT_ERR_NONE;
}
void _tethering_ext_destroy_context(tethering_ext_h tethering_context)
{
- if (!tethering_context) {
- return;
- }
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
- if (tethering_ctx->tethering_ext_callbacks) {
- g_free(tethering_ctx->tethering_ext_callbacks);
- }
- g_free(tethering_context);
+ if (!tethering_context) {
+ return;
+ }
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
+ if (tethering_ctx->tethering_ext_callbacks) {
+ g_free(tethering_ctx->tethering_ext_callbacks);
+ }
+ g_free(tethering_context);
}
bool _tethering_ext_check_context(tethering_ext_h tethering_context)
return FALSE;
}
-void _tethering_ext_add_context(tethering_ext_h *tethering_context)
+void _tethering_ext_add_context(tethering_ext_h * tethering_context)
{
// TETHERING_EXT_LOCK;
tethering_ctx_list = g_slist_append(tethering_ctx_list, *tethering_context);
// TETHERING_EXT_UNLOCK;
}
-
-static void __wifi_tethering_mode_on_off_cb(_tethering_ext_h *tethering_ctx,
- _tethering_ext_event_info_h *event_cb)
+static void __wifi_tethering_mode_on_off_cb(_tethering_ext_h * tethering_ctx, _tethering_ext_event_info_h * event_cb)
{
- tethering_error_e error_code = TETHERING_ERROR_NONE;
- _tethering_ext_state_e state = TETHERING_EXT_STATE_DISABLED; // out
- _tethering_ext_state_e *tethering_state = (_tethering_ext_state_e *)event_cb->Data;
-
- if (tethering_ctx->tethering_ext_state_changed_cb == NULL)
- return;
-
- if (event_cb->Error == TETHERING_EXT_ERR_NONE &&
- event_cb->Datalength == sizeof(_tethering_ext_state_e)) {
- if (*tethering_state == TETHERING_EXT_STATE_ENABLED) {
- TETHERING_EXT_DBG("Tethering mode is enabled");
- state = TETHERING_EXT_STATE_ENABLED;
- } else if (*tethering_state == TETHERING_EXT_STATE_DISABLED) {
- TETHERING_EXT_DBG("Tethering mode is disabled");
- state = TETHERING_EXT_STATE_DISABLED;
- } else {
- TETHERING_EXT_ERR("Error Tethering state %d", *tethering_state);
- error_code = TETHERING_ERROR_OPERATION_FAILED;
- }
- } else {
- TETHERING_EXT_ERR("Tethering power request failed(%d)", event_cb->Error);
- error_code = TETHERING_ERROR_OPERATION_FAILED;
- state = TETHERING_EXT_STATE_DISABLED;
- }
-
- if (error_code == TETHERING_ERROR_NONE) {
- if (tethering_ctx->tethering_ext_state_changed_cb)
- tethering_ctx->tethering_ext_state_changed_cb(state, tethering_ctx->tethering_ext_state_changed_user_data);
- }
+ tethering_error_e error_code = TETHERING_ERROR_NONE;
+ _tethering_ext_state_e state = TETHERING_EXT_STATE_DISABLED; // out
+ _tethering_ext_state_e *tethering_state = (_tethering_ext_state_e *) event_cb->Data;
+
+ if (tethering_ctx->tethering_ext_state_changed_cb == NULL)
+ return;
+
+ if (event_cb->Error == TETHERING_EXT_ERR_NONE && event_cb->Datalength == sizeof(_tethering_ext_state_e)) {
+ if (*tethering_state == TETHERING_EXT_STATE_ENABLED) {
+ TETHERING_EXT_DBG("Tethering mode is enabled");
+ state = TETHERING_EXT_STATE_ENABLED;
+ } else if (*tethering_state == TETHERING_EXT_STATE_DISABLED) {
+ TETHERING_EXT_DBG("Tethering mode is disabled");
+ state = TETHERING_EXT_STATE_DISABLED;
+ } else {
+ TETHERING_EXT_ERR("Error Tethering state %d", *tethering_state);
+ error_code = TETHERING_ERROR_OPERATION_FAILED;
+ }
+ } else {
+ TETHERING_EXT_ERR("Tethering power request failed(%d)", event_cb->Error);
+ error_code = TETHERING_ERROR_OPERATION_FAILED;
+ state = TETHERING_EXT_STATE_DISABLED;
+ }
+
+ if (error_code == TETHERING_ERROR_NONE) {
+ if (tethering_ctx->tethering_ext_state_changed_cb)
+ tethering_ctx->tethering_ext_state_changed_cb(state, tethering_ctx->tethering_ext_state_changed_user_data);
+ }
}
-static void __tethering_ext_evt_cb(_tethering_ext_event_info_h *event_cb, void *user_data)
+static void __tethering_ext_evt_cb(_tethering_ext_event_info_h * event_cb, void *user_data)
{
- // TETHERING_EXT_LOCK;
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *)user_data;
-
- if (!_tethering_ext_check_context(tethering_ctx)) {
- TETHERING_EXT_ERR("WiFi Extension context is not initialized");
- // TETHERING_EXT_UNLOCK;
- return;
- }
-
- switch (event_cb->Event) {
- case TETHERING_EXT_POWER_IND:
- __wifi_tethering_mode_on_off_cb(tethering_ctx, event_cb);
- break;
- default:
- break;
- }
-
- // TETHERING_EXT_UNLOCK;
+ // TETHERING_EXT_LOCK;
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) user_data;
+
+ if (!_tethering_ext_check_context(tethering_ctx)) {
+ TETHERING_EXT_ERR("WiFi Extension context is not initialized");
+ // TETHERING_EXT_UNLOCK;
+ return;
+ }
+
+ switch (event_cb->Event) {
+ case TETHERING_EXT_POWER_IND:
+ __wifi_tethering_mode_on_off_cb(tethering_ctx, event_cb);
+ break;
+ default:
+ break;
+ }
+
+ // TETHERING_EXT_UNLOCK;
}
-static int __tethering_ext_mode_changed(_tethering_ext_h *tethering_ctx, GVariant *param)
+static int __tethering_ext_mode_changed(_tethering_ext_h * tethering_ctx, GVariant * param)
{
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
- gboolean value = FALSE;
- _tethering_ext_event_info_h *event_data = NULL;
+ gboolean value = FALSE;
+ _tethering_ext_event_info_h *event_data = NULL;
- g_variant_get(param, "(b)", &value);
+ g_variant_get(param, "(b)", &value);
- event_data = g_try_malloc0(sizeof(_tethering_ext_event_info_h));
- if (!event_data) {
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
- return TETHERING_EXT_ERR_OUT_OF_MEMORY;
- }
+ event_data = g_try_malloc0(sizeof(_tethering_ext_event_info_h));
+ if (!event_data) {
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ return TETHERING_EXT_ERR_OUT_OF_MEMORY;
+ }
- TETHERING_EXT_DBG("Tethering mode changed to %s", value ? "enabled" : "disabled");
+ TETHERING_EXT_DBG("Tethering mode changed to %s", value ? "enabled" : "disabled");
- event_data->Event = TETHERING_EXT_POWER_IND;
- event_data->Error = TETHERING_EXT_ERR_NONE;
- event_data->Datalength = sizeof(gboolean);
- event_data->Data = &value;
+ event_data->Event = TETHERING_EXT_POWER_IND;
+ event_data->Error = TETHERING_EXT_ERR_NONE;
+ event_data->Datalength = sizeof(gboolean);
+ event_data->Data = &value;
- if (tethering_ctx->tethering_ext_event_cb)
- tethering_ctx->tethering_ext_event_cb(event_data, tethering_ctx->tethering_ext_user_data);
+ if (tethering_ctx->tethering_ext_event_cb)
+ tethering_ctx->tethering_ext_event_cb(event_data, tethering_ctx->tethering_ext_user_data);
- g_free(event_data);
+ g_free(event_data);
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
- return TETHERING_EXT_ERR_NONE;
+ return TETHERING_EXT_ERR_NONE;
}
-static int __tethering_ext_enabled_callback(_tethering_ext_h *tethering_ctx, GVariant *param) {
- gboolean is_enabled = FALSE;
- g_variant_get(param, "(b)", &is_enabled);
-
- if (! is_enabled) {
- return TETHERING_EXT_ERR_INVALID_PARAM;
- }
- _tethering_ext_callback_h *callbacks = tethering_ctx->tethering_ext_callbacks;
- if (callbacks->enabled_cb) {
- callbacks->enabled_cb(TETHERING_ERROR_NONE, true, callbacks->enabled_user_data);
- }
- return TETHERING_EXT_ERR_NONE;
+static int __tethering_ext_enabled_callback(_tethering_ext_h * tethering_ctx, GVariant * param)
+{
+ gboolean is_enabled = FALSE;
+ g_variant_get(param, "(b)", &is_enabled);
+
+ if (!is_enabled) {
+ return TETHERING_EXT_ERR_INVALID_PARAM;
+ }
+ _tethering_ext_callback_h *callbacks = tethering_ctx->tethering_ext_callbacks;
+ if (callbacks->enabled_cb) {
+ callbacks->enabled_cb(TETHERING_ERROR_NONE, true, callbacks->enabled_user_data);
+ }
+ return TETHERING_EXT_ERR_NONE;
}
-static int __tethering_ext_disabled_callback(_tethering_ext_h *tethering_ctx, GVariant *param) {
- gboolean is_disabled = FALSE;
- gint disabled_cause;
- g_variant_get(param, "(bi)", &is_disabled, &disabled_cause);
-
- if (! is_disabled) {
- return TETHERING_EXT_ERR_INVALID_PARAM;
- }
- _tethering_ext_callback_h *callbacks = tethering_ctx->tethering_ext_callbacks;
- if (callbacks->disabled_cb) {
- callbacks->disabled_cb(TETHERING_ERROR_NONE, disabled_cause, callbacks->disabled_user_data);
- }
- return TETHERING_EXT_ERR_NONE;
+static int __tethering_ext_disabled_callback(_tethering_ext_h * tethering_ctx, GVariant * param)
+{
+ gboolean is_disabled = FALSE;
+ gint disabled_cause;
+ g_variant_get(param, "(bi)", &is_disabled, &disabled_cause);
+
+ if (!is_disabled) {
+ return TETHERING_EXT_ERR_INVALID_PARAM;
+ }
+ _tethering_ext_callback_h *callbacks = tethering_ctx->tethering_ext_callbacks;
+ if (callbacks->disabled_cb) {
+ callbacks->disabled_cb(TETHERING_ERROR_NONE, disabled_cause, callbacks->disabled_user_data);
+ }
+ return TETHERING_EXT_ERR_NONE;
}
-static int __tethering_ext_connection_state_callback(_tethering_ext_h *tethering_ctx, GVariant *param) {
- _tethering_ext_err_e ret = TETHERING_EXT_ERR_NONE;
- char *buf = NULL;
+static int __tethering_ext_connection_state_callback(_tethering_ext_h * tethering_ctx, GVariant * param)
+{
+ _tethering_ext_err_e ret = TETHERING_EXT_ERR_NONE;
+ char *buf = NULL;
char *name = NULL;
char *mac = NULL;
char *ip = NULL;
guint timestamp;
- bool opened = false;
- _tethering_ext_client_info_h client;
- _tethering_ext_callback_h *callbacks = tethering_ctx->tethering_ext_callbacks;
- memset(&client, 0, sizeof(_tethering_ext_client_info_h));
- g_variant_get(param, "(ssssu)", &buf, &ip, &mac, &name, ×tamp);
+ bool opened = false;
+ _tethering_ext_client_info_h client;
+ _tethering_ext_callback_h *callbacks = tethering_ctx->tethering_ext_callbacks;
+ memset(&client, 0, sizeof(_tethering_ext_client_info_h));
+ g_variant_get(param, "(ssssu)", &buf, &ip, &mac, &name, ×tamp);
if (!g_strcmp0(buf, "DhcpConnected")) {
opened = true;
opened = false;
} else {
TETHERING_EXT_ERR("Unknown event [%s]\n", buf);
- ret = TETHERING_ERROR_INVALID_PARAMETER;
+ ret = TETHERING_ERROR_INVALID_PARAMETER;
goto DONE;
}
- TETHERING_EXT_INFO("P2P tethering type %s, ip %s, mac %s, name %s, timestamp %d",
- buf, ip, mac, name, timestamp);
- g_strlcpy(client.ip, ip, sizeof(client.ip));
- g_strlcpy(client.mac, mac, sizeof(client.mac));
- if (name != NULL)
- client.hostname = g_strdup(name);
- client.tm = (time_t)timestamp;
- if (callbacks->changed_cb) {
- callbacks->changed_cb((tethering_ext_client_h)&client, opened, callbacks->changed_user_data);
- }
+ TETHERING_EXT_INFO("P2P tethering type %s, ip %s, mac %s, name %s, timestamp %d", buf, ip, mac, name, timestamp);
+ g_strlcpy(client.ip, ip, sizeof(client.ip));
+ g_strlcpy(client.mac, mac, sizeof(client.mac));
+ if (name != NULL)
+ client.hostname = g_strdup(name);
+ client.tm = (time_t) timestamp;
+ if (callbacks->changed_cb) {
+ callbacks->changed_cb((tethering_ext_client_h) & client, opened, callbacks->changed_user_data);
+ }
-DONE:
+ DONE:
g_free(buf);
g_free(ip);
g_free(mac);
g_free(name);
- return ret;
+ return ret;
}
-static _tethering_ext_err_e __tethering_ext_dbus_create(_tethering_ext_h *tethering_ctx) {
- GError *error = NULL;
- #if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
- #endif
+static _tethering_ext_err_e __tethering_ext_dbus_create(_tethering_ext_h * tethering_ctx)
+{
+ GError *error = NULL;
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
- if (!tethering_ctx) {
- return TETHERING_EXT_ERR_APP_NOT_REGISTERED;
- }
+ if (!tethering_ctx) {
+ return TETHERING_EXT_ERR_APP_NOT_REGISTERED;
+ }
- tethering_ctx->tethering_ext_client = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ tethering_ctx->tethering_ext_client = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (!tethering_ctx->tethering_ext_client) {
- if (error) {
- TETHERING_EXT_ERR("Failed to get dbus connection [%s]", error->message);
- g_error_free(error);
- }
- return TETHERING_EXT_ERR_UNKNOWN;
- }
+ if (!tethering_ctx->tethering_ext_client) {
+ if (error) {
+ TETHERING_EXT_ERR("Failed to get dbus connection [%s]", error->message);
+ g_error_free(error);
+ }
+ return TETHERING_EXT_ERR_UNKNOWN;
+ }
- tethering_ctx->tethering_ext_cancellable = g_cancellable_new();
- return TETHERING_EXT_ERR_NONE;
+ tethering_ctx->tethering_ext_cancellable = g_cancellable_new();
+ return TETHERING_EXT_ERR_NONE;
}
-static void __tethering_ext_close_gdbus_call(_tethering_ext_h *tethering_ctx)
+static void __tethering_ext_close_gdbus_call(_tethering_ext_h * tethering_ctx)
{
- if (tethering_ctx->tethering_ext_cancellable) {
- g_cancellable_cancel(tethering_ctx->tethering_ext_cancellable);
- g_object_unref(tethering_ctx->tethering_ext_cancellable);
- tethering_ctx->tethering_ext_cancellable = NULL;
- }
-
- if (tethering_ctx->tethering_ext_client) {
- g_object_unref(tethering_ctx->tethering_ext_client);
- tethering_ctx->tethering_ext_client = NULL;
- }
+ if (tethering_ctx->tethering_ext_cancellable) {
+ g_cancellable_cancel(tethering_ctx->tethering_ext_cancellable);
+ g_object_unref(tethering_ctx->tethering_ext_cancellable);
+ tethering_ctx->tethering_ext_cancellable = NULL;
+ }
+
+ if (tethering_ctx->tethering_ext_client) {
+ g_object_unref(tethering_ctx->tethering_ext_client);
+ tethering_ctx->tethering_ext_client = NULL;
+ }
}
-static void __tethering_ext_signal_filter(GDBusConnection *conn,
- const gchar *name, const gchar *path, const gchar *interface,
- const gchar *sig, GVariant *param, gpointer user_data)
+static void __tethering_ext_signal_filter(GDBusConnection * conn, const gchar * name, const gchar * path, const gchar * interface, const gchar * sig, GVariant * param, gpointer user_data)
{
- TETHERING_EXT_DBG("Received signal %s", sig);
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *)user_data;
-
- if (!g_strcmp0(sig, SIGNAL_TETHERING_EXT_MODE_CHANGED)) {
- __tethering_ext_mode_changed(tethering_ctx, param);
- } else if (!g_strcmp0(sig, SIGNAL_TETHERING_EXT_ENABLED)) {
- __tethering_ext_enabled_callback(tethering_ctx, param);
- } else if (!g_strcmp0(sig, SIGNAL_TETHERING_EXT_DISABLED)) {
- __tethering_ext_disabled_callback(tethering_ctx, param);
- } else if (!g_strcmp0(sig, SIGNAL_TETHERING_CONNECTION_CHANGED)) {
- __tethering_ext_connection_state_callback(tethering_ctx, param);
- }
-
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ TETHERING_EXT_DBG("Received signal %s", sig);
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) user_data;
+
+ if (!g_strcmp0(sig, SIGNAL_TETHERING_EXT_MODE_CHANGED)) {
+ __tethering_ext_mode_changed(tethering_ctx, param);
+ } else if (!g_strcmp0(sig, SIGNAL_TETHERING_EXT_ENABLED)) {
+ __tethering_ext_enabled_callback(tethering_ctx, param);
+ } else if (!g_strcmp0(sig, SIGNAL_TETHERING_EXT_DISABLED)) {
+ __tethering_ext_disabled_callback(tethering_ctx, param);
+ } else if (!g_strcmp0(sig, SIGNAL_TETHERING_CONNECTION_CHANGED)) {
+ __tethering_ext_connection_state_callback(tethering_ctx, param);
+ }
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
}
-static void __tethering_ext_unregister_signal(_tethering_ext_h *tethering_ctx)
+static void __tethering_ext_unregister_signal(_tethering_ext_h * tethering_ctx)
{
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
- if (tethering_ctx) {
- g_dbus_connection_signal_unsubscribe(tethering_ctx->tethering_ext_client, tethering_ctx->subscribe_id_wifi_tethering_state);
- }
-
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ if (tethering_ctx) {
+ g_dbus_connection_signal_unsubscribe(tethering_ctx->tethering_ext_client, tethering_ctx->subscribe_id_wifi_tethering_state);
+ }
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
}
-static int __tethering_ext_dbus_register_signal(_tethering_ext_h *tethering_ctx)
+static int __tethering_ext_dbus_register_signal(_tethering_ext_h * tethering_ctx)
{
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
-
- _tethering_ext_err_e Error = TETHERING_EXT_ERR_NONE;
-
- if (!tethering_ctx) {
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
- return TETHERING_EXT_ERR_APP_NOT_REGISTERED;
- }
-
- /* Create wifi-tethering-service connection */
- tethering_ctx->subscribe_id_wifi_tethering_state = g_dbus_connection_signal_subscribe(
- tethering_ctx->tethering_ext_client,
- TETHERING_EXT_BUS_NAME,
- TETHERING_EXT_INTERFACE_NAME,
- NULL,
- TETHERING_EXT_OBJECT_PATH,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- __tethering_ext_signal_filter,
- tethering_ctx,
- NULL);
-
-
- if (tethering_ctx->subscribe_id_wifi_tethering_state == 0) {
- TETHERING_EXT_ERR("Failed to register signal, subscribe_id_wifi_tethering_state(%d)",
- tethering_ctx->subscribe_id_wifi_tethering_state);
- __tethering_ext_unregister_signal(tethering_ctx);
- Error = TETHERING_EXT_ERR_INVALID_OPERATION;
- }
-
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
- return Error;
-}
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+
+ _tethering_ext_err_e Error = TETHERING_EXT_ERR_NONE;
+
+ if (!tethering_ctx) {
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ return TETHERING_EXT_ERR_APP_NOT_REGISTERED;
+ }
+ /* Create wifi-tethering-service connection */
+ tethering_ctx->subscribe_id_wifi_tethering_state = g_dbus_connection_signal_subscribe(tethering_ctx->tethering_ext_client, TETHERING_EXT_BUS_NAME, TETHERING_EXT_INTERFACE_NAME, NULL, TETHERING_EXT_OBJECT_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE, __tethering_ext_signal_filter, tethering_ctx, NULL);
-int _tethering_ext_register_dbus(tethering_ext_h tethering_context) {
- // __TETHERING_EXT_CAPI_FUNC_ENTER__
- _tethering_ext_err_e Error = TETHERING_EXT_ERR_NONE;
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
- Error = __tethering_ext_dbus_create(tethering_ctx);
- if (Error != TETHERING_EXT_ERR_NONE) {
- return Error;
- }
-
- Error = __tethering_ext_dbus_register_signal(tethering_ctx);
- if (Error != TETHERING_EXT_ERR_NONE) {
- TETHERING_EXT_ERR("Failed to register DBus signal, Error(%d)", Error);
- __tethering_ext_close_gdbus_call(tethering_ctx);
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
- return Error;
- }
-
- tethering_ctx->tethering_ext_event_cb = (_tethering_ext_event_cb) __tethering_ext_evt_cb;
- tethering_ctx->tethering_ext_user_data = tethering_ctx;
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
- return TETHERING_EXT_ERR_NONE;
+ if (tethering_ctx->subscribe_id_wifi_tethering_state == 0) {
+ TETHERING_EXT_ERR("Failed to register signal, subscribe_id_wifi_tethering_state(%d)", tethering_ctx->subscribe_id_wifi_tethering_state);
+ __tethering_ext_unregister_signal(tethering_ctx);
+ Error = TETHERING_EXT_ERR_INVALID_OPERATION;
+ }
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ return Error;
}
-void _tethering_ext_unregister_dbus(tethering_ext_h tethering_context) {
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+int _tethering_ext_register_dbus(tethering_ext_h tethering_context)
+{
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__
+ _tethering_ext_err_e Error = TETHERING_EXT_ERR_NONE;
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
+ Error = __tethering_ext_dbus_create(tethering_ctx);
+ if (Error != TETHERING_EXT_ERR_NONE) {
+ return Error;
+ }
+
+ Error = __tethering_ext_dbus_register_signal(tethering_ctx);
+ if (Error != TETHERING_EXT_ERR_NONE) {
+ TETHERING_EXT_ERR("Failed to register DBus signal, Error(%d)", Error);
+ __tethering_ext_close_gdbus_call(tethering_ctx);
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ return Error;
+ }
+
+ tethering_ctx->tethering_ext_event_cb = (_tethering_ext_event_cb) __tethering_ext_evt_cb;
+ tethering_ctx->tethering_ext_user_data = tethering_ctx;
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ return TETHERING_EXT_ERR_NONE;
+}
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
+void _tethering_ext_unregister_dbus(tethering_ext_h tethering_context)
+{
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
- if (tethering_ctx) {
- tethering_ctx->tethering_ext_event_cb = NULL;
- tethering_ctx->tethering_ext_user_data = NULL;
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
- __tethering_ext_unregister_signal(tethering_ctx);
- __tethering_ext_close_gdbus_call(tethering_ctx);
- }
+ if (tethering_ctx) {
+ tethering_ctx->tethering_ext_event_cb = NULL;
+ tethering_ctx->tethering_ext_user_data = NULL;
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ __tethering_ext_unregister_signal(tethering_ctx);
+ __tethering_ext_close_gdbus_call(tethering_ctx);
+ }
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
}
int _tethering_ext_set_wifi_tethering_mode(tethering_ext_h tethering_context, bool enable)
{
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *)tethering_context;
- _tethering_ext_err_e Error = TETHERING_EXT_ERR_NONE;
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
+ _tethering_ext_err_e Error = TETHERING_EXT_ERR_NONE;
- Error = _tethering_ext_dbus_set_wifi_tethering_mode(tethering_ctx, enable);
- if (Error != TETHERING_EXT_ERR_NONE)
- TETHERING_EXT_ERR("Failed to set tethering mode(%d), Error[%s])",
- enable, tethering_ext_err_to_str(Error));
+ Error = _tethering_ext_dbus_set_wifi_tethering_mode(tethering_ctx, enable);
+ if (Error != TETHERING_EXT_ERR_NONE)
+ TETHERING_EXT_ERR("Failed to set tethering mode(%d), Error[%s])", enable, tethering_ext_err_to_str(Error));
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
- return Error;
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ return Error;
}
int _tethering_ext_set_wifi_tethering_mode_with_params(tethering_ext_h tethering_context, bool enable)
{
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *)tethering_context;
- _tethering_ext_err_e Error = TETHERING_EXT_ERR_NONE;
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
+ _tethering_ext_err_e Error = TETHERING_EXT_ERR_NONE;
- Error = _tethering_ext_dbus_set_wifi_tethering_mode_with_params(tethering_ctx, enable);
- if (Error != TETHERING_EXT_ERR_NONE)
- TETHERING_EXT_ERR("Failed to set tethering mode(%d), Error[%s])",
- enable, tethering_ext_err_to_str(Error));
+ Error = _tethering_ext_dbus_set_wifi_tethering_mode_with_params(tethering_ctx, enable);
+ if (Error != TETHERING_EXT_ERR_NONE)
+ TETHERING_EXT_ERR("Failed to set tethering mode(%d), Error[%s])", enable, tethering_ext_err_to_str(Error));
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
- return Error;
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ return Error;
}
-
-int _tethering_ext_get_wifi_tethering_mode(tethering_ext_h tethering_context, bool *is_enabled) {
- // __TETHERING_EXT_CAPI_FUNC_ENTER__;
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
- _tethering_ext_err_e Error = TETHERING_EXT_ERR_NONE;
- _tethering_ext_state_e tethering_state = TETHERING_EXT_STATE_DISABLED;
-
- Error = _tethering_ext_dbus_get_wifi_tethering_state(tethering_ctx, &tethering_state);
- if (Error != TETHERING_EXT_ERR_NONE)
- TETHERING_EXT_ERR("Failed to get tethering state [%s]", tethering_ext_err_to_str(Error));
- else {
- if (tethering_state == TETHERING_EXT_STATE_ENABLED) {
- *is_enabled = true;
- } else {
- *is_enabled = false;
- }
- tethering_ctx->tethering_ext_state = tethering_state;
- }
- // __TETHERING_EXT_CAPI_FUNC_EXIT__;
- return Error;
+int _tethering_ext_get_wifi_tethering_mode(tethering_ext_h tethering_context, bool *is_enabled)
+{
+ // __TETHERING_EXT_CAPI_FUNC_ENTER__;
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
+ _tethering_ext_err_e Error = TETHERING_EXT_ERR_NONE;
+ _tethering_ext_state_e tethering_state = TETHERING_EXT_STATE_DISABLED;
+
+ Error = _tethering_ext_dbus_get_wifi_tethering_state(tethering_ctx, &tethering_state);
+ if (Error != TETHERING_EXT_ERR_NONE)
+ TETHERING_EXT_ERR("Failed to get tethering state [%s]", tethering_ext_err_to_str(Error));
+ else {
+ if (tethering_state == TETHERING_EXT_STATE_ENABLED) {
+ *is_enabled = true;
+ } else {
+ *is_enabled = false;
+ }
+ tethering_ctx->tethering_ext_state = tethering_state;
+ }
+ // __TETHERING_EXT_CAPI_FUNC_EXIT__;
+ return Error;
}
-int _tethering_ext_set_config(tethering_ext_h tethering_context, void *src_config, int type) {
- int Error = TETHERING_EXT_ERR_NONE;
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
- tethering_ext_config_h *target_config = &(tethering_ctx->tethering_ext_config);
-
- switch (type) {
- case TETHERING_EXT_SSID:
- {
- _tethering_ext_data_h *ssid_data = (_tethering_ext_data_h *) src_config;
- const char *ssid = ssid_data->Data;
- if ((ssid_data->DataLength < TETHERING_EXT_WIFI_SSID_MIN_LEN) ||
- (ssid_data->DataLength > TETHERING_EXT_WIFI_SSID_MAX_LEN)) {
- TETHERING_EXT_ERR("Invalid SSID of length %d", ssid_data->DataLength);
- return TETHERING_EXT_ERR_INVALID_PARAM;
- }
- strncpy(target_config->ssid, ssid, ssid_data->DataLength);
- target_config->ssid[ssid_data->DataLength + 1] = 0;
- break;
- }
- case TETHERING_EXT_PASSPHRASE:
- {
- _tethering_ext_data_h *passphrase_data = (_tethering_ext_data_h *) src_config;
- const char *passphrase = passphrase_data->Data;
- if ((passphrase_data->DataLength < TETHERING_EXT_WIFI_KEY_MIN_LEN) ||
- (passphrase_data->DataLength > TETHERING_EXT_WIFI_KEY_MAX_LEN)) {
- TETHERING_EXT_ERR("Invalid passphrase of length %d", passphrase_data->DataLength);
- return TETHERING_EXT_ERR_INVALID_PARAM;
- }
- strncpy(target_config->passphrase, passphrase, passphrase_data->DataLength);
- target_config->passphrase[passphrase_data->DataLength + 1] = 0;
- break;
- }
- case TETHERING_EXT_CHANNEL:
- target_config->channel = *((int *) src_config);
- break;
- default:
- TETHERING_EXT_ERR("Unknown type %d", type);
- Error = TETHERING_ERROR_INVALID_PARAMETER;
- break;
- }
- return Error;
+int _tethering_ext_set_config(tethering_ext_h tethering_context, void *src_config, int type)
+{
+ int Error = TETHERING_EXT_ERR_NONE;
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
+ tethering_ext_config_h *target_config = &(tethering_ctx->tethering_ext_config);
+
+ switch (type) {
+ case TETHERING_EXT_SSID:
+ {
+ _tethering_ext_data_h *ssid_data = (_tethering_ext_data_h *) src_config;
+ const char *ssid = ssid_data->Data;
+ if ((ssid_data->DataLength < TETHERING_EXT_WIFI_SSID_MIN_LEN) || (ssid_data->DataLength > TETHERING_EXT_WIFI_SSID_MAX_LEN)) {
+ TETHERING_EXT_ERR("Invalid SSID of length %d", ssid_data->DataLength);
+ return TETHERING_EXT_ERR_INVALID_PARAM;
+ }
+ strncpy(target_config->ssid, ssid, ssid_data->DataLength);
+ target_config->ssid[ssid_data->DataLength + 1] = 0;
+ break;
+ }
+ case TETHERING_EXT_PASSPHRASE:
+ {
+ _tethering_ext_data_h *passphrase_data = (_tethering_ext_data_h *) src_config;
+ const char *passphrase = passphrase_data->Data;
+ if ((passphrase_data->DataLength < TETHERING_EXT_WIFI_KEY_MIN_LEN) || (passphrase_data->DataLength > TETHERING_EXT_WIFI_KEY_MAX_LEN)) {
+ TETHERING_EXT_ERR("Invalid passphrase of length %d", passphrase_data->DataLength);
+ return TETHERING_EXT_ERR_INVALID_PARAM;
+ }
+ strncpy(target_config->passphrase, passphrase, passphrase_data->DataLength);
+ target_config->passphrase[passphrase_data->DataLength + 1] = 0;
+ break;
+ }
+ case TETHERING_EXT_CHANNEL:
+ target_config->channel = *((int *)src_config);
+ break;
+ default:
+ TETHERING_EXT_ERR("Unknown type %d", type);
+ Error = TETHERING_ERROR_INVALID_PARAMETER;
+ break;
+ }
+ return Error;
}
-int _tethering_ext_get_config(tethering_ext_h tethering_context, void *target_config, int type) {
- if (! target_config) {
- return TETHERING_EXT_ERR_INVALID_PARAM;
- }
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
- tethering_ext_config_h *src_config = &(tethering_ctx->tethering_ext_config);
- switch (type) {
- case TETHERING_EXT_SSID | TETHERING_EXT_PASSPHRASE:
- {
- _tethering_ext_tethering_info *t_info = (_tethering_ext_tethering_info *) target_config;
- _tethering_ext_dbus_get_wifi_tethering_info(tethering_ctx, t_info);
- break;
- }
- case TETHERING_EXT_SECURITY_TYPE:
- {
- int *security_type = (int *) target_config;
- if (vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_SECURITY, security_type) < 0) {
- TETHERING_EXT_ERR("vconf_get_int is failed\n");
- return TETHERING_EXT_ERR_OPERATION_FAILED;
- }
- break;
- }
- case TETHERING_EXT_CHANNEL:
- *((int *) target_config) = src_config->channel;
- break;
- case TETHERING_EXT_VISIBLE:
- {
- int hide = 0;
- bool *visible = (bool *) target_config;
- if (vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_HIDE, &hide) < 0) {
- TETHERING_EXT_ERR("vconf_get_int is failed\n");
- return TETHERING_EXT_ERR_OPERATION_FAILED;
- }
-
- if (hide)
- *visible = false;
- else
- *visible = true;
- break;
- }
- }
- return TETHERING_EXT_ERR_NONE;
+int _tethering_ext_get_config(tethering_ext_h tethering_context, void *target_config, int type)
+{
+ if (!target_config) {
+ return TETHERING_EXT_ERR_INVALID_PARAM;
+ }
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
+ tethering_ext_config_h *src_config = &(tethering_ctx->tethering_ext_config);
+ switch (type) {
+ case TETHERING_EXT_SSID | TETHERING_EXT_PASSPHRASE:
+ {
+ _tethering_ext_tethering_info *t_info = (_tethering_ext_tethering_info *) target_config;
+ _tethering_ext_dbus_get_wifi_tethering_info(tethering_ctx, t_info);
+ break;
+ }
+ case TETHERING_EXT_SECURITY_TYPE:
+ {
+ int *security_type = (int *)target_config;
+ if (vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_SECURITY, security_type) < 0) {
+ TETHERING_EXT_ERR("vconf_get_int is failed\n");
+ return TETHERING_EXT_ERR_OPERATION_FAILED;
+ }
+ break;
+ }
+ case TETHERING_EXT_CHANNEL:
+ *((int *)target_config) = src_config->channel;
+ break;
+ case TETHERING_EXT_VISIBLE:
+ {
+ int hide = 0;
+ bool *visible = (bool *)target_config;
+ if (vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_HIDE, &hide) < 0) {
+ TETHERING_EXT_ERR("vconf_get_int is failed\n");
+ return TETHERING_EXT_ERR_OPERATION_FAILED;
+ }
+
+ if (hide)
+ *visible = false;
+ else
+ *visible = true;
+ break;
+ }
+ }
+ return TETHERING_EXT_ERR_NONE;
}
-int _tethering_ext_register_callback(tethering_ext_h tethering_context, _tethering_ext_callback_e cb_type, void *callback, void *data) {
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *)tethering_context;
- _tethering_ext_err_e error = TETHERING_EXT_ERR_NONE;
- if (! tethering_ctx->tethering_ext_callbacks)
- {
- TETHERING_EXT_ERR("Callbacks not initialized");
- return TETHERING_EXT_ERR_OPERATION_FAILED;
- }
- switch (cb_type) {
- case TETHERING_EXT_ENABLED_CALLBACK:
- tethering_ctx->tethering_ext_callbacks->enabled_cb = (tethering_ext_enabled_cb) callback;
- tethering_ctx->tethering_ext_callbacks->enabled_user_data = data;
- break;
-
- case TETHERING_EXT_DISABLED_CALLBACK:
- tethering_ctx->tethering_ext_callbacks->disabled_cb = (tethering_ext_disabled_cb) callback;
- tethering_ctx->tethering_ext_callbacks->disabled_user_data = data;
- break;
-
- case TETHERING_EXT_CONNECTION_STATE_CHANGED_CALLBACK:
- tethering_ctx->tethering_ext_callbacks->changed_cb = (tethering_ext_connection_state_changed_cb) callback;
- tethering_ctx->tethering_ext_callbacks->changed_user_data = data;
- break;
-
- default:
- TETHERING_EXT_ERR("Invalid callback type %d specified", (int) cb_type);
- error = TETHERING_EXT_ERR_INVALID_PARAM;
- break;
- }
- return error;
+int _tethering_ext_register_callback(tethering_ext_h tethering_context, _tethering_ext_callback_e cb_type, void *callback, void *data)
+{
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
+ _tethering_ext_err_e error = TETHERING_EXT_ERR_NONE;
+ if (!tethering_ctx->tethering_ext_callbacks) {
+ TETHERING_EXT_ERR("Callbacks not initialized");
+ return TETHERING_EXT_ERR_OPERATION_FAILED;
+ }
+ switch (cb_type) {
+ case TETHERING_EXT_ENABLED_CALLBACK:
+ tethering_ctx->tethering_ext_callbacks->enabled_cb = (tethering_ext_enabled_cb) callback;
+ tethering_ctx->tethering_ext_callbacks->enabled_user_data = data;
+ break;
+
+ case TETHERING_EXT_DISABLED_CALLBACK:
+ tethering_ctx->tethering_ext_callbacks->disabled_cb = (tethering_ext_disabled_cb) callback;
+ tethering_ctx->tethering_ext_callbacks->disabled_user_data = data;
+ break;
+
+ case TETHERING_EXT_CONNECTION_STATE_CHANGED_CALLBACK:
+ tethering_ctx->tethering_ext_callbacks->changed_cb = (tethering_ext_connection_state_changed_cb) callback;
+ tethering_ctx->tethering_ext_callbacks->changed_user_data = data;
+ break;
+
+ default:
+ TETHERING_EXT_ERR("Invalid callback type %d specified", (int)cb_type);
+ error = TETHERING_EXT_ERR_INVALID_PARAM;
+ break;
+ }
+ return error;
}
-int _tethering_ext_unregister_callback(tethering_ext_h tethering_context, _tethering_ext_callback_e cb_type) {
- _tethering_ext_h *tethering_ctx = (_tethering_ext_h *)tethering_context;
- _tethering_ext_err_e error = TETHERING_EXT_ERR_NONE;
- if (! tethering_ctx->tethering_ext_callbacks)
- {
- TETHERING_EXT_ERR("Callbacks not initialized");
- return TETHERING_EXT_ERR_OPERATION_FAILED;
- }
- switch (cb_type) {
- case TETHERING_EXT_ENABLED_CALLBACK:
- tethering_ctx->tethering_ext_callbacks->enabled_cb = NULL;
- tethering_ctx->tethering_ext_callbacks->enabled_user_data = NULL;
- break;
-
- case TETHERING_EXT_DISABLED_CALLBACK:
- tethering_ctx->tethering_ext_callbacks->disabled_cb = NULL;
- tethering_ctx->tethering_ext_callbacks->disabled_user_data = NULL;
- break;
-
- case TETHERING_EXT_CONNECTION_STATE_CHANGED_CALLBACK:
- tethering_ctx->tethering_ext_callbacks->changed_cb = NULL;
- tethering_ctx->tethering_ext_callbacks->changed_user_data = NULL;
- break;
-
- default:
- TETHERING_EXT_ERR("Invalid callback type %d specified", (int) cb_type);
- error = TETHERING_EXT_ERR_INVALID_PARAM;
- break;
- }
- return error;
-}
\ No newline at end of file
+int _tethering_ext_unregister_callback(tethering_ext_h tethering_context, _tethering_ext_callback_e cb_type)
+{
+ _tethering_ext_h *tethering_ctx = (_tethering_ext_h *) tethering_context;
+ _tethering_ext_err_e error = TETHERING_EXT_ERR_NONE;
+ if (!tethering_ctx->tethering_ext_callbacks) {
+ TETHERING_EXT_ERR("Callbacks not initialized");
+ return TETHERING_EXT_ERR_OPERATION_FAILED;
+ }
+ switch (cb_type) {
+ case TETHERING_EXT_ENABLED_CALLBACK:
+ tethering_ctx->tethering_ext_callbacks->enabled_cb = NULL;
+ tethering_ctx->tethering_ext_callbacks->enabled_user_data = NULL;
+ break;
+
+ case TETHERING_EXT_DISABLED_CALLBACK:
+ tethering_ctx->tethering_ext_callbacks->disabled_cb = NULL;
+ tethering_ctx->tethering_ext_callbacks->disabled_user_data = NULL;
+ break;
+
+ case TETHERING_EXT_CONNECTION_STATE_CHANGED_CALLBACK:
+ tethering_ctx->tethering_ext_callbacks->changed_cb = NULL;
+ tethering_ctx->tethering_ext_callbacks->changed_user_data = NULL;
+ break;
+
+ default:
+ TETHERING_EXT_ERR("Invalid callback type %d specified", (int)cb_type);
+ error = TETHERING_EXT_ERR_INVALID_PARAM;
+ break;
+ }
+ return error;
+}
#include "tethering_ext_test_util.h"
#include "tethering_ext.h"
-
#define DISABLE_REASON_TEXT_LEN 64
#define COMMON_STR_BUF_LEN 32
return false;
}
- buf[rv-1] = '\0';
+ buf[rv - 1] = '\0';
return true;
}
static const char *__convert_disabled_code_to_str(const tethering_ext_disabled_cause_e code)
{
- static char str_buf[DISABLE_REASON_TEXT_LEN] = {0, };
+ static char str_buf[DISABLE_REASON_TEXT_LEN] = { 0, };
switch (code) {
case TETHERING_EXT_DISABLED_BY_FLIGHT_MODE:
return str_buf;
}
-static void __register_cbs(tethering_ext_h th, __tethering_ext_cbs *cbs, void *user_data)
+static void __register_cbs(tethering_ext_h th, __tethering_ext_cbs * cbs, void *user_data)
{
tethering_error_e ret = TETHERING_ERROR_NONE;
return;
}
-static const char *tethering_state_str(tethering_state_e state) {
- const char *retval;
- switch (state) {
- case TETHERING_STATE_IDLE:
- retval = "IDLE";
- break;
- case TETHERING_STATE_ACTIVATING:
- retval = "ACTIVATING";
- break;
- case TETHERING_STATE_ACTIVATED:
- retval = "ACTIVATED";
- break;
- case TETHERING_STATE_DEACTIVATING:
- retval = "DEACTIVATING";
- break;
- case TETHERING_STATE_DEACTIVATED:
- retval = "DEACTIVATED";
- break;
- default:
- retval = "UNKNOWN";
- break;
- }
- return retval;
+static const char *tethering_state_str(tethering_state_e state)
+{
+ const char *retval;
+ switch (state) {
+ case TETHERING_STATE_IDLE:
+ retval = "IDLE";
+ break;
+ case TETHERING_STATE_ACTIVATING:
+ retval = "ACTIVATING";
+ break;
+ case TETHERING_STATE_ACTIVATED:
+ retval = "ACTIVATED";
+ break;
+ case TETHERING_STATE_DEACTIVATING:
+ retval = "DEACTIVATING";
+ break;
+ case TETHERING_STATE_DEACTIVATED:
+ retval = "DEACTIVATED";
+ break;
+ default:
+ retval = "UNKNOWN";
+ break;
+ }
+ return retval;
}
-
/* Tethering callbacks */
static void __enabled_cb(tethering_error_e result, bool is_requested, void *user_data)
{
if (result != TETHERING_ERROR_NONE) {
if (!is_requested) {
- TETHERING_EXT_DBG("P2P Tethering failed (not requested)\n");
+ TETHERING_EXT_DBG("P2P Tethering failed (not requested)\n");
GSemaphore_post(&g_tethering_sem);
return;
- }
+ }
TETHERING_EXT_DBG("P2P Tethering is not enabled. error code[0x%X]\n", result);
GSemaphore_post(&g_tethering_sem);
return;
}
GSemaphore_update(&g_tethering_sem, TETHERING_STATE_DEACTIVATED);
- TETHERING_EXT_DBG("P2P Tethering is %s\n", __convert_disabled_code_to_str(cause));
+ TETHERING_EXT_DBG("P2P Tethering is %s\n", __convert_disabled_code_to_str(cause));
GSemaphore_post(&g_tethering_sem);
}
tethering_ext_client_get_name(clone, &hostname);
if (open) {
- g_print("## New station Type [P2P Tethering], IP [%s], MAC [%s], hostname [%s]\n",
- ip_address, mac_address, hostname);
+ g_print("## New station Type [P2P Tethering], IP [%s], MAC [%s], hostname [%s]\n", ip_address, mac_address, hostname);
} else {
- g_print("## Disconnected station Type [P2P Tethering], IP [%s], MAC [%s], hostname [%s]\n",
- ip_address, mac_address, hostname);
+ g_print("## Disconnected station Type [P2P Tethering], IP [%s], MAC [%s], hostname [%s]\n", ip_address, mac_address, hostname);
}
if (ip_address)
return;
}
+
/* End of tethering callbacks */
int test_tethering_ext_initialize(void)
int ret = tethering_ext_initialize(&th);
__tethering_ext_cbs cbs = {
__enabled_cb, __disabled_cb,
- __connection_state_changed_cb};
+ __connection_state_changed_cb
+ };
if (__is_err(ret) == false) {
__register_cbs(th, &cbs, NULL);
g_print("Tethering extension initialize is failed\n");
return -1;
}
- if (GSemaphore_init(&g_tethering_sem) < 0) {
- g_print("Tethering extension initialize: GSemaphore_init failed\n");
- return -1;
- }
+ if (GSemaphore_init(&g_tethering_sem) < 0) {
+ g_print("Tethering extension initialize: GSemaphore_init failed\n");
+ return -1;
+ }
g_print("Tethering extension initialize and register callback success\n");
return 1;
}
return 1;
}
-int test_tethering_ext_get_tethering_info() {
+int test_tethering_ext_get_tethering_info()
+{
int ret = TETHERING_ERROR_NONE;
int rv = 1;
g_app_tethering_info = (app_tethering_info_t *) malloc(sizeof(app_tethering_info_t));
- ret = tethering_ext_get_tethering_info(th, (void *) g_app_tethering_info);
+ ret = tethering_ext_get_tethering_info(th, (void *)g_app_tethering_info);
if (ret != TETHERING_ERROR_NONE) {
g_print("Fail to get tethering ext info\n");
rv = -1;
if (state == TETHERING_STATE_DEACTIVATING) {
g_print("Tethering ext deactivation already in progress\n");
return -1;
- } else if(state == TETHERING_STATE_DEACTIVATED) {
+ } else if (state == TETHERING_STATE_DEACTIVATED) {
g_print("Tethering ext already deactivated\n");
} else if (state == TETHERING_STATE_ACTIVATING) {
g_print("Tethering ext activation currently in progress\n");
int test_tethering_ext_wifi_set_ssid(void)
{
int ret;
- char ssid[100] = {0, };
+ char ssid[100] = { 0, };
- if (test_get_user_string("Input SSID for Wi-Fi tethering:",
- ssid, 100) == false) {
+ if (test_get_user_string("Input SSID for Wi-Fi tethering:", ssid, 100) == false) {
g_print("Failed to read user input!!\n");
return -1;
}
int test_tethering_ext_wifi_set_passphrase(void)
{
int ret;
- char passphrase[100] = {0, };
+ char passphrase[100] = { 0, };
- if (test_get_user_string("Input passphrase for Wi-Fi tethering:",
- passphrase, 100) == false) {
+ if (test_get_user_string("Input passphrase for Wi-Fi tethering:", passphrase, 100) == false) {
g_print("Failed to read user input!!\n");
return -1;
}
return 1;
}
-
int test_tethering_ext_wifi_set_ssid(void);
int test_tethering_ext_wifi_set_passphrase(void);
int test_tethering_ext_wifi_set_channel(void);
-#endif // #ifndef __TETHERING_EXT_TEST_H_
+#endif // #ifndef __TETHERING_EXT_TEST_H_
total++;\
} while (0)
-gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
+gboolean test_thread(GIOChannel * source, GIOCondition condition, gpointer data);
int test_tethering_ext_verification(char *data)
{
// Disable test_thread processing
g_verification = TRUE;
- printf("[%s] Entry =>\n", __FUNCTION__);
- int rv;
+ printf("[%s] Entry =>\n", __FUNCTION__);
+ int rv;
char *saveptr = NULL;
char *options = strtok_r(data, "\n", &saveptr);
if (options == NULL) {
printf("\"f1\" - Verify Tethering Ext Enable (AP connected in 2.4GHz band)\n");
printf("\"f2\" - Verify Tethering Ext Enable (AP connected in 5GHz band)\n");
printf("\"e\"|\"f\" - Show verifications options.......\n");
- rv = 1;
+ rv = 1;
} else if (OPTION_MATCHES(options, "e1")) {
rv = tethering_ext_verify_enable_default();
} else if (OPTION_MATCHES(options, "e2")) {
gboolean input_handle_fn(gpointer data)
{
int rv;
- char *a = (char *) data;
+ char *a = (char *)data;
if (a[0] == '0') {
g_free(a);
}
switch (a[0]) {
- case '1':
- rv = test_tethering_ext_initialize();
- break;
- case '2':
- rv = test_tethering_ext_deinitialize();
- break;
- case 's':
- rv = test_tethering_ext_wifi_set_ssid();
- break;
- case 'p':
- rv = test_tethering_ext_wifi_set_passphrase();
- break;
- case 'c':
- rv = test_tethering_ext_wifi_set_channel();
- break;
- case 'a':
- rv = test_tethering_ext_activate();
- break;
- case 'd':
- rv = test_tethering_ext_deactivate();
- break;
- case 'l':
- rv = test_tethering_ext_get_tethering_info();
- break;
- case 'e':
- case 'f':
- rv = test_tethering_ext_verification(a);
- break;
-
- default:
- printf("unknown option %c\n", a[0]);
- rv = -1;
- break;
+ case '1':
+ rv = test_tethering_ext_initialize();
+ break;
+ case '2':
+ rv = test_tethering_ext_deinitialize();
+ break;
+ case 's':
+ rv = test_tethering_ext_wifi_set_ssid();
+ break;
+ case 'p':
+ rv = test_tethering_ext_wifi_set_passphrase();
+ break;
+ case 'c':
+ rv = test_tethering_ext_wifi_set_channel();
+ break;
+ case 'a':
+ rv = test_tethering_ext_activate();
+ break;
+ case 'd':
+ rv = test_tethering_ext_deactivate();
+ break;
+ case 'l':
+ rv = test_tethering_ext_get_tethering_info();
+ break;
+ case 'e':
+ case 'f':
+ rv = test_tethering_ext_verification(a);
+ break;
+
+ default:
+ printf("unknown option %c\n", a[0]);
+ rv = -1;
+ break;
}
if (rv == 1)
return true;
}
-gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) {
+gboolean test_thread(GIOChannel * source, GIOCondition condition, gpointer data)
+{
if (g_verification) {
return true;
}
mainloop = g_main_loop_new(NULL, false);
g_channel = g_io_channel_unix_new(0);
- g_io_add_watch(g_channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
+ g_io_add_watch(g_channel, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL), test_thread, NULL);
printf("Test Thread created...\n");
g_main_loop_run(mainloop);
return 0;
}
-
#include <unistd.h>
#include <glib.h>
-
#define TETHERING_STEP_EXIT_ON_ERROR(tethering_test_fn) \
do { \
int rv = tethering_test_fn();\
}\
} while (0)
-
typedef enum {
- TETHERING_TEST_SCENARIO_DEFAULT = 0,
- TETHERING_TEST_SCENARIO_AP_DISCONNECTED_WIFI_DIRECT_ON,
- TETHERING_TEST_SCENARIO_AP_DISCONNECTED_WIFI_DIRECT_OFF,
- TETHERING_TEST_SCENARIO_WIFI_OFF,
- TETHERING_TEST_SCENARIO_LOWER_FREQ_BAND,
- TETHERING_TEST_SCENARIO_HIGHER_FREQ_BAND,
- TETHERING_TEST_SCENARIO_MAX
+ TETHERING_TEST_SCENARIO_DEFAULT = 0,
+ TETHERING_TEST_SCENARIO_AP_DISCONNECTED_WIFI_DIRECT_ON,
+ TETHERING_TEST_SCENARIO_AP_DISCONNECTED_WIFI_DIRECT_OFF,
+ TETHERING_TEST_SCENARIO_WIFI_OFF,
+ TETHERING_TEST_SCENARIO_LOWER_FREQ_BAND,
+ TETHERING_TEST_SCENARIO_HIGHER_FREQ_BAND,
+ TETHERING_TEST_SCENARIO_MAX
} tethering_test_scenario_e;
const char *pre_requisites_msg[] = {
- "Make sure DUT is connected to WiFi AP, and WiFi Direct Link is disabled",
- "Ensure that DUT is disconnected from WiFi AP",
- "Ensure that DUT is disconnected from WiFi AP",
- "Ensure that DUT has turned off WiFi interface",
- "Make sure DUT is connected to WiFi AP on the 2.4 GHz band",
- "Make sure DUT is connected to WiFi AP on the 5 GHz band",
+ "Make sure DUT is connected to WiFi AP, and WiFi Direct Link is disabled",
+ "Ensure that DUT is disconnected from WiFi AP",
+ "Ensure that DUT is disconnected from WiFi AP",
+ "Ensure that DUT has turned off WiFi interface",
+ "Make sure DUT is connected to WiFi AP on the 2.4 GHz band",
+ "Make sure DUT is connected to WiFi AP on the 5 GHz band",
};
const char *activation_msg[] = {
- "Activating tethering",
- "Activating tethering, please connect DUT to AP when ready",
- "Activating tethering, please connect DUT to AP when ready",
- "Activating tethering, please enable WiFi on DUT first, then connect to AP when ready",
- "Activating tethering",
- "Activating tethering"
+ "Activating tethering",
+ "Activating tethering, please connect DUT to AP when ready",
+ "Activating tethering, please connect DUT to AP when ready",
+ "Activating tethering, please enable WiFi on DUT first, then connect to AP when ready",
+ "Activating tethering",
+ "Activating tethering"
};
#define TETHERING_WAIT_TILL_PREREQUISITES_MET(scenario_indx) \
TETHERING_STEP_EXIT_ON_ERROR(test_tethering_ext_deinitialize);\
} while(0)
-int tethering_ext_verify_enable_default() {
- TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_DEFAULT);
- return 1;
+int tethering_ext_verify_enable_default()
+{
+ TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_DEFAULT);
+ return 1;
}
-int tethering_ext_verify_enable_ap_disconnected_wifi_direct_on() {
- TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_AP_DISCONNECTED_WIFI_DIRECT_ON);
- return 1;
+int tethering_ext_verify_enable_ap_disconnected_wifi_direct_on()
+{
+ TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_AP_DISCONNECTED_WIFI_DIRECT_ON);
+ return 1;
}
-int tethering_ext_verify_enable_ap_disconnected_wifi_direct_off() {
- TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_AP_DISCONNECTED_WIFI_DIRECT_OFF);
- return 1;
+int tethering_ext_verify_enable_ap_disconnected_wifi_direct_off()
+{
+ TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_AP_DISCONNECTED_WIFI_DIRECT_OFF);
+ return 1;
}
-int tethering_ext_verify_enable_ap_disconnected_wifi_off() {
- TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_WIFI_OFF);
- return 1;
+int tethering_ext_verify_enable_ap_disconnected_wifi_off()
+{
+ TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_WIFI_OFF);
+ return 1;
}
-int tethering_ext_verify_enable_freq_band_lower() {
- TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_LOWER_FREQ_BAND);
- return 1;
+int tethering_ext_verify_enable_freq_band_lower()
+{
+ TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_LOWER_FREQ_BAND);
+ return 1;
}
-int tethering_ext_verify_enable_freq_band_higher() {
- TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_HIGHER_FREQ_BAND);
- return 1;
+int tethering_ext_verify_enable_freq_band_higher()
+{
+ TETHERING_SCENARIO_IMPL(TETHERING_TEST_SCENARIO_HIGHER_FREQ_BAND);
+ return 1;
}
-
-
-
int tethering_ext_verify_enable_freq_band_lower();
int tethering_ext_verify_enable_freq_band_higher();
-#endif // #ifndef __TETHERING_EXT_TEST_SCENARIO_H_
\ No newline at end of file
+#endif // #ifndef __TETHERING_EXT_TEST_SCENARIO_H_
#include "tethering_ext_test_util.h"
-int GSemaphore_init(GSemaphore_t *sem) {
- if (!sem) {
- return -1;
- }
- sem->state = TETHERING_STATE_IDLE;
- g_mutex_init(&sem->mutex);
- g_cond_init(&sem->cond);
- return 0;
+int GSemaphore_init(GSemaphore_t * sem)
+{
+ if (!sem) {
+ return -1;
+ }
+ sem->state = TETHERING_STATE_IDLE;
+ g_mutex_init(&sem->mutex);
+ g_cond_init(&sem->cond);
+ return 0;
}
-int GSemaphore_destroy(GSemaphore_t *sem) {
- if (!sem) {
- return -1;
- }
- g_mutex_clear(&sem->mutex);
- g_cond_clear(&sem->cond);
- return 0;
+int GSemaphore_destroy(GSemaphore_t * sem)
+{
+ if (!sem) {
+ return -1;
+ }
+ g_mutex_clear(&sem->mutex);
+ g_cond_clear(&sem->cond);
+ return 0;
}
-int GSemaphore_post(GSemaphore_t *sem) {
- if (!sem) {
- return -1;
- }
- g_mutex_lock(&sem->mutex);
- g_cond_signal(&sem->cond);
- g_mutex_unlock(&sem->mutex);
- return 0;
+int GSemaphore_post(GSemaphore_t * sem)
+{
+ if (!sem) {
+ return -1;
+ }
+ g_mutex_lock(&sem->mutex);
+ g_cond_signal(&sem->cond);
+ g_mutex_unlock(&sem->mutex);
+ return 0;
}
-int GSemaphore_wait(GSemaphore_t *sem) {
- if (!sem) {
- return -1;
- }
- g_mutex_lock(&sem->mutex);
- g_cond_wait(&sem->cond, &sem->mutex);
- g_mutex_unlock(&sem->mutex);
- return 0;
+int GSemaphore_wait(GSemaphore_t * sem)
+{
+ if (!sem) {
+ return -1;
+ }
+ g_mutex_lock(&sem->mutex);
+ g_cond_wait(&sem->cond, &sem->mutex);
+ g_mutex_unlock(&sem->mutex);
+ return 0;
}
-int GSemaphore_update(GSemaphore_t *sem, tethering_state_e state) {
- if (!sem) {
- return -1;
- }
- g_mutex_lock(&sem->mutex);
- sem->state = state;
- g_mutex_unlock(&sem->mutex);
- return 0;
+int GSemaphore_update(GSemaphore_t * sem, tethering_state_e state)
+{
+ if (!sem) {
+ return -1;
+ }
+ g_mutex_lock(&sem->mutex);
+ sem->state = state;
+ g_mutex_unlock(&sem->mutex);
+ return 0;
}
-int GSemaphore_get_state(GSemaphore_t *sem, tethering_state_e *state) {
- if (!sem) {
- return -1;
- }
- g_mutex_lock(&sem->mutex);
- *state = sem->state;
- g_mutex_unlock(&sem->mutex);
- return 0;
+int GSemaphore_get_state(GSemaphore_t * sem, tethering_state_e * state)
+{
+ if (!sem) {
+ return -1;
+ }
+ g_mutex_lock(&sem->mutex);
+ *state = sem->state;
+ g_mutex_unlock(&sem->mutex);
+ return 0;
}
#define __TETHERING_EXT_TEST_UTIL_H_
#include <glib.h>
-
typedef enum {
- TETHERING_STATE_IDLE = -1,
- TETHERING_STATE_ACTIVATING,
- TETHERING_STATE_ACTIVATED,
- TETHERING_STATE_DEACTIVATING,
- TETHERING_STATE_DEACTIVATED,
+ TETHERING_STATE_IDLE = -1,
+ TETHERING_STATE_ACTIVATING,
+ TETHERING_STATE_ACTIVATED,
+ TETHERING_STATE_DEACTIVATING,
+ TETHERING_STATE_DEACTIVATED,
} tethering_state_e;
typedef struct {
- tethering_state_e state;
- GMutex mutex;
- GCond cond;
+ tethering_state_e state;
+ GMutex mutex;
+ GCond cond;
} GSemaphore_t;
-int GSemaphore_init(GSemaphore_t *sem);
-int GSemaphore_destroy(GSemaphore_t *sem);
-int GSemaphore_post(GSemaphore_t *sem);
-int GSemaphore_wait(GSemaphore_t *sem);
-int GSemaphore_update(GSemaphore_t *sem, tethering_state_e state);
-int GSemaphore_get_state(GSemaphore_t *sem, tethering_state_e *state);
-#endif // #ifndef __TETHERING_EXT_TEST_UTIL_H_
\ No newline at end of file
+int GSemaphore_init(GSemaphore_t * sem);
+int GSemaphore_destroy(GSemaphore_t * sem);
+int GSemaphore_post(GSemaphore_t * sem);
+int GSemaphore_wait(GSemaphore_t * sem);
+int GSemaphore_update(GSemaphore_t * sem, tethering_state_e state);
+int GSemaphore_get_state(GSemaphore_t * sem, tethering_state_e * state);
+#endif // #ifndef __TETHERING_EXT_TEST_UTIL_H_