Fallback mechanism is applied for icon.
authorDuyoung Jang <duyoung.jang@samsung.com>
Tue, 19 Mar 2013 06:20:01 +0000 (15:20 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Tue, 19 Mar 2013 06:20:01 +0000 (15:20 +0900)
Change-Id: I34bec92c5b976ea9f4aebda8b7b24a68dbbc5b0c
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
inc/InstallerDefs.h
src/XmlHandler/ManifestGenerator.cpp
src/XmlHandler/ManifestGenerator.h

index f9218a2..fb38f16 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130318.1]"
+#define OSP_INSTALLER_VERSION "version=[20130319.1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
index fad0e6f..d82e20f 100755 (executable)
@@ -248,7 +248,7 @@ ManifestGenerator::WriteLiveboxes(AppData* pAppData) const
                if (menuIcon.IsEmpty() == false)
                {
                        String menuIconPath;
-                       menuIconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, menuIcon.GetPointer());
+                       GetIconPath(menuIcon, menuIconPath);
 
                        __pWriter->StartElement("icon");
                        __pWriter->WriteString(menuIconPath);
@@ -467,7 +467,7 @@ ManifestGenerator::WriteApp(int index, AppData* pAppData)
                if (pAppData->__mainmenuIcon.IsEmpty() == false)
                {
                        String iconPath;
-                       iconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, pAppData->__mainmenuIcon.GetPointer());
+                       GetIconPath(pAppData->__mainmenuIcon, iconPath);
 
                        __pWriter->StartElement("icon");
                        __pWriter->WriteString(iconPath);
@@ -633,7 +633,7 @@ ManifestGenerator::WriteApp(int index, AppData* pAppData)
        if (pAppData->__mainmenuIcon.IsEmpty() == false)
        {
                String iconPath;
-               iconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, pAppData->__mainmenuIcon.GetPointer());
+               GetIconPath(pAppData->__mainmenuIcon, iconPath);
 
                __pWriter->StartElement("icon");
                __pWriter->WriteString(iconPath);
@@ -643,7 +643,7 @@ ManifestGenerator::WriteApp(int index, AppData* pAppData)
        if (pAppData->__settingIcon.IsEmpty() == false)
        {
                String iconPath;
-               iconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, pAppData->__settingIcon.GetPointer());
+               GetIconPath(pAppData->__settingIcon, iconPath);
 
                __pWriter->StartElement("icon");
                __pWriter->WriteAttribute("section", "setting");
@@ -654,7 +654,7 @@ ManifestGenerator::WriteApp(int index, AppData* pAppData)
        if (pAppData->__notificationIcon.IsEmpty() == false)
        {
                String iconPath;
-               iconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, pAppData->__notificationIcon.GetPointer());
+               GetIconPath(pAppData->__notificationIcon, iconPath);
 
                __pWriter->StartElement("icon");
                __pWriter->WriteAttribute("section", "notification");
@@ -729,7 +729,7 @@ ManifestGenerator::WriteSubModeApp(int index, AppData* pAppData)
        if (pAppData->__mainmenuIcon.IsEmpty() == false)
        {
                String iconPath;
-               iconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, pAppData->__mainmenuIcon.GetPointer());
+               GetIconPath(pAppData->__mainmenuIcon, iconPath);
 
                __pWriter->StartElement("icon");
                __pWriter->WriteString(iconPath);
@@ -974,3 +974,46 @@ ManifestGenerator::WriteMetadata(HashMap* pMetadataMap)
 
        return true;
 }
+
+bool
+ManifestGenerator::GetIconPath(const String& icon, String& iconPath) const
+{
+       String tempIconPath;
+       tempIconPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_SHARED_RES, icon.GetPointer());
+
+       if (File::IsFileExist(tempIconPath) == false)
+       {
+               AppLog("fallback, old path = [%ls]", tempIconPath.GetPointer());
+
+               String densityXhigh("screen-density-xhigh/");
+               String densityHigh("screen-density-high/");
+
+               if (icon.Contains(densityXhigh) == true)
+               {
+                       tempIconPath.Replace(densityXhigh, densityHigh);
+               }
+               else if (icon.Contains(densityHigh) == true)
+               {
+                       tempIconPath.Replace(densityHigh, densityXhigh);
+               }
+               else
+               {
+                       AppLog("invalid icon [%ls]", icon.GetPointer());
+                       return false;
+               }
+
+               AppLog("fallback, new path = [%ls]", tempIconPath.GetPointer());
+
+               if (File::IsFileExist(tempIconPath) == false)
+               {
+                       AppLog("fallback, but file is not found. [%ls]", tempIconPath.GetPointer());
+                       return false;
+               }
+       }
+
+       iconPath = tempIconPath;
+
+       AppLog("icon[%ls], iconPath[%ls]", icon.GetPointer(), iconPath.GetPointer());
+
+       return true;
+}
index 1b69d10..7800adb 100755 (executable)
@@ -63,6 +63,8 @@ private:
        bool WriteNotifications(int index);
        bool WriteMetadata(Tizen::Base::Collection::HashMap* pMetadataMap);
 
+       bool GetIconPath(const Tizen::Base::String& icon, Tizen::Base::String& iconPath) const;
+
 private:
        InstallationContext* __pContext;
        XmlWriter* __pWriter;