2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 /* standard library header */
23 #include <glib-object.h>
30 /* SLP library header */
34 #include "ServerResource.h"
35 #include "smartcard-service-gdbus.h"
36 #include "ServerGDBus.h"
40 using namespace smartcard_service_api;
43 GMainLoop *main_loop = NULL;
46 extern "C" void __gcov_flush(void);
50 static void daemonize(void)
54 /* already a daemon */
58 /* Fork off the parent process */
67 exit(EXIT_SUCCESS); /*Killing the Parent Process*/
70 /* At this point we are executing as the child process */
73 /* Create a new SID for the child process */
80 /* Change the current working directory. */
92 static void _bus_acquired_cb(GDBusConnection *connection,
93 const gchar *path, gpointer user_data)
95 _DBG("bus path : %s", path);
97 ServerResource::getInstance();
99 ServerGDBus::getInstance().init();
102 static void _name_acquired_cb(GDBusConnection *connection,
103 const gchar *name, gpointer user_data)
105 _DBG("name : %s", name);
108 /* LCOV_EXCL_START */
109 static void _name_lost_cb(GDBusConnection *connnection,
110 const gchar *name, gpointer user_data)
112 _DBG("name : %s", name);
114 ServerGDBus::getInstance().deinit();
117 static void __sighandler(int sig)
119 _DBG("signal!! [%d]", sig);
120 #if (BUILD_GCOV != 0)
126 int main(int argc, char *argv[])
129 signal(SIGTERM, &__sighandler);
131 #ifndef USE_AUTOSTART
135 #if (BUILD_GCOV != 0)
136 setenv("GCOV_PREFIX", "/tmp/", 1);
139 main_loop = g_main_loop_new(NULL, FALSE);
141 id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
142 "org.tizen.SmartcardService",
143 G_BUS_NAME_OWNER_FLAGS_NONE,
150 g_main_loop_run(main_loop);
153 g_bus_unown_name(id);
155 /* release secure element.. (pure virtual function problem..) */
156 ServerResource::getInstance().unloadSecureElements();
158 #if (BUILD_GCOV != 0)
165 void smartcard_daemon_exit()
167 g_main_loop_quit(main_loop);
168 g_main_loop_unref(main_loop);