From 896b83566d2eac065c7bb1962a91afe75ed65c12 Mon Sep 17 00:00:00 2001 From: Dongeup Ham Date: Tue, 5 Feb 2013 09:33:05 +0900 Subject: [PATCH] Support livebox preview image Change-Id: I72d311324fa5c6e4ebfeb66da7f40f6ddf2399cc Signed-off-by: Dongeup Ham --- inc/InstallerDefs.h | 2 +- src/Context/InstallationContextData.cpp | 9 ++--- src/Context/InstallationContextData.h | 6 +-- src/XmlHandler/ManifestGenerator.cpp | 49 ++++++++++++++++------- src/XmlHandler/ManifestGenerator.h | 1 + src/XmlHandler/Parser/ManifestLiveboxesParser.cpp | 43 +++++++++++++++++--- 6 files changed, 81 insertions(+), 29 deletions(-) diff --git a/inc/InstallerDefs.h b/inc/InstallerDefs.h index 69d66b5..4ce2d09 100755 --- a/inc/InstallerDefs.h +++ b/inc/InstallerDefs.h @@ -23,7 +23,7 @@ #include "InstallerUtil.h" -#define OSP_INSTALLER_VERSION "version=[20130130.1]" +#define OSP_INSTALLER_VERSION "version=[20130205.1]" #define DIR_BIN L"/bin" #define DIR_INFO L"/info" diff --git a/src/Context/InstallationContextData.cpp b/src/Context/InstallationContextData.cpp index a3c7389..57675a6 100755 --- a/src/Context/InstallationContextData.cpp +++ b/src/Context/InstallationContextData.cpp @@ -76,7 +76,7 @@ LiveboxData::LiveboxData(void) TryReturn(__pNameList, , "__pNameList is null."); __pNameList->Construct(); - __pSizeList = new (std::nothrow) ArrayList; + __pSizeList = new (std::nothrow) HashMap; TryReturn(__pSizeList, , "__pSizeList is null."); __pSizeList->Construct(); } @@ -159,22 +159,21 @@ LiveboxData::GetNameList(void) const } result -LiveboxData::AddSize(const String& size) +LiveboxData::AddSize(String* pSize, String* pPreviewImage) { result r = E_SUCCESS; - r = __pSizeList->Add(size); + r = __pSizeList->Add(pSize, pPreviewImage); return r; } -ArrayList* +HashMap* LiveboxData::GetSizeList(void) const { return __pSizeList; } - ContentData::ContentData(void) :__pNameList(null) { diff --git a/src/Context/InstallationContextData.h b/src/Context/InstallationContextData.h index e28e5d9..dbb73c6 100755 --- a/src/Context/InstallationContextData.h +++ b/src/Context/InstallationContextData.h @@ -50,8 +50,8 @@ public: result AddName(const Tizen::Base::String& language, const Tizen::Base::String& name); Tizen::Base::Collection::HashMap* GetNameList(void) const; - result AddSize(const Tizen::Base::String& size); - Tizen::Base::Collection::ArrayList* GetSizeList(void) const; + result AddSize(Tizen::Base::String* pSize, Tizen::Base::String* pPreviewImage); + Tizen::Base::Collection::HashMap* GetSizeList(void) const; Tizen::Base::String __main; Tizen::Base::String __configurationAppControlAppId; @@ -66,7 +66,7 @@ private: Tizen::Base::String __providerName; Tizen::Base::Collection::HashMap* __pNameList; - Tizen::Base::Collection::ArrayList* __pSizeList; + Tizen::Base::Collection::HashMap* __pSizeList; }; diff --git a/src/XmlHandler/ManifestGenerator.cpp b/src/XmlHandler/ManifestGenerator.cpp index 59be84e..fb34cb6 100755 --- a/src/XmlHandler/ManifestGenerator.cpp +++ b/src/XmlHandler/ManifestGenerator.cpp @@ -246,7 +246,7 @@ ManifestGenerator::WriteLiveboxes(_PackageAppInfoImpl* pAppInfoImpl) const long long updatePeriod = pLiveboxData->GetUpdatePeriod(); String period = LongLong::ToString(updatePeriod/1000); IMap* pLiveboxNameList = pLiveboxData->GetNameList(); - ArrayList* pSizeList = pLiveboxData->GetSizeList(); + IMap* pSizeList = pLiveboxData->GetSizeList(); String popupEnabled = pLiveboxData->GetPopupEnabled(); String primary = pLiveboxData->__main; @@ -280,22 +280,14 @@ ManifestGenerator::WriteLiveboxes(_PackageAppInfoImpl* pAppInfoImpl) const if (pSizeList) { + String previewDir; + __pWriter->StartElement("box"); __pWriter->WriteAttribute("type", "buffer"); - for (int k = 0 ; k < pSizeList->GetCount(); k++) - { - String* pSize = dynamic_cast(pSizeList->GetAt(k)); - if (pSize == null) - { - AppLog("pSize is null [%d]", k); - continue; - } - - __pWriter->StartElement("size"); - __pWriter->WriteString(*pSize); - __pWriter->EndElement(); - } + previewDir.Format(1024, L"%ls%ls", __pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_SHARED_RES); + WriteLiveboxSizeValue(pSizeList, "size", previewDir); + __pWriter->EndElement(); } @@ -325,6 +317,35 @@ ManifestGenerator::WriteLiveboxes(_PackageAppInfoImpl* pAppInfoImpl) const } bool +ManifestGenerator::WriteLiveboxSizeValue(IMap* pList, const String& element, const String& previewDir) const +{ + TryReturn(pList, false, "pList is null."); + + IMapEnumerator* pMapEnum = pList->GetMapEnumeratorN(); + TryReturn(pMapEnum, true, "pMapEnum is null."); + + int count = 0; + while (pMapEnum->MoveNext() == E_SUCCESS) + { + String* pSize = static_cast (pMapEnum->GetKey()); + String* pPriviewImage = static_cast (pMapEnum->GetValue()); + + __pWriter->StartElement(element); + if (pPriviewImage && (pPriviewImage->IsEmpty() == false)) + { + String previewImagePath; + previewImagePath.Format(1024, L"%ls/%ls", previewDir.GetPointer(), pPriviewImage->GetPointer()); + __pWriter->WriteAttribute("preview", previewImagePath); + } + __pWriter->WriteString(*pSize); + __pWriter->EndElement(); + } + + delete pMapEnum; + return true; +} + +bool ManifestGenerator::WriteAppControl(_PackageAppInfoImpl* pAppInfoImpl) const { TryReturn(pAppInfoImpl, false, "pAppInfoImpl is null."); diff --git a/src/XmlHandler/ManifestGenerator.h b/src/XmlHandler/ManifestGenerator.h index 7429dfd..621a022 100755 --- a/src/XmlHandler/ManifestGenerator.h +++ b/src/XmlHandler/ManifestGenerator.h @@ -53,6 +53,7 @@ private: bool FindFeatureValue(Tizen::Base::Collection::ArrayList* pFeatureList, const Tizen::Base::String& feature, const Tizen::Base::String& value) const; bool WriteLanguageValue(Tizen::Base::Collection::IMap* pList, const Tizen::Base::String& label) const; bool WriteLiveboxes(Tizen::App::Package::_PackageAppInfoImpl* pAppInfoImpl) const; + bool WriteLiveboxSizeValue(Tizen::Base::Collection::IMap* pList, const Tizen::Base::String& element, const Tizen::Base::String& previewDir) const; bool WriteAppControl(Tizen::App::Package::_PackageAppInfoImpl* pAppInfoImpl) const; Tizen::Base::String GetGlFrameValue(Tizen::Base::Collection::ArrayList* pFeatureList) const; diff --git a/src/XmlHandler/Parser/ManifestLiveboxesParser.cpp b/src/XmlHandler/Parser/ManifestLiveboxesParser.cpp index f35c0e5..3fdfd05 100755 --- a/src/XmlHandler/Parser/ManifestLiveboxesParser.cpp +++ b/src/XmlHandler/Parser/ManifestLiveboxesParser.cpp @@ -203,25 +203,56 @@ ManifestLiveboxesParser::OnLiveboxEndElement(void) bool ManifestLiveboxesParser::OnSizeValue(const char *pCharacters) { - __pLiveboxData->AddSize(*(new (std::nothrow) String(pCharacters))); + ManifestHandler* pHandler = GetHandler(); + TryReturn(pHandler, false, "pHandler is null"); AppLog(" %s", pCharacters); + + String* pPreviewImage = new (std::nothrow) String(); + TryReturn(pPreviewImage, false, "pPreviewImage is null"); + + XmlAttribute* pAttr = pHandler->GetAttribute(); + if (pAttr) + { + char* pAttrValue = pAttr->Find("PreviewImage"); + if (pAttrValue) + { + char* pDefaultIconType = pHandler->GetDefaultIconType(); + TryReturn(pDefaultIconType, false, "pDefaultIconType is null"); + AppLog(" pDefaultIconType=%s", pDefaultIconType); + + if (strcasecmp(pDefaultIconType, "Xhigh") == 0) + { + pPreviewImage->Format(1024, L"screen-density-xhigh/%s", pAttrValue); + } + else if (strcasecmp(pDefaultIconType, "High") == 0) + { + pPreviewImage->Format(1024, L"screen-density-high/%s", pAttrValue); + } + else + { + TryReturn(0, false, "Invalid pDefaultIconType[%s]", pDefaultIconType); + } + + AppLog(" - PreviewImage=%s", pAttrValue); + } + } + + __pLiveboxData->AddSize(new (std::nothrow) String(pCharacters), pPreviewImage); + return true; } bool ManifestLiveboxesParser::OnDisplayNameValue(const char *pCharacters) { - XmlAttribute* pAttr = 0; - char* pAttrValue = 0; - ManifestHandler* pHandler = GetHandler(); TryReturn(pHandler, false, "pHandler is null"); - pAttr = pHandler->GetAttribute(); + XmlAttribute* pAttr = pHandler->GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); - pAttrValue = pAttr->Find("Locale"); + char* pAttrValue = pAttr->Find("Locale"); TryReturn(pAttrValue, true, "pAttrValue is null"); String* pValue = new (std::nothrow) String; -- 2.7.4