summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJihoon Jung <jh8801.jung@samsung.com>2016-09-28 16:03:27 +0900
committerJihoon Jung <jh8801.jung@samsung.com>2016-09-28 16:03:27 +0900
commitb58c9d011c5850b59071b4e9d292734d003d1ddd (patch)
tree53fc4e75513b21b9bf98ab14fe5c79ce782978ca
parentdbd0146a5216c013c5fd43d55f62471d29165735 (diff)
downloadsmartcard-service-accepted/tizen_3.0.m2_tv.tar.gz
smartcard-service-accepted/tizen_3.0.m2_tv.tar.bz2
smartcard-service-accepted/tizen_3.0.m2_tv.zip
- remove smartcard client library layer Change-Id: I22191234c422379987e8db9111f7b5f2e438c71e
-rw-r--r--CMakeLists.txt1
-rw-r--r--client/CMakeLists.txt91
-rw-r--r--client/ClientChannel.cpp624
-rwxr-xr-xclient/ClientGDBus.cpp45
-rw-r--r--client/Reader.cpp370
-rwxr-xr-xclient/SEService.cpp755
-rw-r--r--client/Session.cpp889
-rw-r--r--client/include/ClientChannel.h101
-rw-r--r--client/include/ClientGDBus.h36
-rw-r--r--client/include/Reader.h87
-rw-r--r--client/include/SEService.h135
-rw-r--r--client/include/SEServiceListener.h42
-rw-r--r--client/include/Session.h157
-rw-r--r--client/include/smartcard-service.h29
-rw-r--r--client/smartcard-service.pc13
-rw-r--r--common/CMakeLists.txt10
-rw-r--r--packaging/smartcard-service-server206
-rwxr-xr-xpackaging/smartcard-service.init (renamed from packaging/smartcard-service-server.init)4
-rwxr-xr-xpackaging/smartcard-service.spec119
-rw-r--r--server/CMakeLists.txt14
-rw-r--r--server/org.tizen.SmartcardService.service2
-rw-r--r--smartcard-service-server.manifest5
-rw-r--r--test-client/CMakeLists.txt2
23 files changed, 57 insertions, 3680 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13a93ef..a67a507 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,7 +26,6 @@ EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
")
ADD_SUBDIRECTORY(common)
-ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(server)
IF(DEFINED TEST_CLIENT)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
deleted file mode 100644
index e0fb961..0000000
--- a/client/CMakeLists.txt
+++ /dev/null
@@ -1,91 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(smartcard-service CXX)
-
-SET(LIB_NAME "smartcard-service")
-SET(VERSION_MAJOR 1)
-SET(VERSION ${VERSION_MAJOR}.0.0)
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common/include)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../server/include)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SRCS)
-
-IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
- SET(CMAKE_BUILD_TYPE "Release")
-ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
-MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
-
-# pkg config
-INCLUDE(FindPkgConfig)
-
-SET(PKG_MODULE glib-2.0 dlog)
-
-pkg_check_modules(pkgs_client REQUIRED ${PKG_MODULE})
-
-MESSAGE("${LIB_NAME} ld flag : ${pkgs_client_LDFLAGS}")
-
-FOREACH(flag ${pkgs_client_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
- SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -finstrument-functions -fPIC")
-#SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-#SET(CMAKE_C_FLAGS_RELEASE "-O2")
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -finstrument-functions -std=c++0x")
-#SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
-#SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
-
-FIND_PROGRAM(UNAME NAMES uname)
-EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
-IF("${ARCH}" STREQUAL "arm")
- ADD_DEFINITIONS("-DTARGET")
- MESSAGE("add -DTARGET")
-ENDIF("${ARCH}" STREQUAL "arm")
-
-MESSAGE("CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DSLP_DEBUG")
-ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE_CLIENT\"")
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
-
-ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
-
-SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${VERSION})
-
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_client_LDFLAGS})
-
-SET(EXPORT_HEADER
- ../common/include/smartcard-types.h
- ../common/include/ByteArray.h
- ../common/include/Debug.h
- ../common/include/Exception.h
- ../common/include/Synchronous.h
- ../common/include/APDUHelper.h
- ../common/include/Channel.h
- ../common/include/Serializable.h
- ../common/include/SEServiceHelper.h
- ../common/include/ReaderHelper.h
- ../common/include/SessionHelper.h
-# ../common/include/FCI.h
-# ../common/include/
- include/SEServiceListener.h
- include/SEService.h
- include/Reader.h
- include/Session.h
- include/ClientChannel.h
- include/smartcard-service.h
-# include/
-)
-
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
-FOREACH(hfile ${EXPORT_HEADER})
- INSTALL(FILES ${hfile} DESTINATION include/${LIB_NAME})
-ENDFOREACH(hfile)
diff --git a/client/ClientChannel.cpp b/client/ClientChannel.cpp
deleted file mode 100644
index c7e9dd4..0000000
--- a/client/ClientChannel.cpp
+++ /dev/null
@@ -1,624 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* standard library header */
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <glib.h>
-
-/* SLP library header */
-
-/* local header */
-#include "Debug.h"
-#include "ClientChannel.h"
-#include "ReaderHelper.h"
-#include "APDUHelper.h"
-#include "ClientGDBus.h"
-
-#ifndef EXTERN_API
-#define EXTERN_API __attribute__((visibility("default")))
-#endif
-
-namespace smartcard_service_api
-{
- ClientChannel::ClientChannel(void *context, Session *session,
- int channelNum, const ByteArray &selectResponse, void *handle)
- : Channel(session)
- {
- this->channelNum = -1;
- this->handle = NULL;
- this->context = NULL;
-
- if (handle == NULL)
- {
- _ERR("ClientIPC::getInstance() failed");
-
- return;
- }
-
- this->channelNum = channelNum;
- this->handle = handle;
- this->selectResponse = selectResponse;
- this->context = context;
-
- /* init default context */
- GError *error = NULL;
-
- proxy = smartcard_service_channel_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.SmartcardService",
- "/org/tizen/SmartcardService/Channel",
- NULL, &error);
- if (proxy == NULL)
- {
- _ERR("Can not create proxy : %s", error->message);
- g_error_free(error);
- return;
- }
- }
-
- ClientChannel::~ClientChannel()
- {
- closeSync();
- }
-
- void ClientChannel::channel_transmit_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data)
- {
- CallbackParam *param = (CallbackParam *)user_data;
- transmitCallback callback;
- gint result;
- GVariant *var_response;
- GError *error = NULL;
- ByteArray response;
-
- _INFO("MSG_REQUEST_TRANSMIT");
-
- if (param == NULL) {
- _ERR("null parameter!!!");
- return;
- }
-
- callback = (transmitCallback)param->callback;
-
- if (smartcard_service_channel_call_transmit_finish(
- SMARTCARD_SERVICE_CHANNEL(source_object),
- &result, &var_response, res, &error) == true) {
- if (result == SCARD_ERROR_OK) {
- GDBusHelper::convertVariantToByteArray(var_response, response);
- } else {
- _ERR("smartcard_service_channel_call_transmit failed, [%d]", result);
- }
- } else {
- _ERR("smartcard_service_channel_call_transmit failed, [%s]", error->message);
- g_error_free(error);
-
- result = SCARD_ERROR_IPC_FAILED;
- }
-
- if (callback != NULL) {
- callback(response.getBuffer(),
- response.size(),
- result, param->user_param);
- }
-
- delete param;
- }
-
- void ClientChannel::channel_close_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data)
- {
- CallbackParam *param = (CallbackParam *)user_data;
- ClientChannel *channel;
- closeChannelCallback callback;
- gint result;
- GError *error = NULL;
-
- _INFO("MSG_REQUEST_CLOSE_CHANNEL");
-
- if (param == NULL) {
- _ERR("null parameter!!!");
- return;
- }
-
- channel = (ClientChannel *)param->instance;
- callback = (closeChannelCallback)param->callback;
-
- if (smartcard_service_channel_call_close_channel_finish(
- SMARTCARD_SERVICE_CHANNEL(source_object),
- &result, res, &error) == true) {
- if (result == SCARD_ERROR_OK) {
- channel->channelNum = -1;
- } else {
- _ERR("smartcard_service_channel_call_close_channel failed, [%d]", result);
- }
- } else {
- _ERR("smartcard_service_channel_call_close_channel failed, [%s]", error->message);
- g_error_free(error);
-
- result = SCARD_ERROR_IPC_FAILED;
- }
-
- if (callback != NULL) {
- callback(result, param->user_param);
- }
-
- delete param;
- }
-
- void ClientChannel::closeSync()
- throw(ExceptionBase &, ErrorIO &, ErrorSecurity &,
- ErrorIllegalState &, ErrorIllegalParameter &)
- {
- if (isClosed() == false)
- {
- if (getSession()->getReader()->isSecureElementPresent() == true)
- {
- gint ret;
- GError *error = NULL;
-
-
- if (proxy == NULL) {
- _ERR("dbus proxy is not initialized yet");
- throw ErrorIllegalState(SCARD_ERROR_NOT_INITIALIZED);
- }
-
- if (smartcard_service_channel_call_close_channel_sync(
- (SmartcardServiceChannel *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle),
- &ret, NULL, &error) == true) {
- if (ret == SCARD_ERROR_OK) {
- channelNum = -1;
- } else {
- _ERR("smartcard_service_channel_call_close_channel_sync failed, [%d]", ret);
- THROW_ERROR(ret);
- }
- } else {
- _ERR("smartcard_service_channel_call_close_channel_sync failed, [%s]", error->message);
- g_error_free(error);
-
- throw ErrorIO(SCARD_ERROR_IPC_FAILED);
- }
- }
- else
- {
- _INFO("unavailable channel");
- }
- }
- }
-
- int ClientChannel::close(closeChannelCallback callback, void *userParam)
- {
- int result = SCARD_ERROR_OK;
-
- if (isClosed() == false)
- {
- if (getSession()->getReader()->isSecureElementPresent() == true)
- {
- CallbackParam *param = new CallbackParam();
-
- param->instance = this;
- param->callback = (void *)callback;
- param->user_param = userParam;
-
- smartcard_service_channel_call_close_channel(
- (SmartcardServiceChannel *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle), NULL,
- &ClientChannel::channel_close_cb, param);
- }
- else
- {
- _ERR("unavailable channel");
- result = SCARD_ERROR_ILLEGAL_STATE;
- }
- }
-
- return result;
- }
-
- int ClientChannel::transmitSync(const ByteArray &command, ByteArray &result)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- int rv = SCARD_ERROR_OK;
-
- if (getSession()->getReader()->isSecureElementPresent() == true)
- {
- GVariant *var_command = NULL, *var_response = NULL;
- GError *error = NULL;
-
- var_command = GDBusHelper::convertByteArrayToVariant(command);
-
- if (smartcard_service_channel_call_transmit_sync(
- (SmartcardServiceChannel *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle),
- var_command, &rv, &var_response,
- NULL, &error) == true) {
-
- if (rv == SCARD_ERROR_OK) {
- GDBusHelper::convertVariantToByteArray(var_response, transmitResponse);
- result = transmitResponse;
- } else {
- _ERR("smartcard_service_session_call_transmit failed, [%d]", rv);
- THROW_ERROR(rv);
- }
- } else {
- _ERR("smartcard_service_session_call_transmit failed, [%s]", error->message);
- g_error_free(error);
-
- throw ErrorIO(SCARD_ERROR_IPC_FAILED);
- }
- }
- else
- {
- _ERR("unavailable channel");
- throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
- }
-
- return rv;
- }
-
- int ClientChannel::transmit(const ByteArray &command, transmitCallback callback, void *userParam)
- {
- int result;
-
- if (getSession()->getReader()->isSecureElementPresent() == true)
- {
- GVariant *var_command;
- CallbackParam *param = new CallbackParam();
-
- param->instance = this;
- param->callback = (void *)callback;
- param->user_param = userParam;
-
- var_command = GDBusHelper::convertByteArrayToVariant(command);
-
- smartcard_service_channel_call_transmit(
- (SmartcardServiceChannel *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle),
- var_command, NULL,
- &ClientChannel::channel_transmit_cb, param);
-
- result = SCARD_ERROR_OK;
- }
- else
- {
- _ERR("unavailable channel");
- result = SCARD_ERROR_ILLEGAL_STATE;
- }
-
- return result;
- }
-} /* namespace smartcard_service_api */
-
-/* export C API */
-#define CHANNEL_EXTERN_BEGIN \
- if (handle != NULL) \
- { \
- ClientChannel *channel = (ClientChannel *)handle;
-
-#define CHANNEL_EXTERN_END \
- } \
- else \
- { \
- _ERR("Invalid param"); \
- }
-
-using namespace smartcard_service_api;
-
-EXTERN_API int channel_close_sync(channel_h handle)
-{
- int result = SCARD_ERROR_OK;
-
- CHANNEL_EXTERN_BEGIN;
-
- try
- {
- channel->closeSync();
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- }
-
- CHANNEL_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int channel_transmit_sync(channel_h handle, unsigned char *command,
- unsigned int cmd_len, unsigned char **response, unsigned int *resp_len)
-{
- int result = SCARD_ERROR_OK;
-
- if (command == NULL || cmd_len == 0 || response == NULL || resp_len == NULL)
- return SCARD_ERROR_UNKNOWN;
-
- CHANNEL_EXTERN_BEGIN;
-
- try
- {
- ByteArray temp, resp;
-
- temp.assign(command, cmd_len);
- channel->transmitSync(temp, resp);
-
- if (resp.size() > 0)
- {
- *response = (unsigned char *)calloc(resp.size(), sizeof(unsigned char));
- *resp_len = resp.size();
- memcpy(*response, resp.getBuffer(), *resp_len);
- }
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- *resp_len = 0;
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- *resp_len = 0;
- }
-
- CHANNEL_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int channel_is_basic_channel(channel_h handle, bool* is_basic_channel)
-{
- int result = SCARD_ERROR_OK;
-
- CHANNEL_EXTERN_BEGIN;
-
- try
- {
- *is_basic_channel = channel->isBasicChannel();
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- }
-
- CHANNEL_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int channel_is_closed(channel_h handle, bool* is_closed)
-{
- int result = SCARD_ERROR_OK;
-
- CHANNEL_EXTERN_BEGIN;
-
- try
- {
- *is_closed = channel->isClosed();
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- }
-
- CHANNEL_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int channel_get_select_response(channel_h handle,
- unsigned char **buffer, size_t *length)
-{
- int result = SCARD_ERROR_OK;
-
- CHANNEL_EXTERN_BEGIN;
-
- try
- {
- ByteArray response = channel->getSelectResponse();
- uint8_t* get_buffer = response.getBuffer();
-
- *length = response.size();
-
- if (*length > 0)
- {
- *buffer = (unsigned char *)calloc(*length, sizeof(unsigned char));
- if(*buffer == NULL || get_buffer == NULL)
- {
- *length = 0;
- return SCARD_ERROR_NOT_ENOUGH_RESOURCE;
- }
-
- memcpy(*buffer, get_buffer, *length);
- }
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- *length = 0;
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- *length = 0;
- }
-
- CHANNEL_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int channel_get_transmit_response(channel_h handle,
- unsigned char **buffer, size_t *length)
-{
- int result = SCARD_ERROR_OK;
-
- CHANNEL_EXTERN_BEGIN;
-
- try
- {
- ByteArray response;
-
- response = channel->getTransmitResponse();
-
- *length = response.size();
-
- if (*length > 0)
- {
- *buffer = (unsigned char *)calloc(*length, sizeof(unsigned char));
- memcpy(*buffer, response.getBuffer(), *length);
- }
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- *length = 0;
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- *length = 0;
- }
-
- CHANNEL_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int channel_get_session(channel_h handle, int *session_handle)
-{
- int result = SCARD_ERROR_OK;
- session_h session = NULL;
-
- CHANNEL_EXTERN_BEGIN;
-
- try
- {
- session = channel->getSession();
- *session_handle = (long)session;
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- }
-
- CHANNEL_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int channel_select_next(channel_h handle, bool *pSuccess)
-{
- int result = SCARD_ERROR_OK;
-
- CHANNEL_EXTERN_BEGIN;
-
- try
- {
- *pSuccess = channel->selectNext();
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- }
-
- CHANNEL_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API unsigned int channel_get_select_response_length(channel_h handle)
-{
- unsigned int result = 0;
-
- CHANNEL_EXTERN_BEGIN;
- result = channel->getSelectResponse().size();
- CHANNEL_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int channel_close(channel_h handle, channel_close_cb callback, void *userParam)
-{
- int result = -1;
-
- CHANNEL_EXTERN_BEGIN;
- result = channel->close((closeChannelCallback)callback, userParam);
- CHANNEL_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int channel_transmit(channel_h handle, unsigned char *command,
- unsigned int length, channel_transmit_cb callback, void *userParam)
-{
- int result = -1;
-
- CHANNEL_EXTERN_BEGIN;
- ByteArray temp;
-
- temp.assign(command, length);
- result = channel->transmit(temp, (transmitCallback)callback, userParam);
- CHANNEL_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API void channel_destroy_instance(channel_h handle)
-{
- /* do nothing */
-}
diff --git a/client/ClientGDBus.cpp b/client/ClientGDBus.cpp
deleted file mode 100755
index 8a3bb8b..0000000
--- a/client/ClientGDBus.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* standard library header */
-#include <glib.h>
-
-/* SLP library header */
-
-/* local header */
-#include "smartcard-types.h"
-#include "Debug.h"
-#include "ByteArray.h"
-#include "ClientGDBus.h"
-
-using namespace std;
-
-/* below functions will be called when dlopen or dlclose is called */
-void __attribute__ ((constructor)) lib_init()
-{
- /* remove for deprecated-declarations build warning: glib ver > 2.36 */
-#if !GLIB_CHECK_VERSION (2, 35, 0)
- g_type_init();
-#endif
-}
-
-void __attribute__ ((destructor)) lib_fini()
-{
-}
-
-namespace smartcard_service_api
-{
-} /* namespace smartcard_service_api */
diff --git a/client/Reader.cpp b/client/Reader.cpp
deleted file mode 100644
index 887d896..0000000
--- a/client/Reader.cpp
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* standard library header */
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-/* SLP library header */
-
-/* local header */
-#include "Debug.h"
-#include "Reader.h"
-#include "Session.h"
-#include "ClientGDBus.h"
-
-#ifndef EXTERN_API
-#define EXTERN_API __attribute__((visibility("default")))
-#endif
-
-namespace smartcard_service_api
-{
- Reader::Reader(void *context, const char *name, void *handle) :
- ReaderHelper(name), context(context), handle(handle)
- {
- _BEGIN();
-
- if (context == NULL || handle == NULL)
- {
- _ERR("invalid param");
-
- return;
- }
-
- /* init default context */
- GError *error = NULL;
-
- proxy = smartcard_service_reader_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.SmartcardService",
- "/org/tizen/SmartcardService/Reader",
- NULL, &error);
- if (proxy == NULL)
- {
- _ERR("Can not create proxy : %s", error->message);
- g_error_free(error);
- return;
- }
-
- present = true;
-
- _END();
- }
-
- Reader::~Reader()
- {
- size_t i;
-
- closeSessions();
-
- for (i = 0; i < sessions.size(); i++)
- {
- delete (Session *)sessions[i];
- }
-
- sessions.clear();
- }
-
- void Reader::closeSessions()
- throw(ErrorIO &, ErrorIllegalState &)
- {
- size_t i;
-
- for (i = 0; i < sessions.size(); i++)
- {
- sessions[i]->closeSync();
- }
- }
-
- SessionHelper *Reader::openSessionSync()
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- Session *session = NULL;
-
- if (isSecureElementPresent() == true)
- {
- gint result;
- GError *error = NULL;
- guint session_id;
-
- if (smartcard_service_reader_call_open_session_sync(
- (SmartcardServiceReader *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle),
- &result, &session_id, NULL, &error) == true) {
- if (result == SCARD_ERROR_OK) {
- /* create new instance of channel */
- session = new Session(context, this,
- GUINT_TO_POINTER(session_id));
- if (session != NULL) {
- sessions.push_back(session);
- } else {
- _ERR("Session creating instance failed");
-
- THROW_ERROR(SCARD_ERROR_OUT_OF_MEMORY);
- }
- } else {
- _ERR("smartcard_service_reader_call_open_session_sync failed, [%d]", result);
-
- THROW_ERROR(result);
- }
- } else {
- _ERR("smartcard_service_reader_call_open_session_sync failed, [%s]", error->message);
- g_error_free(error);
-
- THROW_ERROR(SCARD_ERROR_IPC_FAILED);
- }
- }
- else
- {
- _ERR("unavailable reader");
- throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
- }
-
- return session;
- }
-
- void Reader::reader_open_session_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data)
- {
- CallbackParam *param = (CallbackParam *)user_data;
- Reader *reader;
- openSessionCallback callback;
- Session *session = NULL;
- gint result;
- guint handle;
- GError *error = NULL;
-
- _INFO("MSG_REQUEST_OPEN_SESSION");
-
- if (param == NULL) {
- _ERR("null parameter!!!");
- return;
- }
-
- reader = (Reader *)param->instance;
- callback = (openSessionCallback)param->callback;
-
- if (smartcard_service_reader_call_open_session_finish(
- SMARTCARD_SERVICE_READER(source_object),
- &result, &handle, res, &error) == true) {
- if (result == SCARD_ERROR_OK) {
- /* create new instance of channel */
- session = new Session(reader->context, reader,
- GUINT_TO_POINTER(handle));
- if (session != NULL) {
- reader->sessions.push_back(session);
- } else {
- _ERR("Session creating instance failed");
-
- result = SCARD_ERROR_OUT_OF_MEMORY;
- }
- } else {
- _ERR("smartcard_service_reader_call_open_session failed, [%d]", result);
- }
- } else {
- _ERR("smartcard_service_reader_call_open_session failed, [%s]", error->message);
- g_error_free(error);
-
- result = SCARD_ERROR_IPC_FAILED;
- }
-
- if (callback != NULL) {
- callback(session, result, param->user_param);
- }
-
- delete param;
- }
- int Reader::openSession(openSessionCallback callback, void *userData)
- {
- int result;
-
- _BEGIN();
-
- if (isSecureElementPresent() == true)
- {
- CallbackParam *param = new CallbackParam();
-
- param->instance = this;
- param->callback = (void *)callback;
- param->user_param = userData;
-
- smartcard_service_reader_call_open_session(
- (SmartcardServiceReader *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle),
- NULL, &Reader::reader_open_session_cb, param);
-
- result = SCARD_ERROR_OK;
- }
- else
- {
- _ERR("unavailable reader");
- result = SCARD_ERROR_ILLEGAL_STATE;
- }
-
- _END();
-
- return result;
- }
-} /* namespace smartcard_service_api */
-
-/* export C API */
-#define READER_EXTERN_BEGIN \
- if (handle != NULL) \
- { \
- Reader *reader = (Reader *)handle;
-
-#define READER_EXTERN_END \
- } \
- else \
- { \
- _ERR("Invalid param"); \
- }
-
-using namespace smartcard_service_api;
-
-EXTERN_API int reader_get_name(reader_h handle, char** reader_name)
-{
- int result = SCARD_ERROR_OK;
-
- READER_EXTERN_BEGIN;
-
- try
- {
- *reader_name = g_strdup(reader->getName());
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- }
-
- READER_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int reader_is_secure_element_present(reader_h handle, bool* is_present)
-{
- int result = SCARD_ERROR_OK;
-
- READER_EXTERN_BEGIN;
-
- try
- {
- *is_present = reader->isSecureElementPresent();
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- }
-
- READER_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int reader_open_session_sync(reader_h handle, int *session_handle)
-{
- session_h session;
- int result = SCARD_ERROR_OK;
-
- READER_EXTERN_BEGIN;
-
- try
- {
- session = (session_h)reader->openSessionSync();
- *session_handle = (long)session;
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- *session_handle = 0;
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- *session_handle = 0;
- }
-
- READER_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int reader_close_sessions(reader_h handle)
-{
- int result = SCARD_ERROR_OK;
-
- READER_EXTERN_BEGIN;
-
- try
- {
- reader->closeSessions();
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- }
-
- READER_EXTERN_END;
-
- return result;
-}
-
-
-EXTERN_API se_service_h reader_get_se_service(reader_h handle)
-{
- se_service_h service = NULL;
-
- READER_EXTERN_BEGIN;
- service = (se_service_h)reader->getSEService();
- READER_EXTERN_END;
-
- return service;
-}
-
-EXTERN_API int reader_open_session(reader_h handle, reader_open_session_cb callback, void *userData)
-{
- int result = -1;
-
- READER_EXTERN_BEGIN;
- result = reader->openSession((openSessionCallback)callback, userData);
- READER_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API void reader_destroy_instance(reader_h handle)
-{
-}
diff --git a/client/SEService.cpp b/client/SEService.cpp
deleted file mode 100755
index cac0c85..0000000
--- a/client/SEService.cpp
+++ /dev/null
@@ -1,755 +0,0 @@
-/*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* standard library header */
-#include <unistd.h>
-#include <string.h>
-#include <glib.h>
-#include <glib-object.h>
-
-/* local header */
-#include "Debug.h"
-#include "SEService.h"
-#include "ClientChannel.h"
-#include "Reader.h"
-#include "ClientGDBus.h"
-
-#ifndef EXTERN_API
-#define EXTERN_API __attribute__((visibility("default")))
-#endif
-
-#define SHUTDOWN_DELAY 500000 /* us */
-#define VERSION "3.2"
-
-namespace smartcard_service_api
-{
- SEService::SEService() : SEServiceHelper(),
- handle(-1), context(NULL), handler(NULL), listener(NULL),
- version(VERSION)
- {
- proxy = NULL;
- }
-
- SEService::SEService(void *user_data, serviceConnected handler)
- throw(ErrorIO &, ErrorIllegalParameter &) :
- SEServiceHelper(), handle(-1),
- listener(NULL), version(VERSION)
- {
- initialize(user_data, handler);
- }
-
- SEService::SEService(void *user_data, SEServiceListener *listener)
- throw(ErrorIO &, ErrorIllegalParameter &) :
- SEServiceHelper(), handle(-1),
- handler(NULL), version(VERSION)
- {
- initialize(user_data, listener);
- }
-
- SEService::SEService(void *user_data)
- throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &) :
- SEServiceHelper(), handle(-1),
- handler(NULL), version(VERSION)
- {
- initializeSync(user_data);
- }
-
- SEService::~SEService()
- {
- try
- {
- size_t i;
-
- shutdownSync();
-
- for (i = 0; i < readers.size(); i++)
- {
- delete (Reader *)readers[i];
- }
-
- readers.clear();
- }
- catch (ExceptionBase &e)
- {
- _ERR("EXCEPTION : %s", e.what());
- }
- catch (...)
- {
- _ERR("EXCEPTION!!!");
- }
- }
-
- SEService *SEService::createInstance(void *user_data,
- SEServiceListener *listener)
- throw(ErrorIO &, ErrorIllegalParameter &)
- {
- return new SEService(user_data, listener);
- }
-
- SEService *SEService::createInstance(void *user_data,
- serviceConnected handler)
- throw(ErrorIO &, ErrorIllegalParameter &)
- {
- return new SEService(user_data, handler);
- }
-
- void SEService::reader_inserted(GObject *source_object,
- guint reader_id, gchar *reader_name, gpointer user_data)
- {
- Reader *reader = NULL;
- SEService *service = (SEService *)user_data;
-
- _INFO("[MSG_NOTIFY_SE_INSERTED]");
-
- /* add readers */
- reader = new Reader(service->context,
- reader_name, GUINT_TO_POINTER(reader_id));
- if (reader != NULL)
- {
- service->readers.push_back(reader);
- }
- else
- {
- _ERR("alloc failed");
- }
-
- if (service->listener != NULL)
- {
- service->listener->eventHandler(service,
- reader_name, 1, service->context);
- }
- else if (service->event_handler != NULL)
- {
- service->event_handler(reader_id, 1, service->context);
- }
- else
- {
- _DBG("listener is null");
- }
- }
-
- void SEService::reader_removed(GObject *source_object,
- guint reader_id, gchar *reader_name, gpointer user_data)
- {
- SEService *service = (SEService *)user_data;
- size_t i;
-
- _INFO("[MSG_NOTIFY_SE_REMOVED]");
-
- for (i = 0; i < service->readers.size(); i++)
- {
- if (((Reader *)service->readers[i])->handle ==
- GUINT_TO_POINTER(reader_id))
- {
- ((Reader *)service->readers[i])->unavailable();
- break;
- }
- }
-
- if (service->listener != NULL)
- {
- service->listener->eventHandler(service,
- reader_name, 2, service->context);
- }
- else if (service->event_handler != NULL)
- {
- service->event_handler(reader_id, 2, service->context);
- }
- else
- {
- _DBG("listener is null");
- }
- }
-
- void SEService::se_service_shutdown_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data)
- {
- SEService *service = (SEService *)user_data;
- gint result;
- GError *error = NULL;
-
- if (smartcard_service_se_service_call_shutdown_finish(
- SMARTCARD_SERVICE_SE_SERVICE(source_object),
- &result, res, &error) == true) {
- if (result == SCARD_ERROR_OK) {
- service->connected = false;
- } else {
- _ERR("smartcard_service_se_service_call_shutdown failed, [%d]", result);
- }
- } else {
- _ERR("smartcard_service_se_service_call_shutdown failed, [%s]", error->message);
- g_error_free(error);
- }
- }
-
- void SEService::se_service_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data)
- {
- SEService *service = (SEService *)user_data;
- gint result;
- guint handle;
- GVariant *readers = NULL;
- GError *error = NULL;
-
- if (service == NULL) {
- _ERR("null parameter!!!");
- return;
- }
-
- if (smartcard_service_se_service_call_se_service_finish(
- SMARTCARD_SERVICE_SE_SERVICE(source_object),
- &result, &handle, &readers, res, &error) == true) {
- if (result == SCARD_ERROR_OK) {
- service->connected = true;
- service->handle = handle;
- service->parseReaderInformation(readers);
- }
- } 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);
- } else if (service->listener != NULL) {
- if (result == SCARD_ERROR_OK) {
- service->listener->serviceConnected(service, service->context);
- } else {
- service->listener->errorHandler(service, result, service->context);
- }
- }
- }
-
- void SEService::shutdown()
- {
- shutdownSync();
- }
-
- void SEService::shutdownSync()
- {
- if (connected == true)
- {
- uint32_t i;
-
- for (i = 0; i < readers.size(); i++)
- {
- readers[i]->closeSessions();
- }
-
- gint result;
- GError *error = NULL;
-
- if (smartcard_service_se_service_call_shutdown_sync(
- (SmartcardServiceSeService *)proxy,
- handle,
- &result,
- NULL,
- &error) == false) {
- _ERR("smartcard_service_se_service_call_shutdown_sync failed, [%s]", error->message);
-
- g_error_free(error);
- }
-
- /* wait at least 500ms */
- usleep(SHUTDOWN_DELAY);
-
- connected = false;
- }
- }
-
- bool SEService::_initialize() throw(ErrorIO &)
- {
- bool result = false;
-
- _BEGIN();
-
- /* init default context */
- GError *error = NULL;
-
- 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 */
- smartcard_service_se_service_call_se_service(
- (SmartcardServiceSeService *)proxy,
- NULL,
- &SEService::se_service_cb,
- this);
-
- _END();
-
- return result;
- }
-
- int SEService::_initialize_sync_do_not_throw_exception()
- {
- 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
- {
- _ERR("Initialize error : %d", result);
- }
- }
-
- if (service->handler != NULL) {
- service->handler(service, service->context);
- } else if (service->listener != NULL) {
- if (result == SCARD_ERROR_OK) {
- service->listener->serviceConnected(service, service->context);
- } else {
- service->listener->errorHandler(service, result, service->context);
- }
- }
-
- _END();
-
- 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 &)
- {
- if (context == NULL)
- {
- throw ErrorIllegalParameter(SCARD_ERROR_ILLEGAL_PARAM);
- }
-
- this->context = context;
- this->handler = handler;
-
- return _initialize();
- }
-
- bool SEService::initialize(void *context, SEServiceListener *listener)
- throw(ErrorIO &, ErrorIllegalParameter &)
- {
- if (context == NULL)
- {
- throw ErrorIllegalParameter(SCARD_ERROR_ILLEGAL_PARAM);
- }
-
- this->context = context;
- this->listener = listener;
-
- return _initialize_sync_do_not_throw_exception();
- }
-
- bool SEService::initializeSync(void *context)
- throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &)
- {
- this->context = context;
-
- _initialize_sync();
- return true;
- }
-
- void SEService::setEventHandler(se_service_event_cb cb, void *context)
- {
- this->event_handler = cb;
- this->event_handler_context = context;
- }
-
- bool SEService::parseReaderInformation(GVariant *variant)
- {
- Reader *reader = NULL;
-
- GVariantIter *iter;
- guint handle;
- gchar *name;
-
- g_variant_get(variant, "a(us)", &iter);
-
- while (g_variant_iter_loop(iter, "(us)", &handle, &name) == true)
- {
- SECURE_LOGD("Reader : name [%s], handle [%08x]", name, handle);
-
- /* add readers */
- reader = new Reader((void *)this->handle, name, GUINT_TO_POINTER(handle));
- if (reader == NULL)
- {
- _ERR("alloc failed");
- continue;
- }
-
- readers.push_back(reader);
- }
-
- g_variant_iter_free(iter);
-
- return true;
- }
-
- bool SEService::parseReaderInformation(unsigned int count,
- const ByteArray &data)
- {
- size_t i;
- unsigned int offset = 0;
- unsigned int len = 0;
- void *handle = NULL;
- Reader *reader = NULL;
- char name[100];
- const uint8_t *buffer = NULL;
-
-
- for (i = 0; i < count && offset < data.size(); i++)
- {
- memset(name, 0, sizeof(name));
-
- buffer = data.getBuffer(offset);
- if(buffer == NULL)
- continue;
-
- memcpy(&len, buffer, sizeof(len));
- offset += sizeof(len);
-
- buffer = data.getBuffer(offset);
- if(buffer == NULL)
- return false;
-
- memcpy(name, buffer, len);
- offset += len;
-
- buffer = data.getBuffer(offset);
- if(buffer == NULL)
- return false;
-
- memcpy(&handle, buffer, sizeof(handle));
- offset += sizeof(handle);
-
- SECURE_LOGD("Reader [%d] : name [%s], handle [%p]", i, name, handle);
-
- /* add readers */
- reader = new Reader(context, name, handle);
- if (reader == NULL)
- {
- _ERR("alloc failed");
- continue;
- }
-
- readers.push_back(reader);
- }
-
- return true;
- }
-} /* namespace smartcard_service_api */
-
-/* export C API */
-#define SE_SERVICE_EXTERN_BEGIN \
- if (handle != NULL) \
- { \
- SEService *service = (SEService *)handle;
-
-#define SE_SERVICE_EXTERN_END \
- } \
- else \
- { \
- _ERR("Invalid param"); \
- }
-
-using namespace smartcard_service_api;
-
-EXTERN_API se_service_h se_service_create_instance(void *user_data,
- se_service_connected_cb callback)
-{
- SEService *service;
-
- try
- {
- service = new SEService(user_data, (serviceConnected)callback);
- }
- catch (...)
- {
- service = NULL;
- }
-
- return (se_service_h)service;
-}
-
-EXTERN_API se_service_h se_service_create_instance_with_event_callback(
- void *user_data, se_service_connected_cb connected,
- se_service_event_cb event, se_sesrvice_error_cb error)
-{
- SEService *service;
-
- try
- {
- service = new SEService(user_data, (serviceConnected)connected);
- }
- catch (...)
- {
- service = NULL;
- }
-
- return (se_service_h)service;
-}
-
-EXTERN_API se_service_h se_service_create_instance_sync(void *user_data,
- int *result)
-{
- SEService *service;
-
- try
- {
- service = new SEService(user_data);
- }
- catch (ExceptionBase &e)
- {
- *result = e.getErrorCode();
- service = NULL;
- }
- catch (...)
- {
- *result = SCARD_ERROR_UNKNOWN;
- service = NULL;
- }
-
- return (se_service_h)service;
-}
-
-EXTERN_API int se_service_get_version(se_service_h handle, char **version_str)
-{
- int ret = 0;
-
- SE_SERVICE_EXTERN_BEGIN;
-
- *version_str = g_strdup(service->getVersion());
-
- SE_SERVICE_EXTERN_END;
-
- return ret;
-}
-
-EXTERN_API int se_service_get_readers_count(se_service_h handle)
-{
- int count = 0;
-
- SE_SERVICE_EXTERN_BEGIN;
-
- vector<ReaderHelper *> temp_readers;
-
- temp_readers = service->getReaders();
- count = temp_readers.size();
-
- SE_SERVICE_EXTERN_END;
-
- return count;
-}
-
-EXTERN_API int se_service_get_readers(se_service_h handle, int **readers, int *count)
-{
- int result = 0;
-
- SE_SERVICE_EXTERN_BEGIN;
-
- vector<ReaderHelper *> temp_readers;
- size_t i;
- int temp = 0;
-
- temp_readers = service->getReaders();
- if(temp_readers.size() > 0)
- {
- *readers = (int *)calloc(temp_readers.size(), sizeof(int));
-
- if(*readers == NULL)
- {
- *count = 0;
- return SCARD_ERROR_NOT_ENOUGH_RESOURCE;
- }
-
- for (i = 0; i < temp_readers.size(); i++)
- {
- if (temp_readers[i]->isSecureElementPresent())
- {
- (*readers)[i] = (long)temp_readers[i];
- temp++;
- }
- }
- *count = temp;
- }
- else
- {
- *count = 0;
- }
-
- SE_SERVICE_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API bool se_service_is_connected(se_service_h handle)
-{
- bool result = false;
-
- SE_SERVICE_EXTERN_BEGIN;
-
- result = service->isConnected();
-
- SE_SERVICE_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API void se_service_shutdown(se_service_h handle)
-{
- SE_SERVICE_EXTERN_BEGIN;
-
- service->shutdownSync();
-
- SE_SERVICE_EXTERN_END;
-}
-
-EXTERN_API void se_service_set_event_handler(se_service_h handle,
- se_service_event_cb event_handler, void *user_data)
-{
- SE_SERVICE_EXTERN_BEGIN;
-
- service->setEventHandler(event_handler, user_data);
-
- SE_SERVICE_EXTERN_END;
-}
-
-EXTERN_API void se_service_unset_event_handler(se_service_h handle)
-{
- SE_SERVICE_EXTERN_BEGIN;
-
- service->setEventHandler(NULL, NULL);
-
- SE_SERVICE_EXTERN_END;
-}
-
-EXTERN_API int se_service_destroy_instance(se_service_h handle)
-{
- int result = 0;
-
- SE_SERVICE_EXTERN_BEGIN;
-
- delete service;
-
- SE_SERVICE_EXTERN_END;
-
- return result;
-}
diff --git a/client/Session.cpp b/client/Session.cpp
deleted file mode 100644
index 412bc6a..0000000
--- a/client/Session.cpp
+++ /dev/null
@@ -1,889 +0,0 @@
-/*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* standard library header */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-/* SLP library header */
-
-/* local header */
-#include "Debug.h"
-#include "Session.h"
-#include "Reader.h"
-#include "ClientChannel.h"
-#include "ClientGDBus.h"
-
-#ifndef EXTERN_API
-#define EXTERN_API __attribute__((visibility("default")))
-#endif
-
-namespace smartcard_service_api
-{
- Session::Session(void *context, Reader *reader, void *handle) :
- SessionHelper(reader)
- {
- this->context = NULL;
-
- if (context == NULL || handle == NULL)
- {
- _ERR("handle is null");
-
- return;
- }
-
- this->context = context;
- this->handle = handle;
-
- /* init default context */
- GError *error = NULL;
-
- proxy = smartcard_service_session_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.SmartcardService",
- "/org/tizen/SmartcardService/Session",
- NULL, &error);
- if (proxy == NULL)
- {
- _ERR("Can not create proxy : %s", error->message);
- g_error_free(error);
- return;
- }
-
- closed = false;
- }
-
- Session::~Session()
- {
- size_t i;
-
- closeSync();
-
- for (i = 0; i < channels.size(); i++)
- {
- delete (ClientChannel *)channels[i];
- }
-
- channels.clear();
- }
-
- void Session::closeChannels() throw (ErrorIO &, ErrorIllegalState &)
- {
- size_t i;
-
- for (i = 0; i < channels.size(); i++)
- {
- channels[i]->closeSync();
- }
- }
-
- void Session::session_get_atr_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data)
- {
- CallbackParam *param = (CallbackParam *)user_data;
- Session *session;
- getATRCallback callback;
- gint result;
- GVariant *var_atr;
- GError *error = NULL;
- ByteArray atr;
-
- _INFO("MSG_REQUEST_GET_ATR");
-
- if (param == NULL) {
- _ERR("null parameter!!!");
- return;
- }
-
- session = (Session *)param->instance;
- callback = (getATRCallback)param->callback;
-
- if (smartcard_service_session_call_get_atr_finish(
- SMARTCARD_SERVICE_SESSION(source_object),
- &result, &var_atr, res, &error) == true) {
- if (result == SCARD_ERROR_OK) {
- GDBusHelper::convertVariantToByteArray(var_atr, atr);
-
- session->atr = atr;
- } else {
- _ERR("smartcard_service_session_call_get_atr failed, [%d]", result);
- }
- } else {
- _ERR("smartcard_service_session_call_get_atr failed, [%s]", error->message);
- g_error_free(error);
-
- result = SCARD_ERROR_IPC_FAILED;
- }
-
- if (callback != NULL) {
- callback(atr.getBuffer(),
- atr.size(), result, param->user_param);
- }
-
- delete param;
- }
-
- void Session::session_open_channel_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data)
- {
- CallbackParam *param = (CallbackParam *)user_data;
- Session *session;
- openChannelCallback callback;
- gint result = SCARD_ERROR_UNKNOWN;
- gint channel_number;
- guint channel_id;
- GVariant *var_response;
- GError *error = NULL;
- Channel *channel = NULL;
-
- _INFO("MSG_REQUEST_OPEN_CHANNEL");
-
- if (param == NULL) {
- _ERR("null parameter!!!");
- return;
- }
-
- session = (Session *)param->instance;
- callback = (openChannelCallback)param->callback;
-
- if (smartcard_service_session_call_open_channel_finish(
- SMARTCARD_SERVICE_SESSION(source_object),
- &result, &channel_id, &channel_number, &var_response,
- res, &error) == true) {
- if (result == SCARD_ERROR_OK) {
- ByteArray response;
-
- GDBusHelper::convertVariantToByteArray(
- var_response, response);
-
- /* create new instance of channel */
- channel = new ClientChannel(session->context,
- session, channel_id,
- response, (void *)channel_id);
- if (channel != NULL) {
- session->channels.push_back(channel);
- } else {
- _ERR("alloc failed");
-
- result = SCARD_ERROR_OUT_OF_MEMORY;
- }
- } else {
- _ERR("smartcard_service_session_call_open_channel failed, [%d]", result);
- }
- } else {
- _ERR("smartcard_service_session_call_open_channel failed, [%s]", error->message);
- g_error_free(error);
-
- result = SCARD_ERROR_IPC_FAILED;
- }
-
- if (callback != NULL) {
- callback(channel, result, param->user_param);
- }
-
- delete param;
- }
-
- void Session::session_close_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data)
- {
- CallbackParam *param = (CallbackParam *)user_data;
- Session *session;
- closeSessionCallback callback;
- gint result;
- GError *error = NULL;
-
- _INFO("MSG_REQUEST_CLOSE_SESSION");
-
- if (param == NULL) {
- _ERR("null parameter!!!");
- return;
- }
-
- session = (Session *)param->instance;
- callback = (closeSessionCallback)param->callback;
-
- if (smartcard_service_session_call_close_session_finish(
- SMARTCARD_SERVICE_SESSION(source_object),
- &result, res, &error) == true) {
- if (result == SCARD_ERROR_OK) {
- session->closed = true;
- } else {
- _ERR("smartcard_service_session_call_close_session failed, [%d]", result);
- }
- } else {
- _ERR("smartcard_service_session_call_close_session failed, [%s]", error->message);
- g_error_free(error);
-
- result = SCARD_ERROR_IPC_FAILED;
- }
-
- if (callback != NULL) {
- callback(result, param->user_param);
- }
-
- delete param;
- }
-
- const ByteArray Session::getATRSync()
- throw (ExceptionBase &, ErrorIO &, ErrorSecurity &,
- ErrorIllegalState &, ErrorIllegalParameter &)
- {
- ByteArray result;
-
- if (getReader()->isSecureElementPresent() == true)
- {
- if (atr.isEmpty() == true)
- {
- gint ret;
- GVariant *var_atr = NULL;
- GError *error = NULL;
-
- if (smartcard_service_session_call_get_atr_sync(
- (SmartcardServiceSession *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle),
- &ret, &var_atr, NULL, &error) == true) {
- if (ret == SCARD_ERROR_OK) {
- GDBusHelper::convertVariantToByteArray(var_atr, result);
-
- atr = result;
- } else {
- _ERR("smartcard_service_session_call_get_atr_sync failed, [%d]", ret);
-
- THROW_ERROR(ret);
- }
- } else {
- _ERR("smartcard_service_session_call_get_atr_sync failed, [%s]", error->message);
- g_error_free(error);
-
- THROW_ERROR(SCARD_ERROR_IPC_FAILED);
- }
- }
-
- result = atr;
- }
- else
- {
- _ERR("unavailable session");
- throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
- }
-
- return result;
- }
-
- int Session::getATR(getATRCallback callback, void *userData)
- {
- int result;
-
- if (getReader()->isSecureElementPresent() == true)
- {
- if (atr.isEmpty() == true)
- {
- CallbackParam *param = new CallbackParam();
-
- param->instance = this;
- param->callback = (void *)callback;
- param->user_param = userData;
-
- smartcard_service_session_call_get_atr(
- (SmartcardServiceSession *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle), NULL,
- &Session::session_get_atr_cb, param);
-
- result = SCARD_ERROR_OK;
- }
- else
- {
- result = SCARD_ERROR_OK;
-
- /* TODO : invoke callback directly */
- callback(atr.getBuffer(),
- atr.size(), 0, userData);
- }
- }
- else
- {
- _ERR("unavailable session");
- result = SCARD_ERROR_ILLEGAL_STATE;
- }
-
- return result;
- }
-
- void Session::closeSync()
- throw (ExceptionBase &, ErrorIO &, ErrorSecurity &,
- ErrorIllegalState &, ErrorIllegalParameter &)
- {
- if (isClosed() == false)
- {
- closed = true;
- closeChannels();
-
- gint ret;
- GError *error = NULL;
-
- if (smartcard_service_session_call_close_session_sync(
- (SmartcardServiceSession *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle),
- &ret, NULL, &error) == true) {
- if (ret == SCARD_ERROR_OK) {
- closed = true;
- } else {
- _ERR("smartcard_service_session_call_close_session_sync failed, [%d]", ret);
-
- THROW_ERROR(ret);
- }
- } else {
- _ERR("smartcard_service_session_call_get_atr_sync failed, [%s]", error->message);
- g_error_free(error);
-
- THROW_ERROR(SCARD_ERROR_IPC_FAILED);
- }
- }
- }
-
- int Session::close(closeSessionCallback callback, void *userData)
- {
- int result = SCARD_ERROR_OK;
-
- if (isClosed() == false)
- {
- closed = true;
- closeChannels();
-
- CallbackParam *param = new CallbackParam();
-
- param->instance = this;
- param->callback = (void *)callback;
- param->user_param = userData;
-
- smartcard_service_session_call_close_session(
- (SmartcardServiceSession *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle), NULL,
- &Session::session_close_cb, param);
- }
-
- return result;
- }
-
- size_t Session::getChannelCount() const
- {
- size_t count = 0;
-
- if (getReader()->isSecureElementPresent() == true)
- {
- count = channels.size();
- }
- else
- {
- _ERR("unavailable session");
- throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
- }
-
- return count;
- }
- Channel *Session::openChannelSync(int id, const ByteArray &aid)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- return openChannelSync(id, aid, 0x00);
- }
-
- Channel *Session::openChannelSync(int id, const ByteArray &aid, unsigned char P2)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- Channel *channel = NULL;
-
- if (getReader()->isSecureElementPresent() == true)
- {
- gint ret;
- GVariant *var_aid = NULL, *var_response = NULL;
- guint channel_id;
- gint channel_number;
- GError *error = NULL;
-
- var_aid = GDBusHelper::convertByteArrayToVariant(aid);
-
- if (smartcard_service_session_call_open_channel_sync(
- (SmartcardServiceSession *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle),
- (guint)id, var_aid, (guint8)P2, &ret, &channel_id, &channel_number,
- &var_response, NULL, &error) == true) {
- if (ret == SCARD_ERROR_OK && channel_id != 0) {
- ByteArray response;
-
- GDBusHelper::convertVariantToByteArray(
- var_response, response);
-
- /* create new instance of channel */
- channel = new ClientChannel(context,
- this, channel_number,
- response, (void *)channel_id);
- if (channel != NULL)
- {
- channels.push_back(channel);
- }
- else
- {
- _ERR("alloc failed");
-
- THROW_ERROR(SCARD_ERROR_OUT_OF_MEMORY);
- }
- } else {
- _ERR("smartcard_service_session_call_open_channel_sync failed, [%d]", ret);
-
- THROW_ERROR(ret);
- }
- } else {
- _ERR("smartcard_service_session_call_open_channel_sync failed, [%s]", error->message);
- g_error_free(error);
-
- THROW_ERROR(SCARD_ERROR_IPC_FAILED);
- }
- }
- else
- {
- _ERR("unavailable session");
-
- throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
- }
-
- return (Channel *)channel;
- }
-
- int Session::openChannel(int id, const ByteArray &aid, openChannelCallback callback, void *userData)
- {
- int result;
-
- if (getReader()->isSecureElementPresent() == true)
- {
- GVariant *var_aid;
-
- CallbackParam *param = new CallbackParam();
-
- param->instance = this;
- param->callback = (void *)callback;
- param->user_param = userData;
-
- var_aid = GDBusHelper::convertByteArrayToVariant(aid);
-
- smartcard_service_session_call_open_channel(
- (SmartcardServiceSession *)proxy,
- GPOINTER_TO_UINT(context),
- GPOINTER_TO_UINT(handle),
- (guint)id, var_aid, 0, NULL,
- &Session::session_open_channel_cb, param);
-
- result = SCARD_ERROR_OK;
- }
- else
- {
- _ERR("unavailable session");
- result = SCARD_ERROR_ILLEGAL_STATE;
- }
-
- return result;
- }
-
- Channel *Session::openBasicChannelSync(const ByteArray &aid)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- return openChannelSync(0, aid, 0x00);
- }
-
- Channel *Session::openBasicChannelSync(const ByteArray &aid, unsigned char P2)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- return openChannelSync(0, aid, P2);
- }
-
- Channel *Session::openBasicChannelSync(const unsigned char *aid, unsigned int length)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- ByteArray temp(aid, length);
-
- return openBasicChannelSync(temp, 0x00);
- }
-
- Channel *Session::openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- ByteArray temp(aid, length);
-
- return openBasicChannelSync(temp, P2);
- }
-
- int Session::openBasicChannel(const ByteArray &aid, openChannelCallback callback, void *userData)
- {
- return openChannel(0, aid, callback, userData);
- }
-
- int Session::openBasicChannel(const unsigned char *aid, unsigned int length,
- openChannelCallback callback, void *userData)
- {
- ByteArray temp(aid, length);
-
- return openBasicChannel(temp, callback, userData);
- }
-
- Channel *Session::openLogicalChannelSync(const ByteArray &aid)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- return openChannelSync(1, aid, 0x00);
- }
-
- Channel *Session::openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- return openChannelSync(1, aid, P2);
- }
-
- Channel *Session::openLogicalChannelSync(const unsigned char *aid, unsigned int length)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- ByteArray temp(aid, length);
-
- return openLogicalChannelSync(temp, 0x00);
- }
-
- Channel *Session::openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
- throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &)
- {
- ByteArray temp(aid, length);
-
- return openLogicalChannelSync(temp, P2);
- }
-
- int Session::openLogicalChannel(const ByteArray &aid, openChannelCallback callback, void *userData)
- {
- return openChannel(1, aid, callback, userData);
- }
-
- int Session::openLogicalChannel(const unsigned char *aid, unsigned int length,
- openChannelCallback callback, void *userData)
- {
- ByteArray temp(aid, length);
-
- return openLogicalChannel(temp, callback, userData);
- }
-} /* namespace smartcard_service_api */
-
-/* export C API */
-#define SESSION_EXTERN_BEGIN \
- if (handle != NULL) \
- { \
- Session *session = (Session *)handle;
-
-#define SESSION_EXTERN_END \
- } \
- else \
- { \
- _ERR("Invalid param"); \
- }
-
-using namespace smartcard_service_api;
-
-EXTERN_API int session_get_reader(session_h handle, int* reader_handle)
-{
- int result = SCARD_ERROR_OK;
- reader_h reader = NULL;
-
- SESSION_EXTERN_BEGIN;
-
- try
- {
- reader = session->getReader();
- *reader_handle = (long)reader;
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- *reader_handle = 0;
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- *reader_handle = 0;
- }
-
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int session_is_closed(session_h handle, bool* is_closed)
-{
- int result = SCARD_ERROR_OK;
-
- SESSION_EXTERN_BEGIN;
-
- try
- {
- *is_closed = session->isClosed();
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- }
-
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int session_close_channels(session_h handle)
-{
- int result = SCARD_ERROR_OK;
-
- SESSION_EXTERN_BEGIN;
-
- try
- {
- session->closeChannels();
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- }
-
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length)
-{
- ByteArray temp;
- int result = SCARD_ERROR_OK;
-
- SESSION_EXTERN_BEGIN;
-
- try
- {
- temp = session->getATRSync();
-
- if (temp.size() > 0)
- {
- *buffer = (unsigned char *)calloc(temp.size(), sizeof(char));
- *length = temp.size();
-
- memcpy(*buffer, temp.getBuffer(), *length);
- }
- }
- catch (ErrorIllegalState &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
-
- if(result == SCARD_ERROR_OPERATION_NOT_SUPPORTED)
- {
- *length = 0;
- result = SCARD_ERROR_OK;
- }
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- *length = 0;
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- *length = 0;
- }
-
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int session_close_sync(session_h handle)
-{
- int result = SCARD_ERROR_OK;
-
- SESSION_EXTERN_BEGIN;
-
- try
- {
- session->closeSync();
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- }
-
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int session_open_basic_channel_sync(session_h handle, unsigned char *aid,
- unsigned int length, unsigned char P2, int* channel_handle)
-{
- int result = SCARD_ERROR_OK;
-
- SESSION_EXTERN_BEGIN;
-
- try
- {
- *channel_handle = (long)session->openBasicChannelSync(aid, length, P2);
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- *channel_handle = 0;
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- *channel_handle = 0;
- }
-
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int session_open_logical_channel_sync(session_h handle, unsigned char *aid,
- unsigned int length, unsigned char P2, int* channel_handle)
-{
- int result = SCARD_ERROR_OK;
-
- SESSION_EXTERN_BEGIN;
-
- try
- {
- *channel_handle = (long)session->openLogicalChannelSync(aid, length, P2);
- }
- catch (ExceptionBase &e)
- {
- _ERR("Error occur : %s\n", e.what());
- result = e.getErrorCode();
- *channel_handle = 0;
- }
- catch (...)
- {
- _ERR("Error occur : unknown error\n");
- result = SCARD_ERROR_UNKNOWN;
- *channel_handle = 0;
- }
-
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int session_get_atr(session_h handle, session_get_atr_cb callback, void *userData)
-{
- int result = -1;
-
- SESSION_EXTERN_BEGIN;
- result = session->getATR((getATRCallback)callback, userData);
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int session_close(session_h handle, session_close_session_cb callback, void *userData)
-{
- int result = -1;
-
- SESSION_EXTERN_BEGIN;
- result = session->close((closeSessionCallback)callback, userData);
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int session_open_basic_channel(session_h handle, unsigned char *aid,
- unsigned int length, session_open_channel_cb callback, void *userData)
-{
- int result = -1;
-
- SESSION_EXTERN_BEGIN;
- result = session->openBasicChannel(aid, length, (openChannelCallback)callback, userData);
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API int session_open_logical_channel(session_h handle, unsigned char *aid,
- unsigned int length, session_open_channel_cb callback, void *userData)
-{
- int result = -1;
-
- SESSION_EXTERN_BEGIN;
- result = session->openLogicalChannel(aid, length, (openChannelCallback)callback, userData);
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API size_t session_get_channel_count(session_h handle)
-{
- size_t result = 0;
-
- SESSION_EXTERN_BEGIN;
- result = session->getChannelCount();
- SESSION_EXTERN_END;
-
- return result;
-}
-
-EXTERN_API void session_destroy_instance(session_h handle)
-{
-}
-
diff --git a/client/include/ClientChannel.h b/client/include/ClientChannel.h
deleted file mode 100644
index a4e75ee..0000000
--- a/client/include/ClientChannel.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CLIENTCHANNEL_H_
-#define CLIENTCHANNEL_H_
-
-/* standard library header */
-#include <gio/gio.h>
-
-/* SLP library header */
-
-/* local header */
-#include "smartcard-types.h"
-#ifdef __cplusplus
-#include "Channel.h"
-#include "Session.h"
-#endif /* __cplusplus */
-
-#ifdef __cplusplus
-namespace smartcard_service_api
-{
- class ClientChannel: public Channel
- {
- private:
- void *context;
- void *handle;
- void *proxy;
-
- ClientChannel(void *context, Session *session, int channelNum,
- const ByteArray &selectResponse, void *handle);
- ~ClientChannel();
-
- static void channel_transmit_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data);
- static void channel_close_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data);
-
- public:
- int close(closeChannelCallback callback, void *userParam);
- int transmit(const ByteArray &command,
- transmitCallback callback, void *userParam);
- bool selectNext(){ return false; }
-
- void closeSync()
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorSecurity &, ErrorIllegalParameter &);
- int transmitSync(const ByteArray &command, ByteArray &result)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- void *getHandle(){ return handle; }
-
- friend class Session;
- };
-} /* namespace smartcard_service_api */
-#endif /* __cplusplus */
-
-/* export C API */
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-int channel_is_basic_channel(channel_h handle, bool* is_basic_channel);
-int channel_is_closed(channel_h handle, bool* is_closed );
-int channel_get_session(channel_h handle, int *session_handle);
-int channel_close_sync(channel_h handle);
-int channel_transmit_sync(channel_h handle, unsigned char *command,
- unsigned int cmd_len, unsigned char **response, unsigned int *resp_len);
-int channel_get_select_response(channel_h handle,
- unsigned char **buffer, size_t* length);
-int channel_get_transmit_response(channel_h handle,
- unsigned char **buffer, size_t* length);
-int channel_select_next(channel_h hChannel, bool *pSuccess);
-////
-
-int channel_close(channel_h handle, channel_close_cb callback, void *userParam);
-int channel_transmit(channel_h handle, unsigned char *command,
- unsigned int length, channel_transmit_cb callback, void *userParam);
-unsigned int channel_get_select_response_length(channel_h handle);
-void channel_destroy_instance(channel_h handle) __attribute__((deprecated));
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CLIENTCHANNEL_H_ */
diff --git a/client/include/ClientGDBus.h b/client/include/ClientGDBus.h
deleted file mode 100644
index c111874..0000000
--- a/client/include/ClientGDBus.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef CLIENTGDBUS_H_
-#define CLIENTGDBUS_H_
-
-/* standard library header */
-#include <glib.h>
-
-/* SLP library header */
-
-/* local header */
-#include "GDBusHelper.h"
-#include "smartcard-service-gdbus.h"
-
-namespace smartcard_service_api
-{
- class ClientGDBus
- {
- };
-} /* namespace smartcard_service_api */
-
-#endif /* CLIENTGDBUS_H_ */
diff --git a/client/include/Reader.h b/client/include/Reader.h
deleted file mode 100644
index 876d0b8..0000000
--- a/client/include/Reader.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef READER_H_
-#define READER_H_
-
-/* standard library header */
-#include <glib.h>
-#include <gio/gio.h>
-
-/* SLP library header */
-
-/* local header */
-#include "smartcard-types.h"
-#ifdef __cplusplus
-#include "ReaderHelper.h"
-#include "Session.h"
-#endif /* __cplusplus */
-
-#ifdef __cplusplus
-namespace smartcard_service_api
-{
- class Reader: public ReaderHelper
- {
- private:
- void *context;
- void *handle;
- void *proxy;
-
- Reader(void *context, const char *name, void *handle);
- ~Reader();
-
- inline void unavailable() { present = false; }
- static void reader_open_session_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data);
-
- public:
- void closeSessions()
- throw(ErrorIO &, ErrorIllegalState &);
-
- int openSession(openSessionCallback callback, void *userData);
- SessionHelper *openSessionSync()
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- void *getHandle(){ return handle; }
-
- friend class SEService;
- };
-} /* namespace smartcard_service_api */
-#endif /* __cplusplus */
-
-/* export C API */
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-int reader_get_name(reader_h handle, char** reader_name);
-int reader_is_secure_element_present(reader_h handle, bool* is_present);
-int reader_open_session_sync(reader_h handle, int *session_handle);
-int reader_close_sessions(reader_h handle);
-///
-
-int reader_open_session(reader_h handle, reader_open_session_cb callback,
- void *userData);
-se_service_h reader_get_se_service(reader_h handle);
-__attribute__((deprecated)) void reader_destroy_instance(reader_h handle);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* READER_H_ */
diff --git a/client/include/SEService.h b/client/include/SEService.h
deleted file mode 100644
index e6aa87c..0000000
--- a/client/include/SEService.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SESERVICE_H_
-#define SESERVICE_H_
-
-/* standard library header */
-#include <glib.h>
-#include <gio/gio.h>
-
-/* SLP library header */
-
-/* local header */
-#include "smartcard-types.h"
-#ifdef __cplusplus
-#include "SEServiceListener.h"
-#include "SEServiceHelper.h"
-#endif /* __cplusplus */
-
-#ifdef __cplusplus
-using namespace std;
-
-namespace smartcard_service_api
-{
- typedef void (*serviceConnected)(SEServiceHelper *service, void *context);
-
- class SEService : public SEServiceHelper
- {
- private:
- unsigned int handle;
- void *context;
- serviceConnected handler;
- SEServiceListener *listener;
-
- se_service_event_cb event_handler;
- void *event_handler_context;
-
- void *proxy;
- const char *version;
-
- SEService();
-
- void addReader(unsigned int handle, const char *name);
- bool parseReaderInformation(unsigned int count, const ByteArray &data);
- bool parseReaderInformation(GVariant *variant);
-
- bool _initialize()
- throw(ErrorIO &);
- bool initialize(void *context, serviceConnected handler)
- throw(ErrorIO &, ErrorIllegalParameter &);
- bool initialize(void *context, SEServiceListener *listener)
- throw(ErrorIO &, ErrorIllegalParameter &);
- int _initialize_sync()
- throw(ErrorIO &, ExceptionBase &);
- int _initialize_sync_do_not_throw_exception();
- bool initializeSync(void *context)
- throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &);
-
- static void reader_inserted(GObject *source_object,
- guint reader_id, gchar *reader_name,
- gpointer user_data);
- static void reader_removed(GObject *source_object,
- guint reader_id, gchar *reader_name,
- gpointer user_data);
- static void se_service_shutdown_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data);
- static void se_service_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data);
-
- public:
- SEService(void *user_data, serviceConnected handler)
- throw(ErrorIO &, ErrorIllegalParameter &);
- SEService(void *user_data, SEServiceListener *listener)
- throw(ErrorIO &, ErrorIllegalParameter &);
- SEService(void *user_data)
- throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &);
- ~SEService();
-
- static SEService *createInstance(void *user_data, SEServiceListener *listener)
- throw(ErrorIO &, ErrorIllegalParameter &);
- static SEService *createInstance(void *user_data, serviceConnected handler)
- throw(ErrorIO &, ErrorIllegalParameter &);
-
- void setEventHandler(se_service_event_cb cb, void *context);
- void shutdown();
- void shutdownSync();
- const char *getVersion() const { return version; }
- };
-} /* namespace smartcard_service_api */
-#endif /* __cplusplus */
-
-/* export C API */
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-se_service_h se_service_create_instance(void *user_data,
- se_service_connected_cb callback);
-se_service_h se_service_create_instance_with_event_callback(void *user_data,
- se_service_connected_cb connected, se_service_event_cb event,
- se_sesrvice_error_cb error);
-
-se_service_h se_service_create_instance_sync(void *user_data, int* result);
-int se_service_get_version(se_service_h handle, char **version_str);
-int se_service_get_readers_count(se_service_h handle);
-int se_service_get_readers(se_service_h handle, int **readers, int *count);
-
-bool se_service_is_connected(se_service_h handle);
-void se_service_shutdown(se_service_h handle);
-
-void se_service_set_event_handler(se_service_h handle, se_service_event_cb event_handler, void *user_data);
-void se_service_unset_event_handler(se_service_h handle);
-
-int se_service_destroy_instance(se_service_h handle);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* SESERVICE_H_ */
diff --git a/client/include/SEServiceListener.h b/client/include/SEServiceListener.h
deleted file mode 100644
index 9cfc01b..0000000
--- a/client/include/SEServiceListener.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SESERVICELISTENER_H_
-#define SESERVICELISTENER_H_
-
-/* standard library header */
-
-/* SLP library header */
-
-/* local header */
-
-namespace smartcard_service_api
-{
- class SEServiceHelper;
-
- class SEServiceListener
- {
- public:
- virtual void serviceConnected(SEServiceHelper *service,
- void *context) = 0;
- virtual void eventHandler(SEServiceHelper *service,
- char *seName, int event, void *context) = 0;
- virtual void errorHandler(SEServiceHelper *service, int error,
- void *context) = 0;
- };
-} /* namespace open_mobile_api */
-
-#endif /* SESERVICELISTENER_H_ */
diff --git a/client/include/Session.h b/client/include/Session.h
deleted file mode 100644
index 7d530e3..0000000
--- a/client/include/Session.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SESSION_H_
-#define SESSION_H_
-
-/* standard library header */
-#include <gio/gio.h>
-
-/* SLP library header */
-
-/* local header */
-#include "smartcard-types.h"
-#ifdef __cplusplus
-#include "SessionHelper.h"
-#endif /* __cplusplus */
-
-#ifdef __cplusplus
-namespace smartcard_service_api
-{
- class Reader;
-
- class Session : public SessionHelper
- {
- private:
- void *context;
- void *handle;
- void *proxy;
-
- Session(void *context, Reader *reader, void *handle);
- ~Session();
-
- int openChannel(int id, const ByteArray &aid, openChannelCallback callback, void *userData);
-
- Channel *openChannelSync(int id, const ByteArray &aid)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- Channel *openChannelSync(int id, const ByteArray &aid, unsigned char P2)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- static void session_get_atr_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data);
- static void session_open_channel_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data);
- static void session_close_cb(GObject *source_object,
- GAsyncResult *res, gpointer user_data);
-
- public:
- void closeChannels()
- throw(ErrorIO &, ErrorIllegalState &);
-
- int getATR(getATRCallback callback, void *userData);
- int close(closeSessionCallback callback, void *userData);
-
- int openBasicChannel(const ByteArray &aid, openChannelCallback callback, void *userData);
- int openBasicChannel(const unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData);
- int openLogicalChannel(const ByteArray &aid, openChannelCallback callback, void *userData);
- int openLogicalChannel(const unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData);
-
- const ByteArray getATRSync()
- throw(ExceptionBase &, ErrorIO &, ErrorSecurity &,
- ErrorIllegalState &, ErrorIllegalParameter &);
-
- void closeSync()
- throw(ExceptionBase &, ErrorIO &, ErrorSecurity &,
- ErrorIllegalState &, ErrorIllegalParameter &);
-
- Channel *openBasicChannelSync(const ByteArray &aid)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- Channel *openLogicalChannelSync(const ByteArray &aid)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- Channel *openBasicChannelSync(const ByteArray &aid, unsigned char P2)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- Channel *openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
- throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
- ErrorIllegalParameter &, ErrorSecurity &);
-
- size_t getChannelCount() const;
- void *getHandle(){ return handle; }
-
- friend class Reader;
- };
-} /* namespace smartcard_service_api */
-#endif /* __cplusplus */
-
-/* export C API */
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-int session_get_reader(session_h handle, int* reader_handle);
-int session_is_closed(session_h handle, bool* is_closed);
-int session_close_channels(session_h handle);
-int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length);
-int session_close_sync(session_h handle);
-int session_open_basic_channel_sync(session_h handle, unsigned char *aid,
- unsigned int length, unsigned char P2, int* channel_handle);
-int session_open_logical_channel_sync(session_h handle, unsigned char *aid,
- unsigned int length, unsigned char P2, int* channel_handle);
-///
-
-int session_get_atr(session_h handle, session_get_atr_cb callback,
- void *userData);
-int session_close(session_h handle, session_close_session_cb callback,
- void *userData);
-int session_open_basic_channel(session_h handle, unsigned char *aid,
- unsigned int length, session_open_channel_cb callback, void *userData);
-int session_open_logical_channel(session_h handle, unsigned char *aid,
- unsigned int length, session_open_channel_cb callback, void *userData);
-size_t session_get_channel_count(session_h handle);
-__attribute__((deprecated)) void session_destroy_instance(session_h handle);
-
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* SESSION_H_ */
diff --git a/client/include/smartcard-service.h b/client/include/smartcard-service.h
deleted file mode 100644
index 354e11f..0000000
--- a/client/include/smartcard-service.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SMARTCARD_SERVICE_H_
-#define SMARTCARD_SERVICE_H_
-
-#include "smartcard-types.h"
-#ifdef __cplusplus
-#include "Exception.h"
-#endif
-#include "SEService.h"
-#include "Reader.h"
-#include "Session.h"
-#include "ClientChannel.h"
-
-#endif /* SMARTCARD_SERVICE_H_ */
diff --git a/client/smartcard-service.pc b/client/smartcard-service.pc
deleted file mode 100644
index fb0b732..0000000
--- a/client/smartcard-service.pc
+++ /dev/null
@@ -1,13 +0,0 @@
-# Package Information for pkg-config
-
-prefix=/usr
-exec_prefix=${prefix}/bin
-includedir=${prefix}/include
-libdir=${prefix}/lib
-
-Name: smartcard-service
-Description: Make flags of Common library of Smartcard service
-Version: 1.0
-Requires: glib-2.0 dlog
-Libs: -L${libdir} -lsmartcard-service
-Cflags: -I${includedir}/smartcard-service \ No newline at end of file
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index bf7c6d1..364d8bb 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -63,6 +63,16 @@ SET(EXPORT_HEADER
include/TerminalInterface.h
include/Terminal.h
include/SignatureHelper.h
+ include/SessionHelper.h
+ include/Channel.h
+ include/ReaderHelper.h
+ include/APDUHelper.h
+ include/GDBusHelper.h
+ include/ProviderHelper.h
+ include/TLVHelper.h
+ include/SEServiceHelper.h
+ include/OpensslHelper.h
+ smartcard-service-gdbus.h
)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
diff --git a/packaging/smartcard-service-server b/packaging/smartcard-service-server
deleted file mode 100644
index ec68963..0000000
--- a/packaging/smartcard-service-server
+++ /dev/null
@@ -1,206 +0,0 @@
-Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
-
diff --git a/packaging/smartcard-service-server.init b/packaging/smartcard-service.init
index ffc409b..13264e1 100755
--- a/packaging/smartcard-service-server.init
+++ b/packaging/smartcard-service.init
@@ -1,6 +1,6 @@
#!/bin/sh
### BEGIN INIT INFO
-# Provides: smartcard-service-server
+# Provides: smartcard-service
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
@@ -25,4 +25,4 @@ SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
-$DAEMON $DAEMON_ARGS & \ No newline at end of file
+$DAEMON $DAEMON_ARGS &
diff --git a/packaging/smartcard-service.spec b/packaging/smartcard-service.spec
index 0f98f26..24454d5 100755
--- a/packaging/smartcard-service.spec
+++ b/packaging/smartcard-service.spec
@@ -1,19 +1,21 @@
# FOR COMMENTING DEFINITION, MUST USE %% instead of %
%global use_autostart "-DUSE_AUTOSTART=1"
#%%global test_client "-DTEST_CLIENT=1"
+%global bindir /usr/apps/%{name}
################################################################################
# package : smartcard-service #
################################################################################
Name: smartcard-service
Summary: Smartcard Service FW
-Version: 0.1.50
+Version: 0.1.51
Release: 0
-Group: libs
+Group: Network & Connectivity
+Requires: %{name}-common = %{version}-%{release}
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
%if 0%{!?use_autostart:1}
-Source1: %{name}-server.init
+Source1: %{name}.init
%endif
BuildRequires: cmake
BuildRequires: pkgconfig(glib-2.0)
@@ -45,37 +47,39 @@ Smartcard Service FW.
%files
%manifest %{name}.manifest
%defattr(-,root,root,-)
-%{_libdir}/lib%{name}.so.*
+%{bindir}/bin/smartcard-daemon
+%if 0%{?test_client:1}
+ %{bindir}/bin/smartcard-test-client
+%endif
+%if 0%{?use_autostart:1}
+ %{_datadir}/dbus-1/system-services/org.tizen.SmartcardService.service
+%else
+ %{_sysconfdir}/init.d/%{name}
+%endif
+%{bindir}/%{name}
+%{bindir}/author-signature.xml
+%{bindir}/signature1.xml
+/etc/dbus-1/system.d/org.tizen.SmartcardService.conf
%{_datadir}/license/%{name}
%post
-/sbin/ldconfig
-
+/usr/bin/signing-client/hash-signer-client.sh -a -d -p platform %{bindir}
+%if 0%{!?use_autostart:1}
+ ln -sf /etc/init.d/%{name} /etc/rc.d/rc3.d/S79%{name}
+ ln -sf /etc/init.d/%{name} /etc/rc.d/rc5.d/S79%{name}
+%endif
+ln -sf /usr/apps/%{name}/bin/smartcard-daemon /usr/bin/smartcard-daemon
+%if 0%{?test_client:1}
+ ln -sf /usr/apps/%{name}/bin/smartcard-test-client /usr/bin/smartcard-test-client
+%endif
%postun
-/sbin/ldconfig
-
-
-################################################################################
-# package : smartcard-service-devel #
-################################################################################
-%package devel
-Summary: smartcard service devel
-Group: Development/Libraries
-Requires: %{name} = %{version}-%{release}
-
-
-%description devel
-smartcard service.
-
-
-%files devel
-%manifest %{name}-devel.manifest
-%defattr(-,root,root,-)
-%{_includedir}/%{name}/*
-%{_libdir}/lib%{name}.so
-%{_libdir}/pkgconfig/%{name}.pc
+%if 0%{!?use_autostart:1}
+ rm -f /etc/rc.d/rc3.d/S79%{name}
+ rm -f /etc/rc.d/rc5.d/S79%{name}
+%endif
+rm -f /usr/bin/smartcard-daemon
################################################################################
@@ -117,58 +121,7 @@ common smartcard service.
%{_libdir}/lib%{name}-common.so
%{_libdir}/pkgconfig/%{name}-common.pc
-
-################################################################################
-# package : smartcard-service-server #
-################################################################################
-%global bindir /usr/apps/%{name}-server
-
-%package server
-Summary: server smartcard service
-Group: Development/Libraries
-Requires: %{name}-common = %{version}-%{release}
-
-
-%description server
-smartcard service server
-
-
-%post server
-/usr/bin/signing-client/hash-signer-client.sh -a -d -p platform %{bindir}
-%if 0%{!?use_autostart:1}
- ln -sf /etc/init.d/%{name}-server /etc/rc.d/rc3.d/S79%{name}-server
- ln -sf /etc/init.d/%{name}-server /etc/rc.d/rc5.d/S79%{name}-server
-%endif
-ln -sf /usr/apps/%{name}-server/bin/smartcard-daemon /usr/bin/smartcard-daemon
-%if 0%{?test_client:1}
- ln -sf /usr/apps/%{name}-server/bin/smartcard-test-client /usr/bin/smartcard-test-client
-%endif
-
-
-%postun server
-%if 0%{!?use_autostart:1}
- rm -f /etc/rc.d/rc3.d/S79%{name}-server
- rm -f /etc/rc.d/rc5.d/S79%{name}-server
-%endif
-rm -f /usr/bin/smartcard-daemon
-
-
-%files server
-%manifest %{name}-server.manifest
-%defattr(-,root,root,-)
-%{bindir}/bin/smartcard-daemon
-%if 0%{?test_client:1}
- %{bindir}/bin/smartcard-test-client
-%endif
-%if 0%{?use_autostart:1}
- %{_datadir}/dbus-1/system-services/org.tizen.SmartcardService.service
-%else
- %{_sysconfdir}/init.d/%{name}-server
-%endif
-%{bindir}/%{name}-server
-%{bindir}/author-signature.xml
-%{bindir}/signature1.xml
-/etc/dbus-1/system.d/org.tizen.SmartcardService.conf
+###
################################################################################
# common... #
@@ -195,14 +148,14 @@ cd obj-arm-limux-qnueabi
%__mkdir -p %{buildroot}/etc/init.d/
%__mkdir -p %{buildroot}/etc/rc.d/rc3.d/
%__mkdir -p %{buildroot}/etc/rc.d/rc5.d/
- %__cp -af %SOURCE1 %{buildroot}/etc/init.d/%{name}-server
- chmod 755 %{buildroot}/etc/init.d/%{name}-server
+ %__cp -af %SOURCE1 %{buildroot}/etc/init.d/%{name}
+ chmod 755 %{buildroot}/etc/init.d/%{name}
%endif
mkdir -p %{buildroot}/usr/share/license
mkdir -p %{buildroot}/etc/dbus-1/system.d/
cp -af %{_builddir}/%{name}-%{version}/packaging/%{name} %{buildroot}/usr/share/license/
cp -af %{_builddir}/%{name}-%{version}/packaging/%{name}-common %{buildroot}/usr/share/license/
-cp -af %{_builddir}/%{name}-%{version}/packaging/%{name}-server %{buildroot}%{bindir}
+cp -af %{_builddir}/%{name}-%{version}/packaging/%{name} %{buildroot}%{bindir}
cp -af %{_builddir}/%{name}-%{version}/packaging/org.tizen.SmartcardService.conf %{buildroot}/etc/dbus-1/system.d/
%define tizen_sign 1
diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt
index 21221f0..28baa1e 100644
--- a/server/CMakeLists.txt
+++ b/server/CMakeLists.txt
@@ -31,14 +31,14 @@ INCLUDE(FindPkgConfig)
SET(PKG_MODULE glib-2.0 gio-2.0 gio-unix-2.0 dlog cynara-client cynara-creds-gdbus cynara-session)
-pkg_check_modules(pkgs_server REQUIRED ${PKG_MODULE})
+pkg_check_modules(pkgs REQUIRED ${PKG_MODULE})
-FOREACH(flag ${pkgs_server_CFLAGS})
+FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-MESSAGE("CHECK MODULE in ${PROJECT_NAME} ${pkgs_server_LDFLAGS}")
+MESSAGE("CHECK MODULE in ${PROJECT_NAME} ${pkgs_LDFLAGS}")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -fno-strict-aliasing -Wl,-zdefs -fvisibility=hidden")
SET(ARM_CFLAGS "${ARM_CLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fpic")
@@ -59,16 +59,16 @@ IF("${ARCH}" MATCHES "^arm.*")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARM_CFLAGS}")
ENDIF()
-ADD_DEFINITIONS("-DPREFIX=\"/usr/apps/smartcard-service-server\"")
-ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE_SERVER\"")
+ADD_DEFINITIONS("-DPREFIX=\"/usr/apps/smartcard-service\"")
+ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE\"")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_server_LDFLAGS} "-L../common" "-lsmartcard-service-common" "-pie -ldl")
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-L../common" "-lsmartcard-service-common" "-pie -ldl")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/apps/smartcard-service-server/bin)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/apps/smartcard-service/bin)
IF("${USE_AUTOSTART}" STREQUAL "1")
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.tizen.SmartcardService.service DESTINATION share/dbus-1/system-services)
ENDIF()
diff --git a/server/org.tizen.SmartcardService.service b/server/org.tizen.SmartcardService.service
index a2e59e9..05a886a 100644
--- a/server/org.tizen.SmartcardService.service
+++ b/server/org.tizen.SmartcardService.service
@@ -1,6 +1,6 @@
[D-BUS Service]
Name=org.tizen.SmartcardService
-Exec=/usr/apps/smartcard-service-server/bin/smartcard-daemon
+Exec=/usr/apps/smartcard-service/bin/smartcard-daemon
MemoryLimit=10M
User=network_fw
Group=network_fw
diff --git a/smartcard-service-server.manifest b/smartcard-service-server.manifest
deleted file mode 100644
index 97e8c31..0000000
--- a/smartcard-service-server.manifest
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
- <request>
- <domain name="_"/>
- </request>
-</manifest>
diff --git a/test-client/CMakeLists.txt b/test-client/CMakeLists.txt
index 434f147..51b89db 100644
--- a/test-client/CMakeLists.txt
+++ b/test-client/CMakeLists.txt
@@ -45,4 +45,4 @@ ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE_TEST\"")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_test_client_LDFLAGS} "-L../common" "-lsmartcard-service-common" "-L../client" "-lsmartcard-service" "-pie -ldl")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/apps/smartcard-service-server/bin)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/apps/smartcard-service/bin)