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 char* const HOME = "HOME";
64 const char* const APP_HOME_PATH = "/opt/home/app";
66 WrtClient::WrtClient(int argc, char **argv) :
67 Application(argc, argv, "wrt-client", false),
68 DPL::TaskDecl<WrtClient>(this),
69 m_appControlIndex(DPL::OptionalUInt()),
71 m_initializing(false),
76 m_returnStatus(ReturnStatus::Succeeded),
77 m_widgetState(WidgetState::WidgetState_Stopped)
80 LogDebug("App Created");
83 WrtClient::~WrtClient()
85 LogDebug("App Finished");
88 WrtClient::ReturnStatus::Type WrtClient::getReturnStatus() const
90 return m_returnStatus;
93 void WrtClient::OnStop()
95 LogInfo("Stopping Dummy Client");
98 void WrtClient::OnCreate()
100 LogInfo("On Create");
101 ADD_PROFILING_POINT("OnCreate callback", "point");
105 void WrtClient::OnResume()
107 if (m_widgetState != WidgetState_Suspended) {
108 LogWarning("Widget is not suspended, resuming was skipped");
112 m_widgetState = WidgetState_Running;
115 void WrtClient::OnPause()
117 if (m_widgetState != WidgetState_Running) {
118 LogWarning("Widget is not running to be suspended");
122 m_widgetState = WidgetState_Suspended;
125 void WrtClient::OnReset(bundle *b)
128 // bundle argument is freed after OnReset() is returned
129 // So bundle duplication is needed
130 ApplicationDataSingleton::Instance().setBundle(bundle_dup(b));
131 ApplicationDataSingleton::Instance().setEncodedBundle(b);
133 if (true == m_initializing) {
134 LogDebug("can not handle reset event");
137 if (true == m_launched) {
138 if (m_widgetState == WidgetState_Stopped) {
139 LogError("Widget is not running to be reset");
143 m_windowData->emitSignalForUserLayout(EDJE_SHOW_BACKWARD_SIGNAL, "");
144 m_widgetState = WidgetState_Running;
146 if (true == checkArgument()) {
153 // low memory callback set
154 appcore_set_event_callback(
155 APPCORE_EVENT_LOW_MEMORY,
156 WrtClient::appcoreLowMemoryCallback,
160 void WrtClient::OnTerminate()
162 LogDebug("Wrt Shutdown now");
166 void WrtClient::showHelpAndQuit()
168 printf("Usage: wrt-client [OPTION]... [WIDGET: ID]...\n"
170 "Mandatory arguments to long options are mandatory for short "
172 " -h, --help show this help\n"
174 "launch widget with given tizen ID\n"
176 "launch widget with given tizen ID\n"
182 bool WrtClient::checkArgument()
184 std::string tizenId = getTizenIdFromArgument(m_argc, m_argv);
186 if (tizenId.empty()) {
191 tizenId.find(WrtDB::AppControlPrefix::PROCESS_PREFIX);
192 if (pos != std::string::npos) {
193 std::string id = tizenId.substr(pos);
194 id.erase(strlen(WrtDB::AppControlPrefix::PROCESS_PREFIX));
195 std::stringstream s(id);
196 unsigned int appControlIndex;
197 s >> appControlIndex;
198 m_appControlIndex = appControlIndex;
200 LogDebug("app-control execute-index : " << appControlIndex);
203 LogDebug("Tizen id: " << m_tizenId);
208 std::string WrtClient::getTizenIdFromArgument(int argc, char **argv)
210 LogInfo("checkArgument");
211 std::string arg = argv[0];
217 if (arg.find("wrt-client") != std::string::npos) {
224 if (arg == "-h" || arg == "--help") {
226 } else if (arg == "-l" || arg == "--launch" ||
227 arg == "-t" || arg == "--tizen")
237 // Launch widget based on application basename
238 size_t pos = arg.find_last_of('/');
240 if (pos != std::string::npos) {
241 arg = arg.erase(0, pos + 1);
248 void WrtClient::setStep()
252 AddStep(&WrtClient::initStep);
254 setSdkLauncherDebugData();
256 AddStep(&WrtClient::launchStep);
257 AddStep(&WrtClient::shutdownStep);
259 m_initializing = true;
261 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(NextStepEvent());
264 void WrtClient::setSdkLauncherDebugData()
266 LogDebug("setSdkLauncherDebugData");
268 /* check bundle from sdk launcher */
269 bundle *bundleFromSdkLauncher;
270 bundleFromSdkLauncher = bundle_import_from_argv(m_argc, m_argv);
271 const char *bundle_debug = bundle_get_val(bundleFromSdkLauncher, "debug");
272 const char *bundle_pid = bundle_get_val(bundleFromSdkLauncher, "pid");
273 if (bundle_debug != NULL && bundle_pid != NULL) {
274 if (strcmp(bundle_debug, "true") == 0) {
276 m_sdkLauncherPid = atoi(bundle_pid);
281 bundle_free(bundleFromSdkLauncher);
284 bool WrtClient::checkDebugMode(SDKDebugData* debugData)
286 LogError("Checking for debug mode");
289 bool debugMode = debugData->debugMode;
291 LogInfo("[DEBUG_MODE] Widget is launched in " <<
292 (debugMode ? "DEBUG" : "RETAIL") <<
298 void WrtClient::OnEventReceived(const NextStepEvent& /*event*/)
300 LogDebug("Executing next step");
304 void WrtClient::initStep()
307 if (WRT::CoreModuleSingleton::Instance().Init()) {
308 m_initialized = true;
310 m_returnStatus = ReturnStatus::Failed;
311 SwitchToStep(&WrtClient::shutdownStep);
314 // ecore_event_jobs are processed sequentially without concession to
315 // other type events. To give a chance of execute to other events,
316 // ecore_timer_add was used.
317 DPL::Event::ControllerEventHandler<NextStepEvent>::PostTimedEvent(
318 NextStepEvent(), 0.001);
321 void WrtClient::loadFinishCallback(Evas_Object* webview)
323 ADD_PROFILING_POINT("loadFinishCallback", "start");
324 SDKDebugData* debug = new SDKDebugData;
325 debug->debugMode = m_debugMode;
326 debug->pid = new unsigned long(getpid());
328 LogInfo("Post result of launch");
330 // Start inspector server, if current mode is debugger mode.
331 // In the WK2 case, ewk_view_inspector_server_start should
332 // be called after WebProcess is created.
333 if (checkDebugMode(debug)) {
335 ewk_view_inspector_server_start(m_widget->GetCurrentWebview(), 0);
336 if (debug->portnum == 0) {
337 LogWarning("Failed to get portnum");
339 LogInfo("Assigned port number for inspector : "
343 LogDebug("Debug mode is disabled");
346 //w3c packaging test debug (message on 4>)
347 const char * makeScreen = getenv(W3C_DEBUG_ENV_VARIABLE);
348 if (makeScreen != NULL && strcmp(makeScreen, "1") == 0) {
349 FILE* doutput = fdopen(4, "w");
350 fprintf(doutput, "didFinishLoadForFrameCallback: ready\n");
355 LogDebug("Launch succesfull");
358 m_initializing = false;
360 ADD_PROFILING_POINT("loadFinishCallback", "stop");
361 printf("launched\n");
366 m_returnStatus = ReturnStatus::Failed;
368 DPL::Event::ControllerEventHandler<NextStepEvent>::
369 PostEvent(NextStepEvent());
372 if (debug->debugMode) {
373 LogDebug("Send RT signal to wrt-launcher(pid: " << m_sdkLauncherPid);
375 /* send real time signal with result to wrt-launcher */
377 LogDebug("userData->portnum : " << debug->portnum);
378 sv.sival_int = debug->portnum;
382 sigqueue(m_sdkLauncherPid, SIGRTMIN, sv);
385 ApplicationDataSingleton::Instance().freeBundle();
387 LogDebug("Cleaning wrtClient launch resources...");
392 void WrtClient::progressFinishCallback()
394 m_splashScreen->stopSplashScreen();
397 void WrtClient::webkitExitCallback()
399 LogDebug("window close called, terminating app");
400 SwitchToStep(&WrtClient::shutdownStep);
401 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
405 void WrtClient::webCrashCallback()
407 LogError("webProcess crashed");
408 SwitchToStep(&WrtClient::shutdownStep);
409 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
413 void WrtClient::launchStep()
415 ADD_PROFILING_POINT("launchStep", "start");
416 LogDebug("Launching widget ...");
418 ADD_PROFILING_POINT("getRunnableWidgetObject", "start");
419 m_widget = WRT::CoreModuleSingleton::Instance()
420 .getRunnableWidgetObject(m_tizenId, m_appControlIndex);
421 ADD_PROFILING_POINT("getRunnableWidgetObject", "stop");
424 LogError("RunnableWidgetObject is NULL, stop launchStep");
425 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
430 if (m_widgetState == WidgetState_Running) {
431 LogWarning("Widget already running, stop launchStep");
432 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
437 if (m_widgetState == WidgetState_Authorizing) {
438 LogWarning("Widget already authorizing, stop launchStep");
439 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
444 m_dao.reset(new WrtDB::WidgetDAOReadOnly(DPL::FromASCIIString(m_tizenId)));
445 DPL::Optional<DPL::String> defloc = m_dao->getDefaultlocale();
446 if (!defloc.IsNull()) {
447 LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
451 PrepareExternalStorageSingleton::Instance().Initialize(m_dao->getTizenPkgId());
453 /* remove language change callback */
455 LocalizationSetting::SetLanguageChangedCallback(
456 languageChangedCallback, this);
459 ADD_PROFILING_POINT("CreateWindow", "start");
460 if (s_preparedWindowData == NULL) {
461 m_windowData.reset(new WindowData(static_cast<unsigned long>(getpid()), true));
463 m_windowData.reset(s_preparedWindowData);
464 s_preparedWindowData = NULL;
466 ADD_PROFILING_POINT("CreateWindow", "stop");
467 evas_object_show(m_windowData->m_win);
468 // rotate window to initial value
469 setOrientationWindow();
471 WRT::UserDelegatesPtr cbs(new WRT::UserDelegates);
472 ADD_PROFILING_POINT("Create splash screen", "start");
473 m_splashScreen.reset(
474 new SplashScreenSupport(m_windowData->m_win));
475 if (m_splashScreen->createSplashScreen(m_dao->getSplashImgSrc())) {
476 m_splashScreen->startSplashScreen();
477 cbs->progressFinish = DPL::MakeDelegate(
480 progressFinishCallback);
482 ADD_PROFILING_POINT("Create splash screen", "stop");
483 DPL::OptionalString startUrl = W3CFileLocalization::getStartFile(m_dao);
484 if (!m_widget->PrepareView(DPL::ToUTF8String(*startUrl),
485 m_windowData->m_win, s_preparedEwkContext))
487 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
491 // send rotate information to ewk
494 //you can't show window with splash screen before PrepareView
495 //ewk_view_add_with_context() in viewLogic breaks window
497 m_windowData->init();
499 WrtDB::WidgetLocalizedInfo localizedInfo =
500 W3CFileLocalization::getLocalizedInfo(m_dao);
501 std::string name = "";
502 if (!(localizedInfo.name.IsNull())) {
503 name = DPL::ToUTF8String(*(localizedInfo.name));
505 elm_win_title_set(m_windowData->m_win, name.c_str());
507 initializeWindowModes();
508 connectElmCallback();
510 m_widgetState = WidgetState_Authorizing;
511 if (!m_widget->CheckBeforeLaunch()) {
512 LogError("CheckBeforeLaunch failed, stop launchStep");
513 DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
517 LogInfo("Widget launch accepted. Entering running state");
518 m_widgetState = WidgetState_Running;
520 cbs->loadFinish = DPL::MakeDelegate(this, &WrtClient::loadFinishCallback);
521 cbs->bufferSet = DPL::MakeDelegate(this, &WrtClient::setLayout);
522 cbs->bufferUnset = DPL::MakeDelegate(this, &WrtClient::unsetLayout);
523 cbs->webkitExit = DPL::MakeDelegate(this, &WrtClient::webkitExitCallback);
524 cbs->webCrash = DPL::MakeDelegate(this, &WrtClient::webCrashCallback);
525 cbs->toggleFullscreen = DPL::MakeDelegate(
526 m_windowData.get(), &WindowData::toggleFullscreen);
528 m_widget->SetUserDelegates(cbs);
531 m_windowData->emitSignalForUserLayout(EDJE_SHOW_BACKWARD_SIGNAL, "");
533 ADD_PROFILING_POINT("launchStep", "stop");
536 void WrtClient::initializeWindowModes()
538 Assert(m_windowData);
540 auto windowModes = m_dao->getWindowModes();
541 bool fullscreen = false;
542 bool backbutton = false;
543 if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
544 WrtDB::WidgetSettings widgetSettings;
545 m_dao->getWidgetSettings(widgetSettings);
546 WidgetSettingList settings(widgetSettings);
548 (settings.getBackButtonPresence() == BackButton_Enable);
551 FOREACH(it, windowModes)
553 std::string viewMode = DPL::ToUTF8String(*it);
554 if (viewMode == VIEWMODE_TYPE_FULLSCREEN) {
557 } else if (viewMode == VIEWMODE_TYPE_MAXIMIZED) {
562 m_windowData->setViewMode(fullscreen,
566 void WrtClient::backButtonCallback(void* data,
567 Evas_Object * /*obj*/,
568 void * /*event_info*/)
570 LogInfo("BackButtonCallback");
573 WrtClient* This = static_cast<WrtClient*>(data);
575 This->m_widget->Backward();
578 int WrtClient::appcoreLowMemoryCallback(void* /*data*/)
580 LogInfo("appcoreLowMemoryCallback");
581 //WrtClient* This = static_cast<WrtClient*>(data);
583 // TODO call RunnableWidgetObject API regarding low memory
584 // The API should be implemented
589 void WrtClient::setOrientationWindow(void)
591 Assert(m_windowData);
594 WrtDB::WidgetSettings widgetSettings;
595 m_dao->getWidgetSettings(widgetSettings);
596 WidgetSettingList settings(widgetSettings);
597 WidgetSettingScreenLock rotationValue = settings.getRotationValue();
598 if (rotationValue == Screen_Portrait) {
599 elm_win_wm_rotation_preferred_rotation_set(
601 OrientationAngle::Window::Portrait::PRIMARY);
602 } else if (rotationValue == Screen_Landscape) {
603 elm_win_wm_rotation_preferred_rotation_set(
605 OrientationAngle::Window::Landscape::PRIMARY);
606 } else if (rotationValue == Screen_AutoRotation) {
607 LogInfo("Nothing to do");
609 elm_win_wm_rotation_preferred_rotation_set(
611 OrientationAngle::W3C::Portrait::PRIMARY);
615 void WrtClient::unsetOrientationWindow(void)
617 Assert(m_windowData);
620 WrtDB::WidgetSettings widgetSettings;
621 m_dao->getWidgetSettings(widgetSettings);
622 WidgetSettingList settings(widgetSettings);
623 WidgetSettingScreenLock rotationValue = settings.getRotationValue();
624 if (rotationValue == Screen_AutoRotation) {
625 LogInfo("Nothing to do");
630 void WrtClient::setOrientationEwk(void)
635 WrtDB::WidgetSettings widgetSettings;
636 m_dao->getWidgetSettings(widgetSettings);
637 WidgetSettingList settings(widgetSettings);
638 WidgetSettingScreenLock rotationValue = settings.getRotationValue();
639 if (rotationValue == Screen_Portrait) {
640 ewk_view_orientation_send(
641 m_widget->GetCurrentWebview(),
642 OrientationAngle::W3C::Portrait::PRIMARY);
643 } else if (rotationValue == Screen_Landscape) {
644 ewk_view_orientation_send(
645 m_widget->GetCurrentWebview(),
646 OrientationAngle::W3C::Landscape::PRIMARY);
647 } else if (rotationValue == Screen_AutoRotation) {
648 ewk_view_orientation_send(
649 m_widget->GetCurrentWebview(),
650 OrientationAngle::W3C::Portrait::PRIMARY);
652 ewk_view_orientation_send(
653 m_widget->GetCurrentWebview(),
654 OrientationAngle::W3C::Portrait::PRIMARY);
658 void WrtClient::connectElmCallback()
660 Assert(m_windowData);
662 WrtDB::WidgetSettings widgetSettings;
663 m_dao->getWidgetSettings(widgetSettings);
664 WidgetSettingList settings(widgetSettings);
665 if (settings.getBackButtonPresence() == BackButton_Enable) {
666 m_windowData->addFloatBackButtonCallback(
668 &WrtClient::backButtonCallback,
673 void WrtClient::setLayout(Evas_Object* newBuffer)
675 LogDebug("add new webkit buffer to window");
678 elm_object_part_content_set(m_windowData->m_user_layout,
682 evas_object_show(newBuffer);
685 void WrtClient::unsetLayout(Evas_Object* currentBuffer)
687 LogDebug("remove current webkit buffer from window");
688 Assert(currentBuffer);
689 evas_object_hide(currentBuffer);
691 elm_object_part_content_unset(m_windowData->m_user_layout,
692 ELM_SWALLOW_CONTENT);
695 void WrtClient::shutdownStep()
697 LogDebug("Closing Wrt connection ...");
699 if (m_widget && m_widgetState) {
700 m_widgetState = WidgetState_Stopped;
702 // AutoRotation use m_widget pointer internally.
703 // It must be unset before m_widget is released.
704 unsetOrientationWindow();
706 ewk_context_delete(s_preparedEwkContext);
707 PrepareExternalStorageSingleton::Instance().Deinitialize();
708 WRT::CoreModuleSingleton::Instance().Terminate();
711 m_initialized = false;
713 m_windowData.reset();
717 int WrtClient::languageChangedCallback(void *data)
719 LogDebug("Language Changed");
723 WrtClient* wrtClient = static_cast<WrtClient*>(data);
724 if (!(wrtClient->m_dao)) {
728 // reset function fetches system locales and recreates language tags
729 LanguageTagsProviderSingleton::Instance().resetLanguageTags();
730 // widget default locales are added to language tags below
731 DPL::OptionalString defloc = wrtClient->m_dao->getDefaultlocale();
732 if (!defloc.IsNull()) {
733 LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
737 if (wrtClient->m_launched &&
738 wrtClient->m_widgetState != WidgetState_Stopped)
740 wrtClient->m_widget->ReloadStartPage();
745 void WrtClient::Quit()
748 DPL::Application::Quit();
751 static Eina_Bool proces_pool_fd_handler(void* /*data*/, Ecore_Fd_Handler *handler)
753 int fd = ecore_main_fd_handler_fd_get(handler);
755 if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR))
757 LogDebug("ECORE_FD_ERROR");
765 return ECORE_CALLBACK_CANCEL;
768 if (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ))
770 LogDebug("ECORE_FD_READ");
772 app_pkt_t* pkt = (app_pkt_t*) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
773 memset(pkt, 0, AUL_SOCK_MAXBUFF);
775 int recv_ret = recv(fd, pkt, AUL_SOCK_MAXBUFF, 0);
784 LogDebug("recv error!");
787 LogDebug("recv_ret : " << recv_ret << ", pkt->len : " << pkt->len);
789 ecore_main_fd_handler_del(handler);
791 __wrt_launchpad_main_loop(pkt, app_argv[0], &app_argc, &app_argv);
796 ecore_main_loop_quit();
797 return ECORE_CALLBACK_CANCEL;
800 return ECORE_CALLBACK_CANCEL;
803 static void vconf_changed_handler(keynode_t* /*key*/, void* /*data*/)
805 LogInfo("VCONFKEY_LANGSET vconf-key was changed!");
807 // When system language is changed, the candidate process will be created again.
813 // set evas backend type
814 if (!getenv("ELM_ENGINE"))
816 if (!setenv("ELM_ENGINE", "gl", 1))
818 LogDebug("Enable backend");
823 LogDebug("ELM_ENGINE : " << getenv("ELM_ENGINE"));
827 setenv("COREGL_FASTPATH", "1", 1);
829 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
830 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
831 setenv("ELM_IMAGE_CACHE", "0", 1);
837 // process pool - store arg's value
841 UNHANDLED_EXCEPTION_HANDLER_BEGIN
843 ADD_PROFILING_POINT("main-entered", "point");
846 DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
848 // Set environment variables
851 if (argc > 1 && argv[1] != NULL && !strcmp(argv[1], "-d"))
853 LogInfo("Entered dummy process mode");
854 sprintf(argv[0], "%s ",
857 LogInfo("Prepare ewk_context");
858 appcore_set_i18n("wrt-client", NULL);
859 ewk_set_arguments(argc, argv);
860 setenv("WRT_LAUNCHING_PERFORMANCE", "1", 1);
861 s_preparedEwkContext = ewk_context_new_with_injected_bundle_path(BUNDLE_PATH);
863 if (s_preparedEwkContext == NULL)
865 LogInfo("Creating webkit context was failed!");
869 int client_fd = __connect_process_pool_server();
873 LogInfo("Connecting process_pool_server was failed!");
877 // register language changed callback
878 vconf_notify_key_changed(VCONFKEY_LANGSET, vconf_changed_handler, NULL);
880 LogInfo("Prepare window_data");
881 // Temporarily change HOME path to app
882 // This change is needed for getting elementary profile
883 // /opt/home/app/.elementary/config/mobile/base.cfg
884 const char* backupEnv = getenv(HOME);
885 setenv(HOME, APP_HOME_PATH, 1);
886 LogInfo("elm_init()");
887 elm_init(argc, argv);
888 setenv(HOME, backupEnv, 1);
890 LogInfo("WindowData()");
891 s_preparedWindowData = new WindowData(static_cast<unsigned long>(getpid()));
893 Ecore_Fd_Handler* fd_handler = ecore_main_fd_handler_add(client_fd,
894 (Ecore_Fd_Handler_Flags)(ECORE_FD_READ|ECORE_FD_ERROR),
895 proces_pool_fd_handler, NULL, NULL, NULL);
897 if (fd_handler == NULL)
899 LogInfo("fd_handler is NULL");
903 setpriority(PRIO_PROCESS, 0, 0);
905 LogDebug("ecore_main_loop_begin()");
906 ecore_main_loop_begin();
907 LogDebug("ecore_main_loop_begin()_end");
909 // deregister language changed callback
910 vconf_ignore_key_changed(VCONFKEY_LANGSET, vconf_changed_handler);
912 std::string tizenId = WrtClient::getTizenIdFromArgument(argc, argv);
913 PluginModuleSupport::init(s_preparedEwkContext, tizenId);
917 // This code is to fork a web process without exec.
918 std::string tizenId = WrtClient::getTizenIdFromArgument(argc, argv);
919 if (!tizenId.empty()) {
921 tizenId.find(WrtDB::AppControlPrefix::PROCESS_PREFIX);
922 if (pos != std::string::npos) {
926 LogDebug("Launching by fork mode");
927 // Language env setup
928 appcore_set_i18n("wrt-client", NULL);
929 ewk_set_arguments(argc, argv);
930 setenv("WRT_LAUNCHING_PERFORMANCE", "1", 1);
931 s_preparedEwkContext = ewk_context_new_with_injected_bundle_path(
934 if (s_preparedEwkContext == NULL)
936 LogInfo("Creating webkit context was failed!");
937 Wrt::Popup::PopupInvoker().showInfo("Error", "Creating webkit context was failed.", "OK");
942 PluginModuleSupport::init(s_preparedEwkContext, tizenId);
947 // Output on stdout will be flushed after every newline character,
948 // even if it is redirected to a pipe. This is useful for running
949 // from a script and parsing output.
950 // (Standard behavior of stdlib is to use full buffering when
951 // redirected to a pipe, which means even after an end of line
952 // the output may not be flushed).
955 WrtClient app(app_argc, app_argv);
957 ADD_PROFILING_POINT("Before appExec", "point");
958 int ret = app.Exec();
959 LogDebug("App returned: " << ret);
960 ret = app.getReturnStatus();
961 LogDebug("WrtClient returned: " << ret);
964 UNHANDLED_EXCEPTION_HANDLER_END