diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 109 |
1 files changed, 51 insertions, 58 deletions
@@ -23,6 +23,8 @@ #include <sys/signalfd.h> #include <ctype.h> +#include <systemd/sd-daemon.h> + #include <Ecore.h> #include <glib.h> #include <glib-object.h> @@ -31,10 +33,12 @@ #include <packet.h> #include <dlog.h> -#include <systemd/sd-daemon.h> - #if defined(HAVE_LIVEBOX) + +#include <dynamicbox_service.h> +#include <dynamicbox_conf.h> + #include "slave_life.h" #include "slave_rpc.h" #include "client_life.h" @@ -62,6 +66,7 @@ #include "badge_service.h" #if defined(FLOG) +#define TMP_LOG_FILE "/tmp/live.log" FILE *__file_log_fp; #endif @@ -69,9 +74,9 @@ static inline int app_create(void) { int ret; - if (access(SLAVE_LOG_PATH, R_OK | W_OK) != 0) { - if (mkdir(SLAVE_LOG_PATH, 0755) < 0) { - ErrPrint("Failed to create %s (%s)\n", SLAVE_LOG_PATH, strerror(errno)); + if (access(DYNAMICBOX_CONF_LOG_PATH, R_OK | W_OK) != 0) { + if (mkdir(DYNAMICBOX_CONF_LOG_PATH, 0755) < 0) { + ErrPrint("Failed to create %s (%s)\n", DYNAMICBOX_CONF_LOG_PATH, strerror(errno)); } } @@ -145,24 +150,24 @@ static inline int app_create(void) script_init(); - if (util_service_is_enabled(SERVICE_FILE)) { + if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_FILE)) { file_service_init(); } - if (util_service_is_enabled(SERVICE_UTILITY)) { + if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_UTILITY)) { utility_service_init(); } #endif - if (util_service_is_enabled(SERVICE_SHORTCUT)) { + if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_SHORTCUT)) { shortcut_service_init(); } - if (util_service_is_enabled(SERVICE_NOTIFICATION)) { + if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_NOTIFICATION)) { notification_service_init(); } - if (util_service_is_enabled(SERVICE_BADGE)) { + if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_BADGE)) { badge_service_init(); } @@ -173,21 +178,21 @@ static inline int app_terminate(void) { int ret; - if (util_service_is_enabled(SERVICE_BADGE)) { + if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_BADGE)) { ret = badge_service_fini(); if (ret < 0) { DbgPrint("badge: %d\n", ret); } } - if (util_service_is_enabled(SERVICE_NOTIFICATION)) { + if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_NOTIFICATION)) { ret = notification_service_fini(); if (ret < 0) { DbgPrint("noti: %d\n", ret); } } - if (util_service_is_enabled(SERVICE_SHORTCUT)) { + if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_SHORTCUT)) { ret = shortcut_service_fini(); if (ret < 0) { DbgPrint("shortcut: %d\n", ret); @@ -195,7 +200,7 @@ static inline int app_terminate(void) } #if defined(HAVE_LIVEBOX) - if (util_service_is_enabled(SERVICE_FILE)) { + if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_FILE)) { ret = file_service_fini(); if (ret < 0) { DbgPrint("Finalize the file service: %d\n", ret); @@ -212,7 +217,7 @@ static inline int app_terminate(void) DbgPrint("dead signal handler finalized: %d\n", ret); } - if (util_service_is_enabled(SERVICE_UTILITY)) { + if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_UTILITY)) { ret = utility_service_fini(); if (ret < 0) { DbgPrint("utility: %d\n", ret); @@ -277,12 +282,14 @@ static Eina_Bool signal_cb(void *data, Ecore_Fd_Handler *handler) fd = ecore_main_fd_handler_fd_get(handler); if (fd < 0) { ErrPrint("Unable to get FD\n"); + ecore_main_fd_handler_del(handler); return ECORE_CALLBACK_CANCEL; } size = read(fd, &fdsi, sizeof(fdsi)); if (size != sizeof(fdsi)) { ErrPrint("Unable to get siginfo: %s\n", strerror(errno)); + ecore_main_fd_handler_del(handler); return ECORE_CALLBACK_CANCEL; } @@ -331,26 +338,25 @@ int main(int argc, char *argv[]) sigset_t mask; Ecore_Fd_Handler *signal_handler = NULL; -#if defined(HAVE_LIVEBOX) - conf_init(); - conf_loader(); +#if defined(FLOG) + __file_log_fp = fopen(TMP_LOG_FILE, "w+t"); + if (!__file_log_fp) { + __file_log_fp = fdopen(1, "w+t"); + } #endif - /*! - * \note - * Clear old contents files before start the master provider. - */ - (void)util_unlink_files(ALWAYS_PATH); - (void)util_unlink_files(READER_PATH); - (void)util_unlink_files(IMAGE_PATH); - (void)util_unlink_files(SLAVE_LOG_PATH); + /* appcore_agent_terminate */ + if (ecore_init() <= 0) { + return -EFAULT; + } - if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) { - util_remove_emergency_disk(); - util_prepare_emergency_disk(); + if (util_screen_init() <= 0) { + ecore_shutdown(); + return -EFAULT; } - util_setup_log_disk(); + dynamicbox_conf_init(); + dynamicbox_conf_load(); /*! * How could we care this return values? @@ -361,19 +367,22 @@ int main(int argc, char *argv[]) ErrPrint("Failed to init the critical log\n"); } -#if defined(FLOG) - __file_log_fp = fopen("/tmp/live.log", "w+t"); - if (!__file_log_fp) { - __file_log_fp = fdopen(1, "w+t"); - } -#endif - /* appcore_agent_terminate */ - if (ecore_init() <= 0) { - CRITICAL_LOG("Failed to initiate ecore\n"); - critical_log_fini(); - return -EFAULT; + /*! + * \note + * Clear old contents files before start the master provider. + */ + (void)util_unlink_files(DYNAMICBOX_CONF_ALWAYS_PATH); + (void)util_unlink_files(DYNAMICBOX_CONF_READER_PATH); + (void)util_unlink_files(DYNAMICBOX_CONF_IMAGE_PATH); + (void)util_unlink_files(DYNAMICBOX_CONF_LOG_PATH); + + if (util_free_space(DYNAMICBOX_CONF_IMAGE_PATH) < DYNAMICBOX_CONF_MINIMUM_SPACE) { + util_remove_emergency_disk(); + util_prepare_emergency_disk(); } + util_setup_log_disk(); + sigemptyset(&mask); ret = sigaddset(&mask, SIGTERM); @@ -404,29 +413,13 @@ int main(int argc, char *argv[]) CRITICAL_LOG("Signal handler initiated: %d\n", ret); } - if (util_screen_init() <= 0) { - CRITICAL_LOG("Failed to ecore x init\n"); - ecore_shutdown(); - critical_log_fini(); - return -EFAULT; - } - ecore_app_args_set(argc, (const char **)argv); #if (GLIB_MAJOR_VERSION <= 2 && GLIB_MINOR_VERSION < 36) g_type_init(); #endif -#if defined(HAVE_LIVEBOX) - /*! - * \note - * conf_update_size requires util_screen_init. - */ - conf_update_size(); -#endif - app_create(); - sd_notify(0, "READY=1"); vconf_get_int(VCONFKEY_MASTER_RESTART_COUNT, &restart_count); @@ -454,7 +447,7 @@ int main(int argc, char *argv[]) } #endif - conf_reset(); + dynamicbox_conf_reset(); return 0; } |