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;
iterMap->second.printAccessConditions();
}
- _DBG("========================================================");
+ _DBG("============================================================================");
}
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
- void ClientInstance::setPID(int pid)
- {
- this->pid = pid;
- }
-
ServiceInstance *ClientInstance::createService()
{
ServiceInstance *result = NULL;
_INFO("terminated client, pid [%d]", client->getPID());
resource.removeClient(old_owner);
- if (resource.getClientCount() == 0) {
- g_main_loop_quit((GMainLoop *)resource.getMainLoopInstance());
- }
+ resource.finish();
}
}
}
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;
}
#ifdef USE_GDBUS
#include "ServerGDBus.h"
#endif
+#include "smartcard-daemon.h"
#ifndef EXTERN_API
#define EXTERN_API __attribute__((visibility("default")))
#define OMAPI_SE_PATH "/usr/lib/se"
- ServerResource::ServerResource()
- : mainLoop(NULL), seLoaded(false)
+ ServerResource::ServerResource() : seLoaded(false)
{
_BEGIN();
#ifndef USE_GDBUS
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 */
/* SLP library header */
/* local header */
+#ifndef USE_GDBUS
#include "Message.h"
+#endif
#include "ServiceInstance.h"
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
{
}
#endif
- ~ClientInstance() { removeServices(); }
+ inline ~ClientInstance() { removeServices(); }
#ifdef USE_GDBUS
inline bool operator ==(const char *name) const { return (this->name.compare(name) == 0); }
#else
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);
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;
/* 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();
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);
};
--- /dev/null
+/*
+ * 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_ */
{
_DBG("bus path : %s", path);
- ServerResource::getInstance().setMainLoopInstance(main_loop);
+ ServerResource::getInstance();
ServerGDBus::getInstance().init();
}
#endif
}
-int main()
+int main(int argc, char *argv[])
{
#ifdef USE_GDBUS
guint id = 0;
NULL,
NULL);
#else
- ServerResource::getInstance().setMainLoopInstance(main_loop);
ServerIPC::getInstance()->createListenSocket();
#ifdef USE_AUTOSTART
_initialize_dbus();
return 0;
}
+
+void smartcard_daemon_exit()
+{
+ g_main_loop_quit(main_loop);
+}