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 static void daemonize(void)
50 /* already a daemon */
54 /* Fork off the parent process */
63 exit(EXIT_SUCCESS); /*Killing the Parent Process*/
66 /* At this point we are executing as the child process */
69 /* Create a new SID for the child process */
76 /* Change the current working directory. */
88 static void _bus_acquired_cb(GDBusConnection *connection,
89 const gchar *path, gpointer user_data)
91 _DBG("bus path : %s", path);
93 ServerResource::getInstance();
95 ServerGDBus::getInstance().init();
98 static void _name_acquired_cb(GDBusConnection *connection,
99 const gchar *name, gpointer user_data)
101 _DBG("name : %s", name);
104 static void _name_lost_cb(GDBusConnection *connnection,
105 const gchar *name, gpointer user_data)
107 _DBG("name : %s", name);
109 ServerGDBus::getInstance().deinit();
112 static void __sighandler(int sig)
114 _DBG("signal!! [%d]", sig);
117 int main(int argc, char *argv[])
120 signal(SIGTERM, &__sighandler);
122 #ifndef USE_AUTOSTART
126 main_loop = g_main_new(TRUE);
128 id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
129 "org.tizen.SmartcardService",
130 G_BUS_NAME_OWNER_FLAGS_NONE,
137 g_main_loop_run(main_loop);
140 g_bus_unown_name(id);
142 /* release secure element.. (pure virtual function problem..) */
143 ServerResource::getInstance().unloadSecureElements();
148 void smartcard_daemon_exit()
150 g_main_loop_quit(main_loop);