summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJihoon Jung <jh8801.jung@samsung.com>2021-06-22 09:37:59 +0900
committerJihoon Jung <jh8801.jung@samsung.com>2021-06-22 09:38:48 +0900
commit852bb642bc10c2bc4aa07b03c6642589cebbd4cd (patch)
tree1ee22eaf0dd7e006c6f80e27cf95896da3b941c4
parent5da8c3977bc0e853a9b3540d22a9c351d8fd3e4c (diff)
downloadsmartcard-service-tizen_9.0.tar.gz
smartcard-service-tizen_9.0.tar.bz2
smartcard-service-tizen_9.0.zip
Change-Id: I2f9576520d339b1c3295603482a30fa63d7d571c Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
-rw-r--r--common/include/Terminal.h2
-rwxr-xr-xcommon/smartcard-service-gdbus.xml16
-rw-r--r--server/ServerGDBus.cpp48
-rwxr-xr-xserver/ServerResource.cpp26
-rw-r--r--server/include/ServerGDBus.h4
5 files changed, 94 insertions, 2 deletions
diff --git a/common/include/Terminal.h b/common/include/Terminal.h
index af72b10..3ea02a9 100644
--- a/common/include/Terminal.h
+++ b/common/include/Terminal.h
@@ -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) {}
diff --git a/common/smartcard-service-gdbus.xml b/common/smartcard-service-gdbus.xml
index e98e9d0..6941e88 100755
--- a/common/smartcard-service-gdbus.xml
+++ b/common/smartcard-service-gdbus.xml
@@ -36,6 +36,22 @@
<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">
diff --git a/server/ServerGDBus.cpp b/server/ServerGDBus.cpp
index 7c7148d..f12f39b 100644
--- a/server/ServerGDBus.cpp
+++ b/server/ServerGDBus.cpp
@@ -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);
diff --git a/server/ServerResource.cpp b/server/ServerResource.cpp
index 553da20..cf83de7 100755
--- a/server/ServerResource.cpp
+++ b/server/ServerResource.cpp
@@ -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;
diff --git a/server/include/ServerGDBus.h b/server/include/ServerGDBus.h
index 9a29246..61ffef9 100644
--- a/server/include/ServerGDBus.h
+++ b/server/include/ServerGDBus.h
@@ -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;