Sync with the latest code of phone profile
[platform/framework/web/data-provider-master.git] / src / main.c
index 6e3e298..631f45c 100644 (file)
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/signalfd.h>
+#include <ctype.h>
 
 #include <Ecore.h>
 #include <Ecore_X.h>
-#include <Evas.h>
-#include <Ecore_Evas.h>
 #include <glib.h>
 #include <glib-object.h>
 #include <aul.h>
@@ -66,8 +65,8 @@ static inline int app_create(void)
 {
        int ret;
 
-       if (access(SLAVE_LOG_PATH, R_OK|W_OK) != 0) {
-               if (mkdir(SLAVE_LOG_PATH, 755) < 0) {
+       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));
                }
        }
@@ -121,13 +120,27 @@ static inline int app_create(void)
 
        event_init();
 
-       shortcut_service_init();
-       notification_service_init();
-       badge_service_init();
-       utility_service_init();
+       if (util_service_is_enabled(SERVICE_SHORTCUT)) {
+               shortcut_service_init();
+       }
+
+       if (util_service_is_enabled(SERVICE_NOTIFICATION)) {
+               notification_service_init();
+       }
+
+       if (util_service_is_enabled(SERVICE_BADGE)) {
+               badge_service_init();
+       }
+
+       if (util_service_is_enabled(SERVICE_UTILITY)) {
+               utility_service_init();
+       }
+
        script_init();
 
-       file_service_init();
+       if (util_service_is_enabled(SERVICE_FILE)) {
+               file_service_init();
+       }
 
        return 0;
 }
@@ -136,8 +149,10 @@ static inline int app_terminate(void)
 {
        int ret;
 
-       ret = file_service_fini();
-       DbgPrint("Finalize the file service: %d\n", ret);
+       if (util_service_is_enabled(SERVICE_FILE)) {
+               ret = file_service_fini();
+               DbgPrint("Finalize the file service: %d\n", ret);
+       }
 
        ret = server_fini();
        DbgPrint("Finalize server: %d\n", ret);
@@ -145,17 +160,25 @@ static inline int app_terminate(void)
        ret = dead_fini();
        DbgPrint("dead signal handler finalized: %d\n", ret);
 
-       ret = utility_service_fini();
-       DbgPrint("utility: %d\n", ret);
+       if (util_service_is_enabled(SERVICE_UTILITY)) {
+               ret = utility_service_fini();
+               DbgPrint("utility: %d\n", ret);
+       }
 
-       ret = badge_service_fini();
-       DbgPrint("badge: %d\n", ret);
+       if (util_service_is_enabled(SERVICE_BADGE)) {
+               ret = badge_service_fini();
+               DbgPrint("badge: %d\n", ret);
+       }
 
-       ret = notification_service_fini();
-       DbgPrint("noti: %d\n", ret);
+       if (util_service_is_enabled(SERVICE_NOTIFICATION)) {
+               ret = notification_service_fini();
+               DbgPrint("noti: %d\n", ret);
+       }
 
-       ret = shortcut_service_fini();
-       DbgPrint("shortcut: %d\n", ret);
+       if (util_service_is_enabled(SERVICE_SHORTCUT)) {
+               ret = shortcut_service_fini();
+               DbgPrint("shortcut: %d\n", ret);
+       }
 
        ret = event_fini();
        DbgPrint("event: %d\n", ret);
@@ -260,6 +283,13 @@ int main(int argc, char *argv[])
        (void)util_unlink_files(IMAGE_PATH);
        (void)util_unlink_files(SLAVE_LOG_PATH);
 
+       if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
+               util_remove_emergency_disk();
+               util_prepare_emergency_disk();
+       }
+
+       util_setup_log_disk();
+
        /*!
         * How could we care this return values?
         * Is there any way to print something on the screen?
@@ -321,24 +351,9 @@ int main(int argc, char *argv[])
 
        ecore_app_args_set(argc, (const char **)argv);
 
-       if (evas_init() <= 0) {
-               CRITICAL_LOG("Failed to init evas return count is below than 0\n");
-               ecore_x_shutdown();
-               ecore_shutdown();
-               critical_log_fini();
-               return -EFAULT;
-       }
-
-       if (ecore_evas_init() <= 0) {
-               CRITICAL_LOG("Failed to init ecore_evas\n");
-               evas_shutdown();
-               ecore_x_shutdown();
-               ecore_shutdown();
-               critical_log_fini();
-               return -EFAULT;
-       }
-
+#if (GLIB_MAJOR_VERSION <= 2 && GLIB_MINOR_VERSION < 36)
        g_type_init();
+#endif
 
        /*!
         * \note
@@ -358,9 +373,6 @@ int main(int argc, char *argv[])
 
        app_terminate();
 
-       evas_shutdown();
-       ecore_evas_shutdown();
-
        ecore_x_shutdown();
 
        if (signal_handler) {