tizen 2.4 release accepted/tizen_2.4_mobile tizen_2.4 accepted/tizen/2.4/mobile/20151029.034434 submit/tizen_2.4/20151028.063704 tizen_2.4_mobile_release
authorjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:26:43 +0000 (16:26 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:26:43 +0000 (16:26 +0900)
doc/mobile/smartcard_doc.h
doc/wearable/smartcard_doc.h
packaging/capi-network-smartcard.spec
src/smartcard.c

index 0fadb3d..5991d16 100644 (file)
@@ -77,7 +77,7 @@
   *
   * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
   *
-  * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+  * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
   *
   */
 
@@ -99,7 +99,7 @@
   *
   * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
   *
-  * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+  * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
   *
   */
 
   *
   * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
   *
-  * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+  * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
   *
   */
 
   *
   * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
   *
-  * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+  * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
   *
   */
 
index 0fadb3d..5991d16 100644 (file)
@@ -77,7 +77,7 @@
   *
   * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
   *
-  * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+  * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
   *
   */
 
@@ -99,7 +99,7 @@
   *
   * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
   *
-  * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+  * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
   *
   */
 
   *
   * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
   *
-  * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+  * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
   *
   */
 
   *
   * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
   *
-  * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+  * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
   *
   */
 
index 52aa015..72a64aa 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-network-smartcard
 Summary:    A Smartcard library in Native API
-Version:    0.0.2
+Version:    0.0.4
 Release:    1
 Group:      TO_BE/FILLED_IN
 License:    Apache-2.0
@@ -34,8 +34,8 @@ Requires: %{name} = %{version}-%{release}
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 
 cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
-%if 0%{?model_build_feature_smartcard}
-       %if "%{_repository}" == "target"
+%if "%{?tizen_profile_name}" == "mobile"
+       %ifarch %{arm}
                -DTIZEN_SMARTCARD_SUPPORT=1
        %endif
 %endif
index 522ae02..984fa72 100644 (file)
 #define  SE_ESE_FEATURE "http://tizen.org/feature/network.secure_element.ese"
 
 #define  SMARTCARD_LOCK \
-do{\
-    pthread_mutex_lock(&mutex);\
-}while(0);
+do { \
+       pthread_mutex_lock(&mutex); \
+} while (0);
 
 #define  SMARTCARD_UNLOCK \
-do{\
-    pthread_mutex_unlock(&mutex);\
-}while(0);
+do { \
+       pthread_mutex_unlock(&mutex); \
+} while (0);
 
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -52,28 +52,26 @@ GList *session_list;
 GList *channel_list;
 
 #define CHECK_SUPPORTED() \
-do{\
+do { \
        { \
-               if(_is_smartcard_supported() == false) \
-               { \
+               if (_is_smartcard_supported() == false) { \
                        return SMARTCARD_ERROR_NOT_SUPPORTED; \
                } \
        } \
-}while(0);
+} while (0);
 
 
 #define CHECK_INIT() \
-do{\
+do { \
        SMARTCARD_LOCK; \
        { \
-               if(_is_initialize == false) \
-               { \
+               if (_is_initialize == false) { \
                        SMARTCARD_UNLOCK; \
                        return SMARTCARD_ERROR_NOT_INITIALIZED; \
                } \
        } \
        SMARTCARD_UNLOCK; \
-}while(0);
+} while (0);
 
 static bool _is_smartcard_supported()
 {
@@ -86,7 +84,7 @@ static bool _is_smartcard_supported()
        system_info_get_platform_bool(SE_UICC_FEATURE, &is_supported_se_uicc);
        system_info_get_platform_bool(SE_ESE_FEATURE, &is_supported_se_ese);
 
-       if(is_supported_se && (is_supported_se_uicc || is_supported_se_ese))
+       if (is_supported_se && (is_supported_se_uicc || is_supported_se_ese))
                ret = true;
 
        return ret;
@@ -97,11 +95,10 @@ static int _check_precondition_reader(int handle)
        CHECK_INIT();
 
        SMARTCARD_LOCK;
-               if(g_list_find(g_list_first(reader_list), GINT_TO_POINTER(handle)) == NULL)
-               {
-                       SMARTCARD_UNLOCK;
-                       return SMARTCARD_ERROR_INVALID_PARAMETER;
-               }
+       if (g_list_find(g_list_first(reader_list), GINT_TO_POINTER(handle)) == NULL) {
+               SMARTCARD_UNLOCK;
+               return SMARTCARD_ERROR_INVALID_PARAMETER;
+       }
        SMARTCARD_UNLOCK;
 
        return SMARTCARD_ERROR_NONE;
@@ -112,11 +109,10 @@ static int _check_precondition_session(int handle)
        CHECK_INIT();
 
        SMARTCARD_LOCK;
-               if(g_list_find(g_list_first(session_list), GINT_TO_POINTER(handle)) == NULL)
-               {
-                       SMARTCARD_UNLOCK;
-                       return SMARTCARD_ERROR_INVALID_PARAMETER;
-               }
+       if (g_list_find(g_list_first(session_list), GINT_TO_POINTER(handle)) == NULL) {
+               SMARTCARD_UNLOCK;
+               return SMARTCARD_ERROR_INVALID_PARAMETER;
+       }
        SMARTCARD_UNLOCK;
 
        return SMARTCARD_ERROR_NONE;
@@ -127,11 +123,10 @@ static int _check_precondition_channel(int handle)
        CHECK_INIT();
 
        SMARTCARD_LOCK;
-               if(g_list_find(g_list_first(channel_list), GINT_TO_POINTER(handle)) == NULL)
-               {
-                       SMARTCARD_UNLOCK;
-                       return SMARTCARD_ERROR_INVALID_PARAMETER;
-               }
+       if (g_list_find(g_list_first(channel_list), GINT_TO_POINTER(handle)) == NULL) {
+               SMARTCARD_UNLOCK;
+               return SMARTCARD_ERROR_INVALID_PARAMETER;
+       }
        SMARTCARD_UNLOCK;
 
        return SMARTCARD_ERROR_NONE;
@@ -139,55 +134,54 @@ static int _check_precondition_channel(int handle)
 
 static smartcard_error_e _convert_error_code(const char *func, int native_error_code)
 {
-   smartcard_error_e error_code = SMARTCARD_ERROR_NONE;
-   char *errorstr = NULL;
-
-   switch (native_error_code)
-   {
-               case SCARD_ERROR_OK:
-                       error_code = SMARTCARD_ERROR_NONE;
-                       errorstr = "SMARTCARD_ERROR_NONE";
-                       break;
-               case SCARD_ERROR_NOT_SUPPORTED:
-                       error_code = SMARTCARD_ERROR_OPERATION_NOT_SUPPORTED;
-                       errorstr = "SMARTCARD_ERROR_OPERATION_NOT_SUPPORTED";
-                       break;
-               case SCARD_ERROR_UNAVAILABLE:
-                       error_code = SMARTCARD_ERROR_CHANNEL_NOT_AVAILABLE;
-                       errorstr = "SMARTCARD_ERROR_CHANNEL_NOT_AVAILABLE";
-                       break;
-               case SCARD_ERROR_IPC_FAILED:
-               case SCARD_ERROR_IO_FAILED:
-                       error_code = SMARTCARD_ERROR_IO_ERROR;
-                       errorstr = "SMARTCARD_ERROR_IO_ERROR";
-                       break;
-               case SCARD_ERROR_SECURITY_NOT_ALLOWED:
-                       error_code = SMARTCARD_ERROR_PERMISSION_DENIED;
-                       errorstr = "SMARTCARD_ERROR_PERMISSION_DENIED";
-                       break;
-               case SCARD_ERROR_ILLEGAL_STATE:
-                       error_code = SMARTCARD_ERROR_ILLEGAL_STATE;
-                       errorstr = "SMARTCARD_ERROR_ILLEGAL_STATE";
-                       break;
-               case SCARD_ERROR_ILLEGAL_PARAM:
-                       error_code = SMARTCARD_ERROR_INVALID_PARAMETER;
-                       errorstr = "SMARTCARD_ERROR_INVALID_PARAMETER";
-                       break;
-               case SCARD_ERROR_ILLEGAL_REFERENCE:
-                       error_code = SMARTCARD_ERROR_ILLEGAL_REFERENCE;
-                       errorstr = "SMARTCARD_ERROR_ILLEGAL_REFERENCE";
-                       break;
-               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 :
-                       error_code = SMARTCARD_ERROR_GENERAL;
-                       errorstr = "SMARTCARD_ERROR_GENERAL";
+       smartcard_error_e error_code = SMARTCARD_ERROR_NONE;
+       char *errorstr = NULL;
+
+       switch (native_error_code) {
+       case SCARD_ERROR_OK:
+               error_code = SMARTCARD_ERROR_NONE;
+               errorstr = "SMARTCARD_ERROR_NONE";
+               break;
+       case SCARD_ERROR_NOT_SUPPORTED:
+               error_code = SMARTCARD_ERROR_OPERATION_NOT_SUPPORTED;
+               errorstr = "SMARTCARD_ERROR_OPERATION_NOT_SUPPORTED";
+               break;
+       case SCARD_ERROR_UNAVAILABLE:
+               error_code = SMARTCARD_ERROR_CHANNEL_NOT_AVAILABLE;
+               errorstr = "SMARTCARD_ERROR_CHANNEL_NOT_AVAILABLE";
+               break;
+       case SCARD_ERROR_IPC_FAILED:
+       case SCARD_ERROR_IO_FAILED:
+               error_code = SMARTCARD_ERROR_IO_ERROR;
+               errorstr = "SMARTCARD_ERROR_IO_ERROR";
+               break;
+       case SCARD_ERROR_SECURITY_NOT_ALLOWED:
+               error_code = SMARTCARD_ERROR_PERMISSION_DENIED;
+               errorstr = "SMARTCARD_ERROR_PERMISSION_DENIED";
+       break;
+       case SCARD_ERROR_ILLEGAL_STATE:
+               error_code = SMARTCARD_ERROR_ILLEGAL_STATE;
+               errorstr = "SMARTCARD_ERROR_ILLEGAL_STATE";
+               break;
+       case SCARD_ERROR_ILLEGAL_PARAM:
+               error_code = SMARTCARD_ERROR_INVALID_PARAMETER;
+               errorstr = "SMARTCARD_ERROR_INVALID_PARAMETER";
+               break;
+       case SCARD_ERROR_ILLEGAL_REFERENCE:
+               error_code = SMARTCARD_ERROR_ILLEGAL_REFERENCE;
+               errorstr = "SMARTCARD_ERROR_ILLEGAL_REFERENCE";
+               break;
+       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:
+               error_code = SMARTCARD_ERROR_GENERAL;
+               errorstr = "SMARTCARD_ERROR_GENERAL";
        }
 
        _ERR("smartcard func : %s, %s(0x%08x)\n", func, errorstr, error_code);
@@ -210,14 +204,12 @@ int smartcard_initialize(void)
 
        SMARTCARD_LOCK;
 
-               if(se_service == NULL || ref_count > 0)
-               {
+               if (se_service == NULL || ref_count > 0) {
                        /* create se service instance. */
                        se_service = se_service_create_instance_sync(NULL, &ret);
-                       if(se_service == NULL || ret != SCARD_ERROR_OK)
-                       {
+                       if (se_service == NULL || ret != SCARD_ERROR_OK) {
                                SMARTCARD_UNLOCK;
-                               if(ret == SCARD_ERROR_SECURITY_NOT_ALLOWED)
+                               if (ret == SCARD_ERROR_SECURITY_NOT_ALLOWED)
                                        return SMARTCARD_ERROR_PERMISSION_DENIED;
 
                                return SMARTCARD_ERROR_GENERAL;
@@ -247,29 +239,27 @@ int smartcard_deinitialize(void)
 
        SMARTCARD_LOCK;
 
-               if(ref_count > 0)
-               {
+               if (ref_count > 0) {
                        ref_count--;
-               }
-               else
-               {
+               } else {
                        SMARTCARD_UNLOCK;
                        return SMARTCARD_ERROR_NOT_INITIALIZED;
                }
 
-               if(se_service != NULL && ref_count == 0)
-               {
+               if (se_service != NULL && ref_count == 0) {
                        se_service_shutdown(se_service);
 
                        /* destroy se service instance. */
                        ret = se_service_destroy_instance(se_service);
-                       if(ret != SCARD_ERROR_OK)
-                       {
+                       if (ret != SCARD_ERROR_OK) {
                                SMARTCARD_UNLOCK;
                                return SMARTCARD_ERROR_GENERAL;
                        }
 
                        se_service = NULL;
+                       g_list_free(reader_list);
+                       g_list_free(session_list);
+                       g_list_free(channel_list);
                        reader_list = NULL;
                        session_list = NULL;
                        channel_list = NULL;
@@ -312,12 +302,11 @@ int smartcard_get_readers(int **readers, int *length)
 
        SMARTCARD_UNLOCK;
 
-       for(i = 0; i < *length; i++)
-       {
+       for (i = 0; i < *length; i++) {
                SMARTCARD_LOCK;
 
-                       if(g_list_find(g_list_first(reader_list), GINT_TO_POINTER(*(readers[i]))) == NULL)
-                               reader_list = g_list_append (reader_list, GINT_TO_POINTER(*(readers[i])));
+                       if (g_list_find(g_list_first(reader_list), GINT_TO_POINTER(*(readers[i]))) == NULL)
+                               reader_list = g_list_append(reader_list, GINT_TO_POINTER(*(readers[i])));
 
                SMARTCARD_UNLOCK;
        }
@@ -353,7 +342,7 @@ int smartcard_reader_get_name(int reader, char **reader_name)
        /* process */
        ret = reader_get_name((reader_h)reader, reader_name);
 
-       if(ret != SCARD_ERROR_OK || strlen(*reader_name) == 0)
+       if (ret != SCARD_ERROR_OK || strlen(*reader_name) == 0)
                return SMARTCARD_ERROR_GENERAL;
 
        _END();
@@ -412,11 +401,10 @@ int smartcard_reader_open_session(int reader, int *session)
 
        ret = reader_open_session_sync((reader_h)reader, session);
 
-       if(ret == SCARD_ERROR_OK)
-       {
+       if (ret == SCARD_ERROR_OK) {
                SMARTCARD_LOCK;
-                       if(g_list_find(g_list_first(session_list), GINT_TO_POINTER(*session)) == NULL)
-                               session_list = g_list_append (session_list, GINT_TO_POINTER(*session));
+                       if (g_list_find(g_list_first(session_list), GINT_TO_POINTER(*session)) == NULL)
+                               session_list = g_list_append(session_list, GINT_TO_POINTER(*session));
                SMARTCARD_UNLOCK;
        }
 
@@ -507,11 +495,9 @@ int smartcard_session_get_atr(int session, unsigned char **atr, int *length)
        /* precondition check end */
        ret = session_get_atr_sync((session_h)session, atr, (unsigned int *)length);
 
-       if(ret == SCARD_ERROR_OK)
-       {
-               if(((*atr == NULL) && (*length != 0)) ||
-                       ((*atr != NULL) && (*length == 0)))
-               {
+       if (ret == SCARD_ERROR_OK) {
+               if (((*atr == NULL) && (*length != 0)) ||
+                       ((*atr != NULL) && (*length == 0))) {
                        return SMARTCARD_ERROR_GENERAL;
                }
        }
@@ -625,11 +611,10 @@ int smartcard_session_open_basic_channel(int session, unsigned char *aid, int ai
 
        ret = session_open_basic_channel_sync((session_h)session, aid, aid_len, P2, channel);
 
-       if(ret == SCARD_ERROR_OK)
-       {
+       if (ret == SCARD_ERROR_OK) {
                SMARTCARD_LOCK;
-                       if(g_list_find(g_list_first(channel_list), GINT_TO_POINTER(*channel)) == NULL)
-                               channel_list = g_list_append (channel_list, GINT_TO_POINTER(*channel));
+                       if (g_list_find(g_list_first(channel_list), GINT_TO_POINTER(*channel)) == NULL)
+                               channel_list = g_list_append(channel_list, GINT_TO_POINTER(*channel));
                SMARTCARD_UNLOCK;
        }
 
@@ -662,11 +647,10 @@ int smartcard_session_open_logical_channel(int session, unsigned char *aid, int
 
        ret = session_open_logical_channel_sync((session_h)session, aid, aid_len, P2, channel);
 
-       if(ret == SCARD_ERROR_OK)
-       {
+       if (ret == SCARD_ERROR_OK) {
                SMARTCARD_LOCK;
-                       if(g_list_find(g_list_first(channel_list), GINT_TO_POINTER(*channel)) == NULL)
-                               channel_list = g_list_append (channel_list, GINT_TO_POINTER(*channel));
+                       if (g_list_find(g_list_first(channel_list), GINT_TO_POINTER(*channel)) == NULL)
+                               channel_list = g_list_append(channel_list, GINT_TO_POINTER(*channel));
                SMARTCARD_UNLOCK;
        }