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"
28 #include <dpl/optional.h>
29 #include <dpl/scoped_free.h>
30 #include <dpl/optional_typedefs.h>
31 #include <dpl/exception.h>
32 #include <dpl/sstream.h>
34 #include <dpl/wrt-dao-ro/global_config.h>
35 #include <dpl/localization/localization_utils.h>
36 #include <dpl/popup/popup_controller.h>
37 #include <dpl/optional_typedefs.h>
38 #include <dpl/string.h>
39 #include "option_parser.h"
41 #define PKGMGR_SEND_SIG(installer, pkg_name, key, val) \
42 if(pkgmgr_installer_send_signal(installer, PKG_TYPE, pkg_name, key, val)) {\
43 LogDebug("Failed to send signal to pkgmgr"); \
45 using namespace WrtDB;
46 namespace { // anonymous
47 const char AUL_ARG_KEY[] = "widget_arg";
48 const char PKGMGR_START_KEY[] = "start";
49 const char PKGMGR_END_KEY[] = "end";
50 const char PKG_TYPE[] = "wgt";
51 const char PKGMGR_PROGRESS_KEY[] = "install_percent";
52 const char PKGMGR_OK_VAL[] = "ok";
53 const char PKGMGR_FAIL_VAL[] = "fail";
54 const char PKGMGR_INSTALL_MSG[] = "Install widget";
55 const char PKGMGR_UNINSTALL_MSG[] = "Uninstall widget";
57 const double BASE_LAYOUT_W = 720.0f;
58 const double BASE_LAYOUT_H = 1280.0f;
60 struct PluginInstallerData
63 std::string pluginPath;
65 } // namespace anonymous
67 WrtInstaller::WrtInstaller(int argc, char **argv) :
68 Application(argc, argv, "backend", false),
69 DPL::TaskDecl<WrtInstaller>(this),
73 m_numPluginsToInstall(0),
77 m_installByPkgmgr(false),
81 m_startupPluginInstallation(false)
84 LogDebug("App Created");
87 WrtInstaller::~WrtInstaller()
89 LogDebug("App Finished");
92 void WrtInstaller::OnStop()
94 LogInfo("Stopping Dummy Client");
97 void WrtInstaller::OnCreate()
99 LogInfo("Creating DummyClient");
101 AddStep(&WrtInstaller::initStep);
103 std::string arg = m_argv[0];
106 return showHelpAndQuit();
111 if (arg.find("wrt-installer") != std::string::npos)
114 return showHelpAndQuit();
119 if (arg == "-h" || arg == "--help") {
121 return showHelpAndQuit();
126 } else if (arg == "-p" || arg == "--install-plugins") {
128 return showHelpAndQuit();
130 if (!m_startupPluginInstallation) {
131 AddStep(&WrtInstaller::installPluginsStep);
133 LogInfo("Plugin installation alredy started");
135 } else if (arg == "-i" || arg == "--install") {
137 return showHelpAndQuit();
140 m_packagePath = m_argv[2];
141 m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
142 AddStep(&WrtInstaller::installStep);
143 } else if (arg == "-iu" || arg == "--install-or-update") {
145 return showHelpAndQuit();
148 m_packagePath = m_argv[2];
149 m_installPolicy = WRT_WIM_POLICY_WAC;
150 AddStep(&WrtInstaller::installStep);
151 } else if (arg == "-if" || arg == "--install-force") {
153 return showHelpAndQuit();
156 m_packagePath = m_argv[2];
157 m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL;
158 AddStep(&WrtInstaller::installStep);
159 } else if (arg == "-inq" || arg == "--install-not-quiet") {
161 return showHelpAndQuit();
164 m_packagePath = m_argv[2];
165 m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
166 AddStep(&WrtInstaller::installStep);
167 } else if (arg == "-u" || arg == "--uninstall") {
169 return showHelpAndQuit();
172 m_handle = atoi(m_argv[2]);
173 AddStep(&WrtInstaller::uninstallStep);
174 } else if (arg == "-un" || arg == "--uninstall-name") {
176 return showHelpAndQuit();
179 AddStep(&WrtInstaller::uninstallPkgNameStep);
180 } else if (arg == "-ug" || arg == "--uninstall-guid") {
182 return showHelpAndQuit();
185 AddStep(&WrtInstaller::uninstallGuidStep);
186 } else if (arg == "-unq" || arg == "--uninstall-not-quiet") {
188 return showHelpAndQuit();
191 m_handle = atoi(m_argv[2]);
192 AddStep(&WrtInstaller::uninstallStep);
194 else if (arg == "--url") {
196 return showHelpAndQuit();
198 m_webAppUrl = m_argv[2];
200 DPL::OptionalString icon = OptionParser::QueryOption(m_argc,
203 if (!icon.IsNull()) {
204 m_webAppIcon = DPL::ToUTF8String(*icon);
207 } else if (arg.find("backend") != std::string::npos) {
208 m_installByPkgmgr = true;
212 m_installer = pkgmgr_installer_new();
213 if (!pkgmgr_installer_receive_request(m_installer, m_argc, m_argv)) {
214 //For package manager
215 int reqType = pkgmgr_installer_get_request_type(m_installer);
216 m_quiet = pkgmgr_installer_is_quiet(m_installer);
219 case PKGMGR_REQ_INSTALL:
220 m_packagePath = m_argv[4];
221 m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
222 AddStep(&WrtInstaller::installStep);
224 case PKGMGR_REQ_UNINSTALL:
226 AddStep(&WrtInstaller::uninstallPkgNameStep);
229 LogDebug("Not available type");
234 // Launch widget based on application basename
235 size_t pos = arg.find_last_of('/');
237 if (pos != std::string::npos) {
238 arg = arg.erase(0, pos + 1);
241 if (sscanf(arg.c_str(), "%i", &m_handle) != 1) {
242 printf("failed: invalid widget handle\n");
243 return showHelpAndQuit();
246 LogDebug("Widget Id: " << m_handle << " (" << arg << ")");
249 AddStep(&WrtInstaller::shutdownStep);
250 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
251 WRTInstallerNS::NextStepEvent());
254 void WrtInstaller::OnReset(bundle *b)
256 const char * bundledVal = bundle_get_val(b, AUL_ARG_KEY);
257 if (bundledVal != NULL) {
258 m_bundleValue = bundledVal;
259 LogInfo("Bundled value for (" << AUL_ARG_KEY << ") key received: " <<
264 int WrtInstaller::getReturnStatus() const
266 if (!m_returnStatus) {
273 void WrtInstaller::OnTerminate()
275 LogDebug("Wrt Shutdown now");
277 wrt_installer_shutdown();
282 void WrtInstaller::showHelpAndQuit()
284 printf("Usage: wrt-installer [OPTION]... [WIDGET: ID/NAME/GUID/PATH]...\n"
285 "Operate with WebRuntime daemon: install, uninstall"
286 " and launch widgets.\n"
287 "Query list of installed widgets and setup up debugging support.\n"
289 "Exactly one option must be selected.\n"
290 "Mandatory arguments to long options are mandatory for short "
292 " -h, --help show this help\n"
293 " -p, --install-plugins install plugins\n"
295 "install widget package for given path\n"
296 " -iu, --install-or-update "
297 "install or update widget package for given path\n"
298 " -if, --install-force "
299 "install forcibly widget package for given path\n"
300 " -inq, --install-not-quiet "
301 "install with popup \n"
303 "uninstall widget for given ID\n"
304 " -un, --uninstall for given package name "
305 "uninstall widget for given pakcage name\n"
306 " -ug, --uninstall-guid "
307 "uninstall widget for given Global Unique IDentifier\n"
308 " -unq, --uninstall-not-quiet "
309 "uninstall with popup \n"
311 "URL of the remote page for Web Application installed from browser\n"
313 "path to the icon for Web Application installed from browser\n"
319 void WrtInstaller::OnEventReceived(const WRTInstallerNS::QuitEvent& /*event*/)
324 LogDebug("Wrt Shutdown now");
325 SwitchToStep(&WrtInstaller::shutdownStep);
326 DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
327 WRTInstallerNS::NextStepEvent());
329 LogDebug("Quiting application");
334 void WrtInstaller::OnEventReceived(
335 const WRTInstallerNS::NextStepEvent& /*event*/)
337 LogDebug("Executing next step");
341 void WrtInstaller::OnEventReceived(
342 const WRTInstallerNS::InstallPluginEvent& /*event*/)
344 PluginInstallerData* privateData = new PluginInstallerData;
345 privateData->wrtInstaller = this;
347 if (!(*m_pluginsPaths).empty()) {
348 privateData->pluginPath = (*m_pluginsPaths).front();
349 (*m_pluginsPaths).pop_front();
351 wrt_install_plugin(privateData->pluginPath.c_str(),
352 static_cast<void*>(privateData),
353 &staticWrtPluginInstallationCallback,
354 &staticWrtPluginInstallProgressCb);
358 void WrtInstaller::initStep()
360 wrt_installer_init(this, staticWrtInitCallback);
363 void WrtInstaller::installStep()
365 LogDebug("Installing widget ...");
369 DPL::ScopedFree<char> packagePath(canonicalize_file_name(
370 m_packagePath.c_str()));
371 wrt_install_widget(packagePath ? packagePath.Get() : m_packagePath.c_str(),
372 this, &staticWrtStatusCallback,
373 (!m_quiet || m_installByPkgmgr)
374 ? &staticWrtInstallProgressCallback : NULL,
378 void WrtInstaller::installPluginsStep()
380 LogDebug("Installing plugins ...");
382 if (m_startupPluginInstallation) {
383 LogInfo("Plugin installation started because new plugin package found");
384 } else if (!PluginUtils::lockPluginInstallation()) {
385 LogError("Failed to open plugin installation lock file"
386 " Plugins are currently installed by other process");
387 staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK,
392 std::string PLUGIN_PATH = std::string(GlobalConfig::GetDevicePluginPath());
395 dir = opendir(PLUGIN_PATH.c_str());
401 LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
402 struct dirent* libdir;
406 std::list<std::string> pluginsPaths;
408 while ((libdir = readdir(dir)) != 0) {
409 if (strcmp(libdir->d_name, ".") == 0 ||
410 strcmp(libdir->d_name, "..") == 0)
415 std::string path = PLUGIN_PATH;
417 path += libdir->d_name;
421 if (stat(path.c_str(), &tmp) == -1) {
422 LogError("Failed to open file" << path);
426 if (!S_ISDIR(tmp.st_mode)) {
427 LogError("Not a directory" << path);
431 pluginsPaths.push_back(path);
434 //set nb of plugins to install
435 //this value indicate how many callbacks are expected
436 m_numPluginsToInstall = pluginsPaths.size();
437 LogInfo("Plugins to install: " << m_numPluginsToInstall);
438 m_pluginsPaths = pluginsPaths;
440 // install geolocation plugin
442 m_numPluginsToInstall++;
443 (*m_pluginsPaths).push_back(GlobalConfig::GetW3CGeolocationFeatureName());
446 m_totalPlugins = m_numPluginsToInstall;
447 DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>
448 ::PostEvent(WRTInstallerNS::InstallPluginEvent());
450 if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
451 LogError("Failed to close dir: " << dir);
455 void WrtInstaller::uninstallStep()
457 LogDebug("Uninstalling widget ...");
462 wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
463 (!m_quiet || m_installByPkgmgr)
464 ? &staticWrtUninstallProgressCallback : NULL);
467 void WrtInstaller::uninstallPkgNameStep()
469 LogDebug("Uninstalling widget ...");
474 WrtErrStatus status = wrt_get_widget_by_pkgname(m_name, &m_handle);
475 if (status == WRT_SUCCESS) {
476 LogDebug("Get Widget Handle by package name : " << m_handle);
477 wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
478 (!m_quiet || m_installByPkgmgr)
479 ? &staticWrtUninstallProgressCallback : NULL);
481 LogError("Fail to uninstalling widget... ");
483 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
484 WRTInstallerNS::QuitEvent());
488 void WrtInstaller::uninstallGuidStep()
490 LogDebug("Uninstalling widget ...");
495 WrtErrStatus status = wrt_get_widget_by_guid(m_name, &m_handle);
496 if (status == WRT_SUCCESS) {
497 LogDebug("Get Widget Handle by guid : " << m_handle);
498 wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
499 !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
501 LogError("Fail to uninstalling widget... ");
503 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
504 WRTInstallerNS::QuitEvent());
508 void WrtInstaller::shutdownStep()
510 LogDebug("Closing Wrt connection ...");
512 wrt_installer_shutdown();
513 m_initialized = false;
514 DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
515 WRTInstallerNS::QuitEvent());
519 void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
522 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
525 if (status == WRT_SUCCESS) {
526 LogDebug("Init succesfull");
527 This->m_initialized = true;
528 This->m_returnStatus = 0;
530 if (!This->m_quiet) {
531 This->m_popup = new InstallerPopup;
532 This->m_popup->init();
535 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
536 ::PostEvent(WRTInstallerNS::NextStepEvent());
538 LogError("Init unsuccesfull");
539 This->m_returnStatus = -1;
540 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
541 WRTInstallerNS::QuitEvent());
545 void WrtInstaller::staticWrtStatusCallback(int handle,
549 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
552 Step current = This->GetCurrentStep();
553 DPL::String resultMsg;
554 std::string printMsg;
556 if (current == &WrtInstaller::installStep)
558 resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
559 printMsg = "installed";
560 } else if (current == &WrtInstaller::uninstallStep ||
561 current == &WrtInstaller::uninstallPkgNameStep ||
562 current == &WrtInstaller::uninstallGuidStep)
564 resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
565 printMsg = "uninstalled";
568 if (WRT_SUCCESS != status) {
570 LogDebug("Step failed");
571 This->m_returnStatus = -1;
573 if (This->m_installByPkgmgr) {
574 PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
575 PKGMGR_END_KEY, PKGMGR_FAIL_VAL);
578 if (!This->m_quiet) {
579 resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_FAIL_VAL);
580 This->m_popup->showPopup(This, resultMsg, failResultCallback);
582 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
583 ::PostEvent(WRTInstallerNS::QuitEvent());
587 case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE:
588 This->m_returnStatus = 1; //this status is specific
589 printf("failed: invalid widget package\n");
592 case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST:
593 printf("failed: widget package does not exist\n");
596 case WRT_INSTALLER_ERROR_FACTORY_WIDGET:
597 printf("failed: factory widget\n");
600 case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING:
601 printf("failed: already uninstalling\n");
604 case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
605 printf("failed: out of disk space\n");
608 case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE:
609 printf("failed: invalid certificate\n");
612 case WRT_INSTALLER_ERROR_ALREADY_INSTALLED:
613 printf("failed: already installed\n");
616 case WRT_INSTALLER_ERROR_INTERNAL:
617 printf("failed: internal error\n");
620 case WRT_INSTALLER_ERROR_NOT_ALLOWED:
621 printf("failed: installation or update not allowed; invalid"
625 case WRT_INSTALLER_ERROR_DEFERRED:
626 printf("deferred: widget update will continue after the widget"
627 " has been stopped\n");
630 case WRT_INSTALLER_ERROR_DATABASE_FAILURE:
631 printf("failed: database failure\n");
634 case WRT_INSTALLER_ERROR_UNKNOWN:
635 printf("failed: unknown error\n");
643 printf("%s : %d\n", printMsg.c_str(), handle);
644 LogDebug("Status succesfull");
645 This->m_handle = handle;
646 This->m_returnStatus = 0;
647 resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_OK_VAL);
649 if (This->m_installByPkgmgr) {
650 PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
651 PKGMGR_END_KEY, PKGMGR_OK_VAL);
654 if (!This->m_quiet) {
655 This->m_popup->showPopup(This, resultMsg, showResultCallback);
657 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
658 ::PostEvent(WRTInstallerNS::NextStepEvent());
663 void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
668 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
670 WrtInstaller *This = static_cast<WrtInstaller*>(data->wrtInstaller);
672 std::string path = std::string(data->pluginPath);
675 This->m_numPluginsToInstall--;
676 LogDebug("Plugins to install: " << This->m_numPluginsToInstall);
678 if (This->m_numPluginsToInstall < 1) {
679 LogDebug("All plugins installation completed");
682 if (!PluginUtils::unlockPluginInstallation()) {
683 LogInfo("Failed to remove installation lock");
686 //remove installation request
687 if (!PluginUtils::removeInstallationRequiredFlag()) {
688 LogInfo("Failed to remove file initializing plugin installation");
691 if (!This->m_quiet) {
692 elm_progressbar_value_set(This->m_popup->m_progressbar, 100.0);
693 evas_object_show(This->m_popup->m_popup);
696 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
697 ::PostEvent(WRTInstallerNS::NextStepEvent());
699 if (!This->m_quiet) {
700 float percent = (This->m_totalPlugins - This->m_numPluginsToInstall)/(float)This->m_totalPlugins;
701 elm_progressbar_value_set(This->m_popup->m_progressbar, percent);
702 evas_object_show(This->m_popup->m_popup);
705 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>::PostEvent(
706 WRTInstallerNS::InstallPluginEvent());
709 if (WRT_SUCCESS == status) {
710 This->m_returnStatus = 0;
711 LogDebug("One plugin Installation succesfull: " << path);
716 LogWarning("One of the plugins installation failed!: " << path);
718 if (WRT_PLUGIN_INSTALLER_ERROR_WAITING == status) {
719 LogInfo("Plugin installation is waiting for dependencies");
723 case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
724 LogError("failed: wrong path to plugin directory\n");
727 case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
728 LogError("failed: plugin metafile error\n");
731 case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
732 LogError("failed: plugin already installed\n");
735 case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
736 LogError("failed: plugin library: missing symbols or structures\n");
739 case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
740 LogError("failed: unknown error\n");
748 void WrtInstaller::staticWrtPluginInstallProgressCb(float percent,
749 const char* description,
752 PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
754 std::string path = std::string(data->pluginPath);
756 LogInfo("Plugin Installation: " << path <<
757 " progress: " << percent <<
758 "description " << description);
761 void WrtInstaller::staticWrtInstallProgressCallback(float percent,
762 const char* description, void* userdata)
764 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
765 std::stringstream percentStr;
766 LogInfo(" progress: " << percent <<
767 "description " << description);
769 if (This->m_installByPkgmgr) {
770 if (This->m_sendSig) {
771 std::string desc = description;
772 size_t index = desc.find(" ");
773 std::string widgetId = desc.substr(0, index - 1);
774 This->m_name = desc.substr(index + 1, desc.length() - index);
776 PKGMGR_SEND_SIG(This->m_installer, widgetId.c_str(),
777 PKGMGR_START_KEY, "install");
778 PKGMGR_SEND_SIG(This->m_installer, widgetId.c_str(),
779 "change_pkg_name", This->m_name.c_str());
781 This->m_sendSig = false;
783 LogDebug("Broadcast Progress, pkgname" << This->m_name);
785 percentStr << static_cast<int>(percent);
786 PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
787 PKGMGR_PROGRESS_KEY, percentStr.str().c_str());
790 if (!This->m_quiet) {
791 elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
792 evas_object_show(This->m_popup->m_popup);
795 void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
796 const char* description, void* userdata)
798 WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
799 std::stringstream percentStr;
800 LogInfo(" progress: " << percent <<
801 "description " << description);
803 if (This->m_installByPkgmgr) {
804 if (This->m_sendSig) {
805 PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
806 PKGMGR_START_KEY, "uninstall");
807 This->m_sendSig = false;
809 LogDebug("Broadcast Progress, pkgname" << This->m_name);
811 percentStr << static_cast<int>(percent);
812 PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
813 PKGMGR_PROGRESS_KEY, percentStr.str().c_str());
816 if (!This->m_quiet) {
817 elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
818 evas_object_show(This->m_popup->m_popup);
822 WrtInstaller::InstallerPopup::InstallerPopup() :
829 WrtInstaller::InstallerPopup::~InstallerPopup()
831 LogDebug("App Finished");
834 void WrtInstaller::InstallerPopup::init()
836 LogDebug("Window Init");
839 m_win = createWin("wrt-installer");
841 // security popup uses installer window
842 using namespace DPL::Popup;
843 PopupControllerSingleton::Instance().setExternalCanvas(m_win);
844 evas_object_show(m_win);
847 m_popup = elm_popup_add(m_win);
849 // create progressbar
850 m_progressbar = elm_progressbar_add(m_popup);
851 elm_object_style_set(m_progressbar, "list_progress");
852 elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
853 evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
855 evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
857 elm_popup_content_set(m_popup, m_progressbar);
858 elm_progressbar_value_set(m_progressbar, 0.0);
859 evas_object_show(m_progressbar);
861 // set progressbar to popup
862 evas_object_show(m_popup);
865 Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
868 win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
874 unsigned char *prop_data = NULL;
875 double xScale, yScale, scale;
878 elm_win_alpha_set(win, EINA_TRUE);
879 elm_win_title_set(win, name);
880 elm_win_borderless_set(win, EINA_TRUE);
882 ecore_x_window_geometry_get(ecore_x_window_root_get(
883 ecore_x_window_focus_get()),
888 ret = ecore_x_window_prop_property_get(ecore_x_window_root_get(
889 ecore_x_window_focus_get()),
890 ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
891 ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
893 if (ret && prop_data) {
894 Assert(count != sizeof(int));
895 memcpy(&rotation, prop_data, sizeof(int));
900 evas_object_resize(win, w, h);
902 if (rotation != -1) {
903 elm_win_rotation_with_resize_set(win, rotation);
906 xScale = (double)w / BASE_LAYOUT_W;
907 yScale = (double)h / BASE_LAYOUT_H;
908 scale = xScale < yScale ? xScale : yScale;
909 elm_scale_set(scale);
914 void WrtInstaller::InstallerPopup::showPopup(void* userdata,
915 const DPL::String& pkgMsg,
916 ShowResultCallback callback)
918 LogDebug("Result Popup Created");
919 evas_object_del(m_popup);
922 m_popup = elm_popup_with_buttons_add(m_win, "RESULT",
923 DPL::ToUTF8String(pkgMsg).c_str(),
925 evas_object_smart_callback_add(m_popup, "response", callback, userdata);
926 evas_object_show(m_popup);
929 void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
930 void* /*event_info*/)
932 WrtInstaller *This = static_cast<WrtInstaller*>(data);
935 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
936 ::PostEvent(WRTInstallerNS::NextStepEvent());
939 void WrtInstaller::failResultCallback(void *data, Evas_Object* /*obj*/,
940 void* /*event_info*/)
942 WrtInstaller *This = static_cast<WrtInstaller*>(data);
945 This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
946 ::PostEvent(WRTInstallerNS::QuitEvent());
949 void WrtInstaller::installNewPlugins()
951 LogDebug("Install new plugins");
953 if (!PluginUtils::lockPluginInstallation()) {
954 LogInfo("Lock NOT created");
958 if (!PluginUtils::checkPluginInstallationRequired()) {
959 LogDebug("Plugin installation not required");
960 PluginUtils::unlockPluginInstallation();
964 m_startupPluginInstallation = true;
965 AddStep(&WrtInstaller::installPluginsStep);
968 int main(int argc, char *argv[])
970 // Output on stdout will be flushed after every newline character,
971 // even if it is redirected to a pipe. This is useful for running
972 // from a script and parsing output.
973 // (Standard behavior of stdlib is to use full buffering when
974 // redirected to a pipe, which means even after an end of line
975 // the output may not be flushed).
979 if (!getenv("ELM_ENGINE")) {
980 if (setenv("ELM_ENGINE", "gl", 1)) {
981 LogDebug("Enable gl for HW Accel");
985 WrtInstaller app(argc, argv);
986 int ret = app.Exec();
987 LogDebug("App returned: " << ret);
988 ret = app.getReturnStatus();
989 LogDebug("WrtInstaller returned: " << ret);