Remove legacy codes 63/9963/2
authorWonkyu Kwon <wonkyu.kwon@samsung.com>
Thu, 5 Sep 2013 11:48:41 +0000 (20:48 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Thu, 12 Sep 2013 23:48:40 +0000 (08:48 +0900)
Change-Id: Ie0db3901a0008163d38a361b520a3dbf442b4375

39 files changed:
CMakeLists.txt
client/CMakeLists.txt
client/ClientChannel.cpp
client/ClientDispatcher.cpp [deleted file]
client/ClientGDBus.cpp
client/ClientIPC.cpp [deleted file]
client/Reader.cpp
client/SEService.cpp
client/Session.cpp
client/include/ClientChannel.h
client/include/ClientDispatcher.h [deleted file]
client/include/ClientGDBus.h
client/include/ClientIPC.h [deleted file]
client/include/Reader.h
client/include/SEService.h
client/include/Session.h
common/DispatcherHelper.cpp [deleted file]
common/GDBusHelper.cpp
common/IPCHelper.cpp [deleted file]
common/Message.cpp [deleted file]
common/include/DispatcherHelper.h [deleted file]
common/include/DispatcherMsg.h [deleted file]
common/include/GDBusHelper.h
common/include/IPCHelper.h [deleted file]
common/include/Message.h [deleted file]
packaging/smartcard-service.spec
server/CMakeLists.txt
server/ClientInstance.cpp
server/ServerDispatcher.cpp [deleted file]
server/ServerGDBus.cpp
server/ServerIPC.cpp [deleted file]
server/ServerResource.cpp
server/ServerSEService.cpp
server/include/ClientInstance.h
server/include/ServerDispatcher.h [deleted file]
server/include/ServerGDBus.h
server/include/ServerIPC.h [deleted file]
server/include/ServerResource.h
server/smartcard-daemon.cpp

index f78f23c..f391106 100644 (file)
@@ -4,37 +4,26 @@ MESSAGE("build smartcard-service")
 
 SET(CMAKE_VERBOSE_MAKEFILE OFF)
 
-IF(DEFINED USE_GDBUS)
-       ADD_DEFINITIONS("-DUSE_GDBUS")
-
-       # apply smack
-       ##ADD_DEFINITIONS("-DUSER_SPACE_SMACK")
-
-       IF(DEFINED USE_AUTOSTART)
-               ADD_DEFINITIONS("-DUSE_AUTOSTART")
-       ENDIF()
-
-       FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
-       EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
-               " \\
-               --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/common/smartcard-service-gdbus \\
-               --c-namespace SmartcardService\\
-               --interface-prefix org.tizen.SmartcardService. \\
-               ${CMAKE_CURRENT_SOURCE_DIR}/common/smartcard-service-gdbus.xml \\
-               ")
-ELSE()
-       ADD_DEFINITIONS("-DCLIENT_IPC_THREAD")
-       ADD_DEFINITIONS("-DUSE_IPC_EPOLL")
-
-       IF(DEFINED USE_AUTOSTART)
-               ADD_DEFINITIONS("-DUSE_AUTOSTART")
-
-               FIND_PROGRAM(DBUS_BINDING_TOOL NAMES dbus-binding-tool)
-               EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=smartcard_service ${CMAKE_CURRENT_SOURCE_DIR}/common/smartcard-service.xml --mode=glib-server --output=${CMAKE_CURRENT_SOURCE_DIR}/common/include/smartcard-service-binding.h")
-               EXEC_PROGRAM("${DBUS_BINDING_TOOL}" ARGS "--prefix=smartcard_service ${CMAKE_CURRENT_SOURCE_DIR}/common/smartcard-service.xml --mode=glib-client --output=${CMAKE_CURRENT_SOURCE_DIR}/common/include/smartcard-service-glue.h")
-       ENDIF()
+# apply smack
+ADD_DEFINITIONS("-DUSER_SPACE_SMACK")
+
+IF(DEFINED USE_AUTOSTART)
+       ADD_DEFINITIONS("-DUSE_AUTOSTART")
 ENDIF()
 
+SET(GC_SECTIONS_FLAGS "-fdata-sections -ffunction-sections -Wl,--gc-sections")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GC_SECTIONS_FLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GC_SECTIONS_FLAGS}")
+
+FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
+EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
+       " \\
+       --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/common/smartcard-service-gdbus \\
+       --c-namespace SmartcardService\\
+       --interface-prefix org.tizen.SmartcardService. \\
+       ${CMAKE_CURRENT_SOURCE_DIR}/common/smartcard-service-gdbus.xml \\
+       ")
+
 ADD_SUBDIRECTORY(common)
 ADD_SUBDIRECTORY(client)
 ADD_SUBDIRECTORY(server)
index d78c8ab..08b52c6 100644 (file)
@@ -21,9 +21,6 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 INCLUDE(FindPkgConfig)
 
 SET(PKG_MODULE glib-2.0 dlog)
-IF(NOT DEFINED USE_GDBUS)
-       SET(PKG_MODULE ${PKG_MODULE} dbus-glib-1)
-ENDIF()
 
 pkg_check_modules(pkgs_client REQUIRED ${PKG_MODULE})
 
index 9639c43..3a5a6d7 100644 (file)
@@ -18,9 +18,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#ifdef USE_GDBUS
 #include <glib.h>
-#endif
 
 /* SLP library header */
 
 #include "ClientChannel.h"
 #include "ReaderHelper.h"
 #include "APDUHelper.h"
-#ifdef USE_GDBUS
 #include "ClientGDBus.h"
-#else
-#include "Message.h"
-#include "ClientIPC.h"
-#endif
 
 #ifndef EXTERN_API
 #define EXTERN_API __attribute__((visibility("default")))
@@ -61,7 +54,7 @@ namespace smartcard_service_api
                this->handle = handle;
                this->selectResponse = selectResponse;
                this->context = context;
-#ifdef USE_GDBUS
+
                /* initialize client */
                if (!g_thread_supported())
                {
@@ -84,7 +77,6 @@ namespace smartcard_service_api
                        g_error_free(error);
                        return;
                }
-#endif
        }
 
        ClientChannel::~ClientChannel()
@@ -92,7 +84,6 @@ namespace smartcard_service_api
                closeSync();
        }
 
-#ifdef USE_GDBUS
        void ClientChannel::channel_transmit_cb(GObject *source_object,
                GAsyncResult *res, gpointer user_data)
        {
@@ -176,7 +167,7 @@ namespace smartcard_service_api
 
                delete param;
        }
-#endif
+
        void ClientChannel::closeSync()
                throw(ExceptionBase &, ErrorIO &, ErrorSecurity &,
                        ErrorIllegalState &, ErrorIllegalParameter &)
@@ -185,7 +176,6 @@ namespace smartcard_service_api
                {
                        if (getSession()->getReader()->isSecureElementPresent() == true)
                        {
-#ifdef USE_GDBUS
                                gint ret;
                                GError *error = NULL;
 
@@ -209,43 +199,6 @@ namespace smartcard_service_api
 
                                        throw ErrorIO(SCARD_ERROR_IPC_FAILED);
                                }
-#else
-                               Message msg;
-                               int rv;
-
-#ifdef CLIENT_IPC_THREAD
-                               /* send message to server */
-                               msg.message = Message::MSG_REQUEST_CLOSE_CHANNEL;
-                               msg.param1 = (unsigned long)handle;
-                               msg.error = (unsigned long)context; /* using error to context */
-                               msg.caller = (void *)this;
-                               msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
-
-                               syncLock();
-                               if (ClientIPC::getInstance().sendMessage(msg) == true)
-                               {
-                                       rv = waitTimedCondition(0);
-                                       if (rv < 0)
-                                       {
-                                               _ERR("timeout [%d]", rv);
-                                               this->error = SCARD_ERROR_OPERATION_TIMEOUT;
-                                       }
-                               }
-                               else
-                               {
-                                       _ERR("sendMessage failed");
-                                       this->error = SCARD_ERROR_IPC_FAILED;
-                               }
-                               syncUnlock();
-
-                               channelNum = -1;
-
-                               if (this->error != SCARD_ERROR_OK)
-                               {
-                                       ThrowError::throwError(this->error);
-                               }
-#endif
-#endif
                        }
                        else
                        {
@@ -262,7 +215,6 @@ namespace smartcard_service_api
                {
                        if (getSession()->getReader()->isSecureElementPresent() == true)
                        {
-#ifdef USE_GDBUS
                                CallbackParam *param = new CallbackParam();
 
                                param->instance = this;
@@ -274,24 +226,6 @@ namespace smartcard_service_api
                                        GPOINTER_TO_UINT(context),
                                        GPOINTER_TO_UINT(handle), NULL,
                                        &ClientChannel::channel_close_cb, param);
-#else
-                               Message msg;
-                               channelNum = -1;
-
-                               /* send message to server */
-                               msg.message = Message::MSG_REQUEST_CLOSE_CHANNEL;
-                               msg.param1 = (unsigned long)handle;
-                               msg.error = (unsigned long)context; /* using error to context */
-                               msg.caller = (void *)this;
-                               msg.callback = (void *)callback;
-                               msg.userParam = userParam;
-
-                               if (ClientIPC::getInstance().sendMessage(msg) == false)
-                               {
-                                       _ERR("sendMessage failed");
-                                       result = SCARD_ERROR_IPC_FAILED;
-                               }
-#endif
                        }
                        else
                        {
@@ -311,7 +245,6 @@ namespace smartcard_service_api
 
                if (getSession()->getReader()->isSecureElementPresent() == true)
                {
-#ifdef USE_GDBUS
                        GVariant *var_command = NULL, *var_response = NULL;
                        GError *error = NULL;
 
@@ -336,45 +269,6 @@ namespace smartcard_service_api
 
                                throw ErrorIO(SCARD_ERROR_IPC_FAILED);
                        }
-#else
-                       Message msg;
-#ifdef CLIENT_IPC_THREAD
-                       /* send message to server */
-                       msg.message = Message::MSG_REQUEST_TRANSMIT;
-                       msg.param1 = (unsigned long)handle;
-                       msg.param2 = 0;
-                       msg.data = command;
-                       msg.error = (unsigned long)context; /* using error to context */
-                       msg.caller = (void *)this;
-                       msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
-
-                       syncLock();
-                       if (ClientIPC::getInstance().sendMessage(msg) == true)
-                       {
-                               rv = waitTimedCondition(0);
-                               if (rv >= 0)
-                               {
-                                       result = response;
-                                       rv = SCARD_ERROR_OK;
-                               }
-                               else
-                               {
-                                       _ERR("timeout [%d]", rv);
-                                       this->error = SCARD_ERROR_OPERATION_TIMEOUT;
-                               }
-                       }
-                       else
-                       {
-                               _ERR("sendMessage failed");
-                       }
-                       syncUnlock();
-
-                       if (this->error != SCARD_ERROR_OK)
-                       {
-                               ThrowError::throwError(this->error);
-                       }
-#endif
-#endif
                }
                else
                {
@@ -391,7 +285,6 @@ namespace smartcard_service_api
 
                if (getSession()->getReader()->isSecureElementPresent() == true)
                {
-#ifdef USE_GDBUS
                        GVariant *var_command;
                        CallbackParam *param = new CallbackParam();
 
@@ -409,29 +302,6 @@ namespace smartcard_service_api
                                &ClientChannel::channel_transmit_cb, param);
 
                        result = SCARD_ERROR_OK;
-#else
-                       Message msg;
-
-                       /* send message to server */
-                       msg.message = Message::MSG_REQUEST_TRANSMIT;
-                       msg.param1 = (unsigned long)handle;
-                       msg.param2 = 0;
-                       msg.data = command;
-                       msg.error = (unsigned long)context; /* using error to context */
-                       msg.caller = (void *)this;
-                       msg.callback = (void *)callback;
-                       msg.userParam = userParam;
-
-                       if (ClientIPC::getInstance().sendMessage(msg) == true)
-                       {
-                               result = SCARD_ERROR_OK;
-                       }
-                       else
-                       {
-                               _ERR("sendMessage failed");
-                               result = SCARD_ERROR_IPC_FAILED;
-                       }
-#endif
                }
                else
                {
@@ -441,88 +311,6 @@ namespace smartcard_service_api
 
                return result;
        }
-
-#ifndef USE_GDBUS
-       bool ClientChannel::dispatcherCallback(void *message)
-       {
-               Message *msg = (Message *)message;
-               ClientChannel *channel = NULL;
-               bool result = false;
-
-               if (msg == NULL)
-               {
-                       _ERR("message is null");
-                       return result;
-               }
-
-               channel = (ClientChannel *)msg->caller;
-
-               switch (msg->message)
-               {
-               case Message::MSG_REQUEST_TRANSMIT :
-                       {
-                               /* transmit result */
-                               _INFO("MSG_REQUEST_TRANSMIT");
-
-                               if (msg->isSynchronousCall() == true) /* synchronized call */
-                               {
-                                       /* sync call */
-                                       channel->syncLock();
-
-                                       /* copy result */
-                                       channel->error = msg->error;
-                                       channel->response = msg->data;
-
-                                       channel->signalCondition();
-                                       channel->syncUnlock();
-                               }
-                               else if (msg->callback != NULL)
-                               {
-                                       transmitCallback cb = (transmitCallback)msg->callback;
-
-                                       /* async call */
-                                       cb(msg->data.getBuffer(),
-                                               msg->data.size(),
-                                               msg->error,
-                                               msg->userParam);
-                               }
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_CLOSE_CHANNEL :
-                       {
-                               _INFO("MSG_REQUEST_CLOSE_CHANNEL");
-
-                               if (msg->isSynchronousCall() == true) /* synchronized call */
-                               {
-                                       /* sync call */
-                                       channel->syncLock();
-
-                                       channel->error = msg->error;
-
-                                       channel->signalCondition();
-                                       channel->syncUnlock();
-                               }
-                               else if (msg->callback != NULL)
-                               {
-                                       closeChannelCallback cb = (closeChannelCallback)msg->callback;
-
-                                       /* async call */
-                                       cb(msg->error, msg->userParam);
-                               }
-                       }
-                       break;
-
-               default:
-                       _DBG("Unknown message : %s", msg->toString().c_str());
-                       break;
-               }
-
-               delete msg;
-
-               return result;
-       }
-#endif /* USE_GDBUS */
 } /* namespace smartcard_service_api */
 
 /* export C API */
@@ -568,7 +356,6 @@ EXTERN_API int channel_transmit(channel_h handle, unsigned char *command,
 
 EXTERN_API void channel_close_sync(channel_h handle)
 {
-#ifdef CLIENT_IPC_THREAD
        CHANNEL_EXTERN_BEGIN;
        try
        {
@@ -578,7 +365,6 @@ EXTERN_API void channel_close_sync(channel_h handle)
        {
        }
        CHANNEL_EXTERN_END;
-#endif
 }
 
 EXTERN_API int channel_transmit_sync(channel_h handle, unsigned char *command,
@@ -586,7 +372,6 @@ EXTERN_API int channel_transmit_sync(channel_h handle, unsigned char *command,
 {
        int result = -1;
 
-#ifdef CLIENT_IPC_THREAD
        if (command == NULL || cmd_len == 0 || response == NULL || resp_len == NULL)
                return result;
 
@@ -610,7 +395,6 @@ EXTERN_API int channel_transmit_sync(channel_h handle, unsigned char *command,
                result = -1;
        }
        CHANNEL_EXTERN_END;
-#endif
 
        return result;
 }
diff --git a/client/ClientDispatcher.cpp b/client/ClientDispatcher.cpp
deleted file mode 100644 (file)
index 4af04ba..0000000
+++ /dev/null
@@ -1,219 +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 USE_GDBUS
-/* standard library header */
-#include <glib.h>
-
-/* SLP library header */
-
-/* local header */
-#include "Debug.h"
-#include "ClientDispatcher.h"
-#include "SEService.h"
-#include "Reader.h"
-#include "Session.h"
-#include "ClientChannel.h"
-
-namespace smartcard_service_api
-{
-       ClientDispatcher::ClientDispatcher()
-       {
-       }
-
-       ClientDispatcher::~ClientDispatcher()
-       {
-               mapSESerivces.clear();
-       }
-
-       ClientDispatcher &ClientDispatcher::getInstance()
-       {
-               static ClientDispatcher clientDispatcher;
-
-               return clientDispatcher;
-       }
-
-       bool ClientDispatcher::addSEService(unsigned int handle, SEService *service)
-       {
-               bool result = true;
-               map<unsigned int, SEService *>::iterator item;
-
-               _BEGIN();
-
-               if ((item = mapSESerivces.find(handle)) == mapSESerivces.end())
-               {
-                       mapSESerivces.insert(make_pair(handle, service));
-               }
-               else
-               {
-                       _DBG("SEService [%p] exists", handle);
-               }
-
-               _END();
-
-               return result;
-       }
-
-       void ClientDispatcher::removeSEService(unsigned int handle)
-       {
-               map<unsigned int, SEService *>::iterator item;
-
-               _BEGIN();
-
-               if ((item = mapSESerivces.find(handle)) != mapSESerivces.end())
-               {
-                       mapSESerivces.erase(item);
-               }
-               else
-               {
-                       _DBG("SEService doesn't exist");
-               }
-
-               _END();
-       }
-
-       void *ClientDispatcher::dispatcherThreadFunc(DispatcherMsg *msg, void *data)
-       {
-               _BEGIN();
-
-               if (msg == NULL)
-                       return NULL;
-
-               /* this messages are response from server */
-               switch (msg->message)
-               {
-               /* SE Service requests */
-               case Message::MSG_REQUEST_READERS :
-               case Message::MSG_REQUEST_SHUTDOWN :
-                       {
-                               DispatcherMsg *tempMsg = new DispatcherMsg(*msg);
-
-                               if (msg->isSynchronousCall() == false)
-                               {
-                                       /* Asynchronous call */
-                                       g_idle_add((GSourceFunc)&SEService::dispatcherCallback, (gpointer)tempMsg);
-                               }
-                               else
-                               {
-                                       /* Synchronous call */
-                                       SEService::dispatcherCallback(tempMsg);
-                               }
-                       }
-                       break;
-
-               /* Reader requests */
-               case Message::MSG_REQUEST_OPEN_SESSION :
-                       {
-                               DispatcherMsg *tempMsg = new DispatcherMsg(*msg);
-
-                               if (msg->isSynchronousCall() == false)
-                               {
-                                       /* Asynchronous call */
-                                       g_idle_add((GSourceFunc)&Reader::dispatcherCallback, (gpointer)tempMsg);
-                               }
-                               else
-                               {
-                                       /* Synchronous call */
-                                       Reader::dispatcherCallback(tempMsg);
-                               }
-                       }
-                       break;
-
-               /* Session requests */
-               case Message::MSG_REQUEST_OPEN_CHANNEL :
-               case Message::MSG_REQUEST_GET_ATR :
-               case Message::MSG_REQUEST_CLOSE_SESSION :
-               case Message::MSG_REQUEST_GET_CHANNEL_COUNT :
-                       {
-                               DispatcherMsg *tempMsg = new DispatcherMsg(*msg);
-
-                               if (msg->isSynchronousCall() == false)
-                               {
-                                       /* Asynchronous call */
-                                       g_idle_add((GSourceFunc)&Session::dispatcherCallback, (gpointer)tempMsg);
-                               }
-                               else
-                               {
-                                       /* Synchronous call */
-                                       Session::dispatcherCallback(tempMsg);
-                               }
-                       }
-                       break;
-
-               /* ClientChannel requests */
-               case Message::MSG_REQUEST_TRANSMIT :
-               case Message::MSG_REQUEST_CLOSE_CHANNEL :
-                       {
-                               DispatcherMsg *tempMsg = new DispatcherMsg(*msg);
-
-                               if (msg->isSynchronousCall() == false)
-                               {
-                                       /* Asynchronous call */
-                                       g_idle_add((GSourceFunc)&ClientChannel::dispatcherCallback, (gpointer)tempMsg);
-                               }
-                               else
-                               {
-                                       /* Synchronous call */
-                                       ClientChannel::dispatcherCallback(tempMsg);
-                               }
-                       }
-                       break;
-
-               case Message::MSG_NOTIFY_SE_INSERTED :
-               case Message::MSG_NOTIFY_SE_REMOVED :
-                       {
-                               map<unsigned int, SEService *>::iterator item;
-
-                               for (item = mapSESerivces.begin(); item != mapSESerivces.end(); item++)
-                               {
-                                       DispatcherMsg *tempMsg = new DispatcherMsg(*msg);
-
-                                       tempMsg->caller = item->second;
-
-                                       /* Always asynchronous call */
-                                       g_idle_add((GSourceFunc)&SEService::dispatcherCallback, (gpointer)tempMsg);
-                               }
-                       }
-                       break;
-
-               case Message::MSG_OPERATION_RELEASE_CLIENT :
-                       {
-                               map<unsigned int, SEService *>::iterator item;
-
-                               for (item = mapSESerivces.begin(); item != mapSESerivces.end(); item++)
-                               {
-                                       DispatcherMsg *tempMsg = new DispatcherMsg(*msg);
-
-                                       tempMsg->caller = item->second;
-                                       tempMsg->error = -1;
-
-                                       /* Always asynchronous call */
-                                       g_idle_add((GSourceFunc)&SEService::dispatcherCallback, (gpointer)tempMsg);
-                               }
-                       }
-                       break;
-
-               default :
-                       break;
-               }
-
-               _END();
-
-               return NULL;
-       }
-
-} /* namespace open_mobile_api */
-#endif /* USE_GDBUS */
index 799917f..5e755dd 100644 (file)
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#ifdef USE_GDBUS
 /* standard library header */
 #include <glib.h>
 
@@ -31,4 +30,3 @@ using namespace std;
 namespace smartcard_service_api
 {
 } /* namespace smartcard_service_api */
-#endif
diff --git a/client/ClientIPC.cpp b/client/ClientIPC.cpp
deleted file mode 100644 (file)
index 5239ff9..0000000
+++ /dev/null
@@ -1,247 +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 USE_GDBUS
-/* standard library header */
-#include <sys/socket.h>
-#include <unistd.h>
-
-/* SLP library header */
-#ifdef SECURITY_SERVER
-#include "security-server.h"
-#endif
-
-/* local header */
-#include "Debug.h"
-#include "ClientIPC.h"
-#include "DispatcherMsg.h"
-
-namespace smartcard_service_api
-{
-       ClientIPC::ClientIPC() : IPCHelper()
-       {
-#ifdef USE_AUTOSTART
-               _launch_daemon();
-#endif
-#ifdef SECURITY_SERVER
-               int length;
-
-               if ((length = security_server_get_cookie_size()) > 0)
-               {
-                       uint8_t *buffer = NULL;
-
-                       buffer = new uint8_t[length];
-                       if (buffer != NULL)
-                       {
-                               int error;
-
-                               if ((error = security_server_request_cookie((char *)buffer, length))
-                                       == SECURITY_SERVER_API_SUCCESS)
-                               {
-                                       cookie.assign(buffer, length);
-
-                                       _DBG("cookie : %s", cookie.toString().c_str());
-                               }
-                               else
-                               {
-                                       _ERR("security_server_request_cookie failed [%d]", error);
-                               }
-
-                               delete []buffer;
-                       }
-               }
-               else
-               {
-                       _ERR("security_server_get_cookie_size failed");
-               }
-#endif
-       }
-
-       ClientIPC::~ClientIPC()
-       {
-       }
-
-       ClientIPC &ClientIPC::getInstance()
-       {
-               static ClientIPC clientIPC;
-
-               return clientIPC;
-       }
-
-#ifdef USE_AUTOSTART
-       void ClientIPC::_launch_daemon()
-       {
-               DBusGConnection *connection;
-               GError *error = NULL;
-
-               _BEGIN();
-
-               dbus_g_thread_init();
-
-               g_type_init();
-
-               connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
-               if (error == NULL)
-               {
-                       DBusGProxy *proxy;
-
-                       proxy = dbus_g_proxy_new_for_name(connection, "org.tizen.smartcard_service",
-                               "/org/tizen/smartcard_service", "org.tizen.smartcard_service");
-                       if (proxy != NULL)
-                       {
-                               gint result = 0;
-
-                               if (dbus_g_proxy_call(proxy, "launch", &error, G_TYPE_INVALID,
-                                       G_TYPE_INT, &result, G_TYPE_INVALID) == false)
-                               {
-                                       _ERR("org_tizen_smartcard_service_launch failed");
-                                       if (error != NULL)
-                                       {
-                                               _ERR("message : [%s]", error->message);
-                                               g_error_free(error);
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               _ERR("ERROR: Can't make dbus proxy");
-                       }
-               }
-               else
-               {
-                       _ERR("ERROR: Can't get on system bus [%s]", error->message);
-                       g_error_free(error);
-               }
-
-               _END();
-       }
-#endif
-
-       bool ClientIPC::sendMessage(const Message &msg)
-       {
-               ByteArray stream;
-               unsigned int length;
-
-               if (ipcSocket == -1)
-                       return false;
-
-#ifdef SECURITY_SERVER
-               stream = cookie + msg.serialize();
-#else
-               stream = msg.serialize();
-#endif
-               length = stream.size();
-
-               _DBG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]",
-                       ipcSocket, msg.message, stream.size());
-
-               return IPCHelper::sendMessage(ipcSocket, stream);
-       }
-
-       int ClientIPC::handleIOErrorCondition(void *channel, GIOCondition condition)
-       {
-               _BEGIN();
-
-               if (dispatcher != NULL)
-               {
-                       DispatcherMsg dispMsg;
-
-                       /* push or process disconnect message */
-                       dispMsg.message = Message::MSG_OPERATION_RELEASE_CLIENT;
-                       dispMsg.error = -1;
-
-#ifdef CLIENT_IPC_THREAD
-                       dispatcher->processMessage(&dispMsg);
-#else
-                       dispatcher->pushMessage(&dispMsg);
-#endif
-               }
-
-               _END();
-
-               return FALSE;
-       }
-
-       int ClientIPC::handleInvalidSocketCondition(void *channel, GIOCondition condition)
-       {
-               _BEGIN();
-
-               /* finalize context */
-               destroyConnectSocket();
-
-               _END();
-
-               return FALSE;
-       }
-
-       int ClientIPC::handleIncomingCondition(void *channel, GIOCondition condition)
-       {
-               int result = FALSE;
-
-               _BEGIN();
-
-#ifndef CLIENT_IPC_THREAD
-               if (channel == ioChannel)
-               {
-#endif
-                       Message *msg = NULL;
-
-                       _DBG("message from server to client socket");
-
-                       /* read message */
-                       msg = retrieveMessage();
-                       if (msg != NULL)
-                       {
-                               DispatcherMsg dispMsg(*msg);
-
-                               /* set peer socket */
-                               dispMsg.setPeerSocket(ipcSocket);
-
-                               /* push to dispatcher */
-                               if (dispatcher != NULL)
-                               {
-#ifdef CLIENT_IPC_THREAD
-                                       dispatcher->processMessage(&dispMsg);
-#else
-                                       dispatcher->pushMessage(&dispMsg);
-#endif
-                               }
-
-                               delete msg;
-                       }
-                       else
-                       {
-                               /* clear client connection */
-#ifdef CLIENT_IPC_THREAD
-                               handleIOErrorCondition(channel, condition);
-                               result = -1;
-#endif
-                       }
-
-#ifndef CLIENT_IPC_THREAD
-               }
-               else
-               {
-                       _ERR("Unknown channel event [%p]", channel);
-               }
-#endif
-
-               _END();
-
-               return result;
-       }
-} /* namespace open_mobile_api */
-#endif /* USE_GDBUS */
index e218553..4a8b78c 100644 (file)
 #include "Debug.h"
 #include "Reader.h"
 #include "Session.h"
-#ifdef USE_GDBUS
 #include "ClientGDBus.h"
-#else
-#include "Message.h"
-#include "ClientIPC.h"
-#endif
 
 #ifndef EXTERN_API
 #define EXTERN_API __attribute__((visibility("default")))
@@ -49,7 +44,7 @@ namespace smartcard_service_api
 
                        return;
                }
-#ifdef USE_GDBUS
+
                /* initialize client */
                if (!g_thread_supported())
                {
@@ -72,7 +67,7 @@ namespace smartcard_service_api
                        g_error_free(error);
                        return;
                }
-#endif
+
                present = true;
 
                _END();
@@ -111,7 +106,6 @@ namespace smartcard_service_api
 
                if (isSecureElementPresent() == true)
                {
-#ifdef USE_GDBUS
                        gint result;
                        GError *error = NULL;
                        guint session_id;
@@ -143,44 +137,6 @@ namespace smartcard_service_api
 
                                THROW_ERROR(SCARD_ERROR_IPC_FAILED);
                        }
-#else
-                       Message msg;
-                       int rv;
-
-                       openedSession = NULL;
-#ifdef CLIENT_IPC_THREAD
-                       /* request channel handle from server */
-                       msg.message = Message::MSG_REQUEST_OPEN_SESSION;
-                       msg.param1 = (unsigned long)handle;
-                       msg.error = (unsigned long)context; /* using error to context */
-                       msg.caller = (void *)this;
-                       msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
-
-                       syncLock();
-                       if (ClientIPC::getInstance().sendMessage(msg) == true)
-                       {
-                               rv = waitTimedCondition(0);
-                               if (rv != 0)
-                               {
-                                       _ERR("time over");
-                                       this->error = SCARD_ERROR_OPERATION_TIMEOUT;
-                               }
-
-                               session = openedSession;
-                       }
-                       else
-                       {
-                               _ERR("sendMessage failed");
-                               this->error = SCARD_ERROR_IPC_FAILED;
-                       }
-                       syncUnlock();
-
-                       if (this->error != SCARD_ERROR_OK)
-                       {
-                               ThrowError::throwError(this->error);
-                       }
-#endif
-#endif
                }
                else
                {
@@ -191,7 +147,6 @@ namespace smartcard_service_api
                return session;
        }
 
-#ifdef USE_GDBUS
        void Reader::reader_open_session_cb(GObject *source_object,
                GAsyncResult *res, gpointer user_data)
        {
@@ -243,7 +198,6 @@ namespace smartcard_service_api
 
                delete param;
        }
-#endif
        int Reader::openSession(openSessionCallback callback, void *userData)
        {
                int result;
@@ -252,7 +206,6 @@ namespace smartcard_service_api
 
                if (isSecureElementPresent() == true)
                {
-#ifdef USE_GDBUS
                        CallbackParam *param = new CallbackParam();
 
                        param->instance = this;
@@ -266,27 +219,6 @@ namespace smartcard_service_api
                                NULL, &Reader::reader_open_session_cb, param);
 
                        result = SCARD_ERROR_OK;
-#else
-                       Message msg;
-
-                       /* request channel handle from server */
-                       msg.message = Message::MSG_REQUEST_OPEN_SESSION;
-                       msg.param1 = (unsigned long)handle;
-                       msg.error = (unsigned long)context; /* using error to context */
-                       msg.caller = (void *)this;
-                       msg.callback = (void *)callback;
-                       msg.userParam = userData;
-
-                       if (ClientIPC::getInstance().sendMessage(msg) == true)
-                       {
-                               result = SCARD_ERROR_OK;
-                       }
-                       else
-                       {
-                               _ERR("sendMessage failed");
-                               result = SCARD_ERROR_IPC_FAILED;
-                       }
-#endif
                }
                else
                {
@@ -298,80 +230,6 @@ namespace smartcard_service_api
 
                return result;
        }
-
-#ifndef USE_GDBUS
-       bool Reader::dispatcherCallback(void *message)
-       {
-               Message *msg = (Message *)message;
-               Reader *reader;
-               bool result = false;
-
-               _BEGIN();
-
-               if (msg == NULL)
-               {
-                       _ERR("message is null");
-                       return result;
-               }
-
-               reader = (Reader *)msg->caller;
-
-               switch (msg->message)
-               {
-               case Message::MSG_REQUEST_OPEN_SESSION :
-                       {
-                               Session *session = NULL;
-
-                               _INFO("MSG_REQUEST_OPEN_SESSION");
-
-                               if (msg->param1 != 0)
-                               {
-                                       /* create new instance of channel */
-                                       session = new Session(reader->context, reader, (void *)msg->param1);
-                                       if (session == NULL)
-                                       {
-                                               _ERR("Session creating instance failed");
-
-                                               return session;
-                                       }
-
-                                       reader->sessions.push_back(session);
-                               }
-
-                               if (msg->isSynchronousCall() == true) /* synchronized call */
-                               {
-                                       /* sync call */
-                                       reader->syncLock();
-
-                                       /* copy result */
-                                       reader->error = msg->error;
-                                       reader->openedSession = session;
-                                       reader->signalCondition();
-
-                                       reader->syncUnlock();
-                               }
-                               else if (msg->callback != NULL)
-                               {
-                                       openSessionCallback cb = (openSessionCallback)msg->callback;
-
-                                       /* async call */
-                                       cb(session, msg->error, msg->userParam);
-                               }
-                       }
-                       break;
-
-               default:
-                       _DBG("unknown [%s]", msg->toString().c_str());
-                       break;
-               }
-
-               delete msg;
-
-               _END();
-
-               return result;
-       }
-#endif
 } /* namespace smartcard_service_api */
 
 /* export C API */
@@ -437,11 +295,9 @@ EXTERN_API session_h reader_open_session_sync(reader_h handle)
 {
        session_h result = NULL;
 
-#ifdef CLIENT_IPC_THREAD
        READER_EXTERN_BEGIN;
        result = (session_h)reader->openSessionSync();
        READER_EXTERN_END;
-#endif
 
        return result;
 }
index 2d421e1..5475a7e 100644 (file)
 #include "Debug.h"
 #include "SEService.h"
 #include "Reader.h"
-#ifdef USE_GDBUS
 #include "ClientGDBus.h"
-#else
-#include "Message.h"
-#include "ClientIPC.h"
-#include "ClientDispatcher.h"
-#endif
 
 #ifndef EXTERN_API
 #define EXTERN_API __attribute__((visibility("default")))
@@ -45,9 +39,7 @@ namespace smartcard_service_api
        SEService::SEService() : SEServiceHelper(),
                handle(-1), context(NULL), handler(NULL), listener(NULL)
        {
-#ifdef USE_GDBUS
                proxy = NULL;
-#endif
        }
 
        SEService::SEService(void *user_data, serviceConnected handler)
@@ -104,7 +96,6 @@ namespace smartcard_service_api
                return new SEService(user_data, handler);
        }
 
-#ifdef USE_GDBUS
        void SEService::reader_inserted(GObject *source_object,
                guint reader_id, gchar *reader_name, gpointer user_data)
        {
@@ -225,7 +216,7 @@ namespace smartcard_service_api
                        }
                }
        }
-#endif
+
        void SEService::shutdown()
        {
                shutdownSync();
@@ -241,7 +232,7 @@ namespace smartcard_service_api
                        {
                                readers[i]->closeSessions();
                        }
-#ifdef USE_GDBUS
+
                        gint result;
                        GError *error = NULL;
 
@@ -260,62 +251,17 @@ namespace smartcard_service_api
                        usleep(SHUTDOWN_DELAY);
 
                        connected = false;
-#else
-#ifdef CLIENT_IPC_THREAD
-                       /* send message to load se */
-                       Message msg;
-
-                       msg.message = Message::MSG_REQUEST_SHUTDOWN;
-                       msg.param1 = (unsigned long)handle;
-                       msg.error = (unsigned long)this; /* using error to context */
-                       msg.caller = (void *)this;
-                       msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
-
-                       syncLock();
-                       if (ClientIPC::getInstance().sendMessage(msg) == true)
-                       {
-                               int rv;
-
-                               rv = waitTimedCondition(0);
-                               if (rv == 0)
-                               {
-                                       ClientDispatcher::getInstance().removeSEService(handle);
-
-                                       connected = false;
-                               }
-                               else
-                               {
-                                       _ERR("time over");
-                               }
-                       }
-                       else
-                       {
-                               _ERR("sendMessage failed");
-                       }
-                       syncUnlock();
-#endif
-#endif
                }
        }
 
        bool SEService::_initialize() throw(ErrorIO &)
        {
                bool result = false;
-#ifndef USE_GDBUS
-               ClientIPC *clientIPC;
-               ClientDispatcher *clientDispatcher;
-#endif
-               _BEGIN();
 
-               /* initialize client */
-               if (!g_thread_supported())
-               {
-                       g_thread_init(NULL);
-               }
+               _BEGIN();
 
                g_type_init();
 
-#ifdef USE_GDBUS
                /* init default context */
                GError *error = NULL;
 
@@ -343,40 +289,7 @@ namespace smartcard_service_api
                        NULL,
                        &SEService::se_service_cb,
                        this);
-#else
-               clientDispatcher = &ClientDispatcher::getInstance();
-               clientIPC = &ClientIPC::getInstance();
-
-               clientIPC->setDispatcher(clientDispatcher);
-
-#ifndef CLIENT_IPC_THREAD
-               if (clientDispatcher->runDispatcherThread() == false)
-               {
-                       _ERR("clientDispatcher->runDispatcherThread() failed");
-
-                       return result;
-               }
-#endif
-
-               if (clientIPC->createConnectSocket() == false)
-               {
-                       _ERR("clientIPC->createConnectSocket() failed");
 
-                       return result;
-               }
-
-               {
-                       /* send message to load se */
-                       Message msg;
-
-                       msg.message = Message::MSG_REQUEST_READERS;
-                       msg.error = getpid(); /* using error to pid */
-                       msg.caller = (void *)this;
-                       msg.userParam = context;
-
-                       result = clientIPC->sendMessage(msg);
-               }
-#endif
                _END();
 
                return result;
@@ -410,7 +323,6 @@ namespace smartcard_service_api
                return _initialize();
        }
 
-#ifdef USE_GDBUS
        bool SEService::parseReaderInformation(GVariant *variant)
        {
                Reader *reader = NULL;
@@ -440,7 +352,7 @@ namespace smartcard_service_api
 
                return true;
        }
-#endif
+
        bool SEService::parseReaderInformation(unsigned int count,
                const ByteArray &data)
        {
@@ -477,152 +389,6 @@ namespace smartcard_service_api
 
                return true;
        }
-
-#ifndef USE_GDBUS
-       bool SEService::dispatcherCallback(void *message)
-       {
-               Message *msg = (Message *)message;
-               SEService *service;
-               bool result = false;
-
-               _BEGIN();
-
-               if (msg == NULL)
-               {
-                       _ERR("message is null");
-                       return result;
-               }
-
-               service = (SEService *)msg->caller;
-
-               switch (msg->message)
-               {
-               case Message::MSG_REQUEST_READERS :
-                       _INFO("[MSG_REQUEST_READERS]");
-
-                       service->connected = true;
-                       service->handle = (unsigned int)msg->param2;
-
-                       ClientDispatcher::getInstance().addSEService(service->handle, service);
-
-                       /* parse message data */
-                       service->parseReaderInformation(msg->param1, msg->data);
-
-                       /* call callback function */
-                       if (service->listener != NULL)
-                       {
-                               service->listener->serviceConnected(service, service->context);
-                       }
-                       else if (service->handler != NULL)
-                       {
-                               service->handler(service, service->context);
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_SHUTDOWN :
-                       _INFO("[MSG_REQUEST_SHUTDOWN]");
-
-                       if (msg->isSynchronousCall() == true) /* synchronized call */
-                       {
-                               /* sync call */
-                               service->syncLock();
-
-                               /* copy result */
-//                             service->error = msg->error;
-                               service->signalCondition();
-                               service->syncUnlock();
-                       }
-                       else
-                       {
-                               /* Do nothing... */
-                       }
-                       break;
-
-               case Message::MSG_NOTIFY_SE_INSERTED :
-                       {
-                               Reader *reader = NULL;
-
-                               _INFO("[MSG_NOTIFY_SE_INSERTED]");
-
-                               /* add readers */
-                               reader = new Reader(service->context,
-                                       (char *)msg->data.getBuffer(), (void *)msg->param1);
-                               if (reader != NULL)
-                               {
-                                       service->readers.push_back(reader);
-                               }
-                               else
-                               {
-                                       _ERR("alloc failed");
-                               }
-
-                               if (service->listener != NULL)
-                               {
-                                       service->listener->eventHandler(service,
-                                               (char *)msg->data.getBuffer(), 1, service->context);
-                               }
-                               else
-                               {
-                                       _DBG("listener is null");
-                               }
-                       }
-                       break;
-
-               case Message::MSG_NOTIFY_SE_REMOVED :
-                       {
-                               size_t i;
-
-                               _INFO("[MSG_NOTIFY_SE_REMOVED]");
-
-                               for (i = 0; i < service->readers.size(); i++)
-                               {
-                                       if (((Reader *)service->readers[i])->handle == (void *)msg->param1)
-                                       {
-                                               ((Reader *)service->readers[i])->present = false;
-                                               break;
-                                       }
-                               }
-
-                               if (service->listener != NULL)
-                               {
-                                       service->listener->eventHandler(service,
-                                               (char *)msg->data.getBuffer(), 2, service->context);
-                               }
-                               else
-                               {
-                                       _DBG("listener is null");
-                               }
-                       }
-                       break;
-
-               case Message::MSG_OPERATION_RELEASE_CLIENT :
-                       _INFO("[MSG_OPERATION_RELEASE_CLIENT]");
-
-                       if (service->listener != NULL)
-                       {
-                               service->listener->errorHandler(service, msg->error, service->context);
-
-                               ClientDispatcher::getInstance().removeSEService(service->handle);
-                               service->connected = false;
-                       }
-                       else
-                       {
-                               _ERR("service->listener is null");
-                       }
-                       break;
-
-               default :
-                       _DBG("unknown message [%s]", msg->toString().c_str());
-                       break;
-               }
-
-               delete msg;
-
-               _END();
-
-               return result;
-       }
-#endif
 } /* namespace smartcard_service_api */
 
 /* export C API */
index e08abd1..88fb349 100644 (file)
 #include "Session.h"
 #include "Reader.h"
 #include "ClientChannel.h"
-#ifdef USE_GDBUS
 #include "ClientGDBus.h"
-#else
-#include "ClientIPC.h"
-#endif
 
 #ifndef EXTERN_API
 #define EXTERN_API __attribute__((visibility("default")))
@@ -54,15 +50,6 @@ namespace smartcard_service_api
                this->context = context;
                this->handle = handle;
 
-#ifdef USE_GDBUS
-               /* initialize client */
-               if (!g_thread_supported())
-               {
-                       g_thread_init(NULL);
-               }
-
-               g_type_init();
-
                /* init default context */
                GError *error = NULL;
 
@@ -77,7 +64,7 @@ namespace smartcard_service_api
                        g_error_free(error);
                        return;
                }
-#endif
+
                closed = false;
        }
 
@@ -104,7 +91,7 @@ namespace smartcard_service_api
                        channels[i]->closeSync();
                }
        }
-#ifdef USE_GDBUS
+
        void Session::session_get_atr_cb(GObject *source_object,
                GAsyncResult *res, gpointer user_data)
        {
@@ -251,7 +238,7 @@ namespace smartcard_service_api
 
                delete param;
        }
-#endif
+
        const ByteArray Session::getATRSync()
                throw (ExceptionBase &, ErrorIO &, ErrorSecurity &,
                        ErrorIllegalState &, ErrorIllegalParameter &)
@@ -262,7 +249,6 @@ namespace smartcard_service_api
                {
                        if (atr.isEmpty() == true)
                        {
-#ifdef USE_GDBUS
                                gint ret;
                                GVariant *var_atr = NULL;
                                GError *error = NULL;
@@ -287,40 +273,6 @@ namespace smartcard_service_api
 
                                        THROW_ERROR(SCARD_ERROR_IPC_FAILED);
                                }
-#else
-                               Message msg;
-                               int rv;
-#ifdef CLIENT_IPC_THREAD
-                               /* request channel handle from server */
-                               msg.message = Message::MSG_REQUEST_GET_ATR;
-                               msg.param1 = (unsigned long)handle;
-                               msg.error = (unsigned long)context; /* using error to context */
-                               msg.caller = (void *)this;
-                               msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
-
-                               syncLock();
-                               if (ClientIPC::getInstance().sendMessage(msg) == true)
-                               {
-                                       rv = waitTimedCondition(0);
-                                       if (rv != 0)
-                                       {
-                                               _ERR("time over");
-                                               this->error = SCARD_ERROR_OPERATION_TIMEOUT;
-                                       }
-                               }
-                               else
-                               {
-                                       _ERR("sendMessage failed");
-                                       this->error = SCARD_ERROR_IPC_FAILED;
-                               }
-                               syncUnlock();
-
-                               if (this->error != SCARD_ERROR_OK)
-                               {
-                                       ThrowError::throwError(this->error);
-                               }
-#endif
-#endif
                        }
 
                        result = atr;
@@ -342,7 +294,6 @@ namespace smartcard_service_api
                {
                        if (atr.isEmpty() == true)
                        {
-#ifdef USE_GDBUS
                                CallbackParam *param = new CallbackParam();
 
                                param->instance = this;
@@ -356,27 +307,6 @@ namespace smartcard_service_api
                                        &Session::session_get_atr_cb, param);
 
                                result = SCARD_ERROR_OK;
-#else
-                               Message msg;
-
-                               /* request channel handle from server */
-                               msg.message = Message::MSG_REQUEST_GET_ATR;
-                               msg.param1 = (unsigned long)handle;
-                               msg.error = (unsigned long)context; /* using error to context */
-                               msg.caller = (void *)this;
-                               msg.callback = (void *)callback;
-                               msg.userParam = userData;
-
-                               if (ClientIPC::getInstance().sendMessage(msg) == true)
-                               {
-                                       result = SCARD_ERROR_OK;
-                               }
-                               else
-                               {
-                                       _ERR("sendMessage failed");
-                                       result = SCARD_ERROR_IPC_FAILED;
-                               }
-#endif
                        }
                        else
                        {
@@ -404,7 +334,7 @@ namespace smartcard_service_api
                {
                        closed = true;
                        closeChannels();
-#ifdef USE_GDBUS
+
                        gint ret;
                        GError *error = NULL;
 
@@ -426,42 +356,6 @@ namespace smartcard_service_api
 
                                THROW_ERROR(SCARD_ERROR_IPC_FAILED);
                        }
-#else
-                       int rv;
-                       Message msg;
-
-#ifdef CLIENT_IPC_THREAD
-                       /* request channel handle from server */
-                       msg.message = Message::MSG_REQUEST_CLOSE_SESSION;
-                       msg.param1 = (unsigned long)handle;
-                       msg.error = (unsigned long)context; /* using error to context */
-                       msg.caller = (void *)this;
-                       msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
-
-                       syncLock();
-                       if (ClientIPC::getInstance().sendMessage(msg) == true)
-                       {
-                               rv = waitTimedCondition(0);
-
-                               if (rv != 0)
-                               {
-                                       _ERR("time over");
-                                       this->error = SCARD_ERROR_OPERATION_TIMEOUT;
-                               }
-                       }
-                       else
-                       {
-                               _ERR("sendMessage failed");
-                               this->error = SCARD_ERROR_IPC_FAILED;
-                       }
-                       syncUnlock();
-
-                       if (this->error != SCARD_ERROR_OK)
-                       {
-                               ThrowError::throwError(this->error);
-                       }
-#endif
-#endif
                }
        }
 
@@ -473,7 +367,7 @@ namespace smartcard_service_api
                {
                        closed = true;
                        closeChannels();
-#ifdef USE_GDBUS
+
                        CallbackParam *param = new CallbackParam();
 
                        param->instance = this;
@@ -485,22 +379,6 @@ namespace smartcard_service_api
                                GPOINTER_TO_UINT(context),
                                GPOINTER_TO_UINT(handle), NULL,
                                &Session::session_close_cb, param);
-#else
-                       Message msg;
-                       /* request channel handle from server */
-                       msg.message = Message::MSG_REQUEST_CLOSE_SESSION;
-                       msg.param1 = (unsigned long)handle;
-                       msg.error = (unsigned long)context; /* using error to context */
-                       msg.caller = (void *)this;
-                       msg.callback = (void *)callback;
-                       msg.userParam = userData;
-
-                       if (ClientIPC::getInstance().sendMessage(msg) == false)
-                       {
-                               _ERR("sendMessage failed");
-                               result = SCARD_ERROR_IPC_FAILED;
-                       }
-#endif
                }
 
                return result;
@@ -531,7 +409,6 @@ namespace smartcard_service_api
 
                if (getReader()->isSecureElementPresent() == true)
                {
-#ifdef USE_GDBUS
                        gint ret;
                        GVariant *var_aid = NULL, *var_response = NULL;
                        guint channel_id;
@@ -576,44 +453,6 @@ namespace smartcard_service_api
 
                                THROW_ERROR(SCARD_ERROR_IPC_FAILED);
                        }
-#else
-                       Message msg;
-                       int rv;
-
-#ifdef CLIENT_IPC_THREAD
-                       /* request channel handle from server */
-                       msg.message = Message::MSG_REQUEST_OPEN_CHANNEL;
-                       msg.param1 = id;
-                       msg.param2 = (unsigned long)handle;
-                       msg.data = aid;
-                       msg.error = (unsigned long)context; /* using error to context */
-                       msg.caller = (void *)this;
-                       msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
-
-                       syncLock();
-                       if (ClientIPC::getInstance().sendMessage(msg) == true)
-                       {
-                               rv = waitTimedCondition(0);
-                               if (rv != 0)
-                               {
-                                       _ERR("time over");
-                                       this->error = SCARD_ERROR_OPERATION_TIMEOUT;
-                               }
-
-                               channel = openedChannel;
-                       }
-                       else
-                       {
-                               _ERR("sendMessage failed");
-                               this->error = SCARD_ERROR_IPC_FAILED;
-                       }
-                       syncUnlock();
-#endif
-                       if (this->error != SCARD_ERROR_OK)
-                       {
-                               ThrowError::throwError(this->error);
-                       }
-#endif
                }
                else
                {
@@ -631,7 +470,6 @@ namespace smartcard_service_api
 
                if (getReader()->isSecureElementPresent() == true)
                {
-#ifdef USE_GDBUS
                        GVariant *var_aid;
 
                        CallbackParam *param = new CallbackParam();
@@ -650,29 +488,6 @@ namespace smartcard_service_api
                                &Session::session_open_channel_cb, param);
 
                        result = SCARD_ERROR_OK;
-#else
-                       Message msg;
-
-                       /* request channel handle from server */
-                       msg.message = Message::MSG_REQUEST_OPEN_CHANNEL;
-                       msg.param1 = id;
-                       msg.param2 = (unsigned long)handle;
-                       msg.data = aid;
-                       msg.error = (unsigned long)context; /* using error to context */
-                       msg.caller = (void *)this;
-                       msg.callback = (void *)callback;
-                       msg.userParam = userData;
-
-                       if (ClientIPC::getInstance().sendMessage(msg) == true)
-                       {
-                               result = SCARD_ERROR_OK;
-                       }
-                       else
-                       {
-                               _ERR("sendMessage failed");
-                               result = SCARD_ERROR_IPC_FAILED;
-                       }
-#endif
                }
                else
                {
@@ -740,156 +555,6 @@ namespace smartcard_service_api
 
                return openLogicalChannel(temp, callback, userData);
        }
-
-#ifndef USE_GDBUS
-       bool Session::dispatcherCallback(void *message)
-       {
-               Message *msg = (Message *)message;
-               Session *session;
-               bool result = false;
-
-               if (msg == NULL)
-               {
-                       _ERR("message is null");
-                       return result;
-               }
-
-               session = (Session *)msg->caller;
-
-               switch (msg->message)
-               {
-               case Message::MSG_REQUEST_OPEN_CHANNEL :
-                       {
-                               Channel *channel = NULL;
-
-                               _INFO("MSG_REQUEST_OPEN_CHANNEL");
-
-                               if (msg->param1 != 0)
-                               {
-                                       /* create new instance of channel */
-                                       channel = new ClientChannel(session->context,
-                                               session, msg->param2, msg->data, (void *)msg->param1);
-                                       if (channel != NULL)
-                                       {
-                                               session->channels.push_back(channel);
-                                       }
-                                       else
-                                       {
-                                               _ERR("alloc failed");
-
-                                               msg->error = SCARD_ERROR_OUT_OF_MEMORY;
-                                       }
-                               }
-
-                               if (msg->isSynchronousCall() == true) /* synchronized call */
-                               {
-                                       /* sync call */
-                                       session->syncLock();
-
-                                       /* copy result */
-                                       session->error = msg->error;
-                                       session->openedChannel = channel;
-
-                                       session->signalCondition();
-                                       session->syncUnlock();
-                               }
-                               else if (msg->callback != NULL)
-                               {
-                                       openChannelCallback cb = (openChannelCallback)msg->callback;
-
-                                       /* async call */
-                                       cb(channel, msg->error, msg->userParam);
-                               }
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_GET_ATR :
-                       {
-                               _INFO("MSG_REQUEST_GET_ATR");
-
-                               if (msg->isSynchronousCall() == true) /* synchronized call */
-                               {
-                                       /* sync call */
-                                       session->syncLock();
-
-                                       session->error = msg->error;
-                                       session->atr = msg->data;
-
-                                       session->signalCondition();
-                                       session->syncUnlock();
-                               }
-                               else if (msg->callback != NULL)
-                               {
-                                       getATRCallback cb = (getATRCallback)msg->callback;
-
-                                       /* async call */
-                                       cb(msg->data.getBuffer(),
-                                               msg->data.size(),
-                                               msg->error,
-                                               msg->userParam);
-                               }
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_CLOSE_SESSION :
-                       {
-                               _INFO("MSG_REQUEST_CLOSE_SESSION");
-
-                               if (msg->isSynchronousCall() == true) /* synchronized call */
-                               {
-                                       /* sync call */
-                                       session->syncLock();
-
-                                       session->error = msg->error;
-
-                                       session->signalCondition();
-                                       session->syncUnlock();
-                               }
-                               else if (msg->callback != NULL)
-                               {
-                                       closeSessionCallback cb = (closeSessionCallback)msg->callback;
-
-                                       /* async call */
-                                       cb(msg->error, msg->userParam);
-                               }
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_GET_CHANNEL_COUNT :
-                       {
-                               _INFO("MSG_REQUEST_GET_CHANNEL_COUNT");
-
-                               if (msg->isSynchronousCall() == true) /* synchronized call */
-                               {
-                                       /* sync call */
-                                       session->syncLock();
-
-                                       session->error = msg->error;
-                                       session->channelCount = msg->param1;
-
-                                       session->signalCondition();
-                                       session->syncUnlock();
-                               }
-                               else if (msg->callback != NULL)
-                               {
-                                       getChannelCountCallback cb = (getChannelCountCallback)msg->callback;
-
-                                       /* async call */
-                                       cb(msg->param1, msg->error, msg->userParam);
-                               }
-                       }
-                       break;
-
-               default :
-                       _DBG("unknown message : %s", msg->toString().c_str());
-                       break;
-               }
-
-               delete msg;
-
-               return result;
-       }
-#endif
 } /* namespace smartcard_service_api */
 
 /* export C API */
@@ -991,7 +656,6 @@ EXTERN_API int session_get_atr_sync(session_h handle, unsigned char **buffer, un
        ByteArray temp;
        int result = -1;
 
-#ifdef CLIENT_IPC_THREAD
        if (buffer == NULL || length == NULL)
                return result;
 
@@ -1005,30 +669,25 @@ EXTERN_API int session_get_atr_sync(session_h handle, unsigned char **buffer, un
 
                        result = 0;
                }
-               SESSION_EXTERN_END;
-#endif
+       SESSION_EXTERN_END;
 
        return result;
 }
 
 EXTERN_API void session_close_sync(session_h handle)
 {
-#ifdef CLIENT_IPC_THREAD
        SESSION_EXTERN_BEGIN;
                session->closeSync();
        SESSION_EXTERN_END;
-#endif
 }
 
 EXTERN_API channel_h session_open_basic_channel_sync(session_h handle, unsigned char *aid, unsigned int length)
 {
        channel_h result = NULL;
 
-#ifdef CLIENT_IPC_THREAD
        SESSION_EXTERN_BEGIN;
                result = session->openBasicChannelSync(aid, length);
        SESSION_EXTERN_END;
-#endif
 
        return result;
 }
@@ -1037,11 +696,9 @@ EXTERN_API channel_h session_open_logical_channel_sync(session_h handle, unsigne
 {
        channel_h result = NULL;
 
-#ifdef CLIENT_IPC_THREAD
        SESSION_EXTERN_BEGIN;
                result = session->openLogicalChannelSync(aid, length);
        SESSION_EXTERN_END;
-#endif
 
        return result;
 }
@@ -1050,11 +707,9 @@ EXTERN_API size_t session_get_channel_count(session_h handle)
 {
        size_t result = 0;
 
-#ifdef CLIENT_IPC_THREAD
        SESSION_EXTERN_BEGIN;
                result = session->getChannelCount();
        SESSION_EXTERN_END;
-#endif
 
        return result;
 }
index f8c6676..1cc607e 100644 (file)
@@ -18,9 +18,8 @@
 #define CLIENTCHANNEL_H_
 
 /* standard library header */
-#ifdef USE_GDBUS
 #include <gio/gio.h>
-#endif
+
 /* SLP library header */
 
 /* local header */
@@ -38,29 +37,21 @@ namespace smartcard_service_api
        private:
                void *context;
                void *handle;
-#ifdef USE_GDBUS
                void *proxy;
-#else
-               /* temporary data for sync function */
-               int error;
-               ByteArray response;
-#endif
+
                ClientChannel(void *context, Session *session, int channelNum,
                        const ByteArray &selectResponse, void *handle);
                ~ClientChannel();
 
-#ifdef USE_GDBUS
                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);
-#else
-               static bool dispatcherCallback(void *message);
-#endif
+
        public:
                int close(closeChannelCallback callback, void *userParam);
-               int transmit(const ByteArray &command, transmitCallback callback,
-                       void *userParam);
+               int transmit(const ByteArray &command,
+                       transmitCallback callback, void *userParam);
 
                void closeSync()
                        throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
@@ -69,9 +60,6 @@ namespace smartcard_service_api
                        throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
                                ErrorIllegalParameter &, ErrorSecurity &);
 
-#ifndef USE_GDBUS
-               friend class ClientDispatcher;
-#endif
                friend class Session;
        };
 } /* namespace smartcard_service_api */
@@ -90,7 +78,7 @@ unsigned int channel_get_select_response_length(channel_h handle);
 bool channel_get_select_response(channel_h handle, unsigned char *buffer,
        unsigned int length);
 session_h channel_get_session(channel_h handle);
-void channel_destroy_instance(channel_h handle) __attribute__((deprecated)) ;
+void channel_destroy_instance(channel_h handle) __attribute__((deprecated));
 
 int channel_close(channel_h handle, channel_close_cb callback, void *userParam);
 int channel_transmit(channel_h handle, unsigned char *command,
diff --git a/client/include/ClientDispatcher.h b/client/include/ClientDispatcher.h
deleted file mode 100644 (file)
index 719cfeb..0000000
+++ /dev/null
@@ -1,53 +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 CLIENTDISPATCHER_H_
-#define CLIENTDISPATCHER_H_
-#ifndef USE_GDBUS
-/* standard library header */
-#include <map>
-
-/* SLP library header */
-
-/* local header */
-#include "DispatcherHelper.h"
-
-using namespace std;
-
-namespace smartcard_service_api
-{
-       class SEService;
-
-       class ClientDispatcher: public DispatcherHelper
-       {
-       private:
-               map<unsigned int, SEService *> mapSESerivces;
-
-               ClientDispatcher();
-               ~ClientDispatcher();
-
-               void *dispatcherThreadFunc(DispatcherMsg *msg, void *data);
-
-       public:
-               static ClientDispatcher &getInstance();
-
-               bool addSEService(unsigned int handle, SEService *service);
-               void removeSEService(unsigned int handle);
-       };
-
-} /* namespace open_mobile_api */
-#endif /* USE_GDBUS */
-#endif /* CLIENTDISPATCHER_H_ */
index 5f71d61..c111874 100644 (file)
@@ -17,7 +17,6 @@
 #ifndef CLIENTGDBUS_H_
 #define CLIENTGDBUS_H_
 
-#ifdef USE_GDBUS
 /* standard library header */
 #include <glib.h>
 
@@ -33,5 +32,5 @@ namespace smartcard_service_api
        {
        };
 } /* namespace smartcard_service_api */
-#endif
+
 #endif /* CLIENTGDBUS_H_ */
diff --git a/client/include/ClientIPC.h b/client/include/ClientIPC.h
deleted file mode 100644 (file)
index 76f6c21..0000000
+++ /dev/null
@@ -1,59 +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 CLIENTIPC_H_
-#define CLIENTIPC_H_
-#ifndef USE_GDBUS
-/* standard library header */
-#ifdef USE_AUTOSTART
-#include <dbus/dbus-glib.h>
-#endif
-
-/* SLP library header */
-
-/* local header */
-#include "IPCHelper.h"
-#include "SEServiceListener.h"
-#ifdef USE_AUTOSTART
-#include "smartcard-service-glue.h"
-#endif
-
-namespace smartcard_service_api
-{
-       class ClientIPC: public IPCHelper
-       {
-       private:
-#ifdef SECURITY_SERVER
-               ByteArray cookie;
-#endif
-               ClientIPC();
-               ~ClientIPC();
-
-#ifdef USE_AUTOSTART
-               void _launch_daemon();
-#endif
-               int handleIOErrorCondition(void *channel, GIOCondition condition);
-               int handleInvalidSocketCondition(void *channel, GIOCondition condition);
-               int handleIncomingCondition(void *channel, GIOCondition condition);
-
-       public:
-               static ClientIPC &getInstance();
-               bool sendMessage(const Message &msg);
-       };
-
-} /* namespace open_mobile_api */
-#endif /* USE_GDBUS */
-#endif /* CLIENTIPC_H_ */
index 08ea874..8b22f71 100644 (file)
 #define READER_H_
 
 /* standard library header */
-#ifdef USE_GDBUS
 #include <glib.h>
 #include <gio/gio.h>
-#endif
 
 /* SLP library header */
 
@@ -40,24 +38,14 @@ namespace smartcard_service_api
        private:
                void *context;
                void *handle;
-#ifdef USE_GDBUS
                void *proxy;
-#else
-               /* temporary data for sync function */
-               int error;
-               Session *openedSession;
-#endif
 
                Reader(void *context, const char *name, void *handle);
                ~Reader();
 
                inline void unavailable() { present = false; }
-#ifdef USE_GDBUS
                static void reader_open_session_cb(GObject *source_object,
                        GAsyncResult *res, gpointer user_data);
-#else
-               static bool dispatcherCallback(void *message);
-#endif
 
        public:
                void closeSessions()
@@ -69,9 +57,6 @@ namespace smartcard_service_api
                                ErrorIllegalParameter &, ErrorSecurity &);
 
                friend class SEService;
-#ifndef USE_GDBUS
-               friend class ClientDispatcher;
-#endif
        };
 } /* namespace smartcard_service_api */
 #endif /* __cplusplus */
index 85ac371..d464184 100644 (file)
 #define SESERVICE_H_
 
 /* standard library header */
-#ifdef USE_GDBUS
 #include <glib.h>
 #include <gio/gio.h>
-#endif
 
 /* SLP library header */
 
@@ -46,18 +44,12 @@ namespace smartcard_service_api
                void *context;
                serviceConnected handler;
                SEServiceListener *listener;
-#ifdef USE_GDBUS
                void *proxy;
-#endif
                SEService();
 
                void addReader(unsigned int handle, const char *name);
                bool parseReaderInformation(unsigned int count, const ByteArray &data);
-#ifdef USE_GDBUS
                bool parseReaderInformation(GVariant *variant);
-#else
-               static bool dispatcherCallback(void *message);
-#endif
 
                bool _initialize()
                        throw(ErrorIO &);
@@ -68,7 +60,6 @@ namespace smartcard_service_api
                SEService *initializeSync(void *context, serviceConnected handler)
                        throw(ErrorIO &, ErrorIllegalParameter &);
 
-#ifdef USE_GDBUS
                static void reader_inserted(GObject *source_object,
                        guint reader_id, gchar *reader_name,
                        gpointer user_data);
@@ -79,7 +70,7 @@ namespace smartcard_service_api
                        GAsyncResult *res, gpointer user_data);
                static void se_service_cb(GObject *source_object,
                        GAsyncResult *res, gpointer user_data);
-#endif
+
        public:
                SEService(void *user_data, serviceConnected handler)
                        throw(ErrorIO &, ErrorIllegalParameter &);
@@ -94,10 +85,6 @@ namespace smartcard_service_api
 
                void shutdown();
                void shutdownSync();
-
-#ifndef USE_GDBUS
-               friend class ClientDispatcher;
-#endif
        };
 } /* namespace smartcard_service_api */
 #endif /* __cplusplus */
@@ -108,9 +95,11 @@ 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(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_connected_cb connected, se_service_event_cb event,
+       se_sesrvice_error_cb error);
 int se_service_get_readers_count(se_service_h handle);
 bool se_service_get_readers(se_service_h handle, reader_h *readers, int *count);
 bool se_service_is_connected(se_service_h handle);
index 69df451..04945a1 100644 (file)
@@ -18,9 +18,7 @@
 #define SESSION_H_
 
 /* standard library header */
-#ifdef USE_GDBUS
 #include <gio/gio.h>
-#endif
 
 /* SLP library header */
 
@@ -40,14 +38,8 @@ namespace smartcard_service_api
        private:
                void *context;
                void *handle;
-#ifdef USE_GDBUS
                void *proxy;
-#else
-               /* temporary data for sync function */
-               int error;
-               Channel *openedChannel;
-               unsigned int channelCount;
-#endif
+
                Session(void *context, Reader *reader, void *handle);
                ~Session();
 
@@ -55,16 +47,13 @@ namespace smartcard_service_api
                Channel *openChannelSync(int id, const ByteArray &aid)
                        throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
                                ErrorIllegalParameter &, ErrorSecurity &);
-#ifdef USE_GDBUS
+
                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);
-#else
-               static bool dispatcherCallback(void *message);
-#endif
 
        public:
                void closeChannels()
@@ -104,9 +93,6 @@ namespace smartcard_service_api
 
                size_t getChannelCount() const;
 
-#ifndef USE_GDBUS
-               friend class ClientDispatcher;
-#endif
                friend class Reader;
        };
 } /* namespace smartcard_service_api */
@@ -123,19 +109,24 @@ bool session_is_closed(session_h handle);
 __attribute__((deprecated)) void session_destroy_instance(session_h handle);
 void session_close_channels(session_h 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_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);
 
-int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length);
+int session_get_atr_sync(session_h handle, unsigned char **buffer,
+       unsigned int *length);
 void session_close_sync(session_h handle);
 
-channel_h session_open_basic_channel_sync(session_h handle, unsigned char *aid, unsigned int length);
-channel_h session_open_logical_channel_sync(session_h handle, unsigned char *aid, unsigned int length);
+channel_h session_open_basic_channel_sync(session_h handle,
+       unsigned char *aid, unsigned int length);
+channel_h session_open_logical_channel_sync(session_h handle,
+       unsigned char *aid, unsigned int length);
 
 size_t session_get_channel_count(session_h handle);
 
diff --git a/common/DispatcherHelper.cpp b/common/DispatcherHelper.cpp
deleted file mode 100644 (file)
index 208b2e2..0000000
+++ /dev/null
@@ -1,148 +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 USE_GDBUS
-/* standard library header */
-#include <stdio.h>
-#include <string.h>
-
-/* SLP library header */
-
-/* local header */
-#include "Debug.h"
-#include "DispatcherHelper.h"
-
-namespace smartcard_service_api
-{
-       DispatcherHelper::DispatcherHelper()
-       {
-               dispatcherThread = 0;
-       }
-
-       DispatcherHelper::~DispatcherHelper()
-       {
-               stopDispatcherThread();
-       }
-
-       DispatcherMsg *DispatcherHelper::fetchMessage()
-       {
-               DispatcherMsg *result = NULL;
-
-               if (messageQ.size() > 0)
-               {
-                       result = messageQ.front();
-                       messageQ.pop();
-               }
-
-               return result;
-       }
-
-       void DispatcherHelper::clearQueue()
-       {
-               DispatcherMsg *temp = NULL;
-
-               while (messageQ.size() > 0)
-               {
-                       temp = fetchMessage();
-                       delete temp;
-               }
-       }
-
-       void DispatcherHelper::pushMessage(const DispatcherMsg &msg)
-       {
-               DispatcherMsg *pushMsg = new DispatcherMsg(msg);
-
-               syncLock();
-
-               messageQ.push(pushMsg);
-
-               signalCondition();
-               syncUnlock();
-       }
-
-       void *DispatcherHelper::_dispatcherThreadFunc(void *data)
-       {
-               int result = 0;
-               DispatcherMsg *msg = NULL;
-               DispatcherHelper *helper = (DispatcherHelper *)data;
-
-               while (1)
-               {
-                       helper->syncLock();
-                       if ((msg = helper->fetchMessage()) == NULL)
-                       {
-                               result = helper->waitTimedCondition(0);
-                               helper->syncUnlock();
-                               continue;
-                       }
-                       helper->syncUnlock();
-
-                       /* process message */
-                       helper->dispatcherThreadFunc(msg, data);
-
-                       delete msg;
-               }
-
-               return (void *)NULL;
-       }
-
-       void DispatcherHelper::processMessage(DispatcherMsg *msg)
-       {
-               dispatcherThreadFunc(msg, this);
-       }
-
-       bool DispatcherHelper::runDispatcherThread()
-       {
-               bool result = false;
-               pthread_attr_t attr;
-
-               if (dispatcherThread == 0)
-               {
-                       int ret;
-
-                       pthread_attr_init(&attr);
-                       pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-
-                       if ((ret = pthread_create(&dispatcherThread, &attr, &DispatcherHelper::_dispatcherThreadFunc, this)) != 0)
-                       {
-                               _ERR("pthread_create failed [%d]", ret);
-                       }
-                       else
-                       {
-                               _DBG("pthread_create success");
-                               result = true;
-                       }
-               }
-               else
-               {
-                       _DBG("thread already start");
-                       result = true;
-               }
-
-               return result;
-       }
-
-       void DispatcherHelper::stopDispatcherThread()
-       {
-               if (dispatcherThread != 0)
-               {
-                       pthread_cancel(dispatcherThread);
-                       dispatcherThread = 0;
-               }
-       }
-
-} /* namespace smartcard_service_api */
-#endif
index 0422100..04eefc9 100644 (file)
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#ifdef USE_GDBUS
 #include "GDBusHelper.h"
 
 namespace smartcard_service_api
@@ -58,4 +57,3 @@ namespace smartcard_service_api
                return g_variant_builder_end(&builder);
        }
 } /* namespace smartcard_service_api */
-#endif
diff --git a/common/IPCHelper.cpp b/common/IPCHelper.cpp
deleted file mode 100644 (file)
index 4f8a363..0000000
+++ /dev/null
@@ -1,683 +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 USE_GDBUS
-/* standard library header */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/socket.h>
-#ifdef USE_UNIX_DOMAIN
-#include <sys/un.h>
-#include <sys/stat.h>
-#else /* USE_UNIX_DOMAIN */
-#include <netinet/in.h>
-#endif /* USE_UNIX_DOMAIN */
-#include <fcntl.h>
-#ifdef USE_IPC_EPOLL
-#include <sys/epoll.h>
-#endif
-
-/* SLP library header */
-
-/* local header */
-#include "Debug.h"
-#include "IPCHelper.h"
-
-#ifdef USE_UNIX_DOMAIN
-#define SCARD_SERVER_DOMAIN "/tmp/smartcard-server-domain"
-#endif /* USE_UNIX_DOMAIN */
-
-static void setNonBlockSocket(int socket)
-{
-       int flags;
-
-       flags = fcntl(socket, F_GETFL);
-
-       flags |= O_NONBLOCK;
-
-       if (fcntl(socket, F_SETFL, flags) < 0)
-       {
-               /* _ERR("fcntl, executing nonblock error"); */
-       }
-}
-
-namespace smartcard_service_api
-{
-       IPCHelper::IPCHelper() : fdPoll(-1)
-       {
-               ipcSocket = -1;
-               ioChannel = NULL;
-               watchId = 0;
-               memset(&ipcLock, 0, sizeof(ipcLock));
-               dispatcher = NULL;
-               pollEvents = NULL;
-               readThread = 0;
-       }
-
-       IPCHelper::~IPCHelper()
-       {
-       }
-
-       gboolean IPCHelper::channelCallbackFunc(GIOChannel* channel, GIOCondition condition, gpointer data)
-       {
-               IPCHelper *helper = (IPCHelper *)data;
-               gboolean result = FALSE;
-
-               _DBG("channel [%p], condition [%d], data [%p]", channel, condition, data);
-
-               if (helper == NULL)
-               {
-                       _ERR("ipchelper is null");
-                       return result;
-               }
-
-               if ((G_IO_ERR & condition) || (G_IO_HUP & condition))
-               {
-                       result = helper->handleIOErrorCondition(channel, condition);
-               }
-               else if (G_IO_NVAL & condition)
-               {
-                       result = helper->handleInvalidSocketCondition(channel, condition);
-               }
-               else if (G_IO_IN & condition)
-               {
-                       result = helper->handleIncomingCondition(channel, condition);
-               }
-
-               return result;
-       }
-
-       bool IPCHelper::createListenSocket()
-       {
-               GIOCondition condition = (GIOCondition)(G_IO_ERR | G_IO_HUP | G_IO_IN);
-               struct sockaddr_un saddrun_rv;
-
-               if (ipcSocket >= 0)
-                       return true;
-
-               memset(&saddrun_rv, 0, sizeof(struct sockaddr_un));
-
-               unlink(SCARD_SERVER_DOMAIN);
-
-               ipcSocket = socket(AF_UNIX, SOCK_STREAM, 0);
-               if (ipcSocket == -1)
-               {
-                       _ERR("get socket is failed");
-                       return false;
-               }
-
-               ::setNonBlockSocket(ipcSocket);
-
-               saddrun_rv.sun_family = AF_UNIX;
-               strncpy(saddrun_rv.sun_path, SCARD_SERVER_DOMAIN, sizeof(saddrun_rv.sun_path) - 1);
-
-               if (bind(ipcSocket, (struct sockaddr *)&saddrun_rv, sizeof(saddrun_rv)) < 0)
-               {
-                       _ERR("bind is failed");
-                       goto ERROR;
-               }
-
-               if (chmod(SCARD_SERVER_DOMAIN, 0777) < 0)
-               {
-                       _ERR("can not change permission of UNIX DOMAIN file");
-                       goto ERROR;
-               }
-
-               if (listen(ipcSocket, IPC_SERVER_MAX_CLIENT) < 0)
-               {
-                       _ERR("listen is failed");
-                       goto ERROR;
-               }
-
-               if ((ioChannel = g_io_channel_unix_new(ipcSocket)) != NULL)
-               {
-                       if ((watchId = g_io_add_watch(ioChannel, condition, &IPCHelper::channelCallbackFunc, this)) < 1)
-                       {
-                               _ERR(" g_io_add_watch is failed");
-                               goto ERROR;
-                       }
-               }
-               else
-               {
-                       _ERR(" g_io_channel_unix_new is failed");
-                       goto ERROR;
-               }
-
-#ifdef SECURITY_SERVER
-               int gid, cookies_size;
-               char *cookies;
-
-               gid = security_server_get_gid("smartcard-service");
-               if(gid == 0)
-               {
-                       _DBG("get gid from security server is failed. this object is not allowed by security server");
-                       goto ERROR;
-               }
-
-               if((cookies_size = security_server_get_cookie_size()) != 0)
-               {
-                       if((cookies = (char *)calloc(1, cookies_size)) == NULL)
-                       {
-                               goto ERROR;
-                       }
-               }
-#endif
-
-               _INFO("server ipc is initialized");
-
-               return true;
-ERROR :
-               _ERR("error while initializing server ipc");
-
-               destroyListenSocket();
-
-               return false;
-       }
-
-#ifdef CLIENT_IPC_THREAD
-       int IPCHelper::eventPoll()
-       {
-               int result = -1;
-
-#ifdef USE_IPC_EPOLL
-               int events = 0;
-
-               if ((events = epoll_wait(fdPoll, pollEvents, EPOLL_SIZE, -1)) > 0)
-               {
-                       int i;
-
-                       for (i = 0; i < events; i++)
-                       {
-                               _DBG("pollEvents[%d].events [%X]", i, pollEvents[i].events);
-
-                               if ((pollEvents[i].events & EPOLLHUP) || (pollEvents[i].events & EPOLLERR))
-                               {
-                                       _ERR("connection is closed");
-                                       result = 0;
-                                       break;
-                               }
-                               else if (pollEvents[i].events & EPOLLIN)
-                               {
-                                       result = 1;
-                                       break;
-                               }
-                       }
-               }
-               else if (errno == EINTR)
-               {
-                       _ERR("epoll_wait interrupted");
-               }
-               else
-               {
-                       char buffer[1024];
-
-                       _ERR("epoll_wait failed, errno [%d], %s", errno, strerror_r(errno, buffer, sizeof(buffer)));
-               }
-#else
-               if (select(ipcSocket + 1, &fdSetRead, NULL, NULL, NULL) > 0)
-               {
-                       if (FD_ISSET(ipcSocket, &fdSetRead) == true)
-                       {
-                               int val = -1;
-                               unsigned int size = sizeof(val);
-
-                               if (getsockopt(ipcSocket, SOL_SOCKET, SO_ERROR, (void *)&val, &size) == 0)
-                               {
-                                       if (val == 0)
-                                       {
-                                               _DBG("socket is readable");
-                                               result = 1;
-                                       }
-                                       else
-                                       {
-                                               _DBG("socket is not available. maybe disconnected");
-                                               result = 0;
-                                       }
-                               }
-                               else
-                               {
-                                       _ERR("getsockopt failed, errno [%d]", errno);
-                                       result = errno;
-                               }
-                       }
-                       else
-                       {
-                               _ERR("FD_ISSET false!!! what's wrong");
-                               result = -1;
-                       }
-               }
-               else
-               {
-                       _ERR("select failed [%d]", errno);
-                       result = errno;
-               }
-#endif
-               return result;
-       }
-
-       void *IPCHelper::threadRead(void *data)
-       {
-#ifdef IPC_USE_SIGTERM
-
-               struct sigaction act;
-               act.sa_handler = thread_sig_handler;
-               sigaction(SIGTERM, &act, NULL);
-
-               sigset_t newmask;
-               sigemptyset(&newmask);
-               sigaddset(&newmask, SIGTERM);
-               pthread_sigmask(SIG_UNBLOCK, &newmask, NULL);
-               _DBG("sighandler is registered");
-
-               pthread_mutex_lock(&g_client_lock);
-               pthread_cond_signal ((pthread_cond_t *) data);
-               pthread_mutex_unlock(&g_client_lock);
-#else
-               IPCHelper *helper = (IPCHelper *)data;
-#endif
-               bool condition = true;
-               int result = 0;
-
-               pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
-
-               while (condition == true)
-               {
-                       if ((result = helper->eventPoll()) > 0)
-                       {
-                               condition = (helper->handleIncomingCondition(NULL, G_IO_IN) == 0);
-                       }
-                       else if (result == 0)
-                       {
-                               helper->handleIOErrorCondition(NULL, G_IO_ERR);
-                               condition = false;
-                       }
-                       else
-                       {
-                               /* skip other error case */
-                       }
-               }
-
-               _INFO("threadRead is terminated");
-
-               return (void *)NULL;
-       }
-#endif
-
-       bool IPCHelper::createConnectSocket()
-       {
-#ifndef CLIENT_IPC_THREAD
-               GIOCondition condition = (GIOCondition)(G_IO_ERR | G_IO_HUP | G_IO_IN);
-#endif
-               int result = 0;
-               char err[200] = { 0, };
-
-               _BEGIN();
-
-               if (ipcSocket >= 0)
-                       return true;
-
-               pthread_mutex_lock(&ipcLock);
-
-               struct sockaddr_un saddrun_rv;
-               socklen_t len_saddr = 0;
-
-               memset(&saddrun_rv, 0, sizeof(struct sockaddr_un));
-
-               ipcSocket = socket(AF_UNIX, SOCK_STREAM, 0);
-               if (ipcSocket == -1)
-               {
-                       _ERR("get socket is failed [%d, %s]",
-                               errno, strerror_r(errno, err, sizeof(err)));
-                       goto ERROR;
-               }
-
-               _DBG("socket is created");
-
-               ::setNonBlockSocket(ipcSocket);
-
-               saddrun_rv.sun_family = AF_UNIX;
-               strncpy(saddrun_rv.sun_path, SCARD_SERVER_DOMAIN, sizeof(saddrun_rv.sun_path) - 1);
-
-               len_saddr = sizeof(saddrun_rv.sun_family) + strlen(SCARD_SERVER_DOMAIN);
-
-               if ((result = connect(ipcSocket, (struct sockaddr *)&saddrun_rv, len_saddr)) < 0)
-               {
-                       _ERR("connect failed [%d, %s]",
-                               errno, strerror_r(errno, err, sizeof(err)));
-                       goto ERROR;
-               }
-
-#ifdef CLIENT_IPC_THREAD
-#ifdef USE_IPC_EPOLL
-               if((fdPoll = epoll_create1(EPOLL_CLOEXEC)) == -1)
-               {
-                       _ERR("epoll_create1 failed [%d, %s]",
-                               errno, strerror_r(errno, err, sizeof(err)));
-                       goto ERROR;
-               }
-
-               pollEvents = (struct epoll_event *)calloc(EPOLL_SIZE, sizeof(struct epoll_event));
-               if (pollEvents == NULL)
-               {
-                       _ERR("alloc failed");
-                       goto ERROR;
-               }
-
-               struct epoll_event ev;
-
-               ev.events = EPOLLIN | EPOLLHUP | EPOLLERR;
-               ev.data.fd = ipcSocket;
-
-               epoll_ctl(fdPoll, EPOLL_CTL_ADD, ipcSocket, &ev);
-#else
-               FD_ZERO(&fdSetRead);
-               FD_SET(ipcSocket, &fdSetRead);
-#endif
-#ifdef IPC_USE_SIGTERM
-               pthread_cond_t pcond = PTHREAD_COND_INITIALIZER;
-
-               if (pthread_create(&readThread, NULL, &IPCHelper::threadRead, &pcond) != 0)
-#else
-               if (pthread_create(&readThread, NULL, &IPCHelper::threadRead, this) != 0)
-#endif
-               {
-                       _ERR("pthread_create is failed");
-                       goto ERROR;
-               }
-
-#ifdef IPC_USE_SIGTERM
-               pthread_cond_wait (&pcond, &g_client_lock);
-#endif
-
-#else
-               if ((ioChannel = g_io_channel_unix_new(ipcSocket)) != NULL)
-               {
-                       if ((watchId = g_io_add_watch(ioChannel, condition, &IPCHelper::channelCallbackFunc, this)) < 1)
-                       {
-                               _ERR(" g_io_add_watch is failed");
-                               goto ERROR;
-                       }
-               }
-               else
-               {
-                       _ERR(" g_io_channel_unix_new is failed");
-                       goto ERROR;
-               }
-#endif
-               pthread_mutex_unlock(&ipcLock);
-
-               _INFO("connecting success");
-
-               _END();
-
-               return true;
-
-ERROR :
-               _ERR("error while initializing client ipc");
-
-               destroyConnectSocket();
-
-               pthread_mutex_unlock(&ipcLock);
-
-               _END();
-
-               return false;
-       }
-
-       void IPCHelper::destroyListenSocket()
-       {
-               if (watchId != (uint32_t)-1)
-               {
-                       g_source_remove(watchId);
-                       watchId = -1;
-               }
-
-               if (ioChannel != NULL)
-               {
-                       g_io_channel_unref(ioChannel);
-                       ioChannel = NULL;
-               }
-
-               if (ipcSocket != -1)
-               {
-                       shutdown(ipcSocket, SHUT_RDWR);
-                       close(ipcSocket);
-
-                       ipcSocket = -1;
-               }
-       }
-
-       void IPCHelper::destroyConnectSocket()
-       {
-#ifdef CLIENT_IPC_THREAD
-               /* kill thread */
-               if (readThread > 0)
-               {
-                       pthread_cancel(readThread);
-                       readThread = 0;
-               }
-#ifdef USE_IPC_EPOLL
-               if(fdPoll != -1)
-               {
-                       struct epoll_event ev;
-
-                       ev.events = EPOLLIN | EPOLLHUP | EPOLLERR;
-                       ev.data.fd = ipcSocket;
-                       epoll_ctl(fdPoll, EPOLL_CTL_DEL, ipcSocket, &ev);
-
-                       close(fdPoll);
-                       fdPoll = -1;
-
-                       if (pollEvents != NULL)
-                       {
-                               free(pollEvents);
-                       }
-               }
-#else
-               if (ipcSocket != -1)
-               {
-                       FD_CLR(ipcSocket, &fdSetRead);
-               }
-#endif
-#else
-               if(watchId != 0)
-               {
-                       g_source_remove(watchId);
-                       watchId = 0;
-               }
-
-               if(ioChannel != NULL)
-               {
-                       g_io_channel_unref(ioChannel);
-                       ioChannel = NULL;
-               }
-#endif
-
-               if (ipcSocket != -1)
-               {
-                       shutdown(ipcSocket, SHUT_RDWR);
-                       close(ipcSocket);
-                       ipcSocket = -1;
-               }
-       }
-
-       bool IPCHelper::sendMessage(int socket, const Message &msg)
-       {
-               ByteArray stream;
-               unsigned int length = 0;
-
-               stream = msg.serialize();
-               length = stream.size();
-
-               _DBG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]",
-                       socket, msg.message, stream.size());
-
-               return sendMessage(socket, stream);
-       }
-
-       bool IPCHelper::sendMessage(int socket, const ByteArray &buffer)
-       {
-               bool result = false;
-               unsigned int length = 0;
-
-               length = buffer.size();
-
-               if (length > 0)
-               {
-                       int sentBytes = 0;
-
-                       /* send 4 bytes (length) */
-                       pthread_mutex_lock(&ipcLock);
-                       sentBytes = send(socket, &length, sizeof(length), 0);
-                       pthread_mutex_unlock(&ipcLock);
-                       if (sentBytes == sizeof(length))
-                       {
-                               unsigned int current = 0;
-
-                               /* send message */
-                               pthread_mutex_lock(&ipcLock);
-                               do
-                               {
-                                       sentBytes = send(socket, buffer.getBuffer(current), length - current, 0);
-                                       if (sentBytes > 0)
-                                               current += sentBytes;
-                               }
-                               while (current < length);
-                               pthread_mutex_unlock(&ipcLock);
-
-                               result = true;
-                       }
-                       else
-                       {
-                               _ERR("send failed, sentBytes [%d]", sentBytes);
-                       }
-               }
-               else
-               {
-                       _ERR("stream length is zero");
-               }
-
-               return result;
-       }
-
-       Message *IPCHelper::retrieveMessage()
-       {
-               return retrieveMessage(ipcSocket);
-       }
-
-       Message *IPCHelper::retrieveMessage(int socket)
-       {
-               ByteArray buffer;
-               Message *msg = NULL;
-
-               _BEGIN();
-
-               buffer = retrieveBuffer(socket);
-               if (buffer.size() > 0)
-               {
-                       msg = new Message();
-                       if (msg != NULL)
-                       {
-                               msg->deserialize(buffer);
-                       }
-                       else
-                       {
-                               _ERR("alloc failed");
-                       }
-               }
-               else
-               {
-                       _ERR("retrieveBuffer failed ");
-               }
-
-               _END();
-
-               return msg;
-       }
-
-       const ByteArray IPCHelper::retrieveBuffer(int socket)
-       {
-               ByteArray buffer;
-               unsigned int length = 0;
-               int readBytes = 0;
-
-               _BEGIN();
-
-               /* read 4 bytes (length) */
-               pthread_mutex_lock(&ipcLock);
-               readBytes = recv(socket, &length, sizeof(length), 0);
-               pthread_mutex_unlock(&ipcLock);
-               if (readBytes == sizeof(length))
-               {
-                       if (length > 0)
-                       {
-                               uint8_t *temp = NULL;
-
-                               /* prepare buffer */
-                               temp = new uint8_t[length];
-                               if (temp != NULL)
-                               {
-                                       int retry = 0;
-                                       unsigned int current = 0;
-
-                                       /* read message */
-                                       pthread_mutex_lock(&ipcLock);
-                                       do
-                                       {
-                                               readBytes = recv(socket, temp + current, length - current, 0);
-                                               if (readBytes > 0)
-                                                       current += readBytes;
-                                               retry++;
-                                       }
-                                       while (current < length);
-                                       pthread_mutex_unlock(&ipcLock);
-
-                                       _DBG("<<<[RETRIEVE]<<< socket [%d], msg_length [%d]", socket, length);
-
-                                       buffer.assign(temp, length);
-
-                                       delete []temp;
-                               }
-                               else
-                               {
-                                       _ERR("allocation failed");
-                               }
-                       }
-                       else
-                       {
-                               _ERR("invalid length, socket = [%d], msg_length = [%d]", socket, length);
-                       }
-               }
-               else
-               {
-                       _ERR("failed to recv length, socket = [%d], readBytes [%d]", socket, readBytes);
-               }
-
-               _END();
-
-               return buffer;
-       }
-
-       void IPCHelper::setDispatcher(DispatcherHelper *dispatcher)
-       {
-               this->dispatcher = dispatcher;
-       }
-
-} /* namespace smartcard_service_api */
-#endif
diff --git a/common/Message.cpp b/common/Message.cpp
deleted file mode 100644 (file)
index 5beab7f..0000000
+++ /dev/null
@@ -1,216 +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 USE_GDBUS
-/* standard library header */
-#include <cstdio>
-#include <cstring>
-#include <sstream>
-
-/* SLP library header */
-
-/* local header */
-#include "Debug.h"
-#include "Message.h"
-
-namespace smartcard_service_api
-{
-       Message::Message()
-       {
-               message = 0;
-               param1 = 0;
-               param2 = 0;
-               error = 0;
-               caller = NULL;
-               callback = NULL;
-               userParam = NULL;
-       }
-
-       Message::~Message()
-       {
-       }
-
-       const ByteArray Message::serialize() const
-       {
-               ByteArray result;
-               unsigned int length = 0;
-               unsigned int dataLength = 0;
-               unsigned char *buffer = NULL;
-
-               length = sizeof(message) + sizeof(param1) + sizeof(param2) + sizeof(error) + sizeof(caller) + sizeof(callback) + sizeof(userParam);
-               if (data.size() > 0)
-               {
-                       dataLength = data.size();
-                       length += sizeof(dataLength) + data.size();
-               }
-
-               buffer = new unsigned char[length];
-               if (buffer != NULL)
-               {
-                       unsigned int current = 0;
-
-                       memset(buffer, 0, length);
-
-                       memcpy(buffer + current, &message, sizeof(message));
-                       current += sizeof(message);
-
-                       memcpy(buffer + current, &param1, sizeof(param1));
-                       current += sizeof(param1);
-
-                       memcpy(buffer + current, &param2, sizeof(param2));
-                       current += sizeof(param2);
-
-                       memcpy(buffer + current, &error, sizeof(error));
-                       current += sizeof(error);
-
-                       memcpy(buffer + current, &caller, sizeof(caller));
-                       current += sizeof(caller);
-
-                       memcpy(buffer + current, &callback, sizeof(callback));
-                       current += sizeof(callback);
-
-                       memcpy(buffer + current, &userParam, sizeof(userParam));
-                       current += sizeof(userParam);
-
-                       if (data.size() > 0)
-                       {
-                               memcpy(buffer + current, &dataLength, sizeof(dataLength));
-                               current += sizeof(dataLength);
-
-                               memcpy(buffer + current, data.getBuffer(), dataLength);
-                               current += data.size();
-                       }
-
-                       result.assign(buffer, length);
-
-                       delete []buffer;
-               }
-               else
-               {
-                       _ERR("allocation failed");
-               }
-
-               return result;
-       }
-
-       void Message::deserialize(const ByteArray &buffer)
-       {
-               deserialize(buffer.getBuffer(), buffer.size());
-       }
-
-       void Message::deserialize(const unsigned char *buffer, unsigned int length)
-       {
-               unsigned int current = 0;
-               unsigned int dataLength = 0;
-
-//             _DBG("buffer [%p], length [%d]", buffer, length);
-
-               memcpy(&message, buffer + current, sizeof(message));
-               current += sizeof(message);
-
-//             _DBG("message [%d]", message);
-
-               memcpy(&param1, buffer + current, sizeof(param1));
-               current += sizeof(param1);
-
-//             _DBG("param1 [%d]", param1);
-
-               memcpy(&param2, buffer + current, sizeof(param2));
-               current += sizeof(param2);
-
-//             _DBG("param2 [%d]", param2);
-
-               memcpy(&error, buffer + current, sizeof(error));
-               current += sizeof(error);
-
-               memcpy(&caller, buffer + current, sizeof(caller));
-               current += sizeof(caller);
-
-               memcpy(&callback, buffer + current, sizeof(callback));
-               current += sizeof(callback);
-
-               memcpy(&userParam, buffer + current, sizeof(userParam));
-               current += sizeof(userParam);
-
-//             _DBG("userContext [%p]", userContext);
-
-               if (current + sizeof(dataLength) < length)
-               {
-                       memcpy(&dataLength, buffer + current, sizeof(dataLength));
-                       current += sizeof(dataLength);
-
-//                     _DBG("dataLength [%d]", dataLength);
-
-                       data.assign(buffer + current, dataLength);
-                       current += dataLength;
-               }
-       }
-
-       const string Message::toString() const
-       {
-               stringstream ss;
-               const char *msg = NULL;
-
-               switch (message)
-               {
-               case MSG_REQUEST_READERS :
-                       msg = "MSG_REQUEST_READERS";
-                       break;
-
-//             case MSG_REQUEST_READER_NAME :
-//                     msg = "MSG_REQUEST_READER_NAME";
-//                     break;
-//
-               case MSG_REQUEST_OPEN_SESSION :
-                       msg = "MSG_REQUEST_OPEN_SESSION";
-                       break;
-
-               case MSG_REQUEST_CLOSE_SESSION :
-                       msg = "MSG_REQUEST_CLOSE_CHANNEL";
-                       break;
-
-               case MSG_REQUEST_OPEN_CHANNEL :
-                       msg = "MSG_REQUEST_OPEN_CHANNEL";
-                       break;
-
-               case MSG_REQUEST_CLOSE_CHANNEL :
-                       msg = "MSG_REQUEST_CLOSE_CHANNEL";
-                       break;
-
-               case MSG_REQUEST_GET_ATR :
-                       msg = "MSG_REQUEST_GET_ATR";
-                       break;
-
-               case MSG_REQUEST_TRANSMIT :
-                       msg = "MSG_REQUEST_TRANSMIT";
-                       break;
-
-               case MSG_REQUEST_GET_CHANNEL_COUNT :
-                       msg = "MSG_REQUEST_GET_CHANNEL_COUNT";
-                       break;
-
-               default :
-                       msg = "Unknown";
-                       break;
-               }
-
-               ss << "Message [" << msg << ", " << message << "], param1 [" << param1 << "], param2 [" << param2 << "], error [" << error << "], caller [" << "], callback [" << callback << "], userParam [" << userParam << "], data length [" << data.size() << "]";
-
-               return ss.str();
-       }
-
-} /* namespace smartcard_service_api */
-#endif
diff --git a/common/include/DispatcherHelper.h b/common/include/DispatcherHelper.h
deleted file mode 100644 (file)
index 7a669e8..0000000
+++ /dev/null
@@ -1,65 +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 DISPATCHERHELPER_H_
-#define DISPATCHERHELPER_H_
-#ifndef USE_GDBUS
-/* standard library header */
-#include <queue>
-#include <pthread.h>
-
-/* SLP library header */
-
-/* local header */
-#include "Synchronous.h"
-#include "DispatcherMsg.h"
-
-using namespace std;
-
-namespace smartcard_service_api
-{
-       class DispatcherHelper : public Synchronous
-       {
-       private:
-               pthread_t dispatcherThread;
-
-               queue<DispatcherMsg *> messageQ;
-
-               static void *_dispatcherThreadFunc(void *data);
-
-               DispatcherMsg *fetchMessage();
-
-       protected:
-               virtual void *dispatcherThreadFunc(DispatcherMsg *msg, void *data) = 0;
-
-       public:
-               DispatcherHelper();
-               virtual ~DispatcherHelper();
-
-               void clearQueue();
-
-               void pushMessage(const DispatcherMsg &msg);
-               void processMessage(DispatcherMsg *msg);
-
-               bool runDispatcherThread();
-               void stopDispatcherThread();
-
-               friend void *_dispatcherThreadFunc(void *data);
-       };
-
-} /* namespace smartcard_service_api */
-#endif
-#endif /* DISPATCHERHELPER_H_ */
diff --git a/common/include/DispatcherMsg.h b/common/include/DispatcherMsg.h
deleted file mode 100644 (file)
index becd584..0000000
+++ /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 DISPATCHERMSG_H_
-#define DISPATCHERMSG_H_
-#ifndef USE_GDBUS
-/* standard library header */
-
-/* SLP library header */
-
-/* local header */
-#include "Message.h"
-
-namespace smartcard_service_api
-{
-       class DispatcherMsg : public Message
-       {
-       private:
-               int peerSocket;
-
-       public:
-               DispatcherMsg() : Message()
-               {
-                       peerSocket = -1;
-               }
-
-               DispatcherMsg(const Message &msg) : Message()
-               {
-                       peerSocket = -1;
-                       message = msg.message;
-                       param1 = msg.param1;
-                       param2 = msg.param2;
-                       error = msg.error;
-                       data = msg.data;
-                       caller = msg.caller;
-                       callback = msg.callback;
-                       userParam = msg.userParam;
-               }
-
-               DispatcherMsg(const DispatcherMsg &msg) : Message()
-               {
-                       peerSocket = msg.peerSocket;
-                       message = msg.message;
-                       param1 = msg.param1;
-                       param2 = msg.param2;
-                       error = msg.error;
-                       data = msg.data;
-                       caller = msg.caller;
-                       callback = msg.callback;
-                       userParam = msg.userParam;
-               }
-
-               DispatcherMsg(const Message &msg, int socket) : Message()
-               {
-                       peerSocket = socket;
-                       message = msg.message;
-                       param1 = msg.param1;
-                       param2 = msg.param2;
-                       error = msg.error;
-                       data = msg.data;
-                       caller = msg.caller;
-                       callback = msg.callback;
-                       userParam = msg.userParam;
-               }
-
-               ~DispatcherMsg() {}
-
-               inline int getPeerSocket() const { return peerSocket; }
-               inline void setPeerSocket(int socket) { peerSocket = socket; }
-       };
-
-} /* namespace smartcard_service_api */
-#endif
-#endif /* DISPATCHERMSG_H_ */
index 8de47d4..a32c269 100644 (file)
@@ -17,7 +17,6 @@
 #ifndef GDBUSHELPER_H_
 #define GDBUSHELPER_H_
 
-#ifdef USE_GDBUS
 #include <glib.h>
 
 #include "ByteArray.h"
@@ -42,5 +41,5 @@ namespace smartcard_service_api
                        const ByteArray &array);
        };
 } /* namespace smartcard_service_api */
-#endif
+
 #endif /* GDBUSHELPER_H_ */
diff --git a/common/include/IPCHelper.h b/common/include/IPCHelper.h
deleted file mode 100644 (file)
index 8761815..0000000
+++ /dev/null
@@ -1,92 +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 IPCHELPER_H_
-#define IPCHELPER_H_
-
-#ifndef USE_GDBUS
-/* standard library header */
-#include <glib.h>
-#include <pthread.h>
-#ifdef USE_IPC_EPOLL
-#include <sys/epoll.h>
-#endif
-
-/* SLP library header */
-
-/* local header */
-#include "Message.h"
-#include "DispatcherHelper.h"
-
-namespace smartcard_service_api
-{
-       class IPCHelper
-       {
-       protected:
-               static const int IPC_SERVER_PORT = 8989;
-               static const int IPC_SERVER_MAX_CLIENT = 10;
-
-               int ipcSocket;
-               unsigned int watchId;
-               GIOChannel *ioChannel;
-               pthread_mutex_t ipcLock;
-               DispatcherHelper *dispatcher;
-#ifdef CLIENT_IPC_THREAD
-#ifdef USE_IPC_EPOLL
-               static const int EPOLL_SIZE = 5;
-               int fdPoll;
-               struct epoll_event *pollEvents;
-#else
-               fd_set fdSetRead;
-#endif
-               pthread_t readThread;
-
-               static void *threadRead(void *data);
-               int eventPoll();
-#endif
-
-               static gboolean channelCallbackFunc(GIOChannel* channel, GIOCondition condition, gpointer data);
-
-               virtual int handleIOErrorCondition(void *channel, GIOCondition condition) = 0;
-               virtual int handleInvalidSocketCondition(void *channel, GIOCondition condition) = 0;
-               virtual int handleIncomingCondition(void *channel, GIOCondition condition) = 0;
-
-       public:
-               IPCHelper();
-               virtual ~IPCHelper();
-
-               bool createListenSocket();
-               bool createConnectSocket();
-               void destroyListenSocket();
-               void destroyConnectSocket();
-
-               bool sendMessage(int socket, const Message &msg);
-               bool sendMessage(int socket, const ByteArray &buffer);
-               Message *retrieveMessage();
-               const ByteArray retrieveBuffer(int socket);
-               Message *retrieveMessage(int socket);
-
-               void setDispatcher(DispatcherHelper *dispatcher);
-
-#ifdef CLIENT_IPC_THREAD
-               friend void *threadRead(void *data);
-#endif
-               friend gboolean channelCallbackFunc(GIOChannel* channel, GIOCondition condition, gpointer data);
-       };
-
-} /* namespace smartcard_service_api */
-#endif
-#endif /* IPCHELPER_H_ */
diff --git a/common/include/Message.h b/common/include/Message.h
deleted file mode 100644 (file)
index 28abd03..0000000
+++ /dev/null
@@ -1,74 +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 MESSAGE_H_
-#define MESSAGE_H_
-#ifndef USE_GDBUS
-/* standard library header */
-#include <string>
-
-/* SLP library header */
-
-/* local header */
-#include "Serializable.h"
-
-using namespace std;
-
-namespace smartcard_service_api
-{
-       class Message : public Serializable
-       {
-       private:
-       public:
-               static const int MSG_REQUEST_READERS = 0x80;
-               static const int MSG_REQUEST_SHUTDOWN = 0x81;
-               static const int MSG_REQUEST_OPEN_SESSION = 0x82;
-               static const int MSG_REQUEST_CLOSE_SESSION = 0x83;
-               static const int MSG_REQUEST_OPEN_CHANNEL = 0x84;
-               static const int MSG_REQUEST_CLOSE_CHANNEL = 0x85;
-               static const int MSG_REQUEST_GET_ATR = 0x86;
-               static const int MSG_REQUEST_TRANSMIT = 0x87;
-               static const int MSG_REQUEST_GET_CHANNEL_COUNT = 0x88;
-
-               static const int MSG_NOTIFY_SE_REMOVED = 0x90;
-               static const int MSG_NOTIFY_SE_INSERTED = 0x91;
-
-               static const int MSG_OPERATION_RELEASE_CLIENT = 0xC0;
-
-               unsigned int message;
-               unsigned long param1;
-               unsigned long param2;
-               ByteArray data;
-               long error;
-               void *caller;
-               void *callback;
-               void *userParam;
-
-               Message();
-               virtual ~Message();
-
-               const ByteArray serialize() const;
-               void deserialize(const unsigned char *buffer, unsigned int length);
-               void deserialize(const ByteArray &buffer);
-
-               inline bool isSynchronousCall() const { return (caller == callback); }
-
-               const string toString() const;
-       };
-
-} /* namespace smartcard_service_api */
-#endif
-#endif /* MESSAGE_H_ */
index 2af01c9..5be4bcd 100644 (file)
@@ -1,6 +1,5 @@
 # FOR COMMENTING DEFINITION, MUST USE %% instead of %
 %global use_autostart "-DUSE_AUTOSTART=1"
-%global use_gdbus "-DUSE_GDBUS=1"
 #%%global test_client "-DTEST_CLIENT=1"
 
 Name:       smartcard-service
@@ -22,14 +21,8 @@ BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(libssl)
 BuildRequires: pkgconfig(pkgmgr)
 BuildRequires: pkgconfig(pkgmgr-info)
-%if 0%{!?use_gdbus:1}
-BuildRequires: pkgconfig(dbus-glib-1)
-%endif
-# for gdbus
-%if 0%{?use_gdbus:1}
 BuildRequires: python
 BuildRequires: python-xml
-%endif
 
 Requires(post):   /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
index 9d3be5d..1898c0c 100644 (file)
@@ -6,9 +6,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common/include)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ SRCS)
-IF(DEFINED USE_GDBUS)
-       AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/private SRCS)
-ENDIF()
 
 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
        SET(CMAKE_BUILD_TYPE "Release")
@@ -18,9 +15,6 @@ ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 INCLUDE(FindPkgConfig)
 
 SET(PKG_MODULE glib-2.0 gio-2.0 gio-unix-2.0 security-server dlog)
-IF(NOT DEFINED USE_GDBUS)
-       SET(PKG_MODULE ${PKG_MODULE} dbus-glib-1)
-ENDIF()
 
 pkg_check_modules(pkgs_server REQUIRED ${PKG_MODULE})
 
index d2dfcb9..4e60be7 100644 (file)
@@ -80,22 +80,6 @@ namespace smartcard_service_api
                mapServices.clear();
        }
 
-#ifndef USE_GDBUS
-       bool ClientInstance::sendMessageToAllServices(int socket, const Message &msg)
-       {
-               bool result = true;
-               map<unsigned int, ServiceInstance *>::const_iterator item;
-
-               for (item = mapServices.begin(); item != mapServices.end(); item++)
-               {
-                       if (ServerIPC::getInstance()->sendMessage(socket, msg) == false)
-                               result = false;
-               }
-
-               return result;
-       }
-#endif
-
        void ClientInstance::generateCertificationHashes()
        {
                SignatureHelper::getCertificationHashes(getPID(), certHashes);
diff --git a/server/ServerDispatcher.cpp b/server/ServerDispatcher.cpp
deleted file mode 100644 (file)
index bd49ad4..0000000
+++ /dev/null
@@ -1,398 +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 USE_GDBUS
-/* standard library header */
-#include <stdio.h>
-#include <string.h>
-
-/* SLP library header */
-
-/* local header */
-#include "Debug.h"
-#include "Exception.h"
-#include "ServerDispatcher.h"
-#include "ServerIPC.h"
-#include "ServerResource.h"
-#include "ServerSEService.h"
-#include "ServerChannel.h"
-#include "ServerSession.h"
-#include "ServerReader.h"
-
-namespace smartcard_service_api
-{
-       ServerDispatcher::ServerDispatcher():DispatcherHelper()
-       {
-               _BEGIN();
-
-               runDispatcherThread();
-
-               _END();
-       }
-
-       ServerDispatcher::~ServerDispatcher()
-       {
-       }
-
-       ServerDispatcher *ServerDispatcher::getInstance()
-       {
-               static ServerDispatcher instance;
-
-               return &instance;
-       }
-
-       void *ServerDispatcher::dispatcherThreadFunc(DispatcherMsg *msg, void *data)
-       {
-               int socket = -1;
-               ServerResource *resource = NULL;
-
-               if (data == NULL)
-               {
-                       _ERR("dispatcher instance is null");
-                       return NULL;
-               }
-
-               if (msg == NULL)
-               {
-                       _ERR("message is null");
-                       return NULL;
-               }
-
-               resource = &ServerResource::getInstance();
-               socket = msg->getPeerSocket();
-
-               switch (msg->message)
-               {
-               /* handle message */
-               case Message::MSG_REQUEST_READERS :
-                       {
-                               _INFO("[MSG_REQUEST_READERS]");
-
-                               int count = 0;
-                               Message response(*msg);
-                               ByteArray info;
-                               ClientInstance *instance = NULL;
-                               ServiceInstance *service = NULL;
-
-                               response.param1 = 0;
-                               response.param2 = 0;
-
-                               /* load secure elements */
-                               resource->loadSecureElements();
-
-                               if ((instance = resource->getClient(socket)) != NULL)
-                               {
-                                       /* update client PID */
-                                       if (instance->getPID() == -1)
-                                       {
-                                               instance->setPID(msg->error);
-                                               _INFO("update PID [%d]", msg->error);
-
-                                               /* generate certification hashes */
-                                               instance->generateCertificationHashes();
-                                       }
-
-                                       /* create service */
-                                       if ((service = resource->createService(socket)) != NULL)
-                                       {
-                                               response.error = SCARD_ERROR_OK;
-                                               response.param2 = service->getHandle();
-
-                                               if ((count = resource->getReadersInformation(info)) > 0)
-                                               {
-                                                       response.param1 = count;
-                                                       response.data = info;
-                                               }
-                                               else
-                                               {
-                                                       _INFO("no secure elements");
-                                               }
-                                       }
-                                       else
-                                       {
-                                               _ERR("createClient failed");
-
-                                               response.error = SCARD_ERROR_UNAVAILABLE;
-                                       }
-                               }
-                               else
-                               {
-                                       _ERR("client doesn't exist, socket [%d]", socket);
-
-                                       response.error = SCARD_ERROR_UNAVAILABLE;
-                               }
-
-                               /* response to client */
-                               ServerIPC::getInstance()->sendMessage(socket, response);
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_SHUTDOWN :
-                       {
-                               Message response(*msg);
-
-                               _INFO("[MSG_REQUEST_SHUTDOWN]");
-
-                               response.error = SCARD_ERROR_OK;
-
-                               resource->removeService(socket, msg->param1);
-
-                               /* response to client */
-                               ServerIPC::getInstance()->sendMessage(socket, response);
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_OPEN_SESSION :
-                       {
-                               Message response(*msg);
-                               unsigned int handle = IntegerHandle::INVALID_HANDLE;
-
-                               _INFO("[MSG_REQUEST_OPEN_SESSION]");
-
-                               if (resource->isValidReaderHandle(msg->param1))
-                               {
-                                       vector<ByteArray> temp;
-
-                                       handle = resource->createSession(socket, msg->error/* service context */, msg->param1, temp, msg->caller);
-                                       if (handle != IntegerHandle::INVALID_HANDLE)
-                                       {
-                                               response.error = SCARD_ERROR_OK;
-                                       }
-                                       else
-                                       {
-                                               _ERR("createSession failed [%d]", handle);
-                                               response.error = SCARD_ERROR_OUT_OF_MEMORY;
-                                       }
-                               }
-                               else
-                               {
-                                       _ERR("request invalid reader handle [%d]", msg->param1);
-                                       response.error = SCARD_ERROR_ILLEGAL_PARAM;
-                               }
-
-                               response.param1 = handle;
-
-                               /* response to client */
-                               ServerIPC::getInstance()->sendMessage(socket, response);
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_CLOSE_SESSION :
-                       {
-                               Message response(*msg);
-
-                               _INFO("[MSG_REQUEST_CLOSE_SESSION]");
-
-                               response.param1 = 0;
-                               response.error = SCARD_ERROR_OK;
-
-                               if (resource->isValidSessionHandle(socket, msg->error/* service context */, msg->param1))
-                               {
-                                       resource->removeSession(socket, msg->error/* service context */, msg->param1);
-                               }
-
-                               /* response to client */
-                               ServerIPC::getInstance()->sendMessage(socket, response);
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_OPEN_CHANNEL :
-                       {
-                               Message response(*msg);
-
-                               _INFO("[MSG_REQUEST_OPEN_CHANNEL]");
-
-                               response.param1 = IntegerHandle::INVALID_HANDLE;
-                               response.param2 = 0;
-                               response.data.clear();
-
-                               try
-                               {
-                                       unsigned int channelID = IntegerHandle::INVALID_HANDLE;
-
-                                       channelID = resource->createChannel(socket, msg->error/* service context */, msg->param2, msg->param1, msg->data);
-                                       if (channelID != IntegerHandle::INVALID_HANDLE)
-                                       {
-                                               ServerChannel *temp;
-
-                                               temp = (ServerChannel *)resource->getChannel(socket, msg->error/* service context */, channelID);
-                                               if (temp != NULL)
-                                               {
-                                                       response.param1 = channelID;
-                                                       response.param2 = temp->getChannelNumber();
-                                                       response.error = SCARD_ERROR_OK;
-                                                       response.data = temp->getSelectResponse();
-                                               }
-                                               else
-                                               {
-                                                       _ERR("IS IT POSSIBLE??????????????????");
-                                                       response.error = SCARD_ERROR_UNKNOWN;
-                                               }
-                                       }
-                                       else
-                                       {
-                                               _ERR("channel is null.");
-
-                                               /* set error value */
-                                               response.error = SCARD_ERROR_UNAVAILABLE;
-                                       }
-                               }
-                               catch (ExceptionBase &e)
-                               {
-                                       response.error = e.getErrorCode();
-                               }
-
-                               /* response to client */
-                               ServerIPC::getInstance()->sendMessage(socket, response);
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_GET_CHANNEL_COUNT :
-                       {
-                               Message response(*msg);
-
-                               _INFO("[MSG_REQUEST_GET_CHANNEL_COUNT]");
-
-                               response.error = SCARD_ERROR_OK;
-                               response.param1 = resource->getChannelCount(socket, msg->error/* service context */, msg->param1);
-
-                               /* response to client */
-                               ServerIPC::getInstance()->sendMessage(socket, response);
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_CLOSE_CHANNEL :
-                       {
-                               Message response(*msg);
-
-                               _INFO("[MSG_REQUEST_CLOSE_CHANNEL]");
-
-                               response.error = SCARD_ERROR_OK;
-
-                               if (resource->getChannel(socket, msg->error/* service context */, msg->param1) != NULL)
-                               {
-                                       resource->removeChannel(socket, msg->error/* service context */, msg->param1);
-                               }
-
-                               /* response to client */
-                               ServerIPC::getInstance()->sendMessage(socket, response);
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_GET_ATR :
-                       {
-                               int rv;
-                               Message response(*msg);
-                               ByteArray result;
-                               ServiceInstance *client = NULL;
-
-                               _INFO("[MSG_REQUEST_GET_ATR]");
-
-                               if ((client = resource->getService(socket, msg->error/* service context */)) != NULL)
-                               {
-                                       Terminal *terminal = NULL;
-
-                                       if ((terminal = client->getTerminal(msg->param1)) != NULL)
-                                       {
-                                               if ((rv = terminal->getATRSync(result)) == 0)
-                                               {
-                                                       response.data = result;
-                                                       response.error = SCARD_ERROR_OK;
-                                               }
-                                               else
-                                               {
-                                                       _ERR("transmit failed [%d]", rv);
-
-                                                       response.error = rv;
-                                               }
-                                       }
-                                       else
-                                       {
-                                               _ERR("getTerminal failed : socket [%d], context [%d], session [%d]", socket, msg->error/* service context */, msg->param1);
-                                               response.error = SCARD_ERROR_UNAVAILABLE;
-                                       }
-                               }
-                               else
-                               {
-                                       _ERR("getClient failed : socket [%d], context [%d], session [%d]", socket, msg->error/* service context */, msg->param1);
-                                       response.error = SCARD_ERROR_UNAVAILABLE;
-                               }
-
-                               /* response to client */
-                               ServerIPC::getInstance()->sendMessage(socket, response);
-                       }
-                       break;
-
-               case Message::MSG_REQUEST_TRANSMIT :
-                       {
-                               int rv;
-                               Message response(*msg);
-                               ByteArray result;
-                               Channel *channel = NULL;
-
-                               _INFO("[MSG_REQUEST_TRANSMIT]");
-
-                               if ((channel = resource->getChannel(socket, msg->error/* service context */, msg->param1)) != NULL)
-                               {
-                                       if ((rv = channel->transmitSync(msg->data, result)) == 0)
-                                       {
-                                               response.data = result;
-                                               response.error = SCARD_ERROR_OK;
-                                       }
-                                       else
-                                       {
-                                               _ERR("transmit failed [%d]", rv);
-
-                                               response.error = rv;
-                                       }
-                               }
-                               else
-                               {
-                                       _ERR("invalid handle : socket [%d], context [%d], channel [%d]", socket, msg->error/* service context */, msg->param1);
-                                       response.error = SCARD_ERROR_UNAVAILABLE;
-                               }
-
-                               /* response to client */
-                               ServerIPC::getInstance()->sendMessage(socket, response);
-                       }
-                       break;
-
-               case Message::MSG_OPERATION_RELEASE_CLIENT :
-                       {
-                               _INFO("[MSG_OPERATION_RELEASE_CLIENT]");
-
-                               resource->removeClient(msg->param1);
-                               _DBG("remain client [%d]", resource->getClientCount());
-                       }
-#ifdef USE_AUTOSTART
-                       if (resource->getClientCount() == 0)
-                       {
-                               _INFO("There is no client. shutting down service");
-                               g_main_loop_quit((GMainLoop *)resource->getMainLoopInstance());
-                       }
-#endif
-                       break;
-
-               default :
-                       _DBG("unknown message [%s], socket [%d]", msg->toString().c_str(), socket);
-                       break;
-               }
-
-               return NULL;
-       }
-
-} /* namespace smartcard_service_api */
-#endif
index 1f60e1e..30838c0 100644 (file)
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-#ifdef USE_GDBUS
 /* standard library header */
 #include <unistd.h>
 #include <glib.h>
@@ -1376,4 +1375,3 @@ namespace smartcard_service_api
                }
        }
 } /* namespace smartcard_service_api */
-#endif
diff --git a/server/ServerIPC.cpp b/server/ServerIPC.cpp
deleted file mode 100644 (file)
index 419fc15..0000000
+++ /dev/null
@@ -1,290 +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 USE_GDBUS
-/* standard library header */
-#include <string.h>
-#include <sys/socket.h>
-#include <unistd.h>
-
-/* SLP library header */
-#ifdef SECURITY_SERVER
-#include "security-server.h"
-#endif
-
-/* local header */
-#include "Debug.h"
-#include "ServerIPC.h"
-#include "ServerResource.h"
-#include "ServerDispatcher.h"
-
-#ifndef EXTERN_API
-#define EXTERN_API __attribute__((visibility("default")))
-#endif
-
-namespace smartcard_service_api
-{
-       ServerIPC::ServerIPC() : IPCHelper()
-       {
-               _BEGIN();
-
-               setDispatcher(ServerDispatcher::getInstance());
-
-               _END();
-       }
-
-       ServerIPC::~ServerIPC()
-       {
-       }
-
-       ServerIPC *ServerIPC::getInstance()
-       {
-               static ServerIPC instance;
-
-               return &instance;
-       }
-
-       Message *ServerIPC::retrieveMessage(int socket)
-       {
-               ByteArray buffer;
-               Message *msg = NULL;
-
-               _BEGIN();
-
-               buffer = IPCHelper::retrieveBuffer(socket);
-               if (buffer.size() > 0)
-               {
-#ifdef SECURITY_SERVER
-                       ByteArray cookie;
-                       int result, gid;
-
-                       if (buffer.size() < 20)
-                               return msg;
-
-                       cookie.assign(buffer.getBuffer(), 20);
-
-                       gid = security_server_get_gid("smartcard-daemon");
-                       if ((result = security_server_check_privilege((char *)cookie.getBuffer(), gid)) != SECURITY_SERVER_API_SUCCESS)
-                       {
-                               _ERR("security_server_check_privilege failed [%d]", result);
-                               return msg;
-                       }
-#endif
-                       msg = new Message();
-                       if (msg != NULL)
-                       {
-                               msg->deserialize(buffer);
-                       }
-                       else
-                       {
-                               _ERR("alloc failed");
-                       }
-               }
-               else
-               {
-                       _ERR("retrieveBuffer failed ");
-               }
-
-               _END();
-
-               return msg;
-       }
-
-       bool ServerIPC::acceptClient()
-       {
-               GIOCondition condition = (GIOCondition)(G_IO_ERR | G_IO_HUP | G_IO_IN);
-               socklen_t addrlen = 0;
-               int client_sock_fd = 0;
-               GIOChannel *client_channel = NULL;
-               int client_src_id;
-
-               _DBG("client is trying to connect to server");
-
-               pthread_mutex_lock(&ipcLock);
-               client_sock_fd = accept(ipcSocket, NULL, &addrlen);
-               pthread_mutex_unlock(&ipcLock);
-
-               if (client_sock_fd < 0)
-               {
-                       _ERR("can not accept client");
-                       goto ERROR;
-               }
-
-               _DBG("client is accepted by server");
-
-               if ((client_channel = g_io_channel_unix_new(client_sock_fd)) == NULL)
-               {
-                       _ERR("create new g io channel is failed");
-                       goto ERROR;
-               }
-
-               if ((client_src_id = g_io_add_watch(client_channel, condition, &IPCHelper::channelCallbackFunc, this)) < 1)
-               {
-                       _ERR("add io callback is failed");
-                       goto ERROR;
-               }
-
-               _INFO("client socket is bond with g_io_channel");
-
-               if (ServerResource::getInstance().createClient(client_channel, client_sock_fd, client_src_id, 0, -1) == false)
-               {
-                       _ERR("failed to add client");
-               }
-
-               return true;
-
-ERROR :
-               if (client_channel != NULL)
-               {
-                       g_io_channel_unref(client_channel);
-               }
-
-               if (client_sock_fd != -1)
-               {
-                       shutdown(client_sock_fd, SHUT_RDWR);
-                       close(client_sock_fd);
-               }
-
-               return false;
-       }
-
-       void ServerIPC::restartServerIPC()
-       {
-               destroyListenSocket();
-
-               createListenSocket();
-       }
-
-       void ServerIPC::releaseClient(void *channel, int socket, int watchID)
-       {
-               if (watchID != 0)
-               {
-                       g_source_remove(watchID);
-               }
-
-               if (channel != NULL)
-               {
-                       g_io_channel_unref((GIOChannel *)channel);
-               }
-
-               if (socket >= 0)
-               {
-                       shutdown(socket, SHUT_RDWR);
-                       close(socket);
-               }
-       }
-
-       int ServerIPC::handleIOErrorCondition(void *channel, GIOCondition condition)
-       {
-               _BEGIN();
-
-               if(channel == ioChannel)
-               {
-                       _INFO("server socket is closed");
-                       restartServerIPC();
-               }
-               else
-               {
-                       DispatcherMsg dispMsg;
-                       int peerSocket = g_io_channel_unix_get_fd((GIOChannel *)channel);
-
-                       _INFO("client socket is closed, socket [%d]", peerSocket);
-
-                       /* push message to dispatcher */
-                       dispMsg.message = Message::MSG_OPERATION_RELEASE_CLIENT;
-                       dispMsg.param1 = peerSocket;
-                       dispMsg.setPeerSocket(peerSocket);
-
-                       /* push to dispatcher */
-                       ServerDispatcher::getInstance()->pushMessage(dispMsg);
-               }
-
-               _END();
-
-               return FALSE;
-       }
-
-       int ServerIPC::handleInvalidSocketCondition(void *channel, GIOCondition condition)
-       {
-               _BEGIN();
-               _END();
-
-               return FALSE;
-       }
-
-       int ServerIPC::handleIncomingCondition(void *channel, GIOCondition condition)
-       {
-               int result = FALSE;
-
-               _BEGIN();
-
-               if(channel == ioChannel)
-               {
-                       /* connect state. should accept */
-                       _INFO("new client connected");
-
-                       result = acceptClient();
-               }
-               else
-               {
-                       int peerSocket = g_io_channel_unix_get_fd((GIOChannel *)channel);
-
-                       _DBG("data incoming from [%d]", peerSocket);
-
-                       if (peerSocket >= 0)
-                       {
-                               Message *msg;
-
-                               /* read message */
-                               if ((msg = retrieveMessage(peerSocket)) != NULL)
-                               {
-                                       DispatcherMsg dispMsg(*msg, peerSocket);
-
-                                       /* push to dispatcher */
-                                       ServerDispatcher::getInstance()->pushMessage(dispMsg);
-
-                                       result = TRUE;
-
-                                       delete msg;
-                               }
-                               else
-                               {
-                                       /* clear client connection */
-                                       _ERR("retrieve message failed, socket [%d]", peerSocket);
-                               }
-                       }
-                       else
-                       {
-                               _ERR("client context doesn't exist, socket [%d]", peerSocket);
-                       }
-               }
-
-               _END();
-
-               return result;
-       }
-
-} /* namespace smartcard_service_api */
-
-using namespace smartcard_service_api;
-
-EXTERN_API void server_ipc_create_listen_socket()
-{
-       ServerIPC *ipc = ServerIPC::getInstance();
-
-       ipc->createListenSocket();
-}
-#endif /* USE_GDBUS */
index 63c7d2f..790abdc 100644 (file)
@@ -31,9 +31,7 @@
 #include "SignatureHelper.h"
 #include "GPACE.h"
 #include "PKCS15.h"
-#ifdef USE_GDBUS
 #include "ServerGDBus.h"
-#endif
 #include "smartcard-daemon.h"
 
 #ifndef EXTERN_API
@@ -88,10 +86,6 @@ namespace smartcard_service_api
        ServerResource::ServerResource() : seLoaded(false)
        {
                _BEGIN();
-#ifndef USE_GDBUS
-               serverIPC = ServerIPC::getInstance();
-               serverDispatcher = ServerDispatcher::getInstance();
-#endif
                _END();
        }
 
@@ -106,7 +100,6 @@ namespace smartcard_service_api
                return serverResource;
        }
 
-#ifdef USE_GDBUS
        bool ServerResource::createClient(const char *name, pid_t pid)
        {
                bool result = false;
@@ -400,350 +393,7 @@ namespace smartcard_service_api
                        _ERR("getService doesn't exist : name [%s], handle [%d]", name, handle);
                }
        }
-#else
-       bool ServerResource::createClient(void *ioChannel, int socket,
-               int watchID, int state, int pid)
-       {
-               bool result = false;
-
-               if (getClient(socket) == NULL)
-               {
-                       ClientInstance *instance = new ClientInstance(ioChannel,
-                               socket, watchID, state, pid);
-                       if (instance != NULL)
-                       {
-                               mapClients.insert(make_pair(socket, instance));
-                               result = true;
-                       }
-                       else
-                       {
-                               _ERR("alloc failed");
-                       }
-               }
-               else
-               {
-                       _ERR("client already exist, socket[%d]", socket);
-               }
-
-               return result;
-       }
-
-       bool ServerResource::createClient(int pid)
-       {
-               bool result = false;
-
-               if (getClient(pid) == NULL)
-               {
-                       ClientInstance *instance = new ClientInstance(pid);
-                       if (instance != NULL)
-                       {
-                               mapClients.insert(make_pair(pid, instance));
-                               result = true;
-                       }
-                       else
-                       {
-                               _ERR("alloc failed");
-                       }
-               }
-               else
-               {
-                       _ERR("client already exist, pid[%d]", pid);
-               }
-
-               return result;
-       }
-
-       ClientInstance *ServerResource::getClient(int socket)
-       {
-               ClientInstance *result = NULL;
-               map<int, ClientInstance *>::iterator item;
-
-               if ((item = mapClients.find(socket)) != mapClients.end())
-               {
-                       result = item->second;
-               }
-
-               return result;
-       }
-
-       const ClientInstance *ServerResource::getClient(int socket) const
-       {
-               const ClientInstance *result = NULL;
-               map<int, ClientInstance *>::const_iterator item;
-
-               if ((item = mapClients.find(socket)) != mapClients.end())
-               {
-                       result = item->second;
-               }
-
-               return result;
-       }
-
-       void ServerResource::setPID(int socket, int pid)
-       {
-               map<int, ClientInstance *>::iterator item;
-
-               if ((item = mapClients.find(socket)) != mapClients.end())
-               {
-                       if (item->second->getPID() < 0)
-                               item->second->setPID(pid);
-               }
-       }
-
-       void ServerResource::removeClient(int socket)
-       {
-               map<int, ClientInstance *>::iterator item;
-
-               if ((item = mapClients.find(socket)) != mapClients.end())
-               {
-#ifndef USE_GDBUS
-                       ServerIPC::getInstance()->releaseClient(item->second->getIOChannel(), item->second->getSocket(), item->second->getWatchID());
-#endif
-                       delete item->second;
-                       mapClients.erase(item);
-               }
-               else
-               {
-                       _DBG("client removed already [%d]", socket);
-               }
-       }
-
-       void ServerResource::removeClients()
-       {
-               map<int, ClientInstance *>::iterator item;
-
-               for (item = mapClients.begin(); item != mapClients.end(); item++)
-               {
-#ifndef USE_GDBUS
-                       ServerIPC::getInstance()->releaseClient(item->second->getIOChannel(), item->second->getSocket(), item->second->getWatchID());
-#endif
-                       delete item->second;
-               }
-
-               mapClients.clear();
-       }
-
-       int ServerResource::getClientCount() const
-       {
-               return (int)mapClients.size();
-       }
-
-       ServiceInstance *ServerResource::createService(int socket)
-       {
-               ServiceInstance *result = NULL;
-               ClientInstance *instance = NULL;
-
-               if ((instance = getClient(socket)) != NULL)
-               {
-                       if ((result = instance->createService()) == NULL)
-                       {
-                               _ERR("ClientInstance::createService failed [%d]", socket);
-                       }
-               }
-               else
-               {
-                       _ERR("client doesn't exist [%d]", socket);
-               }
-
-               return result;
-       }
-
-       ServiceInstance *ServerResource::getService(int socket, unsigned int handle)
-       {
-               ServiceInstance *result = NULL;
-               ClientInstance *instance = NULL;
-
-               if ((instance = getClient(socket)) != NULL)
-               {
-                       result = instance->getService(handle);
-               }
-               else
-               {
-                       _ERR("client doesn't exist [%d]", socket);
-               }
-
-               return result;
-       }
-
-       void ServerResource::removeService(int socket, unsigned int handle)
-       {
-               ClientInstance *instance = NULL;
-
-               if ((instance = getClient(socket)) != NULL)
-               {
-                       instance->removeService(handle);
-               }
-               else
-               {
-                       _ERR("client doesn't exist [%d]", socket);
-               }
-       }
-
-       void ServerResource::removeServices(int socket)
-       {
-               ClientInstance *instance = NULL;
-
-               if ((instance = getClient(socket)) != NULL)
-               {
-                       instance->removeServices();
-               }
-               else
-               {
-                       _ERR("client doesn't exist [%d]", socket);
-               }
-       }
-
-       unsigned int ServerResource::createSession(int socket, unsigned int handle, unsigned int readerID, const vector<ByteArray> &certHashes, void *caller)
-       {
-               unsigned int result = -1;
-               Terminal *temp = NULL;
-               ServiceInstance *instance = NULL;
-
-               if ((instance = getService(socket, handle)) != NULL)
-               {
-                       if ((temp = getTerminalByReaderID(readerID)) != NULL)
-                       {
-                               result = instance->openSession(temp, certHashes, caller);
-                       }
-               }
-               else
-               {
-                       _ERR("getService doesn't exist : socket [%d], handle [%d]", socket, handle);
-               }
-
-               return result;
-       }
-
-       ServerSession *ServerResource::getSession(int socket, unsigned int handle, unsigned int sessionID)
-       {
-               ServerSession *result = NULL;
-               ServiceInstance *instance = NULL;
-
-               if ((instance = getService(socket, handle)) != NULL)
-               {
-                       result = instance->getSession(sessionID);
-               }
-               else
-               {
-                       _ERR("Session doesn't exist : socket [%d], handle [%d], handle [%d]", socket, handle, sessionID);
-               }
-
-               return result;
-       }
-
-       bool ServerResource::isValidSessionHandle(int socket, unsigned int handle, unsigned int session)
-       {
-               ServiceInstance *instance = NULL;
-
-               return (((instance = getService(socket, handle)) != NULL) && (instance->isVaildSessionHandle(session)));
-       }
-
-       unsigned int ServerResource::getChannelCount(int socket, unsigned int handle, unsigned int sessionID)
-       {
-               unsigned int result = -1;
-               ServiceInstance *instance = NULL;
-
-               if ((instance = getService(socket, handle)) != NULL)
-               {
-                       result = instance->getChannelCountBySession(sessionID);
-               }
-               else
-               {
-                       _ERR("getService doesn't exist : socket [%d], handle [%d]", socket, handle);
-               }
-
-               return result;
-       }
-
-       void ServerResource::removeSession(int socket, unsigned int handle, unsigned int sessionID)
-       {
-               ServiceInstance *instance = NULL;
-
-               if ((instance = getService(socket, handle)) != NULL)
-               {
-                       instance->closeSession(sessionID);
-               }
-               else
-               {
-                       _ERR("getService doesn't exist : socket [%d], handle [%d]", socket, handle);
-               }
-       }
-
-       unsigned int ServerResource::createChannel(int socket, unsigned int handle, unsigned int sessionID, int channelType, const ByteArray &aid)
-               throw(ExceptionBase &)
-       {
-               unsigned int result = -1;
-               ServiceInstance *service = NULL;
-
-               if ((service = getService(socket, handle)) != NULL)
-               {
-                       if (service->isVaildSessionHandle(sessionID) == true)
-                       {
-                               ServerSession *session = NULL;
-                               Terminal *terminal = NULL;
-
-                               terminal = service->getTerminal(sessionID);
-                               session = service->getSession(sessionID);
-                               if (terminal != NULL && session != NULL)
-                               {
-                                       result = _createChannel(terminal, service, channelType, sessionID, aid);
-                                       if (result == IntegerHandle::INVALID_HANDLE)
-                                       {
-                                               _ERR("create channel failed [%d]", sessionID);
-                                       }
-                               }
-                               else
-                               {
-                                       _ERR("session is invalid [%d]", sessionID);
-                                       throw ExceptionBase(SCARD_ERROR_UNAVAILABLE);
-                               }
-                       }
-                       else
-                       {
-                               _ERR("session is invalid [%d]", sessionID);
-                               throw ExceptionBase(SCARD_ERROR_ILLEGAL_STATE);
-                       }
-               }
-               else
-               {
-                       _ERR("getService is failed [%d] [%d]", socket, handle);
-                       throw ExceptionBase(SCARD_ERROR_UNAVAILABLE);
-               }
-
-               return result;
-       }
 
-       Channel *ServerResource::getChannel(int socket, unsigned int handle, unsigned int channelID)
-       {
-               Channel *result = NULL;
-               ServiceInstance *instance = NULL;
-
-               if ((instance = getService(socket, handle)) != NULL)
-               {
-                       result = instance->getChannel(channelID);
-               }
-               else
-               {
-                       _ERR("Channel doesn't exist : socket [%d], handle [%d], handle [%d]", socket, handle, channelID);
-               }
-
-               return result;
-       }
-
-       void ServerResource::removeChannel(int socket, unsigned int handle, unsigned int channelID)
-       {
-               ServiceInstance *instance = NULL;
-
-               if ((instance = getService(socket, handle)) != NULL)
-               {
-                       instance->closeChannel(channelID);
-               }
-               else
-               {
-                       _ERR("getService doesn't exist : socket [%d], handle [%d]", socket, handle);
-               }
-       }
-#endif
        Terminal *ServerResource::getTerminal(unsigned int terminalID)
        {
                Terminal *result = NULL;
@@ -1347,25 +997,6 @@ namespace smartcard_service_api
                return result;
        }
 
-#ifndef USE_GDBUS
-       bool ServerResource::sendMessageToAllClients(const Message &msg)
-       {
-               bool result = true;
-
-               map<int, ClientInstance *>::const_iterator item;
-
-               for (item = mapClients.begin();
-                       item != mapClients.end(); item++)
-               {
-                       if (item->second->sendMessageToAllServices(
-                               item->second->getSocket(), msg) == false)
-                               result = false;
-               }
-
-               return result;
-       }
-#endif
-
        void ServerResource::terminalCallback(const void *terminal, int event,
                int error, void *user_param)
        {
@@ -1384,19 +1015,8 @@ namespace smartcard_service_api
                                if (terminalID != IntegerHandle::INVALID_HANDLE)
                                {
                                        unsigned int readerID = instance.createReader(terminalID);
-#ifdef USE_GDBUS
-                                       ServerGDBus::getInstance().emitReaderInserted(readerID, (const char *)terminal);
-#else
-                                       Message msg;
 
-                                       /* send all client to refresh reader */
-                                       msg.message = msg.MSG_NOTIFY_SE_INSERTED;
-                                       msg.param1 = readerID;
-                                       msg.data.assign((uint8_t *)terminal,
-                                               strlen((char *)terminal) + 1);
-
-                                       instance.sendMessageToAllClients(msg);
-#endif
+                                       ServerGDBus::getInstance().emitReaderInserted(readerID, (const char *)terminal);
                                }
                        }
                        break;
@@ -1409,20 +1029,10 @@ namespace smartcard_service_api
                                _INFO("[NOTIFY_SE_NOT_AVAILABLE]");
 
                                readerID = instance.getReaderID((char *)terminal);
-#ifdef USE_GDBUS
+
                                ServerGDBus::getInstance().emitReaderRemoved(
                                        readerID, (const char *)terminal);
-#else
-                               Message msg;
 
-                               /* send all client to refresh reader */
-                               msg.message = msg.MSG_NOTIFY_SE_REMOVED;
-                               msg.param1 = readerID;
-                               msg.data.assign((uint8_t *)terminal,
-                                       strlen((char *)terminal) + 1);
-
-                               instance.sendMessageToAllClients(msg);
-#endif
                                instance.removeReader(readerID);
                        }
                        break;
index cc4fc5c..f7d4bcf 100644 (file)
 /* local header */
 #include "Debug.h"
 #include "TerminalInterface.h"
-#ifndef USE_GDBUS
-#include "Message.h"
-#include "ServerIPC.h"
-#endif
 #include "ServerResource.h"
 #include "ServerSEService.h"
 
@@ -188,78 +184,19 @@ namespace smartcard_service_api
                }
        }
 
-       bool ServerSEService::dispatcherCallback(void *message, int socket)
-       {
-#ifndef USE_GDBUS
-               int count;
-               ByteArray info;
-               Message *msg = (Message *)message;
-               Message response(*msg);
-               ServerResource &resource = ServerResource::getInstance();
-               ServiceInstance *service;
-
-               if ((service = resource.createService(socket)) != NULL)
-               {
-                       _ERR("client added : pid [%d]", msg->error);
-
-                       response.error = SCARD_ERROR_OK;
-                       response.param2 = service->getHandle();
-
-                       if ((count = resource.getReadersInformation(info)) > 0)
-                       {
-                               response.param1 = count;
-                               response.data = info;
-                       }
-                       else
-                       {
-                               _DBG("no secure elements");
-                               response.param1 = 0;
-                       }
-               }
-               else
-               {
-                       _ERR("createClient failed");
-
-                       response.error = SCARD_ERROR_OUT_OF_MEMORY;
-               }
-
-               /* response to client */
-               ServerIPC::getInstance()->sendMessage(socket, response);
-#endif
-               return false;
-       }
-
        void ServerSEService::terminalCallback(const void *terminal, int event, int error, void *user_param)
        {
                switch (event)
                {
                case Terminal::NOTIFY_SE_AVAILABLE :
                        {
-#ifndef USE_GDBUS
-                               Message msg;
-
-                               /* send all client to refresh reader */
-                               msg.message = msg.MSG_NOTIFY_SE_INSERTED;
-                               msg.data.assign((unsigned char *)terminal,
-                                       strlen((char *)terminal) + 1);
-
-                               ServerResource::getInstance().sendMessageToAllClients(msg);
-#endif
+                               // TODO: add right se reader
                        }
                        break;
 
                case Terminal::NOTIFY_SE_NOT_AVAILABLE :
                        {
-#ifndef USE_GDBUS
-                               Message msg;
-
-                               /* send all client to refresh reader */
-                               msg.message = msg.MSG_NOTIFY_SE_REMOVED;
-                               msg.data.assign((unsigned char *)terminal,
-                                       strlen((char *)terminal) + 1);
-
-                               ServerResource::getInstance().sendMessageToAllClients(msg);
-#endif
+                               // TODO: remove right se reader
                        }
                        break;
 
index 65f3006..25a0bfc 100644 (file)
 #include <map>
 #include <vector>
 #include <string>
-#ifndef USE_GDBUS
-#include <glib.h>
-#endif
 
 /* SLP library header */
 
 /* local header */
-#ifndef USE_GDBUS
-#include "Message.h"
-#endif
 #include "ServiceInstance.h"
 
 namespace smartcard_service_api
@@ -38,49 +32,19 @@ namespace smartcard_service_api
        class ClientInstance
        {
        private :
-#ifdef USE_GDBUS
                string name;
-#else
-               void *ioChannel;
-               int socket;
-               int watchID;
-               int state;
-#endif
                pid_t pid;
                vector<ByteArray> certHashes;
                map<unsigned int, ServiceInstance *> mapServices;
 
        public :
-#ifdef USE_GDBUS
                ClientInstance(const char *name, pid_t pid) :
                        name(name), pid(pid)
                {
                }
-#else
-               ClientInstance(void *ioChannel, int socket, int watchID,
-                       int state, int pid) : ioChannel(ioChannel),
-                       socket(socket), watchID(watchID), state(state), pid(pid)
-               {
-               }
-
-               ClientInstance(pid_t pid) : ioChannel(NULL),
-                       socket(pid), watchID(0), state(0), pid(pid)
-               {
-               }
-#endif
                inline ~ClientInstance() { removeServices(); }
-#ifdef USE_GDBUS
                inline bool operator ==(const char *name) const { return (this->name.compare(name) == 0); }
-#else
-               inline bool operator ==(const int &socket) const { return (this->socket == socket); }
-#endif
 
-#ifndef USE_GDBUS
-               inline void *getIOChannel() { return ioChannel; }
-               inline int getSocket() { return socket; }
-               inline int getWatchID() { return watchID; }
-               inline int getState() { return state; }
-#endif
                inline void setPID(int pid) { this->pid = pid; }
                inline int getPID() const { return pid; }
 
@@ -89,12 +53,10 @@ namespace smartcard_service_api
                void removeService(unsigned int handle);
                void removeServices();
                inline size_t getServiceCounts() const { return mapServices.size(); }
-#ifndef USE_GDBUS
-               bool sendMessageToAllServices(int socket, const Message &msg);
-#endif
                void generateCertificationHashes();
 
                inline vector<ByteArray> &getCertificationHashes() { return certHashes; }
        };
 } /* namespace smartcard_service_api */
+
 #endif /* CLIENTINSTANCE_H_ */
diff --git a/server/include/ServerDispatcher.h b/server/include/ServerDispatcher.h
deleted file mode 100644 (file)
index cd6f652..0000000
+++ /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.
- */
-
-#ifndef SERVERDISPATCHER_H_
-#define SERVERDISPATCHER_H_
-#ifndef USE_GDBUS
-/* standard library header */
-
-/* SLP library header */
-
-/* local header */
-#include "DispatcherHelper.h"
-
-namespace smartcard_service_api
-{
-       class ServerIPC;
-
-       class ServerDispatcher: public DispatcherHelper
-       {
-       private:
-               ServerDispatcher();
-               ~ServerDispatcher();
-
-               void *dispatcherThreadFunc(DispatcherMsg *msg, void *data);
-
-       public:
-               static ServerDispatcher *getInstance();
-       };
-
-} /* namespace smartcard_service_api */
-#endif /* USE_GDBUS */
-#endif /* SERVERDISPATCHER_H_ */
index 8ede3c6..9a29246 100644 (file)
@@ -16,7 +16,7 @@
 
 #ifndef SERVERGDBUS_H_
 #define SERVERGDBUS_H_
-#ifdef USE_GDBUS
+
 /* standard library header */
 #include <glib.h>
 #include <queue>
@@ -97,5 +97,5 @@ namespace smartcard_service_api
                void deinitChannel();
        };
 } /* namespace smartcard_service_api */
-#endif
+
 #endif /* SERVERGDBUS_H_ */
diff --git a/server/include/ServerIPC.h b/server/include/ServerIPC.h
deleted file mode 100644 (file)
index 3dbc322..0000000
+++ /dev/null
@@ -1,73 +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 SERVERIPC_H_
-#define SERVERIPC_H_
-#ifndef USE_GDBUS
-/* standard library header */
-#ifdef __cplusplus
-#include <map>
-#endif /* __cplusplus */
-
-/* SLP library header */
-
-/* local header */
-#ifdef __cplusplus
-#include "IPCHelper.h"
-#endif /* __cplusplus */
-
-#ifdef __cplusplus
-using namespace std;
-
-namespace smartcard_service_api
-{
-       class ServerIPC: public IPCHelper
-       {
-       private:
-               ServerIPC();
-               ~ServerIPC();
-
-               bool acceptClient();
-               void restartServerIPC();
-               void releaseClient(void *channel, int socket, int watchID);
-
-               int handleIOErrorCondition(void *channel, GIOCondition condition);
-               int handleInvalidSocketCondition(void *channel, GIOCondition condition);
-               int handleIncomingCondition(void *channel, GIOCondition condition);
-
-       public:
-               static ServerIPC *getInstance();
-               Message *retrieveMessage(int socket);
-
-               friend class ServerResource;
-       };
-
-} /* namespace smartcard_service_api */
-#endif /* __cplusplus */
-
-/* export C API */
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-void server_ipc_create_listen_socket();
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* USE_GDBUS */
-#endif /* SERVERIPC_H_ */
index 20f377c..6609575 100644 (file)
 #include "Exception.h"
 #include "Terminal.h"
 #include "Lock.h"
-#ifndef USE_GDBUS
-#include "ServerIPC.h"
-#include "ServerDispatcher.h"
-#endif
 #include "ServerReader.h"
 #include "ServerSession.h"
 #include "ClientInstance.h"
@@ -63,16 +59,8 @@ namespace smartcard_service_api
                vector<void *> libraries;
                map<unsigned int, Terminal *> mapTerminals; /* terminal unique id <-> terminal instance map */
                map<unsigned int, unsigned int> mapReaders; /* reader unique id <-> terminal unique id map */
-#ifdef USE_GDBUS
                map<string, ClientInstance *> mapClients; /* client pid <-> client instance map */
-#else
-               map<int, ClientInstance *> mapClients; /* client pid <-> client instance map */
-#endif
                map<Terminal *, AccessControlList *> mapACL; /* terminal instance <-> access control instance map */
-#ifndef USE_GDBUS
-               ServerIPC *serverIPC;
-               ServerDispatcher *serverDispatcher;
-#endif
                bool seLoaded;
 
                ServerResource();
@@ -111,7 +99,6 @@ namespace smartcard_service_api
                unsigned int getReaderID(const char *name) const;
                void removeReader(unsigned int readerID);
 
-#ifdef USE_GDBUS
                bool createClient(const char *name, pid_t pid);
                ClientInstance *getClient(const char *name);
                void removeClient(const char *name);
@@ -134,40 +121,10 @@ namespace smartcard_service_api
                        throw(ExceptionBase &);
                Channel *getChannel(const char *name, unsigned int handle, unsigned int channelID);
                void removeChannel(const char *name, unsigned int handle, unsigned int channelID);
-#else
-               bool createClient(void *ioChannel, int socket, int watchID, int state, int pid);
-               bool createClient(int pid);
-               ClientInstance *getClient(int socket);
-               const ClientInstance *getClient(int socket) const;
-               void setPID(int socket, int pid);
-               void removeClient(int socket);
-               void removeClients();
-               int getClientCount() const;
-
-               ServiceInstance *createService(int socket);
-               ServiceInstance *getService(int socket, unsigned int handle);
-               void removeService(int socket, unsigned int handle);
-               void removeServices(int socket);
-
-               unsigned int createSession(int socket, unsigned int handle, unsigned int readerID, const vector<ByteArray> &certHashes, void *caller);
-               ServerSession *getSession(int socket, unsigned int handle, unsigned int sessionID);
-               unsigned int getChannelCount(int socket, unsigned int handle, unsigned int sessionID);
-               void removeSession(int socket, unsigned int handle, unsigned int session);
-               bool isValidSessionHandle(int socket, unsigned int handle, unsigned int sessionID);
-
-               unsigned int createChannel(int socket, unsigned int handle,
-                       unsigned int sessionID, int channelType, const ByteArray &aid)
-                       throw(ExceptionBase &);
-               Channel *getChannel(int socket, unsigned int handle, unsigned int channelID);
-               void removeChannel(int socket, unsigned int handle, unsigned int channelID);
-#endif
                void addAccessControlList(Terminal *terminal, AccessControlList *acl);
                void addAccessControlList(ServerChannel *channel, AccessControlList *acl);
                AccessControlList *getAccessControlList(Terminal *terminal);
                AccessControlList *getAccessControlList(ServerChannel *channel);
-#ifndef USE_GDBUS
-               bool sendMessageToAllClients(const Message &msg);
-#endif
                bool isAuthorizedNFCAccess(Terminal *terminal, const ByteArray &aid,
                        const vector<ByteArray> &hashes);
 
index a8ddbd3..3c2890a 100644 (file)
 #include <sys/stat.h>
 #include <signal.h>
 #include <vector>
-#if defined(USE_AUTOSTART) && !defined(USE_GDBUS)
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-#endif
 
 /* SLP library header */
 
 /* local header */
 #include "Debug.h"
-#include "ServerIPC.h"
 #include "ServerResource.h"
-#ifdef USE_GDBUS
 #include "smartcard-service-gdbus.h"
 #include "ServerGDBus.h"
-#else
-#ifdef USE_AUTOSTART
-#include "SmartcardDbus.h"
-#include "smartcard-service-binding.h"
-#endif
-#endif
 
 /* definition */
 using namespace std;
@@ -53,10 +41,6 @@ using namespace smartcard_service_api;
 
 /* global variable */
 GMainLoop *main_loop = NULL;
-#if defined(USE_AUTOSTART) && !defined(USE_GDBUS)
-GObject *object = NULL;
-DBusGConnection *connection = NULL;
-#endif
 
 #ifndef USE_AUTOSTART
 static void daemonize(void)
@@ -101,7 +85,6 @@ static void daemonize(void)
 }
 #endif
 
-#ifdef USE_GDBUS
 static void _bus_acquired_cb(GDBusConnection *connection,
        const gchar *path, gpointer user_data)
 {
@@ -126,118 +109,14 @@ static void _name_lost_cb(GDBusConnection *connnection,
        ServerGDBus::getInstance().deinit();
 }
 
-#else
-#ifdef USE_AUTOSTART
-G_DEFINE_TYPE(Smartcard_Service, smartcard_service, G_TYPE_OBJECT)
-
-/* Just Check the assert  and set the error message */
-#define __G_ASSERT(test, return_val, error, domain, error_code)\
-G_STMT_START\
-{\
-       if G_LIKELY (!(test)) { \
-               g_set_error (error, domain, error_code, #test); \
-               return (return_val); \
-       }\
-}\
-G_STMT_END
-
-GQuark smartcard_service_error_quark(void)
-{
-       _DBG("smartcard_service_error_quark entered");
-
-       return g_quark_from_static_string("smartcard_service_error");
-}
-
-static void smartcard_service_init(Smartcard_Service *smartcard_service)
-{
-       _DBG("smartcard_service_init entered");
-}
-
-static void smartcard_service_class_init(Smartcard_ServiceClass *smartcard_service_class)
-{
-       _DBG("smartcard_service_class_init entered");
-
-       dbus_g_object_type_install_info(SMARTCARD_SERVICE_TYPE, &dbus_glib_smartcard_service_object_info);
-}
-
-gboolean smartcard_service_launch(Smartcard_Service *smartcard_service, guint *result_val, GError **error)
-{
-       _DBG("smartcard_service_launch entered");
-
-       return TRUE;
-}
-
-static void _initialize_dbus()
-{
-       GError *error = NULL;
-       DBusGProxy *proxy = NULL;
-       guint ret = 0;
-
-       _BEGIN();
-
-       g_type_init();
-
-       connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
-       if (error == NULL)
-       {
-               object = (GObject *)g_object_new(SMARTCARD_SERVICE_TYPE, NULL);
-               dbus_g_connection_register_g_object(connection, SMARTCARD_SERVICE_PATH, object);
-
-               /* register service */
-               proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
-               if (proxy != NULL)
-               {
-                       if (!org_freedesktop_DBus_request_name(proxy, SMARTCARD_SERVICE_NAME, 0, &ret, &error))
-                       {
-                               _ERR("Unable to register service: %s", error->message);
-                               g_error_free(error);
-                       }
-
-                       g_object_unref (proxy);
-               }
-               else
-               {
-                       _ERR("dbus_g_proxy_new_for_name failed");
-               }
-       }
-       else
-       {
-               _ERR("ERROR: Can't get on system bus [%s]", error->message);
-               g_error_free(error);
-       }
-
-       _END();
-}
-
-static void _finalize_dbus()
-{
-       _BEGIN();
-
-       dbus_g_connection_unregister_g_object(connection, object);
-       g_object_unref(object);
-
-       _END();
-}
-#endif
-#endif
-
 static void __sighandler(int sig)
 {
        _DBG("signal!! [%d]", sig);
-
-#ifdef USE_GDBUS
-#else
-#ifdef USE_AUTOSTART
-       _finalize_dbus();
-#endif
-#endif
 }
 
 int main(int argc, char *argv[])
 {
-#ifdef USE_GDBUS
        guint id = 0;
-#endif
        signal(SIGTERM, &__sighandler);
 
 #ifndef USE_AUTOSTART
@@ -252,7 +131,6 @@ int main(int argc, char *argv[])
 
        main_loop = g_main_new(TRUE);
 
-#ifdef USE_GDBUS
        id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
                        "org.tizen.SmartcardService",
                        G_BUS_NAME_OWNER_FLAGS_NONE,
@@ -261,22 +139,12 @@ int main(int argc, char *argv[])
                        _name_lost_cb,
                        NULL,
                        NULL);
-#else
-       ServerIPC::getInstance()->createListenSocket();
-#ifdef USE_AUTOSTART
-       _initialize_dbus();
-#endif
-#endif
+
        g_main_loop_run(main_loop);
 
-#ifdef USE_GDBUS
        if (id)
                g_bus_unown_name(id);
-#else
-#ifdef USE_AUTOSTART
-       _finalize_dbus();
-#endif
-#endif
+
        /* release secure element.. (pure virtual function problem..) */
        ServerResource::getInstance().unloadSecureElements();