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 /* @file wrt_installer.cpp
18 * @brief Implementation file for installer
21 #include "wrt_installer.h"
22 #include "plugin_utils.h"
29 #include <sys/resource.h>
30 #include <dpl/optional.h>
31 #include <dpl/scoped_free.h>
32 #include <dpl/optional_typedefs.h>
33 #include <dpl/exception.h>
34 #include <dpl/sstream.h>
36 #include <dpl/wrt-dao-ro/global_config.h>
37 #include <dpl/wrt-dao-ro/config_parser_data.h>
38 #include <dpl/localization/localization_utils.h>
39 #include <dpl/optional_typedefs.h>
40 #include <dpl/string.h>
41 #include <dpl/abstract_waitable_input_adapter.h>
42 #include <dpl/abstract_waitable_output_adapter.h>
43 #include <dpl/zip_input.h>
44 #include <dpl/binary_queue.h>
46 #include <dpl/errno_string.h>
47 #include <dpl/utils/wrt_global_settings.h>
48 #include "option_parser.h"
49 #include <parser_runner.h>
50 #include <widget_parser.h>
51 #include <root_parser.h>
52 #include <pkg-manager/pkgmgr_signal.h>
54 #define NOFILE_CNT_FOR_INSTALLER 9999
56 using namespace WrtDB;
58 namespace { // anonymous
59 const char AUL_ARG_KEY[] = "widget_arg";
60 const char * const PKGMGR_INSTALL_MSG = "Install widget";
61 const char * const PKGMGR_UNINSTALL_MSG = "Uninstall widget";
63 const double BASE_LAYOUT_W = 720.0f;
64 const double BASE_LAYOUT_H = 1280.0f;
66 const char * const CONFIG_XML = "config.xml";
70 void operator()(void* x) { free(x); }
73 struct PluginInstallerData
76 std::string pluginPath;
78 } // namespace anonymous
80 WrtInstaller::WrtInstaller(int argc, char **argv) :
81 Application(argc, argv, "backend", false),
82 DPL::TaskDecl<WrtInstaller>(this),
86 m_numPluginsToInstall(0),
89 m_installByPkgmgr(false),
92 m_startupPluginInstallation(false)
95 LogDebug("App Created");
98 WrtInstaller::~WrtInstaller()
100 LogDebug("App Finished");
103 void WrtInstaller::OnStop()
105 LogInfo("Stopping Dummy Client");
108 void WrtInstaller::OnCreate()
110 LogInfo("Creating DummyClient");
112 AddStep(&WrtInstaller::initStep);
114 std::string arg = m_argv[0];
117 return showHelpAndQuit();
122 if (arg.find("wrt-installer") != std::string::npos)
125 return showHelpAndQuit();
129 if (arg == "-h" || arg == "--help") {
131 return showHelpAndQuit();
135 return showHelpAndQuit();
136 } else if (arg == "-p" || arg == "--install-plugins") {
138 return showHelpAndQuit();
140 if (!m_startupPluginInstallation) {
141 AddStep(&WrtInstaller::installPluginsStep);
143 LogInfo("Plugin installation alredy started");
145 } else if (arg == "-i" || arg == "--install") {
147 return showHelpAndQuit();
150 m_packagePath = m_argv[2];
151 m_installPolicy = WRT_WIM_POLICY_WAC;
152 AddStep(&WrtInstaller::installStep);
153 } else if (arg == "-if" || arg == "--install-force") {
155 return showHelpAndQuit();
158 m_packagePath = m_argv[2];
159 m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL;
160 AddStep(&WrtInstaller::installStep);
161 } else if (arg == "-un" || arg == "--uninstall-name") {
163 return showHelpAndQuit();
166 AddStep(&WrtInstaller::uninstallPkgNameStep);
167 } else if (arg == "-ug" || arg == "--uninstall-guid") {
169 return showHelpAndQuit();
172 AddStep(&WrtInstaller::uninstallGuidStep);
173 } else if (arg == "-up" || arg == "--uninstall-packagepath") {
175 return showHelpAndQuit();
177 m_packagePath = m_argv[2];
178 AddStep(&WrtInstaller::unistallWgtFileStep);
180 return showHelpAndQuit();
183 } else if (arg.find("backend") != std::string::npos) {
184 using namespace PackageManager;
185 m_installByPkgmgr = true;
187 PkgmgrSignalSingleton::Instance().initialize(m_argc, m_argv);
188 m_quiet = PkgmgrSignalSingleton::Instance().isNoPopupRequired();
189 LogDebug("backend m_quiet"<<m_quiet);
191 int reqType = PkgmgrSignalSingleton::Instance().getRequestedType();
194 case PKGMGR_REQ_INSTALL:
195 m_packagePath = m_argv[4];
196 m_installPolicy = WRT_WIM_POLICY_WAC;
197 AddStep(&WrtInstaller::installStep);
199 case PKGMGR_REQ_UNINSTALL:
201 AddStep(&WrtInstaller::uninstallPkgNameStep);
204 LogDebug("Not available type");
208 // Launch widget based on application basename
209 size_t pos = arg.find_last_of('/');
211 if (pos != std::string::npos) {
212 arg = arg.erase(0, pos + 1);
215 if (sscanf(arg.c_str(), "%i", &m_handle) != 1) {
216 printf("failed: invalid widget handle\n");
217 return showHelpAndQuit();
220 LogDebug("Widget Id: " << m_handle << " (" << arg << ")");
223 AddStep(&WrtInstaller::shutdownStep);
224 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
225 WRTInstallerNS::NextStepEvent());
228 void WrtInstaller::OnReset(bundle *b)
230 const char * bundledVal = bundle_get_val(b, AUL_ARG_KEY);
231 if (bundledVal != NULL) {
232 m_bundleValue = bundledVal;
233 LogInfo("Bundled value for (" << AUL_ARG_KEY << ") key received: " <<
238 int WrtInstaller::getReturnStatus() const
240 if (!m_returnStatus) {
247 void WrtInstaller::OnTerminate()
249 LogDebug("Wrt Shutdown now");
250 PluginUtils::unlockPluginInstallation();
252 wrt_installer_shutdown();
257 void WrtInstaller::showHelpAndQuit()
259 printf("Usage: wrt-installer [OPTION]... [WIDGET: ID/NAME/GUID/PATH]...\n"
260 "Operate with WebRuntime daemon: install, uninstall"
261 " and launch widgets.\n"
262 "Query list of installed widgets and setup up debugging support.\n"
264 "Exactly one option must be selected.\n"
265 "Mandatory arguments to long options are mandatory for short "
267 " -h, --help show this help\n"
268 " -p, --install-plugins install plugins\n"
270 "install or update widget package for given path\n"
271 " -if, --install-force "
272 "install forcibly widget package for given path\n"
273 " -un, --uninstall-name "
274 "uninstall widget for given package name\n"
275 " -ug, --uninstall-guid "
276 "uninstall widget for given Global Unique IDentifier\n"
277 " -up, --uninstall-packagepath "
278 "uninstall widget for given package file path\n"
284 void WrtInstaller::OnEventReceived(const WRTInstallerNS::QuitEvent& /*event*/)
289 LogDebug("Wrt Shutdown now");
290 SwitchToStep(&WrtInstaller::shutdownStep);
291 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
292 WRTInstallerNS::NextStepEvent());
294 LogDebug("Quiting application");
299 void WrtInstaller::OnEventReceived(
300 const WRTInstallerNS::NextStepEvent& /*event*/)
302 LogDebug("Executing next step");
306 void WrtInstaller::OnEventReceived(
307 const WRTInstallerNS::InstallPluginEvent& /*event*/)
309 PluginInstallerData* privateData = new PluginInstallerData;
310 privateData->wrtInstaller = this;
312 if (!(*m_pluginsPaths).empty()) {
313 privateData->pluginPath = (*m_pluginsPaths).front();
314 (*m_pluginsPaths).pop_front();
316 wrt_install_plugin(privateData->pluginPath.c_str(),
317 static_cast<void*>(privateData),
318 &staticWrtPluginInstallationCallback,
319 &staticWrtPluginInstallProgressCb);
325 void WrtInstaller::initStep()
327 wrt_installer_init(this, staticWrtInitCallback);
330 void WrtInstaller::installStep()
332 LogDebug("Installing widget ...");
333 std::unique_ptr<char, free_deleter> packagePath(canonicalize_file_name(
334 m_packagePath.c_str()));
336 wrt_install_widget(packagePath ? packagePath.get() : m_packagePath.c_str(),
337 this, &staticWrtStatusCallback,
338 (!m_quiet || m_installByPkgmgr)
339 ? &staticWrtInstallProgressCallback : NULL,
344 void WrtInstaller::installPluginsStep()
346 LogDebug("Installing plugins ...");
348 if (m_startupPluginInstallation) {
349 LogInfo("Plugin installation started because new plugin package found");
350 } else if (!PluginUtils::lockPluginInstallation()) {
351 LogError("Failed to open plugin installation lock file"
352 " Plugins are currently installed by other process");
353 staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK,
358 std::string PLUGIN_PATH = std::string(GlobalConfig::GetDevicePluginPath());
361 dir = opendir(PLUGIN_PATH.c_str());
367 LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
368 struct dirent* libdir;
372 std::list<std::string> pluginsPaths;
374 while ((libdir = readdir(dir)) != 0) {
375 if (strcmp(libdir->d_name, ".") == 0 ||
376 strcmp(libdir->d_name, "..") == 0)
381 std::string path = PLUGIN_PATH;
383 path += libdir->d_name;
387 if (stat(path.c_str(), &tmp) == -1) {
388 LogError("Failed to open file" << path);
392 if (!S_ISDIR(tmp.st_mode)) {
393 LogError("Not a directory" << path);
397 pluginsPaths.push_back(path);
400 //set nb of plugins to install
401 //this value indicate how many callbacks are expected
402 m_numPluginsToInstall = pluginsPaths.size();
403 LogInfo("Plugins to install: " << m_numPluginsToInstall);
404 m_pluginsPaths = pluginsPaths;
406 m_totalPlugins = m_numPluginsToInstall;
407 DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>
408 ::PostEvent(WRTInstallerNS::InstallPluginEvent());
410 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
411 LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
412 << DPL::GetErrnoString());
416 void WrtInstaller::uninstallPkgNameStep()
418 LogDebug("Uninstalling widget ...");
419 LogDebug("Package name : " << m_name);
420 wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback,
421 (!m_quiet || m_installByPkgmgr)
422 ? &staticWrtUninstallProgressCallback : NULL);
425 void WrtInstaller::uninstallGuidStep()
427 LogDebug("Uninstalling widget ...");
429 WrtErrStatus status = wrt_get_widget_by_guid(pkgname, m_name);
430 if (status == WRT_SUCCESS) {
431 LogDebug("Guid : " << m_name);
432 wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
433 !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
435 printf("failed: can not uninstall widget\n");
436 LogError("Fail to uninstalling widget... ");
438 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
439 WRTInstallerNS::QuitEvent());
443 void WrtInstaller::unistallWgtFileStep()
445 LogDebug("Uninstalling widget ...");
450 ConfigParserData configInfo;
453 std::unique_ptr<DPL::ZipInput> zipFile(
454 new DPL::ZipInput(m_packagePath));
456 // Open config.xml file
457 std::unique_ptr<DPL::ZipInput::File> configFile(
458 zipFile->OpenFile(CONFIG_XML));
461 DPL::BinaryQueue buffer;
462 DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
463 DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
464 DPL::Copy(&inputAdapter, &outputAdapter);
465 parser.Parse(&buffer,
467 new RootParser<WidgetParser>(configInfo,
468 DPL::FromUTF32String(
471 DPL::OptionalString widgetGUID = configInfo.widget_id;
473 std::string guid = DPL::ToUTF8String(*widgetGUID);
476 WrtErrStatus status = wrt_get_widget_by_guid(pkgname, guid);
477 if (status == WRT_SUCCESS) {
478 LogDebug("Pkgname from packagePath : " << pkgname);
479 wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
480 !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
482 LogError("Fail to uninstalling widget... ");
484 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
485 WRTInstallerNS::QuitEvent());
488 Catch(DPL::ZipInput::Exception::OpenFailed)
490 LogError("Failed to open widget package");
491 printf("failed: widget package does not exist\n");
493 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
494 WRTInstallerNS::QuitEvent());
496 Catch(DPL::ZipInput::Exception::OpenFileFailed)
498 printf("failed: widget config file does not exist\n");
499 LogError("Failed to open config.xml file");
501 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
502 WRTInstallerNS::QuitEvent());
504 Catch(ElementParser::Exception::ParseError)
506 printf("failed: can not parse config file\n");
507 LogError("Failed to parse config.xml file");
509 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
510 WRTInstallerNS::QuitEvent());
514 void WrtInstaller::shutdownStep()
516 LogDebug("Closing Wrt connection ...");
518 wrt_installer_shutdown();
519 m_initialized = false;
520 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
521 WRTInstallerNS::QuitEvent());
525 void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
528 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
531 if (status == WRT_SUCCESS) {
532 LogDebug("Init succesfull");
533 This->m_initialized = true;
534 This->m_returnStatus = 0;
536 if (This->popupsEnabled()) {
537 This->m_popup = new InstallerPopup;
538 This->m_popup->init();
541 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
542 ::PostEvent(WRTInstallerNS::NextStepEvent());
544 LogError("Init unsuccesfull");
545 This->m_returnStatus = -1;
546 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
547 WRTInstallerNS::QuitEvent());
551 void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
555 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
558 Step current = This->GetCurrentStep();
559 DPL::String resultMsg;
560 std::string printMsg;
562 if (current == &WrtInstaller::installStep)
564 resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
565 printMsg = "installed";
566 } else if (current == &WrtInstaller::uninstallPkgNameStep ||
567 current == &WrtInstaller::uninstallGuidStep ||
568 current == &WrtInstaller::unistallWgtFileStep)
570 resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
571 printMsg = "uninstalled";
574 if (WRT_SUCCESS != status) {
576 LogError("Step failed");
577 This->m_returnStatus = -1;
579 if (This->popupsEnabled()) {
580 resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
581 This->m_popup->showPopup(This, resultMsg, failResultCallback);
583 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
584 ::PostEvent(WRTInstallerNS::QuitEvent());
588 case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE:
589 This->m_returnStatus = 1; //this status is specific
590 printf("failed: invalid widget package\n");
593 case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST:
594 printf("failed: widget package does not exist\n");
597 case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING:
598 printf("failed: already uninstalling\n");
601 case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
602 printf("failed: out of disk space\n");
605 case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE:
606 printf("failed: invalid certificate\n");
609 case WRT_INSTALLER_ERROR_ALREADY_INSTALLED:
610 printf("failed: already installed\n");
613 case WRT_INSTALLER_ERROR_INTERNAL:
614 printf("failed: internal error\n");
617 case WRT_INSTALLER_ERROR_NOT_ALLOWED:
618 printf("failed: installation or update not allowed; invalid"
622 case WRT_INSTALLER_ERROR_DEFERRED:
623 printf("deferred: widget update will continue after the widget"
624 " has been stopped\n");
627 case WRT_INSTALLER_ERROR_DATABASE_FAILURE:
628 printf("failed: database failure\n");
631 case WRT_INSTALLER_ERROR_OSPSVC:
632 printf("failed: during installation or uninstallation osp service\n");
635 case WRT_INSTALLER_ERROR_UNKNOWN:
636 printf("failed: unknown error\n");
644 printf("%s : %s\n", printMsg.c_str(), tizenId.c_str());
645 LogDebug("Status succesfull");
646 This->m_returnStatus = 0;
647 resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
649 if (This->popupsEnabled()) {
650 This->m_popup->showPopup(This, resultMsg, showResultCallback);
652 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
653 ::PostEvent(WRTInstallerNS::NextStepEvent());
658 void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
663 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
665 WrtInstaller *This = static_cast<WrtInstaller*>(data->wrtInstaller);
667 std::string path = std::string(data->pluginPath);
670 This->m_numPluginsToInstall--;
671 LogDebug("Plugins to install: " << This->m_numPluginsToInstall);
673 if (This->m_numPluginsToInstall < 1) {
674 LogDebug("All plugins installation completed");
676 //remove installation request
677 if (!PluginUtils::removeInstallationRequiredFlag()) {
678 LogInfo("Failed to remove file initializing plugin installation");
682 if (!PluginUtils::unlockPluginInstallation()) {
683 LogInfo("Failed to remove installation lock");
686 if (This->popupsEnabled()) {
687 This->m_popup->init();
688 elm_progressbar_value_set(This->m_popup->m_progressbar, 100.0);
689 evas_object_show(This->m_popup->m_popup);
692 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
693 ::PostEvent(WRTInstallerNS::NextStepEvent());
695 if (This->popupsEnabled()) {
696 This->m_popup->init();
697 float percent = (This->m_totalPlugins - This->m_numPluginsToInstall)/(float)This->m_totalPlugins;
698 elm_progressbar_value_set(This->m_popup->m_progressbar, percent);
699 evas_object_show(This->m_popup->m_popup);
702 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>::PostEvent(
703 WRTInstallerNS::InstallPluginEvent());
706 if (WRT_SUCCESS == status) {
707 This->m_returnStatus = 0;
708 LogDebug("One plugin Installation succesfull: " << path);
713 LogWarning("One of the plugins installation failed!: " << path);
715 if (WRT_PLUGIN_INSTALLER_ERROR_WAITING == status) {
716 LogInfo("Plugin installation is waiting for dependencies");
720 case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
721 LogError("failed: wrong path to plugin directory\n");
724 case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
725 LogError("failed: plugin metafile error\n");
728 case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
729 LogError("failed: plugin already installed\n");
732 case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
733 LogError("failed: plugin library: missing symbols or structures\n");
736 case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
737 LogError("failed: unknown error\n");
745 void WrtInstaller::staticWrtPluginInstallProgressCb(float percent,
746 const char* description,
749 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
751 std::string path = std::string(data->pluginPath);
753 LogInfo("Plugin Installation: " << path <<
754 " progress: " << percent <<
755 "description " << description);
758 void WrtInstaller::staticWrtInstallProgressCallback(float percent,
759 const char* description, void* userdata)
761 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
762 std::stringstream percentStr;
763 LogInfo(" progress: " << percent <<
764 " description: " << description);
766 if (This->popupsEnabled()) {
767 This->m_popup->init();
768 elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
769 evas_object_show(This->m_popup->m_popup);
772 void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
773 const char* description, void* userdata)
775 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
776 std::stringstream percentStr;
777 LogInfo(" progress: " << percent <<
778 " description: " << description);
780 if (This->popupsEnabled()) {
781 This->m_popup->init();
782 elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
783 evas_object_show(This->m_popup->m_popup);
787 WrtInstaller::InstallerPopup::InstallerPopup() :
794 WrtInstaller::InstallerPopup::~InstallerPopup()
796 LogDebug("App Finished");
799 void WrtInstaller::InstallerPopup::init()
801 LogDebug("Window Init");
805 m_win = createWin("wrt-installer");
808 m_popup = elm_popup_add(m_win);
810 // create progressbar
811 m_progressbar = elm_progressbar_add(m_popup);
812 elm_object_style_set(m_progressbar, "list_progress");
813 elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
814 evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
816 evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
818 elm_object_content_set(m_popup, m_progressbar);
819 elm_progressbar_value_set(m_progressbar, 0.0);
820 evas_object_show(m_progressbar);
822 evas_object_show(m_popup);
823 evas_object_show(m_win);
827 Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
830 win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
836 elm_win_alpha_set(win, EINA_TRUE);
837 elm_win_title_set(win, name);
838 elm_win_borderless_set(win, EINA_TRUE);
841 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
842 evas_object_resize(win, w, h);
846 void WrtInstaller::InstallerPopup::showPopup(void* userdata,
847 const DPL::String& pkgMsg,
848 ShowResultCallback callback)
853 LogDebug("Result Popup Created");
854 evas_object_del(m_popup);
857 m_popup = elm_popup_add(m_win);
861 btn = elm_button_add(m_popup);
863 evas_object_del(m_popup);
866 elm_object_text_set(btn, "OK");
867 evas_object_smart_callback_add(btn, "clicked", callback, userdata);
868 elm_object_part_content_set(m_popup, "button1", btn);
869 elm_object_part_text_set(m_popup, "title,text", "RESULT");
870 elm_object_text_set(m_popup, DPL::ToUTF8String(pkgMsg).c_str());
872 evas_object_show(m_popup);
873 evas_object_show(m_win);
877 void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
878 void* /*event_info*/)
880 WrtInstaller *This = static_cast<WrtInstaller*>(data);
883 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
884 ::PostEvent(WRTInstallerNS::NextStepEvent());
887 void WrtInstaller::failResultCallback(void *data, Evas_Object* /*obj*/,
888 void* /*event_info*/)
890 WrtInstaller *This = static_cast<WrtInstaller*>(data);
893 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
894 ::PostEvent(WRTInstallerNS::QuitEvent());
897 void WrtInstaller::installNewPlugins()
899 LogDebug("Install new plugins");
901 if (!PluginUtils::lockPluginInstallation()) {
902 LogInfo("Lock NOT created");
906 if (!PluginUtils::checkPluginInstallationRequired()) {
907 LogDebug("Plugin installation not required");
908 PluginUtils::unlockPluginInstallation();
912 m_startupPluginInstallation = true;
913 AddStep(&WrtInstaller::installPluginsStep);
916 bool WrtInstaller::popupsEnabled() const
918 return !m_quiet && !GlobalSettings::PopupsTestModeEnabled();
921 int main(int argc, char *argv[])
923 // Output on stdout will be flushed after every newline character,
924 // even if it is redirected to a pipe. This is useful for running
925 // from a script and parsing output.
926 // (Standard behavior of stdlib is to use full buffering when
927 // redirected to a pipe, which means even after an end of line
928 // the output may not be flushed).
931 // Check and re-set the file open limitation
933 if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) {
934 LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" );
935 LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" );
937 if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) {
938 rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER;
939 rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER;
940 if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) {
941 LogError("setrlimit is fail!!");
945 LogError("getrlimit is fail!!");
948 // set evas backend type for emulator
949 // popup isn't showed in the emulator,
950 // if backend isn't set to SW backend
951 if (GlobalSettings::IsEmulator()) {
952 if (setenv("ELM_ENGINE", "x11", 1)) {
953 LogDebug("Enable backend");
957 WrtInstaller app(argc, argv);
958 int ret = app.Exec();
959 LogDebug("App returned: " << ret);
960 ret = app.getReturnStatus();
961 LogDebug("WrtInstaller returned: " << ret);