merge with Local branch
authorWonkyu Kwon <wonkyu.kwon@samsung.com>
Fri, 30 Aug 2013 04:46:52 +0000 (13:46 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Fri, 30 Aug 2013 04:46:52 +0000 (13:46 +0900)
- Adjust sending signal sequence of activation NFC
- Get target information in client storage first
- Remove asynchronous functions related getting target information
- Modify managing tag context step 1.
  store the result of getting target information and reuse it.
- revise some functions

Change-Id: I4a530ea097e3686872cc9172577af1b5ebf490ce

20 files changed:
client/include/net_nfc_client_tag.h
client/include/net_nfc_client_transceive.h
client/include/net_nfc_data.h
client/include/net_nfc_target_info.h
client/net_nfc_client.c
client/net_nfc_client_data.c
client/net_nfc_client_p2p.c
client/net_nfc_client_system_handler.c
client/net_nfc_client_tag.c
client/net_nfc_client_target_info.c
client/net_nfc_client_transceive.c
common/net_nfc.xml
daemon/net_nfc_server_manager.c
daemon/net_nfc_server_p2p.c
daemon/net_nfc_server_system_handler.c
daemon/net_nfc_server_transceive.c
tests/main.c
tests/net_nfc_test_ndef.c
tests/net_nfc_test_tag.c
tests/net_nfc_test_tag.h

index 37572cf..af7da75 100644 (file)
@@ -18,6 +18,7 @@
 
 #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);
 
@@ -26,27 +27,27 @@ typedef void (*net_nfc_client_tag_get_current_tag_info_completed)(
 
 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);
@@ -61,6 +62,8 @@ void net_nfc_client_tag_set_tag_detached(
 
 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);
index ced0e28..ca1065e 100644 (file)
@@ -21,7 +21,7 @@
 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);
 
index 51c5266..92221d2 100644 (file)
 
   @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.
@@ -52,30 +52,30 @@ net_nfc_error_e net_nfc_create_data_only (data_h* 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 (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
 
@@ -84,31 +84,31 @@ net_nfc_error_e net_nfc_get_data (const data_h data, uint8_t** bytes, uint32_t *
   @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)
@@ -123,7 +123,6 @@ uint8_t * net_nfc_get_data_buffer (const data_h data);
 net_nfc_error_e net_nfc_free_data (data_h data);
 
 
-
 /**
 @}
 */
index 77cb39d..05c4388 100644 (file)
@@ -49,8 +49,8 @@
 
 */
 
-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
@@ -68,7 +68,7 @@ net_nfc_error_e net_nfc_get_tag_type (net_nfc_target_info_h target_info,
 */
 
 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.
@@ -86,8 +86,8 @@ net_nfc_error_e net_nfc_get_tag_handle(net_nfc_target_info_h target_info,
 
 */
 
-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.
@@ -104,8 +104,8 @@ net_nfc_error_e net_nfc_get_tag_ndef_support (net_nfc_target_info_h target_info,
 
 */
 
-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
@@ -123,7 +123,7 @@ net_nfc_error_e net_nfc_get_tag_max_data_size (net_nfc_target_info_h target_info
 */
 
 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);
 
 
 /**
@@ -174,7 +174,7 @@ net_nfc_error_e net_nfc_get_tag_actual_data_size(
 */
 
 net_nfc_error_e net_nfc_get_tag_info_keys(net_nfc_target_info_h target_info,
-               char ***keys, intnumber_of_keys);
+               char ***keys, int *number_of_keys);
 
 /**
   this function return value which is matched key
@@ -222,7 +222,7 @@ net_nfc_error_e net_nfc_get_tag_info_keys(net_nfc_target_info_h target_info,
   */
 
 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
index 449fd12..64d5be7 100644 (file)
@@ -45,9 +45,7 @@ static void _init_smack()
                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;
                                }
index 5771883..0757cc1 100644 (file)
 
 #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_hdata,
-               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;
@@ -60,12 +62,19 @@ API net_nfc_error_e net_nfc_create_data(data_h* data,
        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;
@@ -73,13 +82,14 @@ API net_nfc_error_e net_nfc_get_data(const data_h data, uint8_t** bytes, uint32_
        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;
 
@@ -104,40 +114,36 @@ API net_nfc_error_e net_nfc_set_data(const data_h data, const uint8_t* bytes, co
        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;
index 3b34d84..a76c874 100644 (file)
@@ -67,7 +67,7 @@ static void p2p_device_detached(GObject *source_object,
        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*/
@@ -123,7 +123,7 @@ static void p2p_call_send(GObject *source_object, GAsyncResult *res,
                                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);
@@ -141,8 +141,8 @@ static void p2p_call_send(GObject *source_object, GAsyncResult *res,
 }
 
 
-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_handle,
+               data_data, net_nfc_client_p2p_send_completed callback, void *user_data)
 {
        GVariant *arg_data;
        NetNfcCallback *func_data;
@@ -170,21 +170,21 @@ API net_nfc_error_e net_nfc_client_p2p_send(net_nfc_target_handle_s *handle,
        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_handle,
+               data_h data)
 {
        GVariant *arg_data;
        GError *error = NULL;
@@ -206,13 +206,13 @@ API net_nfc_error_e net_nfc_client_p2p_send_sync(net_nfc_target_handle_s *handle
        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);
@@ -228,6 +228,9 @@ API net_nfc_error_e net_nfc_client_p2p_send_sync(net_nfc_target_handle_s *handle
 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;
 }
@@ -236,6 +239,9 @@ API void net_nfc_client_p2p_set_device_discovered(
 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;
 }
@@ -244,6 +250,9 @@ API void net_nfc_client_p2p_set_device_detached(
 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;
 }
index 15d90e8..4882216 100644 (file)
 #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;
@@ -41,42 +35,32 @@ static void popup_set_active_callback(GObject *source_object, GAsyncResult *res,
 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);
 }
@@ -84,11 +68,9 @@ static void popup_set_active_callback(GObject *source_object, GAsyncResult *res,
 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 */
@@ -96,19 +78,16 @@ API net_nfc_error_e net_nfc_client_sys_handler_set_state(int state,
                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,
@@ -119,8 +98,8 @@ API net_nfc_error_e net_nfc_client_sys_handler_set_state(int state,
 
 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;
@@ -131,9 +110,10 @@ API net_nfc_error_e net_nfc_client_sys_handler_set_state_sync(int state)
        }
 
        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)
        {
@@ -141,19 +121,16 @@ API net_nfc_error_e net_nfc_client_sys_handler_set_state_sync(int state)
                                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;
@@ -163,19 +140,16 @@ API net_nfc_error_e net_nfc_client_sys_handler_set_state_force(int state,
                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,
@@ -186,8 +160,8 @@ API net_nfc_error_e net_nfc_client_sys_handler_set_state_force(int state,
 
 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;
@@ -198,9 +172,10 @@ API net_nfc_error_e net_nfc_client_sys_handler_set_state_force_sync(int state)
        }
 
        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)
        {
@@ -208,64 +183,39 @@ API net_nfc_error_e net_nfc_client_sys_handler_set_state_force_sync(int state)
                                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");
@@ -273,19 +223,28 @@ API net_nfc_error_e net_nfc_client_sys_handler_get_launch_popup_state(
                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)
index c07e00d..0d07768 100644 (file)
 #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;
@@ -57,7 +50,7 @@ static void tag_get_target_info(guint handle,
                GVariant *raw_data,
                net_nfc_target_info_s **info);
 
-
+#if 0
 /* async callback */
 static void tag_is_tag_connected(GObject *source_object,
                GAsyncResult *res,
@@ -70,7 +63,7 @@ static void tag_get_current_tag_info(GObject *source_object,
 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,
@@ -95,13 +88,13 @@ static gboolean tag_check_filter(net_nfc_target_type_e type)
 
        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;
        }
@@ -142,7 +135,7 @@ static void tag_get_info_list(guint8 *buffer,
        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;
@@ -219,20 +212,18 @@ static void tag_get_target_info(guint handle,
 
        *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),
@@ -241,30 +232,23 @@ static void tag_is_tag_connected(GObject *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);
 }
@@ -273,27 +257,23 @@ static void tag_get_current_tag_info(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;
 
-       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),
@@ -310,56 +290,45 @@ static void tag_get_current_tag_info(GObject *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);
 }
@@ -368,58 +337,46 @@ static void tag_get_current_target_handle(GObject *source_object,
                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,
@@ -432,25 +389,17 @@ static void tag_tag_discovered(NetNfcGDbusTag *object,
                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,
@@ -460,14 +409,15 @@ static void tag_tag_discovered(NetNfcGDbusTag *object,
                        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,
@@ -475,27 +425,21 @@ 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 */
@@ -515,23 +459,24 @@ net_nfc_target_info_s *net_nfc_client_tag_get_client_target_info(void)
        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;
@@ -544,62 +489,85 @@ API net_nfc_error_e net_nfc_client_tag_is_tag_connected(
 
        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,
@@ -608,96 +576,109 @@ API net_nfc_error_e net_nfc_client_tag_get_current_tag_info(
 
        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;
 
@@ -709,86 +690,95 @@ API net_nfc_error_e net_nfc_client_tag_get_current_target_handle(
 
        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)
@@ -846,26 +836,17 @@ net_nfc_error_e net_nfc_client_tag_init(void)
 
 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;
 }
index eef253e..746abba 100644 (file)
 #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;
@@ -108,7 +127,7 @@ API net_nfc_error_e net_nfc_get_tag_info_keys(net_nfc_target_info_h target_info,
        if (*keys == NULL)
                return NET_NFC_ALLOC_FAIL;
 
-       net_nfc_tag_info_stag_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++)
        {
@@ -125,19 +144,20 @@ API net_nfc_error_e net_nfc_get_tag_info_keys(net_nfc_target_info_h target_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++)
        {
@@ -156,7 +176,7 @@ API net_nfc_error_e net_nfc_get_tag_info_value(net_nfc_target_info_h target_info
        }
 
        if (i == handle->number_of_keys)
-               return NET_NFC_NOT_SUPPORTED;
+               return NET_NFC_NO_DATA_FOUND;
 
        return NET_NFC_OK;
 }
@@ -218,9 +238,8 @@ API net_nfc_error_e net_nfc_duplicate_target_info(net_nfc_target_info_h origin,
        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)
@@ -229,7 +248,8 @@ static net_nfc_error_e net_nfc_util_release_tag_info(net_nfc_target_info_s *info
        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)
@@ -249,19 +269,20 @@ static net_nfc_error_e net_nfc_util_release_tag_info(net_nfc_target_info_s *info
 
        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;
 }
index 74585c2..318e86c 100644 (file)
@@ -40,20 +40,12 @@ static void transceive_data_call(GObject *source_object,
                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)
        {
@@ -67,7 +59,7 @@ static GVariant *transceive_data_to_transceive_variant(
        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,
@@ -87,7 +79,7 @@ static GVariant *transceive_data_to_transceive_variant(
                        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,
@@ -96,7 +88,6 @@ static GVariant *transceive_data_to_transceive_variant(
                                        transceive_info.buffer,
                                        transceive_info.length);
                }
-
                break;
 
        default :
@@ -118,115 +109,90 @@ static GVariant *transceive_data_to_transceive_variant(
 }
 
 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;
@@ -236,23 +202,27 @@ API net_nfc_error_e net_nfc_client_transceive(net_nfc_target_handle_h handle,
                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),
@@ -269,19 +239,16 @@ API net_nfc_error_e net_nfc_client_transceive(net_nfc_target_handle_h 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;
@@ -291,23 +258,27 @@ API net_nfc_error_e net_nfc_client_transceive_data(net_nfc_target_handle_h handl
                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),
@@ -324,44 +295,38 @@ API net_nfc_error_e net_nfc_client_transceive_data(net_nfc_target_handle_h handl
 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,
@@ -372,9 +337,9 @@ API net_nfc_error_e net_nfc_client_transceive_sync(net_nfc_target_handle_h handl
        {
                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;
@@ -383,43 +348,37 @@ API net_nfc_error_e net_nfc_client_transceive_sync(net_nfc_target_handle_h handl
 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,
@@ -435,7 +394,8 @@ API net_nfc_error_e net_nfc_client_transceive_data_sync(
                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)
@@ -478,7 +438,7 @@ net_nfc_error_e net_nfc_client_transceive_init(void)
 
 void net_nfc_client_transceive_deinit(void)
 {
-       if(transceive_proxy)
+       if (transceive_proxy)
        {
                g_object_unref(transceive_proxy);
                transceive_proxy = NULL;
index 752e876..fb8f738 100644 (file)
       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>
 
index 8c97620..466e091 100644 (file)
@@ -43,9 +43,9 @@ struct _ManagerActivationData
 
 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);
 
@@ -65,15 +65,15 @@ static void manager_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);
@@ -90,34 +90,34 @@ static gboolean manager_active(void)
        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 */
@@ -128,28 +128,27 @@ static gboolean manager_deactive(void)
        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);
@@ -157,25 +156,21 @@ static void manager_handle_active_thread_func(gpointer user_data)
        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);
@@ -184,7 +179,7 @@ static void manager_handle_active_thread_func(gpointer user_data)
 
        /* 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();
        }
@@ -230,7 +225,7 @@ static gboolean manager_handle_set_active(NetNfcGDbusManager *manager,
        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,
@@ -280,7 +275,7 @@ static void manager_active_thread_func(gpointer user_data)
 {
        ManagerActivationData *data =
                (ManagerActivationData *)user_data;
-       gboolean ret;
+       net_nfc_error_e ret;
 
        g_assert(data != NULL);
 
@@ -288,10 +283,10 @@ static void manager_active_thread_func(gpointer user_data)
                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);
        }
index f977622..8e18214 100644 (file)
@@ -20,6 +20,7 @@
 #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"
@@ -32,7 +33,7 @@ struct _P2pSendData
        NetNfcGDbusP2p *p2p;
        GDBusMethodInvocation *invocation;
        gint32 type;
-       net_nfc_target_handle_s *p2p_handle;
+       guint32 p2p_handle;
        data_s data;
 };
 
@@ -58,7 +59,7 @@ static void p2p_send_data_thread_func(gpointer user_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,
@@ -116,7 +117,7 @@ static gboolean p2p_handle_send(NetNfcGDbusP2p *p2p,
        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(
@@ -189,6 +190,9 @@ void net_nfc_server_p2p_detached(void)
 
        DEBUG_ERR_MSG("p2p detached signal");
 
+       /* release target information */
+       net_nfc_server_free_target_info();
+
        net_nfc_gdbus_p2p_emit_detached(p2p_skeleton);
 }
 
index fc3c53f..24aa98a 100644 (file)
@@ -13,8 +13,8 @@
  * 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"
@@ -24,7 +24,7 @@ static NetNfcGDbusPopup *popup_skeleton = NULL;
 
 static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
                GDBusMethodInvocation *invocation,
-               gboolean state,
+               int state,
                gint focus_state,
                GVariant *smack_privilege,
                gpointer user_data);
@@ -36,7 +36,7 @@ static gboolean popup_handle_get(NetNfcGDbusPopup *popup_manager,
 
 static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
                GDBusMethodInvocation *invocation,
-               gboolean state,
+               gint state,
                gint focus_state,
                GVariant *smack_privilege,
                gpointer user_data)
@@ -58,7 +58,7 @@ static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
                        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;
 }
@@ -86,7 +86,8 @@ static gboolean popup_handle_get(NetNfcGDbusPopup *popup_manager,
        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;
 }
@@ -127,8 +128,8 @@ gboolean net_nfc_server_system_handler_init(GDBusConnection *connection)
                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;
@@ -136,10 +137,9 @@ gboolean net_nfc_server_system_handler_init(GDBusConnection *connection)
 
 void net_nfc_server_system_handler_deinit(void)
 {
-       if(popup_skeleton)
+       if (popup_skeleton)
        {
                g_object_unref(popup_skeleton);
                popup_skeleton = NULL;
        }
-
 }
index b5314cd..54a52a0 100644 (file)
@@ -61,9 +61,10 @@ struct _TransceiveSendData
 
 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;
 
@@ -180,8 +181,9 @@ static gboolean transceive_data_handle(NetNfcGDbusTransceive *transceive,
 
 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;
 
index 7196a6e..244d8bb 100644 (file)
@@ -95,7 +95,7 @@ static TestData test_data[] = {
                net_nfc_test_get_nfc_state,
                "Get nfc state"
        },
-
+#if 0
        {
                "Tag",
                "IsTagConnected",
@@ -118,7 +118,7 @@ static TestData test_data[] = {
                net_nfc_test_tag_get_current_target_handle_sync,
                "Get current target handle id"
        },
-
+#endif
        {
                "Tag",
                "TagDiscovered",                /* waiting for signal */
index 16d1211..9432f68 100644 (file)
@@ -149,12 +149,13 @@ static void print_record(ndef_record_h record)
                        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);
 
@@ -163,8 +164,10 @@ static void print_record(ndef_record_h record)
        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)
        {
index 1ecb175..baaa9fb 100644 (file)
 #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);
@@ -41,7 +41,7 @@ static void get_current_tag_info_completed(net_nfc_error_e result,
 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,
@@ -61,7 +61,7 @@ static void run_next_callback(gpointer user_data)
                callback();
        }
 }
-
+#if 0
 static gchar *tag_type_to_string(net_nfc_target_type_e dev_type)
 {
        switch(dev_type)
@@ -107,7 +107,7 @@ static gchar *tag_type_to_string(net_nfc_target_type_e dev_type)
        }
        return "Invalid Target";
 }
-
+#endif
 static void print_is_tag_connected(net_nfc_target_type_e dev_type)
 {
        if (global_info)
@@ -165,7 +165,7 @@ static void tag_detached(void *user_data)
 {
        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)
@@ -205,7 +205,7 @@ static void get_current_target_handle_completed(net_nfc_error_e result,
 
        run_next_callback(user_data);
 }
-
+#endif
 
 static void tag_discovered(net_nfc_target_info_h info,
                void *user_data)
@@ -218,7 +218,7 @@ static void tag_discovered(net_nfc_target_info_h info,
 }
 
 
-
+#if 0
 void net_nfc_test_tag_is_tag_connected(gpointer data,
                gpointer user_data)
 {
@@ -240,7 +240,7 @@ void net_nfc_test_tag_get_current_target_handle(gpointer data,
                        get_current_target_handle_completed,
                        user_data);
 }
-
+#endif
 void net_nfc_test_tag_is_tag_connected_sync(gpointer data,
                gpointer user_data)
 {
index 9f32d8c..77ed733 100644 (file)
@@ -19,7 +19,7 @@
 #include <glib.h>
 
 #include "net_nfc_target_info.h"
-
+#if 0
 void net_nfc_test_tag_is_tag_connected(gpointer data,
                gpointer user_data);
 
@@ -28,7 +28,7 @@ void net_nfc_test_tag_get_current_tag_info(gpointer 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);