Add reader event callback set / unset api 68/79068/6 accepted/tizen/common/20160825.062737 accepted/tizen/ivi/20160825.000724 accepted/tizen/mobile/20160825.000634 accepted/tizen/tv/20160825.000650 accepted/tizen/wearable/20160825.000705 submit/tizen/20160824.060158
authorJihoon Jung <jh8801.jung@samsung.com>
Fri, 8 Jul 2016 05:08:45 +0000 (14:08 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Tue, 16 Aug 2016 07:08:52 +0000 (16:08 +0900)
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
Change-Id: Iaa8a7b797dd210fb53e8b1d10bd787d8a9cd7124

include/smartcard.h [changed mode: 0644->0755]
src/smartcard.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 3806dc7..dc8e78d
@@ -52,9 +52,35 @@ typedef enum {
        SMARTCARD_ERROR_CHANNEL_NOT_AVAILABLE = SMARTCARD_ERROR_CLASS | 0x06, /**< No channel available */
        SMARTCARD_ERROR_NOT_INITIALIZED = SMARTCARD_ERROR_CLASS | 0x07, /**< Smartcard service not initialized */
        SMARTCARD_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+       SMARTCARD_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
 } smartcard_error_e;
 
 /**
+ * @brief Enumerations for Smartcard reader event type
+ * @since_tizen 3.0
+ * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
+ */
+typedef enum {
+       SMARTCARD_READER_EVENT_TYPE_IO_ERROR = 0, /**< This event notifies the application that I/O error occurs on smartcard reader */
+       SMARTCARD_READER_EVENT_TYPE_INSERTED = 1, /**< This event notifies the application that smartcard reader is inserted */
+       SMARTCARD_READER_EVENT_TYPE_REMOVED = 2, /**< This event notifies the application that smartcard reader is removed */
+} smartcard_reader_event_type_e;
+
+/**
+ * @brief Called when a smartcard reader event occurs.
+ * @since_tizen 3.0
+ * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
+ *
+ * @param [in] reader The reader handle
+ * @param [in] event_type The reader event type
+ * @param [in] user_data The user data passed from the callback registration function
+ *
+ * @see smartcard_reader_set_event_cb()
+ * @see smartcard_reader_unset_event_cb()
+ */
+typedef void (*smartcard_reader_event_cb)(int reader, smartcard_reader_event_type_e event_type, void *user_data);
+
+/**
  * @brief Initializes smartcard service
  * @since_tizen 2.3.1
  * @privlevel public
@@ -93,6 +119,25 @@ SMARTCARD_API int smartcard_initialize(void);
 SMARTCARD_API int smartcard_deinitialize(void);
 
 /**
+ * @brief Gets the version of SIMAlliance OpenMobileAPI specification
+ * @since_tizen 3.0
+ * @ingroup CAPI_NETWORK_SMARTCARD_SE_SERVICE_MODULE
+ *
+ * @remarks The @a version must be released using free().
+ *
+ * @param [out] version The version of SIMAlliance OpenMobileAPI specification
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #SMARTCARD_ERROR_NONE Successful
+ * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
+ * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
+ * @retval #SMARTCARD_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ */
+SMARTCARD_API int smartcard_get_version(char **version);
+
+/**
  * @brief Gets the list of available Secure Element readers.
  * @since_tizen 2.3.1
  * @ingroup CAPI_NETWORK_SMARTCARD_SE_SERVICE_MODULE
@@ -203,6 +248,38 @@ SMARTCARD_API int smartcard_reader_open_session(int reader, int *session);
 SMARTCARD_API int smartcard_reader_close_sessions(int reader);
 
 /**
+ * @brief Sets a callback function for receiving reader event.
+ * @since_tizen 3.0
+ * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
+ *
+ * @param [in] cb The reader event callback
+ * @param [in] user_data The user data
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #SMARTCARD_ERROR_NONE Successful
+ * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
+ * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @see smartcard_reader_unset_event_cb()
+ */
+SMARTCARD_API int smartcard_reader_set_event_cb(smartcard_reader_event_cb cb, void *user_data);
+
+/**
+ * @brief Unsets the reader event callback function.
+ * @since_tizen 3.0
+ * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #SMARTCARD_ERROR_NONE Successful
+ * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
+ * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @see smartcard_reader_set_event_cb()
+ */
+SMARTCARD_API int smartcard_reader_unset_event_cb(void);
+
+/**
  * @brief Gets the reader that provides the given session.
  * @since_tizen 2.3.1
  * @ingroup CAPI_NETWORK_SMARTCARD_SESSION_MODULE
old mode 100644 (file)
new mode 100755 (executable)
index fd7474f..f25f943
@@ -187,13 +187,18 @@ static smartcard_error_e _convert_error_code(const char *func, int native_error_
                errorstr = "SMARTCARD_ERROR_ILLEGAL_REFERENCE";
                break;
                /* LCOV_EXCL_STOP */
+       case SCARD_ERROR_NOT_ENOUGH_RESOURCE:
+       case SCARD_ERROR_OUT_OF_MEMORY:
+               /* LCOV_EXCL_START */
+               error_code = SMARTCARD_ERROR_OUT_OF_MEMORY;
+               errorstr = "SMARTCARD_ERROR_OUT_OF_MEMORY";
+               break;
+               /* LCOV_EXCL_STOP */
        case SCARD_ERROR_NOT_INITIALIZED:
        case SCARD_ERROR_SE_NOT_INITIALIZED:
        case SCARD_ERROR_OPERATION_NOT_SUPPORTED:
        case SCARD_ERROR_NEED_MORE_BUFFER:
        case SCARD_ERROR_OPERATION_TIMEOUT:
-       case SCARD_ERROR_NOT_ENOUGH_RESOURCE:
-       case SCARD_ERROR_OUT_OF_MEMORY:
        case SCARD_ERROR_UNKNOWN:
        default:
                /* LCOV_EXCL_START */
@@ -297,6 +302,33 @@ int smartcard_deinitialize(void)
 
 /*----------------<SE Service mapping api>------------------*/
 
+int smartcard_get_version(char **version)
+{
+#ifndef TIZEN_SMARTCARD_SUPPORT
+       return SMARTCARD_ERROR_NOT_SUPPORTED;
+#else
+       int ret = SMARTCARD_ERROR_NONE;
+
+       _BEGIN();
+
+       /* precondition check start */
+       CHECK_SUPPORTED();
+       CHECK_INIT();
+
+       cond_expr_ret(NULL == version, SMARTCARD_ERROR_INVALID_PARAMETER);
+
+       SMARTCARD_LOCK;
+
+       ret = se_service_get_version(se_service, version);
+
+       SMARTCARD_UNLOCK;
+
+       _END();
+
+       return _convert_error_code(__func__, ret);
+#endif
+}
+
 int smartcard_get_readers(int **readers, int *length)
 {
 #ifndef TIZEN_SMARTCARD_SUPPORT
@@ -339,6 +371,56 @@ int smartcard_get_readers(int **readers, int *length)
 
 /*----------------<reader mapping api>------------------*/
 
+int smartcard_reader_set_event_cb(smartcard_reader_event_cb cb, void *user_data)
+{
+#ifndef TIZEN_SMARTCARD_SUPPORT
+       return SMARTCARD_ERROR_NOT_SUPPORTED;
+#else
+       int ret = SMARTCARD_ERROR_NONE;
+
+       _BEGIN();
+
+       /* precondition check start */
+
+       CHECK_SUPPORTED();
+       CHECK_INIT();
+
+       cond_expr_ret(NULL == cb, SMARTCARD_ERROR_INVALID_PARAMETER);
+
+       /* precondition check end */
+
+       se_service_set_event_handler(se_service, (se_service_event_cb)cb, user_data);
+
+       _END();
+
+       return _convert_error_code(__func__, ret);
+#endif
+}
+
+int smartcard_reader_unset_event_cb(void)
+{
+#ifndef TIZEN_SMARTCARD_SUPPORT
+       return SMARTCARD_ERROR_NOT_SUPPORTED;
+#else
+       int ret = SMARTCARD_ERROR_NONE;
+
+       _BEGIN();
+
+       /* precondition check start */
+
+       CHECK_SUPPORTED();
+       CHECK_INIT();
+
+       /* precondition check end */
+
+       se_service_unset_event_handler(se_service);
+
+       _END();
+
+       return _convert_error_code(__func__, ret);
+#endif
+}
+
 int smartcard_reader_get_name(int reader, char **reader_name)
 {
 #ifndef TIZEN_SMARTCARD_SUPPORT