+ // 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);
+
+ LogDebug("ecore_main_loop_begin()");
+ ecore_main_loop_begin();
+ LogDebug("ecore_main_loop_begin()_end");
+
+ // deregister language changed callback
+ vconf_ignore_key_changed(VCONFKEY_LANGSET, vconf_changed_handler);
+
+ std::string tizenId =
+ ClientModule::CommandLineParser::getTizenId(argc, argv);
+ ewk_context_message_post_to_injected_bundle(
+ s_preparedEwkContext,
+ MESSAGE_NAME_INITIALIZE,
+ tizenId.c_str());
+
+ }
+ else
+ {
+ // This code is to fork a web process without exec.
+ std::string tizenId =
+ ClientModule::CommandLineParser::getTizenId(argc, argv);
+
+ if (!tizenId.empty()) {
+ if (UID_ROOT == getuid()) {
+ // Drop root permission
+ // Only launch web application by console command case has root permission
+ if (!ClientModule::SecuritySupport::setAppPrivilege(tizenId)) {
+ LogError("Fail to set app privilege : [" << tizenId << "]");
+ exit(-1);
+ }
+ }
+
+ LogDebug("Launching by fork mode");
+ // Language env setup
+ 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!");
+ Wrt::Popup::PopupInvoker().showInfo("Error", "Creating webkit context was failed.", "OK");
+ exit(-1);
+ }
+
+ // plugin init
+ ewk_context_message_post_to_injected_bundle(
+ s_preparedEwkContext,
+ MESSAGE_NAME_INITIALIZE,
+ tizenId.c_str());
+ }
+ }
+