Metadata value is changed to optional
authorDongeup Ham <dongeup.ham@samsung.com>
Tue, 21 May 2013 05:35:09 +0000 (14:35 +0900)
committerDongeup Ham <dongeup.ham@samsung.com>
Tue, 21 May 2013 05:35:09 +0000 (14:35 +0900)
Change-Id: I776a3cd6356bd3ca879059017a0226c9ede3aada
Signed-off-by: Dongeup Ham <dongeup.ham@samsung.com>
inc/InstallerDefs.h
src/XmlHandler/ManifestGenerator.cpp
src/XmlHandler/ManifestHandler.cpp
src/XmlHandler/ManifestHandler.h

index e198be3..2705b49 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130520.1]"
+#define OSP_INSTALLER_VERSION "version=[20130521.1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
index f9b814a..e947aa3 100755 (executable)
@@ -1050,11 +1050,15 @@ ManifestGenerator::WriteMetadata(HashMap* pMetadataMap)
                TryReturn(pEnum, false, "GetKey() failed. [%s]", GetErrorMessage(GetLastResult()));
 
                String* pValue = static_cast< String* > (pEnum->GetValue());
-               TryReturn(pEnum, false, "GetValue() failed. [%s]", GetErrorMessage(GetLastResult()));
 
                __pWriter->StartElement("metadata");
                __pWriter->WriteAttribute("key", *pKey);
-               __pWriter->WriteAttribute("value", *pValue);
+
+               if (pValue && (pValue->IsEmpty() == false))
+               {
+                       __pWriter->WriteAttribute("value", *pValue);
+               }
+
                __pWriter->EndElement();
        }
 
index 7a0fbd0..f4a5af4 100755 (executable)
@@ -148,6 +148,10 @@ ManifestHandler::OnStartElement(const char *pName)
        {
                status = OnContentStartElement();
        }
+       else if (strcasecmp(pName, "Metadata") == 0)
+       {
+               status = OnMetadataStartElement();
+       }
        else if ((strcasecmp(pName, "Liveboxes") == 0) || strcasecmp(pName, "AppWidgets") == 0)
        {
                status = OnLiveboxesStartElement(pName);
@@ -242,6 +246,10 @@ ManifestHandler::OnEndElement(const char *pName)
        {
                status = OnContentEndElement();
        }
+       else if (strcasecmp(pName, "Metadata") == 0)
+       {
+               status = OnMetadataEndElement();
+       }
        else if (strcasecmp(pName, "Manifest") == 0)
        {
                status = OnManifestEndElement();
@@ -597,6 +605,24 @@ ManifestHandler::OnContentStartElement(void)
 }
 
 bool
+ManifestHandler::OnMetadataStartElement()
+{
+       AppLog("<Metadata>");
+       __metadataKey.Clear();
+
+       XmlAttribute* pAttr = GetAttribute();
+       TryReturn(pAttr, true, "pAttr is null");
+
+       char* pKey = pAttr->Find("Key");
+       if (pKey)
+       {
+               __metadataKey = pKey;
+       }
+
+       return true;
+}
+
+bool
 ManifestHandler::OnLiveboxesStartElement(const char *pName)
 {
        __pParser = new (std::nothrow) ManifestLiveboxesParser;
@@ -802,6 +828,20 @@ ManifestHandler::OnContentEndElement(void)
 }
 
 bool
+ManifestHandler::OnMetadataEndElement(void)
+{
+       AppLog("</Metadata>");
+
+       if (__metadataKey.IsEmpty() == false)
+       {
+               __pAppData->__pMetadataMap->Add(*(new (std::nothrow) String(__metadataKey)), *(new (std::nothrow) String(L"")));
+               __metadataKey.Clear();
+       }
+
+       return true;
+}
+
+bool
 ManifestHandler::OnLiveboxesEndElement(void)
 {
        delete __pParser;
@@ -1249,6 +1289,7 @@ ManifestHandler::OnMetadataValue(const char* pCharacters)
        TryReturn(pKey, true, "pKey is null.");
 
        __pAppData->__pMetadataMap->Add(*(new (std::nothrow) String(pKey)), *(new (std::nothrow) String(pCharacters)));
+       __metadataKey.Clear();
 
        AppLog("<Metadata Key=\"%s\">%s</Metadata>", pKey, pCharacters);
 
index 84008d9..b41cfa6 100755 (executable)
@@ -77,6 +77,8 @@ private:
        bool OnContentsStartElement(void);
        bool OnContentStartElement(void);
 
+       bool OnMetadataStartElement(void);
+
        // Parsers
        bool OnLiveboxesStartElement(const char* pName);
        bool OnAccountsStartElement(const char* pName);
@@ -97,6 +99,7 @@ private:
 
        bool OnContentsEndElement(void);
        bool OnContentEndElement(void);
+       bool OnMetadataEndElement(void);
 
        // Parsers
        bool OnLiveboxesEndElement(void);
@@ -163,6 +166,8 @@ private:
        bool __isParserMode;
        ManifestParser* __pParser;
 
+       Tizen::Base::String __metadataKey;
+
        friend class ManifestAppControlsParser;
 
 }; // ManifestHandler