#include <dpl/assert.h>
#include <dpl/sstream.h>
#include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <dpl/utils/file_utils.h>
#include "root_parser.h"
#include "widget_parser.h"
#include "parser_runner.h"
#include <widget_install/task_certify.h>
#include <widget_install/task_widget_config.h>
#include <widget_install/task_db_update.h>
+#include <widget_install/task_file_manipulation.h>
#include <widget_install/task_ace_check.h>
#include <widget_install/task_smack.h>
#include <widget_install/task_manifest_file.h>
#include <widget_install/task_update_files.h>
#include <widget_install/task_new_db_insert.h>
#include <widget_install/task_remove_backup.h>
+#include <widget_install/task_encrypt_resource.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
#include <string>
const int RESERVED_COUNT = 20; //number of chars reserved in name (e.g. for '.desktop')
const int MAX_TIZENID_LENTH = 255 - RESERVED_COUNT;
+static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
+static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
+
class InstallerTaskFail :
public DPL::TaskDecl<InstallerTaskFail>
{
m_exceptionCaught(Exceptions::Success)
{
// Check installation type (config.xml or widget.wgt)
- bool fromBrowser = hasExtension(widgetPath, XML_EXTENSION);
- LogInfo("Hosted app installation: " << fromBrowser);
+ bool browserRequest = hasExtension(widgetPath, XML_EXTENSION);
+
+ LogInfo("Hosted app installation: " << browserRequest);
struct timeval tv;
gettimeofday(&tv, NULL);
m_installerContext.widgetHandle = handle;
m_installerContext.m_quiet = m_jobStruct.m_quiet;
- m_installerContext.widgetConfig.pType = checkPackageType(widgetPath);
+ if(!browserRequest)
+ {
+ m_installerContext.widgetConfig.pType = checkPackageType(widgetPath);
+ }
+ else
+ {
+ m_installerContext.widgetConfig.pType = WrtDB::PKG_TYPE_TIZEN_WEBAPP;
+ }
+ LogDebug("widgetPath:" << widgetPath);
- ConfigParserData configData = getWidgetDataFromXML(widgetPath, fromBrowser,
+ ConfigParserData configData = getWidgetDataFromXML(widgetPath, browserRequest,
m_installerContext.widgetConfig.pType);
WidgetUpdateInfo update = detectWidgetUpdate(configData);
+ bool needEncryption = detectResourceEncryption(configData);
+
// Configure installation
- ConfigureResult result = ConfigureInstallation(widgetPath, fromBrowser, update);
+ ConfigureResult result = ConfigureInstallation(widgetPath, update);
if (!setTizenId(configData)) {
result = ConfigureResult::Failed;
} else {
LogInfo("WidgetHandle: " << m_installerContext.widgetHandle);
LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
+ configureWidgetLocation(widgetPath, browserRequest);
+
// send start signal of pkgmgr
PkgmgrSignalSingleton::Instance().setPkgname(
DPL::ToUTF8String(
PKGMGR_START_KEY,
PKGMGR_START_INSTALL);
}
-
if (result == ConfigureResult::Ok) {
LogInfo("Configure installation succeeded");
AddTask(new TaskRecovery(m_installerContext));
// Create installation tasks
- if (!fromBrowser) {
+ if (!m_installerContext.locations->browserRequest()) {
AddTask(new TaskUnzip(m_installerContext));
}
AddTask(new TaskWidgetConfig(m_installerContext));
+ if (m_installerContext.locations->browserRequest()) {
+ AddTask(new TaskPrepareFiles(m_installerContext));
+ }
AddTask(new TaskCertify(m_installerContext));
+ if (needEncryption) {
+ AddTask(new TaskEncryptResource(m_installerContext));
+ }
AddTask(new TaskDbUpdate(m_installerContext));
+ AddTask(new TaskFileManipulation(m_installerContext));
// TODO: Update progress information for this task
AddTask(new TaskPrivateStorage(m_installerContext));
LogInfo("Configure installation updated");
LogInfo("Widget Update");
- if (!fromBrowser) {
+ if (!m_installerContext.locations->browserRequest()) {
AddTask(new TaskUnzip(m_installerContext));
}
AddTask(new TaskWidgetConfig(m_installerContext));
+ if (m_installerContext.locations->browserRequest()) {
+ AddTask(new TaskPrepareFiles(m_installerContext));
+ }
AddTask(new TaskCertify(m_installerContext));
AddTask(new TaskUpdateFiles(m_installerContext));
return m_installerContext.widgetHandle;
}
+void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath, bool browserRequest)
+{
+ Try
+ {
+ m_installerContext.locations = WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname),
+ widgetPath, browserRequest, m_installerContext.widgetConfig.pType);
+ }
+ Catch(FileUtils::CreateDirectoryException)
+ {
+ LogError("Failed to create temporary path for widget");
+ ReThrowMsg(FileUtils::CreateDirectoryException, "Failed to create temporary path for widget");
+ }
+
+ LogInfo("widgetSource " << widgetPath);
+}
+
JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
const std::string &widgetSource,
- bool fromBrowser,
const WidgetUpdateInfo &update)
{
LogInfo(
LogInfo("Whether widget policy allow proceed: " << canProceed);
// Init installer context
- m_installerContext.widgetSource = widgetSource;
- m_installerContext.tempWidgetPath = std::string();
-
- // setup config xml path
- if (fromBrowser) {
- LogInfo("widgetSource " << widgetSource);
- size_t slash = widgetSource.find_last_of("\\/");
- if (std::string::npos != slash) {
- m_installerContext.tempWidgetPath = widgetSource.substr(0, slash+1);
- } else {
- m_installerContext.tempWidgetPath = ".";
- }
- }
-
m_installerContext.installStep = InstallerContext::INSTALL_START;
m_installerContext.job = this;
m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
return pType;
}
+bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &configData)
+{
+ FOREACH(it, configData.settingsList)
+ {
+ if (it->m_name == SETTING_VALUE_ENCRYPTION &&
+ it->m_value == SETTING_VALUE_ENCRYPTION_ENABLE) {
+ LogDebug("resource need encryption");
+ return true;
+ }
+ }
+ return false;
+}
+
} //namespace WidgetInstall
} //namespace Jobs