osp-installer implementation for new Manifest spec
authorDongeup Ham <dongeup.ham@samsung.com>
Wed, 26 Dec 2012 02:20:31 +0000 (11:20 +0900)
committerDongeup Ham <dongeup.ham@samsung.com>
Wed, 26 Dec 2012 02:20:31 +0000 (11:20 +0900)
Change-Id: I4719f20935953c8c543bd9b10f7c4822e571651d
Signed-off-by: Dongeup Ham <dongeup.ham@samsung.com>
inc/InstallerDefs.h
src/XmlHandler/ManifestHandler.cpp
src/XmlHandler/ManifestHandler.h

index 8cbcda6..0b37007 100755 (executable)
@@ -21,7 +21,7 @@
 #ifndef _INSTALLER_DEFS_H_
 #define _INSTALLER_DEFS_H_
 
-#define OSP_INSTALLER_VERSION "osp-installer version = [2012/12/22]_RC[1]"
+#define OSP_INSTALLER_VERSION "osp-installer version = [2012/12/26]_RC[1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
index 7cc8a5f..521d6ae 100755 (executable)
@@ -306,6 +306,10 @@ ManifestHandler::OnCharacters(const char *pCharacters)
        {
                status = OnNameValue(pCharacters);
        }
+       else if (strcasecmp(pName, "DisplayName") == 0)
+       {
+               status = OnNameValue(pCharacters);
+       }
        else if (strcasecmp(pName, "Author") == 0)
        {
                status = OnAuthorValue(pCharacters);
@@ -381,116 +385,12 @@ ManifestHandler::OnUiAppStartElement(void)
        __pAppData = new (std::nothrow) AppData;
        TryReturn(__pAppData, false, "[osp-installer] __pAppData is null");
 
+       AppLogTag(OSP_INSTALLER, "<UiApp>");
+
        pAttr = GetAttribute();
        TryReturn(pAttr, true, "[osp-installer] pAttr is null");
 
-       char* pExecutableName = pAttr->Find("ExecutableName");
-       if (pExecutableName == null)
-       {
-               pExecutableName = pAttr->Find("Name");
-       }
-       TryReturn(pExecutableName, true, "[osp-installer] pExecutableName is null");
-
-       __pPackageAppInfoImpl->SetName(pExecutableName);
-
-       char* pDefault = pAttr->Find("Default");
-       if (pDefault)
-       {
-               __pPackageAppInfoImpl->SetDefault(pDefault);
-
-               if (strcasecmp(pDefault, "True") == 0)
-               {
-                       __isDefaultName = true;
-                       __isDefaultAppDetected = true;
-               }
-       }
-       else
-       {
-               __pPackageAppInfoImpl->SetDefault("False");
-       }
-
-       __pPackageAppInfoImpl->SetType("UiApp");
-
-       char* pMainmenuVisible = pAttr->Find("MainmenuVisible");
-       if (pMainmenuVisible)
-       {
-               if (strcasecmp(pMainmenuVisible, "True") == 0)
-               {
-                       __pPackageAppInfoImpl->SetMainmenuVisible(true);
-               }
-               else
-               {
-                       __pPackageAppInfoImpl->SetMainmenuVisible(false);
-               }
-
-               AddAppFeature("MainmenuVisible", pMainmenuVisible);
-               AppLogTag(OSP_INSTALLER, " - MainmenuVisible=%s", pMainmenuVisible);
-       }
-
-       char* pHwAcceleration = pAttr->Find("HwAcceleration");
-       if (pHwAcceleration)
-       {
-               AddAppFeature("HwAcceleration", pHwAcceleration);
-               AppLogTag(OSP_INSTALLER, " - HwAcceleration=%s", pHwAcceleration);
-       }
-       else
-       {
-               char* pGlFrame = pAttr->Find("GlFrame");
-               if (pGlFrame)
-               {
-                       AddAppFeature("GlFrame", pGlFrame);
-                       AppLogTag(OSP_INSTALLER, " - GlFrame=%s", pGlFrame);
-               }
-       }
-
-       char* pCategory = pAttr->Find("Category");
-       if (pCategory)
-       {
-               AppLogTag(OSP_INSTALLER, " - Category=%s", pCategory);
-
-               if (strcasecmp(pCategory, "home-screen") == 0)
-               {
-                       // __pCategoryList->Add(new String("home-screen"));
-                       __pAppData->__pCategoryList->Add(new String("http://tizen.org/category/homescreen"));
-               }
-               else if (strcasecmp(pCategory, "lock-screen") == 0)
-               {
-                       // __pCategoryList->Add(new String("lock-screen"));
-                       __pAppData->__pCategoryList->Add(new String("http://tizen.org/category/lockscreen"));
-               }
-               else if (strcasecmp(pCategory, "Ime") == 0)
-               {
-                       __pAppData->__pCategoryList->Add(new String("http://tizen.org/category/ime"));
-               }
-
-               CategoryType categoryType = InstallerUtil::GetCategoryType(pCategory);
-               __pPackageAppInfoImpl->SetAppFeature(categoryType);
-       }
-
-       char* pSubMode = pAttr->Find("SubMode");
-       if (pSubMode)
-       {
-               if (strcasecmp(pSubMode, "True") == 0)
-               {
-                       __pContext->__isSubMode = true;
-                       AppLogTag(OSP_INSTALLER, " - SubMode=%s", pSubMode);
-               }
-       }
-
-       String app_id;
-       if (__pContext->GetPackageNameType() == INSTALLER_PREFIX_TYPE_ORG)
-       {
-               app_id.Format(1024, PACKAGE_NAME_RULE_ORG, __pPackageInfoImpl->GetAppId().GetPointer(), pExecutableName);
-       }
-       else
-       {
-               app_id.Format(1024, PACKAGE_NAME_RULE, __pPackageInfoImpl->GetAppId().GetPointer(), pExecutableName);
-       }
-
-       __pPackageAppInfoImpl->SetPackageName(app_id);
-
-       AppLogTag(OSP_INSTALLER, "app_id = %S", app_id.GetPointer());
-       AppLogTag(OSP_INSTALLER, "<UiApp Name=\"%s\" Default=\"%s\">", pExecutableName, pDefault ? pDefault:"False");
+       ParseAppAttribute(pAttr, true);
 
        return true;
 }
@@ -499,12 +399,6 @@ bool
 ManifestHandler::OnServiceAppStartElement(void)
 {
        XmlAttribute *pAttr = null;
-       char *pExecutableName = null;
-       char *pDefault = null;
-       char *pMainmenuVisible = null;
-       char *pLaunchOnBoot = null;
-       char *pAutoRestart = null;
-       char *pUseUi = null;
 
        __pPackageAppInfoImpl = new _PackageAppInfoImpl;
        TryReturn(__pPackageAppInfoImpl, false, "[osp-installer] __pPackageAppInfoImpl is null");
@@ -512,96 +406,12 @@ ManifestHandler::OnServiceAppStartElement(void)
        __pAppData = new (std::nothrow) AppData;
        TryReturn(__pAppData, false, "[osp-installer] __pAppData is null");
 
+       AppLogTag(OSP_INSTALLER, "<ServiceApp>");
+
        pAttr = GetAttribute();
        TryReturn(pAttr, true, "pAttr is null");
 
-       pExecutableName = pAttr->Find("ExecutableName");
-       if (pExecutableName == null)
-       {
-               pExecutableName = pAttr->Find("Name");
-       }
-       TryReturn(pExecutableName, true, "[osp-installer] pExecutableName is null");
-
-       __pPackageAppInfoImpl->SetName(pExecutableName);
-
-       pDefault = pAttr->Find("Default");
-       if (pDefault)
-       {
-               __pPackageAppInfoImpl->SetDefault(pDefault);
-
-               if (strcasecmp(pDefault, "True") == 0)
-               {
-                       __isDefaultName = true;
-                       __isDefaultAppDetected = true;
-               }
-       }
-       else
-       {
-               __pPackageAppInfoImpl->SetDefault("False");
-       }
-
-       __pPackageAppInfoImpl->SetType("ServiceApp");
-       __pPackageAppInfoImpl->SetMainmenuVisible(false);
-
-       pMainmenuVisible = pAttr->Find("MainmenuVisible");
-       if (pMainmenuVisible)
-       {
-               AddAppFeature("MainmenuVisible", pMainmenuVisible);
-               AppLogTag(OSP_INSTALLER, "<MainmenuVisible=%s>", pMainmenuVisible);
-       }
-
-       pLaunchOnBoot = pAttr->Find("LaunchOnBoot");
-       if (pLaunchOnBoot)
-       {
-               AddAppFeature("LaunchOnBoot", pLaunchOnBoot);
-               AppLogTag(OSP_INSTALLER, "<LaunchOnBoot=%s>", pLaunchOnBoot);
-       }
-
-       pAutoRestart = pAttr->Find("AutoRestart");
-       if (pAutoRestart)
-       {
-               AddAppFeature("AutoRestart", pAutoRestart);
-               AppLogTag(OSP_INSTALLER, "<AutoRestart=%s>", pAutoRestart);
-       }
-
-       pUseUi = pAttr->Find("UseUi");
-       if (pUseUi)
-       {
-               AddAppFeature("UseUi", pUseUi);
-               AppLogTag(OSP_INSTALLER, "<UseUi=%s>", pUseUi);
-       }
-
-       char* pHwAcceleration = pAttr->Find("HwAcceleration");
-       if (pHwAcceleration)
-       {
-               AddAppFeature("HwAcceleration", pHwAcceleration);
-               AppLogTag(OSP_INSTALLER, " - HwAcceleration=%s", pHwAcceleration);
-       }
-       else
-       {
-               char* pGlFrame = pAttr->Find("GlFrame");
-               if (pGlFrame)
-               {
-                       AddAppFeature("GlFrame", pGlFrame);
-                       AppLogTag(OSP_INSTALLER, " - GlFrame=%s", pGlFrame);
-               }
-       }
-
-       String app_id;
-
-       if (__pContext->GetPackageNameType() == INSTALLER_PREFIX_TYPE_ORG)
-       {
-               app_id.Format(1024, PACKAGE_NAME_RULE_ORG, __pPackageInfoImpl->GetAppId().GetPointer(), pExecutableName);
-       }
-       else
-       {
-               app_id.Format(1024, PACKAGE_NAME_RULE, __pPackageInfoImpl->GetAppId().GetPointer(), pExecutableName);
-       }
-
-       __pPackageAppInfoImpl->SetPackageName(app_id);
-
-       AppLogTag(OSP_INSTALLER, "app_id = %S", app_id.GetPointer());
-       AppLogTag(OSP_INSTALLER, "<ServiceApp Name=\"%s\" Default=\"%s\">", pExecutableName, pDefault ? pDefault:"False");
+       ParseAppAttribute(pAttr, false);
 
        return true;
 }
@@ -1414,7 +1224,7 @@ ManifestHandler::OnNameValue(const char *pCharacters)
                }
        }
 
-       AppLogTag(OSP_INSTALLER, "<Name Locale=\"%s\">%s</Name>", pAttrValue, pCharacters);
+       AppLogTag(OSP_INSTALLER, "<DisplayName Locale=\"%s\">%s</DisplayName>", pAttrValue, pCharacters);
 
        return true;
 }
@@ -1606,3 +1416,150 @@ ManifestHandler::AddAppFeature(const Tizen::Base::String& name, const Tizen::Bas
 
        return true;
 }
+
+bool
+ManifestHandler::ParseAppAttribute(XmlAttribute* pAttr, bool isUiApp)
+{
+       char* pName = pAttr->Find("Name");
+       if (pName == null)
+       {
+               pName = pAttr->Find("ExecutableName");
+       }
+
+       if (pName)
+       {
+               AppLogTag(OSP_INSTALLER, " - Name=%s", pName);
+               __pPackageAppInfoImpl->SetName(pName);
+       }
+
+       char* pMain = pAttr->Find("Main");
+       if (pMain == null)
+       {
+               pMain = pAttr->Find("Default");
+       }
+
+       if (pMain)
+       {
+               AppLogTag(OSP_INSTALLER, " - Main=%s", pMain);
+
+               __pPackageAppInfoImpl->SetDefault(pMain);
+
+               if (strcasecmp(pMain, "True") == 0)
+               {
+                       __isDefaultName = true;
+                       __isDefaultAppDetected = true;
+               }
+       }
+       else
+       {
+               __pPackageAppInfoImpl->SetDefault("False");
+       }
+
+       char* pHwAcceleration = pAttr->Find("HwAcceleration");
+       if (pHwAcceleration)
+       {
+               AddAppFeature("HwAcceleration", pHwAcceleration);
+               AppLogTag(OSP_INSTALLER, " - HwAcceleration=%s", pHwAcceleration);
+       }
+       else
+       {
+               char* pGlFrame = pAttr->Find("GlFrame");
+               if (pGlFrame)
+               {
+                       AddAppFeature("GlFrame", pGlFrame);
+                       AppLogTag(OSP_INSTALLER, " - GlFrame=%s", pGlFrame);
+               }
+       }
+
+       char* pCategory = pAttr->Find("Category");
+       if (pCategory)
+       {
+               AppLogTag(OSP_INSTALLER, " - Category=%s", pCategory);
+
+               if (strcasecmp(pCategory, "home-screen") == 0)
+               {
+                       __pAppData->__pCategoryList->Add(new String("http://tizen.org/category/homescreen"));
+               }
+               else if (strcasecmp(pCategory, "lock-screen") == 0)
+               {
+                       __pAppData->__pCategoryList->Add(new String("http://tizen.org/category/lockscreen"));
+               }
+               else if (strcasecmp(pCategory, "Ime") == 0)
+               {
+                       __pAppData->__pCategoryList->Add(new String("http://tizen.org/category/ime"));
+               }
+
+               CategoryType categoryType = InstallerUtil::GetCategoryType(pCategory);
+               __pPackageAppInfoImpl->SetAppFeature(categoryType);
+       }
+
+       char* pSubMode = pAttr->Find("SubMode");
+       if (pSubMode)
+       {
+               if (strcasecmp(pSubMode, "True") == 0)
+               {
+                       __pContext->__isSubMode = true;
+                       AppLogTag(OSP_INSTALLER, " - SubMode=%s", pSubMode);
+               }
+       }
+
+       if (isUiApp == true)
+       {
+               __pPackageAppInfoImpl->SetType("UiApp");
+
+               char* pMenuIconVisible = pAttr->Find("MenuIconVisible");
+               if (pMenuIconVisible == null)
+               {
+                       pMenuIconVisible = pAttr->Find("MainmenuVisible");
+               }
+
+               if (pMenuIconVisible)
+               {
+                       if (strcasecmp(pMenuIconVisible, "True") == 0)
+                       {
+                               __pPackageAppInfoImpl->SetMainmenuVisible(true);
+                       }
+                       else
+                       {
+                               __pPackageAppInfoImpl->SetMainmenuVisible(false);
+                       }
+
+                       AddAppFeature("MenuIconVisible", pMenuIconVisible);
+                       AppLogTag(OSP_INSTALLER, " - MenuIconVisible=%s", pMenuIconVisible);
+               }
+       }
+       else
+       {
+               __pPackageAppInfoImpl->SetType("ServiceApp");
+               __pPackageAppInfoImpl->SetMainmenuVisible(false);
+
+               char *pUseUi = pAttr->Find("UseUi");
+               if (pUseUi)
+               {
+                       AddAppFeature("UseUi", pUseUi);
+                       AppLogTag(OSP_INSTALLER, " - UseUi=%s", pUseUi);
+               }
+
+               char *pLaunchOnBoot = pAttr->Find("LaunchOnBoot");
+               if (pLaunchOnBoot)
+               {
+                       AddAppFeature("LaunchOnBoot", pLaunchOnBoot);
+                       AppLogTag(OSP_INSTALLER, " - LaunchOnBoot=%s", pLaunchOnBoot);
+               }
+
+               char *pAutoRestart = pAttr->Find("AutoRestart");
+               if (pAutoRestart)
+               {
+                       AddAppFeature("AutoRestart", pAutoRestart);
+                       AppLogTag(OSP_INSTALLER, " - AutoRestart=%s", pAutoRestart);
+               }
+       }
+
+       String appId;
+       appId.Format(1024, PACKAGE_NAME_RULE, __pPackageInfoImpl->GetAppId().GetPointer(), pName);
+       __pPackageAppInfoImpl->SetPackageName(appId);
+
+       AppLogTag(OSP_INSTALLER, " - appId=%ls", appId.GetPointer());
+
+       return true;
+}
index 146ec6b..4d7d205 100755 (executable)
@@ -122,6 +122,7 @@ private:
        // help functions
        bool FindElement(const char *pName);
        bool AddAppFeature(const Tizen::Base::String& name, const Tizen::Base::String& value);
+       bool ParseAppAttribute(XmlAttribute* pAttr, bool isUiApp);
 
 private:
        InstallationContext* __pContext;