//TODO Rewrite this as steps/tasks
namespace // anonymous
{
-const char * const DEFAULT_LANGUAGE = "default";
+const char *const DEFAULT_LANGUAGE = "default";
const size_t MAX_WIDGET_PATH_SIZE = 1024;
//#define WRT_WIDGET_DEFAULT_ICON_WIDTH 80
//#define WRT_WIDGET_DEFAULT_ICON_HEIGHT 80
//#define WRT_WIDGET_CONFIG_BASE_LOCALE "locales"
-const char * const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
+const char *const WRT_WIDGET_CONFIG_FILE_NAME = "config.xml";
}
bool WidgetConfigurationManager::locateAndParseConfigurationFile(
const std::string& _currentPath,
WrtDB::WidgetRegisterInfo& pWidgetConfigInfo,
- const std::string& baseFolder, int* pErrCode)
+ const std::string& baseFolder,
+ int* pErrCode)
{
using namespace WrtDB;
// check if this installation from browser, or not.
size_t pos = _currentPath.rfind("/");
std::ostringstream infoPath;
- infoPath << _currentPath.substr(pos + 1);
+ infoPath << _currentPath.substr(pos+1);
ParserRunner parser;
std::string language = "";
while ((ptr = readdir(dir)) != NULL) { //Find configuration file, based on its name
if (ptr->d_type == DT_REG) {
if (!strcmp(ptr->d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
- _WrtUtilSetAbsolutePath(cfgAbsPath, _currentPath.c_str(),
- ptr->d_name);
+ _WrtUtilSetAbsolutePath(cfgAbsPath,
+ _currentPath.c_str(), ptr->d_name);
//Parse widget configuration file
LogDebug("Found config: " << cfgAbsPath);
Try
{
- parser.Parse(cfgAbsPath,
- ElementParserPtr(
- new RootParser<WidgetParser>(configInfo,
- DPL::FromUTF32String(
- L"widget"))));
+ parser.Parse(cfgAbsPath, ElementParserPtr(new
+ RootParser<
+ WidgetParser>(
+ configInfo,
+ DPL
+ ::
+ FromUTF32String(
+ L"widget"))));
+ }
+ Catch(ElementParser::Exception::Base)
+ {
+ LogDebug("Invalid widget configuration file!");
+ // _rethrown_exception.Dump();
+ *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+ closedir(dir);
+ return false;
}
- Catch(ElementParser::Exception::Base){
- LogDebug("Invalid widget configuration file!");
- // _rethrown_exception.Dump();
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- closedir(dir);
- return false;
- }
- //
- // WidgetConfigurationParser & parser = WidgetConfigurationParserSingleton::Instance();
- // if (!parser.parseConfigurationFile(cfgAbsPath, configInfo, baseFolder.c_str(), pWidgetConfigInfo.signature_type)) {
- // LogDebug("Invalid widget configuration file!");
- // *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- // closedir(dir);
- // return false;
- // }
+ //
+ // WidgetConfigurationParser & parser = WidgetConfigurationParserSingleton::Instance();
+ // if (!parser.parseConfigurationFile(cfgAbsPath, configInfo, baseFolder.c_str(), pWidgetConfigInfo.signature_type)) {
+ // LogDebug("Invalid widget configuration file!");
+ // *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+ // closedir(dir);
+ // return false;
+ // }
has_config_xml = true;
break;
// in case of browser installation
Try
{
- parser.Parse(_currentPath,
- ElementParserPtr(
- new RootParser<WidgetParser>(configInfo,
- DPL::FromUTF32String(L"widget"))));
+ parser.Parse(_currentPath, ElementParserPtr(new
+ RootParser<
+ WidgetParser>(
+ configInfo,
+ DPL::FromUTF32String(
+ L"widget"))));
+ }
+ Catch(ElementParser::Exception::Base)
+ {
+ LogDebug("Invalid widget configuration file!");
+ // _rethrown_exception.Dump();
+ *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+ return false;
}
- Catch(ElementParser::Exception::Base){
- LogDebug("Invalid widget configuration file!");
- // _rethrown_exception.Dump();
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- return false;
}
-}
+
char *tmp_language;
if (!_WrtUtilStringToLower(baseFolder.c_str(), &tmp_language)) {
}
if (!!configInfo.tizenId) {
- if (pWidgetConfigInfo.pkgname_NOTNULL != *configInfo.tizenId) {
- *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
- LogDebug("Invalid archive - Tizen ID not same error");
- return false;
+ if (!pWidgetConfigInfo.pkgname) {
+ pWidgetConfigInfo.pkgname = configInfo.tizenId;
+ } else {
+ if (pWidgetConfigInfo.pkgname != configInfo.tizenId) {
+ *pErrCode = WRT_WM_ERR_INVALID_ARCHIVE;
+ LogDebug("Invalid archive - Tizen ID not same error");
+ return false;
+ }
}
}
int pErrCode;
if (!locateAndParseConfigurationFile(path, widgetConfiguration,
- DEFAULT_LANGUAGE, &pErrCode)) {
+ DEFAULT_LANGUAGE, &pErrCode)) {
LogWarning("Widget archive: Failed while parsing config file");
ThrowMsg(Exception::ProcessFailed, path);
}
regfree(®);
return false;
}
- m_installerContext.widgetConfig.pkgname_NOTNULL = *configInfo.tizenId;
+ m_installerContext.widgetConfig.pkgname = configInfo.tizenId;
} else {
WidgetPkgName tizenId = WidgetDAOReadOnly::generateTizenId();
break;
}
- m_installerContext.widgetConfig.pkgname_NOTNULL = tizenId;
+ m_installerContext.widgetConfig.pkgname = tizenId;
}
LogInfo("tizen_id name was generated by WRT: " << tizenId);
}
regfree(®);
- LogInfo("Tizen Id : " << m_installerContext.widgetConfig.pkgname_NOTNULL);
+ LogInfo("Tizen Id : " << m_installerContext.widgetConfig.pkgname);
LogInfo("W3C Widget GUID : " << m_installerContext.widgetConfig.guid);
return true;
}
const std::string& tempPath)
{
m_installerContext.locations =
- WidgetLocation(DPL::ToUTF8String(m_installerContext.widgetConfig.pkgname_NOTNULL),
+ WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname),
widgetPath, tempPath,
m_installerContext.widgetConfig.packagingType);
LogInfo("Widget info exists. PkgName: " <<
update.existingWidgetInfo.pkgname);
- DPL::String pkgname = update.existingWidgetInfo.pkgname;
+ DPL::OptionalString pkgname = update.existingWidgetInfo.pkgname;
+
+ if(pkgname.IsNull()) {
+ LogInfo("But package name doesn't exist");
+ return ConfigureResult::Failed;
+ }
LogInfo("Widget model exists. package name: " << pkgname);
// Check running state
int retval = APP_MANAGER_ERROR_NONE;
bool isRunning = false;
- retval = app_manager_is_running(DPL::ToUTF8String(pkgname).c_str(), &isRunning);
+ retval = app_manager_is_running(DPL::ToUTF8String(*pkgname).c_str(), &isRunning);
if (APP_MANAGER_ERROR_NONE != retval) {
LogError("Fail to get running state");
return ConfigureResult::Failed;
}
}
- m_installerContext.widgetConfig.pkgname_NOTNULL = pkgname;
+ m_installerContext.widgetConfig.pkgname = pkgname;
OptionalWidgetVersion existingVersion;
existingVersion = update.existingWidgetInfo.existingVersion;
OptionalWidgetVersion incomingVersion = update.incomingVersion;
return ConfigureResult::Failed;
} else {
using namespace PackageManager;
- LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname_NOTNULL);
+ LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
configureWidgetLocation(widgetSource, tempPath);
// send start signal of pkgmgr
PkgmgrSignalSingleton::Instance().setPkgname(
- DPL::ToUTF8String(m_installerContext.widgetConfig.pkgname_NOTNULL));
- PkgmgrSignalSingleton::Instance().sendSignal(PKGMGR_START_KEY,
- PKGMGR_START_INSTALL);
+ DPL::ToUTF8String(
+ *m_installerContext.widgetConfig.pkgname));
+ PkgmgrSignalSingleton::Instance().sendSignal(
+ PKGMGR_START_KEY,
+ PKGMGR_START_INSTALL);
}
// Init installer context
widgetGUID,
widgetVersion,
WidgetUpdateInfo::ExistingWidgetInfo(
- dao.getPkgname_NOTNULL(), dao.getVersion()));
+ *dao.getPkgname(), dao.getVersion()));
}
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
{
//inform widget info
JobWidgetInstall::displayWidgetInfo();
- DPL::String & tizenId = m_installerContext.widgetConfig.pkgname_NOTNULL;
+ DPL::OptionalString & tizenId = m_installerContext.widgetConfig.pkgname;
// send signal of pkgmgr
PkgmgrSignalSingleton::Instance().sendSignal(
LogDebug("Call widget install successfinishedCallback");
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- DPL::ToUTF8String(tizenId), Exceptions::Success);
+ tizenId.IsNull() ? "" : DPL::ToUTF8String(*tizenId), Exceptions::Success);
}
void JobWidgetInstall::SendFinishedFailure()
LogError("Error in installation step: " << m_exceptionCaught);
LogError("Message: " << m_exceptionMessage);
- DPL::String & tizenId = m_installerContext.widgetConfig.pkgname_NOTNULL;
+ DPL::OptionalString & tizenId = m_installerContext.widgetConfig.pkgname;
LogDebug("Call widget install failure finishedCallback");
PKGMGR_END_FAILURE);
getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
- DPL::ToUTF8String(tizenId), m_exceptionCaught);
+ tizenId.IsNull() ? "" : DPL::ToUTF8String(*tizenId), m_exceptionCaught);
}
void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
std::ostringstream out;
WidgetLocalizedInfo localizedInfo =
- W3CFileLocalization::getLocalizedInfo(dao.getPkgname_NOTNULL());
+ W3CFileLocalization::getLocalizedInfo(*dao.getPkgname());
out << std::endl <<
"===================================== INSTALLED WIDGET INFO ========="\
"============================";
out << std::endl << "Name: " << localizedInfo.name;
- out << std::endl << "PkgName: " << dao.getPkgname_NOTNULL();
+ out << std::endl << "PkgName: " << dao.getPkgname();
WidgetSize size = dao.getPreferredSize();
out << std::endl << "Width: " << size.width;
out << std::endl << "Height: " << size.height;
out << std::endl << "Start File: " <<
- W3CFileLocalization::getStartFile(dao.getPkgname_NOTNULL());
+ W3CFileLocalization::getStartFile(*dao.getPkgname());
out << std::endl << "Version: " << dao.getVersion();
out << std::endl << "Licence: " <<
localizedInfo.license;
dao.isDistributorSigned();
out << std::endl << "Widget trusted: " << dao.isTrusted();
- OptionalWidgetIcon icon = W3CFileLocalization::getIcon(dao.getPkgname_NOTNULL());
+ OptionalWidgetIcon icon = W3CFileLocalization::getIcon(*dao.getPkgname());
DPL::OptionalString iconSrc =
!!icon ? icon->src : DPL::OptionalString::Null;
out << std::endl << "Icon: " << iconSrc;
if ((pkgmgr_installer_save_certinfo(
const_cast<char*>(DPL::ToUTF8String(
- m_context.widgetConfig.pkgname_NOTNULL).c_str()),
+ *m_context.widgetConfig.pkgname).c_str()),
m_pkgHandle)) < 0) {
LogError("pkgmgrInstallerSaveCertinfo fail");
ThrowMsg(Exceptions::SetCertificateInfoFailed,
{
if ((pkgmgr_installer_delete_certinfo(
const_cast<char*>(DPL::ToUTF8String(
- m_context.widgetConfig.pkgname_NOTNULL).c_str()))) < 0) {
+ *m_context.widgetConfig.pkgname).c_str()))) < 0) {
LogError("pkgmgr_installer_delete_certinfo fail");
}
}
{
LogDebug("Step Encrypt resource");
m_resEnc = new ResourceEncryptor;
- m_resEnc->CreateEncryptionKey(DPL::ToUTF8String(m_context.
- widgetConfig.pkgname_NOTNULL));
+ m_resEnc->CreateEncryptionKey(DPL::ToUTF8String(*m_context.
+ widgetConfig.pkgname));
EncryptDirectory(m_context.locations->getTemporaryRootDir());
}
void TaskFileManipulation::StepCreateDirs()
{
std::string widgetPath;
- DPL::String pkgname = m_context.widgetConfig.pkgname_NOTNULL;
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
widgetPath = m_context.locations->getPackageInstallationDir();
void TaskFileManipulation::StepRenamePath()
{
std::string instDir;
- DPL::String pkgname = m_context.widgetConfig.pkgname_NOTNULL;
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) {
instDir = m_context.locations->getPackageInstallationDir();
const DPL::String& languageTag) const
{
DPL::OStringStream filename;
- DPL::String pkgname = m_context.widgetConfig.pkgname_NOTNULL;
+ DPL::Optional<DPL::String> pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
- filename << DPL::ToUTF8String(pkgname).c_str();
+ filename << DPL::ToUTF8String(*pkgname).c_str();
if (!languageTag.empty()) {
DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc
{
// Update ail for desktop
std::string cfgPkgname =
- DPL::ToUTF8String(m_context.widgetConfig.pkgname_NOTNULL);
+ DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
const char* pkgname = cfgPkgname.c_str();
LogDebug("Update ail desktop : " << pkgname );
std::list<std::string> fileList;
getFileList(GlobalConfig::GetUserWidgetDesktopIconPath(), fileList);
- std::string pkgname = DPL::ToUTF8String(m_context.widgetConfig.pkgname_NOTNULL);
+ std::string pkgname = DPL::ToUTF8String(*m_context.widgetConfig.pkgname);
FOREACH(it, fileList)
{
void TaskManifestFile::stepGenerateManifest()
{
- DPL::String pkgname = m_context.widgetConfig.pkgname_NOTNULL;
+ DPL::String pkgname = *m_context.widgetConfig.pkgname;
manifest_name = pkgname + L".xml";
manifest_file += L"/tmp/" + manifest_name;
}
//appid
DPL::String pkgname;
-
- pkgname = m_context.widgetConfig.pkgname_NOTNULL;
- uiApp.setAppid(pkgname);
+ if(!!m_context.widgetConfig.pkgname)
+ {
+ pkgname = *m_context.widgetConfig.pkgname;
+ uiApp.setAppid(pkgname);
+ }
//extraid
if(!!m_context.widgetConfig.guid) {
void TaskManifestFile::setWidgetIcons(UiApplication & uiApp)
{
- DPL::String pkgname = m_context.widgetConfig.pkgname_NOTNULL;
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if (pkgname.IsNull()) {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
//TODO this file will need to be updated when user locale preferences
//changes.
void TaskManifestFile::setWidgetManifest(Manifest & manifest)
{
- manifest.setPackage(m_context.widgetConfig.pkgname_NOTNULL);
-
+ if(!!m_context.widgetConfig.pkgname)
+ {
+ manifest.setPackage(*m_context.widgetConfig.pkgname);
+ }
if(!!m_context.widgetConfig.version)
{
manifest.setVersion(*m_context.widgetConfig.version);
InstallerContext::INSTALL_CREATE_PRIVATE_STORAGE;
std::ostringstream widgetPath;
- DPL::String pkgname = m_context.widgetConfig.pkgname_NOTNULL;
-
- widgetPath << m_context.locations->getPackageInstallationDir() << "/";
+ DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
+ if(!pkgname.IsNull()) {
+ widgetPath << m_context.locations->getPackageInstallationDir() << "/";
+ } else {
+ ThrowMsg(Exceptions::InternalError, "No Package name exists.");
+ }
if (euidaccess(widgetPath.str().c_str(), W_OK | X_OK) != 0) {
ThrowMsg(Exceptions::InternalError, DPL::GetErrnoString());
devcaps << utf8;
}
}
- DPL::String pkgName = m_context.widgetConfig.pkgname;
+ DPL::OptionalString pkgName = m_context.widgetConfig.Pkgname;
+ Assert(!pkgName.IsNull() && "widget doesn't have a pkg name");
int result = handle_access_control_conf_forWAC(
- DPL::ToUTF8String(pkgName).c_str(),
+ DPL::ToUTF8String(*pkgName).c_str(),
devcaps.str().c_str(),
OPERATION_INSTALL);
Assert(result==PC_OPERATION_SUCCESS && "access control setup failed");
}
}
if (!!configInfo.tizenId) {
- if (pWidgetConfigInfo.pkgname_NOTNULL != *configInfo.tizenId) {
- LogError("Invalid archive - Tizen ID not same error");
- return false;
+ if (!pWidgetConfigInfo.pkgname) {
+ pWidgetConfigInfo.pkgname = configInfo.tizenId;
+ } else {
+ if (pWidgetConfigInfo.pkgname != configInfo.tizenId) {
+ LogError("Invalid archive - Tizen ID not same error");
+ return false;
+ }
}
}
if (!!configInfo.version) {
#ifdef WRT_SMACK_ENABLED
try {
WrtDB::WidgetDAOReadOnly dao(m_context.locations->getPkgname());
- DPL::String pkgName = dao.getPkgname_NOTNULL();
+ DPL::OptionalString pkgName = dao.getPkgname();
+ Assert(!pkgName.IsNull() && "widget doesn't have a pkg name");
const char *devCap = "";
int result = handle_access_control_conf_forWAC(
- DPL::ToUTF8String(pkgName).c_str(),
+ DPL::ToUTF8String(*pkgName).c_str(),
NULL,
OPERATION_UNINSTALL);
Assert(result==PC_OPERATION_SUCCESS && "access control setup failed");
WrtDB::WrtDatabase::attachToThreadRO();
- WidgetPkgNameList_NOTNULL pkgnameslList = WidgetDAOReadOnly::getPkgnameList_NOTNULL();
+ WidgetPkgNameList pkgnameslList = WidgetDAOReadOnly::getPkgnameList();
*count = 0;
FOREACH(iterator, pkgnameslList) {
pkg_last->next = pkg_info;
}
- WidgetPkgName pkgname = *iterator;
+ WidgetPkgName pkgname = **iterator;
WidgetDAOReadOnly widget(pkgname);
strncpy(pkg_info->pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX);
snprintf(pkg_info->pkg_name, PKG_NAME_STRING_LEN_MAX, "%s",
WidgetGUID widget_guid = DPL::FromUTF8String(guid);
WrtDB::WidgetDAOReadOnly dao(widget_guid);
- pkgname = DPL::ToUTF8String(dao.getPkgname_NOTNULL());
+ pkgname = DPL::ToUTF8String(*dao.getPkgname());
return WRT_SUCCESS;
}
catch (WidgetDAOReadOnly::Exception::WidgetNotExist)