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 == "-u" || arg == "--uninstall") {
163 return showHelpAndQuit();
166 m_handle = atoi(m_argv[2]);
167 AddStep(&WrtInstaller::uninstallStep);
168 } else if (arg == "-un" || arg == "--uninstall-name") {
170 return showHelpAndQuit();
173 AddStep(&WrtInstaller::uninstallPkgNameStep);
174 } else if (arg == "-ug" || arg == "--uninstall-guid") {
176 return showHelpAndQuit();
179 AddStep(&WrtInstaller::uninstallGuidStep);
180 } else if (arg == "-up" || arg == "--uninstall-packagepath") {
182 return showHelpAndQuit();
184 m_packagePath = m_argv[2];
185 AddStep(&WrtInstaller::unistallWgtFileStep);
187 return showHelpAndQuit();
190 } else if (arg.find("backend") != std::string::npos) {
191 using namespace PackageManager;
192 m_installByPkgmgr = true;
194 PkgmgrSignalSingleton::Instance().initialize(m_argc, m_argv);
195 m_quiet = PkgmgrSignalSingleton::Instance().isNoPopupRequired();
196 LogDebug("backend m_quiet"<<m_quiet);
198 int reqType = PkgmgrSignalSingleton::Instance().getRequestedType();
201 case PKGMGR_REQ_INSTALL:
202 m_packagePath = m_argv[4];
203 m_installPolicy = WRT_WIM_POLICY_WAC;
204 AddStep(&WrtInstaller::installStep);
206 case PKGMGR_REQ_UNINSTALL:
208 AddStep(&WrtInstaller::uninstallPkgNameStep);
211 LogDebug("Not available type");
215 // Launch widget based on application basename
216 size_t pos = arg.find_last_of('/');
218 if (pos != std::string::npos) {
219 arg = arg.erase(0, pos + 1);
222 if (sscanf(arg.c_str(), "%i", &m_handle) != 1) {
223 printf("failed: invalid widget handle\n");
224 return showHelpAndQuit();
227 LogDebug("Widget Id: " << m_handle << " (" << arg << ")");
230 AddStep(&WrtInstaller::shutdownStep);
231 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
232 WRTInstallerNS::NextStepEvent());
235 void WrtInstaller::OnReset(bundle *b)
237 const char * bundledVal = bundle_get_val(b, AUL_ARG_KEY);
238 if (bundledVal != NULL) {
239 m_bundleValue = bundledVal;
240 LogInfo("Bundled value for (" << AUL_ARG_KEY << ") key received: " <<
245 int WrtInstaller::getReturnStatus() const
247 if (!m_returnStatus) {
254 void WrtInstaller::OnTerminate()
256 LogDebug("Wrt Shutdown now");
257 PluginUtils::unlockPluginInstallation();
259 wrt_installer_shutdown();
264 void WrtInstaller::showHelpAndQuit()
266 printf("Usage: wrt-installer [OPTION]... [WIDGET: ID/NAME/GUID/PATH]...\n"
267 "Operate with WebRuntime daemon: install, uninstall"
268 " and launch widgets.\n"
269 "Query list of installed widgets and setup up debugging support.\n"
271 "Exactly one option must be selected.\n"
272 "Mandatory arguments to long options are mandatory for short "
274 " -h, --help show this help\n"
275 " -p, --install-plugins install plugins\n"
277 "install or update widget package for given path\n"
278 " -if, --install-force "
279 "install forcibly widget package for given path\n"
281 "uninstall widget for given ID\n"
282 " -un, --uninstall for given package name "
283 "uninstall widget for given package name\n"
284 " -ug, --uninstall-guid "
285 "uninstall widget for given package path\n"
286 " -up, --uninstall-packagepath "
287 "uninstall widget for given Global Unique IDentifier\n"
293 void WrtInstaller::OnEventReceived(const WRTInstallerNS::QuitEvent& /*event*/)
298 LogDebug("Wrt Shutdown now");
299 SwitchToStep(&WrtInstaller::shutdownStep);
300 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
301 WRTInstallerNS::NextStepEvent());
303 LogDebug("Quiting application");
308 void WrtInstaller::OnEventReceived(
309 const WRTInstallerNS::NextStepEvent& /*event*/)
311 LogDebug("Executing next step");
315 void WrtInstaller::OnEventReceived(
316 const WRTInstallerNS::InstallPluginEvent& /*event*/)
318 PluginInstallerData* privateData = new PluginInstallerData;
319 privateData->wrtInstaller = this;
321 if (!(*m_pluginsPaths).empty()) {
322 privateData->pluginPath = (*m_pluginsPaths).front();
323 (*m_pluginsPaths).pop_front();
325 wrt_install_plugin(privateData->pluginPath.c_str(),
326 static_cast<void*>(privateData),
327 &staticWrtPluginInstallationCallback,
328 &staticWrtPluginInstallProgressCb);
334 void WrtInstaller::initStep()
336 wrt_installer_init(this, staticWrtInitCallback);
339 void WrtInstaller::installStep()
341 LogDebug("Installing widget ...");
342 std::unique_ptr<char, free_deleter> packagePath(canonicalize_file_name(
343 m_packagePath.c_str()));
345 wrt_install_widget(packagePath ? packagePath.get() : m_packagePath.c_str(),
346 this, &staticWrtStatusCallback,
347 (!m_quiet || m_installByPkgmgr)
348 ? &staticWrtInstallProgressCallback : NULL,
353 void WrtInstaller::installPluginsStep()
355 LogDebug("Installing plugins ...");
357 if (m_startupPluginInstallation) {
358 LogInfo("Plugin installation started because new plugin package found");
359 } else if (!PluginUtils::lockPluginInstallation()) {
360 LogError("Failed to open plugin installation lock file"
361 " Plugins are currently installed by other process");
362 staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK,
367 std::string PLUGIN_PATH = std::string(GlobalConfig::GetDevicePluginPath());
370 dir = opendir(PLUGIN_PATH.c_str());
376 LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
377 struct dirent* libdir;
381 std::list<std::string> pluginsPaths;
383 while ((libdir = readdir(dir)) != 0) {
384 if (strcmp(libdir->d_name, ".") == 0 ||
385 strcmp(libdir->d_name, "..") == 0)
390 std::string path = PLUGIN_PATH;
392 path += libdir->d_name;
396 if (stat(path.c_str(), &tmp) == -1) {
397 LogError("Failed to open file" << path);
401 if (!S_ISDIR(tmp.st_mode)) {
402 LogError("Not a directory" << path);
406 pluginsPaths.push_back(path);
409 //set nb of plugins to install
410 //this value indicate how many callbacks are expected
411 m_numPluginsToInstall = pluginsPaths.size();
412 LogInfo("Plugins to install: " << m_numPluginsToInstall);
413 m_pluginsPaths = pluginsPaths;
415 m_totalPlugins = m_numPluginsToInstall;
416 DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>
417 ::PostEvent(WRTInstallerNS::InstallPluginEvent());
419 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
420 LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
421 << DPL::GetErrnoString());
425 void WrtInstaller::uninstallStep()
427 LogDebug("Uninstalling widget ...");
428 wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
429 (!m_quiet || m_installByPkgmgr)
430 ? &staticWrtUninstallProgressCallback : NULL);
433 void WrtInstaller::uninstallPkgNameStep()
435 LogDebug("Uninstalling widget ...");
436 WrtErrStatus status = wrt_get_widget_by_pkgname(m_name, &m_handle);
437 if (status == WRT_SUCCESS) {
438 LogDebug("Get Widget Handle by package name : " << m_handle);
439 wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
440 (!m_quiet || m_installByPkgmgr)
441 ? &staticWrtUninstallProgressCallback : NULL);
443 printf("failed: can not uninstall widget\n");
444 LogError("Fail to uninstalling widget... ");
446 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
447 WRTInstallerNS::QuitEvent());
451 void WrtInstaller::uninstallGuidStep()
453 LogDebug("Uninstalling widget ...");
454 WrtErrStatus status = wrt_get_widget_by_guid(m_name, &m_handle);
455 if (status == WRT_SUCCESS) {
456 LogDebug("Get Widget Handle by guid : " << m_handle);
457 wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
458 !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
460 printf("failed: can not uninstall widget\n");
461 LogError("Fail to uninstalling widget... ");
463 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
464 WRTInstallerNS::QuitEvent());
468 void WrtInstaller::unistallWgtFileStep()
470 LogDebug("Uninstalling widget ...");
475 ConfigParserData configInfo;
478 std::unique_ptr<DPL::ZipInput> zipFile(
479 new DPL::ZipInput(m_packagePath));
481 // Open config.xml file
482 std::unique_ptr<DPL::ZipInput::File> configFile(
483 zipFile->OpenFile(CONFIG_XML));
486 DPL::BinaryQueue buffer;
487 DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
488 DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
489 DPL::Copy(&inputAdapter, &outputAdapter);
490 parser.Parse(&buffer,
492 new RootParser<WidgetParser>(configInfo,
493 DPL::FromUTF32String(
496 DPL::OptionalString widgetGUID = configInfo.widget_id;
498 std::string guid = DPL::ToUTF8String(*widgetGUID);
500 WrtErrStatus status = wrt_get_widget_by_guid(guid, &m_handle);
501 if (status == WRT_SUCCESS) {
502 LogDebug("Get Widget Handle by guid : " << m_handle);
503 wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
504 !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
506 LogError("Fail to uninstalling widget... ");
508 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
509 WRTInstallerNS::QuitEvent());
512 Catch(DPL::ZipInput::Exception::OpenFailed)
514 LogError("Failed to open widget package");
515 printf("failed: widget package does not exist\n");
517 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
518 WRTInstallerNS::QuitEvent());
520 Catch(DPL::ZipInput::Exception::OpenFileFailed)
522 printf("failed: widget config file does not exist\n");
523 LogError("Failed to open config.xml file");
525 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
526 WRTInstallerNS::QuitEvent());
528 Catch(ElementParser::Exception::ParseError)
530 printf("failed: can not parse config file\n");
531 LogError("Failed to parse config.xml file");
533 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
534 WRTInstallerNS::QuitEvent());
538 void WrtInstaller::shutdownStep()
540 LogDebug("Closing Wrt connection ...");
542 wrt_installer_shutdown();
543 m_initialized = false;
544 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
545 WRTInstallerNS::QuitEvent());
549 void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
552 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
555 if (status == WRT_SUCCESS) {
556 LogDebug("Init succesfull");
557 This->m_initialized = true;
558 This->m_returnStatus = 0;
560 if (This->popupsEnabled()) {
561 This->m_popup = new InstallerPopup;
562 This->m_popup->init();
565 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
566 ::PostEvent(WRTInstallerNS::NextStepEvent());
568 LogError("Init unsuccesfull");
569 This->m_returnStatus = -1;
570 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
571 WRTInstallerNS::QuitEvent());
575 void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
579 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
582 Step current = This->GetCurrentStep();
583 DPL::String resultMsg;
584 std::string printMsg;
586 if (current == &WrtInstaller::installStep)
588 resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
589 printMsg = "installed";
590 } else if (current == &WrtInstaller::uninstallStep ||
591 current == &WrtInstaller::uninstallPkgNameStep ||
592 current == &WrtInstaller::uninstallGuidStep ||
593 current == &WrtInstaller::unistallWgtFileStep)
595 resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
596 printMsg = "uninstalled";
599 if (WRT_SUCCESS != status) {
601 LogDebug("Step failed");
602 This->m_returnStatus = -1;
604 if (This->popupsEnabled()) {
605 resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
606 This->m_popup->showPopup(This, resultMsg, failResultCallback);
608 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
609 ::PostEvent(WRTInstallerNS::QuitEvent());
613 case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE:
614 This->m_returnStatus = 1; //this status is specific
615 printf("failed: invalid widget package\n");
618 case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST:
619 printf("failed: widget package does not exist\n");
622 case WRT_INSTALLER_ERROR_FACTORY_WIDGET:
623 printf("failed: factory widget\n");
626 case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING:
627 printf("failed: already uninstalling\n");
630 case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
631 printf("failed: out of disk space\n");
634 case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE:
635 printf("failed: invalid certificate\n");
638 case WRT_INSTALLER_ERROR_ALREADY_INSTALLED:
639 printf("failed: already installed\n");
642 case WRT_INSTALLER_ERROR_INTERNAL:
643 printf("failed: internal error\n");
646 case WRT_INSTALLER_ERROR_NOT_ALLOWED:
647 printf("failed: installation or update not allowed; invalid"
651 case WRT_INSTALLER_ERROR_DEFERRED:
652 printf("deferred: widget update will continue after the widget"
653 " has been stopped\n");
656 case WRT_INSTALLER_ERROR_DATABASE_FAILURE:
657 printf("failed: database failure\n");
660 case WRT_INSTALLER_ERROR_OSPSVC:
661 printf("failed: during installation or uninstallation osp service\n");
664 case WRT_INSTALLER_ERROR_UNKNOWN:
665 printf("failed: unknown error\n");
673 printf("%s : %s\n", printMsg.c_str(), tizenId.c_str());
674 LogDebug("Status succesfull");
675 This->m_returnStatus = 0;
676 resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
678 if (This->popupsEnabled()) {
679 This->m_popup->showPopup(This, resultMsg, showResultCallback);
681 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
682 ::PostEvent(WRTInstallerNS::NextStepEvent());
687 void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
692 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
694 WrtInstaller *This = static_cast<WrtInstaller*>(data->wrtInstaller);
696 std::string path = std::string(data->pluginPath);
699 This->m_numPluginsToInstall--;
700 LogDebug("Plugins to install: " << This->m_numPluginsToInstall);
702 if (This->m_numPluginsToInstall < 1) {
703 LogDebug("All plugins installation completed");
705 //remove installation request
706 if (!PluginUtils::removeInstallationRequiredFlag()) {
707 LogInfo("Failed to remove file initializing plugin installation");
711 if (!PluginUtils::unlockPluginInstallation()) {
712 LogInfo("Failed to remove installation lock");
715 if (This->popupsEnabled()) {
716 This->m_popup->init();
717 elm_progressbar_value_set(This->m_popup->m_progressbar, 100.0);
718 evas_object_show(This->m_popup->m_popup);
721 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
722 ::PostEvent(WRTInstallerNS::NextStepEvent());
724 if (This->popupsEnabled()) {
725 This->m_popup->init();
726 float percent = (This->m_totalPlugins - This->m_numPluginsToInstall)/(float)This->m_totalPlugins;
727 elm_progressbar_value_set(This->m_popup->m_progressbar, percent);
728 evas_object_show(This->m_popup->m_popup);
731 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>::PostEvent(
732 WRTInstallerNS::InstallPluginEvent());
735 if (WRT_SUCCESS == status) {
736 This->m_returnStatus = 0;
737 LogDebug("One plugin Installation succesfull: " << path);
742 LogWarning("One of the plugins installation failed!: " << path);
744 if (WRT_PLUGIN_INSTALLER_ERROR_WAITING == status) {
745 LogInfo("Plugin installation is waiting for dependencies");
749 case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
750 LogError("failed: wrong path to plugin directory\n");
753 case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
754 LogError("failed: plugin metafile error\n");
757 case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
758 LogError("failed: plugin already installed\n");
761 case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
762 LogError("failed: plugin library: missing symbols or structures\n");
765 case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
766 LogError("failed: unknown error\n");
774 void WrtInstaller::staticWrtPluginInstallProgressCb(float percent,
775 const char* description,
778 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
780 std::string path = std::string(data->pluginPath);
782 LogInfo("Plugin Installation: " << path <<
783 " progress: " << percent <<
784 "description " << description);
787 void WrtInstaller::staticWrtInstallProgressCallback(float percent,
788 const char* description, void* userdata)
790 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
791 std::stringstream percentStr;
792 LogInfo(" progress: " << percent <<
793 " description: " << description);
795 if (This->popupsEnabled()) {
796 This->m_popup->init();
797 elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
798 evas_object_show(This->m_popup->m_popup);
801 void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
802 const char* description, void* userdata)
804 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
805 std::stringstream percentStr;
806 LogInfo(" progress: " << percent <<
807 " description: " << description);
809 if (This->popupsEnabled()) {
810 This->m_popup->init();
811 elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
812 evas_object_show(This->m_popup->m_popup);
816 WrtInstaller::InstallerPopup::InstallerPopup() :
823 WrtInstaller::InstallerPopup::~InstallerPopup()
825 LogDebug("App Finished");
828 void WrtInstaller::InstallerPopup::init()
830 LogDebug("Window Init");
834 m_win = createWin("wrt-installer");
837 m_popup = elm_popup_add(m_win);
839 // create progressbar
840 m_progressbar = elm_progressbar_add(m_popup);
841 elm_object_style_set(m_progressbar, "list_progress");
842 elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
843 evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
845 evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
847 elm_object_content_set(m_popup, m_progressbar);
848 elm_progressbar_value_set(m_progressbar, 0.0);
849 evas_object_show(m_progressbar);
851 evas_object_show(m_popup);
852 evas_object_show(m_win);
856 Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
859 win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
865 elm_win_alpha_set(win, EINA_TRUE);
866 elm_win_title_set(win, name);
867 elm_win_borderless_set(win, EINA_TRUE);
870 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
871 evas_object_resize(win, w, h);
875 void WrtInstaller::InstallerPopup::showPopup(void* userdata,
876 const DPL::String& pkgMsg,
877 ShowResultCallback callback)
882 LogDebug("Result Popup Created");
883 evas_object_del(m_popup);
886 m_popup = elm_popup_add(m_win);
890 btn = elm_button_add(m_popup);
892 evas_object_del(m_popup);
895 elm_object_text_set(btn, "OK");
896 evas_object_smart_callback_add(btn, "clicked", callback, userdata);
897 elm_object_part_content_set(m_popup, "button1", btn);
898 elm_object_part_text_set(m_popup, "title,text", "RESULT");
899 elm_object_text_set(m_popup, DPL::ToUTF8String(pkgMsg).c_str());
901 evas_object_show(m_popup);
902 evas_object_show(m_win);
906 void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
907 void* /*event_info*/)
909 WrtInstaller *This = static_cast<WrtInstaller*>(data);
912 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
913 ::PostEvent(WRTInstallerNS::NextStepEvent());
916 void WrtInstaller::failResultCallback(void *data, Evas_Object* /*obj*/,
917 void* /*event_info*/)
919 WrtInstaller *This = static_cast<WrtInstaller*>(data);
922 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
923 ::PostEvent(WRTInstallerNS::QuitEvent());
926 void WrtInstaller::installNewPlugins()
928 LogDebug("Install new plugins");
930 if (!PluginUtils::lockPluginInstallation()) {
931 LogInfo("Lock NOT created");
935 if (!PluginUtils::checkPluginInstallationRequired()) {
936 LogDebug("Plugin installation not required");
937 PluginUtils::unlockPluginInstallation();
941 m_startupPluginInstallation = true;
942 AddStep(&WrtInstaller::installPluginsStep);
945 bool WrtInstaller::popupsEnabled() const
947 return !m_quiet && !GlobalSettings::PopupsTestModeEnabled();
950 int main(int argc, char *argv[])
952 // Output on stdout will be flushed after every newline character,
953 // even if it is redirected to a pipe. This is useful for running
954 // from a script and parsing output.
955 // (Standard behavior of stdlib is to use full buffering when
956 // redirected to a pipe, which means even after an end of line
957 // the output may not be flushed).
960 // Check and re-set the file open limitation
962 if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) {
963 LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" );
964 LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" );
966 if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) {
967 rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER;
968 rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER;
969 if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) {
970 LogError("setrlimit is fail!!");
974 LogError("getrlimit is fail!!");
977 // set evas backend type for emulator
978 // popup isn't showed in the emulator,
979 // if backend isn't set to SW backend
980 if (GlobalSettings::IsEmulator()) {
981 if (setenv("ELM_ENGINE", "x11", 1)) {
982 LogDebug("Enable backend");
986 WrtInstaller app(argc, argv);
987 int ret = app.Exec();
988 LogDebug("App returned: " << ret);
989 ret = app.getReturnStatus();
990 LogDebug("WrtInstaller returned: " << ret);