From 322fc5f44df00dfb8848e25a0c7992399ad463ed Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Thu, 14 Jul 2016 14:33:22 +0900 Subject: [PATCH] Revert implementation and add new function for fix side effect Signed-off-by: Jihoon Jung Change-Id: I089cbfb6fd736a0f15d9611fb68635c8331d2b84 --- client/SEService.cpp | 72 ++++++++++++++++++++++++++++++++++------ client/include/SEService.h | 1 + packaging/smartcard-service.spec | 2 +- 3 files changed, 63 insertions(+), 12 deletions(-) diff --git a/client/SEService.cpp b/client/SEService.cpp index 95248f4..5a21e23 100755 --- a/client/SEService.cpp +++ b/client/SEService.cpp @@ -303,7 +303,7 @@ namespace smartcard_service_api return result; } - int SEService::_initialize_sync() throw(ErrorIO &, ExceptionBase &) + int SEService::_initialize_sync_do_not_throw_exception() { gint result; guint handle; @@ -345,16 +345,9 @@ namespace smartcard_service_api } else { - throw ExceptionBase(result); + _ERR("Initialize error : %d", result); } } - else - { - _ERR("smartcard_service_se_service_call_se_service failed, [%s]", error->message); - g_error_free(error); - - result = SCARD_ERROR_IPC_FAILED; - } if (service->handler != NULL) { service->handler(service, service->context); @@ -371,6 +364,64 @@ namespace smartcard_service_api return result; } + int SEService::_initialize_sync() throw(ErrorIO &, ExceptionBase &) + { + gint result; + guint handle; + GError *error = NULL; + GVariant *readers = NULL; + SEService *service = (SEService *)this; + + _BEGIN(); + + /* init default context */ + + proxy = smartcard_service_se_service_proxy_new_for_bus_sync( + G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, + "org.tizen.SmartcardService", + "/org/tizen/SmartcardService/SeService", + NULL, &error); + if (proxy == NULL) + { + _ERR("Can not create proxy : %s", error->message); + g_error_free(error); + return false; + } + + g_signal_connect(proxy, "reader-inserted", + G_CALLBACK(&SEService::reader_inserted), this); + + g_signal_connect(proxy, "reader-removed", + G_CALLBACK(&SEService::reader_removed), this); + + /* request reader */ + if(smartcard_service_se_service_call_se_service_sync( + (SmartcardServiceSeService *)proxy, &result, &handle, &readers, NULL, &error) == true) + { + if (result == SCARD_ERROR_OK) + { + service->connected = true; + service->handle = handle; + service->parseReaderInformation(readers); + } + else + { + throw ExceptionBase(result); + } + } + else + { + _ERR("smartcard_service_se_service_call_se_service failed, [%s]", error->message); + g_error_free(error); + + result = SCARD_ERROR_IPC_FAILED; + } + + _END(); + + return result; + } + bool SEService::initialize(void *context, serviceConnected handler) throw(ErrorIO &, ErrorIllegalParameter &) { @@ -396,8 +447,7 @@ namespace smartcard_service_api this->context = context; this->listener = listener; - _initialize_sync(); - return true; + return _initialize_sync_do_not_throw_exception(); } bool SEService::initializeSync(void *context) diff --git a/client/include/SEService.h b/client/include/SEService.h index cb7672d..8fbffe8 100644 --- a/client/include/SEService.h +++ b/client/include/SEService.h @@ -61,6 +61,7 @@ namespace smartcard_service_api throw(ErrorIO &, ErrorIllegalParameter &); int _initialize_sync() throw(ErrorIO &, ExceptionBase &); + int _initialize_sync_do_not_throw_exception(); bool initializeSync(void *context) throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &); diff --git a/packaging/smartcard-service.spec b/packaging/smartcard-service.spec index 182016b..f040a92 100755 --- a/packaging/smartcard-service.spec +++ b/packaging/smartcard-service.spec @@ -7,7 +7,7 @@ ################################################################################ Name: smartcard-service Summary: Smartcard Service FW -Version: 0.1.48 +Version: 0.1.49 Release: 0 Group: libs License: Apache-2.0 -- 2.7.4