diff options
author | Wonkyu Kwon <wonkyu.kwon@samsung.com> | 2013-07-22 15:38:18 +0900 |
---|---|---|
committer | Wonkyu Kwon <wonkyu.kwon@samsung.com> | 2013-07-24 17:56:39 +0900 |
commit | efaf4c71407f2cd61795c5d684a4a089de40f4f1 (patch) | |
tree | 9f840f511f0861cda99accb1395d14bb9dc58ca7 | |
parent | 905f17c79e50cd959dd36d11f3b4d3844eb80335 (diff) | |
download | smartcard-service-efaf4c71407f2cd61795c5d684a4a089de40f4f1.tar.gz smartcard-service-efaf4c71407f2cd61795c5d684a4a089de40f4f1.tar.bz2 smartcard-service-efaf4c71407f2cd61795c5d684a4a089de40f4f1.zip |
Minor fix
- adjust exit function
- adjust inline function
Change-Id: I9a7627f5c5d5d1087b90ad1f39659147b95cb96b
-rw-r--r-- | common/AccessControlList.cpp | 4 | ||||
-rw-r--r-- | server/ClientInstance.cpp | 5 | ||||
-rw-r--r-- | server/ServerGDBus.cpp | 10 | ||||
-rw-r--r-- | server/ServerResource.cpp | 18 | ||||
-rw-r--r-- | server/include/ClientInstance.h | 11 | ||||
-rw-r--r-- | server/include/ServerResource.h | 13 | ||||
-rw-r--r-- | server/include/smartcard-daemon.h | 22 | ||||
-rw-r--r-- | server/smartcard-daemon.cpp | 10 |
8 files changed, 52 insertions, 41 deletions
diff --git a/common/AccessControlList.cpp b/common/AccessControlList.cpp index 00c9984..0233360 100644 --- a/common/AccessControlList.cpp +++ b/common/AccessControlList.cpp @@ -227,7 +227,7 @@ END : ByteArray temp; map<ByteArray, AccessCondition>::const_iterator iterMap; - _DBG("================ Access Control Rules =================="); + _DBG("========================== Access Control Rules ============================"); for (iterMap = mapConditions.begin(); iterMap != mapConditions.end(); iterMap++) { temp = iterMap->first; @@ -236,7 +236,7 @@ END : iterMap->second.printAccessConditions(); } - _DBG("========================================================"); + _DBG("============================================================================"); } } /* namespace smartcard_service_api */ diff --git a/server/ClientInstance.cpp b/server/ClientInstance.cpp index 04f668f..d2dfcb9 100644 --- a/server/ClientInstance.cpp +++ b/server/ClientInstance.cpp @@ -27,11 +27,6 @@ namespace smartcard_service_api { - void ClientInstance::setPID(int pid) - { - this->pid = pid; - } - ServiceInstance *ClientInstance::createService() { ServiceInstance *result = NULL; diff --git a/server/ServerGDBus.cpp b/server/ServerGDBus.cpp index d075cdc..b74ed8e 100644 --- a/server/ServerGDBus.cpp +++ b/server/ServerGDBus.cpp @@ -143,9 +143,7 @@ namespace smartcard_service_api _INFO("terminated client, pid [%d]", client->getPID()); resource.removeClient(old_owner); - if (resource.getClientCount() == 0) { - g_main_loop_quit((GMainLoop *)resource.getMainLoopInstance()); - } + resource.finish(); } } } @@ -482,11 +480,7 @@ namespace smartcard_service_api invocation, SCARD_ERROR_OK); /* terminate */ - if (resource.getClientCount() == 0) { - _INFO("no client connected. terminate server"); - - g_main_loop_quit((GMainLoop *)resource.getMainLoopInstance()); - } + resource.finish(); return true; } diff --git a/server/ServerResource.cpp b/server/ServerResource.cpp index 172e496..7905e26 100644 --- a/server/ServerResource.cpp +++ b/server/ServerResource.cpp @@ -34,6 +34,7 @@ #ifdef USE_GDBUS #include "ServerGDBus.h" #endif +#include "smartcard-daemon.h" #ifndef EXTERN_API #define EXTERN_API __attribute__((visibility("default"))) @@ -84,8 +85,7 @@ namespace smartcard_service_api #define OMAPI_SE_PATH "/usr/lib/se" - ServerResource::ServerResource() - : mainLoop(NULL), seLoaded(false) + ServerResource::ServerResource() : seLoaded(false) { _BEGIN(); #ifndef USE_GDBUS @@ -1532,11 +1532,13 @@ namespace smartcard_service_api return result; } -} /* namespace smartcard_service_api */ -using namespace smartcard_service_api; + void ServerResource::finish() + { + if (getClientCount() == 0) { + _INFO("no client connected. terminate server"); -EXTERN_API void server_resource_set_main_loop_instance(void *instance) -{ - ServerResource::getInstance().setMainLoopInstance(instance); -} + smartcard_daemon_exit(); + } + } +} /* namespace smartcard_service_api */ diff --git a/server/include/ClientInstance.h b/server/include/ClientInstance.h index 7c22d4e..f3952ea 100644 --- a/server/include/ClientInstance.h +++ b/server/include/ClientInstance.h @@ -27,7 +27,9 @@ /* SLP library header */ /* local header */ +#ifndef USE_GDBUS #include "Message.h" +#endif #include "ServiceInstance.h" namespace smartcard_service_api @@ -49,7 +51,8 @@ namespace smartcard_service_api public : #ifdef USE_GDBUS - ClientInstance(const char *name, pid_t pid) : name(name), pid(pid) + ClientInstance(const char *name, pid_t pid) : + name(name), pid(pid) { } #else @@ -64,7 +67,7 @@ namespace smartcard_service_api { } #endif - ~ClientInstance() { removeServices(); } + inline ~ClientInstance() { removeServices(); } #ifdef USE_GDBUS inline bool operator ==(const char *name) const { return (this->name.compare(name) == 0); } #else @@ -77,8 +80,8 @@ namespace smartcard_service_api inline int getWatchID() { return watchID; } inline int getState() { return state; } #endif - void setPID(int pid); - inline int getPID() { return pid; } + inline void setPID(int pid) { this->pid = pid; } + inline int getPID() const { return pid; } ServiceInstance *createService(); ServiceInstance *getService(unsigned int handle); diff --git a/server/include/ServerResource.h b/server/include/ServerResource.h index add3ccf..20f377c 100644 --- a/server/include/ServerResource.h +++ b/server/include/ServerResource.h @@ -69,7 +69,6 @@ namespace smartcard_service_api map<int, ClientInstance *> mapClients; /* client pid <-> client instance map */ #endif map<Terminal *, AccessControlList *> mapACL; /* terminal instance <-> access control instance map */ - void *mainLoop; #ifndef USE_GDBUS ServerIPC *serverIPC; ServerDispatcher *serverDispatcher; @@ -95,16 +94,6 @@ namespace smartcard_service_api /* static member */ static ServerResource &getInstance(); - /* non-static member */ - inline void setMainLoopInstance(void *mainLoop) - { - this->mainLoop = mainLoop; - } - inline void *getMainLoopInstance() - { - return this->mainLoop; - } - int loadSecureElements(); void unloadSecureElements(); @@ -182,6 +171,8 @@ namespace smartcard_service_api bool isAuthorizedNFCAccess(Terminal *terminal, const ByteArray &aid, const vector<ByteArray> &hashes); + void finish(); + friend void terminalCallback(void *terminal, int event, int error, void *user_param); }; diff --git a/server/include/smartcard-daemon.h b/server/include/smartcard-daemon.h new file mode 100644 index 0000000..17cc583 --- /dev/null +++ b/server/include/smartcard-daemon.h @@ -0,0 +1,22 @@ +/* + * 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 SMARTCARD_DAEMON_H_ +#define SMARTCARD_DAEMON_H_ + +void smartcard_daemon_exit(); + +#endif /* SMARTCARD_DAEMON_H_ */ diff --git a/server/smartcard-daemon.cpp b/server/smartcard-daemon.cpp index fcddf44..a8ddbd3 100644 --- a/server/smartcard-daemon.cpp +++ b/server/smartcard-daemon.cpp @@ -107,7 +107,7 @@ static void _bus_acquired_cb(GDBusConnection *connection, { _DBG("bus path : %s", path); - ServerResource::getInstance().setMainLoopInstance(main_loop); + ServerResource::getInstance(); ServerGDBus::getInstance().init(); } @@ -233,7 +233,7 @@ static void __sighandler(int sig) #endif } -int main() +int main(int argc, char *argv[]) { #ifdef USE_GDBUS guint id = 0; @@ -262,7 +262,6 @@ int main() NULL, NULL); #else - ServerResource::getInstance().setMainLoopInstance(main_loop); ServerIPC::getInstance()->createListenSocket(); #ifdef USE_AUTOSTART _initialize_dbus(); @@ -283,3 +282,8 @@ int main() return 0; } + +void smartcard_daemon_exit() +{ + g_main_loop_quit(main_loop); +} |