X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fjobs%2Fwidget_install%2Ftask_manifest_file.cpp;h=f6bc0389e957da12d54de26f7b46068207f84dfe;hb=ceca4e287d715bf26e923e81b2d45a3f056927af;hp=660c39a903a7725be6e03f3fe4b78707de974773;hpb=b2ace93bd9ba27d509c82a455e590fe042f7baa6;p=framework%2Fweb%2Fwrt-installer.git diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp old mode 100755 new mode 100644 index 660c39a..f6bc038 --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -21,6 +21,7 @@ */ //SYSTEM INCLUDES +#include #include #include #include @@ -63,7 +64,7 @@ LanguageTagMap getLanguageTagMap() { LanguageTagMap map; -#define ADD(tag, l_tag) map.insert(std::make_pair(L ## # tag, L ## # l_tag)); +#define ADD(tag, l_tag) map.insert(std::make_pair(L###tag, L###l_tag)); #include "languages.def" #undef ADD @@ -97,23 +98,15 @@ DPL::OptionalString getLangTag(const DPL::String& tag) namespace Jobs { namespace WidgetInstall { - const char * TaskManifestFile::encoding = "UTF-8"; TaskManifestFile::TaskManifestFile(InstallerContext &inCont) : DPL::TaskDecl(this), - m_context(inCont) + m_context(inCont), + writer(NULL) { - if (false == m_context.existingWidgetInfo.isExist) { - AddStep(&TaskManifestFile::stepCopyIconFiles); - AddStep(&TaskManifestFile::stepCreateExecFile); - AddStep(&TaskManifestFile::stepGenerateManifest); - AddStep(&TaskManifestFile::stepParseManifest); - AddStep(&TaskManifestFile::stepFinalize); - - AddAbortStep(&TaskManifestFile::stepAbortParseManifest); - } else { - // for widget update. + if (m_context.isUpdateMode) { + // for widget update. AddStep(&TaskManifestFile::stepBackupIconFiles); AddStep(&TaskManifestFile::stepCopyIconFiles); AddStep(&TaskManifestFile::stepGenerateManifest); @@ -121,24 +114,65 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) : AddStep(&TaskManifestFile::stepUpdateFinalize); AddAbortStep(&TaskManifestFile::stepAbortIconFiles); + } else { + AddStep(&TaskManifestFile::stepCopyIconFiles); + AddStep(&TaskManifestFile::stepCreateExecFile); + AddStep(&TaskManifestFile::stepGenerateManifest); + AddStep(&TaskManifestFile::stepParseManifest); + AddStep(&TaskManifestFile::stepFinalize); + + AddAbortStep(&TaskManifestFile::stepAbortParseManifest); } } TaskManifestFile::~TaskManifestFile() -{ -} +{} void TaskManifestFile::stepCreateExecFile() { std::string exec = m_context.locations->getExecFile(); std::string clientExeStr = GlobalConfig::GetWrtClientExec(); + //default widget LogInfo("link -s " << clientExeStr << " " << exec); - symlink(clientExeStr.c_str(), exec.c_str()); + errno = 0; + if (symlink(clientExeStr.c_str(), exec.c_str()) != 0) + { + int error = errno; + if (error) + LogPedantic("Failed to make a symbolic name for a file " + << "[" << DPL::GetErrnoString(error) << "]"); + ThrowMsg(Exceptions::FileOperationFailed, + "Symbolic link creating is not done."); + } + +#ifdef MULTIPROCESS_SERVICE_SUPPORT + //services + std::size_t serviceCount = + m_context.widgetConfig.configInfo.appControlList.size(); + serviceCount += m_context.widgetConfig.configInfo.appServiceList.size(); + for (std::size_t i = 0; i < serviceCount; ++i) { + std::stringstream postfix; + postfix << "-__SERVICE_PROCESS__" << i; + std::string serviceExec = exec; + serviceExec.append(postfix.str()); + errno = 0; + if (symlink(clientExeStr.c_str(), serviceExec.c_str()) != 0) + { + int error = errno; + if (error) + LogPedantic("Failed to make a symbolic name for a file " + << "[" << DPL::GetErrnoString(error) << "]"); + ThrowMsg(Exceptions::FileOperationFailed, + "Symbolic link creating is not done."); + } + + } +#endif m_context.job->UpdateProgress( - InstallerContext::INSTALL_CREATE_EXECFILE, - "Widget execfile creation Finished"); + InstallerContext::INSTALL_CREATE_EXECFILE, + "Widget execfile creation Finished"); } void TaskManifestFile::stepCopyIconFiles() @@ -149,27 +183,32 @@ void TaskManifestFile::stepCopyIconFiles() //which there is at least one icon in widget for, icon file is copied. //Coping prioritize last positions when coping. If there is several icons //with given locale, the one, that will be copied, will be icon - //which is declared by tag later than the others in config.xml of widget + //which is declared by tag later than the others in config.xml of + // widget std::vector generatedLocales; - WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons; + WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = + m_context.widgetConfig.localizationData.icons; - //reversed: last has highest priority to be copied if it has given locale (TODO: why was that working that way?) - for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++) + //reversed: last has highest priority to be copied if it has given + // locale (TODO: why was that working that way?) + for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator + icon = icons.rbegin(); + icon != icons.rend(); + ++icon) { FOREACH(locale, icon->availableLocales) { DPL::String src = icon->src; LogDebug("Icon for locale: " << *locale << "is : " << src); - if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end()) + if (std::find(generatedLocales.begin(), generatedLocales.end(), + *locale) != generatedLocales.end()) { LogDebug("Skipping - has that locale"); continue; - } - else - { + } else { generatedLocales.push_back(*locale); } @@ -187,10 +226,11 @@ void TaskManifestFile::stepCopyIconFiles() targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/"; targetFile << getIconTargetFilename(*locale); - if (m_context.widgetConfig.packagingType == - WrtDB::PKG_TYPE_HOSTED_WEB_APP) { - m_context.locations->setIconTargetFilenameForLocale(targetFile.str()); + WrtDB::PKG_TYPE_HOSTED_WEB_APP) + { + m_context.locations->setIconTargetFilenameForLocale( + targetFile.str()); } LogDebug("Copying icon: " << sourceFile.str() << @@ -208,27 +248,30 @@ void TaskManifestFile::stepCopyIconFiles() Catch(DPL::FileInput::Exception::Base) { // Error while opening or closing source file - //ReThrowMsg(InstallerException::CopyIconFailed, sourceFile.str()); + //ReThrowMsg(InstallerException::CopyIconFailed, + // sourceFile.str()); LogError( - "Copying widget's icon failed. Widget's icon will not be"\ + "Copying widget's icon failed. Widget's icon will not be" \ "available from Main Screen"); } Catch(DPL::FileOutput::Exception::Base) { // Error while opening or closing target file - //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str()); + //ReThrowMsg(InstallerException::CopyIconFailed, + // targetFile.str()); LogError( - "Copying widget's icon failed. Widget's icon will not be"\ + "Copying widget's icon failed. Widget's icon will not be" \ "available from Main Screen"); } Catch(DPL::CopyFailed) { // Error while copying - //ReThrowMsg(InstallerException::CopyIconFailed, targetFile.str()); + //ReThrowMsg(InstallerException::CopyIconFailed, + // targetFile.str()); LogError( - "Copying widget's icon failed. Widget's icon will not be"\ + "Copying widget's icon failed. Widget's icon will not be" \ "available from Main Screen"); } } @@ -286,18 +329,18 @@ void TaskManifestFile::stepAbortIconFiles() Catch(DPL::FileInput::Exception::Base) { LogError("Restoration icon File Failed." << backup_file.str() - << " to " << res_file.str()); + << " to " << res_file.str()); } Catch(DPL::FileOutput::Exception::Base) { LogError("Restoration icon File Failed." << backup_file.str() - << " to " << res_file.str()); + << " to " << res_file.str()); } Catch(DPL::CopyFailed) { LogError("Restoration icon File Failed." << backup_file.str() - << " to " << res_file.str()); + << " to " << res_file.str()); } } } @@ -309,7 +352,7 @@ void TaskManifestFile::stepUpdateFinalize() } DPL::String TaskManifestFile::getIconTargetFilename( - const DPL::String& languageTag) const + const DPL::String& languageTag) const { DPL::OStringStream filename; TizenAppId appid = m_context.widgetConfig.tzAppid; @@ -317,12 +360,15 @@ DPL::String TaskManifestFile::getIconTargetFilename( filename << DPL::ToUTF8String(appid).c_str(); if (!languageTag.empty()) { - DPL::OptionalString tag = getLangTag(languageTag); // translate en -> en_US etc - if (tag.IsNull()) { tag = languageTag; } + DPL::OptionalString tag = getLangTag(languageTag); // translate en -> + // en_US etc + if (tag.IsNull()) { + tag = languageTag; + } DPL::String locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag); - if(locale.empty()) { + if (locale.empty()) { filename << L"." << languageTag; } else { filename << L"." << locale; @@ -339,13 +385,12 @@ void TaskManifestFile::stepFinalize() LogInfo("Finished ManifestFile step"); } - void TaskManifestFile::saveLocalizedKey(std::ofstream &file, - const DPL::String& key, - const DPL::String& languageTag) + const DPL::String& key, + const DPL::String& languageTag) { DPL::String locale = - LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag); + LanguageTagsProvider::BCP47LanguageTagToLocale(languageTag); file << key; if (!locale.empty()) { @@ -365,9 +410,9 @@ void TaskManifestFile::updateAilInfo() ail_appinfo_h ai = NULL; ail_error_e ret; - ret = ail_package_get_appinfo(appid, &ai); + ret = ail_get_appinfo(appid, &ai); if (ai) { - ail_package_destroy_appinfo(ai); + ail_destroy_appinfo(ai); } if (AIL_ERROR_NO_DATA == ret) { @@ -398,7 +443,8 @@ void TaskManifestFile::backupIconFiles() FOREACH(it, fileList) { if (0 == (strncmp((*it).c_str(), appid.c_str(), - strlen(appid.c_str())))) { + strlen(appid.c_str())))) + { std::ostringstream icon_file, backup_icon; icon_file << GlobalConfig::GetUserWidgetDesktopIconPath(); icon_file << "/" << (*it); @@ -406,7 +452,7 @@ void TaskManifestFile::backupIconFiles() backup_icon << b_icon_dir.str() << "/" << (*it); LogDebug("Backup icon file " << icon_file.str() << " to " << - backup_icon.str()); + backup_icon.str()); Try { DPL::FileInput input(icon_file.str()); @@ -435,28 +481,38 @@ void TaskManifestFile::backupIconFiles() } void TaskManifestFile::getFileList(const char* path, - std::list &list) + std::list &list) { DIR* dir = opendir(path); if (!dir) { LogError("icon directory doesn't exist"); - ThrowMsg(Exceptions::InternalError, path); + ThrowMsg(Exceptions::FileOperationFailed, path); } - struct dirent* d_ent; - do { - if ((d_ent = readdir(dir))) { - if(strcmp(d_ent->d_name, ".") == 0 || - strcmp(d_ent->d_name, "..") == 0) { - continue; - } - std::string file_name = d_ent->d_name; - list.push_back(file_name); + struct dirent entry; + struct dirent *result; + int return_code; + errno = 0; + for (return_code = readdir_r(dir, &entry, &result); + result != NULL && return_code == 0; + return_code = readdir_r(dir, &entry, &result)) + { + if (strcmp(entry.d_name, ".") == 0 || + strcmp(entry.d_name, "..") == 0) + { + continue; } - }while(d_ent); + std::string file_name = entry.d_name; + list.push_back(file_name); + } + + if (return_code != 0 || errno != 0) { + LogError("readdir_r() failed with " << DPL::GetErrnoString()); + } + if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) { LogError("Failed to close dir: " << path << " with error: " - << DPL::GetErrnoString()); + << DPL::GetErrnoString()); } } @@ -481,13 +537,13 @@ void TaskManifestFile::stepParseManifest() int code = pkgmgr_parser_parse_manifest_for_installation( DPL::ToUTF8String(manifest_file).c_str(), NULL); - if(code != 0) - { + if (code != 0) { LogError("Manifest parser error: " << code); - ThrowMsg(ManifestParsingError, "Parser returncode: " << code); + ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code); } - // TODO : It will be removed. AIL update is temporary code request by pkgmgr team. + // TODO : It will be removed. AIL update is temporary code request by pkgmgr + // team. updateAilInfo(); m_context.job->UpdateProgress( @@ -501,13 +557,13 @@ void TaskManifestFile::stepParseUpgradedManifest() int code = pkgmgr_parser_parse_manifest_for_upgrade( DPL::ToUTF8String(manifest_file).c_str(), NULL); - if(code != 0) - { + if (code != 0) { LogError("Manifest parser error: " << code); - ThrowMsg(ManifestParsingError, "Parser returncode: " << code); + ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code); } - // TODO : It will be removed. AIL update is temporary code request by pkgmgr team. + // TODO : It will be removed. AIL update is temporary code request by pkgmgr + // team. updateAilInfo(); m_context.job->UpdateProgress( @@ -541,66 +597,143 @@ void TaskManifestFile::writeManifest(const DPL::String & path) Manifest manifest; UiApplication uiApp; + //default widget content setWidgetExecPath(uiApp); setWidgetName(manifest, uiApp); + setWidgetIds(manifest, uiApp); setWidgetIcons(uiApp); setWidgetManifest(manifest); setWidgetOtherInfo(uiApp); - setAppServiceInfo(uiApp); - setAppControlInfo(uiApp); +#ifndef MULTIPROCESS_SERVICE_SUPPORT + setAppServicesInfo(uiApp); + setAppControlsInfo(uiApp); +#endif setAppCategory(uiApp); setLiveBoxInfo(manifest); + setAccount(manifest); + setPrivilege(manifest); manifest.addUiApplication(uiApp); +#ifdef MULTIPROCESS_SERVICE_SUPPORT + //services AppControl tag + ConfigParserData::AppControlInfoList appControlList = + m_context.widgetConfig.configInfo.appControlList; + unsigned count = 0; + + FOREACH(it, appControlList) { + it->m_index = count; + UiApplication uiApp; + + uiApp.setTaskmanage(true); + uiApp.setNodisplay(true); + + std::stringstream postfix; + postfix << "-__SERVICE_PROCESS__" << count++; + + setWidgetExecPath(uiApp, postfix.str()); + setWidgetName(manifest, uiApp); + setWidgetIds(manifest, uiApp, postfix.str()); + setWidgetIcons(uiApp); + setAppControlInfo(uiApp, *it); + setAppCategory(uiApp); + setAccount(manifest); + setPrivilege(manifest); + + manifest.addUiApplication(uiApp); + } + //TODO: AppService tag will be removed + //services AppService tag + WrtDB::ConfigParserData::ServiceInfoList appServiceList = + m_context.widgetConfig.configInfo.appServiceList; + FOREACH(it, appServiceList) { + it->m_index = count; + UiApplication uiApp; + + uiApp.setTaskmanage(true); + uiApp.setNodisplay(true); + + std::stringstream postfix; + postfix << "-__SERVICE_PROCESS__" << count++; + + setWidgetExecPath(uiApp, postfix.str()); + setWidgetName(manifest, uiApp); + setWidgetIds(manifest, uiApp, postfix.str()); + setWidgetIcons(uiApp); + setAppServiceInfo(uiApp, *it); + setAppCategory(uiApp); + setAccount(manifest); + setPrivilege(manifest); + + manifest.addUiApplication(uiApp); + } +#endif manifest.generate(path); LogDebug("Manifest file serialized"); } -void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp) +void TaskManifestFile::setWidgetExecPath(UiApplication & uiApp, + const std::string &postfix) { - uiApp.setExec(DPL::FromASCIIString(m_context.locations->getExecFile())); + std::string exec = m_context.locations->getExecFile(); + if (!postfix.empty()) { + exec.append(postfix); + } + LogDebug("exec = " << exec); + uiApp.setExec(DPL::FromASCIIString(exec)); } -void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp) +void TaskManifestFile::setWidgetName(Manifest & manifest, + UiApplication & uiApp) { bool defaultNameSaved = false; - DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale; - std::pair defaultLocalizedData; + DPL::OptionalString defaultLocale = + m_context.widgetConfig.configInfo.defaultlocale; + std::pair defaultLocalizedData; //labels FOREACH(localizedData, m_context.widgetConfig.configInfo.localizedDataSet) { Locale i = localizedData->first; DPL::OptionalString tag = getLangTag(i); // translate en -> en_US etc - if (tag.IsNull()) - { + if (tag.IsNull()) { tag = i; } DPL::OptionalString name = localizedData->second.name; generateWidgetName(manifest, uiApp, tag, name, defaultNameSaved); //store default locale localized data - if(!!defaultLocale && defaultLocale == i) - { + if (!!defaultLocale && defaultLocale == i) { defaultLocalizedData = *localizedData; } } - if (!!defaultLocale && !defaultNameSaved) - { + if (!!defaultLocale && !defaultNameSaved) { DPL::OptionalString name = defaultLocalizedData.second.name; - generateWidgetName(manifest, uiApp, DPL::OptionalString::Null, name, defaultNameSaved); + generateWidgetName(manifest, + uiApp, + DPL::OptionalString::Null, + name, + defaultNameSaved); } +} + +void TaskManifestFile::setWidgetIds(Manifest & manifest, + UiApplication & uiApp, + const std::string &postfix) +{ //appid TizenAppId appid = m_context.widgetConfig.tzAppid; + if (!postfix.empty()) { + appid = DPL::FromUTF8String(DPL::ToUTF8String(appid).append(postfix)); + } uiApp.setAppid(appid); - //extraid - if(!!m_context.widgetConfig.guid) { + if (!!m_context.widgetConfig.guid) { uiApp.setExtraid(*m_context.widgetConfig.guid); } else { - if(!appid.empty()) { + if (!appid.empty()) { uiApp.setExtraid(DPL::String(L"http://") + appid); } } @@ -610,25 +743,24 @@ void TaskManifestFile::setWidgetName(Manifest & manifest, UiApplication & uiApp) manifest.setType(L"wgt"); } -void TaskManifestFile::generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved) +void TaskManifestFile::generateWidgetName(Manifest & manifest, + UiApplication &uiApp, + const DPL::OptionalString& tag, + DPL::OptionalString name, + bool & defaultNameSaved) { if (!!name) { - if (!!tag) - { + if (!!tag) { DPL::String locale = - LanguageTagsProvider::BCP47LanguageTagToLocale(*tag); + LanguageTagsProvider::BCP47LanguageTagToLocale(*tag); if (!locale.empty()) { - uiApp.addLabel(LabelType(*name,*tag)); - } - else - { + uiApp.addLabel(LabelType(*name, *tag)); + } else { uiApp.addLabel(LabelType(*name)); manifest.addLabel(LabelType(*name)); } - } - else - { + } else { defaultNameSaved = true; uiApp.addLabel(LabelType(*name)); manifest.addLabel(LabelType(*name)); @@ -642,108 +774,115 @@ void TaskManifestFile::setWidgetIcons(UiApplication & uiApp) //changes. bool defaultIconSaved = false; - DPL::OptionalString defaultLocale = m_context.widgetConfig.configInfo.defaultlocale; + DPL::OptionalString defaultLocale = + m_context.widgetConfig.configInfo.defaultlocale; std::vector generatedLocales; - WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = m_context.widgetConfig.localizationData.icons; - - //reversed: last has highest priority to be writen to manifest if it has given locale (TODO: why was that working that way?) - for(WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator icon = icons.rbegin(); icon != icons.rend(); icon++) + WrtDB::WidgetRegisterInfo::LocalizedIconList & icons = + m_context.widgetConfig.localizationData.icons; + + //reversed: last has highest priority to be writen to manifest if it + // has given locale (TODO: why was that working that way?) + for (WrtDB::WidgetRegisterInfo::LocalizedIconList::const_reverse_iterator + icon = icons.rbegin(); + icon != icons.rend(); + ++icon) { FOREACH(locale, icon->availableLocales) { - if(std::find(generatedLocales.begin(), generatedLocales.end(), *locale) != generatedLocales.end()) + if (std::find(generatedLocales.begin(), generatedLocales.end(), + *locale) != generatedLocales.end()) { LogDebug("Skipping - has that locale - already in manifest"); continue; - } - else - { + } else { generatedLocales.push_back(*locale); } - DPL::OptionalString tag = getLangTag(*locale); // translate en -> en_US etc - if (tag.IsNull()) { tag = *locale; } + DPL::OptionalString tag = getLangTag(*locale); // translate en -> + // en_US etc + if (tag.IsNull()) { + tag = *locale; + } generateWidgetIcon(uiApp, tag, *locale, defaultIconSaved); } } - if (!!defaultLocale && !defaultIconSaved) - { + if (!!defaultLocale && !defaultIconSaved) { generateWidgetIcon(uiApp, DPL::OptionalString::Null, DPL::String(), defaultIconSaved); } } -void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, - const DPL::String& language, bool & defaultIconSaved) +void TaskManifestFile::generateWidgetIcon(UiApplication & uiApp, + const DPL::OptionalString& tag, + const DPL::String& language, + bool & defaultIconSaved) { DPL::String locale; - if (!!tag) - { + if (!!tag) { locale = LanguageTagsProvider::BCP47LanguageTagToLocale(*tag); - } - else - { + } else { defaultIconSaved = true; } DPL::String iconText; iconText += getIconTargetFilename(language); - if(!locale.empty()) - { + if (!locale.empty()) { uiApp.addIcon(IconType(iconText, locale)); - } - else - { + } else { uiApp.addIcon(IconType(iconText)); } + std::ostringstream iconPath; + iconPath << GlobalConfig::GetUserWidgetDesktopIconPath() << "/"; + iconPath << getIconTargetFilename(locale); + m_context.job->SendProgressIconPath(iconPath.str()); } void TaskManifestFile::setWidgetManifest(Manifest & manifest) { manifest.setPackage(m_context.widgetConfig.tzPkgid); - if(!!m_context.widgetConfig.version) - { + if (!!m_context.widgetConfig.version) { manifest.setVersion(*m_context.widgetConfig.version); } DPL::String email = (!!m_context.widgetConfig.configInfo.authorEmail ? - *m_context.widgetConfig.configInfo.authorEmail : L""); + *m_context.widgetConfig.configInfo.authorEmail : L""); DPL::String href = (!!m_context.widgetConfig.configInfo.authorHref ? - *m_context.widgetConfig.configInfo.authorHref : L""); + *m_context.widgetConfig.configInfo.authorHref : L""); DPL::String name = (!!m_context.widgetConfig.configInfo.authorName ? - *m_context.widgetConfig.configInfo.authorName : L""); - manifest.addAuthor(Author(email,href,L"",name)); + *m_context.widgetConfig.configInfo.authorName : L""); + manifest.addAuthor(Author(email, href, L"", name)); } void TaskManifestFile::setWidgetOtherInfo(UiApplication & uiApp) { FOREACH(it, m_context.widgetConfig.configInfo.settingsList) { - if(!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) { - if(!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) { + if (!strcmp(DPL::ToUTF8String(it->m_name).c_str(), ST_NODISPLAY)) { + if (!strcmp(DPL::ToUTF8String(it->m_value).c_str(), ST_TRUE)) { uiApp.setNodisplay(true); uiApp.setTaskmanage(false); - } - else { + } else { uiApp.setNodisplay(false); uiApp.setTaskmanage(true); } - } - } + } + } //TODO //There is no "X-TIZEN-PackageType=wgt" - //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << DPL::ToUTF8String(*widgetID).c_str() + //There is no X-TIZEN-PackageID in manifest "X-TIZEN-PackageID=" << + // DPL::ToUTF8String(*widgetID).c_str() //There is no Comment in pkgmgr "Comment=Widget application" //that were in desktop file } -void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp) +void TaskManifestFile::setAppServicesInfo(UiApplication & uiApp) { - WrtDB::ConfigParserData::ServiceInfoList appServiceList = m_context.widgetConfig.configInfo.appServiceList; + WrtDB::ConfigParserData::ServiceInfoList appServiceList = + m_context.widgetConfig.configInfo.appServiceList; if (appServiceList.empty()) { LogInfo("Widget doesn't contain application service"); @@ -752,21 +891,11 @@ void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp) // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image; FOREACH(it, appServiceList) { - AppControl appControl; - if (!it->m_operation.empty()) { - appControl.addOperation(it->m_operation); //TODO: encapsulation? - } - if (!it->m_scheme.empty()) { - appControl.addUri(it->m_scheme); - } - if (!it->m_mime.empty()) { - appControl.addMime(it->m_mime); - } - uiApp.addAppControl(appControl); - } -} + setAppServiceInfo(uiApp, *it); + } + } -void TaskManifestFile::setAppControlInfo(UiApplication & uiApp) +void TaskManifestFile::setAppControlsInfo(UiApplication & uiApp) { WrtDB::ConfigParserData::AppControlInfoList appControlList = m_context.widgetConfig.configInfo.appControlList; @@ -776,24 +905,47 @@ void TaskManifestFile::setAppControlInfo(UiApplication & uiApp) return; } - // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image; + // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image; FOREACH(it, appControlList) { - AppControl appControl; - if (!it->m_operation.empty()) { - appControl.addOperation(it->m_operation); //TODO: encapsulation? - } - if (!it->m_uriList.empty()) { - FOREACH(uri, it->m_uriList) { - appControl.addUri(*uri); - } + setAppControlInfo(uiApp, *it); + } +} + +void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp, + const ConfigParserData::ServiceInfo & service) +{ + AppControl appControl; + if (!service.m_operation.empty()) { + appControl.addOperation(service.m_operation); //TODO: encapsulation? + } + if (!service.m_scheme.empty()) { + appControl.addUri(service.m_scheme); + } + if (!service.m_mime.empty()) { + appControl.addMime(service.m_mime); + } + uiApp.addAppControl(appControl); +} + +void TaskManifestFile::setAppControlInfo(UiApplication & uiApp, + const WrtDB::ConfigParserData::AppControlInfo & service) +{ + // x-tizen-svc=http://tizen.org/appcontrol/operation/pick|NULL|image; + AppControl appControl; + if (!service.m_operation.empty()) { + appControl.addOperation(service.m_operation); //TODO: encapsulation? + } + if (!service.m_uriList.empty()) { + FOREACH(uri, service.m_uriList) { + appControl.addUri(*uri); } - if (!it->m_mimeList.empty()) { - FOREACH(mime, it->m_mimeList) { - appControl.addMime(*mime); - } + } + if (!service.m_mimeList.empty()) { + FOREACH(mime, service.m_mimeList) { + appControl.addMime(*mime); } - uiApp.addAppControl(appControl); } + uiApp.addAppControl(appControl); } void TaskManifestFile::setAppCategory(UiApplication &uiApp) @@ -819,14 +971,12 @@ void TaskManifestFile::stepAbortParseManifest() int code = pkgmgr_parser_parse_manifest_for_uninstallation( DPL::ToUTF8String(manifest_file).c_str(), NULL); - if (0 != code) - { + if (0 != code) { LogWarning("Manifest parser error: " << code); - ThrowMsg(ManifestParsingError, "Parser returncode: " << code); + ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code); } int ret = unlink(DPL::ToUTF8String(manifest_file).c_str()); - if (0 != ret) - { + if (0 != ret) { LogWarning("No manifest file found: " << manifest_file); } } @@ -837,82 +987,163 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest) LogInfo("setLiveBoxInfo"); LiveBoxInfo liveBox; DPL::Optional ConfigInfo = *it; - DPL::String pkgid = m_context.widgetConfig.tzPkgid; - size_t found; + DPL::String appid = m_context.widgetConfig.tzAppid; - if(ConfigInfo->m_liveboxId != L"") { - found = ConfigInfo->m_liveboxId.find_first_of(L"."); - if(found != std::string::npos) { - if(0 == ConfigInfo->m_liveboxId.compare(0, found, pkgid)) + if (ConfigInfo->m_liveboxId != L"") { + size_t found = ConfigInfo->m_liveboxId.find_last_of(L"."); + if (found != std::string::npos) { + if (0 == ConfigInfo->m_liveboxId.compare(0, found, appid)) { liveBox.setLiveboxId(ConfigInfo->m_liveboxId); - else { + } else { DPL::String liveboxId = - pkgid+DPL::String(L".")+ConfigInfo->m_liveboxId; + appid + DPL::String(L".") + ConfigInfo->m_liveboxId; liveBox.setLiveboxId(liveboxId); } } else { DPL::String liveboxId = - pkgid+DPL::String(L".")+ConfigInfo->m_liveboxId; + appid + DPL::String(L".") + ConfigInfo->m_liveboxId; liveBox.setLiveboxId(liveboxId); } } - if(ConfigInfo->m_primary != L"") + if (ConfigInfo->m_primary != L"") { liveBox.setPrimary(ConfigInfo->m_primary); + } - if(ConfigInfo->m_autoLaunch == L"true") - liveBox.setAutoLaunch(pkgid); - - if(ConfigInfo->m_updatePeriod != L"") + if (ConfigInfo->m_updatePeriod != L"") { liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod); + } - if(ConfigInfo->m_label != L"") + if (ConfigInfo->m_label != L"") { liveBox.setLabel(ConfigInfo->m_label); + } DPL::String defaultLocale - = DPL::FromUTF8String(m_context.locations->getPackageInstallationDir()) - + DPL::String(L"/res/wgt/"); + = DPL::FromUTF8String( + m_context.locations->getPackageInstallationDir()) + + DPL::String(L"/res/wgt/"); - if(ConfigInfo->m_icon!=L"") { - liveBox.setIcon(defaultLocale+ConfigInfo->m_icon); + if (ConfigInfo->m_icon != L"") { + liveBox.setIcon(defaultLocale + ConfigInfo->m_icon); } - if (ConfigInfo->m_boxInfo.m_boxSrc.empty() || ConfigInfo->m_boxInfo.m_boxSize.empty()) { + if (ConfigInfo->m_boxInfo.m_boxSrc.empty() || + ConfigInfo->m_boxInfo.m_boxSize.empty()) + { LogInfo("Widget doesn't contain box"); return; } else { BoxInfoType box; if (!ConfigInfo->m_boxInfo.m_boxSrc.empty()) { - if((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http")) - || (0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https"))) + if ((0 == ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 4, L"http")) + || (0 == + ConfigInfo->m_boxInfo.m_boxSrc.compare(0, 5, L"https"))) + { box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc; - else + } else { box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc; + } + } + + if (ConfigInfo->m_boxInfo.m_boxMouseEvent == L"true") { + box.boxMouseEvent = ConfigInfo->m_boxInfo.m_boxMouseEvent; + } else { + box.boxMouseEvent = L"false"; } - std::list> BoxSizeList + if (ConfigInfo->m_boxInfo.m_boxTouchEffect == L"true") { + box.boxTouchEffect = ConfigInfo->m_boxInfo.m_boxTouchEffect; + } else { + box.boxTouchEffect= L"false"; + } + + std::list > BoxSizeList = ConfigInfo->m_boxInfo.m_boxSize; FOREACH(im, BoxSizeList) { std::pair boxSize = *im; - if(!boxSize.second.empty()) + if (!boxSize.second.empty()) { boxSize.second = defaultLocale + boxSize.second; + } box.boxSize.push_back(boxSize); } if (!ConfigInfo->m_boxInfo.m_pdSrc.empty() - && !ConfigInfo->m_boxInfo.m_pdWidth.empty() - && !ConfigInfo->m_boxInfo.m_pdHeight.empty()) { - box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc; + && !ConfigInfo->m_boxInfo.m_pdWidth.empty() + && !ConfigInfo->m_boxInfo.m_pdHeight.empty()) + { + if ((0 == ConfigInfo->m_boxInfo.m_pdSrc.compare(0, 4, L"http")) + || (0 == ConfigInfo->m_boxInfo.m_pdSrc.compare(0, 5, L"https"))) + { + box.pdSrc = ConfigInfo->m_boxInfo.m_pdSrc; + } else { + box.pdSrc = defaultLocale + ConfigInfo->m_boxInfo.m_pdSrc; + } box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth; box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight; } - liveBox.setBox(box); } - manifest.addLivebox(liveBox); } +} + +void TaskManifestFile::setAccount(Manifest& manifest) +{ + WrtDB::ConfigParserData::AccountProvider account = + m_context.widgetConfig.configInfo.accountProvider; + + AccountProviderType provider; + + if (account.m_iconSet.empty()) { + LogInfo("Widget doesn't contain Account"); + return; + } + if (account.m_multiAccountSupport) { + provider.multiAccount = L"ture"; + } else { + provider.multiAccount = L"false"; + } + provider.appid = m_context.widgetConfig.tzAppid; + + FOREACH(it, account.m_iconSet) { + std::pair icon; + + if (it->first == ConfigParserData::IconSectionType::DefaultIcon) { + icon.first = L"account"; + } else if (it->first == ConfigParserData::IconSectionType::SmallIcon) { + icon.first = L"account-small"; + } + icon.second = it->second; + + provider.icon.push_back(icon); + } + + FOREACH(it, account.m_displayNameSet) { + provider.name.push_back(LabelType(it->second, it->first)); + } + + FOREACH(it, account.m_capabilityList) { + provider.capability.push_back(*it); + } + + Account accountInfo; + accountInfo.addAccountProvider(provider); + manifest.addAccount(accountInfo); +} + +void TaskManifestFile::setPrivilege(Manifest& manifest) +{ + WrtDB::ConfigParserData::PrivilegeList privileges = + m_context.widgetConfig.configInfo.privilegeList; + + PrivilegeType privilege; + + FOREACH(it, privileges) + { + privilege.addPrivilegeName(it->name); + } + manifest.addPrivileges(privilege); } } //namespace WidgetInstall