+}
+
+int main(int argc,
+ char *argv[])
+{
+ // process pool - store arg's value
+ app_argc = argc;
+ app_argv = argv;
+
+#ifndef X11
+ // Mesa does a bad job detecting the correct EGL
+ // platform to use, and ends up assuming that the
+ // wrt-client is using X
+ setenv("EGL_PLATFORM", "wayland", 1);
+#endif
+
+ UNHANDLED_EXCEPTION_HANDLER_BEGIN
+ {
+ ADD_PROFILING_POINT("main-entered", "point");
+
+ // Set log tagging
+ DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
+
+ // Set environment variables
+ set_env();
+
+ if (argc > 1 && argv[1] != NULL && !strcmp(argv[1], "-d"))
+ {
+ LogDebug("Entered dummy process mode");
+ sprintf(argv[0], "%s ",
+ DUMMY_PROCESS_PATH);
+
+ // Set 'root' home directory
+ setenv(HOME, ROOT_HOME_PATH, 1);
+
+ LogDebug("Prepare ewk_context");
+ appcore_set_i18n("wrt-client", NULL);
+ ewk_set_arguments(argc, argv);
+ setenv("WRT_LAUNCHING_PERFORMANCE", "1", 1);
+ s_preparedEwkContext = ewk_context_new_with_injected_bundle_path(BUNDLE_PATH);
+
+ if (s_preparedEwkContext == NULL)
+ {
+ LogDebug("Creating webkit context was failed!");
+ exit(-1);
+ }
+
+ int client_fd = __connect_process_pool_server();
+
+ if (client_fd == -1)
+ {
+ LogDebug("Connecting process_pool_server was failed!");
+ exit(-1);
+ }
+
+ // register language changed callback
+ vconf_notify_key_changed(VCONFKEY_LANGSET, vconf_changed_handler, NULL);
+
+ LogDebug("Prepare window_data");
+ // Temporarily change HOME path to app
+ // This change is needed for getting elementary profile
+ // /opt/home/app/.elementary/config/mobile/base.cfg
+ const char* backupEnv = getenv(HOME);
+ if (!backupEnv) {
+ // If getenv return "NULL", set empty string
+ backupEnv = "";
+ }
+ setenv(HOME, APP_HOME_PATH, 1);
+ LogDebug("elm_init()");
+ elm_init(argc, argv);
+ setenv(HOME, backupEnv, 1);
+
+ LogDebug("WindowData()");
+ s_preparedWindowData = new WindowData(static_cast<unsigned long>(getpid()));
+
+ Ecore_Fd_Handler* fd_handler = ecore_main_fd_handler_add(client_fd,
+ (Ecore_Fd_Handler_Flags)(ECORE_FD_READ|ECORE_FD_ERROR),
+ proces_pool_fd_handler, NULL, NULL, NULL);
+
+ if (fd_handler == NULL)
+ {
+ LogDebug("fd_handler is NULL");
+ exit(-1);
+ }
+
+ setpriority(PRIO_PROCESS, 0, 0);