GSMA api update 72/12672/1 accepted/tizen/ivi/stable accepted/tizen/mobile accepted/tizen/20131126.000307 accepted/tizen/20131126.004400 accepted/tizen/generic/20140306.081813 accepted/tizen/ivi/20140307.055434 accepted/tizen/mobile/20140306.024700 submit/tizen/20131122.052914 submit/tizen/20140305.214055
authorSangSoo Lee <constant.lee@samsung.com>
Thu, 21 Nov 2013 04:56:46 +0000 (13:56 +0900)
committerJi-hoon Jung <jh8801.jung@samsung.com>
Thu, 21 Nov 2013 04:58:33 +0000 (13:58 +0900)
Change-Id: I0f4647b1e957f871dcf7a9a0b1687d8636427a04
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
TC/testcase/utc_network_nfc_ndef_message.c
TC/testcase/utc_network_nfc_ndef_record.c
include/nfc.h
include/nfc_internal.h
packaging/capi-network-nfc.spec
src/nfc.c
test/network_nfc_test.c

index 922370e..6795f77 100644 (file)
@@ -107,7 +107,7 @@ static void utc_nfc_ndef_message_create_from_rawdata_p(void)
 {
        int ret;
        unsigned char *buffer;
-       int size;
+       uint32_t int size;
        nfc_ndef_message_h message;
        nfc_ndef_message_h message2;
        nfc_ndef_record_h record1;
@@ -183,7 +183,7 @@ static void utc_nfc_ndef_message_get_rawdata_p(void)
 {
        int ret;
        unsigned char *buffer;
-       int size;
+       uint32_t size;
        nfc_ndef_message_h message;
        nfc_ndef_record_h record1;
 
index 84997af..72d4c75 100644 (file)
@@ -309,7 +309,7 @@ static void utc_nfc_ndef_record_get_id_n(void)
 static void utc_nfc_ndef_record_get_payload_p(void)
 {
        int ret;
-       int size;
+       uint32_t size;
        nfc_ndef_record_h record;
        unsigned char *payload;
 
index d59f482..3e186d8 100644 (file)
@@ -155,7 +155,8 @@ typedef enum{
        NFC_SE_EVENT_FIELD_ON, /**< When the CLF(Contactless Front-end) detects a RF field, the card RF gate sends the event #NFC_SE_EVENT_FIELD_ON to the card application gate.\nWhen there are multiple open card RF gates the CLF shall send the #NFC_SE_EVENT_FIELD_ON on all open pipes to these gates.Next the CLF starts the initialization and anti-collision process as defined in ISO/IEC 14443-3 [6]*/
        NFC_SE_EVENT_FIELD_OFF, /**< When the CLF(Contactless Front-end) detects that the RF field is off, the card RF gate shall send #NFC_SE_EVENT_FIELD_OFF to the card application gate.\nWhen there are multiple open card RF gates the CLF shall send the #NFC_SE_EVENT_FIELD_OFF to one gate only.*/
        NFC_SE_EVENT_TRANSACTION, /**< This event  notifies , external reader trys to access secure element */
-       NFC_SE_EVENT_SE_TYPE_CHANGED /**< This event notifies, changing the emulated secure element type */
+       NFC_SE_EVENT_SE_TYPE_CHANGED, /**< This event notifies, changing the emulated secure element type */
+       NFC_SE_EVENT_CARD_EMULATION_CHANGED, /**< This event notifies, changing the card emulation mode */
 } nfc_se_event_e;
 
 /**
@@ -169,6 +170,15 @@ typedef enum{
 } nfc_se_type_e;
 
 /**
+ * @brief Enumerations for NFC Card Emulation Mode type
+ * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
+ */
+typedef enum{
+       NFC_SE_CARD_EMULATION_MODE_OFF = 0x00, /**< Card Emulation mode OFF */
+       NFC_SE_CARD_EMULATION_MODE_ON = 0x01, /**< Card Emulation mode ON */
+} nfc_se_card_emulation_mode_type_e;
+
+/**
  * @brief Enumerations for NFC AC(Alternative Carrier)
  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
  */
@@ -619,6 +629,7 @@ typedef void (*nfc_se_event_cb)(nfc_se_event_e event , void *user_data);
  * @remarks This event  notifies , external reader trys to access secure element.
  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
  *
+ * @param [in] se type
  * @param [in] aid Application Id, specified in ISO/IEC 7816-4
  * @param [in] aid_size The size of aid (5~16)
  * @param [in] param The parameter list, specified in ISO/IEC 8825-1
@@ -628,7 +639,7 @@ typedef void (*nfc_se_event_cb)(nfc_se_event_e event , void *user_data);
  * @see nfc_manager_set_se_transaction_event_cb()
  * @see nfc_manager_unset_se_transaction_event_cb()
  */
-typedef void (*nfc_se_transaction_event_cb)(unsigned char* aid, int aid_size , unsigned char* param, int param_size,  void *user_data);
+typedef void (*nfc_se_transaction_event_cb)(nfc_se_type_e se_type, unsigned char* aid, int aid_size , unsigned char* param, int param_size,  void *user_data);
 
 
 
@@ -923,6 +934,7 @@ void nfc_manager_unset_se_event_cb(void);
  * @brief Registers a callback function for receiving  Secure Element (SIM/UICC(Universal Integrated Circuit Card)) transaction event(#NFC_SE_EVENT_TRANSACTION) data.
  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
  *
+ * @param [in] se_type The type of secure element.
  * @param [in] callback The callback function called when occurred SE transaction event.
  * @param [in] user_data The user data to be passed to the callback function
  *
@@ -933,16 +945,19 @@ void nfc_manager_unset_se_event_cb(void);
  * @see nfc_se_transaction_event_cb()
  * @see nfc_manager_unset_se_transaction_event_cb()
  */
-int nfc_manager_set_se_transaction_event_cb(nfc_se_transaction_event_cb callback, void *user_data);
+int nfc_manager_set_se_transaction_event_cb(nfc_se_type_e se_type, 
+               nfc_se_transaction_event_cb callback, void *user_data);
 
 /**
  * @brief Unregisters the callback function.
  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
  *
+ * @param [in] se_type The type of secure element.
+ *
  * @see nfc_se_transaction_event_cb()
  * @see nfc_manager_set_se_transaction_event_cb()
  */
-void nfc_manager_unset_se_transaction_event_cb(void);
+void nfc_manager_unset_se_transaction_event_cb(nfc_se_type_e se_type);
 
 /**
  * @brief Gets NDEF message cached when the tag is detected or when data received from NFC peer-to-peer target.
@@ -1088,6 +1103,19 @@ int nfc_manager_set_card_emulation_se_type(nfc_se_type_e type, nfc_set_card_emul
 int nfc_manager_get_card_emulation_se_type(nfc_se_type_e* type);
 
 /**
+ * @brief Gets the card emulation Secure Element type
+ * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
+ *
+ * @param [in] type The type of Secure Element
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #NFC_ERROR_NONE Successful
+ * @retval #NFC_ERROR_INVALID_PARAMETER        Invalid parameter
+ *
+ */
+int nfc_manager_set_se_type(nfc_se_type_e type);
+
+/**
  * @brief Creates a record with given parameter value.
  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
  *
@@ -1279,7 +1307,7 @@ int nfc_ndef_record_get_id(nfc_ndef_record_h record, unsigned char **id, int *si
  * @retval #NFC_ERROR_NONE Successful
  * @retval #NFC_ERROR_INVALID_PARAMETER        Invalid parameter
  */
-int nfc_ndef_record_get_payload(nfc_ndef_record_h record, unsigned char ** payload, int *size);
+int nfc_ndef_record_get_payload(nfc_ndef_record_h record, unsigned char ** payload, unsigned int *size);
 
 /**
  * @brief Gets record type.
@@ -1447,7 +1475,7 @@ int nfc_ndef_message_create(nfc_ndef_message_h *ndef_message);
  * @see nfc_ndef_message_destroy()
  * @see nfc_ndef_message_get_rawdata()
  */
-int nfc_ndef_message_create_from_rawdata(nfc_ndef_message_h *ndef_message, const unsigned char *rawdata, int rawdata_size);
+int nfc_ndef_message_create_from_rawdata(nfc_ndef_message_h *ndef_message, const unsigned char *rawdata, unsigned int rawdata_size);
 
 /**
  * @brief Destroys NDEF message handle
@@ -1497,7 +1525,7 @@ int nfc_ndef_message_get_record_count(nfc_ndef_message_h ndef_message, int *coun
  *
  * @see nfc_ndef_message_create_from_rawdata()
  */
-int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message, unsigned char **rawdata, int *rawdata_size);
+int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message, unsigned char **rawdata, unsigned int *rawdata_size);
 
 /**
  * @brief Appends a record into NDEF message
@@ -2301,6 +2329,39 @@ int nfc_snep_unregister_server(const char *san, int sap);
 int nfc_se_open_secure_element(nfc_se_type_e se_type, nfc_se_h *handle);
 
 /**
+ * @brief Enable card emulation mode.
+ * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
+ *
+ * @return 0 on success, otherwise a negative error value.
+ *
+ * @see nfc_se_disable_card_emulation()
+ */
+int nfc_se_enable_card_emulation();
+
+/**
+ * @brief Disable card emulation mode.
+ * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
+ *
+ * @return 0 on success, otherwise a negative error value.
+ *
+ * @see nfc_se_enable_card_emulation()
+ */
+int nfc_se_disable_card_emulation();
+
+/**
+ * @brief Get the current card emulation mode.
+ * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
+ *
+ * @param [out]  type   The current card emulation mode type
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #NFC_ERROR_NONE Successful
+ * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
+ *
+ */
+int nfc_se_get_card_emulation_mode(nfc_se_card_emulation_mode_type_e *type);
+
+/**
  * @brief Open connection to secure element.
  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
  *
index 235a7f9..9ab6e87 100644 (file)
@@ -43,6 +43,10 @@ typedef struct
 
        nfc_se_transaction_event_cb on_se_transaction_event_cb;
        void *on_se_transaction_event_user_data;
-}_nfc_context_s;
 
-#endif //__NFC_INTERNAL_H__
\ No newline at end of file
+       nfc_se_event_cb                         on_se_event_cb;
+       void                            *on_se_event_user_data;
+}
+_nfc_context_s;
+
+#endif // _NFC_INTERNAL_H__
index e3bf7b6..e0f0d22 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-network-nfc
 Summary:    NFC Core API
-Version:    0.1.4
+Version:    0.1.5
 Release:    0
 Group:      Network & Connectivity/NFC
 License:    Apache-2.0
index 888fdf7..33263c7 100644 (file)
--- a/src/nfc.c
+++ b/src/nfc.c
@@ -497,6 +497,21 @@ static void _p2p_device_detached(void *user_data)
        gdbus_nfc_context.current_target = NULL;
 }
 
+static void _se_event_cb(net_nfc_message_e message, void *user_data)
+{
+       if (gdbus_nfc_context.on_se_event_cb != NULL) {
+               if(message == NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED)
+                       gdbus_nfc_context.on_se_event_cb(
+                               NFC_SE_EVENT_CARD_EMULATION_CHANGED,
+                               gdbus_nfc_context.on_se_event_user_data);
+
+               else if(message == NET_NFC_MESSAGE_SE_TYPE_CHANGED)
+                       gdbus_nfc_context.on_se_event_cb(
+                               NFC_SE_EVENT_SE_TYPE_CHANGED,
+                               gdbus_nfc_context.on_se_event_user_data);
+       }
+}
+
 /* deprecated */
 static gboolean _initialize_cb(gpointer user_data)
 {
@@ -546,6 +561,7 @@ int nfc_manager_initialize(nfc_initialize_completed_cb callback, void *user_data
                net_nfc_client_p2p_set_device_discovered(_p2p_target_discovered_cb, NULL);
 
                net_nfc_client_p2p_set_device_detached(_p2p_device_detached, NULL);
+               net_nfc_client_se_set_event_cb(_se_event_cb, NULL);
 
                /* invoke callback if it needs */
                if (callback != NULL) {
@@ -600,6 +616,7 @@ int nfc_manager_initialize_sync()
                net_nfc_client_p2p_set_device_discovered(_p2p_target_discovered_cb, NULL);
 
                net_nfc_client_p2p_set_device_detached(_p2p_device_detached, NULL);
+               net_nfc_client_se_set_event_cb(_se_event_cb, NULL);
 #if 0
                ret = net_nfc_client_tag_is_tag_connected_sync(&devType);
                if (ret == NET_NFC_OK)
@@ -800,7 +817,7 @@ int nfc_tag_read_ndef(nfc_tag_h tag, nfc_tag_read_completed_cb callback,
 }
 
 int nfc_ndef_message_get_rawdata_size(nfc_ndef_message_h ndef_message,
-               int *byte_size)
+               unsigned int *byte_size)
 {
        int ret;
 
@@ -836,7 +853,7 @@ int nfc_tag_write_ndef(nfc_tag_h tag, nfc_ndef_message_h msg,
                nfc_tag_write_completed_cb callback, void *user_data)
 {
        int ret;
-       int byte_size = 0;
+       unsigned int byte_size = 0;
        GVariant *parameter;
 
        if (tag == NULL)
@@ -1015,8 +1032,9 @@ int nfc_ndef_record_set_id(nfc_ndef_record_h record, unsigned char *id, int id_s
        return _convert_error_code(__func__, ret);
 }
 
-int nfc_ndef_record_get_payload(nfc_ndef_record_h record, unsigned char **payload,
-               int *size)
+int nfc_ndef_record_get_payload(nfc_ndef_record_h record,
+       unsigned char **payload,
+       unsigned int *size)
 {
        int ret;
        data_s *payload_data;
@@ -1162,8 +1180,10 @@ int nfc_ndef_message_create(nfc_ndef_message_h *ndef_message)
        return _convert_error_code(__func__, ret);
 }
 
-int nfc_ndef_message_create_from_rawdata(nfc_ndef_message_h *ndef_message,
-               const unsigned char *rawdata, int rawdata_size)
+int nfc_ndef_message_create_from_rawdata(
+       nfc_ndef_message_h *ndef_message,
+       const unsigned char *rawdata,
+       unsigned int rawdata_size)
 {
        int ret;
        data_s rawdata_data = { (unsigned char *)rawdata, rawdata_size };
@@ -1202,7 +1222,8 @@ int nfc_ndef_message_get_record_count(nfc_ndef_message_h ndef_message,
 }
 
 int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message,
-               unsigned char **rawdata, int *rawdata_size)
+       unsigned char **rawdata,
+       unsigned int *rawdata_size)
 {
        int ret;
        data_s *rawdata_data;
@@ -2170,6 +2191,39 @@ int nfc_manager_set_card_emulation_se_type(nfc_se_type_e type,
        return _convert_error_code(__func__, ret);
 }
 
+int nfc_manager_set_se_type(nfc_se_type_e type)
+{
+       int ret;
+       net_nfc_se_type_e se_type = NET_NFC_SE_TYPE_NONE;
+
+       if ((type < NFC_SE_TYPE_DISABLE) || (type > NFC_SE_TYPE_UICC))
+       {
+               return _return_invalid_param(__func__);
+       }
+
+       if (!nfc_manager_is_activated())
+       {
+               return NFC_ERROR_NOT_ACTIVATED;
+       }
+
+       switch (type)
+       {
+       case NFC_SE_TYPE_DISABLE :
+               se_type = NET_NFC_SE_TYPE_NONE;
+               break;
+       case NFC_SE_TYPE_ESE :
+               se_type = NET_NFC_SE_TYPE_ESE;
+               break;
+       case NFC_SE_TYPE_UICC :
+               se_type = NET_NFC_SE_TYPE_UICC;
+               break;
+       }
+
+       ret = net_nfc_client_se_set_secure_element_type_sync(se_type);
+
+       return _convert_error_code(__func__, ret);
+}
+
 int nfc_manager_get_card_emulation_se_type(nfc_se_type_e *type)
 {
        int ret;
@@ -2315,6 +2369,50 @@ int nfc_se_close_secure_element(nfc_se_h handle)
        return _convert_error_code(__func__, result);
 }
 
+int nfc_se_enable_card_emulation()
+{
+       net_nfc_error_e result;
+
+       result = net_nfc_set_card_emulation_mode_sync(NET_NFC_CARD_EMELATION_ENABLE);
+
+       return _convert_error_code(__func__, result);
+}
+
+int nfc_se_disable_card_emulation()
+{
+       net_nfc_error_e result;
+
+       result = net_nfc_set_card_emulation_mode_sync(NET_NFC_CARD_EMULATION_DISABLE);
+
+       return _convert_error_code(__func__, result);
+}
+
+int nfc_se_get_card_emulation_mode(nfc_se_card_emulation_mode_type_e *type)
+{
+       net_nfc_error_e result;
+       net_nfc_se_type_e se_type;
+
+       result = net_nfc_get_card_emulation_mode(&se_type);
+
+       if(result == NET_NFC_OK)
+       {
+               if(se_type == NET_NFC_SE_TYPE_NONE)
+               {
+                       *type = NFC_SE_CARD_EMULATION_MODE_OFF;
+               }
+               else if(se_type == NET_NFC_SE_TYPE_ESE || se_type == NET_NFC_SE_TYPE_UICC)
+               {
+                       *type = NFC_SE_CARD_EMULATION_MODE_ON;
+               }
+       }
+       else
+       {
+               result = NET_NFC_OPERATION_FAIL;
+       }
+
+       return _convert_error_code(__func__, result);;
+}
+
 int nfc_manager_set_se_event_cb(nfc_se_event_cb callback, void *user_data)
 {
        if (callback == NULL)
@@ -2335,36 +2433,74 @@ void nfc_manager_unset_se_event_cb(void)
        gdbus_nfc_context.on_se_transaction_event_user_data = NULL;
 }
 
-static void _se_transaction_event_cb(data_s *aid, data_s *param, void *user_data)
+static void _se_transaction_event_cb(
+                                               net_nfc_se_type_e se_type,
+                                               data_s* aid,
+                                               data_s* param,
+                                               void *user_data)
 {
        if (gdbus_nfc_context.on_se_transaction_event_cb != NULL) {
                gdbus_nfc_context.on_se_transaction_event_cb(
-                               net_nfc_get_data_buffer(aid),
-                               net_nfc_get_data_length(aid),
-                               net_nfc_get_data_buffer(param),
-                               net_nfc_get_data_length(param),
-                               gdbus_nfc_context.on_se_transaction_event_user_data);
+                       se_type,
+                       net_nfc_get_data_buffer(aid),
+                       net_nfc_get_data_length(aid),
+                       net_nfc_get_data_buffer(param),
+                       net_nfc_get_data_length(param),
+                       gdbus_nfc_context.on_se_transaction_event_user_data);
        }
 }
 
 int nfc_manager_set_se_transaction_event_cb(
-               nfc_se_transaction_event_cb callback, void *user_data)
+       nfc_se_type_e se_type,
+       nfc_se_transaction_event_cb callback,
+       void *user_data)
 {
+       net_nfc_se_type_e type = NET_NFC_SE_TYPE_NONE;
+
        if (callback == NULL)
                return _return_invalid_param(__func__);
 
        gdbus_nfc_context.on_se_transaction_event_cb = callback;
        gdbus_nfc_context.on_se_transaction_event_user_data = user_data;
 
-       net_nfc_client_se_set_transaction_event_cb(_se_transaction_event_cb,
-                       NULL);
+       switch(se_type)
+       {
+               case NFC_SE_TYPE_ESE:
+                       type = NET_NFC_SE_TYPE_ESE;
+                       break;
+
+               case NFC_SE_TYPE_UICC:
+                       type = NET_NFC_SE_TYPE_UICC;
+                       break;
+               default:
+                       return _return_invalid_param(__func__);
+                       break;
+
+       }
+
+       net_nfc_client_se_set_transaction_event_cb(type, _se_transaction_event_cb, user_data);
 
        return NFC_ERROR_NONE;
 }
 
-void nfc_manager_unset_se_transaction_event_cb(void)
+void nfc_manager_unset_se_transaction_event_cb(nfc_se_type_e se_type)
 {
-       net_nfc_client_se_unset_transaction_event_cb();
+       net_nfc_se_type_e type = NET_NFC_SE_TYPE_NONE;
+
+       switch(se_type)
+       {
+               case NFC_SE_TYPE_ESE:
+                       type = NET_NFC_SE_TYPE_ESE;
+                       break;
+
+               case NFC_SE_TYPE_UICC:
+                       type = NET_NFC_SE_TYPE_UICC;
+                       break;
+               default:
+                       type = NET_NFC_SE_TYPE_NONE;
+                       break;
+       }
+       net_nfc_client_se_unset_transaction_event_cb(type);
 }
 
 /************************************Raw Data- Transceive*********************/
index d20e8de..0882e6d 100644 (file)
@@ -76,7 +76,7 @@ void print_ndef_message(nfc_ndef_message_h message){
        unsigned char *type;
        int type_size;
        unsigned char *payload;
-       int payload_size;
+       uint32_t payload_size;
        nfc_ndef_record_h record;
        int ret;
 
@@ -133,7 +133,7 @@ void ndef_record_create_test(nfc_error_e error, void *user_data){
        unsigned char *id;
        int id_size;
        unsigned char *payload;
-       int payload_size;
+       unsigned int payload_size;
 
        char *strp = NULL;
        char *strp2 = NULL;