#include "net_nfc_typedef.h"
+#if 0
typedef void (*net_nfc_client_tag_is_tag_connected_completed)(
net_nfc_error_e result, net_nfc_target_type_e dev_type, void *user_data);
typedef void (*net_nfc_client_tag_get_current_target_handle_completed)(
net_nfc_error_e result, net_nfc_target_handle_h handle, void *user_data);
-
+#endif
typedef void (*net_nfc_client_tag_tag_discovered)(net_nfc_target_info_h info,
void *user_data);
typedef void (*net_nfc_client_tag_tag_detached)(void *user_data);
-
+#if 0
net_nfc_error_e net_nfc_client_tag_is_tag_connected(
net_nfc_client_tag_is_tag_connected_completed callback, void *user_data);
-net_nfc_error_e net_nfc_client_tag_is_tag_connected_sync(
- net_nfc_target_type_e *dev_type);
-
net_nfc_error_e net_nfc_client_tag_get_current_tag_info(
net_nfc_client_tag_get_current_tag_info_completed callback, void *user_data);
-net_nfc_error_e net_nfc_client_tag_get_current_tag_info_sync(
- net_nfc_target_info_h *info);
-
net_nfc_error_e net_nfc_client_tag_get_current_target_handle(
net_nfc_client_tag_get_current_target_handle_completed callback, void *user_data);
+#endif
+net_nfc_error_e net_nfc_client_tag_is_tag_connected_sync(
+ net_nfc_target_type_e *dev_type);
+
+net_nfc_error_e net_nfc_client_tag_get_current_tag_info_sync(
+ net_nfc_target_info_h *info);
net_nfc_error_e net_nfc_client_tag_get_current_target_handle_sync(
net_nfc_target_handle_h *handle);
void net_nfc_client_tag_unset_tag_detached(void);
+
+/* internal function */
void net_nfc_client_tag_set_filter(net_nfc_event_filter_e filter);
net_nfc_event_filter_e net_nfc_client_tag_get_filter(void);
typedef void (* nfc_transceive_callback)(net_nfc_error_e result,
void *user_data);
-typedef void (* nfc_transceive_data_callback)(net_nfc_error_e result,
+typedef void (*nfc_transceive_data_callback)(net_nfc_error_e result,
data_h data,
void *user_data);
@return return the result of this operation
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
+ @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
@exception NET_NFC_ALLOC_FAIL memory allocation is failed
*/
-net_nfc_error_e net_nfc_create_data_only (data_h* data);
+net_nfc_error_e net_nfc_create_data_only(data_h *data);
/**
create data handler with initial values, bytes will be copied into the data handler.
@return return the result of this operation
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
+ @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
@exception NET_NFC_ALLOC_FAIL memory allocation is failed
*/
-net_nfc_error_e net_nfc_create_data (data_h* data, const uint8_t* bytes, const uint32_t length);
+net_nfc_error_e net_nfc_create_data(data_h *data, const uint8_t *bytes, size_t length);
/**
get the byes and length from data handler. data handler assume bytes may have '0x0' value.
that's why this function also provides the length.
- @param[in] data data handler
+ @param[in] data data handler
@param[out] bytes binary pointer (it returns the direct pointer of handler's data) do not free this
@param[out] length length of the binary data;
@return return the result of this operation
- @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
+ @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
*/
-net_nfc_error_e net_nfc_get_data (const data_h data, uint8_t** bytes, uint32_t * length);
+net_nfc_error_e net_nfc_get_data(const data_h data, uint8_t **bytes, size_t *length);
/**
replace the data handler with given bytes. binary data (bytes) will be copied to data hander.
application should free or use local variable for given byte pointer.
- @param[in] data data handler
+ @param[in] data data handler
@param[in] bytes binary data
@param[in] length size of binary data
@exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illigal NULL pointer(s)
*/
-net_nfc_error_e net_nfc_set_data (const data_h data, const uint8_t* bytes, const uint32_t length);
+net_nfc_error_e net_nfc_set_data(data_h data, const uint8_t *bytes, size_t length);
/**
get length of data handler's bytes.
@param[in] data data handler
- @return length of bytes length
+ @return return the length of bytes
@exception 0 is returned if data is NULL
*/
-uint32_t net_nfc_get_data_length (const data_h data);
+size_t net_nfc_get_data_length(const data_h data);
/**
- get pointer of the handler's bytes (do not free this. it wll be freed when the application call "net_nfc_free_data" function
+ get pointer of the handler's bytes (do not free this. it should be freed when the application call "net_nfc_free_data" function
- @param[in] data data handler
+ @param[in] data data handler
- @return the pointer of bytes.
+ @return return the pointer of bytes.
@exception NULL is returned if data is NULL
*/
-uint8_t * net_nfc_get_data_buffer (const data_h data);
+uint8_t* net_nfc_get_data_buffer(const data_h data);
/**
free data handler. (it also free the copied bytes)
net_nfc_error_e net_nfc_free_data (data_h data);
-
/**
@}
*/
*/
-net_nfc_error_e net_nfc_get_tag_type (net_nfc_target_info_h target_info,
- net_nfc_target_type_e * type);
+net_nfc_error_e net_nfc_get_tag_type(net_nfc_target_info_h target_info,
+ net_nfc_target_type_e *type);
/**
type getter from targte info handler
*/
net_nfc_error_e net_nfc_get_tag_handle(net_nfc_target_info_h target_info,
- net_nfc_target_handle_h * handle);
+ net_nfc_target_handle_h *handle);
/**
this API returns the NDEF support boolean value.
*/
-net_nfc_error_e net_nfc_get_tag_ndef_support (net_nfc_target_info_h target_info,
- bool * is_support);
+net_nfc_error_e net_nfc_get_tag_ndef_support(net_nfc_target_info_h target_info,
+ bool *is_support);
/**
The max size getter from targte info handler. This max size indicates the maximum size of NDEF message that can be stored in this detected tag.
*/
-net_nfc_error_e net_nfc_get_tag_max_data_size (net_nfc_target_info_h target_info,
- uint32_t * max_size);
+net_nfc_error_e net_nfc_get_tag_max_data_size(net_nfc_target_info_h target_info,
+ uint32_t *max_size);
/**
this function return the actual NDEF message size that stored in the tag
*/
net_nfc_error_e net_nfc_get_tag_actual_data_size(
- net_nfc_target_info_h target_info, uint32_t * actual_data);
+ net_nfc_target_info_h target_info, uint32_t *actual_data);
/**
*/
net_nfc_error_e net_nfc_get_tag_info_keys(net_nfc_target_info_h target_info,
- char ***keys, int* number_of_keys);
+ char ***keys, int *number_of_keys);
/**
this function return value which is matched key
*/
net_nfc_error_e net_nfc_get_tag_info_value(net_nfc_target_info_h target_info,
- const char* key, data_h* value);
+ const char *key, data_h *value);
/**
Duplicate a handle of target information
if (cookie_len > 0) {
cookie = g_new0(uint8_t, cookie_len);
if (cookie != NULL) {
- if (security_server_request_cookie(
- (char *)cookie,
- cookie_len) < 0) {
+ if (security_server_request_cookie((char*)cookie, cookie_len) < 0) {
g_free(cookie);
cookie = NULL;
}
#include <string.h>
+#include "net_nfc_debug_internal.h"
#include "net_nfc_data.h"
#include "net_nfc_typedef_internal.h"
#include "net_nfc_util_internal.h"
-#include "net_nfc_debug_internal.h"
API net_nfc_error_e net_nfc_create_data_only(data_h* data)
{
return net_nfc_create_data(data, NULL, 0);
}
-API net_nfc_error_e net_nfc_create_data(data_h* data,
- const uint8_t* bytes, const uint32_t length)
+API net_nfc_error_e net_nfc_create_data(data_h *data,
+ const uint8_t *bytes, size_t length)
{
data_s *tmp_data = NULL;
if (data == NULL)
return NET_NFC_NULL_PARAMETER;
+ *data = NULL;
+
_net_nfc_util_alloc_mem(tmp_data, sizeof(data_s));
if (tmp_data == NULL)
return NET_NFC_ALLOC_FAIL;
return NET_NFC_OK;
}
-API net_nfc_error_e net_nfc_get_data(const data_h data, uint8_t** bytes, uint32_t * length)
+API net_nfc_error_e net_nfc_get_data(const data_h data,
+ uint8_t **bytes, size_t *length)
{
- if (data == NULL)
+ data_s *tmp_data = (data_s *)data;
+
+ if (bytes == NULL || length == NULL)
return NET_NFC_NULL_PARAMETER;
- data_s * tmp_data = (data_s *)data;
+ *bytes = NULL;
+ *length = 0;
+
+ if (data == NULL)
+ return NET_NFC_NULL_PARAMETER;
*bytes = tmp_data->buffer;
*length = tmp_data->length;
return NET_NFC_OK;
}
-API net_nfc_error_e net_nfc_set_data(const data_h data, const uint8_t* bytes, const uint32_t length)
+API net_nfc_error_e net_nfc_set_data(data_h data,
+ const uint8_t *bytes, size_t length)
{
+ data_s *tmp_data = (data_s *)data;
+
if (data == NULL)
return NET_NFC_NULL_PARAMETER;
- data_s * tmp_data = (data_s *)data;
-
if (tmp_data->buffer == bytes && tmp_data->length == length)
return NET_NFC_OK;
return NET_NFC_OK;
}
-API uint32_t net_nfc_get_data_length(const data_h data)
+API size_t net_nfc_get_data_length(const data_h data)
{
+ data_s *tmp_data = (data_s *)data;
+
if (data == NULL)
- {
return 0;
- }
- data_s * tmp_data = (data_s *)data;
return tmp_data->length;
}
-API uint8_t * net_nfc_get_data_buffer(const data_h data)
+API uint8_t* net_nfc_get_data_buffer(const data_h data)
{
+ data_s *tmp_data = (data_s *)data;
+
if (data == NULL)
- {
return NULL;
- }
- data_s * tmp_data = (data_s *)data;
return tmp_data->buffer;
}
API net_nfc_error_e net_nfc_free_data(data_h data)
{
+ data_s *tmp_data = (data_s *)data;
+
if (data == NULL)
- {
return NET_NFC_NULL_PARAMETER;
- }
- data_s * tmp_data = (data_s *)data;
if (tmp_data->buffer != NULL)
- {
_net_nfc_util_free_mem(tmp_data->buffer);
- }
+
_net_nfc_util_free_mem(tmp_data);
return NET_NFC_OK;
if (p2p_signal_handler.p2p_device_detached_cb)
{
p2p_signal_handler.p2p_device_detached_cb(
- p2p_signal_handler.p2p_device_detached_data);
+ p2p_signal_handler.p2p_device_detached_data);
}
/*llcp client function to close all socket needs to be implemented*/
res,
&error) == FALSE)
{
- out_result = NET_NFC_UNKNOWN_ERROR;
+ out_result = NET_NFC_IPC_FAIL;
DEBUG_ERR_MSG("Can not finish p2p send: %s", error->message);
g_error_free(error);
}
-API net_nfc_error_e net_nfc_client_p2p_send(net_nfc_target_handle_s *handle,
- data_s *data, net_nfc_client_p2p_send_completed callback, void *user_data)
+API net_nfc_error_e net_nfc_client_p2p_send(net_nfc_target_handle_h handle,
+ data_h data, net_nfc_client_p2p_send_completed callback, void *user_data)
{
GVariant *arg_data;
NetNfcCallback *func_data;
arg_data = net_nfc_util_gdbus_data_to_variant(data);
net_nfc_gdbus_p2p_call_send(p2p_proxy,
- 0 /* FIXME */,
- arg_data,
- GPOINTER_TO_UINT(handle),
- net_nfc_client_gdbus_get_privilege(),
- NULL,
- p2p_call_send,
- func_data);
+ 0 /* FIXME */,
+ arg_data,
+ GPOINTER_TO_UINT(handle),
+ net_nfc_client_gdbus_get_privilege(),
+ NULL,
+ p2p_call_send,
+ func_data);
return NET_NFC_OK;
}
-API net_nfc_error_e net_nfc_client_p2p_send_sync(net_nfc_target_handle_s *handle,
- data_s *data)
+API net_nfc_error_e net_nfc_client_p2p_send_sync(net_nfc_target_handle_h handle,
+ data_h data)
{
GVariant *arg_data;
GError *error = NULL;
arg_data = net_nfc_util_gdbus_data_to_variant(data);
if (net_nfc_gdbus_p2p_call_send_sync(p2p_proxy,
- 0 /* FIXME */,
- arg_data,
- GPOINTER_TO_UINT(handle),
- net_nfc_client_gdbus_get_privilege(),
- (gint *)&out_result,
- NULL,
- &error) == FALSE)
+ 0 /* FIXME */,
+ arg_data,
+ GPOINTER_TO_UINT(handle),
+ net_nfc_client_gdbus_get_privilege(),
+ (gint *)&out_result,
+ NULL,
+ &error) == FALSE)
{
DEBUG_ERR_MSG("p2p send (sync call) failed: %s",
error->message);
API void net_nfc_client_p2p_set_device_discovered(
net_nfc_client_p2p_device_discovered callback, void *user_data)
{
+ if (callback == NULL)
+ return;
+
p2p_signal_handler.p2p_device_discovered_cb = callback;
p2p_signal_handler.p2p_device_discovered_data = user_data;
}
API void net_nfc_client_p2p_set_device_detached(
net_nfc_client_p2p_device_detached callback, void *user_data)
{
+ if (callback == NULL)
+ return;
+
p2p_signal_handler.p2p_device_detached_cb = callback;
p2p_signal_handler.p2p_device_detached_data = user_data;
}
API void net_nfc_client_p2p_set_data_received(
net_nfc_client_p2p_data_received callback, void *user_data)
{
+ if (callback == NULL)
+ return;
+
p2p_signal_handler.p2p_data_received_cb = callback;
p2p_signal_handler.p2p_data_received_data = user_data;
}
#include "net_nfc_client_manager.h"
#include "net_nfc_client_system_handler.h"
-typedef struct _PopupFuncData PopupFuncData;
-struct _PopupFuncData
-{
- gpointer callback;
- gpointer user_data;
-};
static NetNfcGDbusPopup *popup_proxy = NULL;
static int popup_state = 0;
static void popup_set_active_callback(GObject *source_object, GAsyncResult *res,
gpointer user_data)
{
- PopupFuncData *func_data;
-
+ NetNfcCallback *func_data = (NetNfcCallback *)user_data;
net_nfc_error_e result = NET_NFC_OK;
GError *error = NULL;
- net_nfc_client_popup_set_state_callback callback;
- gpointer data;
+ g_assert(user_data != NULL);
if (net_nfc_gdbus_popup_call_set_finish(
NET_NFC_GDBUS_POPUP(source_object),
+ &result,
res,
&error) == FALSE)
{
-
- result = NET_NFC_UNKNOWN_ERROR;
-
DEBUG_ERR_MSG("Can not finish popup_set_active: %s",
error->message);
g_error_free(error);
- }
-
- func_data = user_data;
- if (func_data == NULL)
- return;
- if (func_data->callback == NULL)
- {
- g_free(func_data);
- return;
+ result = NET_NFC_IPC_FAIL;
}
- callback = (net_nfc_client_popup_set_state_callback)
- func_data->callback;
- data = func_data->user_data;
+ if (func_data->callback != NULL)
+ {
+ net_nfc_client_popup_set_state_callback callback =
+ (net_nfc_client_popup_set_state_callback)func_data->callback;
- callback(result, data);
+ callback(result, func_data->user_data);
+ }
g_free(func_data);
}
API net_nfc_error_e net_nfc_client_sys_handler_set_state(int state,
net_nfc_client_popup_set_state_callback callback, void *user_data)
{
- gboolean active = FALSE;
- PopupFuncData *func_data;
- net_nfc_launch_popup_check_e focus_state = CHECK_FOREGROUND;
+ NetNfcCallback *func_data;
- if (popup_proxy == NULL )
+ if (popup_proxy == NULL)
return NET_NFC_NOT_INITIALIZED;
/* prevent executing daemon when nfc is off */
return NET_NFC_INVALID_STATE;
}
- func_data = g_new0(PopupFuncData, 1);
+ func_data = g_try_new0(NetNfcCallback, 1);
if (func_data == NULL )
return NET_NFC_ALLOC_FAIL;
func_data->callback = (gpointer)callback;
func_data->user_data = user_data;
- if (state == true)
- active = TRUE;
-
net_nfc_gdbus_popup_call_set(popup_proxy,
- active,
- focus_state,
+ state,
+ CHECK_FOREGROUND,
net_nfc_client_gdbus_get_privilege(),
NULL,
popup_set_active_callback,
API net_nfc_error_e net_nfc_client_sys_handler_set_state_sync(int state)
{
+ net_nfc_error_e result = NET_NFC_OK;
GError *error = NULL;
- net_nfc_launch_popup_check_e focus_state = CHECK_FOREGROUND;
if (popup_proxy == NULL)
return NET_NFC_NOT_INITIALIZED;
}
if (net_nfc_gdbus_popup_call_set_sync(popup_proxy,
- (gboolean)state,
- focus_state,
+ state,
+ CHECK_FOREGROUND,
net_nfc_client_gdbus_get_privilege(),
+ &result,
NULL,
&error) == FALSE)
{
error->message);
g_error_free(error);
- return NET_NFC_IPC_FAIL;
+ result = NET_NFC_IPC_FAIL;
}
- return NET_NFC_OK;
+ return result;
}
API net_nfc_error_e net_nfc_client_sys_handler_set_state_force(int state,
- net_nfc_client_popup_set_state_callback callback,
- void *user_data)
+ net_nfc_client_popup_set_state_callback callback, void *user_data)
{
- gboolean active = FALSE;
- PopupFuncData *func_data;
- net_nfc_launch_popup_check_e focus_state = NO_CHECK_FOREGROUND;
+ NetNfcCallback *func_data;
if (popup_proxy == NULL)
return NET_NFC_NOT_INITIALIZED;
return NET_NFC_INVALID_STATE;
}
- func_data = g_new0(PopupFuncData, 1);
+ func_data = g_try_new0(NetNfcCallback, 1);
if (func_data == NULL)
return NET_NFC_ALLOC_FAIL;
func_data->callback = (gpointer)callback;
func_data->user_data = user_data;
- if (state == true)
- active = TRUE;
-
net_nfc_gdbus_popup_call_set(popup_proxy,
- active,
- focus_state,
+ state,
+ NO_CHECK_FOREGROUND,
net_nfc_client_gdbus_get_privilege(),
NULL,
popup_set_active_callback,
API net_nfc_error_e net_nfc_client_sys_handler_set_state_force_sync(int state)
{
+ net_nfc_error_e result;
GError *error = NULL;
- net_nfc_launch_popup_check_e focus_state = NO_CHECK_FOREGROUND;
if (popup_proxy == NULL)
return NET_NFC_NOT_INITIALIZED;
}
if (net_nfc_gdbus_popup_call_set_sync(popup_proxy,
- (gboolean)state,
- focus_state,
+ state,
+ NO_CHECK_FOREGROUND,
net_nfc_client_gdbus_get_privilege(),
+ &result,
NULL,
&error) == FALSE)
{
error->message);
g_error_free(error);
- return NET_NFC_IPC_FAIL;
+ result = NET_NFC_IPC_FAIL;
}
- return NET_NFC_OK;
+ return result;
}
API net_nfc_error_e net_nfc_client_sys_handler_set_launch_popup_state(
int enable)
{
- net_nfc_error_e ret;
-
popup_state = enable;
- if (enable)
- {
- ret = net_nfc_client_sys_handler_set_state_sync(
- NET_NFC_LAUNCH_APP_SELECT);
- }
- else
- {
- ret = net_nfc_client_sys_handler_set_state_sync(
- NET_NFC_NO_LAUNCH_APP_SELECT);
- }
-
- return ret;
+ return net_nfc_client_sys_handler_set_state_sync(enable);
}
API net_nfc_error_e net_nfc_client_sys_handler_set_launch_popup_state_force(
int enable)
{
- net_nfc_error_e ret;
-
popup_state = enable;
- if (enable)
- {
- ret = net_nfc_client_sys_handler_set_state_force_sync(
- NET_NFC_LAUNCH_APP_SELECT);
- }
- else
- {
- ret = net_nfc_client_sys_handler_set_state_force_sync(
- NET_NFC_NO_LAUNCH_APP_SELECT);
- }
-
- return ret;
+ return net_nfc_client_sys_handler_set_state_force_sync(enable);
}
API net_nfc_error_e net_nfc_client_sys_handler_get_launch_popup_state(
int *state)
{
+ net_nfc_error_e result = NET_NFC_OK;
+ gint out_state = NET_NFC_LAUNCH_APP_SELECT;
+ GError *error = NULL;
+
if (state == NULL)
return NET_NFC_NULL_PARAMETER;
-#if 1
- *state = popup_state;
-#else
- /* TODO : get state from server */
- GError *error = NULL;
+
+ *state = NET_NFC_LAUNCH_APP_SELECT;
if (popup_proxy == NULL) {
DEBUG_ERR_MSG("popup_proxy is null");
return NET_NFC_NOT_INITIALIZED;
}
+ /* prevent executing daemon when nfc is off */
+ if (net_nfc_client_manager_is_activated() == false) {
+ return NET_NFC_INVALID_STATE;
+ }
+
if (net_nfc_gdbus_popup_call_get_sync(popup_proxy,
net_nfc_client_gdbus_get_privilege(),
- state,
+ &result,
+ &out_state,
NULL,
- &error) == false) {
- DEBUG_CLIENT_MSG("net_nfc_gdbus_popup_call_get_sync failed: %s",
+ &error) == true) {
+ *state = out_state;
+ } else {
+
+ DEBUG_ERR_MSG("net_nfc_gdbus_popup_call_get_sync failed: %s",
error->message);
g_error_free(error);
- return NET_NFC_IPC_FAIL;
+ result = NET_NFC_IPC_FAIL;
}
-#endif
- return NET_NFC_OK;
+
+ return result;
}
net_nfc_error_e net_nfc_client_sys_handler_init(void)
#include "net_nfc_client_tag.h"
#include "net_nfc_client_tag_internal.h"
-typedef struct _TagFuncData TagFuncData;
-
-struct _TagFuncData
-{
- gpointer callback;
- gpointer user_data;
-};
static NetNfcGDbusTag *tag_proxy = NULL;
-static TagFuncData *tag_discovered_func_data = NULL;
-static TagFuncData *tag_detached_func_data = NULL;
+static NetNfcCallback tag_discovered_func_data;
+static NetNfcCallback tag_detached_func_data;
static net_nfc_target_info_s *client_target_info = NULL;
static net_nfc_event_filter_e client_filter = NET_NFC_ALL_ENABLE;
GVariant *raw_data,
net_nfc_target_info_s **info);
-
+#if 0
/* async callback */
static void tag_is_tag_connected(GObject *source_object,
GAsyncResult *res,
static void tag_get_current_target_handle(GObject *source_object,
GAsyncResult *res,
gpointer user_data);
-
+#endif
/* signal callback */
static void tag_tag_discovered(NetNfcGDbusTag *object,
guint arg_handle,
DEBUG_CLIENT_MSG("client filter = %d", client_filter);
- if (type >= NET_NFC_ISO14443_A_PICC &&
- type <= NET_NFC_MIFARE_DESFIRE_PICC)
+ if (type >= NET_NFC_ISO14443_A_PICC
+ && type <= NET_NFC_MIFARE_DESFIRE_PICC)
{
converted = NET_NFC_ISO14443A_ENABLE;
}
- else if (type >= NET_NFC_ISO14443_B_PICC &&
- type <= NET_NFC_ISO14443_BPRIME_PICC)
+ else if (type >= NET_NFC_ISO14443_B_PICC
+ && type <= NET_NFC_ISO14443_BPRIME_PICC)
{
converted = NET_NFC_ISO14443B_ENABLE;
}
tmp_list = g_new0(net_nfc_tag_info_s, number_of_keys);
current = tmp_list;
- while(i < number_of_keys)
+ while (i < number_of_keys)
{
gchar *str = NULL;
data_h value = NULL;
*info = info_data;
}
-
+#if 0
static void tag_is_tag_connected(GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- TagFuncData *func_data;
-
- net_nfc_error_e result = NET_NFC_OK;
+ NetNfcCallback *func_data = (NetNfcCallback *)user_data;
+ net_nfc_error_e out_result = NET_NFC_OK;
+ gboolean out_is_connected = false;
+ net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
GError *error = NULL;
- gboolean out_is_connected = FALSE;
- net_nfc_target_type_e out_dev_type;
-
- net_nfc_client_tag_is_tag_connected_completed callback;
+ g_assert(user_data != NULL);
if (net_nfc_gdbus_tag_call_is_tag_connected_finish(
NET_NFC_GDBUS_TAG(source_object),
res,
&error) == FALSE)
{
- result = NET_NFC_UNKNOWN_ERROR;
-
DEBUG_ERR_MSG("Can not finish is_tag_connected: %s",
error->message);
g_error_free(error);
+ out_result = NET_NFC_IPC_FAIL;
}
- func_data = user_data;
- if (func_data == NULL)
- return;
-
- if (func_data->callback == NULL)
+ if (func_data->callback != NULL)
{
- g_free(func_data);
- return;
- }
+ net_nfc_client_tag_is_tag_connected_completed callback =
+ (net_nfc_client_tag_is_tag_connected_completed)func_data->callback;
- if (out_is_connected == FALSE)
- result = NET_NFC_NOT_CONNECTED;
+ if (out_is_connected == FALSE)
+ out_result = NET_NFC_NOT_CONNECTED;
- callback = (net_nfc_client_tag_is_tag_connected_completed)
- func_data->callback;
- callback(result, out_dev_type, func_data->user_data);
+ callback(out_result, out_dev_type, func_data->user_data);
+ }
g_free(func_data);
}
GAsyncResult *res,
gpointer user_data)
{
- TagFuncData *func_data;
-
- net_nfc_error_e result = NET_NFC_OK;
+ NetNfcCallback *func_data = (NetNfcCallback *)user_data;
+ net_nfc_error_e out_result = NET_NFC_OK;
- net_nfc_target_type_e out_dev_type;
+ net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
gboolean out_is_connected = FALSE;
gboolean out_is_ndef_supported = FALSE;
- guchar out_ndef_card_state;
- guint out_handle;
- guint out_max_data_size;
- guint out_actual_data_size;
- guint out_number_of_keys;
+ guchar out_ndef_card_state = 0;
+ guint out_handle = 0;
+ guint out_max_data_size = 0;
+ guint out_actual_data_size = 0;
+ guint out_number_of_keys = 0;
GVariant *out_target_info_values = NULL;
GVariant *out_raw_data = NULL;
GError *error = NULL;
- net_nfc_client_tag_get_current_tag_info_completed callback;
-
- /*FIXME: currently SAVE_TARGET_INFO_IN_CC support only */
- net_nfc_target_info_s *info_s = NULL;
+ g_assert(user_data != NULL);
if (net_nfc_gdbus_tag_call_get_current_tag_info_finish (
NET_NFC_GDBUS_TAG(source_object),
res,
&error) == FALSE)
{
- result = NET_NFC_UNKNOWN_ERROR;
+ out_result = NET_NFC_IPC_FAIL;
DEBUG_ERR_MSG("Can not finish get_current_tag_info: %s",
error->message);
g_error_free(error);
}
- func_data = user_data;
- if(func_data == NULL)
- return;
+ if (out_result == NET_NFC_OK && out_is_connected == true) {
+ net_nfc_release_tag_info((net_nfc_target_info_h)client_target_info);
+ client_target_info = NULL;
- if (func_data->callback == NULL)
- {
- g_free(func_data);
- return;
+ if (tag_check_filter(out_dev_type) == true) {
+ tag_get_target_info(out_handle,
+ out_dev_type,
+ out_is_ndef_supported,
+ out_ndef_card_state,
+ out_max_data_size,
+ out_actual_data_size,
+ out_number_of_keys,
+ out_target_info_values,
+ out_raw_data,
+ &client_target_info);
+ } else {
+ INFO_MSG("The detected target is filtered out, type [%d]", out_dev_type);
+
+ out_is_connected = false;
+ }
}
- if (out_is_connected == FALSE)
- result = NET_NFC_NOT_CONNECTED;
-
- callback = (net_nfc_client_tag_get_current_tag_info_completed)
- func_data->callback;
-
- if (result != NET_NFC_OK)
+ if (func_data->callback != NULL)
{
- callback(result, NULL, func_data->user_data);
- g_free(func_data);
- return;
- }
+ net_nfc_client_tag_get_current_tag_info_completed callback =
+ (net_nfc_client_tag_get_current_tag_info_completed)func_data->callback;
- if (tag_check_filter(out_dev_type) == FALSE)
- DEBUG_CLIENT_MSG("The detected target is filtered out");
+ if (out_result == NET_NFC_OK && out_is_connected == false)
+ out_result = NET_NFC_NOT_CONNECTED;
- net_nfc_release_tag_info((net_nfc_target_info_h)client_target_info);
- client_target_info = NULL;
-
- tag_get_target_info(out_handle,
- out_dev_type,
- out_is_ndef_supported,
- out_ndef_card_state,
- out_max_data_size,
- out_actual_data_size,
- out_number_of_keys,
- out_target_info_values,
- out_raw_data,
- &info_s);
-
- client_target_info = info_s;
-
- callback(result, info_s, func_data->user_data);
+ callback(out_result, client_target_info, func_data->user_data);
+ }
g_free(func_data);
}
GAsyncResult *res,
gpointer user_data)
{
- TagFuncData *func_data;
-
- net_nfc_target_handle_h handle = NULL;
- net_nfc_target_type_e out_dev_type;
-
- gboolean out_is_connected = FALSE;
- guint out_handle = 0;
-
- net_nfc_error_e result = NET_NFC_OK;
+ NetNfcCallback *func_data = (NetNfcCallback *)user_data;
+ net_nfc_error_e out_result = NET_NFC_OK;
+ net_nfc_target_handle_h out_handle = NULL;
+ net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
+ gboolean out_is_connected = false;
GError *error = NULL;
- net_nfc_client_tag_get_current_target_handle_completed callback;
+ g_assert(user_data != NULL);
if (net_nfc_gdbus_tag_call_get_current_target_handle_finish(
NET_NFC_GDBUS_TAG(source_object),
&out_is_connected,
- &out_handle,
+ (guint *)&out_handle,
(gint *)&out_dev_type,
res,
&error) == FALSE)
{
- result = NET_NFC_UNKNOWN_ERROR;
-
DEBUG_ERR_MSG("Can not finish get_current_target_handle: %s",
error->message);
g_error_free(error);
- }
-
- func_data = user_data;
- if (func_data == NULL)
- return;
- if (func_data->callback == NULL)
- {
- g_free(func_data);
- return;
+ out_result = NET_NFC_IPC_FAIL;
}
- callback = (net_nfc_client_tag_get_current_target_handle_completed)
- func_data->callback;
-
- if (out_is_connected == FALSE)
- result = NET_NFC_NOT_CONNECTED;
+ if (func_data->callback != NULL)
+ {
+ net_nfc_client_tag_get_current_target_handle_completed callback =
+ (net_nfc_client_tag_get_current_target_handle_completed)func_data->callback;
- if (out_handle)
- handle = GUINT_TO_POINTER(out_handle);
+ if (out_result == NET_NFC_OK && out_is_connected == FALSE)
+ out_result = NET_NFC_NOT_CONNECTED;
- callback(result, handle, func_data->user_data);
+ callback(out_result,
+ GUINT_TO_POINTER(out_handle),
+ func_data->user_data);
+ }
g_free(func_data);
}
-
+#endif
static void tag_tag_discovered(NetNfcGDbusTag *object,
guint arg_handle,
gint arg_dev_type,
GVariant *arg_raw_data,
gpointer user_data)
{
- /*FIXME: currently SAVE_TARGET_INFO_IN_CC support only */
- net_nfc_target_info_s *info_s = NULL;
-
- net_nfc_client_tag_tag_discovered callback;
-
INFO_MSG(">>> SIGNAL arrived");
- if (tag_discovered_func_data == NULL)
- return;
-
- if (tag_discovered_func_data->callback == NULL)
- return;
-
- if (tag_check_filter(arg_dev_type) == FALSE)
- DEBUG_CLIENT_MSG("The detected target is filtered out");
-
net_nfc_release_tag_info((net_nfc_target_info_h)client_target_info);
client_target_info = NULL;
+ if (tag_check_filter(arg_dev_type) == FALSE) {
+ INFO_MSG("The detected target is filtered out, type [%d]", arg_dev_type);
+
+ return;
+ }
+
tag_get_target_info(arg_handle,
arg_dev_type,
arg_is_ndef_supported,
arg_number_of_keys,
arg_target_info_values,
arg_raw_data,
- &info_s);
+ &client_target_info);
- client_target_info = info_s;
+ if (tag_discovered_func_data.callback != NULL) {
+ net_nfc_client_tag_tag_discovered callback =
+ (net_nfc_client_tag_tag_discovered)tag_discovered_func_data.callback;
- callback = (net_nfc_client_tag_tag_discovered)
- tag_discovered_func_data->callback;
-
- callback(info_s, tag_discovered_func_data->user_data);
+ callback(client_target_info,
+ tag_discovered_func_data.user_data);
+ }
}
static void tag_tag_detached(NetNfcGDbusTag *object,
gint arg_dev_type,
gpointer user_data)
{
- net_nfc_client_tag_tag_detached callback;
-
INFO_MSG(">>> SIGNAL arrived");
- if (tag_detached_func_data == NULL)
- return;
-
- if (tag_detached_func_data->callback == NULL)
- return;
+ if (tag_check_filter(arg_dev_type) == TRUE) {
+ if (tag_detached_func_data.callback != NULL) {
+ net_nfc_client_tag_tag_detached callback =
+ (net_nfc_client_tag_tag_detached)tag_detached_func_data.callback;
- if (tag_check_filter(arg_dev_type) == FALSE)
- DEBUG_CLIENT_MSG("The detected target is filtered out");
+ callback(tag_detached_func_data.user_data);
+ }
+ } else {
+ INFO_MSG("The detected target is filtered out, type [%d]", arg_dev_type);
+ }
- /*FIXME: currently SAVE_TARGET_INFO_IN_CC support only */
net_nfc_release_tag_info((net_nfc_target_info_h)client_target_info);
client_target_info = NULL;
-
- callback = (net_nfc_client_tag_tag_detached)
- tag_detached_func_data->callback;
-
- callback(tag_detached_func_data->user_data);
}
/* internal funcion */
return client_target_info;
}
+#if 0
API net_nfc_error_e net_nfc_client_tag_is_tag_connected(
net_nfc_client_tag_is_tag_connected_completed callback,
void *user_data)
{
- TagFuncData *func_data;
+ NetNfcCallback *func_data;
if (tag_proxy == NULL)
- return NET_NFC_UNKNOWN_ERROR;
+ return NET_NFC_NOT_INITIALIZED;
/* prevent executing daemon when nfc is off */
if (net_nfc_client_manager_is_activated() == false) {
return NET_NFC_INVALID_STATE;
}
- func_data = g_new0(TagFuncData, 1);
+ func_data = g_try_new0(NetNfcCallback, 1);
if (func_data == NULL)
- return NET_NFC_UNKNOWN_ERROR;
+ return NET_NFC_ALLOC_FAIL;
func_data->callback = (gpointer)callback;
func_data->user_data = user_data;
return NET_NFC_OK;
}
+#endif
API net_nfc_error_e net_nfc_client_tag_is_tag_connected_sync(
net_nfc_target_type_e *dev_type)
{
- net_nfc_target_type_e out_dev_type;
-
- gboolean out_is_connected = FALSE;
-
+ net_nfc_target_info_s *info;
+ net_nfc_error_e out_result = NET_NFC_OK;
+ net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
+ gboolean out_is_connected = false;
GError *error = NULL;
+ if (tag_proxy == NULL)
+ return NET_NFC_NOT_INITIALIZED;
+
/* prevent executing daemon when nfc is off */
if (net_nfc_client_manager_is_activated() == false) {
return NET_NFC_INVALID_STATE;
}
- if (net_nfc_gdbus_tag_call_is_tag_connected_sync(tag_proxy,
- net_nfc_client_gdbus_get_privilege(),
- &out_is_connected,
- (gint *)&out_dev_type,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can not get is_tag_connected result: %s",
- error->message);
- g_error_free(error);
- return NET_NFC_UNKNOWN_ERROR;
- }
+ info = net_nfc_client_tag_get_client_target_info();
+ if (info == NULL) {
+ /* try to request target information from server */
+ if (net_nfc_gdbus_tag_call_is_tag_connected_sync(tag_proxy,
+ net_nfc_client_gdbus_get_privilege(),
+ &out_is_connected,
+ (gint *)&out_dev_type,
+ NULL,
+ &error) == FALSE)
+ {
+ DEBUG_ERR_MSG("Can not get is_tag_connected result: %s",
+ error->message);
+ g_error_free(error);
- if (dev_type)
- *dev_type = out_dev_type;
+ out_result = NET_NFC_IPC_FAIL;
+ }
- if (out_is_connected == FALSE)
- return NET_NFC_NOT_CONNECTED;
+ if (out_is_connected == true) {
+ if (dev_type)
+ *dev_type = out_dev_type;
- return NET_NFC_OK;
+ out_result = NET_NFC_OK;
+ } else {
+ out_result = NET_NFC_NOT_CONNECTED;
+ }
+ } else {
+ /* target was connected */
+ if (dev_type != NULL) {
+ *dev_type = info->devType;
+ }
+
+ out_result = NET_NFC_OK;
+ }
+
+ return out_result;
}
+#if 0
API net_nfc_error_e net_nfc_client_tag_get_current_tag_info(
net_nfc_client_tag_get_current_tag_info_completed callback,
void *user_data)
{
- TagFuncData *func_data;
+ NetNfcCallback *func_data;
if (tag_proxy == NULL)
- return NET_NFC_UNKNOWN_ERROR;
+ return NET_NFC_NOT_INITIALIZED;
/* prevent executing daemon when nfc is off */
if (net_nfc_client_manager_is_activated() == false) {
return NET_NFC_INVALID_STATE;
}
- func_data = g_new0(TagFuncData, 1);
+ func_data = g_try_new0(NetNfcCallback, 1);
+ if (func_data == NULL) {
+ return NET_NFC_ALLOC_FAIL;
+ }
+
func_data->callback = (gpointer)callback;
func_data->user_data = user_data;
-
net_nfc_gdbus_tag_call_get_current_tag_info(tag_proxy,
net_nfc_client_gdbus_get_privilege(),
NULL,
return NET_NFC_OK;
}
+#endif
API net_nfc_error_e net_nfc_client_tag_get_current_tag_info_sync(
net_nfc_target_info_h *info)
{
- net_nfc_target_type_e out_dev_type;
- gboolean out_is_connected = FALSE;
- gboolean out_is_ndef_supported;
- guchar out_ndef_card_state;
- guint out_handle;
- guint out_max_data_size;
- guint out_actual_data_size;
- guint out_number_of_keys;
- GVariant *out_target_info_values;
- GVariant *out_raw_data;
-
- net_nfc_target_info_s *info_s = NULL;
-
+ net_nfc_error_e out_result = NET_NFC_OK;
+ net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
+ gboolean out_is_connected = false;
+ gboolean out_is_ndef_supported = false;
+ guchar out_ndef_card_state = 0;
+ guint out_handle = 0;
+ guint out_max_data_size = 0;
+ guint out_actual_data_size = 0;
+ guint out_number_of_keys = 0;
+ GVariant *out_target_info_values = NULL;
+ GVariant *out_raw_data = NULL;
GError *error = NULL;
if (tag_proxy == NULL)
- return NET_NFC_UNKNOWN_ERROR;
+ return NET_NFC_NOT_INITIALIZED;
/* prevent executing daemon when nfc is off */
if (net_nfc_client_manager_is_activated() == false) {
return NET_NFC_INVALID_STATE;
}
- if (net_nfc_gdbus_tag_call_get_current_tag_info_sync(tag_proxy,
- net_nfc_client_gdbus_get_privilege(),
- &out_is_connected,
- &out_handle,
- (gint *)&out_dev_type,
- &out_is_ndef_supported,
- &out_ndef_card_state,
- &out_max_data_size,
- &out_actual_data_size,
- &out_number_of_keys,
- &out_target_info_values,
- &out_raw_data,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can no get current_tag_info result: %s",
- error->message);
-
- g_error_free(error);
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- if (out_is_connected == FALSE)
- return NET_NFC_NOT_CONNECTED;
-
- /* TODO : do something */
- if (info == NULL)
- return NET_NFC_OK;
+ if (net_nfc_client_tag_get_client_target_info() == NULL) {
+ /* try to request target information from server */
+ if (net_nfc_gdbus_tag_call_get_current_tag_info_sync(tag_proxy,
+ net_nfc_client_gdbus_get_privilege(),
+ &out_is_connected,
+ &out_handle,
+ (gint *)&out_dev_type,
+ &out_is_ndef_supported,
+ &out_ndef_card_state,
+ &out_max_data_size,
+ &out_actual_data_size,
+ &out_number_of_keys,
+ &out_target_info_values,
+ &out_raw_data,
+ NULL,
+ &error) == FALSE)
+ {
+ DEBUG_ERR_MSG("Can no get current_tag_info result: %s",
+ error->message);
+ g_error_free(error);
- if(tag_check_filter(out_dev_type) == FALSE)
- DEBUG_CLIENT_MSG("The detected target is filtered out");
+ out_result = NET_NFC_IPC_FAIL;
+ }
- tag_get_target_info(out_handle,
- out_dev_type,
- out_is_ndef_supported,
- out_ndef_card_state,
- out_max_data_size,
- out_actual_data_size,
- out_number_of_keys,
- out_target_info_values,
- out_raw_data,
- &info_s);
+ if (out_is_connected == true) {
+ if (tag_check_filter(out_dev_type) == true) {
+ tag_get_target_info(out_handle,
+ out_dev_type,
+ out_is_ndef_supported,
+ out_ndef_card_state,
+ out_max_data_size,
+ out_actual_data_size,
+ out_number_of_keys,
+ out_target_info_values,
+ out_raw_data,
+ &client_target_info);
+
+ out_result = NET_NFC_OK;
+ } else {
+ INFO_MSG("The detected target is filtered out");
+
+ out_result = NET_NFC_NOT_CONNECTED;
+ }
+ } else {
+ out_result = NET_NFC_NOT_CONNECTED;
+ }
+ } else {
+ out_result = NET_NFC_OK;
+ }
- *info = info_s;
+ if (out_result == NET_NFC_OK && info != NULL) {
+ *info = client_target_info;
+ }
- return NET_NFC_OK;
+ return out_result;
}
+#if 0
API net_nfc_error_e net_nfc_client_tag_get_current_target_handle(
net_nfc_client_tag_get_current_target_handle_completed callback,
void *user_data)
{
- TagFuncData *func_data;
+ NetNfcCallback *func_data;
if (tag_proxy == NULL)
- return NET_NFC_UNKNOWN_ERROR;
+ return NET_NFC_NOT_INITIALIZED;
/* prevent executing daemon when nfc is off */
if (net_nfc_client_manager_is_activated() == false) {
return NET_NFC_INVALID_STATE;
}
- func_data = g_new0(TagFuncData, 1);
+ func_data = g_try_new0(NetNfcCallback, 1);
+ if (func_data == NULL) {
+ return NET_NFC_ALLOC_FAIL;
+ }
+
func_data->callback = (gpointer)callback;
func_data->user_data = user_data;
return NET_NFC_OK;
}
+#endif
API net_nfc_error_e net_nfc_client_tag_get_current_target_handle_sync(
net_nfc_target_handle_h *handle)
{
- net_nfc_target_type_e out_dev_type;
- gboolean out_is_connected = FALSE;
- guint out_handle;
+ net_nfc_target_info_s *info;
+ net_nfc_error_e result;
+ net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
+ gboolean out_is_connected = false;
+ guint out_handle = 0;
GError *error = NULL;
if (tag_proxy == NULL)
- return NET_NFC_UNKNOWN_ERROR;
+ return NET_NFC_NOT_INITIALIZED;
/* prevent executing daemon when nfc is off */
if (net_nfc_client_manager_is_activated() == false) {
return NET_NFC_INVALID_STATE;
}
- if (net_nfc_gdbus_tag_call_get_current_target_handle_sync(tag_proxy,
- net_nfc_client_gdbus_get_privilege(),
- &out_is_connected,
- &out_handle,
- (gint *)&out_dev_type,
- NULL,
- &error) == FALSE)
- {
- DEBUG_ERR_MSG("Can no get current_target_handle result: %s",
- error->message);
+ info = net_nfc_client_tag_get_client_target_info();
+ if (info == NULL) {
+ if (net_nfc_gdbus_tag_call_get_current_target_handle_sync(
+ tag_proxy,
+ net_nfc_client_gdbus_get_privilege(),
+ &out_is_connected,
+ &out_handle,
+ (gint *)&out_dev_type,
+ NULL,
+ &error) == FALSE)
+ {
+ DEBUG_ERR_MSG("Can no get current_target_handle result: %s",
+ error->message);
+ g_error_free(error);
- g_error_free(error);
- return NET_NFC_UNKNOWN_ERROR;
- }
+ result = NET_NFC_IPC_FAIL;
+ }
- if (out_is_connected == FALSE)
- return NET_NFC_NOT_CONNECTED;
+ if (out_is_connected == true) {
+ if (handle)
+ *handle = GUINT_TO_POINTER(out_handle);
- if (handle)
- *handle = GUINT_TO_POINTER(out_handle);
+ result = NET_NFC_OK;
+ } else {
+ result = NET_NFC_NOT_CONNECTED;
+ }
+ } else if (info->devType == NET_NFC_NFCIP1_INITIATOR ||
+ info->devType == NET_NFC_NFCIP1_TARGET) {
+ if (handle)
+ *handle = info->handle;
- return NET_NFC_OK;
+ result = NET_NFC_OK;
+ } else {
+ result = NET_NFC_NOT_CONNECTED;
+ }
+
+ return result;
}
API void net_nfc_client_tag_set_tag_discovered(
- net_nfc_client_tag_tag_discovered callback,
- void *user_data)
+ net_nfc_client_tag_tag_discovered callback, void *user_data)
{
- if (tag_discovered_func_data == NULL)
- tag_discovered_func_data = g_new0(TagFuncData, 1);
+ if (callback == NULL)
+ return;
- tag_discovered_func_data->callback = (gpointer) callback;
- tag_discovered_func_data->user_data = user_data;
+ tag_discovered_func_data.callback = (gpointer)callback;
+ tag_discovered_func_data.user_data = user_data;
}
API void net_nfc_client_tag_unset_tag_discovered(void)
{
- if (tag_discovered_func_data)
- {
- g_free(tag_discovered_func_data);
- tag_discovered_func_data = NULL;
- }
-
+ tag_discovered_func_data.callback = NULL;
+ tag_discovered_func_data.user_data = NULL;
}
API void net_nfc_client_tag_set_tag_detached(
- net_nfc_client_tag_tag_detached callback,
- void *user_data)
+ net_nfc_client_tag_tag_detached callback, void *user_data)
{
- if (tag_detached_func_data == NULL)
- tag_detached_func_data = g_new0(TagFuncData, 1);
+ if (callback == NULL)
+ return;
- tag_detached_func_data->callback = (gpointer) callback;
- tag_detached_func_data->user_data = user_data;
+ tag_detached_func_data.callback = (gpointer)callback;
+ tag_detached_func_data.user_data = user_data;
}
API void net_nfc_client_tag_unset_tag_detached(void)
{
- if (tag_detached_func_data)
- {
- g_free(tag_detached_func_data);
- tag_detached_func_data = NULL;
- }
+ tag_detached_func_data.callback = NULL;
+ tag_detached_func_data.user_data = NULL;
}
API void net_nfc_client_tag_set_filter(net_nfc_event_filter_e filter)
void net_nfc_client_tag_deinit(void)
{
+ client_filter = NET_NFC_ALL_ENABLE;
+
+ net_nfc_release_tag_info((net_nfc_target_info_h)client_target_info);
+ client_target_info = NULL;
+
+ net_nfc_client_tag_unset_tag_discovered();
+ net_nfc_client_tag_unset_tag_detached();
+
if (tag_proxy)
{
g_object_unref(tag_proxy);
tag_proxy = NULL;
}
-
- if (tag_discovered_func_data)
- {
- g_free(tag_discovered_func_data);
- tag_discovered_func_data = NULL;
- }
-
- if (tag_detached_func_data)
- {
- g_free(tag_detached_func_data);
- tag_detached_func_data = NULL;
- }
-
- net_nfc_release_tag_info((net_nfc_target_info_h)client_target_info);
- client_target_info = NULL;
-
- client_filter = NET_NFC_ALL_ENABLE;
}
#include "net_nfc_util_internal.h"
API net_nfc_error_e net_nfc_get_tag_type(net_nfc_target_info_h target_info,
- net_nfc_target_type_e * type)
+ net_nfc_target_type_e *type)
{
- if (target_info == NULL || type == NULL)
+ net_nfc_target_info_s *target_info_private =
+ (net_nfc_target_info_s *)target_info;
+
+ if (type == NULL)
return NET_NFC_NULL_PARAMETER;
- net_nfc_target_info_s * tmp_target_info = (net_nfc_target_info_s*)target_info;
+ *type = NET_NFC_UNKNOWN_TARGET;
+
+ if (target_info == NULL)
+ return NET_NFC_INVALID_HANDLE;
+
+ *type = target_info_private->devType;
- *type = tmp_target_info->devType;
return NET_NFC_OK;
}
API net_nfc_error_e net_nfc_get_tag_handle(net_nfc_target_info_h target_info,
- net_nfc_target_handle_h * handle)
+ net_nfc_target_handle_h *handle)
{
- if (target_info == NULL || handle == NULL)
+ net_nfc_target_info_s *target_info_private =
+ (net_nfc_target_info_s *)target_info;
+
+ if (handle == NULL)
return NET_NFC_NULL_PARAMETER;
- net_nfc_target_info_s * tmp_target_info = (net_nfc_target_info_s*)target_info;
+ *handle = NULL;
+
+ if (target_info == NULL)
+ return NET_NFC_INVALID_HANDLE;
+
+ *handle = (net_nfc_target_handle_h)target_info_private->handle;
- *handle = (net_nfc_target_handle_h)tmp_target_info->handle;
return NET_NFC_OK;
}
API net_nfc_error_e net_nfc_get_tag_ndef_support(
- net_nfc_target_info_h target_info, bool * is_support)
+ net_nfc_target_info_h target_info, bool *is_support)
{
+ net_nfc_target_info_s *target_info_private =
+ (net_nfc_target_info_s *)target_info;
+
if (target_info == NULL || is_support == NULL)
return NET_NFC_NULL_PARAMETER;
- net_nfc_target_info_s * tmp_target_info = (net_nfc_target_info_s*)target_info;
+ *is_support = (bool)target_info_private->is_ndef_supported;
- *is_support = (bool)tmp_target_info->is_ndef_supported;
return NET_NFC_OK;
}
API net_nfc_error_e net_nfc_get_tag_max_data_size(
net_nfc_target_info_h target_info, uint32_t * max_size)
{
+ net_nfc_target_info_s *target_info_private =
+ (net_nfc_target_info_s *)target_info;
+
if (target_info == NULL || max_size == NULL)
return NET_NFC_NULL_PARAMETER;
- net_nfc_target_info_s * tmp_target_info = (net_nfc_target_info_s*)target_info;
+ *max_size = target_info_private->maxDataSize;
- *max_size = tmp_target_info->maxDataSize;
return NET_NFC_OK;
}
API net_nfc_error_e net_nfc_get_tag_actual_data_size(
net_nfc_target_info_h target_info, uint32_t * actual_data)
{
+ net_nfc_target_info_s *target_info_private =
+ (net_nfc_target_info_s *)target_info;
+
if (target_info == NULL || actual_data == NULL)
return NET_NFC_NULL_PARAMETER;
- net_nfc_target_info_s * tmp_target_info = (net_nfc_target_info_s*)target_info;
+ *actual_data = target_info_private->actualDataSize;
- *actual_data = tmp_target_info->actualDataSize;
return NET_NFC_OK;
}
API net_nfc_error_e net_nfc_get_tag_info_keys(net_nfc_target_info_h target_info,
char ***keys, int *number_of_keys)
{
+ net_nfc_target_info_s *handle = (net_nfc_target_info_s *)target_info;
+ int i = 0;
+
if (keys == NULL || number_of_keys == NULL || target_info == NULL)
return NET_NFC_NULL_PARAMETER;
- net_nfc_target_info_s* handle = (net_nfc_target_info_s*)target_info;
-
if (handle->tag_info_list == NULL)
return NET_NFC_NO_DATA_FOUND;
if (handle->number_of_keys <= 0)
return NET_NFC_NO_DATA_FOUND;
- int i = 0;
-
if (handle->keylist != NULL)
{
*keys = handle->keylist;
if (*keys == NULL)
return NET_NFC_ALLOC_FAIL;
- net_nfc_tag_info_s* tag_info = handle->tag_info_list;
+ net_nfc_tag_info_s *tag_info = handle->tag_info_list;
for (; i < handle->number_of_keys; i++, tag_info++)
{
}
API net_nfc_error_e net_nfc_get_tag_info_value(net_nfc_target_info_h target_info,
- const char* key, data_h* value)
+ const char *key, data_h *value)
{
+ net_nfc_target_info_s *handle = (net_nfc_target_info_s *)target_info;
+ net_nfc_tag_info_s *tag_info;
+
if (target_info == NULL || key == NULL || value == NULL)
return NET_NFC_NULL_PARAMETER;
- net_nfc_target_info_s* handle = (net_nfc_target_info_s*)target_info;
-
if (handle->tag_info_list == NULL)
return NET_NFC_NO_DATA_FOUND;
int i = 0;
- net_nfc_tag_info_s* tag_info = handle->tag_info_list;
+ tag_info = handle->tag_info_list;
for (; i < handle->number_of_keys; i++, tag_info++)
{
}
if (i == handle->number_of_keys)
- return NET_NFC_NOT_SUPPORTED;
+ return NET_NFC_NO_DATA_FOUND;
return NET_NFC_OK;
}
return NET_NFC_OK;
}
-static net_nfc_error_e net_nfc_util_release_tag_info(net_nfc_target_info_s *info)
+static net_nfc_error_e _release_tag_info(net_nfc_target_info_s *info)
{
- net_nfc_error_e result = NET_NFC_OK;
net_nfc_tag_info_s *list = NULL;
if (info == NULL)
list = info->tag_info_list;
if (list != NULL)
{
- int i = 0;
+ int i;
+
for (i = 0; i < info->number_of_keys; i++, list++)
{
if (list->key != NULL)
net_nfc_util_free_data(&info->raw_data);
- return result;
+ return NET_NFC_OK;
}
API net_nfc_error_e net_nfc_release_tag_info(net_nfc_target_info_h target_info)
{
net_nfc_target_info_s *info = (net_nfc_target_info_s *)target_info;
+ net_nfc_error_e result;
if (info == NULL)
return NET_NFC_NULL_PARAMETER;
- net_nfc_util_release_tag_info(info);
+ result = _release_tag_info(info);
_net_nfc_util_free_mem(info);
- return NET_NFC_OK;
+ return result;
}
GAsyncResult *res,
gpointer user_data);
-typedef struct _TransceiveFuncData TransceiveFuncData;
-
-struct _TransceiveFuncData
-{
- gpointer transceive_send_callback;
- gpointer transceive_send_data;
-};
-
static GVariant *transceive_data_to_transceive_variant(
net_nfc_target_type_e devType,
data_s *data)
{
- GVariant *variant = NULL;
- data_s transceive_info = {NULL,};
+ data_s transceive_info = { NULL, };
+ GVariant *variant;
if (data == NULL)
{
case NET_NFC_MIFARE_1K_PICC :
case NET_NFC_MIFARE_4K_PICC :
case NET_NFC_MIFARE_ULTRA_PICC :
- if(net_nfc_util_alloc_data(&transceive_info,
+ if (net_nfc_util_alloc_data(&transceive_info,
data->length + 2) == true)
{
memcpy(transceive_info.buffer,
return NULL;
}
- if(net_nfc_util_alloc_data(&transceive_info, 9) == true)
+ if (net_nfc_util_alloc_data(&transceive_info, 9) == true)
{
memcpy(transceive_info.buffer,
data->buffer,
transceive_info.buffer,
transceive_info.length);
}
-
break;
default :
}
static void transceive_data_call(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
+ GAsyncResult *res, gpointer user_data)
{
- TransceiveFuncData *func_data;
-
+ NetNfcCallback *func_data = (NetNfcCallback *)user_data;
net_nfc_error_e out_result = NET_NFC_OK;
- GError *error = NULL;
-
GVariant *out_data = NULL;
+ GError *error = NULL;
- data_s resp = {NULL,};
+ g_assert(user_data != NULL);
- if(net_nfc_gdbus_transceive_call_transceive_data_finish(
+ if (net_nfc_gdbus_transceive_call_transceive_data_finish(
NET_NFC_GDBUS_TRANSCEIVE(source_object),
(gint *)&out_result,
&out_data,
res,
&error) == FALSE)
{
- out_result = NET_NFC_UNKNOWN_ERROR;
-
DEBUG_ERR_MSG("Can not finish transceive: %s", error->message);
g_error_free(error);
- }
- func_data = (TransceiveFuncData*) user_data;
- if(func_data == NULL)
- {
- DEBUG_ERR_MSG("can not get TransceiveFuncData");
- return;
+ out_result = NET_NFC_IPC_FAIL;
}
- if(func_data->transceive_send_callback == NULL)
+ if (func_data->callback != NULL)
{
- DEBUG_CLIENT_MSG("callback function is not avaiilable");
- g_free(func_data);
- return;
- }
+ data_s resp = { NULL, };
- net_nfc_util_gdbus_variant_to_data_s(out_data, &resp);
+ net_nfc_util_gdbus_variant_to_data_s(out_data, &resp);
- ((nfc_transceive_data_callback)func_data->transceive_send_callback)(
- out_result,
- &resp,
- func_data->transceive_send_data);
+ ((nfc_transceive_data_callback)func_data->callback)(
+ out_result,
+ &resp,
+ func_data->user_data);
- net_nfc_util_free_data(&resp);
+ net_nfc_util_free_data(&resp);
+ }
g_free(func_data);
}
static void transceive_call(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
+ GAsyncResult *res, gpointer user_data)
{
- TransceiveFuncData *func_data;
-
+ NetNfcCallback *func_data = (NetNfcCallback *)user_data;
net_nfc_error_e out_result = NET_NFC_OK;
GError *error = NULL;
- if(net_nfc_gdbus_transceive_call_transceive_finish(
+ g_assert(user_data != NULL);
+
+ if (net_nfc_gdbus_transceive_call_transceive_finish(
NET_NFC_GDBUS_TRANSCEIVE(source_object),
(gint *)&out_result,
res,
&error) == FALSE)
{
- out_result = NET_NFC_UNKNOWN_ERROR;
-
DEBUG_ERR_MSG("Can not finish transceive: %s", error->message);
g_error_free(error);
- }
- func_data = (TransceiveFuncData*) user_data;
- if(func_data == NULL)
- {
- DEBUG_ERR_MSG("can not get TransceiveFuncData");
- return;
+ out_result = NET_NFC_IPC_FAIL;
}
- if(func_data->transceive_send_callback == NULL)
+ if (func_data->callback != NULL)
{
- DEBUG_CLIENT_MSG("callback function is not avaiilable");
- g_free(func_data);
- return;
+ ((nfc_transceive_callback)func_data->callback)(
+ out_result,
+ func_data->user_data);
}
- ((nfc_transceive_callback)func_data->transceive_send_callback)(
- out_result,
- func_data->transceive_send_data);
-
g_free(func_data);
}
API net_nfc_error_e net_nfc_client_transceive(net_nfc_target_handle_h handle,
data_h rawdata, nfc_transceive_callback callback, void *user_data)
{
- net_nfc_target_info_s *target_info = NULL;
- data_s *data = (data_s *)rawdata;
-
- GVariant *arg_data = NULL;
- TransceiveFuncData *funcdata = NULL;
+ net_nfc_target_info_s *target_info;
+ NetNfcCallback *funcdata;
+ GVariant *arg_data;
if (transceive_proxy == NULL)
{
DEBUG_ERR_MSG("Can not get TransceiveProxy");
- return NET_NFC_UNKNOWN_ERROR;
+
+ return NET_NFC_NOT_INITIALIZED;
}
- DEBUG_CLIENT_MSG("send reqeust :: transceive = [%p]", handle);
if (handle == NULL || rawdata == NULL)
return NET_NFC_NULL_PARAMETER;
return NET_NFC_INVALID_STATE;
}
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- /* fill trans information struct */
target_info = net_nfc_client_tag_get_client_target_info();
+ if (target_info == NULL || target_info->handle == NULL)
+ return NET_NFC_NOT_CONNECTED;
- if (target_info == NULL)
- return NET_NFC_OPERATION_FAIL;
+ DEBUG_CLIENT_MSG("send request :: transceive = [%p]", handle);
- arg_data = transceive_data_to_transceive_variant(target_info->devType, data);
- if (arg_data == NULL)
- return NET_NFC_OPERATION_FAIL;
+ arg_data = transceive_data_to_transceive_variant(target_info->devType,
+ rawdata);
+ if (arg_data == NULL) {
+ return NET_NFC_INVALID_PARAM;
+ }
+
+ funcdata = g_try_new0(NetNfcCallback, 1);
+ if (funcdata == NULL) {
+ g_variant_unref(arg_data);
- funcdata = g_new0(TransceiveFuncData, 1);
+ return NET_NFC_ALLOC_FAIL;
+ }
- funcdata->transceive_send_callback = (gpointer)callback;
- funcdata->transceive_send_data = user_data;
+ funcdata->callback = (gpointer)callback;
+ funcdata->user_data = user_data;
net_nfc_gdbus_transceive_call_transceive(transceive_proxy,
GPOINTER_TO_UINT(handle),
API net_nfc_error_e net_nfc_client_transceive_data(net_nfc_target_handle_h handle,
data_h rawdata, nfc_transceive_data_callback callback, void *user_data)
{
- net_nfc_target_info_s *target_info = NULL;
- data_s *data = (data_s *)rawdata;
-
- GVariant *arg_data = NULL;
- TransceiveFuncData *funcdata = NULL;
+ net_nfc_target_info_s *target_info;
+ NetNfcCallback *funcdata;
+ GVariant *arg_data;
if (transceive_proxy == NULL)
{
DEBUG_ERR_MSG("Can not get TransceiveProxy");
- return NET_NFC_UNKNOWN_ERROR;
- }
- DEBUG_CLIENT_MSG("send reqeust :: transceive = [%p]", handle);
+ return NET_NFC_NOT_INITIALIZED;
+ }
if (handle == NULL || rawdata == NULL)
return NET_NFC_NULL_PARAMETER;
return NET_NFC_INVALID_STATE;
}
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- /* fill trans information struct */
target_info = net_nfc_client_tag_get_client_target_info();
+ if (target_info == NULL || target_info->handle == NULL)
+ return NET_NFC_NOT_CONNECTED;
- if (target_info == NULL)
- return NET_NFC_OPERATION_FAIL;
+ DEBUG_CLIENT_MSG("send request :: transceive = [%p]", handle);
- arg_data = transceive_data_to_transceive_variant(target_info->devType, data);
- if (arg_data == NULL)
- return NET_NFC_OPERATION_FAIL;
+ arg_data = transceive_data_to_transceive_variant(target_info->devType,
+ rawdata);
+ if (arg_data == NULL) {
+ return NET_NFC_INVALID_PARAM;
+ }
- funcdata = g_new0(TransceiveFuncData, 1);
+ funcdata = g_try_new0(NetNfcCallback, 1);
+ if (funcdata == NULL) {
+ g_variant_unref(arg_data);
- funcdata->transceive_send_callback = (gpointer)callback;
- funcdata->transceive_send_data = user_data;
+ return NET_NFC_ALLOC_FAIL;
+ }
+
+ funcdata->callback = (gpointer)callback;
+ funcdata->user_data = user_data;
net_nfc_gdbus_transceive_call_transceive_data(transceive_proxy,
GPOINTER_TO_UINT(handle),
API net_nfc_error_e net_nfc_client_transceive_sync(net_nfc_target_handle_h handle,
data_h rawdata)
{
- net_nfc_target_info_s *target_info = NULL;
- data_s *data = (data_s *)rawdata;
-
+ net_nfc_target_info_s *target_info;
+ net_nfc_error_e out_result = NET_NFC_OK;
GError *error = NULL;
- GVariant *arg_data = NULL;
+ GVariant *arg_data;
- net_nfc_error_e out_result;
+ if (handle == NULL || rawdata == NULL)
+ return NET_NFC_NULL_PARAMETER;
if (transceive_proxy == NULL)
{
DEBUG_ERR_MSG("Can not get TransceiveProxy");
- return NET_NFC_UNKNOWN_ERROR;
- }
-
- DEBUG_CLIENT_MSG("send reqeust :: transceive = [%p]", handle);
- if (handle == NULL || rawdata == NULL)
- return NET_NFC_NULL_PARAMETER;
+ return NET_NFC_NOT_INITIALIZED;
+ }
/* prevent executing daemon when nfc is off */
if (net_nfc_client_manager_is_activated() == false) {
return NET_NFC_INVALID_STATE;
}
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- /* fill trans information struct */
target_info = net_nfc_client_tag_get_client_target_info();
+ if (target_info == NULL || target_info->handle == NULL)
+ return NET_NFC_NOT_CONNECTED;
- if (target_info == NULL)
- return NET_NFC_OPERATION_FAIL;
+ DEBUG_CLIENT_MSG("send request :: transceive = [%p]", handle);
- arg_data = transceive_data_to_transceive_variant(target_info->devType, data);
+ arg_data = transceive_data_to_transceive_variant(target_info->devType,
+ rawdata);
if (arg_data == NULL)
- return NET_NFC_OPERATION_FAIL;
+ return NET_NFC_ALLOC_FAIL;
- if(net_nfc_gdbus_transceive_call_transceive_sync(transceive_proxy,
+ if (net_nfc_gdbus_transceive_call_transceive_sync(transceive_proxy,
GPOINTER_TO_UINT(handle),
target_info->devType,
arg_data,
{
DEBUG_ERR_MSG("Transceive (sync call) failed: %s",
error->message);
-
g_error_free(error);
- return NET_NFC_UNKNOWN_ERROR;
+
+ out_result = NET_NFC_IPC_FAIL;
}
return out_result;
API net_nfc_error_e net_nfc_client_transceive_data_sync(
net_nfc_target_handle_h handle, data_h rawdata, data_h *response)
{
- net_nfc_target_info_s *target_info = NULL;
- data_s *data = (data_s *)rawdata;
-
- GError *error = NULL;
- GVariant *arg_data = NULL;
+ net_nfc_target_info_s *target_info;
+ net_nfc_error_e out_result = NET_NFC_OK;
GVariant *out_data = NULL;
+ GError *error = NULL;
+ GVariant *arg_data;
- net_nfc_error_e out_result = NET_NFC_OK;
+ if (handle == NULL || rawdata == NULL)
+ return NET_NFC_NULL_PARAMETER;
if (transceive_proxy == NULL)
{
DEBUG_ERR_MSG("Can not get TransceiveProxy");
- return NET_NFC_UNKNOWN_ERROR;
- }
- DEBUG_CLIENT_MSG("send reqeust :: transceive = [%p]", handle);
-
- if (handle == NULL || rawdata == NULL)
- return NET_NFC_NULL_PARAMETER;
+ return NET_NFC_NOT_INITIALIZED;
+ }
/* prevent executing daemon when nfc is off */
if (net_nfc_client_manager_is_activated() == false) {
return NET_NFC_INVALID_STATE;
}
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
-
- /* fill trans information struct */
target_info = net_nfc_client_tag_get_client_target_info();
+ if (target_info == NULL || target_info->handle == NULL)
+ return NET_NFC_NOT_CONNECTED;
- if (target_info == NULL)
- return NET_NFC_OPERATION_FAIL;
+ DEBUG_CLIENT_MSG("send request :: transceive = [%p]", handle);
- arg_data = transceive_data_to_transceive_variant(target_info->devType, data);
+ arg_data = transceive_data_to_transceive_variant(target_info->devType,
+ rawdata);
if (arg_data == NULL)
- return NET_NFC_OPERATION_FAIL;
+ return NET_NFC_ALLOC_FAIL;
if (net_nfc_gdbus_transceive_call_transceive_data_sync(
transceive_proxy,
DEBUG_ERR_MSG("Transceive (sync call) failed: %s",
error->message);
g_error_free(error);
- return NET_NFC_UNKNOWN_ERROR;
+
+ out_result = NET_NFC_IPC_FAIL;
}
if (response && out_data != NULL)
void net_nfc_client_transceive_deinit(void)
{
- if(transceive_proxy)
+ if (transceive_proxy)
{
g_object_unref(transceive_proxy);
transceive_proxy = NULL;
Set
-->
<method name="Set">
- <arg type="b" name="state" direction="in" />
+ <arg type="i" name="state" direction="in" />
<arg type="i" name="focus_state" direction="in" />
<arg type="a(y)" name="privilege" direction="in" />
+ <arg type="i" name="result" direction="out" />
</method>
<!--
-->
<method name="Get">
<arg type="a(y)" name="privilege" direction="in" />
- <arg type="b" name="state" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ <arg type="i" name="state" direction="out" />
</method>
</interface>
static NetNfcGDbusManager *manager_skeleton = NULL;
-static gboolean manager_active(void);
+static net_nfc_error_e manager_active(void);
-static gboolean manager_deactive(void);
+static net_nfc_error_e manager_deactive(void);
static void manager_handle_active_thread_func(gpointer user_data);
/* reimplementation of net_nfc_service_init()*/
-static gboolean manager_active(void)
+static net_nfc_error_e manager_active(void)
{
net_nfc_error_e result;
if (net_nfc_controller_is_ready(&result) == false)
{
- DEBUG_ERR_MSG("%s failed [%d]",
- "net_nfc_cotroller_is_ready", result);
- return FALSE;
+ DEBUG_ERR_MSG("net_nfc_controller_is_ready failed [%d]", result);
+
+ return result;
}
result = net_nfc_server_se_change_se(SECURE_ELEMENT_TYPE_UICC);
if (net_nfc_controller_configure_discovery(
NET_NFC_DISCOVERY_MODE_START,
NET_NFC_ALL_ENABLE,
- &result) == false)
+ &result) == TRUE)
{
- DEBUG_ERR_MSG("%s is failed %d",
- "net_nfc_controller_configure_discovery",
- result);
- return FALSE;
- }
+ /* vconf on */
+ if (vconf_set_bool(VCONFKEY_NFC_STATE, TRUE) != 0)
+ {
+ DEBUG_ERR_MSG("vconf_set_bool is failed");
- /* vconf on */
- if (vconf_set_bool(VCONFKEY_NFC_STATE, TRUE) != 0)
+ result = NET_NFC_OPERATION_FAIL;
+ }
+ }
+ else
{
- DEBUG_ERR_MSG("%s is failed", "vconf_set_bool");
- return FALSE;
+ DEBUG_ERR_MSG("net_nfc_controller_configure_discovery is failed, [%d]", result);
}
- return TRUE;
+ return result;
}
/* reimplementation of net_nfc_service_deinit()*/
-static gboolean manager_deactive(void)
+static net_nfc_error_e manager_deactive(void)
{
net_nfc_error_e result;
if (net_nfc_controller_is_ready(&result) == false)
{
- DEBUG_ERR_MSG("%s failed [%d]",
- "net_nfc_cotroller_is_ready", result);
- return FALSE;
+ DEBUG_ERR_MSG("net_nfc_controller_is_ready failed [%d]", result);
+
+ return result;
}
/* unregister all services */
if (net_nfc_controller_configure_discovery(
NET_NFC_DISCOVERY_MODE_STOP,
NET_NFC_ALL_DISABLE,
- &result) == false)
+ &result) == TRUE)
{
- DEBUG_ERR_MSG("%s is failed %d",
- "net_nfc_controller_configure_discovery",
- result);
- return FALSE;
- }
+ /* vconf off */
+ if (vconf_set_bool(VCONFKEY_NFC_STATE, FALSE) != 0)
+ {
+ DEBUG_ERR_MSG("vconf_set_bool is failed");
- /* vconf off */
- if (vconf_set_bool(VCONFKEY_NFC_STATE, FALSE) != 0)
+ result = NET_NFC_OPERATION_FAIL;
+ }
+ }
+ else
{
- DEBUG_ERR_MSG("%s is failed", "vconf_set_bool");
- return FALSE;
+ DEBUG_ERR_MSG("net_nfc_controller_configure_discovery is failed, [%d]", result);
}
- return TRUE;
+ return result;
}
static void manager_handle_active_thread_func(gpointer user_data)
{
ManagerActivationData *data = (ManagerActivationData *)user_data;
- gboolean ret;
net_nfc_error_e result;
g_assert(data != NULL);
g_assert(data->invocation != NULL);
if (data->is_active)
- ret = manager_active();
+ result = manager_active();
else
- ret = manager_deactive();
- if (ret == TRUE)
- {
- result = NET_NFC_OK;
- INFO_MSG("nfc %s", data->is_active ? "activated" : "deactivated");
+ result = manager_deactive();
+
+ net_nfc_gdbus_manager_complete_set_active(data->manager,
+ data->invocation,
+ result);
+
+ if (result == NET_NFC_OK) {
+ INFO_MSG("nfc %s", data->is_active ?
+ "activated" : "deactivated");
net_nfc_gdbus_manager_emit_activated(data->manager,
- data->is_active);
+ data->is_active);
}
- else
- {
- result = NET_NFC_OPERATION_FAIL;
- }
-
- net_nfc_gdbus_manager_complete_set_active(data->manager,
- data->invocation,
- result);
g_object_unref(data->invocation);
g_object_unref(data->manager);
/* shutdown process if it doesn't need */
if (data->is_active == false &&
- net_nfc_server_gdbus_is_server_busy() == false) {
+ net_nfc_server_gdbus_is_server_busy() == false) {
net_nfc_server_controller_deinit();
}
data->is_active = arg_is_active;
result = net_nfc_server_controller_async_queue_push(
- manager_handle_active_thread_func, data);
+ manager_handle_active_thread_func, data);
if (result == FALSE)
{
g_dbus_method_invocation_return_dbus_error(invocation,
{
ManagerActivationData *data =
(ManagerActivationData *)user_data;
- gboolean ret;
+ net_nfc_error_e ret;
g_assert(data != NULL);
ret = manager_active();
else
ret = manager_deactive();
- if (ret == TRUE)
+ if (ret == NET_NFC_OK)
{
INFO_MSG("nfc %s",
- data->is_active ? "activated" : "deactivated");
+ data->is_active ? "activated" : "deactivated");
net_nfc_gdbus_manager_emit_activated(data->manager, data->is_active);
}
#include "net_nfc_server_controller.h"
#include "net_nfc_gdbus.h"
#include "net_nfc_server_common.h"
+#include "net_nfc_server_tag.h"
#include "net_nfc_server_context.h"
#include "net_nfc_server_process_snep.h"
#include "net_nfc_server_p2p.h"
NetNfcGDbusP2p *p2p;
GDBusMethodInvocation *invocation;
gint32 type;
- net_nfc_target_handle_s *p2p_handle;
+ guint32 p2p_handle;
data_s data;
};
g_assert(p2p_data->invocation != NULL);
result = net_nfc_server_snep_default_client_start(
- p2p_data->p2p_handle,
+ GUINT_TO_POINTER(p2p_data->p2p_handle),
SNEP_REQ_PUT,
&p2p_data->data,
-1,
data->p2p = g_object_ref(p2p);
data->invocation = g_object_ref(invocation);
data->type = arg_type;
- data->p2p_handle = GUINT_TO_POINTER(handle);
+ data->p2p_handle = handle;
net_nfc_util_gdbus_variant_to_data_s(arg_data, &data->data);
result = net_nfc_server_controller_async_queue_push(
DEBUG_ERR_MSG("p2p detached signal");
+ /* release target information */
+ net_nfc_server_free_target_info();
+
net_nfc_gdbus_p2p_emit_detached(p2p_skeleton);
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "net_nfc_gdbus.h"
#include "net_nfc_debug_internal.h"
+#include "net_nfc_gdbus.h"
#include "net_nfc_server_common.h"
#include "net_nfc_server_context.h"
#include "net_nfc_server_system_handler.h"
static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
GDBusMethodInvocation *invocation,
- gboolean state,
+ int state,
gint focus_state,
GVariant *smack_privilege,
gpointer user_data);
static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
GDBusMethodInvocation *invocation,
- gboolean state,
+ gint state,
gint focus_state,
GVariant *smack_privilege,
gpointer user_data)
g_dbus_method_invocation_get_sender(invocation),
state, focus_state);
- net_nfc_gdbus_popup_complete_set(popup_manager, invocation);
+ net_nfc_gdbus_popup_complete_set(popup_manager, invocation, NET_NFC_OK);
return TRUE;
}
state = net_nfc_server_gdbus_get_launch_state(
g_dbus_method_invocation_get_sender(invocation));
- net_nfc_gdbus_popup_complete_get(popup_manager, invocation, state);
+ net_nfc_gdbus_popup_complete_get(popup_manager, invocation,
+ NET_NFC_OK, state);
return TRUE;
}
DEBUG_ERR_MSG("Can not skeleton_export %s", error->message);
g_error_free(error);
- g_object_unref(popup_skeleton);
- popup_skeleton = NULL;
+
+ net_nfc_server_system_handler_deinit();
}
return result;
void net_nfc_server_system_handler_deinit(void)
{
- if(popup_skeleton)
+ if (popup_skeleton)
{
g_object_unref(popup_skeleton);
popup_skeleton = NULL;
}
-
}
static void transceive_data_thread_func(gpointer user_data)
{
- TransceiveSendData *transceive_data = user_data;
- net_nfc_target_handle_s *handle = GUINT_TO_POINTER(transceive_data->transceive_handle);
- net_nfc_error_e result;
+ TransceiveSendData *transceive_data = (TransceiveSendData*)user_data;
+ net_nfc_target_handle_s *handle =
+ (net_nfc_target_handle_s *)transceive_data->transceive_handle;
+ net_nfc_error_e result = NET_NFC_OK;
data_s *data = NULL;
GVariant *resp_data = NULL;
static void transceive_thread_func(gpointer user_data)
{
- TransceiveSendData *transceive_data = user_data;
- net_nfc_target_handle_s *handle = GUINT_TO_POINTER(transceive_data->transceive_handle);
+ TransceiveSendData *transceive_data = (TransceiveSendData *)user_data;
+ net_nfc_target_handle_s *handle =
+ (net_nfc_target_handle_s *)transceive_data->transceive_handle;
net_nfc_error_e result = NET_NFC_OK;
data_s *data = NULL;
net_nfc_test_get_nfc_state,
"Get nfc state"
},
-
+#if 0
{
"Tag",
"IsTagConnected",
net_nfc_test_tag_get_current_target_handle_sync,
"Get current target handle id"
},
-
+#endif
{
"Tag",
"TagDiscovered", /* waiting for signal */
net_nfc_get_record_il(flag),
tnf_str[tnf]);
- net_nfc_get_record_type(record, &type);
-
- str = g_strndup((gchar *)net_nfc_get_data_buffer(type),
- net_nfc_get_data_length(type));
- g_print("Type : %s\n", str);
- g_free(str);
+ if (net_nfc_get_record_type(record, &type) == NET_NFC_OK)
+ {
+ str = g_strndup((gchar *)net_nfc_get_data_buffer(type),
+ net_nfc_get_data_length(type));
+ g_print("Type : %s\n", str);
+ g_free(str);
+ }
net_nfc_get_record_id(record, &id);
g_print("ID : %s\n", str);
g_free(str);
- net_nfc_get_record_payload(record, &payload);
- print_received_data(payload);
+ if (net_nfc_get_record_payload(record, &payload) == NET_NFC_OK)
+ {
+ print_received_data(payload);
+ }
switch(tnf)
{
#include "net_nfc_test_tag.h"
static void run_next_callback(gpointer user_data);
-
+#if 0
static gchar *tag_type_to_string(net_nfc_target_type_e dev_type);
-
+#endif
static void print_is_tag_connected(net_nfc_target_type_e dev_type);
static void print_get_current_tag_info(net_nfc_target_info_h info);
static void print_get_current_target_handle(net_nfc_target_handle_h handle);
-
+#if 0
static void is_tag_connected_completed(net_nfc_error_e result,
net_nfc_target_type_e dev_type,
void *user_data);
static void get_current_target_handle_completed(net_nfc_error_e result,
net_nfc_target_handle_h handle,
void *user_data);
-
+#endif
static void tag_detached(void *user_data);
static void tag_discovered(net_nfc_target_info_h info,
callback();
}
}
-
+#if 0
static gchar *tag_type_to_string(net_nfc_target_type_e dev_type)
{
switch(dev_type)
}
return "Invalid Target";
}
-
+#endif
static void print_is_tag_connected(net_nfc_target_type_e dev_type)
{
if (global_info)
{
g_print("TagDetached\n");
}
-
+#if 0
static void is_tag_connected_completed(net_nfc_error_e result,
net_nfc_target_type_e dev_type,
void *user_data)
run_next_callback(user_data);
}
-
+#endif
static void tag_discovered(net_nfc_target_info_h info,
void *user_data)
}
-
+#if 0
void net_nfc_test_tag_is_tag_connected(gpointer data,
gpointer user_data)
{
get_current_target_handle_completed,
user_data);
}
-
+#endif
void net_nfc_test_tag_is_tag_connected_sync(gpointer data,
gpointer user_data)
{
#include <glib.h>
#include "net_nfc_target_info.h"
-
+#if 0
void net_nfc_test_tag_is_tag_connected(gpointer data,
gpointer user_data);
void net_nfc_test_tag_get_current_target_handle(gpointer data,
gpointer user_data);
-
+#endif
void net_nfc_test_tag_is_tag_connected_sync(gpointer data,
gpointer user_data);