* @brief Implementation file for main installer task
*/
#include <memory>
+#include <string>
+#include <sys/time.h>
+#include <ctime>
+#include <cstdlib>
+#include <limits.h>
+#include <regex.h>
#include <dpl/noncopyable.h>
#include <dpl/abstract_waitable_input_adapter.h>
#include <dpl/copy.h>
#include <dpl/assert.h>
#include <dpl/sstream.h>
+#include <dpl/file_input.h>
+#include <dpl/utils/wrt_utility.h>
#include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-rw/global_dao.h> // TODO remove
+#include <dpl/localization/w3c_file_localization.h>
+
+#include <libiriwrapper.h>
+#include <pkg-manager/pkgmgr_signal.h>
+#include <app_manager.h>
+//#include <drm_client.h>
+#include <drm-oem-intel.h> //temporary code
+
#include "root_parser.h"
#include "widget_parser.h"
#include "parser_runner.h"
#include <widget_install/job_widget_install.h>
-#include <widget_install/task_unzip.h>
#include <widget_install/task_certify.h>
#include <widget_install/task_widget_config.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_private_storage.h>
#include <widget_install/task_prepare_files.h>
#include <widget_install/task_recovery.h>
#include <widget_install/task_install_ospsvc.h>
#include <widget_install/task_remove_backup.h>
#include <widget_install/task_encrypt_resource.h>
#include <widget_install/task_certificates.h>
+#include <widget_install/task_unzip.h>
+#include <widget_install/task_commons.h>
-#ifdef LB_SUPPORT
-#include <widget_install/task_livebox_conf.h>
-#endif
#include <widget_install/task_plugins_copy.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
-#include <string>
-#include <sys/time.h>
-#include <ctime>
-#include <cstdlib>
-#include <limits.h>
-#include <regex.h>
-#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-#include <dpl/wrt-dao-ro/global_config.h>
-#include <dpl/wrt-dao-rw/global_dao.h> // TODO remove
-#include <dpl/localization/w3c_file_localization.h>
-#include <libiriwrapper.h>
-#include <pkg-manager/pkgmgr_signal.h>
-#include <app_manager.h>
+#include <widget_install_to_external.h>
using namespace WrtDB;
//allowed: a-z, A-Z, 0-9
const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}$";
-const int MAX_TIZENID_LENGTH = 10;
static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
+const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME =
+ L"install-location-type";
+const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT =
+ L"prefer-external";
class InstallerTaskFail :
public DPL::TaskDecl<InstallerTaskFail>
}
return (0 == filename.compare(fileLen-extLen, extLen, extension));
}
+
+bool checkTizenIdExist(const std::string& tizenId) {
+ std::string installPath =
+ std::string(GlobalConfig::GetUserInstalledWidgetPath()) +
+ "/" + tizenId;
+ std::string preinstallPath =
+ std::string(GlobalConfig::GetUserPreloadedWidgetPath()) +
+ "/" + tizenId;
+
+ struct stat dirStat;
+ if ((stat(installPath.c_str(), &dirStat) == 0) &&
+ (stat(preinstallPath.c_str(), &dirStat) == 0)) {
+ return true;
+ }
+ return false;
+}
} // namespace anonymous
namespace Jobs {
JobContextBase<WidgetInstallationStruct>(installerStruct),
m_exceptionCaught(Exceptions::Success)
{
- // Check installation type (config.xml or widget.wgt)
- bool browserRequest = hasExtension(widgetPath, XML_EXTENSION);
-
- LogInfo("Hosted app installation: " << browserRequest);
-
struct timeval tv;
gettimeofday(&tv, NULL);
srand(time(NULL) + tv.tv_usec);
m_installerContext.m_quiet = m_jobStruct.m_quiet;
- 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, browserRequest,
- m_installerContext.widgetConfig.pType);
- WidgetUpdateInfo update = detectWidgetUpdate(configData);
- bool needEncryption = detectResourceEncryption(configData);
-
- // Configure installation
- ConfigureResult result = ConfigureInstallation(widgetPath, configData,
- update, browserRequest);
+ ConfigureResult result = PrePareInstallation(widgetPath);
if (result == ConfigureResult::Ok) {
LogInfo("Configure installation succeeded");
AddTask(new TaskRecovery(m_installerContext));
// Create installation tasks
- if (!m_installerContext.locations->browserRequest()) {
+ if (m_installerContext.widgetConfig.packagingType !=
+ WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
+ m_installerContext.widgetConfig.packagingType !=
+ WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
+ !m_isDRM)
+ {
AddTask(new TaskUnzip(m_installerContext));
}
+
AddTask(new TaskWidgetConfig(m_installerContext));
- if (m_installerContext.locations->browserRequest()) {
+ if (m_installerContext.widgetConfig.packagingType ==
+ WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+ {
AddTask(new TaskPrepareFiles(m_installerContext));
}
AddTask(new TaskCertify(m_installerContext));
- if (needEncryption) {
+ if (m_needEncryption) {
AddTask(new TaskEncryptResource(m_installerContext));
}
+
AddTask(new TaskFileManipulation(m_installerContext));
// TODO: Update progress information for this task
- AddTask(new TaskPrivateStorage(m_installerContext));
-
//This is sort of quick solution, because ACE verdicts are based upon
//data from DAO (DB). So AceCheck for now has to be AFTER DbUpdate
//task.
AddTask(new TaskManifestFile(m_installerContext));
AddTask(new TaskCertificates(m_installerContext));
- if (m_installerContext.widgetConfig.pType ==
- PKG_TYPE_TIZEN_WITHSVCAPP) {
+ if (m_installerContext.widgetConfig.packagingType ==
+ PKG_TYPE_HYBRID_WEB_APP) {
AddTask(new TaskInstallOspsvc(m_installerContext));
}
-#ifdef LB_SUPPORT
- AddTask(new TaskLiveboxConf(m_installerContext));
-#endif
AddTask(new TaskPluginsCopy(m_installerContext));
-
AddTask(new TaskDatabase(m_installerContext));
AddTask(new TaskAceCheck(m_installerContext));
} else if (result == ConfigureResult::Updated) {
LogInfo("Configure installation updated");
LogInfo("Widget Update");
-
- if (!m_installerContext.locations->browserRequest()) {
+ if (m_installerContext.widgetConfig.packagingType !=
+ WrtDB::PKG_TYPE_HOSTED_WEB_APP &&
+ m_installerContext.widgetConfig.packagingType !=
+ WrtDB::PKG_TYPE_DIRECTORY_WEB_APP &&
+ !m_isDRM)
+ {
AddTask(new TaskUnzip(m_installerContext));
}
+
AddTask(new TaskWidgetConfig(m_installerContext));
- if (m_installerContext.locations->browserRequest()) {
+
+ if (m_installerContext.widgetConfig.packagingType ==
+ WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+ {
AddTask(new TaskPrepareFiles(m_installerContext));
}
AddTask(new TaskCertify(m_installerContext));
- AddTask(new TaskUpdateFiles(m_installerContext));
+ if (m_installerContext.widgetConfig.packagingType !=
+ WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+ {
+ AddTask(new TaskUpdateFiles(m_installerContext));
+ }
/* TODO : To backup file, save md5 values */
AddTask(new TaskSmack(m_installerContext));
AddTask(new TaskManifestFile(m_installerContext));
- if (m_installerContext.widgetConfig.pType ==
- PKG_TYPE_TIZEN_WITHSVCAPP) {
+ if (m_installerContext.widgetConfig.packagingType ==
+ PKG_TYPE_HYBRID_WEB_APP) {
AddTask(new TaskInstallOspsvc(m_installerContext));
}
- AddTask(new TaskRemoveBackupFiles(m_installerContext));
-#ifdef LB_SUPPORT
- AddTask(new TaskLiveboxConf(m_installerContext));
-#endif
+ if (m_installerContext.widgetConfig.packagingType !=
+ WrtDB::PKG_TYPE_DIRECTORY_WEB_APP)
+ {
+ AddTask(new TaskRemoveBackupFiles(m_installerContext));
+ }
AddTask(new TaskPluginsCopy(m_installerContext));
-
AddTask(new TaskDatabase(m_installerContext));
-
AddTask(new TaskAceCheck(m_installerContext));
//TODO: remove widgetHandle from this task and move before database task
// by now widget handle is needed in ace check
}
}
-std::string JobWidgetInstall::generateTizenId() {
- std::string allowed("0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz");
- std::string tizenId;
- tizenId.resize(MAX_TIZENID_LENGTH);
- for (int i = 0; i < MAX_TIZENID_LENGTH; ++i) {
- tizenId[i] = allowed[rand() % allowed.length()];
+JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation(
+ const std::string &widgetPath)
+{
+ ConfigureResult result;
+ m_needEncryption = false;
+
+ Try
+ {
+ std::string tempDir =
+ Jobs::WidgetInstall::createTempPath(m_jobStruct.m_preload);
+
+ m_isDRM = isDRMWidget(widgetPath);
+ if (true == m_isDRM) {
+ LogDebug("decrypt DRM widget");
+ if(DecryptDRMWidget(widgetPath, tempDir)) {
+ LogDebug("Failed decrypt DRM widget");
+ return ConfigureResult::Failed;
+ }
+ }
+
+ LogDebug("widgetPath:" << widgetPath);
+
+ m_installerContext.widgetConfig.packagingType =
+ checkPackageType(widgetPath, tempDir);
+ ConfigParserData configData = getWidgetDataFromXML(
+ widgetPath,
+ tempDir,
+ m_installerContext.widgetConfig.packagingType,
+ m_isDRM);
+ LogDebug("widget packaging type : " <<
+ m_installerContext.widgetConfig.packagingType.pkgType);
+ WidgetUpdateInfo update = detectWidgetUpdate(configData);
+ m_needEncryption = detectResourceEncryption(configData);
+ setInstallLocationType(configData);
+
+ // Configure installation
+ result = ConfigureInstallation(widgetPath, configData, update, tempDir);
+ }
+ Catch(Exceptions::ExtractFileFailed)
+ {
+ LogError("Failed to create temporary path for widget");
+ result = ConfigureResult::Failed;
}
- return tizenId;
+
+ return result;
}
bool JobWidgetInstall::setTizenId(
- const WrtDB::ConfigParserData &configInfo, ConfigureResult result)
+ const WrtDB::ConfigParserData &configInfo,
+ const WidgetUpdateInfo &update,
+ bool preload)
{
+ using namespace PackageManager;
regex_t reg;
- regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED);
- struct stat dirStat;
+ if(regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
+ LogDebug("Regcomp failed");
+ }
+
+ ConfigureResult result = checkWidgetUpdate(update);
if(!!configInfo.tizenId) {
LogDebug("Setting tizenId provided in config.xml: " << configInfo.tizenId);
+ // send start signal of pkgmgr
+ getInstallerStruct().pkgmgrInterface->setPkgname(
+ DPL::ToUTF8String(*(configInfo.tizenId)));
+ getInstallerStruct().pkgmgrInterface->sendSignal(
+ PKGMGR_START_KEY,
+ PKGMGR_START_INSTALL);
+
+ if (result == ConfigureResult::Failed) {
+ return false;
+ }
+
if ((regexec(®, DPL::ToUTF8String(*(configInfo.tizenId)).c_str(),
static_cast<size_t>(0), NULL, 0) != REG_NOERROR) ||
- ((stat((std::string(GlobalConfig::GetUserInstalledWidgetPath()) + "/"
- + DPL::ToUTF8String(*(configInfo.tizenId))).c_str(), &dirStat) == 0)
- && result != ConfigureResult::Updated))
+ (checkTizenIdExist(DPL::ToUTF8String(*(configInfo.tizenId))) &&
+ result != ConfigureResult::Updated))
{
//it is true when tizenId does not fit REG_TIZENID_PATTERN
LogError("tizen_id provided but not proper.");
m_installerContext.widgetConfig.pkgname = configInfo.tizenId;
} else {
- std::string tizenId = generateTizenId();
+ WidgetPkgName tizenId = WidgetDAOReadOnly::generateTizenId();
// only for installation, not for update
if (result == ConfigureResult::Ok) {
//check if there is package with same name and if generate different name
- std::string path = GlobalConfig::GetUserInstalledWidgetPath();
- path += "/";
-
- std::ostringstream newPath;
- newPath << path << tizenId;
LogDebug("Checking if tizen id is unique");
while (true) {
- if (stat(newPath.str().c_str(), &dirStat) == 0) {
+ if (checkTizenIdExist(DPL::ToUTF8String(tizenId))) {
//path exist, chose another one
- tizenId = generateTizenId();
- newPath.str("");
- newPath << path << tizenId;
+ tizenId = WidgetDAOReadOnly::generateTizenId();
continue;
}
break;
}
- m_installerContext.widgetConfig.pkgname =
- DPL::FromUTF8String(tizenId);
+ m_installerContext.widgetConfig.pkgname = tizenId;
}
LogInfo("tizen_id name was generated by WRT: " << tizenId);
+ // send start signal of pkgmgr
+ getInstallerStruct().pkgmgrInterface->setPkgname(DPL::ToUTF8String(
+ *m_installerContext.widgetConfig.pkgname));
+ getInstallerStruct().pkgmgrInterface->sendSignal(
+ PKGMGR_START_KEY,
+ PKGMGR_START_INSTALL);
}
regfree(®);
return true;
}
-DPL::OptionalString JobWidgetInstall::getNewTizenId() const
+void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
+ const std::string& tempPath)
{
- return m_installerContext.widgetConfig.pkgname;
-}
-
-void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath, bool browserRequest)
-{
- m_installerContext.locations = WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname),
- widgetPath, browserRequest, m_installerContext.widgetConfig.pType);
+ m_installerContext.locations =
+ WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname),
+ widgetPath, tempPath,
+ m_installerContext.widgetConfig.packagingType,
+ m_installerContext.locationType);
LogInfo("widgetSource " << widgetPath);
}
const std::string &widgetSource,
const WrtDB::ConfigParserData &configData,
const WidgetUpdateInfo &update,
- bool browserRequest)
+ const std::string &tempPath)
+{
+
+ if (!setTizenId(configData, update, m_jobStruct.m_preload)) {
+ return ConfigureResult::Failed;
+ } else {
+ LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
+
+ configureWidgetLocation(widgetSource, tempPath);
+ }
+
+ // Init installer context
+ m_installerContext.installStep = InstallerContext::INSTALL_START;
+ m_installerContext.job = this;
+ m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
+ m_installerContext.widgetConfig.shareHref = std::string();
+
+ return ConfigureResult::Ok;
+}
+
+JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate(
+ const WidgetUpdateInfo &update)
{
LogInfo(
"Widget install/update: incoming guid = '" <<
// Check policy
WidgetUpdateMode::Type updateTypeCheckBit;
- JobWidgetInstall::ConfigureResult ret = ConfigureResult::Ok;
if (update.existingWidgetInfo.isExist == false) {
LogInfo("Widget info does not exist");
} else {
LogInfo(
"Widget is already running. Policy is not update according to WAC");
- LogInfo("Installation aborted: " << widgetSource);
return ConfigureResult::Failed;
}
updateTypeCheckBit = CalcWidgetUpdatePolicy(existingVersion,
incomingVersion);
// Calc proceed flag
- if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0) {
+ if ((m_jobStruct.updateMode & updateTypeCheckBit) > 0 ||
+ m_jobStruct.updateMode ==
+ WidgetUpdateMode::PolicyDirectoryForceInstall)
+ {
LogInfo("Whether widget policy allow proceed ok");
- ret = ConfigureResult::Updated;
+ return ConfigureResult::Updated;
}
else
return ConfigureResult::Failed;
}
-
- if (!setTizenId(configData, ret)) {
- return ConfigureResult::Failed;
- } else {
- using namespace PackageManager;
- LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
-
- configureWidgetLocation(widgetSource, browserRequest);
-
- // send start signal of pkgmgr
- PkgmgrSignalSingleton::Instance().setPkgname(
- DPL::ToUTF8String(
- *m_installerContext.widgetConfig.pkgname));
- PkgmgrSignalSingleton::Instance().sendSignal(
- PKGMGR_START_KEY,
- PKGMGR_START_INSTALL);
- }
-
- // Init installer context
- m_installerContext.installStep = InstallerContext::INSTALL_START;
- m_installerContext.job = this;
- m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
- m_installerContext.widgetConfig.shareHref = std::string();
-
- // Return result
- return ret;
+ return ConfigureResult::Ok;
}
WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
const std::string &widgetSource,
- bool fromBrowser, WrtDB::PkgType isOspsvc)
+ const std::string &tempPath,
+ WrtDB::PackagingType pkgType,
+ bool isDRM)
{
+ // Parse config
+ ParserRunner parser;
+ ConfigParserData configInfo;
+
Try
{
- // Parse config
- ParserRunner parser;
- ConfigParserData configInfo;
-
- if (fromBrowser) {
+ if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
parser.Parse(widgetSource,
+ ElementParserPtr(
+ new RootParser<WidgetParser>(configInfo,
+ DPL::FromUTF32String(
+ L"widget"))));
+ } else if (pkgType == PKG_TYPE_DIRECTORY_WEB_APP) {
+ parser.Parse(widgetSource + '/' + WITH_OSP_XML,
ElementParserPtr(
- new RootParser<WidgetParser>(configInfo,
- DPL::FromUTF32String(
- L"widget"))));
- }
- else {
- // Open zip file
- std::unique_ptr<DPL::ZipInput> zipFile(
- new DPL::ZipInput(widgetSource));
+ new RootParser<WidgetParser>(
+ configInfo,
+ DPL::FromUTF32String(L"widget"))));
+ } else {
+ if (!isDRM) {
+ std::unique_ptr<DPL::ZipInput> zipFile(
+ new DPL::ZipInput(widgetSource));
- std::unique_ptr<DPL::ZipInput::File> configFile;
+ std::unique_ptr<DPL::ZipInput::File> configFile;
- // Open config.xml file
- if (isOspsvc == PKG_TYPE_TIZEN_WITHSVCAPP) {
- configFile.reset(zipFile->OpenFile(WITH_OSP_XML));
+ // Open config.xml file
+ if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
+ configFile.reset(zipFile->OpenFile(WITH_OSP_XML));
+ } else {
+ configFile.reset(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"))));
} else {
- configFile.reset(zipFile->OpenFile(CONFIG_XML));
- }
+ // DRM widget
+ std::string configFile;
+ if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
+ configFile = tempPath + "/" + WITH_OSP_XML;
+ } else {
+ configFile = tempPath + "/" + 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"))));
+ parser.Parse(configFile,
+ ElementParserPtr(
+ new RootParser<WidgetParser>(configInfo,
+ DPL::FromUTF32String(
+ L"widget"))));
+ }
}
-
- return configInfo;
}
Catch(DPL::ZipInput::Exception::OpenFailed)
{
LogError("Failed to extract config.xml file");
return ConfigParserData();
}
+ Catch(DPL::FileInput::Exception::OpenFailed)
+ {
+ LogError("Failed to open config.xml file");
+ return ConfigParserData();
+ }
Catch(ElementParser::Exception::ParseError)
{
LogError("Failed to parse config.xml file");
return ConfigParserData();
}
+ Catch(DPL::ZipInput::Exception::SeekFileFailed)
+ {
+ LogError("Failed to seek widget archive - corrupted package?");
+ return ConfigParserData();
+ }
+ return configInfo;
}
WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
// send progress signal of pkgmgr
std::ostringstream percent;
percent << static_cast<int>(GetProgressPercent());
- PkgmgrSignalSingleton::Instance().sendSignal(
+ getInstallerStruct().pkgmgrInterface->sendSignal(
PKGMGR_PROGRESS_KEY,
percent.str());
// TODO : sync should move to separate task.
sync();
+
+ if (INSTALL_LOCATION_TYPE_EXTERNAL == m_installerContext.locationType) {
+ if (false == m_installerContext.existingWidgetInfo.isExist) {
+ WidgetInstallToExtSingleton::Instance().postInstallation(true);
+ } else {
+ WidgetInstallToExtSingleton::Instance().postUpgrade(true);
+ }
+ WidgetInstallToExtSingleton::Instance().deinitialize();
+ }
+
// remove widget install information file
unlink(m_installerContext.installInfo.c_str());
//inform widget info
JobWidgetInstall::displayWidgetInfo();
- DPL::OptionalString tizenId = getNewTizenId();
+ DPL::OptionalString & tizenId = m_installerContext.widgetConfig.pkgname;
// send signal of pkgmgr
- PkgmgrSignalSingleton::Instance().sendSignal(
+ getInstallerStruct().pkgmgrInterface->sendSignal(
PKGMGR_END_KEY,
PKGMGR_END_SUCCESS);
LogError("Error in installation step: " << m_exceptionCaught);
LogError("Message: " << m_exceptionMessage);
- DPL::OptionalString tizenId = getNewTizenId();
+ DPL::OptionalString & tizenId = m_installerContext.widgetConfig.pkgname;
LogDebug("Call widget install failure finishedCallback");
// send signal of pkgmgr
- PkgmgrSignalSingleton::Instance().sendSignal(
+ getInstallerStruct().pkgmgrInterface->sendSignal(
PKGMGR_END_KEY,
PKGMGR_END_FAILURE);
}
WrtDB::PackagingType JobWidgetInstall::checkPackageType(
- const std::string &widgetSource)
+ const std::string &widgetSource,
+ const std::string &tempPath)
{
- using namespace WrtDB;
-
- PackagingType pType = PKG_TYPE_UNKNOWN;
- std::unique_ptr<DPL::ZipInput> zipFile;
-
- Try
+ // Check installation type (direcotory/ or config.xml or widget.wgt)
+ if (WidgetUpdateMode::PolicyDirectoryForceInstall == m_jobStruct.updateMode)
{
- // Open zip file
- zipFile.reset(new DPL::ZipInput(widgetSource));
-
+ LogDebug("Install directly from directory");
+ return PKG_TYPE_DIRECTORY_WEB_APP;
}
- Catch(DPL::ZipInput::Exception::OpenFailed)
- {
- LogError("Failed to open widget package");
- return PKG_TYPE_UNKNOWN;
+ if (hasExtension(widgetSource, XML_EXTENSION)) {
+ LogInfo("Hosted app installation");
+ return PKG_TYPE_HOSTED_WEB_APP;
}
- Try
- {
- // Open config.xml file in package root
- std::unique_ptr<DPL::ZipInput::File> configFile(
- zipFile->OpenFile(CONFIG_XML));
- pType = PKG_TYPE_TIZEN_WEBAPP;
- }
- Catch(DPL::ZipInput::Exception::OpenFileFailed)
- {
- LogWarning("Could not find ./config.xml");
- }
+ if (m_isDRM) {
+ std::string configFile = tempPath + "/" + CONFIG_XML;
+ if (WrtUtilFileExists(configFile)) {
+ return PKG_TYPE_NOMAL_WEB_APP;
+ }
- Try
- {
- // Open config.xml file in package root
- std::unique_ptr<DPL::ZipInput::File> configFile(
- zipFile->OpenFile(WITH_OSP_XML));
- if (pType == PKG_TYPE_TIZEN_WEBAPP) {
- LogWarning("Two config.xml's found. Application type is unknown.");
+ configFile = tempPath + "/" + WITH_OSP_XML;
+ if (WrtUtilFileExists(configFile)) {
+ return PKG_TYPE_HYBRID_WEB_APP;
+ }
+ } else {
+ std::unique_ptr<DPL::ZipInput> zipFile;
+
+ Try
+ {
+ // Open zip file
+ zipFile.reset(new DPL::ZipInput(widgetSource));
+
+ }
+ Catch(DPL::ZipInput::Exception::OpenFailed)
+ {
+ LogDebug("Failed to open widget package");
+ return PKG_TYPE_UNKNOWN;
+ }
+ Catch(DPL::ZipInput::Exception::SeekFileFailed)
+ {
+ LogError("Failed to seek widget package file");
return PKG_TYPE_UNKNOWN;
}
- pType = PKG_TYPE_TIZEN_WITHSVCAPP;
- }
- Catch(DPL::ZipInput::Exception::OpenFileFailed)
- {
- LogWarning("Could not find ./res/wgt/config.xml");
- }
+ Try
+ {
+ // Open config.xml file in package root
+ std::unique_ptr<DPL::ZipInput::File> configFile(
+ zipFile->OpenFile(CONFIG_XML));
+ return PKG_TYPE_NOMAL_WEB_APP;
+ }
+ Catch(DPL::ZipInput::Exception::OpenFileFailed)
+ {
+ LogDebug("Could not find config.xml");
+ }
+
+ Try
+ {
+ // Open config.xml file in package root
+ std::unique_ptr<DPL::ZipInput::File> configFile(
+ zipFile->OpenFile(WITH_OSP_XML));
- if (pType == PKG_TYPE_UNKNOWN) {
- LogWarning("config.xml not found. Application type is unknown.");
+ return PKG_TYPE_HYBRID_WEB_APP;
+ }
+ Catch(DPL::ZipInput::Exception::OpenFileFailed)
+ {
+ LogDebug("Could not find wgt/config.xml");
+ return PKG_TYPE_UNKNOWN;
+ }
}
- return pType;
+
+ return PKG_TYPE_UNKNOWN;
}
bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &configData)
return false;
}
+void JobWidgetInstall::setInstallLocationType(const
+ WrtDB::ConfigParserData &configData)
+{
+ m_installerContext.locationType = INSTALL_LOCATION_TYPE_NOMAL;
+
+ if (true == m_jobStruct.m_preload) {
+ m_installerContext.locationType =
+ INSTALL_LOCATION_TYPE_PRELOAD;
+ } else {
+ FOREACH(it, configData.settingsList)
+ {
+ if (it->m_name == SETTING_VALUE_INSTALLTOEXT_NAME &&
+ it->m_value ==
+ SETTING_VALUE_INSTALLTOEXT_PREPER_EXT) {
+ LogDebug("This widget will be installed to sd card");
+ m_installerContext.locationType =
+ INSTALL_LOCATION_TYPE_EXTERNAL;
+ }
+ }
+ }
+}
+
+bool JobWidgetInstall::isDRMWidget(std::string widgetPath)
+{
+ /* TODO :
+ drm_bool_type_e is_drm_file = DRM_UNKNOWN;
+ int ret = -1;
+
+ ret = drm_is_drm_file(widgetPath.c_str(), &is_drm_file);
+ if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file) {
+ */
+
+ /* blow code temporary code for drm. */
+ int ret = drm_oem_intel_isDrmFile(const_cast<char*>(widgetPath.c_str()));
+ if ( 1 == ret) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool JobWidgetInstall::DecryptDRMWidget(std::string widgetPath,
+ std::string destPath)
+{
+ /* TODO :
+ drm_trusted_sapps_decrypt_package_info_s package_info;
+
+ strncpy(package_info.sadcf_filepath, widgetPath.c_str(),
+ sizeof(package_info.sadcf_filepath));
+ strncpy(package_info.decrypt_filepath, destPath.c_str(),
+ sizeof(package_info.decrypt_filepath));
+
+ drm_trusted_request_type_e requestType =
+ DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE;
+
+ int ret = drm_trusted_handle_request(requestType,
+ (void *)&package_info, NULL);
+ if (DRM_TRUSTED_RETURN_SUCCESS == ret) {
+ return true;
+ } else {
+ return false;
+ }
+ */
+ if (drm_oem_intel_decrypt_package(const_cast<char*>(widgetPath.c_str()),
+ const_cast<char*>(destPath.c_str())) != 0) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
} //namespace WidgetInstall
} //namespace Jobs