From e29e1b86b977f24b3ef60802c78bd60ac75a5621 Mon Sep 17 00:00:00 2001 From: leerang song Date: Mon, 27 May 2013 19:29:21 +0900 Subject: [PATCH] Write the variable language boxlabel in manifest file. [Issue#] N/A [Bug] N/A [Cause] N/A [Solution] Add function for parsing language label in widget_parser. [Verification] This commit should be release with wrt-commons. Change-Id: I789f4d2518d900cd3dd1e6e2b90f227ad9cbb68f --- configuration/widgets.tizen.xsd | 1 + src/configuration_parser/widget_parser.cpp | 15 +++++++++++---- src/jobs/widget_install/manifest.cpp | 22 ++++++++++++++++++---- src/jobs/widget_install/manifest.h | 6 ++++-- src/jobs/widget_install/task_manifest_file.cpp | 17 +++++++++++++++-- 5 files changed, 49 insertions(+), 12 deletions(-) mode change 100644 => 100755 configuration/widgets.tizen.xsd mode change 100644 => 100755 src/configuration_parser/widget_parser.cpp mode change 100644 => 100755 src/jobs/widget_install/manifest.cpp mode change 100644 => 100755 src/jobs/widget_install/manifest.h mode change 100644 => 100755 src/jobs/widget_install/task_manifest_file.cpp diff --git a/configuration/widgets.tizen.xsd b/configuration/widgets.tizen.xsd old mode 100644 new mode 100755 index 3d0c175..b3ba2ca --- a/configuration/widgets.tizen.xsd +++ b/configuration/widgets.tizen.xsd @@ -147,6 +147,7 @@ + diff --git a/src/configuration_parser/widget_parser.cpp b/src/configuration_parser/widget_parser.cpp old mode 100644 new mode 100755 index 3bc0167..5a56c0f --- a/src/configuration_parser/widget_parser.cpp +++ b/src/configuration_parser/widget_parser.cpp @@ -1592,9 +1592,12 @@ class AppWidgetParser : public ElementParser return &IgnoringParser::Create; //ignore unknown according to w3c } - virtual void Accept(const XmlAttribute& /*attribute*/) - {} - + virtual void Accept(const XmlAttribute& attribute) + { + if (m_properNamespace) { + m_lang = attribute.lang; + } + } virtual void Accept(const Element& element) { if (element.ns == @@ -1617,7 +1620,10 @@ class AppWidgetParser : public ElementParser ThrowMsg(Exception::ParseError, "box-label element cannot be empty - ignoring"); } - m_data.m_label = m_label; + std::pair boxLabel; + boxLabel.first = m_lang; + boxLabel.second = m_label; + m_data.m_label.push_back(boxLabel); } BoxLabelParser(ConfigParserData::LiveboxInfo& data) : @@ -1627,6 +1633,7 @@ class AppWidgetParser : public ElementParser {} private: + DPL::String m_lang; DPL::String m_label; bool m_properNamespace; ConfigParserData::LiveboxInfo& m_data; diff --git a/src/jobs/widget_install/manifest.cpp b/src/jobs/widget_install/manifest.cpp old mode 100644 new mode 100755 index 15f381e..9688ee2 --- a/src/jobs/widget_install/manifest.cpp +++ b/src/jobs/widget_install/manifest.cpp @@ -367,11 +367,25 @@ void LiveBox::serialize(xmlTextWriterPtr writer) writeAttribute(writer, "nodisplay", "false"); if (!this->label.empty()) { - startElement(writer, "label"); - writeText(writer, this->label); - endElement(writer); + int defaultLabelChk = 0; + FOREACH(m, this->label) + { + std::pair boxLabel = *m; + startElement(writer, "label"); + if (!boxLabel.first.empty()) { + writeAttribute(writer, "xml:lang", boxLabel.first); + } else { + defaultLabelChk++; + } + writeText(writer, boxLabel.second); + endElement(writer); + } + if(!defaultLabelChk) { + startElement(writer, "label"); + writeText(writer, DPL::FromUTF8String("NO NAME")); + endElement(writer); + } } - if (!this->icon.empty()) { startElement(writer, "icon"); writeText(writer, this->icon); diff --git a/src/jobs/widget_install/manifest.h b/src/jobs/widget_install/manifest.h old mode 100644 new mode 100755 index cb7e6d6..30a849d --- a/src/jobs/widget_install/manifest.h +++ b/src/jobs/widget_install/manifest.h @@ -406,6 +406,7 @@ typedef UiApplication UiApplicationType; * @brief LiveBox element */ typedef std::list > boxSizeType; +typedef std::list > boxLabelType; struct BoxInfo { @@ -435,7 +436,7 @@ class LiveBox { this->updatePeriod = x; } - void setLabel(const NcnameType &x) + void setLabel(const boxLabelType &x) { this->label = x; } @@ -456,8 +457,9 @@ class LiveBox NcnameType autoLaunch; NcnameType updatePeriod; NcnameType timeout; - NcnameType label; + boxLabelType label; NcnameType icon; + NcnameType lang; BoxInfoType box; }; diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp old mode 100644 new mode 100755 index a5bd917..d9cfeaa --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -1075,8 +1075,21 @@ void TaskManifestFile::setLiveBoxInfo(Manifest& manifest) liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod); } - if (ConfigInfo->m_label != L"") { - liveBox.setLabel(ConfigInfo->m_label); + std::list > boxLabelList; + if (!ConfigInfo->m_label.empty()) { + FOREACH(im, ConfigInfo->m_label) { + std::pair boxSize; + Locale i = (*im).first; + // translate en -> en_US etc + DPL::OptionalString tag = getLangTag(i); + if (tag.IsNull()) { + tag = i; + } + boxSize.first = (*tag); + boxSize.second = (*im).second; + boxLabelList.push_back(boxSize); + } + liveBox.setLabel(boxLabelList); } DPL::String defaultLocale = -- 2.7.4