update wrt_0.8.107
[platform/framework/web/wrt.git] / src / wrt-client / wrt-client.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #include "wrt-client.h"
17 #include <cstdlib>
18 #include <cstdio>
19 #include <string>
20 #include <dpl/log/log.h>
21 #include <dpl/optional_typedefs.h>
22 #include <common/application_data.h>
23 #include <core_module.h>
24 #include <global_logic.h>
25 #include <widget_model.h>
26 #include <widget_localize_model.h>
27 #include <localization_setting.h>
28 #include <widget_deserialize_model.h>
29 #include <launch_user_data.h>
30 #include <EWebKit2.h>
31 #include <dpl/localization/w3c_file_localization.h>
32 #include <dpl/localization/LanguageTagsProvider.h>
33
34 //W3C PACKAGING enviroment variable name
35 #define W3C_DEBUG_ENV_VARIABLE "DEBUG_LOAD_FINISH"
36
37 // window signal callback
38 const char *EDJE_SHOW_BACKWARD_SIGNAL = "show,backward,signal";
39 const std::string VIEWMODE_TYPE_FULLSCREEN = "fullscreen";
40 const std::string VIEWMODE_TYPE_MAXIMIZED = "maximized";
41
42 WrtClient::WrtClient(int argc, char **argv) :
43     Application(argc, argv, "wrt-client", false),
44     DPL::TaskDecl<WrtClient>(this),
45     m_launched(false),
46     m_initializing(false),
47     m_initialized(false),
48     m_sdkLauncherPid(0),
49     m_debugMode(false),
50     m_debuggerPort(0),
51     m_returnStatus(ReturnStatus::Succeeded),
52     m_widgetState(WidgetState::WidgetState_Stopped)
53 {
54     Touch();
55     LogDebug("App Created");
56 }
57
58 WrtClient::~WrtClient()
59 {
60     LogDebug("App Finished");
61 }
62
63 WrtClient::ReturnStatus::Type WrtClient::getReturnStatus() const
64 {
65     return m_returnStatus;
66 }
67
68 void WrtClient::OnStop()
69 {
70     LogInfo("Stopping Dummy Client");
71 }
72
73
74 void WrtClient::OnCreate()
75 {
76     LogInfo("On Create");
77 }
78
79
80 void WrtClient::OnResume()
81 {
82     if (m_widgetState != WidgetState_Suspended) {
83         LogWarning("Widget is not suspended, resuming was skipped");
84         return;
85     }
86     m_widget->Resume();
87     evas_object_focus_set(m_widget->GetCurrentWebview(), EINA_TRUE);
88     m_widgetState = WidgetState_Running;
89 }
90
91
92 void WrtClient::OnPause()
93 {
94     if (m_widgetState != WidgetState_Running) {
95         LogWarning("Widget is not running to be suspended");
96         return;
97     }
98     m_widget->Suspend();
99     evas_object_focus_set(m_widget->GetCurrentWebview(), EINA_FALSE);
100     m_widgetState = WidgetState_Suspended;
101 }
102
103 void WrtClient::OnReset(bundle *b)
104 {
105     LogDebug("OnReset");
106     // bundle argument is freed after OnReset() is returned
107     // So bundle duplication is needed
108     ApplicationDataSingleton::Instance().setBundle(bundle_dup(b));
109
110     if (true == m_initializing) {
111         LogDebug("can not handle reset event");
112         return;
113     }
114     if (true == m_launched) {
115         if (m_widgetState == WidgetState_Stopped) {
116             LogError("Widget is not running to be reset");
117             return;
118         }
119         m_widget->Reset();
120         m_windowData->emitSignalForUserLayout(EDJE_SHOW_BACKWARD_SIGNAL, "");
121         elm_win_raise(m_windowData->m_win);
122         evas_object_focus_set(m_widget->GetCurrentWebview(), EINA_TRUE);
123         m_widgetState = WidgetState_Running;
124     } else {
125         if (true == checkArgument())
126         {
127             setStep();
128         }
129         else
130         {
131             showHelpAndQuit();
132         }
133     }
134 }
135
136 void WrtClient::OnTerminate()
137 {
138     LogDebug("Wrt Shutdown now");
139     shutdownStep();
140 }
141
142 void WrtClient::showHelpAndQuit()
143 {
144     printf("Usage: wrt-client [OPTION]... [WIDGET: ID]...\n"
145            "launch widgets.\n"
146            "Mandatory arguments to long options are mandatory for short "
147            "options too.\n"
148            "  -h,    --help                                 show this help\n"
149            "  -l,    --launch                               "
150            "launch widget with given tizen ID\n"
151            "  -t,    --tizen                                "
152            "launch widget with given tizen ID\n"
153            "\n");
154
155     Quit();
156 }
157
158 bool WrtClient::checkArgument()
159 {
160     LogInfo("checkArgument");
161
162     std::string arg = m_argv[0];
163
164     if (arg.empty()) {
165         return false;
166     }
167
168     if (arg.find("wrt-client") != std::string::npos)
169     {
170         if (m_argc <= 1) {
171             return false;
172         }
173
174         arg = m_argv[1];
175
176         if (arg == "-h" || arg == "--help") {
177             // Just show help
178             return false;
179         } else if (arg == "-l" || arg == "--launch" ||
180                 arg == "-t" || arg == "--tizen") {
181             if (m_argc != 3) {
182                 return false;
183             }
184             m_tizenId = std::string(m_argv[2]);
185         } else {
186             return false;
187         }
188     } else {
189         size_t pos = arg.find_last_of('/');
190
191         if (pos != std::string::npos) {
192             arg = arg.erase(0, pos + 1);
193         }
194
195         // Launch widget based on application basename
196         m_tizenId = arg;
197         LogDebug("Tizen id: " << m_tizenId);
198     }
199
200     return true;
201 }
202
203 void WrtClient::setStep()
204 {
205     LogInfo("setStep");
206
207     AddStep(&WrtClient::initStep);
208
209     setSdkLauncherDebugData();
210
211     AddStep(&WrtClient::launchStep);
212     AddStep(&WrtClient::shutdownStep);
213
214     m_initializing = true;
215
216     DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(NextStepEvent());
217 }
218
219 void WrtClient::setSdkLauncherDebugData()
220 {
221     LogDebug("setSdkLauncherDebugData");
222
223     /* check bundle from sdk launcher */
224     bundle *bundleFromSdkLauncher;
225     bundleFromSdkLauncher = bundle_import_from_argv(m_argc, m_argv);
226     const char *bundle_debug = bundle_get_val(bundleFromSdkLauncher, "debug");
227     const char *bundle_pid = bundle_get_val(bundleFromSdkLauncher, "pid");
228     if (bundle_debug != NULL && bundle_pid != NULL) {
229         if (strcmp(bundle_debug, "true") == 0) {
230             m_debugMode = true;
231             m_sdkLauncherPid = atoi(bundle_pid);
232         } else {
233             m_debugMode = false;
234         }
235     }
236 }
237
238 bool WrtClient::checkDebugMode(SDKDebugData* debugData)
239 {
240     LogError("Checking for debug mode");
241     Assert(m_dao);
242
243     bool debugMode = debugData->debugMode;
244
245     LogInfo("[DEBUG_MODE] Widget is launched in " <<
246             (debugMode ? "DEBUG" : "RETAIL") <<
247             " mode.");
248
249     if (debugMode == true) {
250         // In WAC widget, only test widgets can use web inspector.
251         // In TIZEN widget,
252         // every launched widgets as debug mode can use it.
253         if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_WAC20)
254         {
255             bool developerMode =
256                 GlobalLogicSingleton::Instance().GetGlobalModel()
257                 ->DeveloperMode.Get();
258             //This code will be activated
259             //after WAC test certificate is used by SDK
260             //bool isTestWidget = view->m_widgetModel->IsTestWidget.Get();
261             //if(!isTestWidget)
262             //{
263             //    LogInfo("This is not WAC Test Widget");
264             //    break;
265             //}
266             if (!developerMode) {
267                 LogInfo("This is not WAC Developer Mode");
268                 debugMode = false;
269             }
270         }
271     }
272     return debugMode;
273 }
274
275 void WrtClient::OnEventReceived(const NextStepEvent& /*event*/)
276 {
277     LogDebug("Executing next step");
278     NextStep();
279 }
280
281 void WrtClient::initStep()
282 {
283     LogDebug("");
284     if (WRT::CoreModuleSingleton::Instance().Init()) {
285         m_initialized = true;
286     } else {
287         m_returnStatus = ReturnStatus::Failed;
288         SwitchToStep(&WrtClient::shutdownStep);
289     }
290
291     // ecore_event_jobs are processed sequentially without concession to
292     // other type events. To give a chance of execute to other events,
293     // ecore_timer_add was used.
294     DPL::Event::ControllerEventHandler<NextStepEvent>::PostTimedEvent(
295             NextStepEvent(),0.001);
296 }
297
298 bool WrtClient::checkWACTestCertififedWidget()
299 {
300     // WAC Waikiki Beta Release Core Specification: Widget Runtime
301     // 10 Dec 2010
302     //
303     // WR-4710 The WRT MUST enable debug functions only for WAC test widgets
304     // i.e. the functions must not be usable for normal WAC widgets, even when
305     // a WAC test widget is executing.
306     ADD_PROFILING_POINT("DeveloperModeCheck", "start");
307     Assert(!!m_dao);
308     // WAC test widget
309     // A widget signed with a WAC-issued test certificate as described in
310     // Developer Mode.
311
312     bool developerWidget = m_dao->isTestWidget();
313     bool developerMode =
314         GlobalLogicSingleton::Instance().GetGlobalModel()->DeveloperMode.Get();
315
316     LogDebug("Is WAC test widget: " << developerWidget);
317     LogDebug("Is developer Mode: " << developerMode);
318
319     if (developerWidget) {
320         if(!developerMode)
321         {
322             LogError("WAC test certified developer widget is needed for " <<
323                     "developer mode");
324             return false;
325         }else{
326             //TODO: WR-4660 (show popup about developer widget
327             //      during launch
328             LogInfo("POPUP: THIS IS TEST WIDGET!");
329         }
330     }
331     ADD_PROFILING_POINT("DeveloperModeCheck", "stop");
332     return true;
333 }
334
335 void WrtClient::loadFinishCallback(bool success)
336 {
337     ADD_PROFILING_POINT("loadFinishCallback", "start");
338     SDKDebugData* debug = new SDKDebugData;
339     debug->debugMode = m_debugMode;
340     debug->pid = new unsigned long(getpid());
341
342     LogInfo("Post result of launch");
343
344     // Start inspector server, if current mode is debugger mode.
345     // In the WK2 case, ewk_view_inspector_server_start should
346     // be called after WebProcess is created.
347     if (checkDebugMode(debug))
348     {
349         debug->portnum =
350             ewk_view_inspector_server_start(m_widget->GetCurrentWebview(), 0);
351         if (debug->portnum == 0) {
352             LogWarning("Failed to get portnum");
353         } else {
354             LogInfo("Assigned port number for inspector : "
355                     << debug->portnum);
356         }
357     } else {
358         LogDebug("Debug mode is disabled");
359     }
360
361     //w3c packaging test debug (message on 4>)
362     const char * makeScreen = getenv(W3C_DEBUG_ENV_VARIABLE);
363     if(makeScreen != NULL && strcmp(makeScreen, "1") == 0)
364     {
365         FILE* doutput = fdopen(4, "w");
366         fprintf(doutput,"didFinishLoadForFrameCallback: ready\n");
367         fclose(doutput);
368     }
369
370     if (success) {
371         LogDebug("Launch succesfull");
372
373         m_launched = true;
374         m_initializing = false;
375         setlinebuf(stdout);
376         ADD_PROFILING_POINT("loadFinishCallback", "stop");
377         printf("launched\n");
378         fflush(stdout);
379     } else {
380         printf("failed\n");
381
382         m_returnStatus = ReturnStatus::Failed;
383         //shutdownStep
384         DPL::Event::ControllerEventHandler<NextStepEvent>::
385                 PostEvent(NextStepEvent());
386     }
387
388     if(debug->debugMode)
389     {
390         LogDebug("Send RT signal to wrt-launcher(pid: "
391                 << m_sdkLauncherPid << ", status: " << success);
392         union sigval sv;
393         /* send real time signal with result to wrt-launcher */
394         if(success)
395         {
396             LogDebug("userData->portnum : " << debug->portnum);
397             sv.sival_int = debug->portnum;
398         }
399         else
400         {
401            sv.sival_int = -1;
402         }
403         sigqueue(m_sdkLauncherPid, SIGRTMIN, sv);
404     }
405
406     ApplicationDataSingleton::Instance().freeBundle();
407
408     LogDebug("Cleaning wrtClient launch resources...");
409     delete debug->pid;
410     delete debug;
411 }
412
413 void WrtClient::progressFinishCallback()
414 {
415     m_splashScreen->stopSplashScreen();
416 }
417
418 void WrtClient::windowCloseCallback()
419 {
420     LogDebug("window close called, terminating app");
421     SwitchToStep(&WrtClient::shutdownStep);
422     DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
423             NextStepEvent());
424 }
425
426 void WrtClient::webCrashCallback()
427 {
428     LogDebug("webProcess crashed");
429     SwitchToStep(&WrtClient::shutdownStep);
430     DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
431             NextStepEvent());
432 }
433
434
435 void WrtClient::launchStep()
436 {
437     ADD_PROFILING_POINT("launchStep", "start");
438     LogDebug("Launching widget ...");
439
440     m_widget = WRT::CoreModuleSingleton::Instance()
441                     .getRunnableWidgetObject(m_tizenId);
442     if (!m_widget) {
443         LogError("RunnableWidgetObject is NULL, stop launchStep");
444         DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
445                     NextStepEvent());
446         return;
447     }
448
449     if (m_widgetState == WidgetState_Running) {
450         LogWarning("Widget already running, stop launchStep");
451         DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
452                     NextStepEvent());
453         return;
454     }
455
456     if (m_widgetState == WidgetState_Authorizing) {
457         LogWarning("Widget already authorizing, stop launchStep");
458         DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
459                     NextStepEvent());
460         return;
461     }
462
463     m_dao.reset(new WrtDB::WidgetDAOReadOnly(DPL::FromASCIIString(m_tizenId)));
464     Domain::localizeWidgetModel(m_dao->getDefaultlocale());
465     LocalizationSetting::SetLanguageChangedCallback(
466             languageChangedCallback, this);
467
468     ADD_PROFILING_POINT("CreateWindow", "start");
469     m_windowData.reset(new WindowData(static_cast<unsigned long>(getpid())));
470     ADD_PROFILING_POINT("CreateWindow", "stop");
471
472     WRT::UserDelegatesPtr cbs(new WRT::UserDelegates);
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(this, &WrtClient::progressFinishCallback);
478     }
479     DPL::OptionalString startUrl = W3CFileLocalization::getStartFile(m_dao);
480     m_widget->PrepareView(DPL::ToUTF8String(*startUrl),
481             m_windowData->m_win);
482     //you can't show window with splash screen before PrepareView
483     //ewk_view_add_with_context() in viewLogic breaks window
484     evas_object_show(m_windowData->m_win);
485     initializeWindowModes();
486     connectElmCallback();
487
488     if (!checkWACTestCertififedWidget())
489     {
490         LogWarning("WAC Certificate failed, stop launchStep");
491         return;
492     }
493
494     m_widgetState = WidgetState_Authorizing;
495     if (!m_widget->CheckBeforeLaunch()) {
496         LogError("CheckBeforeLaunch failed, stop launchStep");
497         DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
498                     NextStepEvent());
499         return;
500     }
501     LogInfo("Widget launch accepted. Entering running state");
502     m_widgetState = WidgetState_Running;
503
504     cbs->loadFinish = DPL::MakeDelegate(this, &WrtClient::loadFinishCallback);
505     cbs->bufferSet = DPL::MakeDelegate(this, &WrtClient::setLayout);
506     cbs->bufferUnset = DPL::MakeDelegate(this, &WrtClient::unsetLayout);
507     cbs->windowClose = DPL::MakeDelegate(this, &WrtClient::windowCloseCallback);
508     cbs->webCrash = DPL::MakeDelegate(this, &WrtClient::webCrashCallback);
509     cbs->toggleFullscreen = DPL::MakeDelegate(m_windowData.get(), &WindowData::toggleFullscreen);
510
511     m_widget->SetUserDelegates(cbs);
512     m_widget->Show();
513     m_windowData->emitSignalForUserLayout(EDJE_SHOW_BACKWARD_SIGNAL, "");
514     ADD_PROFILING_POINT("launchStep", "stop");
515 }
516
517 void WrtClient::initializeWindowModes()
518 {
519     Assert(m_windowData);
520     Assert(m_dao);
521     auto windowModes = m_dao->getWindowModes();
522     bool fullscreen = false;
523     FOREACH(it, windowModes)
524     {
525         std::string viewMode = DPL::ToUTF8String(*it);
526         if (viewMode == VIEWMODE_TYPE_FULLSCREEN) {
527             fullscreen = true;
528             break;
529         } else if (viewMode == VIEWMODE_TYPE_MAXIMIZED) {
530             break;
531         }
532     }
533     bool indicator = true;
534     bool backbutton = false;
535     if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
536         WidgetSettings widgetSettings;
537         m_dao->getWidgetSettings(widgetSettings);
538         WidgetSettingList settings(widgetSettings);
539         indicator = (settings.getIndicatorPresence()
540                 == Indicator_Enable);
541         backbutton = (settings.getBackButtonPresence()
542                 == BackButton_Enable);
543     }
544
545     WrtDB::WidgetLocalizedInfo localizedInfo =
546             W3CFileLocalization::getLocalizedInfo(m_dao);
547     std::string name = "";
548     if (!(localizedInfo.name.IsNull())) {
549         name = DPL::ToUTF8String(*(localizedInfo.name));
550     }
551     LogInfo("initializeWindowModes " << m_debugMode);
552
553     SDKDebugData* debug = new SDKDebugData;
554     if(m_debugMode) {
555         m_windowData->m_debugMode = TRUE;
556     }
557     else {
558         m_windowData->m_debugMode = FALSE;
559     }
560
561     WindowData::CtxMenuItems ctxMenuItems;
562
563     WindowData::CtxMenuItem ctxMenuBackword;
564     ctxMenuBackword.label = WRT_OPTION_LABEL_BACKWARD;
565     ctxMenuBackword.icon = WRT_OPTION_ICON_BACKWARD;
566     ctxMenuBackword.callback = backwardCallback;
567     ctxMenuBackword.data = this;
568     ctxMenuItems.push_back(ctxMenuBackword);
569
570     WindowData::CtxMenuItem ctxMenuReload;
571     ctxMenuReload.label = WRT_OPTION_LABEL_RELOAD;
572     ctxMenuReload.icon = WRT_OPTION_ICON_RELOAD;
573     ctxMenuReload.callback = reloadCallback;
574     ctxMenuReload.data = this;
575     ctxMenuItems.push_back(ctxMenuReload);
576
577     WindowData::CtxMenuItem ctxMenuForward;
578     ctxMenuForward.label = WRT_OPTION_LABEL_FORWARD;
579     ctxMenuForward.icon = WRT_OPTION_ICON_FORWARD;
580     ctxMenuForward.callback = forwardCallback;
581     ctxMenuForward.data = this;
582     ctxMenuItems.push_back(ctxMenuForward);
583
584     m_windowData->setViewMode(name.c_str(), fullscreen, indicator, backbutton, ctxMenuItems);
585
586 }
587
588 void WrtClient::backButtonCallback(void* data,
589                                      Evas_Object * /*obj*/,
590                                      void * /*event_info*/)
591 {
592     LogInfo("BackButtonCallback");
593     Assert(data);
594
595     WrtClient* This = static_cast<WrtClient*>(data);
596
597     This->m_widget->Backward();
598 }
599
600 void WrtClient::backwardCallback(void *data,
601         Evas_Object */*obj*/,
602         void */*event_info*/)
603 {
604     LogInfo("BackButtonCallback");
605     Assert(data);
606
607     WrtClient* This = static_cast<WrtClient*>(data);
608
609     This->m_widget->Backward();
610     This->m_windowData->initFullViewMode();
611 }
612
613 void WrtClient::reloadCallback(void *data,
614         Evas_Object */*obj*/,
615         void */*event_info*/)
616 {
617     LogInfo("reloadCallback");
618
619     WrtClient* This = static_cast<WrtClient*>(data);
620
621     This->m_widget->Reload();
622     This->m_windowData->initFullViewMode();
623 }
624
625 void WrtClient::forwardCallback(void *data,
626         Evas_Object */*obj*/,
627         void */*event_info*/)
628 {
629     LogInfo("forwardCallback");
630
631     WrtClient* This = static_cast<WrtClient*>(data);
632
633     This->m_widget->Forward();
634     This->m_windowData->initFullViewMode();
635 }
636
637
638 void WrtClient::connectElmCallback()
639 {
640     Assert(m_windowData);
641     Assert(m_dao);
642     if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
643         WidgetSettings widgetSettings;
644         m_dao->getWidgetSettings(widgetSettings);
645         WidgetSettingList settings(widgetSettings);
646         if (settings.getBackButtonPresence() ==
647                 BackButton_Enable)
648         {
649             m_windowData->addFloatBackButtonCallback(
650                 "clicked",
651                 &WrtClient::backButtonCallback,
652                 this);
653         }
654
655         WidgetSettingScreenLock rotationValue = settings.getRotationValue();
656         if (rotationValue == Screen_Portrait) {
657             elm_win_rotation_with_resize_set(m_windowData->m_win, 0);
658         } else if (rotationValue == Screen_Landscape) {
659             elm_win_rotation_with_resize_set(m_windowData->m_win, 270);
660         } else {
661             elm_win_rotation_with_resize_set(m_windowData->m_win, 0);
662         }
663     }
664 }
665
666 void WrtClient::setLayout(Evas_Object* newBuffer) {
667     LogDebug("add new webkit buffer to window");
668     Assert(newBuffer);
669     elm_object_content_set(m_windowData->m_conformant, newBuffer);
670     evas_object_show(newBuffer);
671     evas_object_focus_set(newBuffer, EINA_TRUE);
672 }
673
674 void WrtClient::unsetLayout(Evas_Object* currentBuffer) {
675     LogDebug("remove current webkit buffer from window");
676     Assert(currentBuffer);
677     evas_object_hide(currentBuffer);
678     elm_object_content_unset(m_windowData->m_conformant);
679 }
680
681 void WrtClient::shutdownStep()
682 {
683     LogDebug("Closing Wrt connection ...");
684     if (m_initialized && m_widget) {
685         m_widgetState = WidgetState_Stopped;
686         m_widget->Hide();
687         m_widget.reset();
688         m_windowData.reset();
689         WRT::CoreModuleSingleton::Instance().Terminate();
690         m_initialized = false;
691     }
692     Quit();
693 }
694
695 int WrtClient::languageChangedCallback(void *data)
696 {
697     LogDebug("Language Changed");
698     WrtClient* wrtClient = static_cast<WrtClient*>(data);
699
700     LanguageTags oldtags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
701     // reset function fetches system locales and recreates language tags
702     LanguageTagsProviderSingleton::Instance().resetLanguageTags();
703     LanguageTags newtags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
704
705     // check whether LanguageTags changed or not
706     if (oldtags != newtags) {
707         // update localized data
708         Domain::localizeWidgetModel(wrtClient->m_dao->getDefaultlocale());
709
710         if (true == wrtClient->m_launched &&
711                 wrtClient->m_widgetState != WidgetState_Stopped) {
712             wrtClient->m_widget->ReloadStartPage();
713         }
714     }
715     return 0;
716 }
717
718 int main(int argc,
719          char *argv[])
720 {
721     ADD_PROFILING_POINT("main-entered", "point");
722
723     // Output on stdout will be flushed after every newline character,
724     // even if it is redirected to a pipe. This is useful for running
725     // from a script and parsing output.
726     // (Standard behavior of stdlib is to use full buffering when
727     // redirected to a pipe, which means even after an end of line
728     // the output may not be flushed).
729     setlinebuf(stdout);
730
731     // set evas backend type
732     if (!getenv("ELM_ENGINE")) {
733         if (setenv("ELM_ENGINE", "gl", 1)) {
734                 LogDebug("Enable backend");
735         }
736     }
737     setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
738     setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
739     // Set log tagging
740     DPL::Log::LogSystemSingleton::Instance().SetTag("WRT-CLIENT");
741
742     WrtClient app(argc, argv);
743     int ret = app.Exec();
744     LogDebug("App returned: " << ret);
745     ret = app.getReturnStatus();
746     LogDebug("WrtClient returned: " << ret);
747     return ret;
748 }