merge with master
authorJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:13:35 +0000 (01:13 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:13:35 +0000 (01:13 +0900)
34 files changed:
nfc-manager.manifest
packaging/nfc-manager.spec
src/clientlib/CMakeLists.txt
src/clientlib/include/net_nfc_apdu.h [deleted file]
src/clientlib/include/net_nfc_client_dispatcher_private.h
src/clientlib/include/net_nfc_client_ipc_private.h
src/clientlib/include/net_nfc_internal_se.h
src/clientlib/net_nfc_client_dispatcher.c
src/clientlib/net_nfc_client_exchanger.c
src/clientlib/net_nfc_client_internal_se.c
src/clientlib/net_nfc_client_ipc.c
src/clientlib/net_nfc_client_llcp.c
src/clientlib/net_nfc_client_nfc.c
src/clientlib/net_nfc_client_tag.c
src/clientlib/net_nfc_client_test.c
src/commonlib/include/net_nfc_oem_controller.h
src/commonlib/include/net_nfc_typedef.h
src/commonlib/include/net_nfc_typedef_private.h
src/manager/CMakeLists.txt
src/manager/include/net_nfc_controller_private.h
src/manager/include/net_nfc_server_dispatcher_private.h
src/manager/include/net_nfc_service_llcp_private.h
src/manager/include/net_nfc_service_private.h
src/manager/include/net_nfc_service_se_private.h
src/manager/include/net_nfc_service_tag_private.h
src/manager/include/net_nfc_service_test_private.h [new file with mode: 0755]
src/manager/net_nfc_controller.c
src/manager/net_nfc_server_dispatcher.c
src/manager/net_nfc_server_ipc.c
src/manager/net_nfc_service.c
src/manager/net_nfc_service_se.c
src/manager/net_nfc_service_tag.c
src/manager/net_nfc_service_test.c [new file with mode: 0644]
src/manager/net_nfc_util_access_control.c

index ca44b95..ac8bc49 100644 (file)
@@ -1,13 +1,24 @@
 <manifest>
        <define>
                <domain name="nfc-manager" />
+               <provide>
+                       <label name="nfc-manager::tag" />
+                       <label name="nfc-manager::p2p" />
+                       <label name="nfc-manager::admin" />
+                       <label name="nfc-manager::card_emul" />
+               </provide>
+               <request>
+                       <smack request="sys-assert::core" type="rwxat" />
+               </request>
        </define>
        <assign>
                <filesystem path="/usr/bin/nfc-manager-daemon" exec_label="nfc-manager" />
+               <filesystem path="/etc/init.d/libnfc-manager-0" label="_" exec_label="none" />
+               <filesystem path="/etc/rc.d/rc3.d/S81libnfc-manager-0" label="_" exec_label="none" />
+               <filesystem path="/etc/rc.d/rc5.d/S81libnfc-manager-0" label="_" exec_label="none" />
                <filesystem path="/usr/bin/ndef-tool" exec_label="nfc-manager" />
                <filesystem path="/usr/lib/libnfc.so.1" label="_" />
                <filesystem path="/usr/lib/libnfc.so.1.0.0" label="_" />
-               <filesystem path="/etc/init.d/libnfc-manager-0" label="_" exec_label="none"/>
        </assign>
        <request>
                <domain name="nfc-manager" />
index 18ad82b..57b6997 100644 (file)
@@ -1,12 +1,13 @@
 Name:       nfc-manager
 Summary:    NFC framework manager
-Version:    0.0.33
-Release:    1
+Version:    0.0.37
+Release:    0
 Group:      libs
 License:    Flora Software License
 Source0:    %{name}-%{version}.tar.gz
 Source1:    libnfc-manager-0.init.in
 Source2:    nfc-manager.service
+Requires:   sys-assert
 BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(gobject-2.0)
@@ -27,38 +28,48 @@ BuildRequires: pkgconfig(smartcard-service-common)
 BuildRequires: pkgconfig(libssl)
 BuildRequires: pkgconfig(pmapi)
 BuildRequires: pkgconfig(pkgmgr)
+BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: cmake
 BuildRequires: gettext-tools
 Requires(post):   /sbin/ldconfig
 Requires(post):   /usr/bin/vconftool
 requires(postun): /sbin/ldconfig
+
+
 %description
 NFC library Manager.
 
+
 %prep
 %setup -q
 
+
 %package devel
 Summary:    Download agent
 Group:      Development/Libraries
 Requires:   %{name} = %{version}-%{release}
 
+
 %description devel
 NFC library Manager (devel)
 
+
 %package -n nfc-common-lib
 Summary:    NFC common library
 Group:      Development/Libraries
 Requires:   %{name} = %{version}-%{release}
 
+
 %description -n nfc-common-lib
 NFC Common library.
 
+
 %package -n nfc-common-lib-devel
 Summary:    NFC common library (devel)
 Group:      libs
 Requires:   %{name} = %{version}-%{release}
 
+
 %description -n nfc-common-lib-devel
 NFC common library (devel)
 
@@ -71,6 +82,7 @@ LDFLAGS="$LDFLAGS" cmake .. -DCMAKE_INSTALL_PREFIX=%{_prefix}
 
 make
 
+
 %install
 cd cmake_tmp
 %make_install
@@ -85,6 +97,7 @@ mkdir -p %{buildroot}/usr/lib/systemd/system/multi-user.target.wants
 cp -af %{SOURCE2} %{buildroot}/usr/lib/systemd/system/
 ln -s ../nfc-manager.service %{buildroot}/usr/lib/systemd/system/multi-user.target.wants/nfc-manager.service
 
+
 %post
 /sbin/ldconfig
 vconftool set -t bool db/nfc/feature 1 -u 5000 -f
@@ -93,7 +106,6 @@ vconftool set -t bool db/nfc/sbeam 0 -u 5000 -f
 vconftool set -t int db/nfc/se_type 0 -u 5000 -f
 vconftool set -t bool db/nfc/predefined_item_state 0 -u 5000 -f
 vconftool set -t string db/nfc/predefined_item "None" -u 5000 -f
-
 vconftool set -t bool memory/private/nfc-manager/popup_disabled 0 -u 5000 -f
 
 ln -s /etc/init.d/libnfc-manager-0 /etc/rc.d/rc3.d/S81libnfc-manager-0 -f
@@ -103,12 +115,12 @@ mkdir -p /opt/etc/nfc_debug
 chown :5000 /opt/etc/nfc_debug
 chmod 775 /opt/etc/nfc_debug
 
-
 systemctl daemon-reload
 if [ $1 == 1 ]; then
     systemctl restart nfc-manager.service
 fi
 
+
 %postun
 /sbin/ldconfig
 mkdir -p /etc/rc.d/rc3.d
@@ -121,10 +133,13 @@ if [ $1 == 0 ]; then
 fi
 systemctl daemon-reload
 
+
 %post -n nfc-common-lib -p /sbin/ldconfig
 
+
 %postun -n nfc-common-lib -p /sbin/ldconfig
 
+
 %files
 %manifest nfc-manager.manifest
 %defattr(-,root,root,-)
@@ -138,6 +153,7 @@ systemctl daemon-reload
 /usr/lib/systemd/system/nfc-manager.service
 /usr/lib/systemd/system/multi-user.target.wants/nfc-manager.service
 
+
 %files devel
 %manifest nfc-manager-devel.manifest
 %defattr(-,root,root,-)
@@ -154,6 +170,7 @@ systemctl daemon-reload
 /usr/share/license/nfc-common-lib
 /usr/share/nfc-manager-daemon/sounds/*
 
+
 %files -n nfc-common-lib-devel
 %manifest nfc-common-lib-devel.manifest
 %defattr(-,root,root,-)
index 94e0740..849507c 100644 (file)
@@ -81,7 +81,6 @@ SET(CLIENT_HEADER
        include/net_nfc_ndef_message_handover.h
        include/net_nfc_sign_record.h
        include/net_nfc_data.h
-       include/net_nfc_apdu.h
        include/net_nfc_exchanger.h
        include/net_nfc_internal_se.h
        include/net_nfc_test.h
diff --git a/src/clientlib/include/net_nfc_apdu.h b/src/clientlib/include/net_nfc_apdu.h
deleted file mode 100755 (executable)
index 9ca81b7..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
-  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-  *
-  * Licensed under the Flora License, Version 1.0 (the "License");
-  * you may not use this file except in compliance with the License.
-  * You may obtain a copy of the License at
-
-  *     http://floralicense.org/license/
-  *
-  * Unless required by applicable law or agreed to in writing, software
-  * distributed under the License is distributed on an "AS IS" BASIS,
-  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  * See the License for the specific language governing permissions and
-  * limitations under the License.
-  */
-
-
-#ifndef __NET_NFC_APDU__
-#define __NET_NFC_APDU__
-
-#include "net_nfc_typedef.h"
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-
-typedef unsigned int apdu_slot_t;
-typedef unsigned int apdu_channel_t;
-typedef void (* net_nfc_apdu_response_cb ) (net_nfc_error_e result, apdu_channel_t channel, data_h data, void* user_data);
-
-/**
-@addtogroup NET_NFC_MANAGER_APDU
-@{
-
-*/
-
-/**
-       initialize the apdu api. the callback function will be called when the data is arrived from simcard or SE
-
-       @param[in]              callback                callback function
-       @param[in]              user_data       context value that will be delivered to the callback function
-
-       @return         return the result of the calling the function
-*/
-net_nfc_error_e net_nfc_register_apdu_cb (net_nfc_apdu_response_cb callback, void * user_data);
-
-/**
-
-       allows to select the slot. UICC or SE
-
-       <ul>
-       <li> slot# 0 : UICC     <\li>
-       <li> slot# 1 : Secure Element<\li>
-       </ul>
-
-       @param[in]              slot            slot for mms
-
-       @return         return the result of the calling the function
-*/
-net_nfc_error_e net_nfc_select_apdu_slot (apdu_slot_t slot);
-
-/**
-       Answer to reset  is the sequence of bytes output by a chip card after the card reader has electrically reset the card.
-       The ATR tells the reader which communication capabilities the card has. The format of the ATR is defined in ISO/IEC 7816-3.[1]
-       this function return ATR data if the simcard is available, or NULL will be returned
-
-       @param[out]             data            ATR data will be returned if the simcard is available.
-
-       @return         return the result of the calling the function
-
-*/
-net_nfc_error_e net_nfc_get_apdu_answer_to_reset (data_h  data);
-
-/**
-       this opens a channel to communicate with application on the simcard.
-       you may open the channel with
-
-       @param[out]             channel         return the assined chennel
-       @param[in]              aid                     application id that mached in the simcard application
-
-       @return         return the result of the calling the function
-
-*/
-net_nfc_error_e net_nfc_open_apdu_channel (apdu_channel_t *channel , net_nfc_string_t aid);
-
-/**
-       send the apud data to opened channel.
-
-       @param[in]              channel                 channel number that already opened
-       @param[in]              data                    data value that will be send
-
-       @return         return the result of the calling the function
-*/
-net_nfc_error_e net_nfc_send_apdu_command (apdu_channel_t channel, data_t data);
-
-/**
-       closes opened channel
-
-       @param[in]              channel                 channel number
-
-       @return         return the result of the calling the function
-*/
-net_nfc_error_e net_nfc_close_apdu_channel (apdu_channel_t channel);
-
-/**
-       disconnect all the channel and return to original state. it stops calling callback function
-
-       @return         return the result of the calling the function
-
-       @exception NET_NFC_NOT_REGISTERED       unset is requested but the callback was not registered before
-*/
-net_nfc_error_e net_nfc_unset_apdu_cb (void);
-
-
-/**
-@}
-*/
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
-
-
index 4583032..7addd1b 100755 (executable)
@@ -28,7 +28,7 @@ void net_nfc_client_call_dispatcher_in_ecore_main_loop(net_nfc_response_cb clien
 #else
 void net_nfc_client_call_dispatcher_in_current_context(net_nfc_response_cb client_cb, net_nfc_response_msg_t* msg);
 #endif
-bool net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg);
+net_nfc_error_e net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg);
 
 #endif
 
index 5fef309..edc5a7e 100755 (executable)
@@ -25,8 +25,8 @@ net_nfc_error_e net_nfc_client_socket_initialize();
 void net_nfc_client_socket_finalize();
 bool net_nfc_client_is_connected();
 
-net_nfc_error_e net_nfc_client_send_reqeust(net_nfc_request_msg_t *msg, ...);
-net_nfc_error_e net_nfc_client_send_reqeust_sync(net_nfc_request_msg_t *msg, ...);
+net_nfc_error_e net_nfc_client_send_request(net_nfc_request_msg_t *msg, ...);
+net_nfc_error_e net_nfc_client_send_request_sync(net_nfc_request_msg_t *msg, ...);
 
 void _net_nfc_client_set_cookies(const char * cookie, size_t size);
 void _net_nfc_client_free_cookies(void);
index 5acab58..c1fbf21 100755 (executable)
@@ -1,31 +1,29 @@
 /*
-  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-  *
-  * Licensed under the Flora License, Version 1.0 (the "License");
-  * you may not use this file except in compliance with the License.
-  * You may obtain a copy of the License at
-
-  *     http://floralicense.org/license/
-  *
-  * Unless required by applicable law or agreed to in writing, software
-  * distributed under the License is distributed on an "AS IS" BASIS,
-  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  * See the License for the specific language governing permissions and
-  * limitations under the License.
-  */
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 #ifndef __NET_NFC_INTERNAL_SE_H__
 #define __NET_NFC_INTERNAL_SE_H__
 
 #include "net_nfc_typedef.h"
 
-
 #ifdef __cplusplus
- extern "C" {
+extern "C"
+{
 #endif
 
-
 /**
 
 @addtogroup NET_NFC_MANAGER_SECURE_ELEMENT
 
         NFC Manager defines are defined in <net_nfc_typedef.h>
 
-        @li @c #net_nfc_set_secure_element_type                set secure element type
-        @li @c #net_nfc_get_secure_element_type                get current selected secure element
-        @li @c #net_nfc_open_internal_secure_element   open selected secure element
-        @li @c #net_nfc_close_internal_secure_element  close selected secure element
-        @li @c #net_nfc_send_apdu                                              send apdu
-
-
-
+        @li @c #net_nfc_set_secure_element_type                        set secure element type
+        @li @c #net_nfc_get_secure_element_type                        get current selected secure element
+        @li @c #net_nfc_open_internal_secure_element           open selected secure element
+        @li @c #net_nfc_open_internal_secure_element_sync      open selected secure element (synchronous)
+        @li @c #net_nfc_close_internal_secure_element          close selected secure element
+        @li @c #net_nfc_close_internal_secure_element_sync     close selected secure element (synchronous)
+        @li @c #net_nfc_send_apdu                              send apdu to opened secure element
+        @li @c #net_nfc_send_apdu_sync                         send apdu to opened secure element (synchronous)
+        @li @c #net_nfc_get_atr                                        request atr of secure element
+        @li @c #net_nfc_get_atr_sync                           request atr of secure element (synchronous)
 */
 
 /**
-       set secure element type. secure element will be a UICC or ESE. only one secure element is selected in a time. external reader can communicate with
-       secure element by emitting RF
+       set secure element type. secure element will be a UICC or ESE.
+       only one secure element is selected in a time.
+       external reader can communicate with secure element by emitting RF
 
        \par Sync (or) Async: Sync
        This is a Asynchronous API
        @return         return the result of the calling the function
 
        @exception NET_NFC_INVALID_PARAM        not supported se_type
-
 */
-
-net_nfc_error_e net_nfc_set_secure_element_type(net_nfc_se_type_e se_type, void* trans_param);
+net_nfc_error_e net_nfc_set_secure_element_type(net_nfc_se_type_e se_type, void *trans_param);
 
 /**
        get current select se type.
 
-       \par Sync (or) Async: Sync
+       \par Sync (or) Async: Async
+       This is a Asynchronous API
+
+       @param[in]      trans_param             user data that will be delivered to callback
+
+       @return         return the result of the calling the function
+*/
+net_nfc_error_e net_nfc_get_secure_element_type(void *trans_param);
+
+/**
+       open and initialize the type of secure element.
+       if the type of secure element is selected, then change mode as MODE OFF
+       to prevent to be detected by external reader
+
+       \par Sync (or) Async: Async
        This is a Asynchronous API
 
        @param[in]      se_type                 secure element type
@@ -74,53 +87,96 @@ net_nfc_error_e net_nfc_set_secure_element_type(net_nfc_se_type_e se_type, void*
        @return         return the result of the calling the function
 
        @exception NET_NFC_INVALID_PARAM        not supported se_type
-
 */
-
-net_nfc_error_e net_nfc_get_secure_element_type(void* trans_param);
+net_nfc_error_e net_nfc_open_internal_secure_element(net_nfc_se_type_e se_type, void *trans_param);
 
 /**
-       open and intialize the type of secure element. if the type of secure element is selected, then change mode as MODE OFF to prevent to be detected by external reader
+       open and initialize the type of secure element.
+       if the type of secure element is selected, then change mode as MODE OFF
+       to prevent to be detected by external reader
 
        \par Sync (or) Async: Sync
        This is a Asynchronous API
 
        @param[in]      se_type                 secure element type
-       @param[in]      trans_param             user data that will be delivered to callback
+       @param[out]     handle                  the handle of opened secure element
 
        @return         return the result of the calling the function
 
        @exception NET_NFC_INVALID_PARAM        not supported se_type
-
 */
-
-net_nfc_error_e net_nfc_open_internal_secure_element(net_nfc_se_type_e se_type, void* trans_param);
+net_nfc_error_e net_nfc_open_internal_secure_element_sync(net_nfc_se_type_e se_type, net_nfc_target_handle_h *handle);
 
 /**
-       close opend secure element and change back to previous setting
+       close opened secure element and change back to previous setting
 
-       \par Sync (or) Async: Sync
+       \par Sync (or) Async: Async
        This is a Asynchronous API
 
-       @param[in]      handle                  the handle of opend secure element
+       @param[in]      handle                  the handle of opened secure element
        @param[in]      trans_param             user data that will be delivered to callback
 
        @return         return the result of the calling the function
 
-       @exception NET_NFC_INVALID_PARAM        not supported se_type
+       @exception NET_NFC_INVALID_PARAM        invalid secure element handle
+*/
+net_nfc_error_e net_nfc_close_internal_secure_element(net_nfc_target_handle_h handle, void *trans_param);
+
+/**
+       close opened secure element and change back to previous setting
+
+       \par Sync (or) Async: Sync
+       This is a Asynchronous API
+
+       @param[in]      handle                  the handle of opened secure element
 
+       @return         return the result of the calling the function
+
+       @exception NET_NFC_INVALID_PARAM        invalid secure element handle
 */
+net_nfc_error_e net_nfc_close_internal_secure_element_sync(net_nfc_target_handle_h handle);
+
+/**
+       send apdu to opened secure element
+
+       \par Sync (or) Async: Async
+       This is a Asynchronous API
+
+       @param[in]      handle                  the handle of opened secure element
+       @param[in]      apdu                    apdu command to send
+       @param[in]      trans_param             user data that will be delivered to callback
+
+       @return         return the result of the calling the function
 
-net_nfc_error_e net_nfc_close_internal_secure_element(net_nfc_target_handle_h handle, void* trans_param);
+       @exception NET_NFC_INVALID_PARAM        invalid secure element handle
+       @exception NET_NFC_NULL_PARAM           data is null or empty
+*/
+net_nfc_error_e net_nfc_send_apdu(net_nfc_target_handle_h handle, data_h apdu, void *trans_param);
 
 /**
-       send apdu to opend secure element
+       send apdu to opened secure element
 
-       \par Sync (or) Async: Sync
+       \par Sync (or) Async: Async
        This is a Asynchronous API
 
-       @param[in]      handle                  the handle of opend secure element
+       @param[in]      handle                  the handle of opened secure element
        @param[in]      apdu                    apdu command to send
+       @param[out]     response                result of apdu
+
+       @return         return the result of the calling the function
+
+       @exception NET_NFC_INVALID_PARAM        invalid secure element handle or parameter
+       @exception NET_NFC_NULL_PARAM           data is null or empty
+*/
+net_nfc_error_e net_nfc_send_apdu_sync(net_nfc_target_handle_h handle, data_h apdu, data_h *response);
+
+/**
+       request atr of secure element
+
+       \par Sync (or) Async: Async
+       This is a Asynchronous API
+
+       @param[in]      handle                  the handle of opened secure element
        @param[in]      trans_param             user data that will be delivered to callback
 
        @return         return the result of the calling the function
@@ -128,9 +184,23 @@ net_nfc_error_e net_nfc_close_internal_secure_element(net_nfc_target_handle_h ha
        @exception NET_NFC_INVALID_PARAM        invalid
 
 */
+net_nfc_error_e net_nfc_get_atr(net_nfc_target_handle_h handle, void *trans_param);
+
+/**
+       request atr of secure element
 
-net_nfc_error_e net_nfc_send_apdu(net_nfc_target_handle_h handle, data_h apdu, void* trans_param);
+       \par Sync (or) Async: Sync
+       This is a Asynchronous API
+
+       @param[in]      handle                  the handle of opened secure element
+       @param[out]     atr                     Answer to reset of secure element
+
+       @return         return the result of the calling the function
+
+       @exception NET_NFC_INVALID_PARAM        invalid
 
+*/
+net_nfc_error_e net_nfc_get_atr_sync(net_nfc_target_handle_h handle, data_h *atr);
 
 #ifdef __cplusplus
 }
index 4c259a8..e82e90d 100755 (executable)
@@ -233,6 +233,23 @@ static bool net_nfc_client_dispatch_response(client_dispatcher_param_t *param)
                }
                break;
 
+       case NET_NFC_MESSAGE_GET_ATR_SE :
+               {
+                       data_s *atr = &(((net_nfc_response_get_atr_t *)msg->detail_message)->data);
+
+                       if (atr->length > 0)
+                       {
+                               if (client_cb != NULL)
+                                       client_cb(msg->response_type, ((net_nfc_response_get_atr_t *)msg->detail_message)->result, atr, client_context->register_user_param, (void *)((net_nfc_response_get_atr_t *)(msg->detail_message))->user_param);
+                       }
+                       else
+                       {
+                               if (client_cb != NULL)
+                                       client_cb(msg->response_type, ((net_nfc_response_get_atr_t *)msg->detail_message)->result, NULL, client_context->register_user_param, (void *)((net_nfc_response_get_atr_t *)(msg->detail_message))->user_param);
+                       }
+               }
+               break;
+
        case NET_NFC_MESSAGE_NOTIFY :
                {
                        if (client_cb != NULL)
@@ -247,7 +264,7 @@ static bool net_nfc_client_dispatch_response(client_dispatcher_param_t *param)
                        if (data->length > 0)
                        {
                                if (client_cb != NULL)
-                                       client_cb(msg->response_type, ((net_nfc_response_transceive_t *)msg->detail_message)->result, data, client_context->register_user_param, ((net_nfc_response_transceive_t *)(msg->detail_message))->trans_param);
+                                       client_cb(msg->response_type, ((net_nfc_response_transceive_t *)msg->detail_message)->result, (void *)data, client_context->register_user_param, ((net_nfc_response_transceive_t *)(msg->detail_message))->trans_param);
                        }
                        else
                        {
@@ -856,13 +873,11 @@ static bool net_nfc_client_dispatch_response(client_dispatcher_param_t *param)
        return false;
 }
 
-bool net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg)
+net_nfc_error_e net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg)
 {
+       net_nfc_error_e result = NET_NFC_OK;
 //     client_context_t *client_context = NULL;
 
-       if (msg == NULL || msg->detail_message == NULL)
-               return false;
-
        DEBUG_CLIENT_MSG("synchronous callback, message = [%d]", msg->response_type);
 
 //     client_context = net_nfc_get_client_context();
@@ -879,12 +894,58 @@ bool net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg)
                break;
 
        case NET_NFC_MESSAGE_OPEN_INTERNAL_SE :
+               {
+                       net_nfc_response_open_internal_se_t *response = (net_nfc_response_open_internal_se_t *)msg->detail_message;
+                       net_nfc_target_handle_h *handle = (net_nfc_target_handle_h *)response->user_param;
+
+                       /* return */
+                       result = response->result;
+
+                       if (handle != NULL) {
+                               *handle = (net_nfc_target_handle_h)response->handle;
+                       }
+               }
                break;
 
        case NET_NFC_MESSAGE_CLOSE_INTERNAL_SE :
+               {
+                       net_nfc_response_close_internal_se_t *response = (net_nfc_response_close_internal_se_t *)msg->detail_message;
+
+                       /* return */
+                       result = response->result;
+               }
                break;
 
        case NET_NFC_MESSAGE_SEND_APDU_SE :
+               {
+                       net_nfc_response_send_apdu_t *response = (net_nfc_response_send_apdu_t *)msg->detail_message;
+                       data_h *data = (data_h *)response->user_param;
+
+                       /* return */
+                       result = response->result;
+
+                       if (data != NULL && response->data.buffer != NULL &&
+                               response->data.length > 0) {
+                               net_nfc_create_data(data, response->data.buffer,
+                                       response->data.length);
+                       }
+               }
+               break;
+
+       case NET_NFC_MESSAGE_GET_ATR_SE :
+               {
+                       net_nfc_response_get_atr_t *response = (net_nfc_response_get_atr_t *)msg->detail_message;
+                       data_h *data = (data_h *)response->user_param;
+
+                       /* return */
+                       result = response->result;
+
+                       if (data != NULL && response->data.buffer != NULL &&
+                               response->data.length > 0) {
+                               net_nfc_create_data(data, response->data.buffer,
+                                       response->data.length);
+                       }
+               }
                break;
 
        case NET_NFC_MESSAGE_NOTIFY :
@@ -901,6 +962,9 @@ bool net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg)
                        net_nfc_response_is_tag_connected_t *response = (net_nfc_response_is_tag_connected_t *)msg->detail_message;
                        net_nfc_response_is_tag_connected_t *context = (net_nfc_response_is_tag_connected_t *)response->trans_param;
 
+                       /* return */
+                       result = response->result;
+
                        if (context != NULL)
                        {
                                context->result = response->result;
@@ -938,6 +1002,9 @@ bool net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg)
                        net_nfc_response_get_current_tag_info_t *response = (net_nfc_response_get_current_tag_info_t *)msg->detail_message;
                        net_nfc_response_get_current_tag_info_t *context = (net_nfc_response_get_current_tag_info_t *)response->trans_param;
 
+                       /* return */
+                       result = response->result;
+
                        if (context != NULL)
                        {
                                context->result = response->result;
@@ -980,6 +1047,9 @@ bool net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg)
                        net_nfc_response_get_current_target_handle_t *response = (net_nfc_response_get_current_target_handle_t *)msg->detail_message;
                        net_nfc_response_get_current_target_handle_t *context = (net_nfc_response_get_current_target_handle_t *)response->trans_param;
 
+                       /* return */
+                       result = response->result;
+
                        if (context != NULL)
                        {
                                context->handle = response->handle;
@@ -1057,11 +1127,11 @@ bool net_nfc_client_dispatch_sync_response(net_nfc_response_msg_t *msg)
                break;
        }
 
-       /* client  callback must copy data to client area */
+       /* client callback must copy data to client area */
        net_nfc_util_mem_free_detail_msg(NET_NFC_UTIL_MSG_TYPE_RESPONSE, msg->response_type, msg->detail_message);
        _net_nfc_util_free_mem(msg);
 
-       return false;
+       return result;
 }
 
 static net_nfc_error_e net_nfc_get_tag_info_list(data_s *values, int number_of_keys, net_nfc_tag_info_s **list)
index 35dd38b..f1aecd3 100755 (executable)
@@ -135,7 +135,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_send_exchanger_data(net_nfc_exchanger
 
        memcpy(&request->data.buffer, ex_data->binary_data.buffer, request->data.length);
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
 
        _net_nfc_util_free_mem(request);
 
@@ -166,7 +166,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_exchanger_request_connection_handover
        request->handle = (net_nfc_target_handle_s *)target_handle;
        request->type = type;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
 
        _net_nfc_util_free_mem(request);
 
index 839ee56..604daf6 100755 (executable)
@@ -1,35 +1,32 @@
 /*
-  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-  *
-  * Licensed under the Flora License, Version 1.0 (the "License");
-  * you may not use this file except in compliance with the License.
-  * You may obtain a copy of the License at
-
-  *     http://floralicense.org/license/
-  *
-  * Unless required by applicable law or agreed to in writing, software
-  * distributed under the License is distributed on an "AS IS" BASIS,
-  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  * See the License for the specific language governing permissions and
-  * limitations under the License.
-  */
-
-
-#include "net_nfc_tag.h"
-#include "net_nfc_typedef_private.h"
-#include "net_nfc_client_ipc_private.h"
-#include "net_nfc_debug_private.h"
-#include "net_nfc_util_private.h"
-#include "net_nfc_client_nfc_private.h"
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 #include <string.h>
 #include <pthread.h>
 
+#include "net_nfc_typedef_private.h"
+#include "net_nfc_debug_private.h"
+#include "net_nfc_util_private.h"
+#include "net_nfc_client_ipc_private.h"
+
 #ifndef NET_NFC_EXPORT_API
 #define NET_NFC_EXPORT_API __attribute__((visibility("default")))
 #endif
 
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_secure_element_type(net_nfc_se_type_e se_type, voidtrans_param)
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_secure_element_type(net_nfc_se_type_e se_type, void *trans_param)
 {
        net_nfc_error_e ret;
        net_nfc_request_set_se_t request = { 0, };
@@ -44,12 +41,12 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_secure_element_type(net_nfc_se_ty
        request.se_type = se_type;
        request.trans_param = trans_param;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
 
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_secure_element_type(voidtrans_param)
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_secure_element_type(void *trans_param)
 {
        net_nfc_error_e ret;
        net_nfc_request_get_se_t request = { 0, };
@@ -58,12 +55,12 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_secure_element_type(void* trans_p
        request.request_type = NET_NFC_MESSAGE_GET_SE;
        request.trans_param = trans_param;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
 
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_open_internal_secure_element(net_nfc_se_type_e se_type, voidtrans_param)
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_open_internal_secure_element(net_nfc_se_type_e se_type, void *trans_param)
 {
        net_nfc_error_e ret;
        net_nfc_request_open_internal_se_t request = { 0, };
@@ -78,11 +75,41 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_open_internal_secure_element(net_nfc_
        request.se_type = se_type;
        request.trans_param = trans_param;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
 
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_open_internal_secure_element_sync(net_nfc_se_type_e se_type, net_nfc_target_handle_h *handle)
+{
+       net_nfc_request_open_internal_se_t request = { 0, };
+       net_nfc_target_handle_h temp = NULL;
+       net_nfc_error_e result;
+
+       if (se_type < NET_NFC_SE_TYPE_NONE || se_type > NET_NFC_SE_TYPE_UICC) {
+               return NET_NFC_INVALID_PARAM;
+       }
+
+       request.length = sizeof(net_nfc_request_open_internal_se_t);
+       request.request_type = NET_NFC_MESSAGE_OPEN_INTERNAL_SE;
+       request.se_type = se_type;
+       request.user_param = (uint32_t)&temp;
+
+       result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
+       if (result == NET_NFC_OK) {
+               if (temp != NULL) {
+                       *handle = temp;
+               } else {
+                       DEBUG_ERR_MSG("NULL handle returned data returned");
+                       result = NET_NFC_OPERATION_FAIL;
+               }
+       } else{
+               DEBUG_ERR_MSG("net_nfc_client_send_request_sync failed [%d]", result);
+       }
+
+       return result;
+}
+
 NET_NFC_EXPORT_API net_nfc_error_e net_nfc_close_internal_secure_element(net_nfc_target_handle_h handle, void *trans_param)
 {
        net_nfc_error_e ret;
@@ -98,12 +125,30 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_close_internal_secure_element(net_nfc
        request.handle = (net_nfc_target_handle_s *)handle;
        request.trans_param = trans_param;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
 
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_send_apdu(net_nfc_target_handle_h handle, data_h apdu, void* trans_param)
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_close_internal_secure_element_sync(net_nfc_target_handle_h handle)
+{
+       net_nfc_error_e result;
+       net_nfc_request_close_internal_se_t request = { 0, };
+
+       if (handle == NULL) {
+               return NET_NFC_NULL_PARAMETER;
+       }
+
+       request.length = sizeof(net_nfc_request_close_internal_se_t);
+       request.request_type = NET_NFC_MESSAGE_CLOSE_INTERNAL_SE;
+       request.handle = (net_nfc_target_handle_s *)handle;
+
+       result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
+
+       return result;
+}
+
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_send_apdu(net_nfc_target_handle_h handle, data_h apdu, void *trans_param)
 {
        net_nfc_error_e ret;
        net_nfc_request_send_apdu_t *request = NULL;
@@ -131,10 +176,102 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_send_apdu(net_nfc_target_handle_h han
        request->data.length = apdu_data->length;
        memcpy(&request->data.buffer, apdu_data->buffer, request->data.length);
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
+
+       _net_nfc_util_free_mem(request);
+
+       return ret;
+}
+
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_send_apdu_sync(net_nfc_target_handle_h handle, data_h apdu, data_h *response)
+{
+       net_nfc_request_send_apdu_t *request = NULL;
+       data_s *apdu_data = (data_s *)apdu;
+       net_nfc_error_e result;
+       uint32_t length;
+       data_h resp = NULL;
+
+       if (handle == NULL || apdu_data == NULL || apdu_data->buffer == NULL || apdu_data->length == 0)
+       {
+               return NET_NFC_NULL_PARAMETER;
+       }
+
+       length = sizeof(net_nfc_request_send_apdu_t) + apdu_data->length;
+
+       _net_nfc_util_alloc_mem(request, length);
+       if (request == NULL)
+       {
+               return NET_NFC_ALLOC_FAIL;
+       }
+
+       request->length = length;
+       request->request_type = NET_NFC_MESSAGE_SEND_APDU_SE;
+       request->handle = (net_nfc_target_handle_s *)handle;
+       request->user_param = (uint32_t)&resp;
+
+       request->data.length = apdu_data->length;
+       memcpy(&request->data.buffer, apdu_data->buffer, request->data.length);
+
+       result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)request, NULL);
+       if (result == NET_NFC_OK) {
+               if (resp != NULL) {
+                       *response = resp;
+               } else {
+                       DEBUG_ERR_MSG("NULL response returned");
+                       result = NET_NFC_OPERATION_FAIL;
+               }
+       } else {
+               DEBUG_ERR_MSG("net_nfc_client_send_request_sync failed [%d]", result);
+       }
 
        _net_nfc_util_free_mem(request);
 
+       return result;
+}
+
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_atr(net_nfc_target_handle_h handle, void *trans_param)
+{
+       net_nfc_error_e ret;
+       net_nfc_request_get_atr_t request = { 0, };
+
+       if (handle == NULL)
+       {
+               return NET_NFC_NULL_PARAMETER;
+       }
+
+       request.length = sizeof(net_nfc_request_get_atr_t);
+       request.request_type = NET_NFC_MESSAGE_GET_ATR_SE;
+       request.handle = (net_nfc_target_handle_s *)handle;
+       request.user_param = (uint32_t)trans_param;
+
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
+
        return ret;
 }
 
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_atr_sync(net_nfc_target_handle_h handle, data_h *atr)
+{
+       net_nfc_request_get_atr_t request = { 0, };
+       data_h response = NULL;
+       net_nfc_error_e result;
+
+       if (handle == NULL) {
+               return NET_NFC_NULL_PARAMETER;
+       }
+
+       request.length = sizeof(net_nfc_request_get_atr_t);
+       request.request_type = NET_NFC_MESSAGE_GET_ATR_SE;
+       request.handle = (net_nfc_target_handle_s *)handle;
+       request.user_param = (uint32_t)&response;
+
+       result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
+       if (result == NET_NFC_OK) {
+               if (response != NULL) {
+                       *atr = response;
+               } else {
+                       result = NET_NFC_OPERATION_FAIL;
+               }
+       }
+
+       return result;
+}
index e23fa1c..db7591d 100755 (executable)
@@ -44,6 +44,7 @@ static pthread_mutex_t g_client_ipc_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t g_client_ipc_cond = PTHREAD_COND_INITIALIZER;
 static pthread_mutex_t cb_lock = PTHREAD_MUTEX_INITIALIZER;
 static net_nfc_response_cb client_cb = NULL;
+static net_nfc_error_e sync_result;
 
 #ifdef G_MAIN_LOOP
 static GIOChannel *g_client_channel = NULL;
@@ -90,10 +91,17 @@ static void net_nfc_client_prepare_sync_call(net_nfc_request_msg_t *msg)
 static net_nfc_error_e net_nfc_client_wait_sync_call(int timeout)
 {
        net_nfc_error_e result = NET_NFC_OPERATION_FAIL;
+       struct timeval now;
+       struct timespec ts;
 
-       if (pthread_cond_wait(&g_client_ipc_cond, &g_client_ipc_mutex) == 0)
+       gettimeofday(&now, NULL);
+       ts.tv_sec = now.tv_sec + timeout;
+       ts.tv_nsec = now.tv_usec * 1000;
+
+       if (pthread_cond_timedwait(&g_client_ipc_cond, &g_client_ipc_mutex,
+               &ts) == 0)
        {
-               result = NET_NFC_OK;
+               result = sync_result;
        }
 
        return result;
@@ -109,8 +117,10 @@ static void net_nfc_client_recv_sync_call()
        net_nfc_client_ipc_lock();
 }
 
-static void net_nfc_client_notify_sync_call()
+static void net_nfc_client_notify_sync_call(net_nfc_error_e result)
 {
+       sync_result = result;
+
        pthread_cond_signal(&g_client_ipc_cond);
        net_nfc_client_ipc_unlock();
 }
@@ -429,20 +439,22 @@ static void *net_nfc_client_ipc_thread(void *data)
                        msg = net_nfc_client_read_response_msg(&result);
 
                        pthread_mutex_lock(&cb_lock);
-                       if (msg != NULL)
+                       if (msg != NULL && msg->detail_message != NULL)
                        {
                                /* TODO : need to remove */
                                net_nfc_response_msg_t *temp = (net_nfc_response_msg_t *)(msg->detail_message);
 ;
                                if (NET_NFC_FLAGS_IS_SYNC_CALL(temp->flags))
                                {
+                                       net_nfc_error_e result;
+
                                        net_nfc_client_recv_sync_call();
 
                                        /* call a callback in IPC thread */
-                                       net_nfc_client_dispatch_sync_response(msg);
+                                       result = net_nfc_client_dispatch_sync_response(msg);
 
                                        /* unset sync call flag */
-                                       net_nfc_client_notify_sync_call();
+                                       net_nfc_client_notify_sync_call(result);
                                }
                                else
                                {
@@ -1645,7 +1657,7 @@ static net_nfc_error_e _send_request(net_nfc_request_msg_t *msg, va_list list)
        }
 }
 
-net_nfc_error_e net_nfc_client_send_reqeust(net_nfc_request_msg_t *msg, ...)
+net_nfc_error_e net_nfc_client_send_request(net_nfc_request_msg_t *msg, ...)
 {
        va_list list;
        net_nfc_error_e result = NET_NFC_OK;
@@ -1663,7 +1675,7 @@ net_nfc_error_e net_nfc_client_send_reqeust(net_nfc_request_msg_t *msg, ...)
        return result;
 }
 
-net_nfc_error_e net_nfc_client_send_reqeust_sync(net_nfc_request_msg_t *msg, ...)
+net_nfc_error_e net_nfc_client_send_request_sync(net_nfc_request_msg_t *msg, ...)
 {
        va_list list;
        net_nfc_error_e result = NET_NFC_OK;
@@ -1678,7 +1690,7 @@ net_nfc_error_e net_nfc_client_send_reqeust_sync(net_nfc_request_msg_t *msg, ...
 
        if (result == NET_NFC_OK)
        {
-               result = net_nfc_client_wait_sync_call(0);
+               result = net_nfc_client_wait_sync_call(3);
        }
        net_nfc_client_post_sync_call();
 
@@ -1712,4 +1724,3 @@ net_nfc_error_e _net_nfc_client_unregister_cb(void)
 
        return NET_NFC_OK;
 }
-
index d983af9..1c955a7 100755 (executable)
@@ -356,7 +356,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_listen_llcp(net_nfc_llcp_socket_t soc
        request->service_name.length = srv_name_count;
        memcpy(&request->service_name.buffer, psocket_data->service_name, request->service_name.length);
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
 
        _net_nfc_util_free_mem(request);
 
@@ -388,7 +388,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_disconnect_llcp(net_nfc_llcp_socket_t
        request.client_socket = psocket_data->client_socket;
        request.trans_param = trans_param;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        pthread_mutex_unlock(&llcp_lock);
 
@@ -425,7 +425,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_close_llcp_socket(net_nfc_llcp_socket
        request.client_socket = psocket_data->client_socket;
        request.trans_param = trans_param;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        _remove_internal_socket(psocket_data);
 
@@ -477,7 +477,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_send_llcp(net_nfc_llcp_socket_t socke
        request->data.length = data_private->length;
        memcpy(&request->data.buffer, data_private->buffer, request->data.length);
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
 
        _net_nfc_util_free_mem(request);
 
@@ -511,7 +511,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_receive_llcp(net_nfc_llcp_socket_t so
        request.trans_param = trans_param;
        request.req_length = req_length;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        pthread_mutex_unlock(&llcp_lock);
 
@@ -561,7 +561,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_send_to_llcp(net_nfc_llcp_socket_t so
        request->data.length = data_private->length;
        memcpy(&request->data.buffer, data_private->buffer, request->data.length);
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
 
        _net_nfc_util_free_mem(request);
 
@@ -595,7 +595,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_receive_from_llcp(net_nfc_llcp_socket
        request.trans_param = trans_param;
        request.req_length = req_length;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        pthread_mutex_unlock(&llcp_lock);
 
@@ -629,7 +629,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_connect_llcp_with_sap(net_nfc_llcp_so
        request.miu = psocket_data->miu;
        request.rw = psocket_data->rw;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        pthread_mutex_unlock(&llcp_lock);
 
@@ -678,7 +678,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_connect_llcp(net_nfc_llcp_socket_t so
        request->service_name.length = svc_name_length;
        memcpy(&request->service_name.buffer, service_name, request->service_name.length);
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
 
        _net_nfc_util_free_mem(request);
 
@@ -749,7 +749,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_llcp_local_configure(net_nfc_llcp
        request.trans_param = trans_param;
        memcpy(&(request.config), config, sizeof(net_nfc_llcp_config_info_s));
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
@@ -1052,7 +1052,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_current_target_handle(void *trans
        request.request_type = NET_NFC_MESSAGE_GET_CURRENT_TARGET_HANDLE;
        request.trans_param = trans_param;
 
-       result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       result = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return result;
 }
@@ -1067,7 +1067,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_current_target_handle_sync(net_nf
        request.request_type = NET_NFC_MESSAGE_GET_CURRENT_TARGET_HANDLE;
        request.trans_param = (void *)&response;
 
-       result = net_nfc_client_send_reqeust_sync((net_nfc_request_msg_t *)&request, NULL);
+       result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
        if (result == NET_NFC_OK)
        {
                *handle = (net_nfc_target_handle_h)response.handle;
index 125b0ce..26ef548 100755 (executable)
@@ -4,7 +4,7 @@
  * Licensed under the Flora License, Version 1.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
-
+ *
  *     http://floralicense.org/license/
  *
  * Unless required by applicable law or agreed to in writing, software
@@ -308,7 +308,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_launch_popup_state(int enable)
        request.request_type = NET_NFC_MESSAGE_SERVICE_SET_LAUNCH_STATE;
        request.set_launch_popup = enable;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
@@ -415,7 +415,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_state_activate(void)
        request.request_type = NET_NFC_MESSAGE_SERVICE_CHANGE_CLIENT_STATE;
        request.client_state = NET_NFC_CLIENT_ACTIVE_STATE;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
@@ -429,7 +429,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_state_deactivate(void)
        request.request_type = NET_NFC_MESSAGE_SERVICE_CHANGE_CLIENT_STATE;
        request.client_state = NET_NFC_CLIENT_INACTIVE_STATE;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
@@ -461,7 +461,7 @@ net_nfc_error_e net_nfc_send_init(void *context)
        req_msg.request_type = NET_NFC_MESSAGE_SERVICE_INIT;
        req_msg.user_param = (uint32_t)context;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&req_msg, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&req_msg, NULL);
 
        return ret;
 }
@@ -475,7 +475,7 @@ net_nfc_error_e net_nfc_send_deinit(void *context)
        req_msg.request_type = NET_NFC_MESSAGE_SERVICE_DEINIT;
        req_msg.user_param = (uint32_t)context;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&req_msg, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&req_msg, NULL);
 
        return ret;
 }
index 7a3e74b..f98540b 100755 (executable)
@@ -14,6 +14,9 @@
  * limitations under the License.
  */
 
+#include <string.h>
+#include <pthread.h>
+
 #include "net_nfc_tag.h"
 #include "net_nfc_typedef_private.h"
 #include "net_nfc_client_ipc_private.h"
@@ -22,9 +25,6 @@
 #include "net_nfc_util_ndef_message.h"
 #include "net_nfc_client_nfc_private.h"
 
-#include <string.h>
-#include <pthread.h>
-
 #ifndef NET_NFC_EXPORT_API
 #define NET_NFC_EXPORT_API __attribute__((visibility("default")))
 #endif
@@ -64,7 +64,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_format_ndef(net_nfc_target_handle_h h
                memcpy(&request->key.buffer, struct_key->buffer, request->key.length);
        }
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
 
        _net_nfc_util_free_mem(request);
 
@@ -214,7 +214,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_transceive(net_nfc_target_handle_h ha
        request->trans_param = trans_param;
        request->info.dev_type = (uint32_t)target_info->devType;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
 
        _net_nfc_util_free_mem(request);
 
@@ -243,7 +243,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_read_tag(net_nfc_target_handle_h hand
        request.handle = (net_nfc_target_handle_s *)handle;
        request.trans_param = trans_param;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
@@ -299,7 +299,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_write_ndef(net_nfc_target_handle_h ha
                return result;
        }
 
-       result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+       result = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
 
        _net_nfc_util_free_mem(request);
 
@@ -315,7 +315,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_is_tag_connected(void *trans_param)
        request.request_type = NET_NFC_MESSAGE_IS_TAG_CONNECTED;
        request.trans_param = trans_param;
 
-       result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       result = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return result;
 }
@@ -333,11 +333,10 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_is_tag_connected_sync(int *dev_type)
        request.request_type = NET_NFC_MESSAGE_IS_TAG_CONNECTED;
        request.trans_param = (void *)&context;
 
-       result = net_nfc_client_send_reqeust_sync((net_nfc_request_msg_t *)&request, NULL);
+       result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
        if (result == NET_NFC_OK)
        {
                *dev_type = context.devType;
-               result = context.result;
        }
 
        return result;
@@ -365,7 +364,6 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_make_read_only_ndef_tag(net_nfc_targe
        tmp_client_context = net_nfc_get_client_context();
        if (tmp_client_context != NULL)
        {
-
                target_info = tmp_client_context->target_info;
 
                if (target_info != NULL)
@@ -400,7 +398,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_make_read_only_ndef_tag(net_nfc_targe
        request.handle = (net_nfc_target_handle_s *)handle;
        request.trans_param = trans_param;
 
-       result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       result = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return result;
 }
@@ -414,7 +412,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_current_tag_info(void *trans_para
        request.request_type = NET_NFC_MESSAGE_GET_CURRENT_TAG_INFO;
        request.trans_param = trans_param;
 
-       result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       result = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return result;
 }
@@ -429,15 +427,11 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_current_tag_info_sync(net_nfc_tar
        request.request_type = NET_NFC_MESSAGE_GET_CURRENT_TAG_INFO;
        request.trans_param = (void *)&response;
 
-       result = net_nfc_client_send_reqeust_sync((net_nfc_request_msg_t *)&request, NULL);
+       result = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
        if (result == NET_NFC_OK)
        {
-               result = response.result;
-               if (response.result == NET_NFC_OK)
-               {
-                       /* already allocated memory */
-                       *info = (net_nfc_target_info_h)response.trans_param;
-               }
+               /* already allocated memory */
+               *info = (net_nfc_target_info_h)response.trans_param;
        }
 
        return result;
index 1069c6b..0e95188 100644 (file)
@@ -83,7 +83,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_sim_test(void)
        request.length = sizeof(net_nfc_request_test_t);
        request.request_type = NET_NFC_MESSAGE_SIM_TEST;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
@@ -98,7 +98,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_prbs_test(int tech, int rate)
        request.rate = rate;
        request.tech = tech;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
@@ -111,7 +111,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_firmware_version(void)
        request.length = sizeof(net_nfc_request_msg_t);
        request.request_type = NET_NFC_MESSAGE_GET_FIRMWARE_VERSION;
 
-       ret = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)&request, NULL);
+       ret = net_nfc_client_send_request((net_nfc_request_msg_t *)&request, NULL);
 
        return ret;
 }
@@ -140,7 +140,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_eedata_register(int mode, int reg
        request->data.length = len;
        memcpy(request->data.buffer, data, len);
 
-       result = net_nfc_client_send_reqeust((net_nfc_request_msg_t *)request, NULL);
+       result = net_nfc_client_send_request((net_nfc_request_msg_t *)request, NULL);
 
        _net_nfc_util_free_mem(request);
 
index 243ff4e..18d2589 100644 (file)
@@ -24,27 +24,27 @@ typedef bool (*net_nfc_oem_controller_init)(net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_deinit)(void);
 typedef bool (*net_nfc_oem_controller_register_listener)(target_detection_listener_cb target_detection_listener, se_transaction_listener_cb se_transaction_listener, llcp_event_listener_cb llcp_event_listener, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_unregister_listener)(void);
+typedef bool (*net_nfc_oem_controller_support_nfc)(net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_get_firmware_version)(data_s **data, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_check_firmware_version)(net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_update_firmware)(net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_get_stack_information)(net_nfc_stack_information_s *stack_info, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_configure_discovery)(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e *result);
-typedef bool (*net_nfc_oem_controller_get_secure_element_list)(net_nfc_secure_element_info_s *list, int* count, net_nfc_error_e *result);
-typedef bool (*net_nfc_oem_controller_set_secure_element_mode)(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e *result);
-typedef bool (*net_nfc_oem_controller_check_target_presence)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_exception_handler)(void);
+
+/* tag api */
 typedef bool (*net_nfc_oem_controller_connect)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_disconnect)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_check_target_presence)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_check_ndef)(net_nfc_target_handle_s *handle, uint8_t *ndef_card_state, int *max_data_size, int *real_data_size, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_read_ndef)(net_nfc_target_handle_s *handle, data_s **data, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_write_ndef)(net_nfc_target_handle_s *handle, data_s *data, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_make_read_only_ndef)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_format_ndef)(net_nfc_target_handle_s *handle, data_s *secure_key, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_transceive)(net_nfc_target_handle_s *handle, net_nfc_transceive_info_s *info, data_s **data, net_nfc_error_e *result);
-typedef bool (*net_nfc_oem_controller_exception_handler)(void);
 typedef bool (*net_nfc_oem_controller_is_ready)(net_nfc_error_e *result);
 
-// LLCP API DEFINE
-
+/* llcp api */
 typedef bool (*net_nfc_oem_controller_llcp_config)(net_nfc_llcp_config_info_s *config, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_llcp_check_llcp)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_llcp_activate_llcp)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
@@ -64,13 +64,19 @@ typedef bool (*net_nfc_oem_controller_llcp_reject)(net_nfc_target_handle_s *hand
 typedef bool (*net_nfc_oem_controller_llcp_get_remote_config)(net_nfc_target_handle_s *handle, net_nfc_llcp_config_info_s *config, net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_llcp_get_remote_socket_info)(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_llcp_socket_option_s *option, net_nfc_error_e *result);
 
+/* secure element api */
+typedef bool (*net_nfc_oem_controller_get_secure_element_list)(net_nfc_secure_element_info_s *list, int* count, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_set_secure_element_mode)(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_secure_element_open)(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s **handle, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_secure_element_get_atr)(net_nfc_target_handle_s *handle, data_s **atr, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_secure_element_send_apdu)(net_nfc_target_handle_s *handle, data_s *command, data_s **response, net_nfc_error_e *result);
+typedef bool (*net_nfc_oem_controller_secure_element_close)(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
+
+/* test api */
 typedef bool (*net_nfc_oem_controller_sim_test)(net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_prbs_test)(net_nfc_error_e *result , int tech , int rate);
-
 typedef bool (*net_nfc_oem_controller_test_mode_on)(net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_test_mode_off)(net_nfc_error_e *result);
-
-typedef bool (*net_nfc_oem_controller_support_nfc)(net_nfc_error_e *result);
 typedef bool (*net_nfc_oem_controller_eedata_register_set)(net_nfc_error_e *result , uint32_t mode , uint32_t reg_id , data_s *data);
 
 typedef struct _net_nfc_oem_interface_s
@@ -125,6 +131,10 @@ typedef struct _net_nfc_oem_interface_s
        net_nfc_oem_controller_support_nfc support_nfc;
        net_nfc_oem_controller_eedata_register_set eedata_register_set;
 
+       net_nfc_oem_controller_secure_element_open secure_element_open;
+       net_nfc_oem_controller_secure_element_get_atr secure_element_get_atr;
+       net_nfc_oem_controller_secure_element_send_apdu secure_element_send_apdu;
+       net_nfc_oem_controller_secure_element_close secure_element_close;
 } net_nfc_oem_interface_s;
 
 #endif
index ec4d7ba..bd723fa 100644 (file)
@@ -206,6 +206,7 @@ typedef enum
        NET_NFC_MESSAGE_OPEN_INTERNAL_SE,
        NET_NFC_MESSAGE_CLOSE_INTERNAL_SE,
        NET_NFC_MESSAGE_SEND_APDU_SE,
+       NET_NFC_MESSAGE_GET_ATR_SE,
        NET_NFC_GET_SERVER_STATE,
 
        NET_NFC_MESSAGE_SIM_TEST,
@@ -367,23 +368,23 @@ typedef enum
        NET_NFC_NPP,
 } llcp_app_protocol_e;
 
-typedef struct data_s *data_h;
+typedef struct _data_s *data_h;
 
-typedef struct ndef_record_s *ndef_record_h;
+typedef struct _ndef_record_s *ndef_record_h;
 
-typedef struct ndef_message_s *ndef_message_h;
+typedef struct _ndef_message_s *ndef_message_h;
 
-typedef struct net_nfc_target_info_s *net_nfc_target_info_h;
+typedef struct _net_nfc_target_info_s *net_nfc_target_info_h;
 
 typedef uint32_t net_nfc_traceive_cmd;
 
-typedef struct net_nfc_llcp_config_info_s *net_nfc_llcp_config_info_h;
+typedef struct _net_nfc_llcp_config_info_s *net_nfc_llcp_config_info_h;
 
-typedef struct net_nfc_llcp_socket_option_s *net_nfc_llcp_socket_option_h;
+typedef struct _net_nfc_llcp_socket_option_s *net_nfc_llcp_socket_option_h;
 
-typedef struct net_nfc_target_handle_s *net_nfc_target_handle_h;
+typedef struct _net_nfc_target_handle_s *net_nfc_target_handle_h;
 
-typedef struct net_nfc_connection_handover_info_s *net_nfc_connection_handover_info_h;
+typedef struct _net_nfc_connection_handover_info_s *net_nfc_connection_handover_info_h;
 
 typedef uint8_t sap_t;
 
@@ -413,7 +414,7 @@ typedef enum
        NET_NFC_EXCHANGER_RAW,
 } net_nfc_exchanger_data_type_e;
 
-typedef struct net_nfc_exchanger_data_s *net_nfc_exchanger_data_h;
+typedef struct _net_nfc_exchanger_data_s *net_nfc_exchanger_data_h;
 
 typedef net_nfc_exchanger_data_h (*net_nfc_exchanger_cb)(net_nfc_exchanger_event_e event, void *user_param);
 
@@ -433,8 +434,8 @@ typedef enum
        NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN_STATUS,
 } net_nfc_conn_handover_carrier_state_e;
 
-typedef struct net_nfc_conn_handover_carrier_info_s *net_nfc_conn_handover_carrier_info_h;
-typedef struct net_nfc_conn_handover_info_s *net_nfc_conn_handover_info_h;
+typedef struct _net_nfc_conn_handover_carrier_info_s *net_nfc_conn_handover_carrier_info_h;
+typedef struct _net_nfc_conn_handover_info_s *net_nfc_conn_handover_info_h;
 
 #define MIFARE_KEY_DEFAULT {(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF}
 #define MIFARE_KEY_APPLICATION_DIRECTORY {(uint8_t)0xA0,(uint8_t)0xA1,(uint8_t)0xA2,(uint8_t)0xA3,(uint8_t)0xA4,(uint8_t)0xA5}
@@ -487,8 +488,8 @@ typedef enum
        NET_NFC_BT_ATTRIBUTE_ADDRESS = 0xF0, /* Bluetooth device Address */
 } net_nfc_handover_bt_attribute_e;
 
-typedef struct net_nfc_carrier_config_s *net_nfc_carrier_config_h;
-typedef struct net_nfc_carrier_property_s *net_nfc_property_group_h;
+typedef struct _net_nfc_carrier_config_s *net_nfc_carrier_config_h;
+typedef struct _net_nfc_carrier_property_s *net_nfc_property_group_h;
 
 typedef enum
 {
index 1e5a4cf..a23a41c 100755 (executable)
@@ -1,29 +1,25 @@
 /*
-  * Copyright (C) 2010 NXP Semiconductors
-  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-  *
-  * Licensed under the Apache License, Version 2.0 (the "License");
-  * you may not use this file except in compliance with the License.
-  * You may obtain a copy of the License at
-  *
-  *      http://www.apache.org/licenses/LICENSE-2.0
-  *
-  * Unless required by applicable law or agreed to in writing, software
-  * distributed under the License is distributed on an "AS IS" BASIS,
-  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  * See the License for the specific language governing permissions and
-  * limitations under the License.
-  */
-
-
-
+ * Copyright (C) 2010 NXP Semiconductors
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 #ifndef __NET_NFC_INTERNAL_TYPEDEF_H__
 #define __NET_NFC_INTERNAL_TYPEDEF_H__
 
 #include "net_nfc_typedef.h"
 
-
 typedef enum
 {
        NET_NFC_POLL_START = 0x01,
@@ -57,6 +53,7 @@ typedef struct _net_nfc_target_handle_s
 {
        uint32_t connection_id;
        net_nfc_connection_type_e connection_type;
+       net_nfc_target_type_e target_type;
        /*++npp++*/
        llcp_app_protocol_e app_type;
        /*--npp--*/
@@ -782,6 +779,13 @@ typedef struct _net_nfc_request_send_apdu_t
        net_nfc_data_s data;
 } net_nfc_request_send_apdu_t;
 
+typedef struct _net_nfc_request_get_atr_t
+{
+       NET_NFC_REQUEST_MSG_HEADER
+
+       net_nfc_target_handle_s *handle;
+} net_nfc_request_get_atr_t;
+
 typedef struct _net_nfc_request_connection_handover_t
 {
        NET_NFC_REQUEST_MSG_HEADER
@@ -1104,6 +1108,13 @@ typedef struct _net_nfc_response_send_apdu_t
        void *trans_param;
 } net_nfc_response_send_apdu_t;
 
+typedef struct _net_nfc_response_get_atr_t
+{
+       NET_NFC_RESPONSE_MSG_HEADER
+
+       data_s data;
+} net_nfc_response_get_atr_t;
+
 typedef struct _net_nfc_response_get_server_state_t
 {
        NET_NFC_RESPONSE_MSG_HEADER
index 43baaf0..afd8db5 100644 (file)
@@ -14,7 +14,7 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(manager_pkges REQUIRED aul glib-2.0 gobject-2.0 security-server dbus-glib-1 vconf dlog tapi appsvc libcurl bluetooth-api heynoti smartcard-service smartcard-service-common libssl pmapi svi capi-media-wav-player pkgmgr)
+pkg_check_modules(manager_pkges REQUIRED aul glib-2.0 gobject-2.0 security-server dbus-glib-1 vconf dlog tapi appsvc libcurl bluetooth-api heynoti smartcard-service smartcard-service-common libssl pmapi svi capi-media-wav-player pkgmgr pkgmgr-info)
 
 FOREACH(flag ${manager_pkges_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 37a9c81..ab3bf32 100644 (file)
@@ -21,6 +21,7 @@
 #include "net_nfc_typedef.h"
 #include "net_nfc_typedef_private.h"
 
+/* common api */
 void* net_nfc_controller_onload(void);
 bool net_nfc_controller_unload(void* handle);
 bool net_nfc_controller_init (net_nfc_error_e* result);
@@ -32,8 +33,6 @@ bool net_nfc_controller_check_firmware_version(net_nfc_error_e* result);
 bool net_nfc_controller_update_firmware(net_nfc_error_e* result);
 bool net_nfc_controller_get_stack_information(net_nfc_stack_information_s* stack_info, net_nfc_error_e* result);
 bool net_nfc_controller_confiure_discovery (net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e* result);
-bool net_nfc_controller_get_secure_element_list(net_nfc_secure_element_info_s* list, int* count, net_nfc_error_e* result);
-bool net_nfc_controller_set_secure_element_mode(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e* result);
 bool net_nfc_controller_check_target_presence(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
 bool net_nfc_controller_connect(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
 bool net_nfc_controller_disconnect(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
@@ -46,8 +45,7 @@ bool net_nfc_controller_transceive (net_nfc_target_handle_s* handle, net_nfc_tra
 bool net_nfc_controller_exception_handler(void);
 bool net_nfc_controller_is_ready(net_nfc_error_e* result);
 
-// LLCP API DEFINE
-
+/* llcp api */
 bool net_nfc_controller_llcp_config(net_nfc_llcp_config_info_s * config, net_nfc_error_e * result);
 bool net_nfc_controller_llcp_check_llcp(net_nfc_target_handle_s* handle, net_nfc_error_e* result);
 bool net_nfc_controller_llcp_activate_llcp(net_nfc_target_handle_s * handle, net_nfc_error_e* result);
@@ -67,10 +65,15 @@ bool net_nfc_controller_llcp_reject(net_nfc_target_handle_s* handle, net_nfc_llc
 bool net_nfc_controller_llcp_get_remote_config (net_nfc_target_handle_s* handle, net_nfc_llcp_config_info_s *config, net_nfc_error_e* result);
 bool net_nfc_controller_llcp_get_remote_socket_info (net_nfc_target_handle_s* handle, net_nfc_llcp_socket_t socket, net_nfc_llcp_socket_option_s * option, net_nfc_error_e* result);
 
+/* secure element api */
+bool net_nfc_controller_secure_element_open(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s **handle, net_nfc_error_e *result);
+bool net_nfc_controller_secure_element_get_atr(net_nfc_target_handle_s *handle, data_s **atr, net_nfc_error_e *result);
+bool net_nfc_controller_secure_element_send_apdu(net_nfc_target_handle_s *handle, data_s *command, data_s **response, net_nfc_error_e *result);
+bool net_nfc_controller_secure_element_close(net_nfc_target_handle_s *handle, net_nfc_error_e *result);
+bool net_nfc_controller_get_secure_element_list(net_nfc_secure_element_info_s* list, int* count, net_nfc_error_e* result);
+bool net_nfc_controller_set_secure_element_mode(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e* result);
 
-
-// LLCP API DEFINE
-
+/* test api */
 bool net_nfc_controller_sim_test(net_nfc_error_e* result);
 bool net_nfc_controller_prbs_test(net_nfc_error_e* result , uint32_t tech , uint32_t rate);
 
index 2194d3e..c190247 100755 (executable)
@@ -1,31 +1,28 @@
 /*
-  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-  *
-  * Licensed under the Flora License, Version 1.0 (the "License");
-  * you may not use this file except in compliance with the License.
-  * You may obtain a copy of the License at
-
-  *     http://floralicense.org/license/
-  *
-  * Unless required by applicable law or agreed to in writing, software
-  * distributed under the License is distributed on an "AS IS" BASIS,
-  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  * See the License for the specific language governing permissions and
-  * limitations under the License.
-  */
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 #ifndef __NET_NFC_SERVER_DISPATCHER__
 #define __NET_NFC_SERVER_DISPATCHER__
 
 #include "net_nfc_typedef_private.h"
 
-void net_nfc_dispatcher_queue_push(net_nfc_request_msg_treq_msg);
+void net_nfc_dispatcher_queue_push(net_nfc_request_msg_t *req_msg);
 bool net_nfc_dispatcher_start_thread();
 void net_nfc_dispatcher_cleanup_queue(void);
 void net_nfc_dispatcher_put_cleaner(void);
 
-
 #endif
 
-
index 3125b32..b2615cc 100755 (executable)
@@ -1,19 +1,18 @@
 /*
-  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
-  *
-  * Licensed under the Flora License, Version 1.0 (the "License");
-  * you may not use this file except in compliance with the License.
-  * You may obtain a copy of the License at
-
-  *     http://floralicense.org/license/
-  *
-  * Unless required by applicable law or agreed to in writing, software
-  * distributed under the License is distributed on an "AS IS" BASIS,
-  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  * See the License for the specific language governing permissions and
-  * limitations under the License.
-  */
-
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 #ifndef NET_NFC_SERVICE_LLCP_PRIVATE_H
 #define NET_NFC_SERVICE_LLCP_PRIVATE_H
 /* Service Name should be followed naming rule. */
 // service access name
 
-#define SDP_SAN                                        "urn:nfc:sn:sdp"
-#define IP_SAN                                 "urn:nfc:sn:ip"
-#define SNEP_SAN                               "urn:nfc:sn:snep"
-#define OBEX_SAN                               "urn:nfc:sn:obex"
+#define SDP_SAN                        "urn:nfc:sn:sdp"
+#define IP_SAN                 "urn:nfc:sn:ip"
+#define SNEP_SAN               "urn:nfc:sn:snep"
+#define OBEX_SAN               "urn:nfc:sn:obex"
 
 #define CONN_HANDOVER_SAN      "urn:nfc:sn:handover"
 
-#define NPP_SAN                              "com.android.npp"
-#define NPP_SAP 0x10
-
-#define SDP_SAP        1    /* service discovery protocol service access point */
-#define IP_SAP 2       /* Internet protocol service access point */
-#define OBEX_SAP 3  /* ojbect exchange service access point */
-#define SNEP_SAP 4  /* simple ndef exchange protocol service access point */
+#define NPP_SAN                        "com.android.npp"
+#define NPP_SAP                        0x10
 
-#define CONN_HANDOVER_SAP 5 /* connection handover service access point */
+#define SDP_SAP                        1    /* service discovery protocol service access point */
+#define IP_SAP                 2       /* Internet protocol service access point */
+#define OBEX_SAP               3  /* ojbect exchange service access point */
+#define SNEP_SAP               4  /* simple ndef exchange protocol service access point */
 
-#define SNEP_MAJOR_VER 1
-#define SNEP_MINOR_VER 0
+#define CONN_HANDOVER_SAP      5 /* connection handover service access point */
 
+#define SNEP_MAJOR_VER         1
+#define SNEP_MINOR_VER         0
 
-#define NPP_MAJOR_VER 0
-#define NPP_MINOR_VER 1
+#define NPP_MAJOR_VER          0
+#define NPP_MINOR_VER          1
 
-#define NPP_NDEF_ENTRY 0x00000001
+#define NPP_NDEF_ENTRY         0x00000001
 
-#define NPP_ACTION_CODE 0x01
+#define NPP_ACTION_CODE                0x01
 
-#define SNEP_MAX_BUFFER 128 /* simple NDEF exchange protocol */
-#define CH_MAX_BUFFER 128     /* connection handover */
+#define SNEP_MAX_BUFFER                128 /* simple NDEF exchange protocol */
+#define CH_MAX_BUFFER          128     /* connection handover */
 
 typedef enum{
        NPP_REQ_CONTINUE = 0x00,
@@ -150,12 +148,12 @@ typedef struct _net_nfc_llcp_npp_t{
 } __attribute__((packed))net_nfc_llcp_npp_t;
 
 #define NET_NFC_COMMON_HANDOVER_CONTEXT unsigned int step;\
-                                                                               net_nfc_llcp_state_t *llcp_state;\
-                                                                               void *user_data;\
-                                                                               net_nfc_error_e result;\
-                                                                               net_nfc_conn_handover_carrier_type_e request_type;\
-                                                                               void *data;\
-                                                                               bool is_requester;
+                                       net_nfc_llcp_state_t *llcp_state;\
+                                       void *user_data;\
+                                       net_nfc_error_e result;\
+                                       net_nfc_conn_handover_carrier_type_e request_type;\
+                                       void *data;\
+                                       bool is_requester;
 
 typedef struct _net_nfc_handover_context_t
 {
index 628e7ff..68ffc11 100644 (file)
@@ -1,18 +1,18 @@
 /*
 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
-
 *     http://floralicense.org/license/
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 
 #ifndef NET_NFC_SERVICE_PRIVATE_H
@@ -32,4 +32,13 @@ void net_nfc_service_llcp_event_cb(void* info, void* user_context);
 
 void net_nfc_service_msg_processing(data_s* data);
 
+void net_nfc_service_is_tag_connected(net_nfc_request_msg_t *msg);
+void net_nfc_service_get_current_tag_info(net_nfc_request_msg_t *msg);
+void net_nfc_service_get_current_target_handle(net_nfc_request_msg_t *msg);
+void net_nfc_service_init(net_nfc_request_msg_t *msg);
+void net_nfc_service_deinit(net_nfc_request_msg_t *msg);
+
+void net_nfc_service_restart_polling(net_nfc_request_msg_t *msg);
+void net_nfc_service_get_server_state(net_nfc_request_msg_t *msg);
+
 #endif
index 3a39827..101e2fb 100755 (executable)
@@ -48,5 +48,12 @@ void net_nfc_service_tapi_deinit(void);
 bool net_nfc_service_transfer_apdu(int client_fd, data_s *apdu, void *trans_param);
 bool net_nfc_service_request_atr(int client_fd, void *trans_param);
 bool net_nfc_service_se_transaction_receive(net_nfc_request_msg_t* msg);
+void net_nfc_service_se_send_apdu(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_get_atr(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_close_se(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_open_se(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_set_se(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_get_se(net_nfc_request_msg_t *msg);
+void net_nfc_service_se_cleanup();
 
 #endif
index aa23369..ee14395 100755 (executable)
@@ -1,18 +1,18 @@
 /*
 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
-
 *     http://floralicense.org/license/
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 
 #ifndef NET_NFC_SERVICE_TAG_PRIVATE_H
@@ -24,4 +24,9 @@ data_s* net_nfc_service_tag_process(net_nfc_target_handle_s* handle, int devType
 void net_nfc_service_clean_tag_context(net_nfc_request_target_detected_t* stand_alone, net_nfc_error_e result);
 void net_nfc_service_watch_dog(net_nfc_request_msg_t* req_msg);
 
+void net_nfc_service_tag_make_readonly(net_nfc_request_msg_t *msg);
+void net_nfc_service_tag_read_ndef(net_nfc_request_msg_t *msg);
+void net_nfc_service_tag_write_ndef(net_nfc_request_msg_t *msg);
+void net_nfc_service_tag_format_ndef(net_nfc_request_msg_t *msg);
+
 #endif
diff --git a/src/manager/include/net_nfc_service_test_private.h b/src/manager/include/net_nfc_service_test_private.h
new file mode 100755 (executable)
index 0000000..dd4532c
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NET_NFC_SERVICE_TEST_PRIVATE_H
+#define NET_NFC_SERVICE_TEST_PRIVATE_H
+
+#include "net_nfc_typedef_private.h"
+
+void net_nfc_service_test_sim_test(net_nfc_request_msg_t *msg);
+void net_nfc_service_test_get_firmware_version(net_nfc_request_msg_t *msg);
+void net_nfc_service_test_prbs_test(net_nfc_request_msg_t *msg);
+void net_nfc_service_test_set_eedata(net_nfc_request_msg_t *msg);
+
+#endif
index e314684..9c083e1 100755 (executable)
@@ -287,6 +287,70 @@ bool net_nfc_controller_set_secure_element_mode(net_nfc_secure_element_type_e el
        }
 }
 
+bool net_nfc_controller_secure_element_open(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s **handle, net_nfc_error_e *result)
+{
+       int ret_val = 0;
+
+       ret_val = pm_lock_state(LCD_NORMAL, GOTO_STATE_NOW, 0);
+
+       if (g_interface.secure_element_open != NULL)
+       {
+               return g_interface.secure_element_open(element_type, handle, result);
+       }
+       else
+       {
+               *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
+               DEBUG_SERVER_MSG("interface is null");
+               return false;
+       }
+}
+
+bool net_nfc_controller_secure_element_get_atr(net_nfc_target_handle_s *handle, data_s **atr, net_nfc_error_e *result)
+{
+       if (g_interface.secure_element_get_atr != NULL)
+       {
+               return g_interface.secure_element_get_atr(handle, atr, result);
+       }
+       else
+       {
+               *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
+               DEBUG_SERVER_MSG("interface is null");
+               return false;
+       }
+}
+
+bool net_nfc_controller_secure_element_send_apdu(net_nfc_target_handle_s *handle, data_s *command, data_s **response, net_nfc_error_e *result)
+{
+       if (g_interface.secure_element_send_apdu != NULL)
+       {
+               return g_interface.secure_element_send_apdu(handle, command, response, result);
+       }
+       else
+       {
+               *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
+               DEBUG_SERVER_MSG("interface is null");
+               return false;
+       }
+}
+
+bool net_nfc_controller_secure_element_close(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
+{
+       int ret_val = 0;
+
+       ret_val = pm_unlock_state(LCD_NORMAL, PM_RESET_TIMER);
+
+       if (g_interface.secure_element_close != NULL)
+       {
+               return g_interface.secure_element_close(handle, result);
+       }
+       else
+       {
+               *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
+               DEBUG_SERVER_MSG("interface is null");
+               return false;
+       }
+}
+
 bool net_nfc_controller_check_target_presence(net_nfc_target_handle_s* handle, net_nfc_error_e* result)
 {
        if (g_interface.check_presence != NULL)
index cb3d0f0..79a9188 100644 (file)
@@ -18,7 +18,6 @@
 #include <string.h>
 #include <unistd.h>
 #include <pthread.h>
-#include <stdarg.h>
 #include <glib.h>
 
 #include "vconf.h"
@@ -35,8 +34,9 @@
 #include "net_nfc_service_llcp_private.h"
 #include "net_nfc_service_llcp_handover_private.h"
 #include "net_nfc_service_tag_private.h"
-#include "net_nfc_manager_util_private.h"
 #include "net_nfc_service_se_private.h"
+#include "net_nfc_service_test_private.h"
+#include "net_nfc_manager_util_private.h"
 #include "net_nfc_util_access_control_private.h"
 #include "net_nfc_server_context_private.h"
 
@@ -45,9 +45,6 @@ static pthread_cond_t g_dispatcher_queue_cond = PTHREAD_COND_INITIALIZER;
 static pthread_mutex_t g_dispatcher_queue_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_t g_dispatcher_thread;
 
-static uint8_t g_se_prev_type = SECURE_ELEMENT_TYPE_INVALID;
-static uint8_t g_se_prev_mode = SECURE_ELEMENT_OFF_MODE;
-
 static void *_net_nfc_dispatcher_thread_func(void *data);
 static net_nfc_request_msg_t *_net_nfc_dispatcher_queue_pop();
 
@@ -76,7 +73,7 @@ void net_nfc_dispatcher_cleanup_queue(void)
 
        while ((req_msg = _net_nfc_dispatcher_queue_pop()) != NULL)
        {
-               DEBUG_MSG("abandon request : %d", req_msg->request_type);
+               DEBUG_ERR_MSG("abandon request : %d", req_msg->request_type);
                _net_nfc_util_free_mem(req_msg);
        }
 
@@ -174,7 +171,7 @@ bool net_nfc_dispatcher_start_thread()
 
 static void *_net_nfc_dispatcher_thread_func(void *data)
 {
-       net_nfc_request_msg_t *req_msg = NULL;
+       net_nfc_request_msg_t *req_msg;
 
        DEBUG_SERVER_MSG("net_nfc_controller_thread is created ");
 
@@ -195,293 +192,43 @@ static void *_net_nfc_dispatcher_thread_func(void *data)
                {
                case NET_NFC_MESSAGE_SERVICE_CLEANER :
                        {
-                               DEBUG_SERVER_MSG("client is terminated abnormally");
-
-                               if (g_se_prev_type == SECURE_ELEMENT_TYPE_ESE)
-                               {
-                                       net_nfc_error_e result = NET_NFC_OK;
-                                       net_nfc_target_handle_s *ese_handle = net_nfc_service_se_get_current_ese_handle();
-
-                                       if (ese_handle != NULL)
-                                       {
-                                               DEBUG_SERVER_MSG("ese_handle was not freed and disconnected");
-
-                                               net_nfc_service_se_close_ese();
-#ifdef BROADCAST_MESSAGE
-                                               net_nfc_server_set_server_state(NET_NFC_SERVER_IDLE);
-#endif
-                                       }
-
-                                       if ((g_se_prev_type != net_nfc_service_se_get_se_type()) || (g_se_prev_mode != net_nfc_service_se_get_se_mode()))
-                                       {
-                                               net_nfc_controller_set_secure_element_mode(g_se_prev_type, g_se_prev_mode, &result);
-
-                                               net_nfc_service_se_set_se_type(g_se_prev_type);
-                                               net_nfc_service_se_set_se_mode(g_se_prev_mode);
-                                       }
-                               }
-                               else if (g_se_prev_type == SECURE_ELEMENT_TYPE_UICC)
-                               {
-                                       net_nfc_service_tapi_deinit();
-                               }
-                               else
-                               {
-                                       DEBUG_SERVER_MSG("SE type is not valid");
-                               }
+                               net_nfc_service_se_cleanup();
                        }
                        break;
 
                case NET_NFC_MESSAGE_SEND_APDU_SE :
                        {
-                               net_nfc_request_send_apdu_t *detail = (net_nfc_request_send_apdu_t *)req_msg;
-
-                               if (detail->handle == (net_nfc_target_handle_s *)UICC_TARGET_HANDLE)
-                               {
-                                       data_s apdu_data = { NULL, 0 };
-
-                                       if (net_nfc_util_duplicate_data(&apdu_data, &detail->data) == false)
-                                               break;
-
-                                       net_nfc_service_transfer_apdu(req_msg->client_fd, &apdu_data, detail->trans_param);
-
-                                       net_nfc_util_free_data(&apdu_data);
-                               }
-                               else if (detail->handle == net_nfc_service_se_get_current_ese_handle())
-                               {
-                                       data_s *data = NULL;
-                                       net_nfc_error_e result = NET_NFC_OK;
-                                       net_nfc_transceive_info_s info;
-                                       bool success = true;
-
-                                       info.dev_type = NET_NFC_ISO14443_A_PICC;
-                                       if (net_nfc_util_duplicate_data(&info.trans_data, &detail->data) == false)
-                                       {
-                                               DEBUG_ERR_MSG("alloc failed");
-                                               break;
-                                       }
-
-                                       if ((success = net_nfc_controller_transceive(detail->handle, &info, &data, &result)) == true)
-                                       {
-                                               if (data != NULL)
-                                               {
-                                                       DEBUG_SERVER_MSG("trasceive data recieved [%d], Success = %d", data->length, success);
-                                               }
-                                       }
-                                       else
-                                       {
-                                               DEBUG_SERVER_MSG("trasceive is failed = [%d]", result);
-                                       }
-                                       net_nfc_util_free_data(&info.trans_data);
-
-                                       if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                                       {
-                                               net_nfc_response_send_apdu_t resp = { 0 };
-
-                                               resp.length = sizeof(net_nfc_response_send_apdu_t);
-                                               resp.flags = detail->flags;
-                                               resp.trans_param = detail->trans_param;
-                                               resp.result = result;
-
-                                               if (success && data != NULL)
-                                               {
-                                                       DEBUG_MSG("send response send apdu msg");
-                                                       resp.data.length = data->length;
-                                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_send_apdu_t),
-                                                                       data->buffer, data->length, NULL);
-                                               }
-                                               else
-                                               {
-                                                       DEBUG_MSG("send response send apdu msg");
-                                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
-                                               }
-                                       }
-                               }
-                               else
-                               {
-                                       DEBUG_SERVER_MSG("invalid se handle");
-
-                                       if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                                       {
-                                               net_nfc_response_send_apdu_t resp = { 0 };
-
-                                               resp.length = sizeof(net_nfc_response_send_apdu_t);
-                                               resp.flags = detail->flags;
-                                               resp.trans_param = detail->trans_param;
-                                               resp.result = NET_NFC_INVALID_PARAM;
+                               net_nfc_service_se_send_apdu(req_msg);
+                       }
+                       break;
 
-                                               net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
-                                       }
-                               }
+               case NET_NFC_MESSAGE_GET_ATR_SE :
+                       {
+                               net_nfc_service_se_get_atr(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_CLOSE_INTERNAL_SE :
                        {
-                               net_nfc_request_close_internal_se_t *detail = (net_nfc_request_close_internal_se_t *)req_msg;
-                               net_nfc_error_e result = NET_NFC_OK;
-
-                               if (detail->handle == (net_nfc_target_handle_s *)UICC_TARGET_HANDLE)
-                               {
-                                       /*deinit TAPI*/
-                                       DEBUG_SERVER_MSG("UICC is current secure element");
-                                       net_nfc_service_tapi_deinit();
-
-                               }
-                               else if (detail->handle == net_nfc_service_se_get_current_ese_handle())
-                               {
-                                       result = net_nfc_service_se_close_ese();
-#ifdef BROADCAST_MESSAGE
-                                       net_nfc_server_unset_server_state(NET_NFC_SE_CONNECTED);
-#endif
-                               }
-                               else
-                               {
-                                       DEBUG_ERR_MSG("invalid se handle received handle = [0x%p] and current handle = [0x%p]", detail->handle, net_nfc_service_se_get_current_ese_handle());
-                               }
-
-                               if ((g_se_prev_type != net_nfc_service_se_get_se_type()) || (g_se_prev_mode != net_nfc_service_se_get_se_mode()))
-                               {
-                                       /*return back se mode*/
-                                       net_nfc_controller_set_secure_element_mode(g_se_prev_type, g_se_prev_mode, &result);
-
-                                       net_nfc_service_se_set_se_type(g_se_prev_type);
-                                       net_nfc_service_se_set_se_mode(g_se_prev_mode);
-                               }
-
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_close_internal_se_t resp = { 0 };
-
-                                       resp.length = sizeof(net_nfc_response_close_internal_se_t);
-                                       resp.flags = detail->flags;
-                                       resp.trans_param = detail->trans_param;
-                                       resp.result = result;
-
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_close_internal_se_t), NULL);
-                               }
+                               net_nfc_service_se_close_se(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_OPEN_INTERNAL_SE :
                        {
-                               net_nfc_request_open_internal_se_t *detail = (net_nfc_request_open_internal_se_t *)req_msg;
-                               net_nfc_target_handle_s *handle = NULL;
-                               net_nfc_error_e result = NET_NFC_OK;
-
-                               g_se_prev_type = net_nfc_service_se_get_se_type();
-                               g_se_prev_mode = net_nfc_service_se_get_se_mode();
-
-                               if (detail->se_type == SECURE_ELEMENT_TYPE_UICC)
-                               {
-                                       /*off ESE*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_OFF_MODE, &result);
-
-                                       /*Off UICC. UICC SHOULD not be detected by external reader when being communicated in internal process*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
-
-                                       net_nfc_service_se_set_se_type(SECURE_ELEMENT_TYPE_UICC);
-                                       net_nfc_service_se_set_se_mode(SECURE_ELEMENT_OFF_MODE);
-
-                                       /*Init tapi api and return back response*/
-                                       if (net_nfc_service_tapi_init() != true)
-                                       {
-                                               net_nfc_service_tapi_deinit();
-                                               result = NET_NFC_INVALID_STATE;
-                                               handle = NULL;
-                                       }
-                                       else
-                                       {
-                                               result = NET_NFC_OK;
-                                               handle = (net_nfc_target_handle_s *)UICC_TARGET_HANDLE;
-                                       }
-                               }
-                               else if (detail->se_type == SECURE_ELEMENT_TYPE_ESE)
-                               {
-                                       /*Connect NFC-WI to ESE*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_WIRED_MODE, &result);
-
-                                       /*off UICC*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
-
-                                       net_nfc_service_se_set_se_type(SECURE_ELEMENT_TYPE_ESE);
-                                       net_nfc_service_se_set_se_mode(SECURE_ELEMENT_WIRED_MODE);
-                                       net_nfc_service_se_get_se_setting()->open_request_trans_param = detail->trans_param;
-
-                                       result = NET_NFC_OK;
-                                       handle = (net_nfc_target_handle_s *)1;
-                               }
-                               else
-                               {
-                                       result = NET_NFC_INVALID_STATE;
-                                       handle = NULL;
-                               }
-
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_open_internal_se_t resp = { 0 };
-
-                                       resp.length = sizeof(net_nfc_response_open_internal_se_t);
-                                       resp.flags = detail->flags;
-                                       resp.trans_param = detail->trans_param;
-                                       resp.result = result;
-                                       resp.se_type = detail->se_type;
-                                       resp.handle = handle;
-
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_set_se_t), NULL);
-                               }
+                               net_nfc_service_se_open_se(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_SET_SE :
                        {
-                               net_nfc_request_set_se_t *detail = (net_nfc_request_set_se_t *)req_msg;
-                               net_nfc_error_e result = NET_NFC_OK;
-                               bool isTypeChange = false;
-
-                               if (detail->se_type != net_nfc_service_se_get_se_type())
-                               {
-                                       result = net_nfc_service_se_change_se(detail->se_type);
-                                       isTypeChange = true;
-                               }
-
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_set_se_t resp = { 0 };
-
-                                       resp.length = sizeof(net_nfc_response_set_se_t);
-                                       resp.flags = detail->flags;
-                                       resp.trans_param = detail->trans_param;
-                                       resp.se_type = detail->se_type;
-                                       resp.result = result;
-
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_set_se_t), NULL);
-                               }
-
-                               if (isTypeChange)
-                               {
-                                       net_nfc_response_notify_t noti_se = { 0, };
-
-                                       net_nfc_broadcast_response_msg(NET_NFC_MESSAGE_SE_TYPE_CHANGED, (void *)&noti_se, sizeof(net_nfc_response_notify_t), NULL);
-                               }
+                               net_nfc_service_se_set_se(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_GET_SE :
                        {
-                               net_nfc_request_get_se_t *detail = (net_nfc_request_get_se_t *)req_msg;
-
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_get_se_t resp = { 0 };
-
-                                       resp.length = sizeof(net_nfc_request_get_se_t);
-                                       resp.flags = detail->flags;
-                                       resp.trans_param = detail->trans_param;
-                                       resp.result = NET_NFC_OK;
-                                       resp.se_type = net_nfc_service_se_get_se_type();
-
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_se_t), NULL);
-                               }
+                               net_nfc_service_se_get_se(req_msg);
                        }
                        break;
 
@@ -586,581 +333,85 @@ static void *_net_nfc_dispatcher_thread_func(void *data)
 
                case NET_NFC_MESSAGE_MAKE_READ_ONLY_NDEF :
                        {
-                               net_nfc_request_make_read_only_ndef_t *detail = (net_nfc_request_make_read_only_ndef_t *)req_msg;
-                               net_nfc_error_e result = NET_NFC_OK;
-
-                               if (net_nfc_server_is_target_connected(detail->handle))
-                               {
-                                       net_nfc_controller_make_read_only_ndef(detail->handle, &result);
-                               }
-                               else
-                               {
-                                       result = NET_NFC_TARGET_IS_MOVED_AWAY;
-                               }
-
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_make_read_only_ndef_t resp = { 0, };
-
-                                       resp.length = sizeof(net_nfc_response_make_read_only_ndef_t);
-                                       resp.flags = detail->flags;
-                                       resp.result = result;
-                                       resp.trans_param = detail->trans_param;
-
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_write_ndef_t), NULL);
-                               }
+                               net_nfc_service_tag_make_readonly(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_IS_TAG_CONNECTED :
                        {
-                               net_nfc_request_is_tag_connected_t *detail = (net_nfc_request_is_tag_connected_t *)req_msg;
-                               net_nfc_current_target_info_s* target_info = NULL;
-
-                               target_info = net_nfc_server_get_tag_info();
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_is_tag_connected_t resp = { 0, };
-
-                                       resp.length = sizeof(net_nfc_response_is_tag_connected_t);
-                                       resp.flags = detail->flags;
-                                       resp.trans_param = detail->trans_param;
-
-                                       if (target_info != NULL)
-                                       {
-                                               resp.result = NET_NFC_OK;
-                                               resp.devType = target_info->devType;
-                                       }
-                                       else
-                                       {
-                                               resp.result = NET_NFC_NOT_CONNECTED;
-                                               resp.devType = NET_NFC_UNKNOWN_TARGET;
-                                       }
-
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_is_tag_connected_t), NULL);
-                               }
+                               net_nfc_service_is_tag_connected(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_GET_CURRENT_TAG_INFO :
                        {
-                               net_nfc_response_get_current_tag_info_t resp = { 0, };
-                               net_nfc_request_get_current_tag_info_t *detail = (net_nfc_request_get_current_tag_info_t *)req_msg;
-                               net_nfc_current_target_info_s *target_info = NULL;
-                               net_nfc_error_e result = NET_NFC_OK;
-
-                               resp.length = sizeof(net_nfc_response_get_current_tag_info_t);
-                               resp.flags = detail->flags;
-                               resp.trans_param = detail->trans_param;
-
-                               target_info = net_nfc_server_get_tag_info();
-
-                               if (target_info != NULL)
-                               {
-                                       bool success = true;
-                                       data_s* recv_data = NULL;
-
-                                       if (target_info->devType != NET_NFC_NFCIP1_TARGET && target_info->devType != NET_NFC_NFCIP1_INITIATOR)
-                                       {
-#ifdef BROADCAST_MESSAGE
-                                               net_nfc_server_set_server_state(NET_NFC_TAG_CONNECTED);
-#endif
-                                               DEBUG_SERVER_MSG("tag is connected");
-
-                                               uint8_t ndef_card_state = 0;
-                                               int max_data_size = 0;
-                                               int real_data_size = 0;
-
-                                               if (net_nfc_controller_check_ndef(target_info->handle, &ndef_card_state, &max_data_size, &real_data_size, &result) == true)
-                                               {
-                                                       resp.ndefCardState = ndef_card_state;
-                                                       resp.maxDataSize = max_data_size;
-                                                       resp.actualDataSize = real_data_size;
-                                                       resp.is_ndef_supported = 1;
-                                               }
-
-                                               resp.devType = target_info->devType;
-                                               resp.handle = target_info->handle;
-                                               resp.number_of_keys = target_info->number_of_keys;
-
-                                               net_nfc_util_duplicate_data(&resp.target_info_values, &target_info->target_info_values);
-
-                                               if (resp.is_ndef_supported)
-                                               {
-                                                       if (net_nfc_controller_read_ndef(target_info->handle, &recv_data, &(resp.result)) == true)
-                                                       {
-                                                               DEBUG_SERVER_MSG("net_nfc_controller_read_ndef is success");
-
-                                                               resp.raw_data.length = recv_data->length;
-
-                                                               success = net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
-                                                                               (void *)(resp.target_info_values.buffer), resp.target_info_values.length,
-                                                                               (void *)(recv_data->buffer), recv_data->length, NULL);
-                                                       }
-                                                       else
-                                                       {
-                                                               DEBUG_SERVER_MSG("net_nfc_controller_read_ndef is fail");
-
-                                                               resp.raw_data.length = 0;
-
-                                                               success = net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
-                                                                               (void *)(resp.target_info_values.buffer), resp.target_info_values.length, NULL);
-                                                       }
-                                               }
-                                               else
-                                               {
-                                                       resp.raw_data.length = 0;
-
-                                                       success = net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
-                                                                       (void *)(resp.target_info_values.buffer), resp.target_info_values.length, NULL);
-                                               }
-
-                                               net_nfc_util_free_data(&resp.target_info_values);
-                                       }
-                               }
-                               else
-                               {
-                                       resp.result = NET_NFC_NOT_CONNECTED;
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t), NULL);
-                               }
+                               net_nfc_service_get_current_tag_info(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_GET_CURRENT_TARGET_HANDLE :
                        {
-                               net_nfc_request_get_current_target_handle_t *detail = (net_nfc_request_get_current_target_handle_t *)req_msg;
-                               net_nfc_current_target_info_s *target_info = NULL;
-
-                               target_info = net_nfc_server_get_tag_info();
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_get_current_target_handle_t resp = { 0, };
-
-                                       resp.length = sizeof(net_nfc_response_get_current_target_handle_t);
-                                       resp.flags = detail->flags;
-                                       resp.trans_param = detail->trans_param;
-
-                                       if (target_info != NULL)
-                                       {
-                                               resp.handle = target_info->handle;
-                                               resp.devType = target_info->devType;
-                                               resp.result = NET_NFC_OK;
-                                       }
-                                       else
-                                       {
-                                               resp.result = NET_NFC_NOT_CONNECTED;
-                                       }
-
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_target_handle_t), NULL);
-                               }
+                               net_nfc_service_get_current_target_handle(req_msg);
                        }
                        break;
 
                case NET_NFC_GET_SERVER_STATE :
                        {
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_get_server_state_t resp = { 0, };
-
-                                       resp.length = sizeof(net_nfc_response_get_server_state_t);
-                                       resp.flags = req_msg->flags;
-                                       resp.state = net_nfc_server_get_server_state();
-                                       resp.result = NET_NFC_OK;
-
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_server_state_t), NULL);
-                               }
+                               net_nfc_service_get_server_state(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_READ_NDEF :
                        {
-                               net_nfc_request_read_ndef_t *detail = (net_nfc_request_read_ndef_t*)req_msg;
-                               net_nfc_error_e result = NET_NFC_OK;
-                               data_s *data = NULL;
-                               bool success = false;
-
-                               if (net_nfc_server_is_target_connected(detail->handle))
-                               {
-                                       success = net_nfc_controller_read_ndef(detail->handle, &data, &result);
-                               }
-                               else
-                               {
-                                       result = NET_NFC_TARGET_IS_MOVED_AWAY;
-                               }
-
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_read_ndef_t resp = { 0, };
-
-                                       resp.length = sizeof(net_nfc_response_read_ndef_t);
-                                       resp.flags = detail->flags;
-                                       resp.result = result;
-                                       resp.trans_param = detail->trans_param;
-
-                                       if (success)
-                                       {
-                                               resp.data.length = data->length;
-                                               net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_read_ndef_t),
-                                                               data->buffer, data->length, NULL);
-                                       }
-                                       else
-                                       {
-                                               resp.data.length = 0;
-                                               resp.data.buffer = NULL;
-                                               net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_read_ndef_t), NULL);
-                                       }
-                               }
-
-                               if (data != NULL)
-                               {
-                                       net_nfc_util_free_data(data);
-                                       _net_nfc_util_free_mem(data);
-                               }
+                               net_nfc_service_tag_read_ndef(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_WRITE_NDEF :
                        {
-                               net_nfc_request_write_ndef_t *detail = (net_nfc_request_write_ndef_t *)req_msg;
-                               net_nfc_error_e result = NET_NFC_OK;
-
-                               if (net_nfc_server_is_target_connected(detail->handle))
-                               {
-                                       data_s data = { NULL, 0 };
-
-                                       if (net_nfc_util_duplicate_data(&data, &detail->data) == true)
-                                       {
-                                               net_nfc_controller_write_ndef(detail->handle, &data, &result);
-
-                                               net_nfc_util_free_data(&data);
-                                       }
-                                       else
-                                       {
-                                               result = NET_NFC_ALLOC_FAIL;
-                                       }
-                               }
-                               else
-                               {
-                                       result = NET_NFC_TARGET_IS_MOVED_AWAY;
-                               }
-
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_write_ndef_t resp = { 0, };
-
-                                       resp.length = sizeof(net_nfc_response_write_ndef_t);
-                                       resp.flags = detail->flags;
-                                       resp.result = result;
-                                       resp.trans_param = detail->trans_param;
-
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_write_ndef_t), NULL);
-                               }
+                               net_nfc_service_tag_write_ndef(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_FORMAT_NDEF :
                        {
-                               net_nfc_request_format_ndef_t *detail = (net_nfc_request_format_ndef_t *)req_msg;
-                               net_nfc_error_e result = NET_NFC_OK;
-
-                               if (net_nfc_server_is_target_connected(detail->handle))
-                               {
-                                       data_s data = { NULL, 0 };
-
-                                       if (net_nfc_util_duplicate_data(&data, &detail->key) == true)
-                                       {
-                                               net_nfc_controller_format_ndef(detail->handle, &data, &result);
-                                               net_nfc_util_free_data(&data);
-                                       }
-                                       else
-                                       {
-                                               result = NET_NFC_ALLOC_FAIL;
-                                       }
-                               }
-                               else
-                               {
-                                       result = NET_NFC_TARGET_IS_MOVED_AWAY;
-                               }
-
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_format_ndef_t resp = { 0 };
-
-                                       resp.length = sizeof(net_nfc_response_format_ndef_t);
-                                       resp.flags = detail->flags;
-                                       resp.result = result;
-                                       resp.trans_param = detail->trans_param;
-
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_format_ndef_t), NULL);
-                               }
+                               net_nfc_service_tag_format_ndef(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_SIM_TEST :
                        {
-                               net_nfc_request_test_t *detail = (net_nfc_request_test_t *)req_msg;
-                               net_nfc_error_e result = NET_NFC_OK;
-
-                               if (net_nfc_controller_sim_test(&result) == true)
-                               {
-                                       DEBUG_SERVER_MSG("net_nfc_controller_sim_test Result [SUCCESS]");
-                               }
-                               else
-                               {
-                                       DEBUG_SERVER_MSG("net_nfc_controller_sim_test Result [ERROR1]");
-                               }
-
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_test_t resp = { 0, };
-
-                                       resp.length = sizeof(net_nfc_response_test_t);
-                                       resp.flags = detail->flags;
-                                       resp.result = result;
-                                       resp.trans_param = detail->trans_param;
-
-                                       DEBUG_SERVER_MSG("SEND RESPONSE!!");
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
-                               }
+                               net_nfc_service_test_sim_test(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_GET_FIRMWARE_VERSION :
                        {
-                               net_nfc_error_e result = NET_NFC_OK;
-                               data_s *data = NULL;
-
-                               if (net_nfc_controller_get_firmware_version(&data, &result) == true)
-                               {
-                                       DEBUG_SERVER_MSG("net_nfc_controller_update_firmware Result [SUCCESS]");
-
-                               }
-                               else
-                               {
-                                       DEBUG_ERR_MSG("net_nfc_controller_update_firmware Result [ERROR3]");
-                               }
-
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_firmware_version_t resp = { 0, };
-
-                                       resp.length = sizeof(net_nfc_response_firmware_version_t);
-                                       resp.flags = req_msg->flags;
-                                       resp.result = result;
-                                       resp.data.length = data->length;
-
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_firmware_version_t), (void *)data->buffer, resp.data.length, NULL);
-                               }
-
-                               net_nfc_util_free_data(data);
+                               net_nfc_service_test_get_firmware_version(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_PRBS_TEST :
                        {
-                               net_nfc_request_test_t *detail = (net_nfc_request_test_t *)req_msg;
-                               net_nfc_error_e result = NET_NFC_OK;
-                               uint32_t local_tech = 0;
-                               uint32_t local_rate = 0;
-
-                               local_tech = detail->tech;
-                               local_rate = detail->rate;
-
-                               DEBUG_SERVER_MSG("NET_NFC_MESSAGE_PRBS_TEST local_tech [%d]\n", local_tech);
-                               DEBUG_SERVER_MSG("NET_NFC_MESSAGE_PRBS_TEST local_rate [%d]\n", local_rate);
-
-                               if (net_nfc_controller_prbs_test(&result, local_tech, local_rate) == true)
-                               {
-                                       DEBUG_SERVER_MSG("net_nfc_controller_prbs_test Result [SUCCESS]");
-                               }
-                               else
-                               {
-                                       DEBUG_ERR_MSG("net_nfc_controller_prbs_test Result [ERROR3]");
-                               }
-
-                               if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                               {
-                                       net_nfc_response_test_t resp = { 0, };
-
-                                       resp.length = sizeof(net_nfc_response_test_t);
-                                       resp.flags = detail->flags;
-                                       resp.result = result;
-                                       resp.trans_param = detail->trans_param;
-
-                                       DEBUG_SERVER_MSG("SEND RESPONSE!!");
-                                       net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
-                               }
+                               net_nfc_service_test_prbs_test(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_SET_EEDATA :
                        {
-                               net_nfc_request_eedata_register_t *detail = (net_nfc_request_eedata_register_t *)req_msg;
-                               net_nfc_error_e result = NET_NFC_OK;
-                               uint32_t local_mode = 0;
-                               uint32_t local_reg_id = 0;
-                               data_s data = { NULL, 0 };
-
-                               local_mode = detail->mode;
-                               local_reg_id = detail->reg_id;
-
-                               DEBUG_SERVER_MSG("NET_NFC_MESSAGE_SET_EEDATA local_mode [%d]\n", local_mode);
-                               DEBUG_SERVER_MSG("NET_NFC_MESSAGE_SET_EEDATA local_reg_id [%d]\n", local_reg_id);
-
-                               if (net_nfc_util_duplicate_data(&data, &detail->data) == true)
-                               {
-                                       if (net_nfc_controller_eedata_register_set(&result, local_mode, local_reg_id, &data) == true)
-                                       {
-                                               DEBUG_SERVER_MSG("net_nfc_controller_eedata_register_set Result [SUCCESS]");
-                                       }
-                                       else
-                                       {
-                                               DEBUG_ERR_MSG("net_nfc_controller_eedata_register_set Result [ERROR3]");
-                                       }
-                                       net_nfc_util_free_data(&data);
-
-                                       if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                                       {
-                                               net_nfc_response_test_t resp = { 0, };
-
-                                               resp.length = sizeof(net_nfc_response_test_t);
-                                               resp.flags = detail->flags;
-                                               resp.result = result;
-                                               resp.trans_param = detail->trans_param;
-
-                                               DEBUG_SERVER_MSG("SEND RESPONSE!!");
-                                               net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
-                                       }
-                               }
+                               net_nfc_service_test_set_eedata(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_SERVICE_DEINIT :
                        {
-                               net_nfc_error_e result;
-
-                               result = net_nfc_service_se_change_se(SECURE_ELEMENT_TYPE_INVALID);
-
-                               /* release access control instance */
-                               net_nfc_util_access_control_release();
-
-                               net_nfc_server_free_current_tag_info();
-
-                               if (net_nfc_controller_deinit() == TRUE)
-                               {
-                                       DEBUG_SERVER_MSG("net_nfc_controller_deinit success [%d]", result);
-
-                                       /*vconf off*/
-                                       if (vconf_set_bool(VCONFKEY_NFC_STATE, FALSE) != 0)
-                                       {
-                                               DEBUG_ERR_MSG("vconf_set_bool failed");
-                                       }
-
-                                       net_nfc_response_test_t resp = { 0, };
-
-                                       resp.length = sizeof(net_nfc_response_test_t);
-                                       resp.flags = req_msg->flags;
-                                       resp.result = NET_NFC_OK;
-                                       resp.trans_param = (void *)req_msg->user_param;
-
-                                       net_nfc_broadcast_response_msg(req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
-                               }
-                               else
-                               {
-                                       DEBUG_SERVER_MSG("net_nfc_controller_deinit failed");
-
-                                       if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                                       {
-                                               net_nfc_response_test_t resp = { 0, };
-
-                                               resp.length = sizeof(net_nfc_response_test_t);
-                                               resp.flags = req_msg->flags;
-                                               resp.result = NET_NFC_UNKNOWN_ERROR;
-                                               resp.trans_param = (void *)req_msg->user_param;
-
-                                               net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
-                                       }
-                               }
+                               net_nfc_service_deinit(req_msg);
                        }
                        break;
 
                case NET_NFC_MESSAGE_SERVICE_INIT :
                        {
-                               net_nfc_error_e result;
-
-                               if (net_nfc_controller_init(&result) == true)
-                               {
-                                       net_nfc_llcp_config_info_s config = { 128, 1, 100, 0 };
-
-                                       if (net_nfc_controller_register_listener(net_nfc_service_target_detected_cb, net_nfc_service_se_transaction_cb, net_nfc_service_llcp_event_cb, &result) == true)
-                                       {
-                                               DEBUG_SERVER_MSG("net_nfc_controller_register_listener Success!!");
-                                       }
-                                       else
-                                       {
-                                               DEBUG_ERR_MSG("net_nfc_controller_register_listener failed [%d]", result);
-                                       }
-
-                                       if (net_nfc_controller_llcp_config(&config, &result) == true)
-                                       {
-                                               /*We need to check the stack that supports the llcp or not.*/
-                                               DEBUG_SERVER_MSG("llcp is enabled");
-                                       }
-                                       else
-                                       {
-                                               DEBUG_ERR_MSG("net_nfc_controller_llcp_config failed [%d]", result);
-                                       }
-
-                                       result = net_nfc_service_se_change_se(SECURE_ELEMENT_TYPE_UICC);
-
-                                       if (net_nfc_controller_confiure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG, NET_NFC_ALL_ENABLE, &result) == true)
-                                       {
-                                               DEBUG_SERVER_MSG("now, nfc is ready");
-                                       }
-                                       else
-                                       {
-                                               DEBUG_ERR_MSG("net_nfc_controller_confiure_discovery failed [%d]", result);
-                                       }
-
-                                       /* initialize access control instance */
-                                       net_nfc_util_access_control_initialize();
-
-                                       /*Send the Init Success Response Msg*/
-                                       {
-                                               net_nfc_response_test_t resp = { 0, };
-
-                                               DEBUG_SERVER_MSG("net_nfc_controller_init success [%d]", result);
-
-                                               resp.length = sizeof(net_nfc_response_test_t);
-                                               resp.flags = req_msg->flags;
-                                               resp.result = NET_NFC_OK;
-                                               resp.trans_param = (void *)req_msg->user_param;
-
-                                               /*vconf on*/
-                                               if (vconf_set_bool(VCONFKEY_NFC_STATE, TRUE) != 0)
-                                               {
-                                                       DEBUG_ERR_MSG("vconf_set_bool failed");
-                                               }
-
-                                               net_nfc_broadcast_response_msg(req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
-                                       }
-                               }
-                               else
-                               {
-                                       DEBUG_ERR_MSG("net_nfc_controller_init failed [%d]", result);
-
-                                       if (net_nfc_server_check_client_is_running(req_msg->client_fd))
-                                       {
-                                               net_nfc_response_test_t resp = { 0, };
-
-                                               resp.length = sizeof(net_nfc_response_test_t);
-                                               resp.flags = req_msg->flags;
-                                               resp.result = result;
-                                               resp.trans_param = (void *)req_msg->user_param;
-
-                                               net_nfc_send_response_msg(req_msg->client_fd, req_msg->request_type, (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
-                                       }
-                               }
+                               net_nfc_service_init(req_msg);
                        }
                        break;
 
@@ -1174,33 +425,7 @@ static void *_net_nfc_dispatcher_thread_func(void *data)
 
                case NET_NFC_MESSAGE_SERVICE_RESTART_POLLING_LOOP :
                        {
-                               net_nfc_error_e result = NET_NFC_OK;
-                               int pm_state = 0;
-                               int set_config = 0;
-                               net_nfc_request_msg_t *discovery_req = (net_nfc_request_msg_t *)req_msg;
-
-                               pm_state = discovery_req->user_param;
-
-                               DEBUG_SERVER_MSG("NET_NFC_MESSAGE_SERVICE_RESTART_POLLING_LOOP PM State = [%d]", pm_state);
-
-                               if (pm_state == 1)
-                               {
-                                       set_config = NET_NFC_ALL_ENABLE;
-                               }
-                               else if (pm_state == 3)
-                               {
-                                       set_config = NET_NFC_ALL_DISABLE;
-                               }
-                               else
-                               {
-                                       DEBUG_SERVER_MSG("Do not anything!!");
-                               }
-
-                               //if (net_nfc_controller_confiure_discovery(NET_NFC_DISCOVERY_MODE_RESUME, NET_NFC_ALL_ENABLE, &result) == true)
-                               if (net_nfc_controller_confiure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG, set_config, &result) == true)
-                               {
-                                       DEBUG_SERVER_MSG("now, nfc polling loop is running again");
-                               }
+                               net_nfc_service_restart_polling(req_msg);
                        }
                        break;
 
@@ -1278,44 +503,7 @@ static void *_net_nfc_dispatcher_thread_func(void *data)
 
                case NET_NFC_MESSAGE_SERVICE_SE :
                        {
-                               net_nfc_request_set_se_t *detail = (net_nfc_request_set_se_t *)req_msg;
-                               net_nfc_error_e result = NET_NFC_OK;
-                               int mode;
-
-                               mode = (int)detail->se_type;
-
-                               if (mode == NET_NFC_SE_CMD_UICC_ON)
-                               {
-                                       /*turn on UICC*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_VIRTUAL_MODE, &result);
-
-                                       /*turn off ESE*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_OFF_MODE, &result);
-                               }
-                               else if (mode == NET_NFC_SE_CMD_ESE_ON)
-                               {
-                                       /*turn off UICC*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
-
-                                       /*turn on ESE*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_VIRTUAL_MODE, &result);
-                               }
-                               else if (mode == NET_NFC_SE_CMD_ALL_OFF)
-                               {
-                                       /*turn off both*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
-
-                                       /*turn on ESE*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_OFF_MODE, &result);
-                               }
-                               else
-                               {
-                                       /*turn off both*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_VIRTUAL_MODE, &result);
-
-                                       /*turn on ESE*/
-                                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_VIRTUAL_MODE, &result);
-                               }
+                               net_nfc_service_se_set_se(req_msg);
                        }
                        break;
 
index fb8a607..a25f8fa 100755 (executable)
@@ -30,7 +30,7 @@
 
 #include "vconf.h"
 #ifdef SECURITY_SERVER
-#include <security-server.h>
+#include "security-server.h"
 #endif
 
 #include "net_nfc_typedef_private.h"
index b06b502..7e16578 100644 (file)
@@ -17,6 +17,8 @@
 #include <pthread.h>
 #include <malloc.h>
 
+#include "vconf.h"
+
 #include "net_nfc_controller_private.h"
 #include "net_nfc_util_private.h"
 #include "net_nfc_typedef.h"
@@ -32,6 +34,7 @@
 #include "net_nfc_util_ndef_message.h"
 #include "net_nfc_util_ndef_record.h"
 #include "net_nfc_util_access_control_private.h"
+#include "net_nfc_server_context_private.h"
 
 /* static variable */
 
@@ -180,7 +183,7 @@ static bool _is_isp_dep_ndef_formatable(net_nfc_target_handle_s *handle, int dev
        }
        else
        {
-               DEBUG_ERR_MSG("net_nfc_controller_transceive is failed, [%d]", result);
+               DEBUG_ERR_MSG("net_nfc_controller_transceive is failed, [%d]", error);
        }
 
        return result;
@@ -518,3 +521,333 @@ static void _net_nfc_service_show_exception_msg(char* msg)
 
        bundle_free(kb);
 }
+
+void net_nfc_service_is_tag_connected(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_is_tag_connected_t *detail = (net_nfc_request_is_tag_connected_t *)msg;
+       net_nfc_current_target_info_s *target_info;
+
+       target_info = net_nfc_server_get_tag_info();
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_is_tag_connected_t resp = { 0, };
+
+               resp.length = sizeof(net_nfc_response_is_tag_connected_t);
+               resp.flags = detail->flags;
+               resp.trans_param = detail->trans_param;
+
+               if (target_info != NULL)
+               {
+                       resp.result = NET_NFC_OK;
+                       resp.devType = target_info->devType;
+               }
+               else
+               {
+                       resp.result = NET_NFC_NOT_CONNECTED;
+                       resp.devType = NET_NFC_UNKNOWN_TARGET;
+               }
+
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_is_tag_connected_t), NULL);
+       }
+}
+
+void net_nfc_service_get_current_tag_info(net_nfc_request_msg_t *msg)
+{
+       net_nfc_response_get_current_tag_info_t resp = { 0, };
+       net_nfc_request_get_current_tag_info_t *detail = (net_nfc_request_get_current_tag_info_t *)msg;
+       net_nfc_current_target_info_s *target_info = NULL;
+       net_nfc_error_e result = NET_NFC_OK;
+
+       resp.length = sizeof(net_nfc_response_get_current_tag_info_t);
+       resp.flags = detail->flags;
+       resp.trans_param = detail->trans_param;
+
+       target_info = net_nfc_server_get_tag_info();
+       if (target_info != NULL)
+       {
+               bool success = true;
+               data_s *recv_data = NULL;
+
+               if (target_info->devType != NET_NFC_NFCIP1_TARGET && target_info->devType != NET_NFC_NFCIP1_INITIATOR)
+               {
+#ifdef BROADCAST_MESSAGE
+                       net_nfc_server_set_server_state(NET_NFC_TAG_CONNECTED);
+#endif
+                       DEBUG_SERVER_MSG("tag is connected");
+
+                       uint8_t ndef_card_state = 0;
+                       int max_data_size = 0;
+                       int real_data_size = 0;
+
+                       if (net_nfc_controller_check_ndef(target_info->handle,
+                               &ndef_card_state, &max_data_size, &real_data_size, &result) == true)
+                       {
+                               resp.ndefCardState = ndef_card_state;
+                               resp.maxDataSize = max_data_size;
+                               resp.actualDataSize = real_data_size;
+                               resp.is_ndef_supported = 1;
+                       }
+
+                       resp.devType = target_info->devType;
+                       resp.handle = target_info->handle;
+                       resp.number_of_keys = target_info->number_of_keys;
+
+                       net_nfc_util_duplicate_data(&resp.target_info_values, &target_info->target_info_values);
+
+                       if (resp.is_ndef_supported)
+                       {
+                               if (net_nfc_controller_read_ndef(target_info->handle, &recv_data, &(resp.result)) == true)
+                               {
+                                       DEBUG_SERVER_MSG("net_nfc_controller_read_ndef is success");
+
+                                       resp.raw_data.length = recv_data->length;
+
+                                       success = net_nfc_send_response_msg(msg->client_fd, msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
+                                                       (void *)(resp.target_info_values.buffer), resp.target_info_values.length,
+                                                       (void *)(recv_data->buffer), recv_data->length, NULL);
+                               }
+                               else
+                               {
+                                       DEBUG_SERVER_MSG("net_nfc_controller_read_ndef is fail");
+
+                                       resp.raw_data.length = 0;
+
+                                       success = net_nfc_send_response_msg(msg->client_fd, msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
+                                               (void *)(resp.target_info_values.buffer), resp.target_info_values.length, NULL);
+                               }
+                       }
+                       else
+                       {
+                               resp.raw_data.length = 0;
+
+                               success = net_nfc_send_response_msg(msg->client_fd, msg->request_type, (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t),
+                                       (void *)(resp.target_info_values.buffer), resp.target_info_values.length, NULL);
+                       }
+
+                       net_nfc_util_free_data(&resp.target_info_values);
+               }
+               else
+               {
+                       /* LLCP */
+                       resp.result = NET_NFC_NOT_CONNECTED;
+                       net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                               (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t), NULL);
+               }
+       }
+       else
+       {
+               resp.result = NET_NFC_NOT_CONNECTED;
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_get_current_tag_info_t), NULL);
+       }
+}
+
+void net_nfc_service_get_current_target_handle(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_get_current_target_handle_t *detail = (net_nfc_request_get_current_target_handle_t *)msg;
+       net_nfc_current_target_info_s *target_info = NULL;
+
+       target_info = net_nfc_server_get_tag_info();
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_get_current_target_handle_t resp = { 0, };
+
+               resp.length = sizeof(net_nfc_response_get_current_target_handle_t);
+               resp.flags = detail->flags;
+               resp.trans_param = detail->trans_param;
+
+               if (target_info != NULL)
+               {
+                       resp.handle = target_info->handle;
+                       resp.devType = target_info->devType;
+                       resp.result = NET_NFC_OK;
+               }
+               else
+               {
+                       resp.result = NET_NFC_NOT_CONNECTED;
+               }
+
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_get_current_target_handle_t), NULL);
+       }
+}
+
+void net_nfc_service_deinit(net_nfc_request_msg_t *msg)
+{
+       net_nfc_error_e result;
+
+       result = net_nfc_service_se_change_se(SECURE_ELEMENT_TYPE_INVALID);
+
+       /* release access control instance */
+       net_nfc_util_access_control_release();
+
+       net_nfc_server_free_current_tag_info();
+
+       if (net_nfc_controller_deinit() == TRUE)
+       {
+               DEBUG_SERVER_MSG("net_nfc_controller_deinit success [%d]", result);
+
+               /*vconf off*/
+               if (vconf_set_bool(VCONFKEY_NFC_STATE, FALSE) != 0)
+               {
+                       DEBUG_ERR_MSG("vconf_set_bool failed");
+               }
+
+               net_nfc_response_test_t resp = { 0, };
+
+               resp.length = sizeof(net_nfc_response_test_t);
+               resp.flags = msg->flags;
+               resp.result = NET_NFC_OK;
+               resp.trans_param = (void *)msg->user_param;
+
+               net_nfc_broadcast_response_msg(msg->request_type, (void *)&resp,
+                       sizeof(net_nfc_response_test_t), NULL);
+       }
+       else
+       {
+               DEBUG_SERVER_MSG("net_nfc_controller_deinit failed");
+
+               if (net_nfc_server_check_client_is_running(msg->client_fd))
+               {
+                       net_nfc_response_test_t resp = { 0, };
+
+                       resp.length = sizeof(net_nfc_response_test_t);
+                       resp.flags = msg->flags;
+                       resp.result = NET_NFC_UNKNOWN_ERROR;
+                       resp.trans_param = (void *)msg->user_param;
+
+                       net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                               (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+               }
+       }
+}
+
+void net_nfc_service_init(net_nfc_request_msg_t *msg)
+{
+       net_nfc_error_e result;
+
+       if (net_nfc_controller_init(&result) == true)
+       {
+               net_nfc_llcp_config_info_s config = { 128, 1, 100, 0 };
+
+               if (net_nfc_controller_register_listener(net_nfc_service_target_detected_cb,
+                       net_nfc_service_se_transaction_cb, net_nfc_service_llcp_event_cb, &result) == true)
+               {
+                       DEBUG_SERVER_MSG("net_nfc_controller_register_listener Success!!");
+               }
+               else
+               {
+                       DEBUG_ERR_MSG("net_nfc_controller_register_listener failed [%d]", result);
+               }
+
+               if (net_nfc_controller_llcp_config(&config, &result) == true)
+               {
+                       /*We need to check the stack that supports the llcp or not.*/
+                       DEBUG_SERVER_MSG("llcp is enabled");
+               }
+               else
+               {
+                       DEBUG_ERR_MSG("net_nfc_controller_llcp_config failed [%d]", result);
+               }
+
+               result = net_nfc_service_se_change_se(SECURE_ELEMENT_TYPE_UICC);
+
+               if (net_nfc_controller_confiure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG,
+                       NET_NFC_ALL_ENABLE, &result) == true)
+               {
+                       DEBUG_SERVER_MSG("now, nfc is ready");
+               }
+               else
+               {
+                       DEBUG_ERR_MSG("net_nfc_controller_confiure_discovery failed [%d]", result);
+               }
+
+               /* initialize access control instance */
+               net_nfc_util_access_control_initialize();
+
+               /*Send the Init Success Response Msg*/
+               {
+                       net_nfc_response_test_t resp = { 0, };
+
+                       DEBUG_SERVER_MSG("net_nfc_controller_init success [%d]", result);
+
+                       resp.length = sizeof(net_nfc_response_test_t);
+                       resp.flags = msg->flags;
+                       resp.result = NET_NFC_OK;
+                       resp.trans_param = (void *)msg->user_param;
+
+                       /*vconf on*/
+                       if (vconf_set_bool(VCONFKEY_NFC_STATE, TRUE) != 0)
+                       {
+                               DEBUG_ERR_MSG("vconf_set_bool failed");
+                       }
+
+                       net_nfc_broadcast_response_msg(msg->request_type,
+                               (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+               }
+       }
+       else
+       {
+               DEBUG_ERR_MSG("net_nfc_controller_init failed [%d]", result);
+
+               if (net_nfc_server_check_client_is_running(msg->client_fd))
+               {
+                       net_nfc_response_test_t resp = { 0, };
+
+                       resp.length = sizeof(net_nfc_response_test_t);
+                       resp.flags = msg->flags;
+                       resp.result = result;
+                       resp.trans_param = (void *)msg->user_param;
+
+                       net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                               (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+               }
+       }
+}
+
+void net_nfc_service_restart_polling(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_msg_t *discovery_req = (net_nfc_request_msg_t *)msg;
+       net_nfc_error_e result = NET_NFC_OK;
+       int pm_state = 0;
+       int set_config = 0;
+
+       pm_state = discovery_req->user_param;
+
+       DEBUG_SERVER_MSG("NET_NFC_MESSAGE_SERVICE_RESTART_POLLING_LOOP PM State = [%d]", pm_state);
+
+       if (pm_state == 1)
+       {
+               set_config = NET_NFC_ALL_ENABLE;
+       }
+       else if (pm_state == 3)
+       {
+               set_config = NET_NFC_ALL_DISABLE;
+       }
+       else
+       {
+               DEBUG_SERVER_MSG("Do not anything!!");
+       }
+
+       if (net_nfc_controller_confiure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG, set_config, &result) == true)
+       {
+               DEBUG_SERVER_MSG("now, nfc polling loop is running again");
+       }
+}
+
+void net_nfc_service_get_server_state(net_nfc_request_msg_t *msg)
+{
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_get_server_state_t resp = { 0, };
+
+               resp.length = sizeof(net_nfc_response_get_server_state_t);
+               resp.flags = msg->flags;
+               resp.state = net_nfc_server_get_server_state();
+               resp.result = NET_NFC_OK;
+
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_get_server_state_t), NULL);
+       }
+}
index a7b3aa5..2a70b0e 100755 (executable)
 #include "net_nfc_server_ipc_private.h"
 #include "net_nfc_server_dispatcher_private.h"
 #include "net_nfc_service_se_private.h"
+#include "net_nfc_server_context_private.h"
 
 /* define */
+
+/* static variable */
+static uint8_t g_se_prev_type = SECURE_ELEMENT_TYPE_INVALID;
+static uint8_t g_se_prev_mode = SECURE_ELEMENT_OFF_MODE;
+
 /* For ESE*/
 static net_nfc_se_setting_t g_se_setting;
 
@@ -198,7 +204,8 @@ void net_nfc_service_se_detected(net_nfc_request_msg_t *msg)
 
        DEBUG_SERVER_MSG("trans param = [%p]", resp.trans_param);
 
-       net_nfc_send_response_msg(detail_msg->client_fd, NET_NFC_MESSAGE_OPEN_INTERNAL_SE, &resp, sizeof(net_nfc_response_open_internal_se_t), NULL);
+       net_nfc_send_response_msg(detail_msg->client_fd, NET_NFC_MESSAGE_OPEN_INTERNAL_SE,
+               &resp, sizeof(net_nfc_response_open_internal_se_t), NULL);
 
        g_se_setting.open_request_trans_param = NULL;
 }
@@ -209,7 +216,7 @@ net_nfc_error_e net_nfc_service_se_close_ese()
 
        if (g_se_setting.current_ese_handle != NULL)
        {
-               if (net_nfc_controller_disconnect(g_se_setting.current_ese_handle, &result) == false)
+               if (net_nfc_controller_secure_element_close(g_se_setting.current_ese_handle, &result) == false)
                {
                        net_nfc_controller_exception_handler();
                }
@@ -381,12 +388,14 @@ void _uicc_transmit_apdu_cb(TapiHandle *handle, int result, void *data, void *us
                resp.data.length = apdu->apdu_resp_len;
 
                DEBUG_MSG("send response send apdu msg");
-               net_nfc_send_response_msg(param->client_fd, NET_NFC_MESSAGE_SEND_APDU_SE, (void *)&resp, sizeof(net_nfc_response_send_apdu_t), apdu->apdu_resp, apdu->apdu_resp_len, NULL);
+               net_nfc_send_response_msg(param->client_fd, NET_NFC_MESSAGE_SEND_APDU_SE,
+                       (void *)&resp, sizeof(net_nfc_response_send_apdu_t), apdu->apdu_resp, apdu->apdu_resp_len, NULL);
        }
        else
        {
                DEBUG_MSG("send response send apdu msg");
-               net_nfc_send_response_msg(param->client_fd, NET_NFC_MESSAGE_SEND_APDU_SE, (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
+               net_nfc_send_response_msg(param->client_fd, NET_NFC_MESSAGE_SEND_APDU_SE,
+                       (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
        }
 
        _net_nfc_util_free_mem(param);
@@ -435,10 +444,437 @@ bool net_nfc_service_se_transaction_receive(net_nfc_request_msg_t* msg)
        {
                DEBUG_SERVER_MSG("launch se app");
 
-               net_nfc_app_util_launch_se_transaction_app(se_event->aid.buffer, se_event->aid.length, se_event->param.buffer, se_event->param.length);
+               net_nfc_app_util_launch_se_transaction_app(se_event->aid.buffer,
+                       se_event->aid.length, se_event->param.buffer, se_event->param.length);
 
                DEBUG_SERVER_MSG("launch se app end");
        }
 
        return res;
 }
+
+void net_nfc_service_se_send_apdu(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_send_apdu_t *detail = (net_nfc_request_send_apdu_t *)msg;
+
+       if (detail->handle == (net_nfc_target_handle_s *)UICC_TARGET_HANDLE)
+       {
+               data_s apdu_data = { NULL, 0 };
+
+               if (net_nfc_util_duplicate_data(&apdu_data, &detail->data) == false)
+                       return;
+
+               net_nfc_service_transfer_apdu(msg->client_fd, &apdu_data, detail->trans_param);
+
+               net_nfc_util_free_data(&apdu_data);
+       }
+       else if (detail->handle == net_nfc_service_se_get_current_ese_handle())
+       {
+               bool success;
+               data_s command;
+               data_s *response = NULL;
+               net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
+
+               if (net_nfc_util_duplicate_data(&command, &detail->data) == false)
+               {
+                       DEBUG_ERR_MSG("alloc failed");
+                       return;
+               }
+
+               if ((success = net_nfc_controller_secure_element_send_apdu(detail->handle, &command, &response, &result)) == true)
+               {
+                       if (response != NULL)
+                       {
+                               DEBUG_SERVER_MSG("transceive data received, len [%d]", response->length);
+                       }
+               }
+               else
+               {
+                       DEBUG_ERR_MSG("transceive failed = [%d]", result);
+               }
+               net_nfc_util_free_data(&command);
+
+               if (net_nfc_server_check_client_is_running(msg->client_fd))
+               {
+                       net_nfc_response_send_apdu_t resp = { 0, };
+
+                       DEBUG_SERVER_MSG("send response send_apdu");
+
+                       resp.length = sizeof(net_nfc_response_send_apdu_t);
+                       resp.flags = detail->flags;
+                       resp.user_param = detail->user_param;
+                       resp.trans_param = detail->trans_param;
+                       resp.result = result;
+
+                       if (response != NULL)
+                       {
+                               resp.data.length = response->length;
+                               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                                       (void *)&resp, sizeof(net_nfc_response_send_apdu_t),
+                                       response->buffer, response->length, NULL);
+                       }
+                       else
+                       {
+                               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                                       (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
+                       }
+               }
+       }
+       else
+       {
+               DEBUG_SERVER_MSG("invalid se handle");
+
+               if (net_nfc_server_check_client_is_running(msg->client_fd))
+               {
+                       net_nfc_response_send_apdu_t resp = { 0 };
+
+                       resp.length = sizeof(net_nfc_response_send_apdu_t);
+                       resp.flags = detail->flags;
+                       resp.trans_param = detail->trans_param;
+                       resp.result = NET_NFC_INVALID_PARAM;
+
+                       net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                               (void *)&resp, sizeof(net_nfc_response_send_apdu_t), NULL);
+               }
+       }
+}
+
+void net_nfc_service_se_get_atr(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_get_atr_t *detail = (net_nfc_request_get_atr_t *)msg;
+
+       if (detail->handle == (net_nfc_target_handle_s *)UICC_TARGET_HANDLE)
+       {
+               net_nfc_service_request_atr(msg->client_fd, (void *)detail->user_param);
+       }
+       else if (detail->handle == net_nfc_service_se_get_current_ese_handle())
+       {
+               data_s *data = NULL;
+               net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
+
+               /* TODO : get atr */
+#if 0
+               net_nfc_transceive_info_s info;
+
+               info.dev_type = NET_NFC_ISO14443_A_PICC;
+               if (net_nfc_controller_transceive(detail->handle, &info, &data, &result) == true)
+               {
+                       if (data != NULL)
+                       {
+                               DEBUG_SERVER_MSG("transceive data received [%d]", data->length);
+                       }
+               }
+               else
+               {
+                       DEBUG_SERVER_MSG("transceive is failed = [%d]", result);
+               }
+#endif
+               if (net_nfc_server_check_client_is_running(msg->client_fd))
+               {
+                       net_nfc_response_get_atr_t resp = { 0, };
+
+                       resp.length = sizeof(net_nfc_response_get_atr_t);
+                       resp.flags = detail->flags;
+                       resp.user_param = detail->user_param;
+                       resp.result = result;
+
+                       if (data != NULL)
+                       {
+                               DEBUG_SERVER_MSG("send response send apdu msg");
+                               resp.data.length = data->length;
+                               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                                       (void *)&resp, sizeof(net_nfc_response_get_atr_t),
+                                               data->buffer, data->length, NULL);
+                       }
+                       else
+                       {
+                               DEBUG_SERVER_MSG("send response send apdu msg");
+                               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                                       (void *)&resp, sizeof(net_nfc_response_get_atr_t), NULL);
+                       }
+               }
+       }
+       else
+       {
+               DEBUG_SERVER_MSG("invalid se handle");
+
+               if (net_nfc_server_check_client_is_running(msg->client_fd))
+               {
+                       net_nfc_response_get_atr_t resp = { 0 };
+
+                       resp.length = sizeof(net_nfc_response_get_atr_t);
+                       resp.flags = detail->flags;
+                       resp.user_param = detail->user_param;
+                       resp.result = NET_NFC_INVALID_PARAM;
+
+                       net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                               (void *)&resp, sizeof(net_nfc_response_get_atr_t), NULL);
+               }
+       }
+}
+
+void net_nfc_service_se_close_se(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_close_internal_se_t *detail = (net_nfc_request_close_internal_se_t *)msg;
+       net_nfc_error_e result = NET_NFC_OK;
+
+       if (detail->handle == (net_nfc_target_handle_s *)UICC_TARGET_HANDLE)
+       {
+               /*deinit TAPI*/
+               DEBUG_SERVER_MSG("UICC is current secure element");
+               net_nfc_service_tapi_deinit();
+
+       }
+       else if (detail->handle == net_nfc_service_se_get_current_ese_handle())
+       {
+               result = net_nfc_service_se_close_ese();
+#ifdef BROADCAST_MESSAGE
+               net_nfc_server_unset_server_state(NET_NFC_SE_CONNECTED);
+#endif
+       }
+       else
+       {
+               DEBUG_ERR_MSG("invalid se handle received handle = [0x%p] and current handle = [0x%p]",
+                       detail->handle, net_nfc_service_se_get_current_ese_handle());
+       }
+
+       if ((g_se_prev_type != net_nfc_service_se_get_se_type()) || (g_se_prev_mode != net_nfc_service_se_get_se_mode()))
+       {
+               /*return back se mode*/
+               net_nfc_controller_set_secure_element_mode(g_se_prev_type, g_se_prev_mode, &result);
+
+               net_nfc_service_se_set_se_type(g_se_prev_type);
+               net_nfc_service_se_set_se_mode(g_se_prev_mode);
+       }
+
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_close_internal_se_t resp = { 0 };
+
+               resp.length = sizeof(net_nfc_response_close_internal_se_t);
+               resp.flags = detail->flags;
+               resp.trans_param = detail->trans_param;
+               resp.result = result;
+
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_close_internal_se_t), NULL);
+       }
+
+}
+
+void net_nfc_service_se_open_se(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_open_internal_se_t *detail = (net_nfc_request_open_internal_se_t *)msg;
+       net_nfc_target_handle_s *handle = NULL;
+       net_nfc_error_e result = NET_NFC_OK;
+
+       g_se_prev_type = net_nfc_service_se_get_se_type();
+       g_se_prev_mode = net_nfc_service_se_get_se_mode();
+
+       if (detail->se_type == SECURE_ELEMENT_TYPE_UICC)
+       {
+               /*off ESE*/
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_OFF_MODE, &result);
+
+               /*Off UICC. UICC SHOULD not be detected by external reader when being communicated in internal process*/
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
+
+               net_nfc_service_se_set_se_type(SECURE_ELEMENT_TYPE_UICC);
+               net_nfc_service_se_set_se_mode(SECURE_ELEMENT_OFF_MODE);
+
+               /*Init tapi api and return back response*/
+               if (net_nfc_service_tapi_init() != true)
+               {
+                       net_nfc_service_tapi_deinit();
+                       result = NET_NFC_INVALID_STATE;
+                       handle = NULL;
+               }
+               else
+               {
+                       result = NET_NFC_OK;
+                       handle = (net_nfc_target_handle_s *)UICC_TARGET_HANDLE;
+               }
+       }
+       else if (detail->se_type == SECURE_ELEMENT_TYPE_ESE)
+       {
+               /*off UICC*/
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
+
+               if (net_nfc_controller_secure_element_open(SECURE_ELEMENT_TYPE_ESE, &handle, &result) == true)
+               {
+                       net_nfc_service_se_set_se_type(SECURE_ELEMENT_TYPE_ESE);
+                       net_nfc_service_se_set_se_mode(SECURE_ELEMENT_WIRED_MODE);
+
+                       net_nfc_service_se_get_se_setting()->open_request_trans_param = detail->trans_param;
+                       net_nfc_service_se_set_current_ese_handle(handle);
+
+                       DEBUG_ERR_MSG("handle [%p]", handle);
+               }
+               else
+               {
+                       DEBUG_ERR_MSG("net_nfc_controller_secure_element_open failed [%d]", result);
+               }
+       }
+       else
+       {
+               result = NET_NFC_INVALID_STATE;
+               handle = NULL;
+       }
+
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_open_internal_se_t resp = { 0 };
+
+               resp.length = sizeof(net_nfc_response_open_internal_se_t);
+               resp.flags = detail->flags;
+               resp.user_param = detail->user_param;
+               resp.trans_param = detail->trans_param;
+               resp.result = result;
+               resp.se_type = detail->se_type;
+               resp.handle = handle;
+
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_open_internal_se_t), NULL);
+       }
+}
+
+void net_nfc_service_se_set_se(net_nfc_request_msg_t *msg)
+{
+#if 1
+       net_nfc_request_set_se_t *detail = (net_nfc_request_set_se_t *)msg;
+       net_nfc_error_e result = NET_NFC_OK;
+       bool isTypeChange = false;
+
+       if (detail->se_type != net_nfc_service_se_get_se_type())
+       {
+               result = net_nfc_service_se_change_se(detail->se_type);
+               isTypeChange = true;
+       }
+
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_set_se_t resp = { 0 };
+
+               resp.length = sizeof(net_nfc_response_set_se_t);
+               resp.flags = detail->flags;
+               resp.trans_param = detail->trans_param;
+               resp.se_type = detail->se_type;
+               resp.result = result;
+
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_set_se_t), NULL);
+       }
+
+       if (isTypeChange)
+       {
+               net_nfc_response_notify_t noti_se = { 0, };
+
+               net_nfc_broadcast_response_msg(NET_NFC_MESSAGE_SE_TYPE_CHANGED,
+                       (void *)&noti_se, sizeof(net_nfc_response_notify_t), NULL);
+       }
+
+#else
+       net_nfc_request_set_se_t *detail = (net_nfc_request_set_se_t *)msg;
+       net_nfc_error_e result = NET_NFC_OK;
+       int mode;
+
+       mode = (int)detail->se_type;
+
+       if (mode == NET_NFC_SE_CMD_UICC_ON)
+       {
+               /*turn on UICC*/
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+                       SECURE_ELEMENT_VIRTUAL_MODE, &result);
+
+               /*turn off ESE*/
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+                       SECURE_ELEMENT_OFF_MODE, &result);
+       }
+       else if (mode == NET_NFC_SE_CMD_ESE_ON)
+       {
+               /*turn off UICC*/
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+                       SECURE_ELEMENT_OFF_MODE, &result);
+
+               /*turn on ESE*/
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+                       SECURE_ELEMENT_VIRTUAL_MODE, &result);
+       }
+       else if (mode == NET_NFC_SE_CMD_ALL_OFF)
+       {
+               /*turn off both*/
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+                       SECURE_ELEMENT_OFF_MODE, &result);
+
+               /*turn on ESE*/
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+                       SECURE_ELEMENT_OFF_MODE, &result);
+       }
+       else
+       {
+               /*turn off both*/
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+                       SECURE_ELEMENT_VIRTUAL_MODE, &result);
+
+               /*turn on ESE*/
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+                       SECURE_ELEMENT_VIRTUAL_MODE, &result);
+       }
+#endif
+}
+
+void net_nfc_service_se_get_se(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_get_se_t *detail = (net_nfc_request_get_se_t *)msg;
+
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_get_se_t resp = { 0 };
+
+               resp.length = sizeof(net_nfc_request_get_se_t);
+               resp.flags = detail->flags;
+               resp.trans_param = detail->trans_param;
+               resp.result = NET_NFC_OK;
+               resp.se_type = net_nfc_service_se_get_se_type();
+
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_get_se_t), NULL);
+       }
+}
+
+void net_nfc_service_se_cleanup()
+{
+       DEBUG_SERVER_MSG("client is terminated abnormally");
+
+       if (g_se_prev_type == SECURE_ELEMENT_TYPE_ESE)
+       {
+               net_nfc_error_e result = NET_NFC_OK;
+               net_nfc_target_handle_s *ese_handle = net_nfc_service_se_get_current_ese_handle();
+
+               if (ese_handle != NULL)
+               {
+                       DEBUG_SERVER_MSG("ese_handle was not freed and disconnected");
+
+                       net_nfc_service_se_close_ese();
+#ifdef BROADCAST_MESSAGE
+                       net_nfc_server_set_server_state(NET_NFC_SERVER_IDLE);
+#endif
+               }
+
+               if ((g_se_prev_type != net_nfc_service_se_get_se_type()) || (g_se_prev_mode != net_nfc_service_se_get_se_mode()))
+               {
+                       net_nfc_controller_set_secure_element_mode(g_se_prev_type, g_se_prev_mode, &result);
+
+                       net_nfc_service_se_set_se_type(g_se_prev_type);
+                       net_nfc_service_se_set_se_mode(g_se_prev_mode);
+               }
+       }
+       else if (g_se_prev_type == SECURE_ELEMENT_TYPE_UICC)
+       {
+               net_nfc_service_tapi_deinit();
+       }
+       else
+       {
+               DEBUG_SERVER_MSG("SE type is not valid");
+       }
+}
index 890d59d..7a71355 100755 (executable)
@@ -27,6 +27,7 @@
 #include "net_nfc_server_ipc_private.h"
 #include "net_nfc_server_dispatcher_private.h"
 #include "net_nfc_manager_util_private.h"
+#include "net_nfc_server_context_private.h"
 
 /* define */
 
@@ -177,3 +178,141 @@ data_s* net_nfc_service_tag_process(net_nfc_target_handle_s* handle, int devType
 
 }
 #endif
+
+void net_nfc_service_tag_make_readonly(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_make_read_only_ndef_t *detail = (net_nfc_request_make_read_only_ndef_t *)msg;
+       net_nfc_error_e result = NET_NFC_OK;
+
+       if (net_nfc_server_is_target_connected(detail->handle))
+       {
+               net_nfc_controller_make_read_only_ndef(detail->handle, &result);
+       }
+       else
+       {
+               result = NET_NFC_TARGET_IS_MOVED_AWAY;
+       }
+
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_make_read_only_ndef_t resp = { 0, };
+
+               resp.length = sizeof(net_nfc_response_make_read_only_ndef_t);
+               resp.flags = detail->flags;
+               resp.result = result;
+               resp.trans_param = detail->trans_param;
+
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_write_ndef_t), NULL);
+       }
+}
+
+void net_nfc_service_tag_read_ndef(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_read_ndef_t *detail = (net_nfc_request_read_ndef_t *)msg;
+       net_nfc_error_e result = NET_NFC_TARGET_IS_MOVED_AWAY;
+       data_s *data = NULL;
+
+       if (net_nfc_server_is_target_connected(detail->handle))
+       {
+               net_nfc_controller_read_ndef(detail->handle, &data, &result);
+       }
+
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_read_ndef_t resp = { 0, };
+
+               resp.length = sizeof(net_nfc_response_read_ndef_t);
+               resp.flags = detail->flags;
+               resp.result = result;
+               resp.trans_param = detail->trans_param;
+
+               if (data != NULL)
+               {
+                       resp.data.length = data->length;
+                       net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                               (void *)&resp, sizeof(net_nfc_response_read_ndef_t),
+                               data->buffer, data->length, NULL);
+               }
+               else
+               {
+                       net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                               (void *)&resp, sizeof(net_nfc_response_read_ndef_t), NULL);
+               }
+       }
+
+       if (data != NULL)
+       {
+               net_nfc_util_free_data(data);
+               _net_nfc_util_free_mem(data);
+       }
+}
+
+void net_nfc_service_tag_write_ndef(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_write_ndef_t *detail = (net_nfc_request_write_ndef_t *)msg;
+       net_nfc_error_e result = NET_NFC_TARGET_IS_MOVED_AWAY;
+
+       if (net_nfc_server_is_target_connected(detail->handle))
+       {
+               data_s data = { NULL, 0 };
+
+               if (net_nfc_util_duplicate_data(&data, &detail->data) == true)
+               {
+                       net_nfc_controller_write_ndef(detail->handle, &data, &result);
+
+                       net_nfc_util_free_data(&data);
+               }
+               else
+               {
+                       result = NET_NFC_ALLOC_FAIL;
+               }
+       }
+
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_write_ndef_t resp = { 0, };
+
+               resp.length = sizeof(net_nfc_response_write_ndef_t);
+               resp.flags = detail->flags;
+               resp.result = result;
+               resp.trans_param = detail->trans_param;
+
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_write_ndef_t), NULL);
+       }
+}
+
+void net_nfc_service_tag_format_ndef(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_format_ndef_t *detail = (net_nfc_request_format_ndef_t *)msg;
+       net_nfc_error_e result = NET_NFC_TARGET_IS_MOVED_AWAY;
+
+       if (net_nfc_server_is_target_connected(detail->handle))
+       {
+               data_s data = { NULL, 0 };
+
+               if (net_nfc_util_duplicate_data(&data, &detail->key) == true)
+               {
+                       net_nfc_controller_format_ndef(detail->handle, &data, &result);
+                       net_nfc_util_free_data(&data);
+               }
+               else
+               {
+                       result = NET_NFC_ALLOC_FAIL;
+               }
+       }
+
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_format_ndef_t resp = { 0 };
+
+               resp.length = sizeof(net_nfc_response_format_ndef_t);
+               resp.flags = detail->flags;
+               resp.result = result;
+               resp.trans_param = detail->trans_param;
+
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_format_ndef_t), NULL);
+       }
+}
diff --git a/src/manager/net_nfc_service_test.c b/src/manager/net_nfc_service_test.c
new file mode 100644 (file)
index 0000000..84d1e1b
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "net_nfc_typedef.h"
+#include "net_nfc_debug_private.h"
+#include "net_nfc_util_private.h"
+#include "net_nfc_server_ipc_private.h"
+#include "net_nfc_controller_private.h"
+#include "net_nfc_service_test_private.h"
+#include "net_nfc_server_context_private.h"
+
+void net_nfc_service_test_sim_test(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_test_t *detail = (net_nfc_request_test_t *)msg;
+       net_nfc_error_e result = NET_NFC_OK;
+
+       if (net_nfc_controller_sim_test(&result) == true)
+       {
+               DEBUG_SERVER_MSG("net_nfc_controller_sim_test Result [SUCCESS]");
+       }
+       else
+       {
+               DEBUG_SERVER_MSG("net_nfc_controller_sim_test Result [ERROR1]");
+       }
+
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_test_t resp = { 0, };
+
+               resp.length = sizeof(net_nfc_response_test_t);
+               resp.flags = detail->flags;
+               resp.result = result;
+               resp.trans_param = detail->trans_param;
+
+               DEBUG_SERVER_MSG("SEND RESPONSE!!");
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+       }
+}
+
+void net_nfc_service_test_get_firmware_version(net_nfc_request_msg_t *msg)
+{
+       net_nfc_error_e result = NET_NFC_OK;
+       data_s *data = NULL;
+
+       if (net_nfc_controller_get_firmware_version(&data, &result) == true)
+       {
+               DEBUG_SERVER_MSG("net_nfc_controller_update_firmware Result [SUCCESS]");
+
+       }
+       else
+       {
+               DEBUG_ERR_MSG("net_nfc_controller_update_firmware Result [ERROR3]");
+       }
+
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_firmware_version_t resp = { 0, };
+
+               resp.length = sizeof(net_nfc_response_firmware_version_t);
+               resp.flags = msg->flags;
+               resp.result = result;
+               resp.data.length = data->length;
+
+               if (data != NULL)
+               {
+                       net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                               (void *)&resp, sizeof(net_nfc_response_firmware_version_t),
+                               (void *)data->buffer, resp.data.length, NULL);
+               }
+               else
+               {
+                       net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                               (void *)&resp, sizeof(net_nfc_response_firmware_version_t), NULL);
+               }
+       }
+
+       if (data != NULL)
+       {
+               net_nfc_util_free_data(data);
+               _net_nfc_util_free_mem(data);
+       }
+}
+
+void net_nfc_service_test_prbs_test(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_test_t *detail = (net_nfc_request_test_t *)msg;
+       net_nfc_error_e result = NET_NFC_OK;
+       uint32_t local_tech = 0;
+       uint32_t local_rate = 0;
+
+       local_tech = detail->tech;
+       local_rate = detail->rate;
+
+       DEBUG_SERVER_MSG("local_tech [%d]\n", local_tech);
+       DEBUG_SERVER_MSG("local_rate [%d]\n", local_rate);
+
+       if (net_nfc_controller_prbs_test(&result, local_tech, local_rate) == true)
+       {
+               DEBUG_SERVER_MSG("net_nfc_controller_prbs_test Result [SUCCESS]");
+       }
+       else
+       {
+               DEBUG_ERR_MSG("net_nfc_controller_prbs_test Result [ERROR3]");
+       }
+
+       if (net_nfc_server_check_client_is_running(msg->client_fd))
+       {
+               net_nfc_response_test_t resp = { 0, };
+
+               resp.length = sizeof(net_nfc_response_test_t);
+               resp.flags = detail->flags;
+               resp.result = result;
+               resp.trans_param = detail->trans_param;
+
+               DEBUG_SERVER_MSG("SEND RESPONSE!!");
+               net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                       (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+       }
+}
+
+void net_nfc_service_test_set_eedata(net_nfc_request_msg_t *msg)
+{
+       net_nfc_request_eedata_register_t *detail = (net_nfc_request_eedata_register_t *)msg;
+       net_nfc_error_e result = NET_NFC_OK;
+       uint32_t local_mode = 0;
+       uint32_t local_reg_id = 0;
+       data_s data = { NULL, 0 };
+
+       local_mode = detail->mode;
+       local_reg_id = detail->reg_id;
+
+       DEBUG_SERVER_MSG("local_mode [%d]\n", local_mode);
+       DEBUG_SERVER_MSG("local_reg_id [%d]\n", local_reg_id);
+
+       if (net_nfc_util_duplicate_data(&data, &detail->data) == true)
+       {
+               if (net_nfc_controller_eedata_register_set(&result, local_mode,
+                       local_reg_id, &data) == true)
+               {
+                       DEBUG_SERVER_MSG("net_nfc_controller_eedata_register_set Result [SUCCESS]");
+               }
+               else
+               {
+                       DEBUG_ERR_MSG("net_nfc_controller_eedata_register_set Result [ERROR3]");
+               }
+               net_nfc_util_free_data(&data);
+
+               if (net_nfc_server_check_client_is_running(msg->client_fd))
+               {
+                       net_nfc_response_test_t resp = { 0, };
+
+                       resp.length = sizeof(net_nfc_response_test_t);
+                       resp.flags = detail->flags;
+                       resp.result = result;
+                       resp.trans_param = detail->trans_param;
+
+                       DEBUG_SERVER_MSG("SEND RESPONSE!!");
+                       net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+                               (void *)&resp, sizeof(net_nfc_response_test_t), NULL);
+               }
+       }
+}
index 6f9ad73..9f07add 100644 (file)
@@ -1,18 +1,18 @@
 /*
 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
-
 *     http://floralicense.org/license/
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
+ * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 
 #include <stdio.h>
@@ -24,6 +24,7 @@
 #include <sys/time.h>
 
 #include "package-manager.h"
+#include "pkgmgr-info.h"
 #include "SEService.h"
 #include "Reader.h"
 #include "Session.h"
@@ -118,7 +119,7 @@ static gp_se_acl_h _get_acl(reader_h reader)
                unsigned char aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35 };
                channel_h channel = NULL;
 
-               channel = session_open_basic_channel_sync(session, aid, sizeof(aid));
+               channel = session_open_logical_channel_sync(session, aid, sizeof(aid));
                if (channel != NULL)
                {
                        result = gp_se_acl_create_instance(channel);
@@ -213,8 +214,25 @@ bool net_nfc_util_access_control_is_authorized_package(const char *pkg_name, uin
        net_nfc_util_access_control_initialize();
        {
                pkgmgr_certinfo_h cert_info = NULL;
+               pkgmgrinfo_appinfo_h handle;
+               char *pkgid = NULL;
+
+               if(pkgmgrinfo_appinfo_get_appinfo(pkg_name, &handle) != PMINFO_R_OK)
+               {
+                       DEBUG_ERR_MSG("pkgmgrinfo_appinfo_get_appinfo fail");
+                       return result;
+               }
+
+               if(pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid) != PMINFO_R_OK)
+               {
+                       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+                       DEBUG_ERR_MSG("pkgmgrinfo_appinfo_get_pkgid fail");
+                       return result;
+               }
+               cert_info = _get_cert_info(pkgid);
+
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
 
-               cert_info = _get_cert_info(pkg_name);
                if (cert_info != NULL)
                {
                        int i;