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/utils/wrt_global_settings.h>
47 #include "option_parser.h"
48 #include <parser_runner.h>
49 #include <widget_parser.h>
50 #include <root_parser.h>
51 #include <pkg-manager/pkgmgr_signal.h>
53 #define NOFILE_CNT_FOR_INSTALLER 9999
55 using namespace WrtDB;
57 namespace { // anonymous
58 const char AUL_ARG_KEY[] = "widget_arg";
59 const char * const PKGMGR_INSTALL_MSG = "Install widget";
60 const char * const PKGMGR_UNINSTALL_MSG = "Uninstall widget";
62 const double BASE_LAYOUT_W = 720.0f;
63 const double BASE_LAYOUT_H = 1280.0f;
65 const char * const CONFIG_XML = "config.xml";
69 void operator()(void* x) { free(x); }
72 struct PluginInstallerData
75 std::string pluginPath;
77 } // namespace anonymous
79 WrtInstaller::WrtInstaller(int argc, char **argv) :
80 Application(argc, argv, "backend", false),
81 DPL::TaskDecl<WrtInstaller>(this),
85 m_numPluginsToInstall(0),
88 m_installByPkgmgr(false),
91 m_startupPluginInstallation(false)
94 LogDebug("App Created");
97 WrtInstaller::~WrtInstaller()
99 LogDebug("App Finished");
102 void WrtInstaller::OnStop()
104 LogInfo("Stopping Dummy Client");
107 void WrtInstaller::OnCreate()
109 LogInfo("Creating DummyClient");
111 AddStep(&WrtInstaller::initStep);
113 std::string arg = m_argv[0];
116 return showHelpAndQuit();
121 if (arg.find("wrt-installer") != std::string::npos)
124 return showHelpAndQuit();
128 if (arg == "-h" || arg == "--help") {
130 return showHelpAndQuit();
134 return showHelpAndQuit();
135 } else if (arg == "-p" || arg == "--install-plugins") {
137 return showHelpAndQuit();
139 if (!m_startupPluginInstallation) {
140 AddStep(&WrtInstaller::installPluginsStep);
142 LogInfo("Plugin installation alredy started");
144 } else if (arg == "-i" || arg == "--install") {
146 return showHelpAndQuit();
149 m_packagePath = m_argv[2];
150 m_installPolicy = WRT_WIM_POLICY_WAC;
151 AddStep(&WrtInstaller::installStep);
152 } else if (arg == "-if" || arg == "--install-force") {
154 return showHelpAndQuit();
157 m_packagePath = m_argv[2];
158 m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL;
159 AddStep(&WrtInstaller::installStep);
160 } else if (arg == "-u" || arg == "--uninstall") {
162 return showHelpAndQuit();
165 m_handle = atoi(m_argv[2]);
166 AddStep(&WrtInstaller::uninstallStep);
167 } else if (arg == "-un" || arg == "--uninstall-name") {
169 return showHelpAndQuit();
172 AddStep(&WrtInstaller::uninstallPkgNameStep);
173 } else if (arg == "-ug" || arg == "--uninstall-guid") {
175 return showHelpAndQuit();
178 AddStep(&WrtInstaller::uninstallGuidStep);
179 } else if (arg == "-up" || arg == "--uninstall-packagepath") {
181 return showHelpAndQuit();
183 m_packagePath = m_argv[2];
184 AddStep(&WrtInstaller::unistallWgtFileStep);
186 return showHelpAndQuit();
189 } else if (arg.find("backend") != std::string::npos) {
190 using namespace PackageManager;
191 m_installByPkgmgr = true;
193 PkgmgrSignalSingleton::Instance().initialize(m_argc, m_argv);
194 m_quiet = PkgmgrSignalSingleton::Instance().isNoPopupRequired();
195 LogDebug("backend m_quiet"<<m_quiet);
197 int reqType = PkgmgrSignalSingleton::Instance().getRequestedType();
200 case PKGMGR_REQ_INSTALL:
201 m_packagePath = m_argv[4];
202 m_installPolicy = WRT_WIM_POLICY_WAC;
203 AddStep(&WrtInstaller::installStep);
205 case PKGMGR_REQ_UNINSTALL:
207 AddStep(&WrtInstaller::uninstallPkgNameStep);
210 LogDebug("Not available type");
214 // Launch widget based on application basename
215 size_t pos = arg.find_last_of('/');
217 if (pos != std::string::npos) {
218 arg = arg.erase(0, pos + 1);
221 if (sscanf(arg.c_str(), "%i", &m_handle) != 1) {
222 printf("failed: invalid widget handle\n");
223 return showHelpAndQuit();
226 LogDebug("Widget Id: " << m_handle << " (" << arg << ")");
229 AddStep(&WrtInstaller::shutdownStep);
230 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
231 WRTInstallerNS::NextStepEvent());
234 void WrtInstaller::OnReset(bundle *b)
236 const char * bundledVal = bundle_get_val(b, AUL_ARG_KEY);
237 if (bundledVal != NULL) {
238 m_bundleValue = bundledVal;
239 LogInfo("Bundled value for (" << AUL_ARG_KEY << ") key received: " <<
244 int WrtInstaller::getReturnStatus() const
246 if (!m_returnStatus) {
253 void WrtInstaller::OnTerminate()
255 LogDebug("Wrt Shutdown now");
256 PluginUtils::unlockPluginInstallation();
258 wrt_installer_shutdown();
263 void WrtInstaller::showHelpAndQuit()
265 printf("Usage: wrt-installer [OPTION]... [WIDGET: ID/NAME/GUID/PATH]...\n"
266 "Operate with WebRuntime daemon: install, uninstall"
267 " and launch widgets.\n"
268 "Query list of installed widgets and setup up debugging support.\n"
270 "Exactly one option must be selected.\n"
271 "Mandatory arguments to long options are mandatory for short "
273 " -h, --help show this help\n"
274 " -p, --install-plugins install plugins\n"
276 "install or update widget package for given path\n"
277 " -if, --install-force "
278 "install forcibly widget package for given path\n"
280 "uninstall widget for given ID\n"
281 " -un, --uninstall for given package name "
282 "uninstall widget for given package name\n"
283 " -ug, --uninstall-guid "
284 "uninstall widget for given package path\n"
285 " -up, --uninstall-packagepath "
286 "uninstall widget for given Global Unique IDentifier\n"
292 void WrtInstaller::OnEventReceived(const WRTInstallerNS::QuitEvent& /*event*/)
297 LogDebug("Wrt Shutdown now");
298 SwitchToStep(&WrtInstaller::shutdownStep);
299 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
300 WRTInstallerNS::NextStepEvent());
302 LogDebug("Quiting application");
307 void WrtInstaller::OnEventReceived(
308 const WRTInstallerNS::NextStepEvent& /*event*/)
310 LogDebug("Executing next step");
314 void WrtInstaller::OnEventReceived(
315 const WRTInstallerNS::InstallPluginEvent& /*event*/)
317 PluginInstallerData* privateData = new PluginInstallerData;
318 privateData->wrtInstaller = this;
320 if (!(*m_pluginsPaths).empty()) {
321 privateData->pluginPath = (*m_pluginsPaths).front();
322 (*m_pluginsPaths).pop_front();
324 wrt_install_plugin(privateData->pluginPath.c_str(),
325 static_cast<void*>(privateData),
326 &staticWrtPluginInstallationCallback,
327 &staticWrtPluginInstallProgressCb);
333 void WrtInstaller::initStep()
335 wrt_installer_init(this, staticWrtInitCallback);
338 void WrtInstaller::installStep()
340 LogDebug("Installing widget ...");
341 std::unique_ptr<char, free_deleter> packagePath(canonicalize_file_name(
342 m_packagePath.c_str()));
344 wrt_install_widget(packagePath ? packagePath.get() : m_packagePath.c_str(),
345 this, &staticWrtStatusCallback,
346 (!m_quiet || m_installByPkgmgr)
347 ? &staticWrtInstallProgressCallback : NULL,
352 void WrtInstaller::installPluginsStep()
354 LogDebug("Installing plugins ...");
356 if (m_startupPluginInstallation) {
357 LogInfo("Plugin installation started because new plugin package found");
358 } else if (!PluginUtils::lockPluginInstallation()) {
359 LogError("Failed to open plugin installation lock file"
360 " Plugins are currently installed by other process");
361 staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK,
366 std::string PLUGIN_PATH = std::string(GlobalConfig::GetDevicePluginPath());
369 dir = opendir(PLUGIN_PATH.c_str());
375 LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
376 struct dirent* libdir;
380 std::list<std::string> pluginsPaths;
382 while ((libdir = readdir(dir)) != 0) {
383 if (strcmp(libdir->d_name, ".") == 0 ||
384 strcmp(libdir->d_name, "..") == 0)
389 std::string path = PLUGIN_PATH;
391 path += libdir->d_name;
395 if (stat(path.c_str(), &tmp) == -1) {
396 LogError("Failed to open file" << path);
400 if (!S_ISDIR(tmp.st_mode)) {
401 LogError("Not a directory" << path);
405 pluginsPaths.push_back(path);
408 //set nb of plugins to install
409 //this value indicate how many callbacks are expected
410 m_numPluginsToInstall = pluginsPaths.size();
411 LogInfo("Plugins to install: " << m_numPluginsToInstall);
412 m_pluginsPaths = pluginsPaths;
414 m_totalPlugins = m_numPluginsToInstall;
415 DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>
416 ::PostEvent(WRTInstallerNS::InstallPluginEvent());
418 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
419 LogError("Failed to close dir: " << dir);
423 void WrtInstaller::uninstallStep()
425 LogDebug("Uninstalling widget ...");
426 wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
427 (!m_quiet || m_installByPkgmgr)
428 ? &staticWrtUninstallProgressCallback : NULL);
431 void WrtInstaller::uninstallPkgNameStep()
433 LogDebug("Uninstalling widget ...");
434 WrtErrStatus status = wrt_get_widget_by_pkgname(m_name, &m_handle);
435 if (status == WRT_SUCCESS) {
436 LogDebug("Get Widget Handle by package name : " << m_handle);
437 wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
438 (!m_quiet || m_installByPkgmgr)
439 ? &staticWrtUninstallProgressCallback : NULL);
441 printf("failed: can not uninstall widget\n");
442 LogError("Fail to uninstalling widget... ");
444 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
445 WRTInstallerNS::QuitEvent());
449 void WrtInstaller::uninstallGuidStep()
451 LogDebug("Uninstalling widget ...");
452 WrtErrStatus status = wrt_get_widget_by_guid(m_name, &m_handle);
453 if (status == WRT_SUCCESS) {
454 LogDebug("Get Widget Handle by guid : " << m_handle);
455 wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
456 !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
458 printf("failed: can not uninstall widget\n");
459 LogError("Fail to uninstalling widget... ");
461 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
462 WRTInstallerNS::QuitEvent());
466 void WrtInstaller::unistallWgtFileStep()
468 LogDebug("Uninstalling widget ...");
473 ConfigParserData configInfo;
476 std::unique_ptr<DPL::ZipInput> zipFile(
477 new DPL::ZipInput(m_packagePath));
479 // Open config.xml file
480 std::unique_ptr<DPL::ZipInput::File> configFile(
481 zipFile->OpenFile(CONFIG_XML));
484 DPL::BinaryQueue buffer;
485 DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
486 DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
487 DPL::Copy(&inputAdapter, &outputAdapter);
488 parser.Parse(&buffer,
490 new RootParser<WidgetParser>(configInfo,
491 DPL::FromUTF32String(
494 DPL::OptionalString widgetGUID = configInfo.widget_id;
496 std::string guid = DPL::ToUTF8String(*widgetGUID);
498 WrtErrStatus status = wrt_get_widget_by_guid(guid, &m_handle);
499 if (status == WRT_SUCCESS) {
500 LogDebug("Get Widget Handle by guid : " << m_handle);
501 wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
502 !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
504 LogError("Fail to uninstalling widget... ");
506 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
507 WRTInstallerNS::QuitEvent());
510 Catch(DPL::ZipInput::Exception::OpenFailed)
512 LogError("Failed to open widget package");
513 printf("failed: widget package does not exist\n");
515 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
516 WRTInstallerNS::QuitEvent());
518 Catch(DPL::ZipInput::Exception::OpenFileFailed)
520 printf("failed: widget config file does not exist\n");
521 LogError("Failed to open config.xml file");
523 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
524 WRTInstallerNS::QuitEvent());
526 Catch(ElementParser::Exception::ParseError)
528 printf("failed: can not parse config file\n");
529 LogError("Failed to parse config.xml file");
531 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
532 WRTInstallerNS::QuitEvent());
536 void WrtInstaller::shutdownStep()
538 LogDebug("Closing Wrt connection ...");
540 wrt_installer_shutdown();
541 m_initialized = false;
542 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
543 WRTInstallerNS::QuitEvent());
547 void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
550 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
553 if (status == WRT_SUCCESS) {
554 LogDebug("Init succesfull");
555 This->m_initialized = true;
556 This->m_returnStatus = 0;
558 if (This->popupsEnabled()) {
559 This->m_popup = new InstallerPopup;
560 This->m_popup->init();
563 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
564 ::PostEvent(WRTInstallerNS::NextStepEvent());
566 LogError("Init unsuccesfull");
567 This->m_returnStatus = -1;
568 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
569 WRTInstallerNS::QuitEvent());
573 void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
577 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
580 Step current = This->GetCurrentStep();
581 DPL::String resultMsg;
582 std::string printMsg;
584 if (current == &WrtInstaller::installStep)
586 resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
587 printMsg = "installed";
588 } else if (current == &WrtInstaller::uninstallStep ||
589 current == &WrtInstaller::uninstallPkgNameStep ||
590 current == &WrtInstaller::uninstallGuidStep ||
591 current == &WrtInstaller::unistallWgtFileStep)
593 resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
594 printMsg = "uninstalled";
597 if (WRT_SUCCESS != status) {
599 LogDebug("Step failed");
600 This->m_returnStatus = -1;
602 if (This->popupsEnabled()) {
603 resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
604 This->m_popup->showPopup(This, resultMsg, failResultCallback);
606 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
607 ::PostEvent(WRTInstallerNS::QuitEvent());
611 case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE:
612 This->m_returnStatus = 1; //this status is specific
613 printf("failed: invalid widget package\n");
616 case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST:
617 printf("failed: widget package does not exist\n");
620 case WRT_INSTALLER_ERROR_FACTORY_WIDGET:
621 printf("failed: factory widget\n");
624 case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING:
625 printf("failed: already uninstalling\n");
628 case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
629 printf("failed: out of disk space\n");
632 case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE:
633 printf("failed: invalid certificate\n");
636 case WRT_INSTALLER_ERROR_ALREADY_INSTALLED:
637 printf("failed: already installed\n");
640 case WRT_INSTALLER_ERROR_INTERNAL:
641 printf("failed: internal error\n");
644 case WRT_INSTALLER_ERROR_NOT_ALLOWED:
645 printf("failed: installation or update not allowed; invalid"
649 case WRT_INSTALLER_ERROR_DEFERRED:
650 printf("deferred: widget update will continue after the widget"
651 " has been stopped\n");
654 case WRT_INSTALLER_ERROR_DATABASE_FAILURE:
655 printf("failed: database failure\n");
658 case WRT_INSTALLER_ERROR_OSPSVC:
659 printf("failed: during installation or uninstallation osp service\n");
662 case WRT_INSTALLER_ERROR_UNKNOWN:
663 printf("failed: unknown error\n");
671 printf("%s : %s\n", printMsg.c_str(), tizenId.c_str());
672 LogDebug("Status succesfull");
673 This->m_returnStatus = 0;
674 resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
676 if (This->popupsEnabled()) {
677 This->m_popup->showPopup(This, resultMsg, showResultCallback);
679 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
680 ::PostEvent(WRTInstallerNS::NextStepEvent());
685 void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
690 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
692 WrtInstaller *This = static_cast<WrtInstaller*>(data->wrtInstaller);
694 std::string path = std::string(data->pluginPath);
697 This->m_numPluginsToInstall--;
698 LogDebug("Plugins to install: " << This->m_numPluginsToInstall);
700 if (This->m_numPluginsToInstall < 1) {
701 LogDebug("All plugins installation completed");
703 //remove installation request
704 if (!PluginUtils::removeInstallationRequiredFlag()) {
705 LogInfo("Failed to remove file initializing plugin installation");
709 if (!PluginUtils::unlockPluginInstallation()) {
710 LogInfo("Failed to remove installation lock");
713 if (This->popupsEnabled()) {
714 This->m_popup->init();
715 elm_progressbar_value_set(This->m_popup->m_progressbar, 100.0);
716 evas_object_show(This->m_popup->m_popup);
719 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
720 ::PostEvent(WRTInstallerNS::NextStepEvent());
722 if (This->popupsEnabled()) {
723 This->m_popup->init();
724 float percent = (This->m_totalPlugins - This->m_numPluginsToInstall)/(float)This->m_totalPlugins;
725 elm_progressbar_value_set(This->m_popup->m_progressbar, percent);
726 evas_object_show(This->m_popup->m_popup);
729 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>::PostEvent(
730 WRTInstallerNS::InstallPluginEvent());
733 if (WRT_SUCCESS == status) {
734 This->m_returnStatus = 0;
735 LogDebug("One plugin Installation succesfull: " << path);
740 LogWarning("One of the plugins installation failed!: " << path);
742 if (WRT_PLUGIN_INSTALLER_ERROR_WAITING == status) {
743 LogInfo("Plugin installation is waiting for dependencies");
747 case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
748 LogError("failed: wrong path to plugin directory\n");
751 case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
752 LogError("failed: plugin metafile error\n");
755 case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
756 LogError("failed: plugin already installed\n");
759 case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
760 LogError("failed: plugin library: missing symbols or structures\n");
763 case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
764 LogError("failed: unknown error\n");
772 void WrtInstaller::staticWrtPluginInstallProgressCb(float percent,
773 const char* description,
776 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
778 std::string path = std::string(data->pluginPath);
780 LogInfo("Plugin Installation: " << path <<
781 " progress: " << percent <<
782 "description " << description);
785 void WrtInstaller::staticWrtInstallProgressCallback(float percent,
786 const char* description, void* userdata)
788 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
789 std::stringstream percentStr;
790 LogInfo(" progress: " << percent <<
791 " description: " << description);
793 if (This->popupsEnabled()) {
794 This->m_popup->init();
795 elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
796 evas_object_show(This->m_popup->m_popup);
799 void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
800 const char* description, void* userdata)
802 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
803 std::stringstream percentStr;
804 LogInfo(" progress: " << percent <<
805 " description: " << description);
807 if (This->popupsEnabled()) {
808 This->m_popup->init();
809 elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
810 evas_object_show(This->m_popup->m_popup);
814 WrtInstaller::InstallerPopup::InstallerPopup() :
821 WrtInstaller::InstallerPopup::~InstallerPopup()
823 LogDebug("App Finished");
826 void WrtInstaller::InstallerPopup::init()
828 LogDebug("Window Init");
832 m_win = createWin("wrt-installer");
835 m_popup = elm_popup_add(m_win);
837 // create progressbar
838 m_progressbar = elm_progressbar_add(m_popup);
839 elm_object_style_set(m_progressbar, "list_progress");
840 elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
841 evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
843 evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
845 elm_object_content_set(m_popup, m_progressbar);
846 elm_progressbar_value_set(m_progressbar, 0.0);
847 evas_object_show(m_progressbar);
849 evas_object_show(m_popup);
850 evas_object_show(m_win);
854 Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
857 win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
863 elm_win_alpha_set(win, EINA_TRUE);
864 elm_win_title_set(win, name);
865 elm_win_borderless_set(win, EINA_TRUE);
868 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
869 evas_object_resize(win, w, h);
873 void WrtInstaller::InstallerPopup::showPopup(void* userdata,
874 const DPL::String& pkgMsg,
875 ShowResultCallback callback)
880 LogDebug("Result Popup Created");
881 evas_object_del(m_popup);
884 m_popup = elm_popup_add(m_win);
888 btn = elm_button_add(m_popup);
890 evas_object_del(m_popup);
893 elm_object_text_set(btn, "OK");
894 evas_object_smart_callback_add(btn, "clicked", callback, userdata);
895 elm_object_part_content_set(m_popup, "button1", btn);
896 elm_object_part_text_set(m_popup, "title,text", "RESULT");
897 elm_object_text_set(m_popup, DPL::ToUTF8String(pkgMsg).c_str());
899 evas_object_show(m_popup);
900 evas_object_show(m_win);
904 void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
905 void* /*event_info*/)
907 WrtInstaller *This = static_cast<WrtInstaller*>(data);
910 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
911 ::PostEvent(WRTInstallerNS::NextStepEvent());
914 void WrtInstaller::failResultCallback(void *data, Evas_Object* /*obj*/,
915 void* /*event_info*/)
917 WrtInstaller *This = static_cast<WrtInstaller*>(data);
920 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
921 ::PostEvent(WRTInstallerNS::QuitEvent());
924 void WrtInstaller::installNewPlugins()
926 LogDebug("Install new plugins");
928 if (!PluginUtils::lockPluginInstallation()) {
929 LogInfo("Lock NOT created");
933 if (!PluginUtils::checkPluginInstallationRequired()) {
934 LogDebug("Plugin installation not required");
935 PluginUtils::unlockPluginInstallation();
939 m_startupPluginInstallation = true;
940 AddStep(&WrtInstaller::installPluginsStep);
943 bool WrtInstaller::popupsEnabled() const
945 return !m_quiet && !GlobalSettings::PopupsTestModeEnabled();
948 int main(int argc, char *argv[])
950 // Output on stdout will be flushed after every newline character,
951 // even if it is redirected to a pipe. This is useful for running
952 // from a script and parsing output.
953 // (Standard behavior of stdlib is to use full buffering when
954 // redirected to a pipe, which means even after an end of line
955 // the output may not be flushed).
958 // Check and re-set the file open limitation
960 if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) {
961 LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" );
962 LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" );
964 if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) {
965 rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER;
966 rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER;
967 if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) {
968 LogError("setrlimit is fail!!");
972 LogError("getrlimit is fail!!");
975 // set evas backend type for emulator
976 // popup isn't showed in the emulator,
977 // if backend isn't set to SW backend
978 if (GlobalSettings::IsEmulator()) {
979 if (setenv("ELM_ENGINE", "x11", 1)) {
980 LogDebug("Enable backend");
984 WrtInstaller app(argc, argv);
985 int ret = app.Exec();
986 LogDebug("App returned: " << ret);
987 ret = app.getReturnStatus();
988 LogDebug("WrtInstaller returned: " << ret);