Add to parse metadata
authorDuyoung Jang <duyoung.jang@samsung.com>
Mon, 18 Mar 2013 10:11:07 +0000 (19:11 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Mon, 18 Mar 2013 10:11:07 +0000 (19:11 +0900)
Change-Id: I843f69f5b26785c3c501ba469bf3db33cc6d51b7
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
inc/InstallerDefs.h
src/Context/InstallationContextData.cpp
src/Context/InstallationContextData.h
src/Manager/SmackManager.cpp
src/XmlHandler/ManifestGenerator.cpp
src/XmlHandler/ManifestGenerator.h
src/XmlHandler/ManifestHandler.cpp
src/XmlHandler/ManifestHandler.h
src/XmlHandler/Parser/ManifestLiveboxesParser.cpp

index 3f79eb0..f9218a2 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130314.1]"
+#define OSP_INSTALLER_VERSION "version=[20130318.1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
index 603fb85..b93f160 100755 (executable)
@@ -438,6 +438,7 @@ AppData::AppData()
 ,__pFeatureList(null)
 ,__pLaunchConditionList(null)
 ,__pNotificationMap(null)
+,__pMetadataMap(null)
 ,__feature(0)
 ,__isSubMode(false)
 ,__legacyAppControls(false)
@@ -507,6 +508,12 @@ AppData::~AppData()
                __pNotificationMap->RemoveAll();
                delete __pNotificationMap;
        }
+
+       if (__pMetadataMap)
+       {
+               __pMetadataMap->RemoveAll();
+               delete __pMetadataMap;
+       }
 }
 
 InstallerError
@@ -552,5 +559,10 @@ AppData::Construct(void)
        r = __pNotificationMap->Construct();
        TryReturn(!IsFailed(r), INSTALLER_ERROR_OUT_OF_MEMORY, "__pNotificationMap->Construct() failed.");
 
+       __pMetadataMap = new (std::nothrow) HashMap(SingleObjectDeleter);
+       TryReturn(__pMetadataMap, INSTALLER_ERROR_OUT_OF_MEMORY, "__pMetadataMap is null.");
+       r = __pMetadataMap->Construct();
+       TryReturn(!IsFailed(r), INSTALLER_ERROR_OUT_OF_MEMORY, "__pMetadataMap->Construct() failed.");
+
        return INSTALLER_ERROR_NONE;
 }
index 5e5dbf9..58508a4 100755 (executable)
@@ -270,6 +270,7 @@ public:
        Tizen::Base::Collection::HashMap* __pFeatureList;
        Tizen::Base::Collection::HashMap* __pLaunchConditionList;
        Tizen::Base::Collection::HashMap* __pNotificationMap;
+       Tizen::Base::Collection::HashMap* __pMetadataMap;
 
        int __feature;
 
index e68035e..815588f 100755 (executable)
@@ -122,11 +122,13 @@ SmackManager::AddLabelSharedDir(const PackageId& packageId, const String& dirPat
 
        if (dirPath.Contains(L"shared/data") == true)
        {
-               label.Append("_shareddata");
+               label = L"*";
+               //label.Append("_shareddata");
        }
        else if (dirPath.Contains(L"shared/res") == true)
        {
-               label.Append("_sharedres");
+               label = L"*";
+               //label.Append("_sharedres");
        }
        else if (dirPath.Contains(L"shared/trusted") == true)
        {
index 9013a9f..fad0e6f 100755 (executable)
@@ -568,6 +568,12 @@ ManifestGenerator::WriteApp(int index, AppData* pAppData)
                __pWriter->EndElement();
        }
 
+       HashMap* pMetadataMap = pAppData->__pMetadataMap;
+       if (pMetadataMap->GetCount() > 0)
+       {
+               WriteMetadata(pMetadataMap);
+       }
+
        WriteCategory(index);
 
 #if 0
@@ -945,3 +951,26 @@ ManifestGenerator::WriteNotifications(int index)
        delete pMapEnum;
        return true;
 }
+
+bool
+ManifestGenerator::WriteMetadata(HashMap* pMetadataMap)
+{
+       std::unique_ptr< IMapEnumerator > pEnum(pMetadataMap->GetMapEnumeratorN());
+       TryReturn(pEnum, false, "GetMapEnumeratorN() failed. [%s]", GetErrorMessage(GetLastResult()));
+
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               String* pKey = static_cast< String* > (pEnum->GetKey());
+               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("name", *pKey);
+               __pWriter->WriteAttribute("value", *pValue);
+               __pWriter->EndElement();
+       }
+
+       return true;
+}
index 0cb3878..1b69d10 100755 (executable)
@@ -61,6 +61,7 @@ private:
        bool WriteAppControl(int index, bool subMode = false);
        bool WriteAccounts(int index);
        bool WriteNotifications(int index);
+       bool WriteMetadata(Tizen::Base::Collection::HashMap* pMetadataMap);
 
 private:
        InstallationContext* __pContext;
index ccfdf25..e10896d 100755 (executable)
@@ -147,7 +147,7 @@ ManifestHandler::OnStartElement(const char *pName)
        {
                status = OnContentStartElement();
        }
-       else if (strcasecmp(pName, "Liveboxes") == 0)
+       else if ((strcasecmp(pName, "Liveboxes") == 0) || strcasecmp(pName, "AppWidgets") == 0)
        {
                status = OnLiveboxesStartElement(pName);
        }
@@ -185,7 +185,7 @@ ManifestHandler::OnEndElement(const char *pName)
                TryReturn(__pParser, false, "__pParser is null");
                __pParser->OnEndElement(pName);
 
-               if (strcasecmp(pName, "Liveboxes") == 0)
+               if ((strcasecmp(pName, "Liveboxes") == 0) || strcasecmp(pName, "AppWidgets") == 0)
                {
                        status = OnLiveboxesEndElement();
                }
@@ -332,6 +332,10 @@ ManifestHandler::OnCharacters(const char *pCharacters)
        {
                status = OnCategoryValue(pCharacters);
        }
+       else if (strcasecmp(pName, "Metadata") == 0)
+       {
+               status = OnMetadataValue(pCharacters);
+       }
 
        if (!status)
        {
@@ -1198,6 +1202,27 @@ ManifestHandler::OnCategoryValue(const char *pCharacters)
 }
 
 bool
+ManifestHandler::OnMetadataValue(const char* pCharacters)
+{
+       TryReturn(__pAppData, false, "__pAppData is null");
+
+       XmlAttribute* pAttr = null;
+       char* pKey = null;
+
+       pAttr = GetAttribute();
+       TryReturn(pAttr, true, "pAttr is null.");
+
+       pKey = pAttr->Find("Key");
+       TryReturn(pKey, true, "pKey is null.");
+
+       __pAppData->__pMetadataMap->Add(*(new (std::nothrow) String(pKey)), *(new (std::nothrow) String(pCharacters)));
+
+       AppLog("<Metadata Key=\"%s\">%s</Metadata>", pKey, pCharacters);
+
+       return true;
+}
+
+bool
 ManifestHandler::FindElement(const char *pName)
 {
        bool res = false;
index edbb470..b73fc9c 100755 (executable)
@@ -122,6 +122,7 @@ private:
        bool OnSizeValue(const char *pCharacters);
        bool OnInstallationLocationValue(const char *pCharacters);
        bool OnCategoryValue(const char *pCharacters);
+       bool OnMetadataValue(const char* pCharacters);
 
        bool OnMimeTypeValue(const char* pCharacters);
        bool OnUriValue(const char* pCharacters);
index d18ecff..9a1a930 100755 (executable)
@@ -53,11 +53,11 @@ ManifestLiveboxesParser::OnStartElement(const char *pName)
 
        bool status = true;
 
-       if (strcasecmp(pName, "Liveboxes") == 0)
+       if ((strcasecmp(pName, "Liveboxes") == 0) || (strcasecmp(pName, "AppWidgets") == 0))
        {
                status = OnLiveboxesStartElement();
        }
-       else if (strcasecmp(pName, "Livebox") == 0)
+       else if ((strcasecmp(pName, "Livebox") == 0) || (strcasecmp(pName, "AppWidget") == 0))
        {
                status = OnLiveboxStartElement();
        }
@@ -72,11 +72,11 @@ ManifestLiveboxesParser::OnEndElement(const char *pName)
 
        bool status = true;
 
-       if (strcasecmp(pName, "Liveboxes") == 0)
+       if ((strcasecmp(pName, "Liveboxes") == 0) || (strcasecmp(pName, "AppWidgets") == 0))
        {
                status = OnLiveboxesEndElement();
        }
-       else if (strcasecmp(pName, "Livebox") == 0)
+       else if ((strcasecmp(pName, "Livebox") == 0) || (strcasecmp(pName, "AppWidget") == 0))
        {
                status = OnLiveboxEndElement();
        }
@@ -125,7 +125,7 @@ ManifestLiveboxesParser::OnLiveboxesStartElement()
        __pLiveboxDataList = new (std::nothrow) ArrayList;
        TryReturn(__pLiveboxDataList, false, "__pLiveboxDataList is null");
 
-       AppLog("  <Liveboxes>");
+       AppLog("  <AppWidgets>");
 
        return true;
 }
@@ -144,7 +144,7 @@ ManifestLiveboxesParser::OnLiveboxStartElement(void)
        pAttr = pHandler->GetAttribute();
        TryReturn(pAttr, true, "pAttr is null");
 
-       AppLog("  <Livebox>");
+       AppLog("  <AppWidget>");
 
        char *pProviderName = pAttr->Find("ProviderName");
        if (pProviderName)
@@ -161,12 +161,21 @@ ManifestLiveboxesParser::OnLiveboxStartElement(void)
                AppLog("   - UpdatePeriod=%lld", updatePeriod);
        }
 
-       char *pLiveboxPopupEnabled = pAttr->Find("LiveboxPopupEnabled");
+       charpLiveboxPopupEnabled = pAttr->Find("LiveboxPopupEnabled");
        if (pLiveboxPopupEnabled)
        {
                __pLiveboxData->SetPopupEnabled(pLiveboxPopupEnabled);
                AppLog("   - LiveboxPopupEnabled=%s", pLiveboxPopupEnabled);
        }
+       else
+       {
+               char* pAppWidgetPopupEnabled = pAttr->Find("AppWidgetPopupEnabled");
+               if (pAppWidgetPopupEnabled)
+               {
+                       __pLiveboxData->SetPopupEnabled(pAppWidgetPopupEnabled);
+                       AppLog("   - AppWidgetPopupEnabled=%s", pAppWidgetPopupEnabled);
+               }
+       }
 
        char* pDefault = pAttr->Find("Default");
        if (pDefault == null)
@@ -188,7 +197,7 @@ ManifestLiveboxesParser::OnLiveboxesEndElement(void)
 {
        __pContext->SetLiveboxDataList(__pLiveboxDataList);
        __pLiveboxDataList = null;
-       AppLog("  </Liveboxes>");
+       AppLog("  </AppWidgets>");
 
        return true;
 }
@@ -198,7 +207,7 @@ ManifestLiveboxesParser::OnLiveboxEndElement(void)
 {
        __pLiveboxDataList->Add(*__pLiveboxData);
        __pLiveboxData = null;
-       AppLog("  </Livebox>");
+       AppLog("  </AppWidget>");
 
        return true;
 }