#include <string>
#include <fstream>
#include <unistd.h>
+#include <memory>
+#include <sys/resource.h>
#include <dpl/optional.h>
#include <dpl/scoped_free.h>
#include <dpl/optional_typedefs.h>
#include <dpl/sstream.h>
#include <vconf.h>
#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
#include <dpl/localization/localization_utils.h>
-#include <dpl/popup/popup_controller.h>
#include <dpl/optional_typedefs.h>
#include <dpl/string.h>
+#include <dpl/abstract_waitable_input_adapter.h>
+#include <dpl/abstract_waitable_output_adapter.h>
+#include <dpl/zip_input.h>
+#include <dpl/binary_queue.h>
+#include <dpl/copy.h>
+#include <dpl/errno_string.h>
+#include <dpl/utils/wrt_global_settings.h>
#include "option_parser.h"
+#include <parser_runner.h>
+#include <widget_parser.h>
+#include <root_parser.h>
+
+#define NOFILE_CNT_FOR_INSTALLER 9999
-#define PKGMGR_SEND_SIG(installer, pkg_name, key, val) \
- if(pkgmgr_installer_send_signal(installer, PKG_TYPE, pkg_name, key, val)) {\
- LogDebug("Failed to send signal to pkgmgr"); \
- }
using namespace WrtDB;
+
namespace { // anonymous
const char AUL_ARG_KEY[] = "widget_arg";
-const char PKGMGR_START_KEY[] = "start";
-const char PKGMGR_END_KEY[] = "end";
-const char PKG_TYPE[] = "wgt";
-const char PKGMGR_PROGRESS_KEY[] = "install_percent";
-const char PKGMGR_OK_VAL[] = "ok";
-const char PKGMGR_FAIL_VAL[] = "fail";
-const char PKGMGR_INSTALL_MSG[] = "Install widget";
-const char PKGMGR_UNINSTALL_MSG[] = "Uninstall widget";
+const char * const PKGMGR_INSTALL_MSG = "Install widget";
+const char * const PKGMGR_UNINSTALL_MSG = "Uninstall widget";
const double BASE_LAYOUT_W = 720.0f;
const double BASE_LAYOUT_H = 1280.0f;
+const char * const CONFIG_XML = "config.xml";
+
+struct free_deleter
+{
+ void operator()(void* x)
+ {
+ free(x);
+ }
+};
+
struct PluginInstallerData
{
void* wrtInstaller;
WrtInstaller::WrtInstaller(int argc, char **argv) :
Application(argc, argv, "backend", false),
DPL::TaskDecl<WrtInstaller>(this),
+ m_installPolicy(WRT_WIM_NOT_INSTALLED),
m_packagePath(),
m_handle(-1),
m_initialized(false),
m_numPluginsToInstall(0),
m_totalPlugins(0),
m_returnStatus(-1),
- m_installer(NULL),
m_installByPkgmgr(false),
m_quiet(true),
- m_sendSig(false),
m_popup(NULL),
- m_startupPluginInstallation(false)
+ m_startupPluginInstallation(false),
+ m_preloadWidget(false)
{
Touch();
LogDebug("App Created");
void WrtInstaller::OnCreate()
{
LogInfo("Creating DummyClient");
+ fprintf(stderr,
+ "===========================================================\n");
+ fprintf(stderr, "# wrt-installer #\n");
+ fprintf(stderr, "# argc [%d]\n", m_argc);
+ fprintf(stderr, "# argv[0] = [%s]\n", m_argv[0]);
+ fprintf(stderr, "# argv[1] = [%s]\n", m_argv[1]);
+ fprintf(stderr, "# argv[2] = [%s]\n", m_argv[2]);
+ fprintf(stderr,
+ "===========================================================\n");
AddStep(&WrtInstaller::initStep);
std::string arg = m_argv[0];
+ pkgmgrSignalInterface =
+ std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
+ std::shared_ptr<PackageManager::PkgmgrSignalDummy>(
+ new PackageManager::PkgmgrSignalDummy()
+ )
+ );
+
if (arg.empty()) {
return showHelpAndQuit();
}
installNewPlugins();
- if (arg.find("wrt-installer") != std::string::npos)
- {
+ if (arg.find("wrt-installer") != std::string::npos) {
if (m_argc <= 1) {
return showHelpAndQuit();
}
arg = m_argv[1];
-
if (arg == "-h" || arg == "--help") {
if (m_argc != 2) {
return showHelpAndQuit();
}
// Just show help
- showHelpAndQuit();
+ return showHelpAndQuit();
} else if (arg == "-p" || arg == "--install-plugins") {
if (m_argc != 2) {
return showHelpAndQuit();
return showHelpAndQuit();
}
- m_packagePath = m_argv[2];
- m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
- AddStep(&WrtInstaller::installStep);
- } else if (arg == "-iu" || arg == "--install-or-update") {
- if (m_argc != 3) {
- return showHelpAndQuit();
+ struct stat info;
+ if (-1 != stat(m_argv[2], &info) && S_ISDIR(info.st_mode)) {
+ LogInfo("Installing package directly from directory");
+ m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL;
+ } else {
+ LogInfo("Installing from regular location");
+ m_installPolicy = WRT_WIM_POLICY_WAC;
}
-
m_packagePath = m_argv[2];
- m_installPolicy = WRT_WIM_POLICY_WAC;
AddStep(&WrtInstaller::installStep);
} else if (arg == "-if" || arg == "--install-force") {
if (m_argc != 3) {
m_packagePath = m_argv[2];
m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL;
AddStep(&WrtInstaller::installStep);
- } else if (arg == "-inq" || arg == "--install-not-quiet") {
+ } else if (arg == "-il" || arg == "--install-preload") {
if (m_argc != 3) {
return showHelpAndQuit();
}
- m_quiet = false;
+
m_packagePath = m_argv[2];
- m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
+ m_preloadWidget = true;
+ m_installPolicy = WRT_WIM_POLICY_WAC;
AddStep(&WrtInstaller::installStep);
- } else if (arg == "-u" || arg == "--uninstall") {
- if (m_argc != 3) {
- return showHelpAndQuit();
- }
-
- m_handle = atoi(m_argv[2]);
- AddStep(&WrtInstaller::uninstallStep);
} else if (arg == "-un" || arg == "--uninstall-name") {
if (m_argc != 3) {
return showHelpAndQuit();
}
m_name = m_argv[2];
AddStep(&WrtInstaller::uninstallGuidStep);
- } else if (arg == "-unq" || arg == "--uninstall-not-quiet") {
+ } else if (arg == "-up" || arg == "--uninstall-packagepath") {
if (m_argc != 3) {
return showHelpAndQuit();
}
- m_quiet = false;
- m_handle = atoi(m_argv[2]);
- AddStep(&WrtInstaller::uninstallStep);
- }
- else if (arg == "--url") {
- if (m_argc < 3) {
- return showHelpAndQuit();
- }
- m_webAppUrl = m_argv[2];
-
- DPL::OptionalString icon = OptionParser::QueryOption(m_argc,
- m_argv,
- "--icon");
- if (!icon.IsNull()) {
- m_webAppIcon = DPL::ToUTF8String(*icon);
- }
+ m_packagePath = m_argv[2];
+ AddStep(&WrtInstaller::unistallWgtFileStep);
+ } else {
+ return showHelpAndQuit();
}
} else if (arg.find("backend") != std::string::npos) {
+ using namespace PackageManager;
m_installByPkgmgr = true;
- m_quiet = false;
- m_sendSig = true;
-
- m_installer = pkgmgr_installer_new();
- if (!pkgmgr_installer_receive_request(m_installer, m_argc, m_argv)) {
- //For package manager
- int reqType = pkgmgr_installer_get_request_type(m_installer);
- m_quiet = pkgmgr_installer_is_quiet(m_installer);
-
- switch (reqType) {
- case PKGMGR_REQ_INSTALL:
- m_packagePath = m_argv[4];
- m_installPolicy = WRT_WIM_POLICY_NEVER_UPDATE;
- AddStep(&WrtInstaller::installStep);
- break;
- case PKGMGR_REQ_UNINSTALL:
- m_name = m_argv[4];
- AddStep(&WrtInstaller::uninstallPkgNameStep);
- break;
- default:
- LogDebug("Not available type");
- break;
- }
- }
- } else {
- // Launch widget based on application basename
- size_t pos = arg.find_last_of('/');
-
- if (pos != std::string::npos) {
- arg = arg.erase(0, pos + 1);
- }
- if (sscanf(arg.c_str(), "%i", &m_handle) != 1) {
- printf("failed: invalid widget handle\n");
- return showHelpAndQuit();
+ auto pkgmgrSignal = std::shared_ptr<PackageManager::PkgmgrSignal>(
+ new PackageManager::PkgmgrSignal()
+ );
+
+ pkgmgrSignal->initialize(m_argc, m_argv);
+ m_quiet = pkgmgrSignal->isNoPopupRequired();
+ LogDebug("backend m_quiet" << m_quiet);
+
+ int reqType = pkgmgrSignal->getRequestedType();
+
+ pkgmgrSignalInterface =
+ std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
+ pkgmgrSignal);
+ switch (reqType) {
+ case PKGMGR_REQ_INSTALL:
+ m_packagePath = m_argv[4];
+ struct stat info;
+ if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) {
+ LogInfo("Installing package directly from directory");
+ m_installPolicy = WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL;
+ } else {
+ LogInfo("Installing from regular location");
+ m_installPolicy = WRT_WIM_POLICY_WAC;
+ }
+ AddStep(&WrtInstaller::installStep);
+ break;
+ case PKGMGR_REQ_UNINSTALL:
+ m_name = m_argv[4];
+ AddStep(&WrtInstaller::uninstallPkgNameStep);
+ break;
+ default:
+ LogDebug("Not available type");
+ break;
}
-
- LogDebug("Widget Id: " << m_handle << " (" << arg << ")");
}
AddStep(&WrtInstaller::shutdownStep);
- DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::
+ PostEvent(
WRTInstallerNS::NextStepEvent());
}
void WrtInstaller::OnTerminate()
{
LogDebug("Wrt Shutdown now");
+ PluginUtils::unlockPluginInstallation();
if (m_initialized) {
wrt_installer_shutdown();
}
" -h, --help show this help\n"
" -p, --install-plugins install plugins\n"
" -i, --install "
- "install widget package for given path\n"
- " -iu, --install-or-update "
"install or update widget package for given path\n"
" -if, --install-force "
"install forcibly widget package for given path\n"
- " -inq, --install-not-quiet "
- "install with popup \n"
- " -u, --uninstall "
- "uninstall widget for given ID\n"
- " -un, --uninstall for given package name "
- "uninstall widget for given pakcage name\n"
+ " -un, --uninstall-name "
+ "uninstall widget for given package name\n"
" -ug, --uninstall-guid "
"uninstall widget for given Global Unique IDentifier\n"
- " -unq, --uninstall-not-quiet "
- "uninstall with popup \n"
- " --url "
- "URL of the remote page for Web Application installed from browser\n"
- " --icon "
- "path to the icon for Web Application installed from browser\n"
+ " -up, --uninstall-packagepath "
+ "uninstall widget for given package file path\n"
"\n");
Quit();
if (m_initialized) {
LogDebug("Wrt Shutdown now");
SwitchToStep(&WrtInstaller::shutdownStep);
- DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::
+ PostEvent(
WRTInstallerNS::NextStepEvent());
} else {
LogDebug("Quiting application");
(*m_pluginsPaths).pop_front();
wrt_install_plugin(privateData->pluginPath.c_str(),
- static_cast<void*>(privateData),
- &staticWrtPluginInstallationCallback,
- &staticWrtPluginInstallProgressCb);
+ static_cast<void*>(privateData),
+ &staticWrtPluginInstallationCallback,
+ &staticWrtPluginInstallProgressCb);
+ } else {
+ delete privateData;
}
}
void WrtInstaller::installStep()
{
LogDebug("Installing widget ...");
- if (!m_quiet) {
- m_popup->init();
- }
- DPL::ScopedFree<char> packagePath(canonicalize_file_name(
- m_packagePath.c_str()));
- wrt_install_widget(packagePath ? packagePath.Get() : m_packagePath.c_str(),
+ std::unique_ptr<char, free_deleter> packagePath(canonicalize_file_name(
+ m_packagePath.c_str()));
+
+ wrt_install_widget(packagePath ? packagePath.get() : m_packagePath.c_str(),
this, &staticWrtStatusCallback,
(!m_quiet || m_installByPkgmgr)
? &staticWrtInstallProgressCallback : NULL,
- m_installPolicy);
+ m_installPolicy,
+ m_quiet,
+ m_preloadWidget,
+ pkgmgrSignalInterface);
}
void WrtInstaller::installPluginsStep()
{
LogDebug("Installing plugins ...");
+ fprintf(stderr, "Installing plugins ...\n");
if (m_startupPluginInstallation) {
LogInfo("Plugin installation started because new plugin package found");
} else if (!PluginUtils::lockPluginInstallation()) {
LogError("Failed to open plugin installation lock file"
- " Plugins are currently installed by other process");
+ " Plugins are currently installed by other process");
staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK,
- this);
+ this);
return;
}
}
LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
- struct dirent* libdir;
-
- errno = 0;
std::list<std::string> pluginsPaths;
-
- while ((libdir = readdir(dir)) != 0) {
- if (strcmp(libdir->d_name, ".") == 0 ||
- strcmp(libdir->d_name, "..") == 0)
+ struct dirent libdir;
+ struct dirent *result;
+ int return_code;
+ errno = 0;
+ for (return_code = readdir_r(dir, &libdir, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &libdir, &result))
+ {
+ if (strcmp(libdir.d_name, ".") == 0 ||
+ strcmp(libdir.d_name, "..") == 0)
{
continue;
}
std::string path = PLUGIN_PATH;
path += "/";
- path += libdir->d_name;
+ path += libdir.d_name;
struct stat tmp;
pluginsPaths.push_back(path);
}
+ if (return_code != 0 || errno != 0) {
+ LogError("readdir_r() failed with " << DPL::GetErrnoString());
+ }
+
//set nb of plugins to install
//this value indicate how many callbacks are expected
m_numPluginsToInstall = pluginsPaths.size();
LogInfo("Plugins to install: " << m_numPluginsToInstall);
m_pluginsPaths = pluginsPaths;
- // install geolocation plugin
- {
- m_numPluginsToInstall++;
- (*m_pluginsPaths).push_back(GlobalConfig::GetW3CGeolocationFeatureName());
- }
-
m_totalPlugins = m_numPluginsToInstall;
DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>
::PostEvent(WRTInstallerNS::InstallPluginEvent());
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
- LogError("Failed to close dir: " << dir);
+ LogError("Failed to close dir: " << PLUGIN_PATH << " with error: "
+ << DPL::GetErrnoString());
}
}
-void WrtInstaller::uninstallStep()
+void WrtInstaller::uninstallPkgNameStep()
{
LogDebug("Uninstalling widget ...");
- if (!m_quiet) {
- m_popup->init();
- }
-
- wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
- (!m_quiet || m_installByPkgmgr)
- ? &staticWrtUninstallProgressCallback : NULL);
+ LogDebug("Package name : " << m_name);
+ wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback,
+ (!m_quiet || m_installByPkgmgr)
+ ? &staticWrtUninstallProgressCallback : NULL,
+ pkgmgrSignalInterface);
}
-void WrtInstaller::uninstallPkgNameStep()
+void WrtInstaller::uninstallGuidStep()
{
LogDebug("Uninstalling widget ...");
- if (!m_quiet) {
- m_popup->init();
- }
-
- WrtErrStatus status = wrt_get_widget_by_pkgname(m_name, &m_handle);
+ std::string appid;
+ WrtErrStatus status = wrt_get_widget_by_guid(appid, m_name);
if (status == WRT_SUCCESS) {
- LogDebug("Get Widget Handle by package name : " << m_handle);
- wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
- (!m_quiet || m_installByPkgmgr)
- ? &staticWrtUninstallProgressCallback : NULL);
+ LogDebug("Guid : " << m_name);
+ wrt_uninstall_widget(
+ appid.c_str(), this, &staticWrtStatusCallback,
+ !m_quiet ? &staticWrtUninstallProgressCallback :
+ NULL,
+ pkgmgrSignalInterface);
} else {
+ printf("failed: can not uninstall widget\n");
LogError("Fail to uninstalling widget... ");
m_returnStatus = -1;
- DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+ PostEvent(
WRTInstallerNS::QuitEvent());
}
}
-void WrtInstaller::uninstallGuidStep()
+void WrtInstaller::unistallWgtFileStep()
{
LogDebug("Uninstalling widget ...");
- if (!m_quiet) {
- m_popup->init();
- }
- WrtErrStatus status = wrt_get_widget_by_guid(m_name, &m_handle);
- if (status == WRT_SUCCESS) {
- LogDebug("Get Widget Handle by guid : " << m_handle);
- wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
- !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
- } else {
- LogError("Fail to uninstalling widget... ");
+ Try {
+ // Parse config
+ ParserRunner parser;
+ ConfigParserData configInfo;
+
+ // Open zip file
+ std::unique_ptr<DPL::ZipInput> zipFile(
+ new DPL::ZipInput(m_packagePath));
+
+ // Open config.xml file
+ std::unique_ptr<DPL::ZipInput::File> configFile(
+ zipFile->OpenFile(CONFIG_XML));
+
+ // Extract config
+ DPL::BinaryQueue buffer;
+ DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
+ DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
+ DPL::Copy(&inputAdapter, &outputAdapter);
+ parser.Parse(&buffer,
+ ElementParserPtr(
+ new RootParser<WidgetParser>(configInfo,
+ DPL::FromUTF32String(
+ L"widget"))));
+
+ DPL::OptionalString widgetGUID = configInfo.widget_id;
+
+ std::string guid = DPL::ToUTF8String(*widgetGUID);
+
+ std::string appid;
+ WrtErrStatus status = wrt_get_widget_by_guid(appid, guid);
+ if (status == WRT_SUCCESS) {
+ LogDebug("Appid from packagePath : " << appid);
+ wrt_uninstall_widget(
+ appid.c_str(), this, &staticWrtStatusCallback,
+ !m_quiet ? &staticWrtUninstallProgressCallback
+ : NULL,
+ pkgmgrSignalInterface);
+ } else {
+ LogError("Fail to uninstalling widget... ");
+ m_returnStatus = -1;
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+ PostEvent(
+ WRTInstallerNS::QuitEvent());
+ }
+ }
+ Catch(DPL::ZipInput::Exception::OpenFailed)
+ {
+ LogError("Failed to open widget package");
+ printf("failed: widget package does not exist\n");
+ m_returnStatus = -1;
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+ PostEvent(
+ WRTInstallerNS::QuitEvent());
+ }
+ Catch(DPL::ZipInput::Exception::OpenFileFailed)
+ {
+ printf("failed: widget config file does not exist\n");
+ LogError("Failed to open config.xml file");
+ m_returnStatus = -1;
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+ PostEvent(
+ WRTInstallerNS::QuitEvent());
+ }
+ Catch(ElementParser::Exception::ParseError)
+ {
+ printf("failed: can not parse config file\n");
+ LogError("Failed to parse config.xml file");
m_returnStatus = -1;
- DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+ PostEvent(
WRTInstallerNS::QuitEvent());
}
}
if (m_initialized) {
wrt_installer_shutdown();
m_initialized = false;
- DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+ PostEvent(
WRTInstallerNS::QuitEvent());
}
}
void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
- void* userdata)
+ void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
Assert(This);
This->m_initialized = true;
This->m_returnStatus = 0;
- if (!This->m_quiet) {
+ if (This->popupsEnabled()) {
This->m_popup = new InstallerPopup;
This->m_popup->init();
}
} else {
LogError("Init unsuccesfull");
This->m_returnStatus = -1;
- This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::
+ PostEvent(
WRTInstallerNS::QuitEvent());
}
}
-void WrtInstaller::staticWrtStatusCallback(int handle,
+void WrtInstaller::staticWrtStatusCallback(std::string tizenId,
WrtErrStatus status,
void* userdata)
{
DPL::String resultMsg;
std::string printMsg;
- if (current == &WrtInstaller::installStep)
- {
+ if (current == &WrtInstaller::installStep) {
resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
- printMsg = "installed";
- } else if (current == &WrtInstaller::uninstallStep ||
- current == &WrtInstaller::uninstallPkgNameStep ||
- current == &WrtInstaller::uninstallGuidStep)
+ printMsg = "installation";
+ } else if (current == &WrtInstaller::uninstallPkgNameStep ||
+ current == &WrtInstaller::uninstallGuidStep ||
+ current == &WrtInstaller::unistallWgtFileStep)
{
resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
- printMsg = "uninstalled";
+ printMsg = "uninstallation";
}
if (WRT_SUCCESS != status) {
// Failure
- LogDebug("Step failed");
+ LogError("Step failed");
This->m_returnStatus = -1;
- if (This->m_installByPkgmgr) {
- PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
- PKGMGR_END_KEY, PKGMGR_FAIL_VAL);
- }
-
- if (!This->m_quiet) {
- resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_FAIL_VAL);
+ if (This->popupsEnabled()) {
+ resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
This->m_popup->showPopup(This, resultMsg, failResultCallback);
} else {
This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
switch (status) {
case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE:
This->m_returnStatus = 1; //this status is specific
- printf("failed: invalid widget package\n");
+ fprintf(stderr, "## wrt-installer : %s %s has failed - invalid widget package\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST:
- printf("failed: widget package does not exist\n");
- break;
-
- case WRT_INSTALLER_ERROR_FACTORY_WIDGET:
- printf("failed: factory widget\n");
+ fprintf(stderr, "## wrt-installer : %s %s has failed - widget package does not exist\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING:
- printf("failed: already uninstalling\n");
- break;
-
- case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
- printf("failed: out of disk space\n");
+ fprintf(stderr, "## wrt-installer : %s %s has failed - already uninstalling\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE:
- printf("failed: invalid certificate\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - invalid certificate\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_ALREADY_INSTALLED:
- printf("failed: already installed\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - already installed\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_INTERNAL:
- printf("failed: internal error\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - internal error\n",
+ tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_NOT_ALLOWED:
- printf("failed: installation or update not allowed; invalid"
- " mode\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - installation or update not allowed; invalid"
+ " mode\n", tizenId.c_str(), printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_DEFERRED:
- printf("deferred: widget update will continue after the widget"
+ fprintf(stderr,"## wrt-installer : deferred: widget update will continue after the widget"
" has been stopped\n");
break;
case WRT_INSTALLER_ERROR_DATABASE_FAILURE:
- printf("failed: database failure\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - database failure\n",
+ tizenId.c_str(), printMsg.c_str());
+ break;
+
+ case WRT_INSTALLER_ERROR_OSPSVC:
+ fprintf(stderr,"## wrt-installer : %s %s has failed - during installation or"
+ " uninstallation osp service\n", tizenId.c_str(),
+ printMsg.c_str());
break;
case WRT_INSTALLER_ERROR_UNKNOWN:
- printf("failed: unknown error\n");
+ fprintf(stderr,"## wrt-installer : %s %s has failed - unknown error\n",
+ tizenId.c_str(), printMsg.c_str());
break;
default:
break;
}
} else {
-
- printf("%s : %d\n", printMsg.c_str(), handle);
+ fprintf(stderr,
+ "## wrt-installer : %s %s was successful.\n",
+ tizenId.c_str(),
+ printMsg.c_str());
LogDebug("Status succesfull");
- This->m_handle = handle;
This->m_returnStatus = 0;
- resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_OK_VAL);
+ resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
- if (This->m_installByPkgmgr) {
- PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
- PKGMGR_END_KEY, PKGMGR_OK_VAL);
- }
-
- if (!This->m_quiet) {
+ if (This->popupsEnabled()) {
This->m_popup->showPopup(This, resultMsg, showResultCallback);
} else {
- This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
+ This->DPL::Event::ControllerEventHandler<WRTInstallerNS::
+ NextStepEvent>
::PostEvent(WRTInstallerNS::NextStepEvent());
}
}
}
void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
- void* userdata)
+ void* userdata)
{
Assert(userdata);
if (This->m_numPluginsToInstall < 1) {
LogDebug("All plugins installation completed");
-
- //remove lock file
- if (!PluginUtils::unlockPluginInstallation()) {
- LogInfo("Failed to remove installation lock");
- }
+ fprintf(stderr, "All plugins installation completed.\n");
//remove installation request
if (!PluginUtils::removeInstallationRequiredFlag()) {
LogInfo("Failed to remove file initializing plugin installation");
}
- if (!This->m_quiet) {
+ //remove lock file
+ if (!PluginUtils::unlockPluginInstallation()) {
+ LogInfo("Failed to remove installation lock");
+ }
+
+ if (This->popupsEnabled()) {
+ This->m_popup->init();
elm_progressbar_value_set(This->m_popup->m_progressbar, 100.0);
evas_object_show(This->m_popup->m_popup);
}
This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
::PostEvent(WRTInstallerNS::NextStepEvent());
} else {
- if (!This->m_quiet) {
- float percent = (This->m_totalPlugins - This->m_numPluginsToInstall)/(float)This->m_totalPlugins;
+ if (This->popupsEnabled()) {
+ This->m_popup->init();
+ float percent =
+ (This->m_totalPlugins -
+ This->m_numPluginsToInstall) / (float)This->m_totalPlugins;
elm_progressbar_value_set(This->m_popup->m_progressbar, percent);
evas_object_show(This->m_popup->m_popup);
}
- This->DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>::PostEvent(
- WRTInstallerNS::InstallPluginEvent());
+ This->DPL::Event::ControllerEventHandler<WRTInstallerNS::
+ InstallPluginEvent>::
+ PostEvent(
+ WRTInstallerNS::InstallPluginEvent());
}
if (WRT_SUCCESS == status) {
This->m_returnStatus = 0;
+ fprintf(stderr,
+ "## wrt-installer : plugin installation successfull [%s]\n",
+ path.c_str());
LogDebug("One plugin Installation succesfull: " << path);
return;
}
if (WRT_PLUGIN_INSTALLER_ERROR_WAITING == status) {
LogInfo("Plugin installation is waiting for dependencies");
+ fprintf(stderr, "## wrt-installer : plugin installation failed [%s]\n",
+ path.c_str());
}
switch (status) {
}
void WrtInstaller::staticWrtInstallProgressCallback(float percent,
- const char* description, void* userdata)
+ const char* description,
+ void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
- std::stringstream percentStr;
LogInfo(" progress: " << percent <<
- "description " << description);
+ " description: " << description);
- if (This->m_installByPkgmgr) {
- if (This->m_sendSig) {
- std::string desc = description;
- size_t index = desc.find(" ");
- std::string widgetId = desc.substr(0, index - 1);
- This->m_name = desc.substr(index + 1, desc.length() - index);
-
- PKGMGR_SEND_SIG(This->m_installer, widgetId.c_str(),
- PKGMGR_START_KEY, "install");
- PKGMGR_SEND_SIG(This->m_installer, widgetId.c_str(),
- "change_pkg_name", This->m_name.c_str());
-
- This->m_sendSig = false;
- }
- LogDebug("Broadcast Progress, pkgname" << This->m_name);
-
- percentStr << static_cast<int>(percent);
- PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
- PKGMGR_PROGRESS_KEY, percentStr.str().c_str());
- }
-
- if (!This->m_quiet) {
- elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
+ if (This->popupsEnabled()) {
+ This->m_popup->init();
+ elm_progressbar_value_set(This->m_popup->m_progressbar, percent / 100.0);
evas_object_show(This->m_popup->m_popup);
}
}
void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
- const char* description, void* userdata)
+ const char* description,
+ void* userdata)
{
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
- std::stringstream percentStr;
LogInfo(" progress: " << percent <<
- "description " << description);
-
- if (This->m_installByPkgmgr) {
- if (This->m_sendSig) {
- PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
- PKGMGR_START_KEY, "uninstall");
- This->m_sendSig = false;
- }
- LogDebug("Broadcast Progress, pkgname" << This->m_name);
-
- percentStr << static_cast<int>(percent);
- PKGMGR_SEND_SIG(This->m_installer, This->m_name.c_str(),
- PKGMGR_PROGRESS_KEY, percentStr.str().c_str());
- }
+ " description: " << description);
- if (!This->m_quiet) {
- elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
+ if (This->popupsEnabled()) {
+ This->m_popup->init();
+ elm_progressbar_value_set(This->m_popup->m_progressbar, percent / 100.0);
evas_object_show(This->m_popup->m_popup);
}
}
m_win(NULL),
m_popup(NULL),
m_progressbar(NULL)
-{
-}
+{}
WrtInstaller::InstallerPopup::~InstallerPopup()
{
{
LogDebug("Window Init");
- // create window
- m_win = createWin("wrt-installer");
-
- // security popup uses installer window
- using namespace DPL::Popup;
- PopupControllerSingleton::Instance().setExternalCanvas(m_win);
- evas_object_show(m_win);
-
- // create popup
- m_popup = elm_popup_add(m_win);
-
- // create progressbar
- m_progressbar = elm_progressbar_add(m_popup);
- elm_object_style_set(m_progressbar, "list_progress");
- elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
- evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
- EVAS_HINT_FILL);
- evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_popup_content_set(m_popup, m_progressbar);
- elm_progressbar_value_set(m_progressbar, 0.0);
- evas_object_show(m_progressbar);
-
- // set progressbar to popup
- evas_object_show(m_popup);
+ if (m_win == NULL) {
+ // create window
+ m_win = createWin("wrt-installer");
+
+ // create popup
+ m_popup = elm_popup_add(m_win);
+
+ // create progressbar
+ m_progressbar = elm_progressbar_add(m_popup);
+ elm_object_style_set(m_progressbar, "list_progress");
+ elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
+ evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_object_content_set(m_popup, m_progressbar);
+ elm_progressbar_value_set(m_progressbar, 0.0);
+ evas_object_show(m_progressbar);
+
+ evas_object_show(m_popup);
+ evas_object_show(m_win);
+ }
}
Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
Evas_Object *win;
win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
- int w, h, x, y;
- int ret = 0;
- int count;
- int rotation = -1;
- unsigned char *prop_data = NULL;
- double xScale, yScale, scale;
-
- if (win) {
- elm_win_alpha_set(win, EINA_TRUE);
- elm_win_title_set(win, name);
- elm_win_borderless_set(win, EINA_TRUE);
- elm_win_raise(win);
- ecore_x_window_geometry_get(ecore_x_window_root_get(
- ecore_x_window_focus_get()),
- &x,
- &y,
- &w,
- &h);
- ret = ecore_x_window_prop_property_get(ecore_x_window_root_get(
- ecore_x_window_focus_get()),
- ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
- ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
- }
- if (ret && prop_data) {
- Assert(count != sizeof(int));
- memcpy(&rotation, prop_data, sizeof(int));
- }
- if (prop_data) {
- free(prop_data);
- }
- evas_object_resize(win, w, h);
-
- if (rotation != -1) {
- elm_win_rotation_with_resize_set(win, rotation);
+ int w, h;
+ if (!win) {
+ return NULL;
}
- xScale = (double)w / BASE_LAYOUT_W;
- yScale = (double)h / BASE_LAYOUT_H;
- scale = xScale < yScale ? xScale : yScale;
- elm_scale_set(scale);
+ elm_win_alpha_set(win, EINA_TRUE);
+ elm_win_title_set(win, name);
+ elm_win_borderless_set(win, EINA_TRUE);
+ elm_win_raise(win);
+ ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+ evas_object_resize(win, w, h);
return win;
}
const DPL::String& pkgMsg,
ShowResultCallback callback)
{
+ Evas_Object *btn;
+
LogDebug("Result Popup Created");
evas_object_del(m_popup);
m_popup = NULL;
- m_popup = elm_popup_with_buttons_add(m_win, "RESULT",
- DPL::ToUTF8String(pkgMsg).c_str(),
- 1, "OK", 5, NULL);
- evas_object_smart_callback_add(m_popup, "response", callback, userdata);
+ m_popup = elm_popup_add(m_win);
+ if (!m_popup) {
+ return;
+ }
+
+ btn = elm_button_add(m_popup);
+ if (!btn) {
+ evas_object_del(m_popup);
+ return;
+ }
+ elm_object_text_set(btn, "OK");
+ evas_object_smart_callback_add(btn, "clicked", callback, userdata);
+ elm_object_part_content_set(m_popup, "button1", btn);
+ elm_object_part_text_set(m_popup, "title,text", "RESULT");
+ elm_object_text_set(m_popup, DPL::ToUTF8String(pkgMsg).c_str());
+
evas_object_show(m_popup);
+ evas_object_show(m_win);
}
void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
AddStep(&WrtInstaller::installPluginsStep);
}
+bool WrtInstaller::popupsEnabled() const
+{
+ return !m_quiet && !GlobalSettings::PopupsTestModeEnabled();
+}
+
int main(int argc, char *argv[])
{
- // Output on stdout will be flushed after every newline character,
- // even if it is redirected to a pipe. This is useful for running
- // from a script and parsing output.
- // (Standard behavior of stdlib is to use full buffering when
- // redirected to a pipe, which means even after an end of line
- // the output may not be flushed).
- setlinebuf(stdout);
-
- // enable gl
- if (!getenv("ELM_ENGINE")) {
- if (setenv("ELM_ENGINE", "gl", 1)) {
- LogDebug("Enable gl for HW Accel");
+ UNHANDLED_EXCEPTION_HANDLER_BEGIN
+ {
+ // Output on stdout will be flushed after every newline character,
+ // even if it is redirected to a pipe. This is useful for running
+ // from a script and parsing output.
+ // (Standard behavior of stdlib is to use full buffering when
+ // redirected to a pipe, which means even after an end of line
+ // the output may not be flushed).
+ setlinebuf(stdout);
+
+ // Check and re-set the file open limitation
+ struct rlimit rlim;
+ if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) {
+ LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")");
+ LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")");
+
+ if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) {
+ rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER;
+ rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER;
+ if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) {
+ LogError("setrlimit is fail!!");
+ }
+ }
+ } else {
+ LogError("getrlimit is fail!!");
}
- }
- WrtInstaller app(argc, argv);
- int ret = app.Exec();
- LogDebug("App returned: " << ret);
- ret = app.getReturnStatus();
- LogDebug("WrtInstaller returned: " << ret);
- return ret;
+ // set evas backend type for emulator
+ // popup isn't showed in the emulator,
+ // if backend isn't set to SW backend
+ if (GlobalSettings::IsEmulator()) {
+ if (setenv("ELM_ENGINE", "x11", 1)) {
+ LogDebug("Enable backend");
+ }
+ }
+
+ WrtInstaller app(argc, argv);
+ int ret = app.Exec();
+ LogDebug("App returned: " << ret);
+ ret = app.getReturnStatus();
+ LogDebug("WrtInstaller returned: " << ret);
+ return ret;
+ }
+ UNHANDLED_EXCEPTION_HANDLER_END
}