Add card Inserted implementation and fix bug 89/260189/1 accepted/tizen_6.5_unified accepted/tizen_7.0_unified accepted/tizen_7.0_unified_hotfix accepted/tizen_8.0_unified accepted/tizen_9.0_unified tizen_6.5 tizen_7.0 tizen_7.0_hotfix tizen_8.0 tizen_9.0 accepted/tizen/6.5/unified/20211028.100907 accepted/tizen/7.0/unified/20221110.060522 accepted/tizen/7.0/unified/hotfix/20221116.105221 accepted/tizen/8.0/unified/20231005.093242 accepted/tizen/9.0/unified/20241030.232250 accepted/tizen/unified/20210622.031114 submit/tizen/20210622.011556 submit/tizen_6.5/20211028.162201 tizen_6.5.m2_release tizen_7.0_m2_release tizen_8.0_m2_release tizen_9.0_m2_release
authorJihoon Jung <jh8801.jung@samsung.com>
Tue, 22 Jun 2021 00:37:59 +0000 (09:37 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Tue, 22 Jun 2021 00:38:48 +0000 (09:38 +0900)
Change-Id: I2f9576520d339b1c3295603482a30fa63d7d571c
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
common/include/Terminal.h
common/smartcard-service-gdbus.xml
server/ServerGDBus.cpp
server/ServerResource.cpp
server/include/ServerGDBus.h

index af72b10aec964fcb6d60f50f2931927c297b934f..3ea02a92a4ad588447137a34b38d177a471904c7 100644 (file)
@@ -44,6 +44,8 @@ namespace smartcard_service_api
        public:
                static const int NOTIFY_SE_AVAILABLE = 1;
                static const int NOTIFY_SE_NOT_AVAILABLE = -1;
+               static const int NOTIFY_CARD_AVAILABLE = 2;
+               static const int NOTIFY_CARD_NOT_AVAILABLE = -2;
 
                Terminal() : statusCallback(NULL), initialized(false),
                        closed(true), name(NULL) {}
index e98e9d08cddc26b92f14b28755150dcbb75f4b9c..6941e880b9b4aba6232d42157b2bcf8f0dc0596f 100755 (executable)
       <arg type="u" name="reader_id" />
       <arg type="s" name="reader_name" />
     </signal>
+
+    <!--
+      CardInserted
+    -->
+    <signal name="CardInserted">
+      <arg type="u" name="reader_id" />
+      <arg type="s" name="reader_name" />
+    </signal>
+
+    <!--
+      CardRemoved
+    -->
+    <signal name="CardRemoved">
+      <arg type="u" name="reader_id" />
+      <arg type="s" name="reader_name" />
+    </signal>
   </interface>
 
   <interface name="org.tizen.SmartcardService.Reader">
index 7c7148da2bd65b2ec75413b3b17033f998fc7be8..f12f39bfb7764c784406abeba7c73730e5a89d47 100644 (file)
@@ -704,6 +704,26 @@ namespace smartcard_service_api
                /* LCOV_EXCL_STOP */
        }
 
+       void ServerGDBus::emitCardInserted(unsigned int reader_id,
+               const char *reader_name)
+       {
+               /* LCOV_EXCL_START */
+               smartcard_service_se_service_emit_card_inserted(
+                       SMARTCARD_SERVICE_SE_SERVICE(seService),
+                       reader_id, reader_name);
+               /* LCOV_EXCL_STOP */
+       }
+
+       void ServerGDBus::emitCardRemoved(unsigned int reader_id,
+               const char *reader_name)
+       {
+               /* LCOV_EXCL_START */
+               smartcard_service_se_service_emit_card_removed(
+                       SMARTCARD_SERVICE_SE_SERVICE(seService),
+                       reader_id, reader_name);
+               /* LCOV_EXCL_STOP */
+       }
+
        /* Reader *
         *
         *
@@ -1439,6 +1459,27 @@ namespace smartcard_service_api
                g_object_unref(command);
        }
 
+       static GVariant *_copy_variant(GVariant *src)
+       {
+               GVariantBuilder builder;
+
+               GVariantIter *iter;
+               guint8 element;
+               guint i;
+
+               g_variant_get(src, "a(y)", &iter);
+
+               g_variant_builder_init(&builder, G_VARIANT_TYPE("a(y)"));
+
+               for (i = 0; g_variant_iter_loop(iter, "(y)", &element); i++) {
+                       g_variant_builder_add(&builder, "(y)", element);
+               }
+
+               g_variant_iter_free(iter);
+
+               return g_variant_builder_end(&builder);
+       }
+
        static gboolean _handle_transmit(SmartcardServiceChannel *object,
                GDBusMethodInvocation *invocation,
                guint service_id,
@@ -1447,6 +1488,9 @@ namespace smartcard_service_api
                void *user_data)
        {
                vector<void *> params;
+               GVariant *_command;
+
+               _command = _copy_variant(command);
 
                /* apply user space smack */
                if (_is_authorized_request(invocation) == true) {
@@ -1460,8 +1504,8 @@ namespace smartcard_service_api
                        params.push_back((void *)service_id);
                        params.push_back((void *)channel_id);
 
-                       g_object_ref(command);
-                       params.push_back((void *)command);
+                       g_object_ref(_command);
+                       params.push_back((void *)_command);
 
                        params.push_back(user_data);
 
index 553da2070e0eb5897e9284dfad47710e1d7aa542..cf83de7794a879fe4c415079b415de6b3d5e2aed 100755 (executable)
@@ -939,6 +939,32 @@ namespace smartcard_service_api
                        }
                        break;
 
+               case Terminal::NOTIFY_CARD_AVAILABLE :
+                       {
+                               ServerResource &instance = ServerResource::getInstance();
+                               unsigned int readerID = IntegerHandle::INVALID_HANDLE;
+
+                               _INFO("[NOTIFY_CARD_AVAILABLE]");
+
+                               readerID = instance.getReaderID((char *)terminal);
+
+                               ServerGDBus::getInstance().emitCardInserted(
+                                       readerID, (const char *)terminal);
+                       }
+                       break;
+               case Terminal::NOTIFY_CARD_NOT_AVAILABLE :
+                       {
+                               ServerResource &instance = ServerResource::getInstance();
+                               unsigned int readerID = IntegerHandle::INVALID_HANDLE;
+
+                               _INFO("[NOTIFY_CARD_NOT_AVAILABLE]");
+
+                               readerID = instance.getReaderID((char *)terminal);
+
+                               ServerGDBus::getInstance().emitCardRemoved(
+                                       readerID, (const char *)terminal);
+                       }
+                       break;
                default :
                        _DBG("terminal [%s], event [%d], error [%d], user_param [%p]", (char *)terminal, event, error, user_param);
                        break;
index 9a292467aa4cd91969aeba769fdfe2e2ef366e03..61ffef90f02cd236e4b0fb38065bae317011752d 100644 (file)
@@ -72,6 +72,10 @@ namespace smartcard_service_api
                        const char *reader_name);
                void emitReaderRemoved(unsigned int reader_id,
                        const char *reader_name);
+               void emitCardInserted(unsigned int reader_id,
+                       const char *reader_name);
+               void emitCardRemoved(unsigned int reader_id,
+                       const char *reader_name);
 
        private :
                GDBusConnection *connection;