Write the variable language boxlabel in manifest file.
authorleerang song <leerang.song@samsung.com>
Mon, 27 May 2013 10:29:21 +0000 (19:29 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 31 May 2013 08:00:54 +0000 (17:00 +0900)
[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 [changed mode: 0644->0755]
src/configuration_parser/widget_parser.cpp [changed mode: 0644->0755]
src/jobs/widget_install/manifest.cpp [changed mode: 0644->0755]
src/jobs/widget_install/manifest.h [changed mode: 0644->0755]
src/jobs/widget_install/task_manifest_file.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 3d0c175..b3ba2ca
 
     <xs:element name="box-label">
         <xs:complexType mixed="true">
+            <xs:attribute ref="xml:lang" minOccurs="1"/>
         </xs:complexType>
     </xs:element>
 
old mode 100644 (file)
new mode 100755 (executable)
index 3bc0167..5a56c0f
@@ -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<DPL::String, DPL::String> 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;
old mode 100644 (file)
new mode 100755 (executable)
index 15f381e..9688ee2
@@ -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<DPL::String, DPL::String> 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);
old mode 100644 (file)
new mode 100755 (executable)
index cb7e6d6..30a849d
@@ -406,6 +406,7 @@ typedef UiApplication UiApplicationType;
  * @brief LiveBox element
  */
 typedef std::list<std::pair<DPL::String, DPL::String> > boxSizeType;
+typedef std::list<std::pair<DPL::String, DPL::String> > 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;
 };
 
old mode 100644 (file)
new mode 100755 (executable)
index a5bd917..d9cfeaa
@@ -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<std::pair<DPL::String, DPL::String> > boxLabelList;
+        if (!ConfigInfo->m_label.empty()) {
+            FOREACH(im, ConfigInfo->m_label) {
+                std::pair<DPL::String, DPL::String> 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 =