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");
209 AddStep(&WrtInstaller::shutdownStep);
210 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
211 WRTInstallerNS::NextStepEvent());
214 void WrtInstaller::OnReset(bundle *b)
216 const char * bundledVal = bundle_get_val(b, AUL_ARG_KEY);
217 if (bundledVal != NULL) {
218 m_bundleValue = bundledVal;
219 LogInfo("Bundled value for (" << AUL_ARG_KEY << ") key received: " <<
224 int WrtInstaller::getReturnStatus() const
226 if (!m_returnStatus) {
233 void WrtInstaller::OnTerminate()
235 LogDebug("Wrt Shutdown now");
236 PluginUtils::unlockPluginInstallation();
238 wrt_installer_shutdown();
243 void WrtInstaller::showHelpAndQuit()
245 printf("Usage: wrt-installer [OPTION]... [WIDGET: ID/NAME/GUID/PATH]...\n"
246 "Operate with WebRuntime daemon: install, uninstall"
247 " and launch widgets.\n"
248 "Query list of installed widgets and setup up debugging support.\n"
250 "Exactly one option must be selected.\n"
251 "Mandatory arguments to long options are mandatory for short "
253 " -h, --help show this help\n"
254 " -p, --install-plugins install plugins\n"
256 "install or update widget package for given path\n"
257 " -if, --install-force "
258 "install forcibly widget package for given path\n"
259 " -un, --uninstall-name "
260 "uninstall widget for given package name\n"
261 " -ug, --uninstall-guid "
262 "uninstall widget for given Global Unique IDentifier\n"
263 " -up, --uninstall-packagepath "
264 "uninstall widget for given package file path\n"
270 void WrtInstaller::OnEventReceived(const WRTInstallerNS::QuitEvent& /*event*/)
275 LogDebug("Wrt Shutdown now");
276 SwitchToStep(&WrtInstaller::shutdownStep);
277 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
278 WRTInstallerNS::NextStepEvent());
280 LogDebug("Quiting application");
285 void WrtInstaller::OnEventReceived(
286 const WRTInstallerNS::NextStepEvent& /*event*/)
288 LogDebug("Executing next step");
292 void WrtInstaller::OnEventReceived(
293 const WRTInstallerNS::InstallPluginEvent& /*event*/)
295 PluginInstallerData* privateData = new PluginInstallerData;
296 privateData->wrtInstaller = this;
298 if (!(*m_pluginsPaths).empty()) {
299 privateData->pluginPath = (*m_pluginsPaths).front();
300 (*m_pluginsPaths).pop_front();
302 wrt_install_plugin(privateData->pluginPath.c_str(),
303 static_cast<void*>(privateData),
304 &staticWrtPluginInstallationCallback,
305 &staticWrtPluginInstallProgressCb);
311 void WrtInstaller::initStep()
313 wrt_installer_init(this, staticWrtInitCallback);
316 void WrtInstaller::installStep()
318 LogDebug("Installing widget ...");
319 std::unique_ptr<char, free_deleter> packagePath(canonicalize_file_name(
320 m_packagePath.c_str()));
322 wrt_install_widget(packagePath ? packagePath.get() : m_packagePath.c_str(),
323 this, &staticWrtStatusCallback,
324 (!m_quiet || m_installByPkgmgr)
325 ? &staticWrtInstallProgressCallback : NULL,
330 void WrtInstaller::installPluginsStep()
332 LogDebug("Installing plugins ...");
334 if (m_startupPluginInstallation) {
335 LogInfo("Plugin installation started because new plugin package found");
336 } else if (!PluginUtils::lockPluginInstallation()) {
337 LogError("Failed to open plugin installation lock file"
338 " Plugins are currently installed by other process");
339 staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK,
344 std::string PLUGIN_PATH = std::string(GlobalConfig::GetDevicePluginPath());
347 dir = opendir(PLUGIN_PATH.c_str());
353 LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
354 struct dirent* libdir;
358 std::list<std::string> pluginsPaths;
360 while ((libdir = readdir(dir)) != 0) {
361 if (strcmp(libdir->d_name, ".") == 0 ||
362 strcmp(libdir->d_name, "..") == 0)
367 std::string path = PLUGIN_PATH;
369 path += libdir->d_name;
373 if (stat(path.c_str(), &tmp) == -1) {
374 LogError("Failed to open file" << path);
378 if (!S_ISDIR(tmp.st_mode)) {
379 LogError("Not a directory" << path);
383 pluginsPaths.push_back(path);
386 //set nb of plugins to install
387 //this value indicate how many callbacks are expected
388 m_numPluginsToInstall = pluginsPaths.size();
389 LogInfo("Plugins to install: " << m_numPluginsToInstall);
390 m_pluginsPaths = pluginsPaths;
392 m_totalPlugins = m_numPluginsToInstall;
393 DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>
394 ::PostEvent(WRTInstallerNS::InstallPluginEvent());
396 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
397 LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
398 << DPL::GetErrnoString());
402 void WrtInstaller::uninstallPkgNameStep()
404 LogDebug("Uninstalling widget ...");
405 LogDebug("Package name : " << m_name);
406 wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback,
407 (!m_quiet || m_installByPkgmgr)
408 ? &staticWrtUninstallProgressCallback : NULL);
411 void WrtInstaller::uninstallGuidStep()
413 LogDebug("Uninstalling widget ...");
415 WrtErrStatus status = wrt_get_widget_by_guid(pkgname, m_name);
416 if (status == WRT_SUCCESS) {
417 LogDebug("Guid : " << m_name);
418 wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
419 !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
421 printf("failed: can not uninstall widget\n");
422 LogError("Fail to uninstalling widget... ");
424 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
425 WRTInstallerNS::QuitEvent());
429 void WrtInstaller::unistallWgtFileStep()
431 LogDebug("Uninstalling widget ...");
436 ConfigParserData configInfo;
439 std::unique_ptr<DPL::ZipInput> zipFile(
440 new DPL::ZipInput(m_packagePath));
442 // Open config.xml file
443 std::unique_ptr<DPL::ZipInput::File> configFile(
444 zipFile->OpenFile(CONFIG_XML));
447 DPL::BinaryQueue buffer;
448 DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
449 DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
450 DPL::Copy(&inputAdapter, &outputAdapter);
451 parser.Parse(&buffer,
453 new RootParser<WidgetParser>(configInfo,
454 DPL::FromUTF32String(
457 DPL::OptionalString widgetGUID = configInfo.widget_id;
459 std::string guid = DPL::ToUTF8String(*widgetGUID);
462 WrtErrStatus status = wrt_get_widget_by_guid(pkgname, guid);
463 if (status == WRT_SUCCESS) {
464 LogDebug("Pkgname from packagePath : " << pkgname);
465 wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
466 !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
468 LogError("Fail to uninstalling widget... ");
470 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
471 WRTInstallerNS::QuitEvent());
474 Catch(DPL::ZipInput::Exception::OpenFailed)
476 LogError("Failed to open widget package");
477 printf("failed: widget package does not exist\n");
479 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
480 WRTInstallerNS::QuitEvent());
482 Catch(DPL::ZipInput::Exception::OpenFileFailed)
484 printf("failed: widget config file does not exist\n");
485 LogError("Failed to open config.xml file");
487 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
488 WRTInstallerNS::QuitEvent());
490 Catch(ElementParser::Exception::ParseError)
492 printf("failed: can not parse config file\n");
493 LogError("Failed to parse config.xml file");
495 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
496 WRTInstallerNS::QuitEvent());
500 void WrtInstaller::shutdownStep()
502 LogDebug("Closing Wrt connection ...");
504 wrt_installer_shutdown();
505 m_initialized = false;
506 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
507 WRTInstallerNS::QuitEvent());
511 void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
514 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
517 if (status == WRT_SUCCESS) {
518 LogDebug("Init succesfull");
519 This->m_initialized = true;
520 This->m_returnStatus = 0;
522 if (This->popupsEnabled()) {
523 This->m_popup = new InstallerPopup;
524 This->m_popup->init();
527 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
528 ::PostEvent(WRTInstallerNS::NextStepEvent());
530 LogError("Init unsuccesfull");
531 This->m_returnStatus = -1;
532 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
533 WRTInstallerNS::QuitEvent());
537 void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
541 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
544 Step current = This->GetCurrentStep();
545 DPL::String resultMsg;
546 std::string printMsg;
548 if (current == &WrtInstaller::installStep)
550 resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
551 printMsg = "installed";
552 } else if (current == &WrtInstaller::uninstallPkgNameStep ||
553 current == &WrtInstaller::uninstallGuidStep ||
554 current == &WrtInstaller::unistallWgtFileStep)
556 resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
557 printMsg = "uninstalled";
560 if (WRT_SUCCESS != status) {
562 LogError("Step failed");
563 This->m_returnStatus = -1;
565 if (This->popupsEnabled()) {
566 resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
567 This->m_popup->showPopup(This, resultMsg, failResultCallback);
569 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
570 ::PostEvent(WRTInstallerNS::QuitEvent());
574 case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE:
575 This->m_returnStatus = 1; //this status is specific
576 printf("failed: invalid widget package\n");
579 case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST:
580 printf("failed: widget package does not exist\n");
583 case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING:
584 printf("failed: already uninstalling\n");
587 case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
588 printf("failed: out of disk space\n");
591 case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE:
592 printf("failed: invalid certificate\n");
595 case WRT_INSTALLER_ERROR_ALREADY_INSTALLED:
596 printf("failed: already installed\n");
599 case WRT_INSTALLER_ERROR_INTERNAL:
600 printf("failed: internal error\n");
603 case WRT_INSTALLER_ERROR_NOT_ALLOWED:
604 printf("failed: installation or update not allowed; invalid"
608 case WRT_INSTALLER_ERROR_DEFERRED:
609 printf("deferred: widget update will continue after the widget"
610 " has been stopped\n");
613 case WRT_INSTALLER_ERROR_DATABASE_FAILURE:
614 printf("failed: database failure\n");
617 case WRT_INSTALLER_ERROR_OSPSVC:
618 printf("failed: during installation or uninstallation osp service\n");
621 case WRT_INSTALLER_ERROR_UNKNOWN:
622 printf("failed: unknown error\n");
630 printf("%s : %s\n", printMsg.c_str(), tizenId.c_str());
631 LogDebug("Status succesfull");
632 This->m_returnStatus = 0;
633 resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
635 if (This->popupsEnabled()) {
636 This->m_popup->showPopup(This, resultMsg, showResultCallback);
638 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
639 ::PostEvent(WRTInstallerNS::NextStepEvent());
644 void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
649 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
651 WrtInstaller *This = static_cast<WrtInstaller*>(data->wrtInstaller);
653 std::string path = std::string(data->pluginPath);
656 This->m_numPluginsToInstall--;
657 LogDebug("Plugins to install: " << This->m_numPluginsToInstall);
659 if (This->m_numPluginsToInstall < 1) {
660 LogDebug("All plugins installation completed");
662 //remove installation request
663 if (!PluginUtils::removeInstallationRequiredFlag()) {
664 LogInfo("Failed to remove file initializing plugin installation");
668 if (!PluginUtils::unlockPluginInstallation()) {
669 LogInfo("Failed to remove installation lock");
672 if (This->popupsEnabled()) {
673 This->m_popup->init();
674 elm_progressbar_value_set(This->m_popup->m_progressbar, 100.0);
675 evas_object_show(This->m_popup->m_popup);
678 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
679 ::PostEvent(WRTInstallerNS::NextStepEvent());
681 if (This->popupsEnabled()) {
682 This->m_popup->init();
683 float percent = (This->m_totalPlugins - This->m_numPluginsToInstall)/(float)This->m_totalPlugins;
684 elm_progressbar_value_set(This->m_popup->m_progressbar, percent);
685 evas_object_show(This->m_popup->m_popup);
688 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>::PostEvent(
689 WRTInstallerNS::InstallPluginEvent());
692 if (WRT_SUCCESS == status) {
693 This->m_returnStatus = 0;
694 LogDebug("One plugin Installation succesfull: " << path);
699 LogWarning("One of the plugins installation failed!: " << path);
701 if (WRT_PLUGIN_INSTALLER_ERROR_WAITING == status) {
702 LogInfo("Plugin installation is waiting for dependencies");
706 case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
707 LogError("failed: wrong path to plugin directory\n");
710 case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
711 LogError("failed: plugin metafile error\n");
714 case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
715 LogError("failed: plugin already installed\n");
718 case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
719 LogError("failed: plugin library: missing symbols or structures\n");
722 case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
723 LogError("failed: unknown error\n");
731 void WrtInstaller::staticWrtPluginInstallProgressCb(float percent,
732 const char* description,
735 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
737 std::string path = std::string(data->pluginPath);
739 LogInfo("Plugin Installation: " << path <<
740 " progress: " << percent <<
741 "description " << description);
744 void WrtInstaller::staticWrtInstallProgressCallback(float percent,
745 const char* description, void* userdata)
747 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
748 std::stringstream percentStr;
749 LogInfo(" progress: " << percent <<
750 " description: " << description);
752 if (This->popupsEnabled()) {
753 This->m_popup->init();
754 elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
755 evas_object_show(This->m_popup->m_popup);
758 void WrtInstaller::staticWrtUninstallProgressCallback(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);
773 WrtInstaller::InstallerPopup::InstallerPopup() :
780 WrtInstaller::InstallerPopup::~InstallerPopup()
782 LogDebug("App Finished");
785 void WrtInstaller::InstallerPopup::init()
787 LogDebug("Window Init");
791 m_win = createWin("wrt-installer");
794 m_popup = elm_popup_add(m_win);
796 // create progressbar
797 m_progressbar = elm_progressbar_add(m_popup);
798 elm_object_style_set(m_progressbar, "list_progress");
799 elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
800 evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
802 evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
804 elm_object_content_set(m_popup, m_progressbar);
805 elm_progressbar_value_set(m_progressbar, 0.0);
806 evas_object_show(m_progressbar);
808 evas_object_show(m_popup);
809 evas_object_show(m_win);
813 Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
816 win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
822 elm_win_alpha_set(win, EINA_TRUE);
823 elm_win_title_set(win, name);
824 elm_win_borderless_set(win, EINA_TRUE);
827 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
828 evas_object_resize(win, w, h);
832 void WrtInstaller::InstallerPopup::showPopup(void* userdata,
833 const DPL::String& pkgMsg,
834 ShowResultCallback callback)
839 LogDebug("Result Popup Created");
840 evas_object_del(m_popup);
843 m_popup = elm_popup_add(m_win);
847 btn = elm_button_add(m_popup);
849 evas_object_del(m_popup);
852 elm_object_text_set(btn, "OK");
853 evas_object_smart_callback_add(btn, "clicked", callback, userdata);
854 elm_object_part_content_set(m_popup, "button1", btn);
855 elm_object_part_text_set(m_popup, "title,text", "RESULT");
856 elm_object_text_set(m_popup, DPL::ToUTF8String(pkgMsg).c_str());
858 evas_object_show(m_popup);
859 evas_object_show(m_win);
863 void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
864 void* /*event_info*/)
866 WrtInstaller *This = static_cast<WrtInstaller*>(data);
869 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
870 ::PostEvent(WRTInstallerNS::NextStepEvent());
873 void WrtInstaller::failResultCallback(void *data, Evas_Object* /*obj*/,
874 void* /*event_info*/)
876 WrtInstaller *This = static_cast<WrtInstaller*>(data);
879 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
880 ::PostEvent(WRTInstallerNS::QuitEvent());
883 void WrtInstaller::installNewPlugins()
885 LogDebug("Install new plugins");
887 if (!PluginUtils::lockPluginInstallation()) {
888 LogInfo("Lock NOT created");
892 if (!PluginUtils::checkPluginInstallationRequired()) {
893 LogDebug("Plugin installation not required");
894 PluginUtils::unlockPluginInstallation();
898 m_startupPluginInstallation = true;
899 AddStep(&WrtInstaller::installPluginsStep);
902 bool WrtInstaller::popupsEnabled() const
904 return !m_quiet && !GlobalSettings::PopupsTestModeEnabled();
907 int main(int argc, char *argv[])
909 // Output on stdout will be flushed after every newline character,
910 // even if it is redirected to a pipe. This is useful for running
911 // from a script and parsing output.
912 // (Standard behavior of stdlib is to use full buffering when
913 // redirected to a pipe, which means even after an end of line
914 // the output may not be flushed).
917 // Check and re-set the file open limitation
919 if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) {
920 LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" );
921 LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" );
923 if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) {
924 rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER;
925 rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER;
926 if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) {
927 LogError("setrlimit is fail!!");
931 LogError("getrlimit is fail!!");
934 // set evas backend type for emulator
935 // popup isn't showed in the emulator,
936 // if backend isn't set to SW backend
937 if (GlobalSettings::IsEmulator()) {
938 if (setenv("ELM_ENGINE", "x11", 1)) {
939 LogDebug("Enable backend");
943 WrtInstaller app(argc, argv);
944 int ret = app.Exec();
945 LogDebug("App returned: " << ret);
946 ret = app.getReturnStatus();
947 LogDebug("WrtInstaller returned: " << ret);