Fix PackageParser for bug
authorDuyoung Jang <duyoung.jang@samsung.com>
Mon, 30 Sep 2013 07:02:04 +0000 (16:02 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Mon, 30 Sep 2013 07:02:04 +0000 (16:02 +0900)
Change-Id: I66830d5d9b8138c9b4515e041e9cf033720d329b
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
src/app/inc/FAppPkg_PackageParser.h
src/app/package/FAppPkg_PackageParser.cpp

index 9c13ec0..c445f57 100755 (executable)
@@ -144,6 +144,7 @@ private:
        bool OnCategoryValue(const char* pCharacters);
 
        bool ParseAppAttribute(_PackageXmlAttribute* pAttr, bool isUiApp);
+       bool FindElement(const char* pName);
 
 private:
        _PackageInfoImpl* __pPackageInfoImpl;
index 038c61e..8255c57 100755 (executable)
 #include <FAppPkg_PackageParser.h>
 #include <FBase_StringConverter.h>
 
+using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Base::Utility;
-using namespace Tizen::App;
 using namespace Tizen::Io;
 using namespace Tizen::System;
 
@@ -63,11 +63,11 @@ _PackageXmlAttribute::Construct(const char* pName, const char* pValue)
        }
 
        __pName = new (std::nothrow) char[strlen(pName)+1];
-       SysTryReturn(NID_APP, __pName, false, E_OUT_OF_MEMORY, "__pName is null");
+       SysTryReturn(NID_APP, __pName, false, E_OUT_OF_MEMORY, "__pName is null.");
        strcpy(__pName, pName);
 
        __pValue = new (std::nothrow) char[strlen(pValue)+1];
-       SysTryReturn(NID_APP, __pValue, false, E_OUT_OF_MEMORY, "__pValue is null");
+       SysTryReturn(NID_APP, __pValue, false, E_OUT_OF_MEMORY, "__pValue is null.");
        strcpy(__pValue, pValue);
 
        return true;
@@ -120,7 +120,7 @@ _PackageXmlAttribute::Add(const char* pName, const char* pValue)
        else
        {
                __pNext = new (std::nothrow) _PackageXmlAttribute();
-               SysTryReturn(NID_APP, __pNext, false, E_OUT_OF_MEMORY, "__pNext is null");
+               SysTryReturn(NID_APP, __pNext, false, E_OUT_OF_MEMORY, "__pNext is null.");
 
                __pNext->Construct(pName, pValue);
        }
@@ -297,10 +297,10 @@ _PackageXmlHandler::ParseNormalizedDocument(const char* pFilepath)
        TryCatch(size > 0, ret = false, "size is invalid. [%s]", pFilepath);
 
        pBuf = new (std::nothrow) char[size+1];
-       TryCatch(pBuf, ret = false, "pBuf is null");
+       TryCatch(pBuf, ret = false, "pBuf is null.");
 
        pNormalizedBuf = new (std::nothrow) char[size+1];
-       TryCatch(pNormalizedBuf, ret = false, "pNormalizedBuf is null");
+       TryCatch(pNormalizedBuf, ret = false, "pNormalizedBuf is null.");
 
        memset(pBuf, 0, size+1);
        memset(pNormalizedBuf, 0, size+1);
@@ -315,7 +315,7 @@ _PackageXmlHandler::ParseNormalizedDocument(const char* pFilepath)
        TryCatch(ctxt, ret = false, "invalid xml file, %s", pFilepath);
 
        pSAXHandler = new (std::nothrow) xmlSAXHandler;
-       TryCatch(pSAXHandler, ret = false, "pSAXHandler is null");
+       TryCatch(pSAXHandler, ret = false, "pSAXHandler is null.");
        memset(pSAXHandler, 0, sizeof(xmlSAXHandler));
 
        ctxt->userData = (void *)this;
@@ -376,7 +376,7 @@ _PackageXmlHandler::Normalize(const char* pBuf, int size, char* pNormalizedBuf)
 bool
 _PackageXmlHandler::SetElementName(const char* pElementName)
 {
-       SysTryReturn(NID_APP, pElementName, false, E_SYSTEM, "pElementName is null");
+       SysTryReturn(NID_APP, pElementName, false, E_SYSTEM, "pElementName is null.");
 
        if (__pElementName)
        {
@@ -385,7 +385,7 @@ _PackageXmlHandler::SetElementName(const char* pElementName)
        }
 
        __pElementName = new (std::nothrow) char[strlen(pElementName)+1];
-       SysTryReturn(NID_APP, __pElementName, false, E_OUT_OF_MEMORY, "__pElementName is null");
+       SysTryReturn(NID_APP, __pElementName, false, E_OUT_OF_MEMORY, "__pElementName is null.");
        strcpy(__pElementName, pElementName);
 
        __elementStack.Push(*new (std::nothrow) String(pElementName));
@@ -411,12 +411,12 @@ _PackageXmlHandler::DeleteElement(void)
 bool
 _PackageXmlHandler::SetCharacters(const char* pCharacter)
 {
-       SysTryReturn(NID_APP, pCharacter, false, E_SYSTEM, "pCharacter is null");
+       SysTryReturn(NID_APP, pCharacter, false, E_SYSTEM, "pCharacter is null.");
 
        if (__pCharacters == null)
        {
                __pCharacters = new (std::nothrow) char[4096];
-               SysTryReturn(NID_APP, __pCharacters, false, E_OUT_OF_MEMORY, "__pCharacters is null");
+               SysTryReturn(NID_APP, __pCharacters, false, E_OUT_OF_MEMORY, "__pCharacters is null.");
 
                memset(__pCharacters, 0, 4096);
        }
@@ -653,7 +653,7 @@ _PackageParser::OnUiAppStartElement(void)
        SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
 
        _PackageXmlAttribute* pAttr = GetAttribute();
-       SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null");
+       SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null.");
 
        ParseAppAttribute(pAttr, true);
 
@@ -670,7 +670,7 @@ _PackageParser::OnServiceAppStartElement(void)
        SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
 
        _PackageXmlAttribute* pAttr = GetAttribute();
-       SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null");
+       SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null.");
 
        ParseAppAttribute(pAttr, false);
 
@@ -804,16 +804,26 @@ _PackageParser::OnPrivilegeValue(const char* pCharacters)
 bool
 _PackageParser::OnIconValue(const char* pCharacters)
 {
-       SysTryReturn(NID_APP, __pDefaultIconType, false, E_SYSTEM, "__pDefaultIconType is null");
+       SysTryReturn(NID_APP, __pDefaultIconType, false, E_SYSTEM, "__pDefaultIconType is null.");
 
        _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
        SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
 
        _PackageXmlAttribute* pAttr = GetAttribute();
-       SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null");
+       SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null.");
+
+       if ((FindElement("Accounts") == true) || (FindElement("AppWidgets") == true))
+       {
+               AppLog("Skip icon value.");
+               return true;
+       }
+       else
+       {
+               AppLog("It's icon value for UiApp, ServiceApp");
+       }
 
        char* pSection = pAttr->Find("Section");
-       SysTryReturn(NID_APP, pSection, true, E_SYSTEM, "pSection is null");
+       SysTryReturn(NID_APP, pSection, true, E_SYSTEM, "pSection is null.");
 
        String iconRelPath;
        String tempIconPath;
@@ -920,6 +930,16 @@ _PackageParser::OnDisplayNameValue(const char* pCharacters)
        pAttr = GetAttribute();
        SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null");
 
+       if ((FindElement("Accounts") == true) || (FindElement("AppWidgets") == true))
+       {
+               AppLog("Skip display name.");
+               return true;
+       }
+       else
+       {
+               AppLog("It's display name for UiApp, ServiceApp");
+       }
+
        pAttrValue = pAttr->Find("Locale");
        SysTryReturn(NID_APP, pAttrValue, true, E_SYSTEM, "pAttrValue is null");
 
@@ -1044,4 +1064,32 @@ _PackageParser::ParseAppAttribute(_PackageXmlAttribute* pAttr, bool isUiApp)
        return true;
 }
 
+bool
+_PackageParser::FindElement(const char* pName)
+{
+       bool res = false;
+       IEnumerator* pEnum = GetElementEnumeratorN();
+
+       if (pEnum)
+       {
+               while(pEnum->MoveNext() == E_SUCCESS)
+               {
+                       String* pStr = static_cast< String* >(pEnum->GetCurrent());
+                       if (pStr)
+                       {
+                               if (pStr->Equals(pName, false) == true)
+                               {
+                                       AppLog("[%s] is matched.", pName);
+                                       res = true;
+                                       break;
+                               }
+                       }
+               }
+
+               delete pEnum;
+       }
+
+       return res;
+}
+
 } } } // Tizen::App::Package