2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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.
20 #include <sys/types.h>
27 #include <Ecore_Evas.h>
29 #include <glib-object.h>
36 #include "slave_life.h"
37 #include "slave_rpc.h"
38 #include "client_life.h"
40 #include "buffer_handler.h"
41 #include "script_handler.h"
44 #include "dead_monitor.h"
52 #include "critical_log.h"
54 #include "shortcut_service.h"
55 #include "notification_service.h"
56 #include "utility_service.h"
57 #include "badge_service.h"
63 static inline int app_create(void)
67 if (access(SLAVE_LOG_PATH, R_OK|W_OK) != 0) {
68 if (mkdir(SLAVE_LOG_PATH, 755) < 0)
69 ErrPrint("Failed to create %s (%s)\n", SLAVE_LOG_PATH, strerror(errno));
74 * Dead signal handler has to be initialized before
75 * initate package or client (slave and client).
77 * Because while creating slaves for packages.
78 * It could be crashed before complete the initation stage.
80 * Then the dead callback should be invoked to handle it properly.
82 * To enable the dead signal handler,
83 * dead_init should be done before other components are initiated.
86 DbgPrint("Setting initialized: %d\n", ret);
89 DbgPrint("Client initialized: %d\n", ret);
92 DbgPrint("Dead callback is registered: %d\n", ret);
95 DbgPrint("group init: %d\n", ret);
98 DbgPrint("Init I/O: %d\n", ret);
100 ret = package_init();
101 DbgPrint("pkgmgr initialized: %d\n", ret);
105 ret = xmonitor_init();
106 DbgPrint("XMonitor init is done: %d\n", ret);
108 ret = buffer_handler_init();
109 DbgPrint("Buffer handler init is done: %d\n", ret);
113 * After initiate all other sub-systtems,
114 * Enable the server socket.
117 DbgPrint("Server initialized: %d\n", ret);
123 static inline int app_terminate(void)
129 ret = setting_fini();
130 DbgPrint("Finalize setting : %d\n", ret);
136 ret = package_fini();
137 DbgPrint("Finalize package info: %d\n", ret);
142 DbgPrint("Finalize dbus: %d\n", ret);
145 DbgPrint("dead signal handler finalized: %d\n", ret);
148 DbgPrint("IO finalized: %d\n", ret);
151 DbgPrint("Group finalized: %d\n", ret);
153 DbgPrint("Terminated\n");
157 static void signal_handler(int signum, siginfo_t *info, void *unused)
161 CRITICAL_LOG("Terminated(SIGTERM)\n");
162 fd = creat("/tmp/.stop.provider", 0644);
169 int main(int argc, char *argv[])
171 struct sigaction act;
175 * How could we care this return values?
176 * Is there any way to print something on the screen?
178 ret = critical_log_init(util_basename(argv[0]));
180 ErrPrint("Failed to init the critical log\n");
183 __file_log_fp = fopen("/tmp/live.log", "w+t");
185 __file_log_fp = fdopen(1, "w+t");
187 /* appcore_agent_terminate */
188 if (ecore_init() <= 0) {
189 CRITICAL_LOG("Failed to initiate ecore\n");
194 act.sa_sigaction = signal_handler;
195 act.sa_flags = SA_SIGINFO;
197 ret = sigemptyset(&act.sa_mask);
199 CRITICAL_LOG("Failed to do sigemptyset: %s\n", strerror(errno));
201 ret = sigaddset(&act.sa_mask, SIGTERM);
203 CRITICAL_LOG("Failed to mask the SIGTERM: %s\n", strerror(errno));
205 ret = sigaction(SIGTERM, &act, NULL);
207 CRITICAL_LOG("Failed to add sigaction: %s\n", strerror(errno));
209 if (ecore_x_init(NULL) <= 0) {
210 CRITICAL_LOG("Failed to ecore x init\n");
216 ecore_app_args_set(argc, (const char **)argv);
218 if (evas_init() <= 0) {
219 CRITICAL_LOG("Failed to init evas return count is below than 0\n");
226 if (ecore_evas_init() <= 0) {
227 CRITICAL_LOG("Failed to init ecore_evas\n");
235 #if !GLIB_CHECK_VERSION (2, 36, 0)
243 * Clear old contents files before start the master provider.
245 (void)util_unlink_files(ALWAYS_PATH);
246 (void)util_unlink_files(READER_PATH);
247 (void)util_unlink_files(IMAGE_PATH);
248 (void)util_unlink_files(SLAVE_LOG_PATH);
250 shortcut_service_init();
251 notification_service_init();
252 badge_service_init();
253 utility_service_init();
258 ecore_main_loop_begin();
263 utility_service_fini();
264 badge_service_fini();
265 notification_service_fini();
266 shortcut_service_fini();
268 ecore_evas_shutdown();
277 fclose(__file_log_fp);