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_unified tizen_6.5 tizen_7.0 tizen_7.0_hotfix tizen_8.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/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
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 af72b10..3ea02a9 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 e98e9d0..6941e88 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 7c7148d..f12f39b 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 553da20..cf83de7 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 9a29246..61ffef9 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;