m_type = value;
MimeTypeUtils::MimeAttributes mimeAttributes =
MimeTypeUtils::getMimeAttributes(value);
- if (mimeAttributes.count(L"charset") > 0) {
+ if ((mimeAttributes.count(L"charset") > 0) && m_encoding.IsNull())
+ {
m_encoding = mimeAttributes[L"charset"];
}
} else if (attribute.name == L"encoding") {
ConfigParserData::AppControlInfo& m_data;
};
+ struct DispositionParser : public ElementParser
+ {
+ public:
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& /*name*/)
+ {
+ return &IgnoringParser::Create;
+ }
+
+ virtual void Accept(const Text& /*text*/)
+ {}
+
+ virtual void Accept(const Element& /*element*/)
+ {}
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (attribute.name == L"disposition") {
+ if (attribute.value.size() > 0) {
+ m_value = attribute.value;
+ NormalizeString(m_value);
+ }
+ }
+ }
+
+ virtual void Verify()
+ {
+ if (m_value.IsNull() || *m_value != L"inline") {
+ m_data.m_disposition = ConfigParserData::AppControlInfo::Disposition::WINDOW;
+ }
+ else {
+ m_data.m_disposition = ConfigParserData::AppControlInfo::Disposition::INLINE;
+ }
+ }
+
+ DispositionParser(ConfigParserData::AppControlInfo& data) :
+ ElementParser(),
+ m_properNamespace(false),
+ m_data(data)
+ {}
+
+ private:
+ bool m_properNamespace;
+ DPL::OptionalString m_value;
+ ConfigParserData::AppControlInfo& m_data;
+ };
+
virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
const DPL::String& name)
{
return DPL::MakeDelegate(this, &AppControlParser::OnUriElement);
} else if (name == L"mime") {
return DPL::MakeDelegate(this, &AppControlParser::OnMimeElement);
+ } else if (name == L"disposition") {
+ return DPL::MakeDelegate(this,
+ &AppControlParser::OnDispositionElement);
} else {
return &IgnoringParser::Create;
}
return ElementParserPtr(new MimeParser(m_appControl));
}
+ ElementParserPtr OnDispositionElement()
+ {
+ return ElementParserPtr(new DispositionParser(m_appControl));
+ }
+
AppControlParser(ConfigParserData& data) :
ElementParser(),
m_data(data),
std::string exec = m_context.locations->getExecFile();
std::string clientExeStr = GlobalConfig::GetWrtClientExec();
+ //default widget
LogInfo("link -s " << clientExeStr << " " << exec);
-
errno = 0;
- if (symlink(clientExeStr.c_str(), exec.c_str()) != 0)
+ if (symlink(clientExeStr.c_str(), exec.c_str()) != 0)
{
int error = errno;
- if(error)
+ 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");
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);
+#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
+ uiApp.setTaskmanage(ConfigParserData::AppControlInfo::Disposition::INLINE != it->m_disposition);
+ uiApp.setMultiple(ConfigParserData::AppControlInfo::Disposition::INLINE == it->m_disposition);
+#endif
+ 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);
+#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
+ uiApp.setTaskmanage(ConfigParserData::ServiceInfo::Disposition::INLINE != it->m_disposition);
+ uiApp.setMultiple(ConfigParserData::ServiceInfo::Disposition::INLINE == it->m_disposition);
+#endif
+
+ 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;
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
//that were in desktop file
}
-void TaskManifestFile::setAppServiceInfo(UiApplication & uiApp)
+void TaskManifestFile::setAppServicesInfo(UiApplication & uiApp)
{
WrtDB::ConfigParserData::ServiceInfoList appServiceList =
m_context.widgetConfig.configInfo.appServiceList;
// 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;
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)
WrtDB::ConfigParserData& configInfo,
const std::string& _currentPath)
{
- ParserRunner parser;
-
- //TODO: rewrite this madness
- std::string cfgAbsPath;
- DIR* dir = NULL;
-
- dir = opendir(_currentPath.c_str());
- if (dir == NULL) {
+ std::string configFilePath;
+ WrtUtilJoinPaths(configFilePath, _currentPath, WRT_WIDGET_CONFIG_FILE_NAME);
+ if (!WrtUtilFileExists(configFilePath))
+ {
+ LogError("Archive does not contain configuration file");
return false;
}
- bool has_config_xml = false;
- struct dirent ptr;
- struct dirent *result;
- int return_code;
- errno = 0;
- //Find configuration file, based on its name
- for (return_code = readdir_r(dir, &ptr, &result);
- result != NULL && return_code == 0;
- return_code = readdir_r(dir, &ptr, &result))
- {
- if (ptr.d_type == DT_REG) {
- if (!strcmp(ptr.d_name, WRT_WIDGET_CONFIG_FILE_NAME)) {
- std::string dName(ptr.d_name);
- WrtUtilJoinPaths(cfgAbsPath, _currentPath, dName);
-
- //Parse widget configuration file
- LogDebug("Found config: " << cfgAbsPath);
-
- Try
- {
- parser.Parse(cfgAbsPath, ElementParserPtr(new
- RootParser<
- WidgetParser>(
- configInfo,
- DPL
- ::
- FromUTF32String(
- L"widget"))));
- }
- Catch(ElementParser::Exception::Base)
- {
- LogError("Invalid widget configuration file!");
- if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
- LogError(
- "Failed to close dir: " << _currentPath <<
- " with error: "
- << DPL::GetErrnoString());
- }
- return false;
- }
+ LogDebug("Configuration file: " << configFilePath);
- has_config_xml = true;
- break;
- }
- }
- }
- if (errno != 0) {
- LogError("readdir_r() failed with " << DPL::GetErrnoString());
- }
- errno = 0;
- if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
- LogError("Failed to close dir: " << _currentPath << " with error: "
- << DPL::GetErrnoString());
+ Try
+ {
+ ParserRunner parser;
+ parser.Parse(configFilePath,
+ ElementParserPtr(new RootParser<WidgetParser>(
+ configInfo,
+ DPL::FromUTF32String(L"widget"))));
+ return true;
}
-
- //We must have config.xml so leaveing if we doesn't
- if (!has_config_xml) {
- LogError("Invalid archive");
+ Catch (ElementParser::Exception::Base)
+ {
+ LogError("Invalid configuration file!");
return false;
}
- return true;
}
bool TaskWidgetConfig::locateAndParseConfigurationFile(