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 "badge_service.h"
62 static inline int app_create(void)
66 if (access(SLAVE_LOG_PATH, R_OK|W_OK) != 0) {
67 if (mkdir(SLAVE_LOG_PATH, 755) < 0)
68 ErrPrint("Failed to create %s (%s)\n", SLAVE_LOG_PATH, strerror(errno));
73 * Dead signal handler has to be initialized before
74 * initate package or client (slave and client).
76 * Because while creating slaves for packages.
77 * It could be crashed before complete the initation stage.
79 * Then the dead callback should be invoked to handle it properly.
81 * To enable the dead signal handler,
82 * dead_init should be done before other components are initiated.
85 DbgPrint("Setting initialized: %d\n", ret);
88 DbgPrint("Client initialized: %d\n", ret);
91 DbgPrint("Dead callback is registered: %d\n", ret);
94 DbgPrint("group init: %d\n", ret);
97 DbgPrint("Init I/O: %d\n", ret);
100 DbgPrint("pkgmgr initialized: %d\n", ret);
104 ret = xmonitor_init();
105 DbgPrint("XMonitor init is done: %d\n", ret);
107 ret = buffer_handler_init();
108 DbgPrint("Buffer handler init is done: %d\n", ret);
112 * After initiate all other sub-systtems,
113 * Enable the server socket.
116 DbgPrint("Server initialized: %d\n", ret);
122 static inline int app_terminate(void)
128 ret = setting_fini();
129 DbgPrint("Finalize setting : %d\n", ret);
135 ret = package_fini();
136 DbgPrint("Finalize package info: %d\n", ret);
141 DbgPrint("Finalize dbus: %d\n", ret);
144 DbgPrint("dead signal handler finalized: %d\n", ret);
147 DbgPrint("IO finalized: %d\n", ret);
150 DbgPrint("Group finalized: %d\n", ret);
152 DbgPrint("Terminated\n");
156 static void signal_handler(int signum, siginfo_t *info, void *unused)
159 CRITICAL_LOG("Terminated(SIGTERM)\n");
160 fd = creat("/tmp/.stop.provider", 0644);
166 int main(int argc, char *argv[])
168 struct sigaction act;
172 * How could we care this return values?
173 * Is there any way to print something on the screen?
175 ret = critical_log_init(util_basename(argv[0]));
177 fprintf(stderr, "Failed to init the critical log\n");
180 __file_log_fp = fopen("/tmp/live.log", "w+t");
182 __file_log_fp = fdopen(1, "w+t");
184 /* appcore_agent_terminate */
185 if (ecore_init() <= 0) {
186 CRITICAL_LOG("Failed to initiate ecore\n");
191 act.sa_sigaction = signal_handler;
192 act.sa_flags = SA_SIGINFO;
194 ret = sigemptyset(&act.sa_mask);
196 CRITICAL_LOG("Failed to do sigemptyset: %s\n", strerror(errno));
198 ret = sigaddset(&act.sa_mask, SIGTERM);
200 CRITICAL_LOG("Failed to mask the SIGTERM: %s\n", strerror(errno));
202 ret = sigaction(SIGTERM, &act, NULL);
204 CRITICAL_LOG("Failed to add sigaction: %s\n", strerror(errno));
206 if (ecore_x_init(NULL) <= 0) {
207 CRITICAL_LOG("Failed to ecore x init\n");
213 ecore_app_args_set(argc, (const char **)argv);
215 if (evas_init() <= 0) {
216 CRITICAL_LOG("Failed to init evas return count is below than 0\n");
223 if (ecore_evas_init() <= 0) {
224 CRITICAL_LOG("Failed to init ecore_evas\n");
238 * Clear old contents files before start the master provider.
240 (void)util_unlink_files(ALWAYS_PATH);
241 (void)util_unlink_files(READER_PATH);
242 (void)util_unlink_files(IMAGE_PATH);
243 (void)util_unlink_files(SLAVE_LOG_PATH);
245 shortcut_service_init();
246 notification_service_init();
247 badge_service_init();
252 vconf_set_bool(VCONFKEY_MASTER_STARTED, 1);
253 ecore_main_loop_begin();
254 vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
259 badge_service_fini();
260 notification_service_fini();
261 shortcut_service_fini();
263 ecore_evas_shutdown();
272 fclose(__file_log_fp);