m_isDRM);
LogDebug("widget packaging type : " <<
m_installerContext.widgetConfig.packagingType.pkgType);
- WidgetUpdateInfo update = detectWidgetUpdate(configData);
+
+ setTizenId(configData);
+ setApplicationType(configData);
m_needEncryption = detectResourceEncryption(configData);
setInstallLocationType(configData);
// Configure installation
- result = ConfigureInstallation(widgetPath, configData, update, tempDir);
+ result = ConfigureInstallation(widgetPath, configData, tempDir);
}
Catch(Exceptions::ExtractFileFailed)
{
return result;
}
-bool JobWidgetInstall::setTizenId(
- const WrtDB::ConfigParserData &configInfo,
- const WidgetUpdateInfo &update,
- bool preload)
+void JobWidgetInstall::setTizenId(
+ const WrtDB::ConfigParserData &configInfo)
{
using namespace PackageManager;
- regex_t reg;
- 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
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) ||
- (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.");
- regfree(®);
- return false;
- }
m_installerContext.widgetConfig.pkgName = *configInfo.tizenId;
} else {
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
-
- LogDebug("Checking if tizen id is unique");
- while (true) {
- if (checkTizenIdExist(DPL::ToUTF8String(tizenId))) {
- //path exist, chose another one
- tizenId = WidgetDAOReadOnly::generateTizenId();
- continue;
- }
- break;
+ LogDebug("Checking if tizen id is unique");
+ while (true) {
+ if (checkTizenIdExist(DPL::ToUTF8String(tizenId))) {
+ //path exist, chose another one
+ tizenId = WidgetDAOReadOnly::generateTizenId();
+ continue;
}
-
- m_installerContext.widgetConfig.pkgName = tizenId;
+ break;
}
+
+ m_installerContext.widgetConfig.pkgName = tizenId;
LogInfo("tizen_id name was generated by WRT: " << tizenId);
// send start signal of pkgmgr
getInstallerStruct().pkgmgrInterface->setPkgname(DPL::ToUTF8String(
PKGMGR_START_KEY,
PKGMGR_START_INSTALL);
}
- regfree(®);
LogInfo("Tizen Id : " << m_installerContext.widgetConfig.pkgName);
LogInfo("W3C Widget GUID : " << m_installerContext.widgetConfig.guid);
- return true;
}
void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
const std::string &widgetSource,
const WrtDB::ConfigParserData &configData,
- const WidgetUpdateInfo &update,
const std::string &tempPath)
{
+ WidgetUpdateInfo update = detectWidgetUpdate(configData,
+ m_installerContext.widgetConfig.webAppType,
+ m_installerContext.widgetConfig.pkgName);
+ ConfigureResult result = checkWidgetUpdate(update);
- if (!setTizenId(configData, update, m_jobStruct.m_preload)) {
- return ConfigureResult::Failed;
- } else {
- LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgName);
+ // Validate tizenId
+ regex_t reg;
+ if(regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
+ LogDebug("Regcomp failed");
+ }
- configureWidgetLocation(widgetSource, tempPath);
+ if ((regexec(®,
+ DPL::ToUTF8String(m_installerContext.widgetConfig.pkgName).c_str(),
+ static_cast<size_t>(0), NULL, 0) != REG_NOERROR) ||
+ (checkTizenIdExist(DPL::ToUTF8String(m_installerContext.widgetConfig.pkgName)) &&
+ result != ConfigureResult::Updated))
+ {
+ //it is true when tizenId does not fit REG_TIZENID_PATTERN
+ LogError("tizen_id provided but not proper.");
+ regfree(®);
+ return ConfigureResult::Failed;
}
+ regfree(®);
+
+ configureWidgetLocation(widgetSource, tempPath);
// Init installer context
m_installerContext.installStep = InstallerContext::INSTALL_START;
m_installerContext.existingWidgetInfo = update.existingWidgetInfo;
m_installerContext.widgetConfig.shareHref = std::string();
- return ConfigureResult::Ok;
+ return result;
}
JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate(
}
WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
- const ConfigParserData &configInfo)
+ const ConfigParserData &configInfo,
+ const WrtDB::WidgetType appType,
+ const WrtDB::WidgetPkgName &tizenId)
{
LogInfo("Checking up widget package for config.xml...");
WidgetVersion(*configInfo.version));
}
- Try
- {
- // Search widget handle by GUID
- WidgetDAOReadOnly dao(widgetGUID);
- return WidgetUpdateInfo(
- widgetGUID,
- widgetVersion,
- WidgetUpdateInfo::ExistingWidgetInfo(
- dao.getPkgName(), dao.getVersion()));
- }
- Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
- {
- // GUID isn't installed
- return WidgetUpdateInfo(
- widgetGUID,
- widgetVersion,
- WidgetUpdateInfo::ExistingWidgetInfo());
+ if (appType == APP_TYPE_WAC20) {
+ Try
+ {
+ // Search widget handle by GUID
+ WidgetDAOReadOnly dao(widgetGUID);
+ return WidgetUpdateInfo(
+ widgetGUID,
+ widgetVersion,
+ WidgetUpdateInfo::ExistingWidgetInfo(
+ dao.getPkgName(), dao.getVersion()));
+ }
+ Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
+ {
+ // GUID isn't installed
+ return WidgetUpdateInfo(
+ widgetGUID,
+ widgetVersion,
+ WidgetUpdateInfo::ExistingWidgetInfo());
+ }
+ } else {
+ Try
+ {
+ // Search widget handle by appId
+ WidgetDAOReadOnly dao(tizenId);
+ return WidgetUpdateInfo(
+ widgetGUID,
+ widgetVersion,
+ WidgetUpdateInfo::ExistingWidgetInfo(
+ dao.getPkgName(), dao.getVersion()));
+ }
+ Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
+ {
+ // GUID isn't installed
+ return WidgetUpdateInfo(
+ widgetGUID,
+ widgetVersion,
+ WidgetUpdateInfo::ExistingWidgetInfo());
+ }
+
}
}
return PKG_TYPE_UNKNOWN;
}
+void JobWidgetInstall::setApplicationType(
+ const WrtDB::ConfigParserData &configInfo)
+{
+
+ FOREACH(iterator, configInfo.nameSpaces) {
+ LogInfo("namespace = [" << *iterator << "]");
+ AppType currentAppType = APP_TYPE_UNKNOWN;
+
+ if (*iterator == ConfigurationNamespace::W3CWidgetNamespaceName) {
+ continue;
+ } else if (
+ *iterator ==
+ ConfigurationNamespace::WacWidgetNamespaceNameForLinkElement ||
+ *iterator ==
+ ConfigurationNamespace::WacWidgetNamespaceName)
+ {
+ currentAppType = APP_TYPE_WAC20;
+ } else if (*iterator ==
+ ConfigurationNamespace::TizenWebAppNamespaceName) {
+ currentAppType = APP_TYPE_TIZENWEBAPP;
+ }
+
+ if (m_installerContext.widgetConfig.webAppType ==
+ APP_TYPE_UNKNOWN) {
+ m_installerContext.widgetConfig.webAppType = currentAppType;
+ } else if (m_installerContext.widgetConfig.webAppType ==
+ currentAppType) {
+ continue;
+ } else {
+ ThrowMsg(Exceptions::WidgetConfigFileInvalid,
+ "Config.xml has more than one namespace");
+ }
+ }
+
+ // If there is no define, type set to WAC 2.0
+ if (m_installerContext.widgetConfig.webAppType == APP_TYPE_UNKNOWN) {
+ m_installerContext.widgetConfig.webAppType = APP_TYPE_WAC20;
+ }
+
+ LogInfo("type = [" <<
+ m_installerContext.widgetConfig.webAppType.getApptypeToString() << "]");
+}
+
bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &configData)
{
FOREACH(it, configData.settingsList)
LogError("Parsing failed.");
ReThrow(Exceptions::WidgetConfigFileInvalid);
}
- Try
- {
- // To get widget type for distribute WAC, TIZEN WebApp
- setApplicationType();
- }
- Catch(Exception::ConfigParseFailed)
- {
- LogError("Config.xml has more than one namespace");
- ReThrow(Exceptions::WidgetConfigFileInvalid);
- }
m_installContext.job->UpdateProgress(
InstallerContext::INSTALL_WIDGET_CONFIG1,
"Widget Config step2 Finished");
}
-void TaskWidgetConfig::setApplicationType()
-{
- using namespace WrtDB;
- WidgetRegisterInfo* widgetInfo = &(m_installContext.widgetConfig);
- ConfigParserData* configInfo = &(widgetInfo->configInfo);
-
- FOREACH(iterator, configInfo->nameSpaces) {
- LogInfo("namespace = [" << *iterator << "]");
- AppType currentAppType = APP_TYPE_UNKNOWN;
-
- if (*iterator == ConfigurationNamespace::W3CWidgetNamespaceName) {
- continue;
- } else if (
- *iterator ==
- ConfigurationNamespace::WacWidgetNamespaceNameForLinkElement ||
- *iterator ==
- ConfigurationNamespace::WacWidgetNamespaceName)
- {
- currentAppType = APP_TYPE_WAC20;
- } else if (*iterator == ConfigurationNamespace::TizenWebAppNamespaceName) {
- currentAppType = APP_TYPE_TIZENWEBAPP;
- }
-
- if (widgetInfo->webAppType == APP_TYPE_UNKNOWN) {
- widgetInfo->webAppType = currentAppType;
- } else if (widgetInfo->webAppType == currentAppType) {
- continue;
- } else {
- ThrowMsg(Exceptions::WidgetConfigFileInvalid,
- "Config.xml has more than one namespace");
- }
- }
-
- // If there is no define, type set to WAC 2.0
- if (widgetInfo->webAppType == APP_TYPE_UNKNOWN) {
- widgetInfo->webAppType = APP_TYPE_WAC20;
- }
-
- LogInfo("type = [" << widgetInfo->webAppType.getApptypeToString() << "]");
-}
-
bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
DPL::String featureName)
{