2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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.
16 #include "wrt-client.h"
19 #include <sys/resource.h>
20 #include <appcore-efl.h>
21 #include <appcore-common.h>
25 #include <dpl/log/log.h>
26 #include <dpl/optional_typedefs.h>
27 #include <dpl/exception.h>
28 #include <common/application_data.h>
29 #include <core_module.h>
30 #include <localization_setting.h>
31 #include <widget_deserialize_model.h>
33 #include <dpl/localization/w3c_file_localization.h>
34 #include <dpl/localization/LanguageTagsProvider.h>
35 #include "webkit/injected-bundle/plugin_module_support.h"
36 #include <popup-runner/PopupInvoker.h>
37 #include <prepare_external_storage.h>
40 #include "process_pool.h"
41 #include "menu_db_util.h"
42 #include "launchpad_util.h"
44 //W3C PACKAGING enviroment variable name
45 #define W3C_DEBUG_ENV_VARIABLE "DEBUG_LOAD_FINISH"
47 // window signal callback
48 const char *EDJE_SHOW_BACKWARD_SIGNAL = "show,backward,signal";
49 const std::string VIEWMODE_TYPE_FULLSCREEN = "fullscreen";
50 const std::string VIEWMODE_TYPE_MAXIMIZED = "maximized";
51 char const* const ELM_SWALLOW_CONTENT = "elm.swallow.content";
52 const char* const BUNDLE_PATH = "/usr/lib/libwrt-injected-bundle.so";
53 const char* const caCertPath = "/opt/usr/share/certs/ca-certificate.crt";
56 const char* const DUMMY_PROCESS_PATH = "/usr/bin/wrt_launchpad_daemon_candidate";
57 static Ewk_Context* s_preparedEwkContext = NULL;
58 static WindowData* s_preparedWindowData = NULL;
59 static int app_argc = 0;
60 static char** app_argv = NULL;
63 const int WIN_ORIENTATION_PORTRAIT_PRIMARY_ANGLE = 0;
64 const int WIN_ORIENTATION_LANDSCAPE_PRIMARY_ANGLE = 270;
65 const int W3C_ORIENTATION_PORTRAIT_PRIMARY_ANGLE = 0;
66 const int W3C_ORIENTATION_LANDSCAPE_PRIMARY_ANGLE = 90;
69 const char* const HOME = "HOME";
70 const char* const APP_HOME_PATH = "/opt/home/app";
72 WrtClient::WrtClient(int argc, char **argv) :
73 Application(argc, argv, "wrt-client", false),
74 DPL::TaskDecl<WrtClient>(this),
75 m_appControlIndex(DPL::OptionalUInt()),
77 m_initializing(false),
82 m_returnStatus(ReturnStatus::Succeeded),
83 m_widgetState(WidgetState::WidgetState_Stopped)
86 LogDebug("App Created");
89 WrtClient::~WrtClient()
91 LogDebug("App Finished");
94 WrtClient::ReturnStatus::Type WrtClient::getReturnStatus() const
96 return m_returnStatus;
99 void WrtClient::OnStop()
101 LogInfo("Stopping Dummy Client");
104 void WrtClient::OnCreate()
106 LogInfo("On Create");
107 ADD_PROFILING_POINT("OnCreate callback", "point");
111 void WrtClient::OnResume()
113 if (m_widgetState != WidgetState_Suspended) {
114 LogWarning("Widget is not suspended, resuming was skipped");
118 m_widgetState = WidgetState_Running;
121 void WrtClient::OnPause()
123 if (m_widgetState != WidgetState_Running) {
124 LogWarning("Widget is not running to be suspended");
128 m_widgetState = WidgetState_Suspended;
131 void WrtClient::OnReset(bundle *b)
134 // bundle argument is freed after OnReset() is returned
135 // So bundle duplication is needed
136 ApplicationDataSingleton::Instance().setBundle(bundle_dup(b));
138 if (true == m_initializing) {
139 LogDebug("can not handle reset event");
142 if (true == m_launched) {
143 if (m_widgetState == WidgetState_Stopped) {
144 LogError("Widget is not running to be reset");
148 m_windowData->emitSignalForUserLayout(EDJE_SHOW_BACKWARD_SIGNAL, "");
149 m_widgetState = WidgetState_Running;
151 if (true == checkArgument()) {
158 // low memory callback set
159 appcore_set_event_callback(
160 APPCORE_EVENT_LOW_MEMORY,
161 WrtClient::appcoreLowMemoryCallback,
165 void WrtClient::OnTerminate()
167 LogDebug("Wrt Shutdown now");
171 void WrtClient::showHelpAndQuit()
173 printf("Usage: wrt-client [OPTION]... [WIDGET: ID]...\n"
175 "Mandatory arguments to long options are mandatory for short "
177 " -h, --help show this help\n"
179 "launch widget with given tizen ID\n"
181 "launch widget with given tizen ID\n"
187 bool WrtClient::checkArgument()
189 std::string tizenId = getTizenIdFromArgument(m_argc, m_argv);
191 if (tizenId.empty()) {
196 tizenId.find(WrtDB::AppControlPrefix::PROCESS_PREFIX);
197 if (pos != std::string::npos) {
198 std::string id = tizenId.substr(pos);
199 id.erase(strlen(WrtDB::AppControlPrefix::PROCESS_PREFIX));
200 std::stringstream s(id);
201 unsigned int appControlIndex;
202 s >> appControlIndex;
203 m_appControlIndex = appControlIndex;
205 LogDebug("app-control execute-index : " << appControlIndex);
208 LogDebug("Tizen id: " << m_tizenId);
213 std::string WrtClient::getTizenIdFromArgument(int argc, char **argv)
215 LogInfo("checkArgument");
216 std::string arg = argv[0];
222 if (arg.find("wrt-client") != std::string::npos) {
229 if (arg == "-h" || arg == "--help") {
231 } else if (arg == "-l" || arg == "--launch" ||
232 arg == "-t" || arg == "--tizen")
242 // Launch widget based on application basename
243 size_t pos = arg.find_last_of('/');
245 if (pos != std::string::npos) {
246 arg = arg.erase(0, pos + 1);
253 void WrtClient::setStep()
257 AddStep(&WrtClient::initStep);
259 setSdkLauncherDebugData();
261 AddStep(&WrtClient::launchStep);
262 AddStep(&WrtClient::shutdownStep);
264 m_initializing = true;
266 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(NextStepEvent());
269 void WrtClient::setSdkLauncherDebugData()
271 LogDebug("setSdkLauncherDebugData");
273 /* check bundle from sdk launcher */
274 bundle *bundleFromSdkLauncher;
275 bundleFromSdkLauncher = bundle_import_from_argv(m_argc, m_argv);
276 const char *bundle_debug = bundle_get_val(bundleFromSdkLauncher, "debug");
277 const char *bundle_pid = bundle_get_val(bundleFromSdkLauncher, "pid");
278 if (bundle_debug != NULL && bundle_pid != NULL) {
279 if (strcmp(bundle_debug, "true") == 0) {
281 m_sdkLauncherPid = atoi(bundle_pid);
286 bundle_free(bundleFromSdkLauncher);
289 bool WrtClient::checkDebugMode(SDKDebugData* debugData)
291 LogError("Checking for debug mode");
294 bool debugMode = debugData->debugMode;
296 LogInfo("[DEBUG_MODE] Widget is launched in " <<
297 (debugMode ? "DEBUG" : "RETAIL") <<
303 void WrtClient::OnEventReceived(const NextStepEvent& /*event*/)
305 LogDebug("Executing next step");
309 void WrtClient::initStep()
312 if (WRT::CoreModuleSingleton::Instance().Init()) {
313 m_initialized = true;
315 m_returnStatus = ReturnStatus::Failed;
316 SwitchToStep(&WrtClient::shutdownStep);
319 // ecore_event_jobs are processed sequentially without concession to
320 // other type events. To give a chance of execute to other events,
321 // ecore_timer_add was used.
322 DPL::Event::ControllerEventHandler<NextStepEvent>::PostTimedEvent(
323 NextStepEvent(), 0.001);
326 void WrtClient::loadFinishCallback(Evas_Object* webview)
328 ADD_PROFILING_POINT("loadFinishCallback", "start");
329 SDKDebugData* debug = new SDKDebugData;
330 debug->debugMode = m_debugMode;
331 debug->pid = new unsigned long(getpid());
333 LogInfo("Post result of launch");
335 // Start inspector server, if current mode is debugger mode.
336 // In the WK2 case, ewk_view_inspector_server_start should
337 // be called after WebProcess is created.
338 if (checkDebugMode(debug)) {
340 ewk_view_inspector_server_start(m_widget->GetCurrentWebview(), 0);
341 if (debug->portnum == 0) {
342 LogWarning("Failed to get portnum");
344 LogInfo("Assigned port number for inspector : "
348 LogDebug("Debug mode is disabled");
351 //w3c packaging test debug (message on 4>)
352 const char * makeScreen = getenv(W3C_DEBUG_ENV_VARIABLE);
353 if (makeScreen != NULL && strcmp(makeScreen, "1") == 0) {
354 FILE* doutput = fdopen(4, "w");
355 fprintf(doutput, "didFinishLoadForFrameCallback: ready\n");
360 LogDebug("Launch succesfull");
363 m_initializing = false;
365 ADD_PROFILING_POINT("loadFinishCallback", "stop");
366 printf("launched\n");
371 m_returnStatus = ReturnStatus::Failed;
373 DPL::Event::ControllerEventHandler<NextStepEvent>::
374 PostEvent(NextStepEvent());
377 if (debug->debugMode) {
378 LogDebug("Send RT signal to wrt-launcher(pid: " << m_sdkLauncherPid);
380 /* send real time signal with result to wrt-launcher */
382 LogDebug("userData->portnum : " << debug->portnum);
383 sv.sival_int = debug->portnum;
387 sigqueue(m_sdkLauncherPid, SIGRTMIN, sv);
390 ApplicationDataSingleton::Instance().freeBundle();
392 LogDebug("Cleaning wrtClient launch resources...");
397 void WrtClient::progressFinishCallback()
399 m_splashScreen->stopSplashScreen();
402 void WrtClient::webkitExitCallback()
404 LogDebug("window close called, terminating app");
405 SwitchToStep(&WrtClient::shutdownStep);
406 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
410 void WrtClient::webCrashCallback()
412 LogError("webProcess crashed");
413 SwitchToStep(&WrtClient::shutdownStep);
414 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
418 void WrtClient::launchStep()
420 ADD_PROFILING_POINT("launchStep", "start");
421 LogDebug("Launching widget ...");
423 ADD_PROFILING_POINT("getRunnableWidgetObject", "start");
424 m_widget = WRT::CoreModuleSingleton::Instance()
425 .getRunnableWidgetObject(m_tizenId, m_appControlIndex);
426 ADD_PROFILING_POINT("getRunnableWidgetObject", "stop");
429 LogError("RunnableWidgetObject is NULL, stop launchStep");
430 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
435 if (m_widgetState == WidgetState_Running) {
436 LogWarning("Widget already running, stop launchStep");
437 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
442 if (m_widgetState == WidgetState_Authorizing) {
443 LogWarning("Widget already authorizing, stop launchStep");
444 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
449 m_dao.reset(new WrtDB::WidgetDAOReadOnly(DPL::FromASCIIString(m_tizenId)));
450 DPL::Optional<DPL::String> defloc = m_dao->getDefaultlocale();
451 if (!defloc.IsNull()) {
452 LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
456 PrepareExternalStorageSingleton::Instance().Initialize(m_dao->getTizenPkgId());
458 /* remove language change callback */
460 LocalizationSetting::SetLanguageChangedCallback(
461 languageChangedCallback, this);
464 ADD_PROFILING_POINT("CreateWindow", "start");
465 if (s_preparedWindowData == NULL) {
466 m_windowData.reset(new WindowData(static_cast<unsigned long>(getpid()), true));
468 m_windowData.reset(s_preparedWindowData);
469 s_preparedWindowData = NULL;
471 ADD_PROFILING_POINT("CreateWindow", "stop");
472 evas_object_show(m_windowData->m_win);
473 // rotate window to initial value
474 setOrientationWindow();
476 WRT::UserDelegatesPtr cbs(new WRT::UserDelegates);
477 ADD_PROFILING_POINT("Create splash screen", "start");
478 m_splashScreen.reset(
479 new SplashScreenSupport(m_windowData->m_win));
480 if (m_splashScreen->createSplashScreen(m_dao->getSplashImgSrc())) {
481 m_splashScreen->startSplashScreen();
482 cbs->progressFinish = DPL::MakeDelegate(
485 progressFinishCallback);
487 ADD_PROFILING_POINT("Create splash screen", "stop");
488 DPL::OptionalString startUrl = W3CFileLocalization::getStartFile(m_dao);
489 if (!m_widget->PrepareView(DPL::ToUTF8String(*startUrl),
490 m_windowData->m_win, s_preparedEwkContext))
492 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
496 // send rotate information to ewk
499 //you can't show window with splash screen before PrepareView
500 //ewk_view_add_with_context() in viewLogic breaks window
502 m_windowData->init();
504 WrtDB::WidgetLocalizedInfo localizedInfo =
505 W3CFileLocalization::getLocalizedInfo(m_dao);
506 std::string name = "";
507 if (!(localizedInfo.name.IsNull())) {
508 name = DPL::ToUTF8String(*(localizedInfo.name));
510 elm_win_title_set(m_windowData->m_win, name.c_str());
512 initializeWindowModes();
513 connectElmCallback();
515 m_widgetState = WidgetState_Authorizing;
516 if (!m_widget->CheckBeforeLaunch()) {
517 LogError("CheckBeforeLaunch failed, stop launchStep");
518 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
522 LogInfo("Widget launch accepted. Entering running state");
523 m_widgetState = WidgetState_Running;
525 cbs->loadFinish = DPL::MakeDelegate(this, &WrtClient::loadFinishCallback);
526 cbs->bufferSet = DPL::MakeDelegate(this, &WrtClient::setLayout);
527 cbs->bufferUnset = DPL::MakeDelegate(this, &WrtClient::unsetLayout);
528 cbs->webkitExit = DPL::MakeDelegate(this, &WrtClient::webkitExitCallback);
529 cbs->webCrash = DPL::MakeDelegate(this, &WrtClient::webCrashCallback);
530 cbs->toggleFullscreen = DPL::MakeDelegate(
531 m_windowData.get(), &WindowData::toggleFullscreen);
533 m_widget->SetUserDelegates(cbs);
536 m_windowData->emitSignalForUserLayout(EDJE_SHOW_BACKWARD_SIGNAL, "");
538 ADD_PROFILING_POINT("launchStep", "stop");
541 void WrtClient::initializeWindowModes()
543 Assert(m_windowData);
545 auto windowModes = m_dao->getWindowModes();
546 bool fullscreen = false;
547 bool backbutton = false;
548 if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
549 WrtDB::WidgetSettings widgetSettings;
550 m_dao->getWidgetSettings(widgetSettings);
551 WidgetSettingList settings(widgetSettings);
553 (settings.getBackButtonPresence() == BackButton_Enable);
556 FOREACH(it, windowModes)
558 std::string viewMode = DPL::ToUTF8String(*it);
559 if (viewMode == VIEWMODE_TYPE_FULLSCREEN) {
562 } else if (viewMode == VIEWMODE_TYPE_MAXIMIZED) {
567 m_windowData->setViewMode(fullscreen,
571 void WrtClient::backButtonCallback(void* data,
572 Evas_Object * /*obj*/,
573 void * /*event_info*/)
575 LogInfo("BackButtonCallback");
578 WrtClient* This = static_cast<WrtClient*>(data);
580 This->m_widget->Backward();
583 int WrtClient::appcoreLowMemoryCallback(void* /*data*/)
585 LogInfo("appcoreLowMemoryCallback");
586 //WrtClient* This = static_cast<WrtClient*>(data);
588 // TODO call RunnableWidgetObject API regarding low memory
589 // The API should be implemented
594 void WrtClient::setOrientationWindow(void)
596 Assert(m_windowData);
599 WrtDB::WidgetSettings widgetSettings;
600 m_dao->getWidgetSettings(widgetSettings);
601 WidgetSettingList settings(widgetSettings);
602 WidgetSettingScreenLock rotationValue = settings.getRotationValue();
603 if (rotationValue == Screen_Portrait) {
604 elm_win_wm_rotation_preferred_rotation_set(
606 WIN_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
607 } else if (rotationValue == Screen_Landscape) {
608 elm_win_wm_rotation_preferred_rotation_set(
610 WIN_ORIENTATION_LANDSCAPE_PRIMARY_ANGLE);
612 elm_win_wm_rotation_preferred_rotation_set(
614 WIN_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
618 void WrtClient::setOrientationEwk(void)
623 WrtDB::WidgetSettings widgetSettings;
624 m_dao->getWidgetSettings(widgetSettings);
625 WidgetSettingList settings(widgetSettings);
626 WidgetSettingScreenLock rotationValue = settings.getRotationValue();
627 if (rotationValue == Screen_Portrait) {
628 ewk_view_orientation_send(
629 m_widget->GetCurrentWebview(),
630 W3C_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
631 } else if (rotationValue == Screen_Landscape) {
632 ewk_view_orientation_send(
633 m_widget->GetCurrentWebview(),
634 W3C_ORIENTATION_LANDSCAPE_PRIMARY_ANGLE);
636 ewk_view_orientation_send(
637 m_widget->GetCurrentWebview(),
638 W3C_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
642 void WrtClient::connectElmCallback()
644 Assert(m_windowData);
646 WrtDB::WidgetSettings widgetSettings;
647 m_dao->getWidgetSettings(widgetSettings);
648 WidgetSettingList settings(widgetSettings);
649 if (settings.getBackButtonPresence() == BackButton_Enable) {
650 m_windowData->addFloatBackButtonCallback(
652 &WrtClient::backButtonCallback,
657 void WrtClient::setLayout(Evas_Object* newBuffer)
659 LogDebug("add new webkit buffer to window");
662 elm_object_part_content_set(m_windowData->m_user_layout,
666 evas_object_show(newBuffer);
669 void WrtClient::unsetLayout(Evas_Object* currentBuffer)
671 LogDebug("remove current webkit buffer from window");
672 Assert(currentBuffer);
673 evas_object_hide(currentBuffer);
675 elm_object_part_content_unset(m_windowData->m_user_layout,
676 ELM_SWALLOW_CONTENT);
679 void WrtClient::shutdownStep()
681 LogDebug("Closing Wrt connection ...");
683 if (m_widget && m_widgetState) {
684 m_widgetState = WidgetState_Stopped;
687 ewk_context_delete(s_preparedEwkContext);
688 PrepareExternalStorageSingleton::Instance().Deinitialize();
689 WRT::CoreModuleSingleton::Instance().Terminate();
692 m_initialized = false;
694 m_windowData.reset();
698 int WrtClient::languageChangedCallback(void *data)
700 LogDebug("Language Changed");
704 WrtClient* wrtClient = static_cast<WrtClient*>(data);
705 if (!(wrtClient->m_dao)) {
709 // reset function fetches system locales and recreates language tags
710 LanguageTagsProviderSingleton::Instance().resetLanguageTags();
711 // widget default locales are added to language tags below
712 DPL::OptionalString defloc = wrtClient->m_dao->getDefaultlocale();
713 if (!defloc.IsNull()) {
714 LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
718 if (wrtClient->m_launched &&
719 wrtClient->m_widgetState != WidgetState_Stopped)
721 wrtClient->m_widget->ReloadStartPage();
726 void WrtClient::Quit()
729 DPL::Application::Quit();
732 static Eina_Bool proces_pool_fd_handler(void* /*data*/, Ecore_Fd_Handler *handler)
734 int fd = ecore_main_fd_handler_fd_get(handler);
736 if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR))
738 LogDebug("ECORE_FD_ERROR");
746 return ECORE_CALLBACK_CANCEL;
749 if (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ))
751 LogDebug("ECORE_FD_READ");
753 app_pkt_t* pkt = (app_pkt_t*) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
754 memset(pkt, 0, AUL_SOCK_MAXBUFF);
756 int recv_ret = recv(fd, pkt, AUL_SOCK_MAXBUFF, 0);
765 LogDebug("recv error!");
768 LogDebug("recv_ret : " << recv_ret << ", pkt->len : " << pkt->len);
770 ecore_main_fd_handler_del(handler);
772 __wrt_launchpad_main_loop(pkt, app_argv[0], &app_argc, &app_argv);
777 ecore_main_loop_quit();
778 return ECORE_CALLBACK_CANCEL;
781 return ECORE_CALLBACK_CANCEL;
784 static void vconf_changed_handler(keynode_t* /*key*/, void* /*data*/)
786 LogInfo("VCONFKEY_LANGSET vconf-key was changed!");
788 // When system language is changed, the candidate process will be created again.
794 // set evas backend type
795 if (!getenv("ELM_ENGINE"))
797 if (!setenv("ELM_ENGINE", "gl", 1))
799 LogDebug("Enable backend");
804 LogDebug("ELM_ENGINE : " << getenv("ELM_ENGINE"));
808 setenv("COREGL_FASTPATH", "1", 1);
810 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
811 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
812 setenv("ELM_IMAGE_CACHE", "0", 1);
818 // process pool - store arg's value
822 UNHANDLED_EXCEPTION_HANDLER_BEGIN
824 ADD_PROFILING_POINT("main-entered", "point");
827 DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
829 // Set environment variables
832 if (argc > 1 && argv[1] != NULL && !strcmp(argv[1], "-d"))
834 LogInfo("Entered dummy process mode");
835 sprintf(argv[0], "%s ",
838 LogInfo("Prepare ewk_context");
839 appcore_set_i18n("wrt-client", NULL);
840 ewk_set_arguments(argc, argv);
841 setenv("WRT_LAUNCHING_PERFORMANCE", "1", 1);
842 s_preparedEwkContext = ewk_context_new_with_injected_bundle_path(BUNDLE_PATH);
844 if (s_preparedEwkContext == NULL)
846 LogInfo("Creating webkit context was failed!");
850 int client_fd = __connect_process_pool_server();
854 LogInfo("Connecting process_pool_server was failed!");
858 // register language changed callback
859 vconf_notify_key_changed(VCONFKEY_LANGSET, vconf_changed_handler, NULL);
861 LogInfo("Prepare window_data");
862 // Temporarily change HOME path to app
863 // This change is needed for getting elementary profile
864 // /opt/home/app/.elementary/config/mobile/base.cfg
865 const char* backupEnv = getenv(HOME);
866 setenv(HOME, APP_HOME_PATH, 1);
867 LogInfo("elm_init()");
868 elm_init(argc, argv);
869 setenv(HOME, backupEnv, 1);
871 LogInfo("WindowData()");
872 s_preparedWindowData = new WindowData(static_cast<unsigned long>(getpid()));
874 Ecore_Fd_Handler* fd_handler = ecore_main_fd_handler_add(client_fd,
875 (Ecore_Fd_Handler_Flags)(ECORE_FD_READ|ECORE_FD_ERROR),
876 proces_pool_fd_handler, NULL, NULL, NULL);
878 if (fd_handler == NULL)
880 LogInfo("fd_handler is NULL");
884 setpriority(PRIO_PROCESS, 0, 0);
886 LogDebug("ecore_main_loop_begin()");
887 ecore_main_loop_begin();
888 LogDebug("ecore_main_loop_begin()_end");
890 // deregister language changed callback
891 vconf_ignore_key_changed(VCONFKEY_LANGSET, vconf_changed_handler);
893 std::string tizenId = WrtClient::getTizenIdFromArgument(argc, argv);
894 PluginModuleSupport::init(s_preparedEwkContext, tizenId);
898 // This code is to fork a web process without exec.
899 std::string tizenId = WrtClient::getTizenIdFromArgument(argc, argv);
900 if (!tizenId.empty()) {
902 tizenId.find(WrtDB::AppControlPrefix::PROCESS_PREFIX);
903 if (pos != std::string::npos) {
907 LogDebug("Launching by fork mode");
908 // Language env setup
909 appcore_set_i18n("wrt-client", NULL);
910 ewk_set_arguments(argc, argv);
911 setenv("WRT_LAUNCHING_PERFORMANCE", "1", 1);
912 s_preparedEwkContext = ewk_context_new_with_injected_bundle_path(
915 if (s_preparedEwkContext == NULL)
917 LogInfo("Creating webkit context was failed!");
918 Wrt::Popup::PopupInvoker().showInfo("Error", "Creating webkit context was failed.", "OK");
923 PluginModuleSupport::init(s_preparedEwkContext, tizenId);
928 // Output on stdout will be flushed after every newline character,
929 // even if it is redirected to a pipe. This is useful for running
930 // from a script and parsing output.
931 // (Standard behavior of stdlib is to use full buffering when
932 // redirected to a pipe, which means even after an end of line
933 // the output may not be flushed).
936 WrtClient app(app_argc, app_argv);
938 ADD_PROFILING_POINT("Before appExec", "point");
939 int ret = app.Exec();
940 LogDebug("App returned: " << ret);
941 ret = app.getReturnStatus();
942 LogDebug("WrtClient returned: " << ret);
945 UNHANDLED_EXCEPTION_HANDLER_END