From: lke01.lee Date: Fri, 7 Dec 2012 07:22:57 +0000 (+0900) Subject: For livebox configuration X-Git-Tag: accepted/tizen_2.1/20130425.023916~20^2~24^2~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e997f2559189cf1e41a690aa1aa6690079822f45;p=framework%2Fweb%2Fwrt-installer.git For livebox configuration [Issue#] [Problem] [Cause] The configuration informations has been changed from pkgname.config to config.xml [Solution] Add parsing routine for livebox configuration [Verification] This commit depends on http://slp-info.sec.samsung.net/gerrit/#/c/125839/, http://slp-info.sec.samsung.net/gerrit/#/c/128073/ Change-Id: I0d188fea4df254d9a5418649d94cfa19860e461b --- diff --git a/configuration/config.tizen.xsd b/configuration/config.tizen.xsd index 490795e..46adddc 100755 --- a/configuration/config.tizen.xsd +++ b/configuration/config.tizen.xsd @@ -38,6 +38,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -114,4 +143,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/configuration_parser/widget_parser.cpp b/src/configuration_parser/widget_parser.cpp old mode 100644 new mode 100755 index 20ec69e..5ec1f8f --- a/src/configuration_parser/widget_parser.cpp +++ b/src/configuration_parser/widget_parser.cpp @@ -1466,6 +1466,374 @@ class CategoryParser : public ElementParser ConfigParserData& m_data; }; +class LiveboxParser : public ElementParser +{ + public: + + struct LabelParser : public ElementParser + { + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const XmlAttribute& attribute) + { + } + + virtual void Accept(const Element& element) + { + if (element.ns == + ConfigurationNamespace::TizenWebAppNamespaceName) + { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& text) + { + if(m_properNamespace) + m_label = text.value; + } + + virtual void Verify() + { + m_data.m_label = m_label; + } + + LabelParser(ConfigParserData::LiveboxInfo& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + { + } + + private: + DPL::String m_label; + ConfigParserData::LiveboxInfo& m_data; + bool m_properNamespace; + }; + + struct IconParser : public ElementParser + { + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const XmlAttribute& attribute) + { + if(m_properNamespace) { + if (attribute.name == L"src") { + m_icon = attribute.value; + } + } + } + + virtual void Accept(const Element& element) + { + if (element.ns == + ConfigurationNamespace::TizenWebAppNamespaceName) + { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& /*text*/) + { + } + + virtual void Verify() + { + m_data.m_icon = m_icon; + } + + explicit IconParser(ConfigParserData::LiveboxInfo& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + { + } + + private: + DPL::String m_icon; + ConfigParserData::LiveboxInfo& m_data; + bool m_properNamespace; + }; + + struct BoxParser : public ElementParser + { + struct PdParser : public ElementParser + { + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& name) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const XmlAttribute& attribute) + { + if(m_properNamespace) { + if (attribute.name == L"src") { + m_src = attribute.value; + } else if (attribute.name == L"width") { + m_width = attribute.value; + } else if (attribute.name == L"height") { + m_height = attribute.value; + } + } + } + + virtual void Accept(const Element& element) + { + if (element.ns == + ConfigurationNamespace::TizenWebAppNamespaceName) + { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& /*text*/) + { + } + + virtual void Verify() + { + m_data.m_pdSrc = m_src; + m_data.m_pdWidth = m_width; + m_data.m_pdHeight = m_height; + } + + explicit PdParser(ConfigParserData::LiveboxInfo::Box& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + { + } + + private: + DPL::String m_src; + DPL::String m_width; + DPL::String m_height; + + bool m_properNamespace; + ConfigParserData::LiveboxInfo::Box& m_data; + }; + + struct SizeParser : public ElementParser + { + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& /*name*/) + { + return &IgnoringParser::Create; + } + + virtual void Accept(const XmlAttribute& attribute) + { + if(m_properNamespace) { + if (attribute.name == L"preview") { + m_preview = attribute.value; + } + } + } + + virtual void Accept(const Element& element) + { + if (element.ns == + ConfigurationNamespace::TizenWebAppNamespaceName) + { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& text) + { + if(m_properNamespace) + m_size = text.value; + } + + virtual void Verify() + { + std::pair boxSize; + boxSize.first = m_size; + boxSize.second = m_preview; + m_data.m_boxSize.push_back(boxSize); + } + + explicit SizeParser(ConfigParserData::LiveboxInfo::Box& data) : + ElementParser(), + m_data(data) + { + } + + private: + DPL::String m_size; + DPL::String m_preview; + bool m_properNamespace; + ConfigParserData::LiveboxInfo::Box& m_data; + }; + + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& name) + { + if (name == L"boxsize") { + return DPL::MakeDelegate(this, &LiveboxParser::BoxParser::OnSizeElement); + } else if (name == L"pd") { + return DPL::MakeDelegate(this, &LiveboxParser::BoxParser::OnPdElement); + } + } + + virtual void Accept(const XmlAttribute& attribute) + { + if (m_properNamespace) { + if (attribute.name == L"src") + m_box.m_boxSrc = attribute.value; + } + } + + virtual void Accept(const Element& element) + { + if (element.ns == + ConfigurationNamespace::TizenWebAppNamespaceName) + { + m_properNamespace = true; + } + } + + virtual void Accept(const Text& /*text*/) + { + } + + virtual void Verify() + { + m_data.m_boxInfo = m_box; + } + + explicit BoxParser(ConfigParserData::LiveboxInfo& data) : + ElementParser(), + m_properNamespace(false), + m_data(data) + { + } + + ElementParserPtr OnPdElement() + { + return ElementParserPtr(new PdParser(m_box)); + } + + ElementParserPtr OnSizeElement() + { + return ElementParserPtr(new SizeParser(m_box)); + } + + private: + DPL::String m_src; + ConfigParserData::LiveboxInfo& m_data; + bool m_properNamespace; + ConfigParserData::LiveboxInfo::Box m_box; + + }; + + virtual ActionFunc GetElementParser(const DPL::String& /*ns*/, + const DPL::String& name) + { + if (name == L"label") { + return DPL::MakeDelegate(this, &LiveboxParser::OnLabelElement); + } else if (name == L"icon") { + return DPL::MakeDelegate(this, &LiveboxParser::OnIconElement); + } else if (name == L"box") { + return DPL::MakeDelegate(this, &LiveboxParser::OnBoxElement); + } else { + return &IgnoringParser::Create; + } + } + + virtual void Accept(const XmlAttribute& attribute) + { + if (m_properNamespace) { + if (attribute.name == L"appid") { + m_appId = attribute.value; + } else if (attribute.name == L"auto_launch") { + m_autoLaunch = attribute.value; + } else if (attribute.name == L"period") { + m_period = attribute.value; + } else if (attribute.name == L"network") { + m_network = attribute.value; + LogDebug("@@@ "<uiApplication) { u->serialize(writer); } FOREACH(i, this->imeApplication) { i->serialize(writer); } //FOREACH(f, this->font) { f->serialize(writer); } + FOREACH(l, this->livebox) { l->serialize(writer); } } endElement(writer); } @@ -301,5 +302,84 @@ void AppControl::serialize(xmlTextWriterPtr writer) } endElement(writer); } + +void LiveBox::serialize(xmlTextWriterPtr writer) +{ + startElement(writer, "livebox"); + if(!this->appid.empty()) { + writeAttribute(writer, "appid", this->appid); + } + if(!this->auto_launch.empty()) { + writeAttribute(writer, "auto_launch", this->auto_launch); + } + if(!this->network.empty()) { + writeAttribute(writer, "network", this->network); + } + writeAttribute(writer, "abi", "html"); + if(!this->period.empty()) { + writeAttribute(writer, "period", this->period); + } + if(!this->nodisplay.empty()) { + writeAttribute(writer, "nodisplay", this->nodisplay); + } + if(!this->primary.empty()) { + writeAttribute(writer, "primary", this->primary); + } + if(!this->timeout.empty()) { + writeAttribute(writer, "timeout", this->timeout); + } + if(!this->label.empty()) { + startElement(writer, "label"); + writeText(writer, this->label); + endElement(writer); + } + + if(!this->icon.empty()) { + startElement(writer, "icon"); + writeText(writer, this->icon); + endElement(writer); + } + + if(!this->box.boxSrc.empty() && !this->box.boxSize.empty()) + { + startElement(writer, "box"); + writeAttribute(writer, "type", "buffer"); + + FOREACH(m, this->box.boxSize) + { + std::pair boxSize = *m; + startElement(writer, "size"); + if(!boxSize.second.empty()) + writeAttribute(writer, "preview", boxSize.second); + writeText(writer, boxSize.first); + endElement(writer); + } + + startElement(writer, "script"); + writeAttribute(writer, "src", this->box.boxSrc); + endElement(writer); + + endElement(writer); + + if(!this->box.pdSrc.empty() && ! this->box.pdWidth.empty() && ! this->box.pdHeight.empty()) { + startElement(writer, "pd"); + writeAttribute(writer, "type", "buffer"); + + startElement(writer, "size"); + DPL::String pdSize = this->box.pdWidth+DPL::String(L"x")+this->box.pdHeight; + writeText(writer, pdSize); + endElement(writer); + + startElement(writer, "script"); + writeAttribute(writer, "src", this->box.pdSrc); + endElement(writer); + + endElement(writer); + } + } + + endElement(writer); +} + } //namespace Jobs } //namespace WidgetInstall diff --git a/src/jobs/widget_install/manifest.h b/src/jobs/widget_install/manifest.h old mode 100644 new mode 100755 index ecbedee..0418a84 --- a/src/jobs/widget_install/manifest.h +++ b/src/jobs/widget_install/manifest.h @@ -223,6 +223,54 @@ private: typedef UiApplication UiApplicationType; /** + * @brief LiveBox element + */ +typedef std::list> boxSizeType; + + +struct BoxInfo +{ + NcnameType boxSrc; + boxSizeType boxSize; + NcnameType pdSrc; + NcnameType pdWidth; + NcnameType pdHeight; +}; +typedef BoxInfo BoxInfoType; + +class LiveBox +{ +public: + LiveBox() { } + void setAppid(const NcnameType &x) { this->appid = x; } + void setAutoLaunch(const NcnameType &x) { this->auto_launch = x; } + void setPeriod(const NcnameType &x) { this->period = x; } + void setNetwork(const NcnameType &x) { this->network = x; } + void setNodisplay(const NcnameType &x) { this->nodisplay = x; } + void setPrimary(const NcnameType &x) { this->primary = x; } + void setTimeout(const NcnameType &x) { this->timeout = x; } + void setLabel(const NcnameType &x) { this->label = x; } + void setIcon(const NcnameType &x) { this->icon = x; } + void setBox(const BoxInfoType &x) { this->box = x; } + + void serialize(xmlTextWriterPtr writer); + +private: + NcnameType appid; + NcnameType auto_launch; + NcnameType period; + NcnameType network; + NcnameType nodisplay; + NcnameType primary; + NcnameType timeout; + NcnameType label; + NcnameType icon; + BoxInfoType box; +}; + +typedef LiveBox LiveBoxInfo; + +/** * @brief manifest element * * Manifest xml file representation. @@ -263,6 +311,11 @@ public: } // void addFont(const FontType &x) { this->font.push_back(x); } + void addLivebox(const LiveBoxInfo &x) + { + this->livebox.push_back(x); + } + void setInstallLocation(const InstallLocationType &x) { this->installLocation = x; @@ -281,6 +334,7 @@ private: std::list uiApplication; std::list imeApplication; // std::list font; + std::list livebox; InstallLocationType installLocation; NcnameType package; PackageType type; diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp index 21743d2..8e2965f 100755 --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -551,6 +551,7 @@ void TaskManifestFile::writeManifest(const DPL::String & path) setWidgetOtherInfo(uiApp); setAppServiceInfo(uiApp); setAppCategory(uiApp); + setLiveBoxInfo(manifest); manifest.addUiApplication(uiApp); manifest.generate(path); @@ -809,6 +810,91 @@ void TaskManifestFile::stepAbortParseManifest() { LogWarning("No manifest file found: " << manifest_file); } +} + +void TaskManifestFile::setLiveBoxInfo(Manifest& manifest) +{ + + FOREACH(it, m_context.widgetConfig.configInfo.m_livebox) { + + LogInfo("setLiveBoxInfo"); + LiveBoxInfo liveBox; + DPL::String pkgname; + DPL::Optional ConfigInfo = *it; + + if(!!m_context.widgetConfig.pkgname) + { + pkgname = + *m_context.widgetConfig.pkgname+DPL::String(L".") + +ConfigInfo->m_appId; + liveBox.setAppid(pkgname); + } + + if(ConfigInfo->m_autoLaunch !=L"") { + liveBox.setAutoLaunch(ConfigInfo->m_autoLaunch); + } + + if(ConfigInfo->m_period !=L"") + liveBox.setPeriod(ConfigInfo->m_period); + + if(ConfigInfo->m_network !=L"") + liveBox.setNetwork(ConfigInfo->m_network); + + if(ConfigInfo->m_nodisplay !=L"") + liveBox.setNodisplay(ConfigInfo->m_nodisplay); + + if(ConfigInfo->m_primary !=L"") + liveBox.setPrimary(ConfigInfo->m_primary); + + if(ConfigInfo->m_timeout !=L"") + liveBox.setTimeout(ConfigInfo->m_timeout); + + if(ConfigInfo->m_label !=L"") + liveBox.setLabel(ConfigInfo->m_label); + + DPL::String defaultLocale + = 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_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((std::string::npos != ConfigInfo->m_boxInfo.m_boxSrc.find(L"http")) + || (std::string::npos != ConfigInfo->m_boxInfo.m_boxSrc.find(L"https"))) + box.boxSrc = ConfigInfo->m_boxInfo.m_boxSrc; + else + box.boxSrc = defaultLocale + ConfigInfo->m_boxInfo.m_boxSrc; + } + + std::list> BoxSizeList + = ConfigInfo->m_boxInfo.m_boxSize; + FOREACH(im, BoxSizeList) { + std::pair boxSize = *im; + 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; + box.pdWidth = ConfigInfo->m_boxInfo.m_pdWidth; + box.pdHeight = ConfigInfo->m_boxInfo.m_pdHeight; + } + + liveBox.setBox(box); + } + + manifest.addLivebox(liveBox); + } } diff --git a/src/jobs/widget_install/task_manifest_file.h b/src/jobs/widget_install/task_manifest_file.h old mode 100644 new mode 100755 index 0755d6d..191bc49 --- a/src/jobs/widget_install/task_manifest_file.h +++ b/src/jobs/widget_install/task_manifest_file.h @@ -96,6 +96,7 @@ class TaskManifestFile : void setWidgetOtherInfo(UiApplication & uiApp); void setAppServiceInfo(UiApplication & uiApp); void setAppCategory(UiApplication & uiApp); + void setLiveBoxInfo(Manifest& manifest); void generateWidgetName(Manifest & manifest, UiApplication &uiApp, const DPL::OptionalString& tag, DPL::OptionalString name, bool & defaultNameSaved); void generateWidgetIcon(UiApplication & uiApp, const DPL::OptionalString& tag, const DPL::String& language, bool & defaultIconSaved);