2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 * @file FAppPkg_PackageParser.cpp
18 * @brief This is the implementation for the _PackageParser class.
21 #include <libxml/parserInternals.h>
22 #include <system_info.h>
24 #include <FAppPkgPackageAppInfo.h>
25 #include <FBaseSysLog.h>
27 #include <FIoDirectory.h>
28 #include <FAppPkg_PackageAppInfoImpl.h>
29 #include <FAppPkg_PackageInfoImpl.h>
30 #include <FAppPkg_PackageParser.h>
31 #include <FBase_StringConverter.h>
33 using namespace Tizen::App;
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Utility;
37 using namespace Tizen::Io;
38 using namespace Tizen::System;
40 namespace Tizen { namespace App { namespace Package
43 _PackageXmlAttribute::_PackageXmlAttribute(void)
50 _PackageXmlAttribute::~_PackageXmlAttribute(void)
58 _PackageXmlAttribute::Construct(const char* pName, const char* pValue)
60 if (pName == 0 || pValue == 0)
65 __pName = new (std::nothrow) char[strlen(pName)+1];
66 SysTryReturn(NID_APP, __pName, false, E_OUT_OF_MEMORY, "__pName is null.");
67 strcpy(__pName, pName);
69 __pValue = new (std::nothrow) char[strlen(pValue)+1];
70 SysTryReturn(NID_APP, __pValue, false, E_OUT_OF_MEMORY, "__pValue is null.");
71 strcpy(__pValue, pValue);
77 _PackageXmlAttribute::Find(const char* pName)
84 if (__pName == 0 || __pValue == 0)
89 if (strcasecmp(pName, __pName) == 0)
96 return __pNext->Find(pName);
103 _PackageXmlAttribute::Add(const char* pName, const char* pValue)
105 if (pName == 0 || pValue == 0)
112 _PackageXmlAttribute* pNext = __pNext;
113 while (pNext->__pNext)
115 pNext = pNext->__pNext;
118 return pNext->Add(pName, pValue);
122 __pNext = new (std::nothrow) _PackageXmlAttribute();
123 SysTryReturn(NID_APP, __pNext, false, E_OUT_OF_MEMORY, "__pNext is null.");
125 __pNext->Construct(pName, pValue);
132 _PackageXmlHandler::_PackageXmlHandler(void)
134 ,__pElementName(null)
140 _PackageXmlHandler::~_PackageXmlHandler(void)
145 delete[] __pElementName;
146 __pElementName = null;
150 _PackageXmlHandler::OnStartDocument(void)
156 _PackageXmlHandler::OnEndDocument(void)
162 _PackageXmlHandler::OnStartElement(const char* pName)
168 _PackageXmlHandler::OnEndElement(const char* pName)
174 _PackageXmlHandler::OnCharacters(const char* pCharacters)
180 _PackageXmlHandler::StartElement(void* pCtx, const xmlChar* pName, const xmlChar** ppAtts)
187 _PackageXmlHandler* pHandler = null;
188 pHandler = (_PackageXmlHandler*) pCtx;
189 bool xmlResult = false;
191 pHandler->SetElementName((const char *) pName);
195 _PackageXmlAttribute* pAttr = 0;
197 if (ppAtts[0] != null && ppAtts[1] != null)
199 pAttr = new (std::nothrow) _PackageXmlAttribute();
200 SysTryReturnVoidResult(NID_APP, pAttr, E_OUT_OF_MEMORY, "pAttr is null.");
202 pAttr->Construct((const char *)ppAtts[0], (const char *)ppAtts[1]);
206 while (ppAtts != null && ppAtts[0] != null && ppAtts[1] != null)
208 pAttr->Add((const char *)ppAtts[0], (const char *)ppAtts[1]);
212 pHandler->SetAttribute(pAttr);
215 xmlResult = pHandler->OnStartElement((const char *)pName);
216 if (xmlResult == false)
218 pHandler->SetError();
223 _PackageXmlHandler::EndElement(void* pCtx, const xmlChar* pName)
225 _PackageXmlHandler* pHandler = null;
226 pHandler = (_PackageXmlHandler*) pCtx;
227 bool xmlResult = false;
228 char* pCharacters = pHandler->GetCharacters();
230 if (pCharacters && (strlen(pCharacters) > 0))
232 xmlResult = pHandler->OnCharacters(pCharacters);
233 if (xmlResult == false)
235 pHandler->SetError();
239 xmlResult = pHandler->OnEndElement((const char *)pName);
240 if (xmlResult == false)
242 pHandler->SetError();
245 pHandler->DeleteElement();
246 pHandler->DeleteAttribute();
247 pHandler->DeleteCharacters();
251 _PackageXmlHandler::Characters(void* pCtx, const xmlChar* pCh, int len)
253 SysTryReturnVoidResult(NID_APP, pCh, E_SYSTEM, "pCh is null.");
255 _PackageXmlHandler* pHandler = null;
256 pHandler = (_PackageXmlHandler*) pCtx;
257 char* pCharacters = null;
259 if (pCh[0] == 0x20 || pCh[0] == 0x09 || pCh[0] == 0x0D || pCh[0] == 0x0A)
264 pCharacters = new (std::nothrow) char[len+1];
265 SysTryReturnVoidResult(NID_APP, pCharacters, E_OUT_OF_MEMORY, "pCharacters is null.");
267 strncpy(pCharacters, (const char *)pCh, len);
268 pCharacters[len] = 0;
270 pHandler->SetCharacters(pCharacters);
272 delete[] pCharacters;
276 _PackageXmlHandler::ParseNormalizedDocument(const char* pFilepath)
278 xmlSAXHandler* pSAXHandler = null;
279 xmlParserCtxtPtr ctxt = 0;
283 result r = E_SUCCESS;
285 char* pNormalizedBuf = null;
287 int normalizedSize = 0;
290 r = file.Construct(pFilepath, L"r");
291 TryCatch(r == E_SUCCESS, ret = false, "file.Construct is failed. [%s]", pFilepath);
293 r = file.GetAttributes(pFilepath, attr);
294 TryCatch(IsFailed(r) == false, ret = false, "file.GetAttributes is failed. [%s]", pFilepath);
296 size = (int)attr.GetFileSize();
297 TryCatch(size > 0, ret = false, "size is invalid. [%s]", pFilepath);
299 pBuf = new (std::nothrow) char[size+1];
300 TryCatch(pBuf, ret = false, "pBuf is null.");
302 pNormalizedBuf = new (std::nothrow) char[size+1];
303 TryCatch(pNormalizedBuf, ret = false, "pNormalizedBuf is null.");
305 memset(pBuf, 0, size+1);
306 memset(pNormalizedBuf, 0, size+1);
308 readSize = file.Read(pBuf, size);
309 TryCatch(readSize > 0, ret = false, "file.Read is failed. [%s][%d]", pFilepath, readSize);
311 normalizedSize = Normalize(pBuf, size, pNormalizedBuf);
312 TryCatch(normalizedSize > 0, ret = false, "normalizedSize [%d]", readSize);
314 ctxt = xmlCreateMemoryParserCtxt(pNormalizedBuf, normalizedSize);
315 TryCatch(ctxt, ret = false, "invalid xml file, %s", pFilepath);
317 pSAXHandler = new (std::nothrow) xmlSAXHandler;
318 TryCatch(pSAXHandler, ret = false, "pSAXHandler is null.");
319 memset(pSAXHandler, 0, sizeof(xmlSAXHandler));
321 ctxt->userData = (void *)this;
323 pSAXHandler->startElement = _PackageXmlHandler::StartElement;
324 pSAXHandler->endElement = _PackageXmlHandler::EndElement;
325 pSAXHandler->characters = _PackageXmlHandler::Characters;
327 ctxt->sax = pSAXHandler;
329 xmlParseDocument(ctxt);
330 xmlFreeParserCtxt(ctxt);
332 TryCatch(GetError() != true, ret = false, "xml parsing error is occurred.");
336 delete[] pNormalizedBuf;
342 _PackageXmlHandler::Normalize(const char* pBuf, int size, char* pNormalizedBuf)
345 int normalizedIdx = 0;
347 while (pBuf[idx] && idx < size)
349 if (pBuf[idx] == 0x0D)
351 if (pBuf[idx + 1] == 0x0A)
355 pNormalizedBuf[normalizedIdx] = 0x0A;
358 else if((pBuf[idx] == 0X0A) && (pBuf[idx + 1] == 0x4d) && (pBuf[idx - 1] == 0x3E))
361 pNormalizedBuf[normalizedIdx] = pBuf[idx];
366 pNormalizedBuf[normalizedIdx] = pBuf[idx];
373 return normalizedIdx;
377 _PackageXmlHandler::SetElementName(const char* pElementName)
379 SysTryReturn(NID_APP, pElementName, false, E_SYSTEM, "pElementName is null.");
383 delete[] __pElementName;
384 __pElementName = null;
387 __pElementName = new (std::nothrow) char[strlen(pElementName)+1];
388 SysTryReturn(NID_APP, __pElementName, false, E_OUT_OF_MEMORY, "__pElementName is null.");
389 strcpy(__pElementName, pElementName);
391 __elementStack.Push(*new (std::nothrow) String(pElementName));
397 _PackageXmlHandler::GetElementName(void)
399 return __pElementName;
403 _PackageXmlHandler::DeleteElement(void)
405 delete[]__pElementName;
408 __elementStack.Pop();
412 _PackageXmlHandler::SetCharacters(const char* pCharacter)
414 SysTryReturn(NID_APP, pCharacter, false, E_SYSTEM, "pCharacter is null.");
416 if (__pCharacters == null)
418 __pCharacters = new (std::nothrow) char[4096];
419 SysTryReturn(NID_APP, __pCharacters, false, E_OUT_OF_MEMORY, "__pCharacters is null.");
421 memset(__pCharacters, 0, 4096);
424 strncat(__pCharacters, pCharacter, strlen(pCharacter));
430 _PackageXmlHandler::GetCharacters(void)
432 return __pCharacters;
436 _PackageXmlHandler::DeleteCharacters(void)
438 delete[] __pCharacters;
439 __pCharacters = null;
443 _PackageXmlHandler::SetAttribute(_PackageXmlAttribute* pAttr)
448 _PackageXmlAttribute*
449 _PackageXmlHandler::GetAttribute(void)
455 _PackageXmlHandler::DeleteAttribute(void)
462 _PackageXmlHandler::GetElementEnumeratorN(void)
464 return __elementStack.GetEnumeratorN();
468 _PackageXmlHandler::GetElementCount(void)
470 return __elementStack.GetCount();
474 _PackageXmlHandler::SetError(void)
480 _PackageXmlHandler::GetError(void)
486 _PackageParser::_PackageParser(void)
487 :__pPackageInfoImpl(null)
489 ,__pDefaultIconType(null)
490 ,__isDefaultName(false)
495 _PackageParser::~_PackageParser(void)
497 delete[] __pDefaultIconType;
498 __pDefaultIconType = null;
502 _PackageParser::Construct(PackageInfo* pPackageInfo)
504 SysTryReturn(NID_APP, pPackageInfo, false, E_INVALID_ARG, "pPackageInfo is null.");
506 _PackageInfoImpl* pPackageInfoImpl = _PackageInfoImpl::GetInstance(pPackageInfo);
507 SysTryReturn(NID_APP, pPackageInfoImpl, false, E_SYSTEM, "pPackageInfoImpl is null.");
509 __pPackageInfoImpl = pPackageInfoImpl;
514 _PackageParser::Parse(const String& packagepath)
516 __packagePath = packagepath;
519 FileUnzipper unzipper;
521 Directory::Remove("/tmp/__manifest/", true);
522 Directory::Create("/tmp/__manifest/", false);
524 result r = unzipper.Construct(packagepath);
525 SysTryReturn(NID_APP, !IsFailed(r), false, E_SYSTEM, "unzipper.Construct() failed.");
527 r = unzipper.UnzipTo(L"/tmp/__manifest", L"info/manifest.xml");
528 SysTryReturn(NID_APP, !IsFailed(r), false, E_SYSTEM, "unzipper.UnzipTo() failed.");
530 res = ParseNormalizedDocument("/tmp/__manifest/info/manifest.xml");
532 Directory::Remove("/tmp/__manifest/", true);
538 _PackageParser::OnStartElement(const char* pName)
540 SysTryReturn(NID_APP, pName, true, E_SYSTEM, "pName is null.");
544 if (strcasecmp(pName, "UiApp") == 0)
546 status = OnUiAppStartElement();
548 else if (strcasecmp(pName, "ServiceApp") == 0)
550 status = OnServiceAppStartElement();
552 else if (strcasecmp(pName, "Icons") == 0)
554 status = OnIconsStartElement();
566 _PackageParser::OnEndElement(const char* pName)
568 SysTryReturn(NID_APP, pName, true, E_SYSTEM, "pName is null.");
572 if (strcasecmp(pName, "UiApp") == 0)
574 status = OnUiAppEndElement();
576 else if (strcasecmp(pName, "ServiceApp") == 0)
578 status = OnServiceAppEndElement();
580 else if (strcasecmp(pName, "DisplayNames") == 0)
582 status = OnDisplayNamesEndElement();
594 _PackageParser::OnCharacters(const char* pCharacters)
598 char* pName = GetElementName();
599 SysTryReturn(NID_APP, pName, false, E_SYSTEM, "pName is null.");
601 if (strcasecmp(pName, "Id") == 0)
603 status = OnIdValue(pCharacters);
605 else if (strcasecmp(pName, "Version") == 0)
607 status = OnVersionValue(pCharacters);
609 else if (strcasecmp(pName, "Url") == 0)
611 status = OnUrlValue(pCharacters);
613 else if (strcasecmp(pName, "Privilege") == 0)
615 status = OnPrivilegeValue(pCharacters);
617 else if (strcasecmp(pName, "DisplayName") == 0)
619 status = OnDisplayNameValue(pCharacters);
621 else if (strcasecmp(pName, "Author") == 0)
623 status = OnAuthorValue(pCharacters);
625 else if (strcasecmp(pName, "Description") == 0)
627 status = OnDescriptionValue(pCharacters);
629 else if (strcasecmp(pName, "Icon") == 0)
631 status = OnIconValue(pCharacters);
633 else if (strcasecmp(pName, "Category") == 0)
635 status = OnCategoryValue(pCharacters);
647 _PackageParser::OnUiAppStartElement(void)
649 __pAppInfo = new (std::nothrow) PackageAppInfo;
650 SysTryReturn(NID_APP, __pAppInfo, false, E_OUT_OF_MEMORY, "__pAppInfo is null.");
652 _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
653 SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
655 _PackageXmlAttribute* pAttr = GetAttribute();
656 SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null.");
658 ParseAppAttribute(pAttr, true);
664 _PackageParser::OnServiceAppStartElement(void)
666 __pAppInfo = new (std::nothrow) PackageAppInfo;
667 SysTryReturn(NID_APP, __pAppInfo, false, E_OUT_OF_MEMORY, "__pAppInfo is null.");
669 _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
670 SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
672 _PackageXmlAttribute* pAttr = GetAttribute();
673 SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null.");
675 ParseAppAttribute(pAttr, false);
681 _PackageParser::OnIconsStartElement(void)
685 String defaultIconType;
687 res = system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_WIDTH, &width);
688 if (res != SYSTEM_INFO_ERROR_NONE)
690 SysLog(NID_APP, "system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_WIDTH) failed. res = [%d]", res);
691 defaultIconType = L"Xhigh";
697 defaultIconType = L"High";
701 defaultIconType = L"Xhigh";
705 __pDefaultIconType = _StringConverter::CopyToCharArrayN(defaultIconType);
706 SysTryReturn(NID_APP, __pDefaultIconType, false, E_OUT_OF_MEMORY, "__pDefaultIconType is null.");
708 SysLog(NID_APP, "ScreenWidth = [%d], DefaultIconType = [%s]", width, __pDefaultIconType);
714 _PackageParser::OnUiAppEndElement(void)
716 __pPackageInfoImpl->AddPackageAppInfo(*__pAppInfo);
719 __isDefaultName = false;
725 _PackageParser::OnServiceAppEndElement(void)
727 __pPackageInfoImpl->AddPackageAppInfo(*__pAppInfo);
730 __isDefaultName = false;
736 _PackageParser::OnDisplayNamesEndElement(void)
744 _PackageParser::OnIdValue(const char* pCharacters)
746 SysLog(NID_APP, "Id = [%s]", pCharacters);
747 __pPackageInfoImpl->SetId(pCharacters);
749 RegularExpression regularExpression;
750 String pattern(L"([a-zA-Z0-9]{10})");
751 result r = regularExpression.Construct(pattern);
752 SysTryReturn(NID_APP, !IsFailed(r), false, E_SYSTEM, "regularExpression.Construct() failed.");
754 PackageId packageId = pCharacters;
755 if (regularExpression.Match(packageId, true) == true)
757 SysLog(NID_APP, "[%ls] is tizen native application.", packageId.GetPointer());
761 SysLog(NID_APP, "[%ls] is not tizen native application.", packageId.GetPointer());
769 _PackageParser::OnVersionValue(const char* pCharacters)
771 SysLog(NID_APP, "Version = [%s]", pCharacters);
772 __pPackageInfoImpl->SetVersion(pCharacters);
778 _PackageParser::OnAuthorValue(const char* pCharacters)
780 SysLog(NID_APP, "Author = [%s]", pCharacters);
781 __pPackageInfoImpl->SetAuthor(pCharacters);
787 _PackageParser::OnUrlValue(const char* pCharacters)
789 SysLog(NID_APP, "Url = [%s]", pCharacters);
790 __pPackageInfoImpl->SetUrl(pCharacters);
796 _PackageParser::OnPrivilegeValue(const char* pCharacters)
798 SysLog(NID_APP, "Privilege = [%s]", pCharacters);
799 __pPackageInfoImpl->AddPrivilege(*new (std::nothrow) String(pCharacters));
805 _PackageParser::OnIconValue(const char* pCharacters)
807 SysTryReturn(NID_APP, __pDefaultIconType, false, E_SYSTEM, "__pDefaultIconType is null.");
809 _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
810 SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
812 _PackageXmlAttribute* pAttr = GetAttribute();
813 SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null.");
815 if ((FindElement("Accounts") == true) || (FindElement("AppWidgets") == true))
817 AppLog("Skip icon value.");
822 AppLog("It's icon value for UiApp, ServiceApp");
825 char* pSection = pAttr->Find("Section");
826 SysTryReturn(NID_APP, pSection, true, E_SYSTEM, "pSection is null.");
831 if (strcasecmp(__pDefaultIconType, "Xhigh") == 0)
833 iconRelPath.Format(1024, L"shared/res/screen-density-xhigh/%s", pCharacters);
835 else if (strcasecmp(__pDefaultIconType, "High") == 0)
837 iconRelPath.Format(1024, L"shared/res/screen-density-high/%s", pCharacters);
841 SysTryReturn(NID_APP, 0, false, E_SYSTEM, "Invalid __pDefaultIconType [%s]", __pDefaultIconType);
844 if (strcasecmp(pSection, "MainMenu") == 0)
846 FileUnzipper unzipper;
847 String tmp(L"/tmp/__icon/");
848 Directory::Remove(tmp, true);
849 Directory::Create(tmp, false);
851 result r = unzipper.Construct(__packagePath);
852 SysTryReturn(NID_APP, !IsFailed(r), false, E_SYSTEM, "unzipper.Construct() failed.");
855 r = unzipper.GetEntry(iconRelPath, entry);
858 AppLog("fallback, old path = [%ls]", iconRelPath.GetPointer());
860 String densityXhigh("screen-density-xhigh/");
861 String densityHigh("screen-density-high/");
863 if (iconRelPath.Contains(densityXhigh) == true)
865 iconRelPath.Replace(densityXhigh, densityHigh);
867 else if (iconRelPath.Contains(densityHigh) == true)
869 iconRelPath.Replace(densityHigh, densityXhigh);
873 AppLog("invalid icon [%ls]", iconRelPath.GetPointer());
877 AppLog("fallback, new path = [%ls]", iconRelPath.GetPointer());
880 r = unzipper.UnzipTo(tmp, iconRelPath);
883 result r = E_SUCCESS;
885 tempIconPath = tmp + iconRelPath;
887 r = file.Construct(tempIconPath, "r");
891 file.GetAttributes(tempIconPath, attr);
892 int size = (int)attr.GetFileSize();
894 char* pBuffer = new (std::nothrow) char[size];
895 SysTryReturn(NID_APP, pBuffer, false, E_OUT_OF_MEMORY, "pBuffer is null.");
897 memset(pBuffer, 0, size);
898 file.Read((void*)pBuffer, size);
900 pPackageAppInfoImpl->SetAppMenuIconBuffer(pBuffer, size);
902 Directory::Remove(tmp, true);
907 SysLog(NID_APP, "file.Construct(%ls) failed.", tempIconPath.GetPointer());
912 SysLog(NID_APP, "UnzipTo(%ls) is failed.", iconRelPath.GetPointer());
916 SysLog(NID_APP, "Section = [%s], Icon = [%ls], TempIcon = [%ls]", pSection, iconRelPath.GetPointer(), tempIconPath.GetPointer());
922 _PackageParser::OnDisplayNameValue(const char* pCharacters)
924 _PackageXmlAttribute* pAttr = 0;
925 char* pAttrValue = 0;
927 _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
928 SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
930 pAttr = GetAttribute();
931 SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null");
933 if ((FindElement("Accounts") == true) || (FindElement("AppWidgets") == true))
935 AppLog("Skip display name.");
940 AppLog("It's display name for UiApp, ServiceApp");
943 pAttrValue = pAttr->Find("Locale");
944 SysTryReturn(NID_APP, pAttrValue, true, E_SYSTEM, "pAttrValue is null");
946 if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
948 pPackageAppInfoImpl->SetAppDisplayName(pCharacters);
950 if (__isDefaultName == true)
952 __pPackageInfoImpl->SetDisplayName(pCharacters);
956 String* pValue = new (std::nothrow) String;
957 StringUtil::Utf8ToString(pCharacters, *pValue);
959 pPackageAppInfoImpl->AddName(*(new (std::nothrow) String(pAttrValue)), *pValue);
961 SysLog(NID_APP, "DisplayName Locale = [%s][%s]", pAttrValue, pCharacters);
967 _PackageParser::OnDescriptionValue(const char* pCharacters)
969 _PackageXmlAttribute *pAttr = 0;
970 char *pAttrValue = 0;
972 pAttr = GetAttribute();
973 SysTryReturn(NID_APP, pAttr, true, E_SYSTEM, "pAttr is null");
975 pAttrValue = pAttr->Find("Locale");
976 SysTryReturn(NID_APP, pAttrValue, true, E_SYSTEM, "pAttrValue is null");
978 if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
980 __pPackageInfoImpl->SetDescription(pCharacters);
983 SysLog(NID_APP, "Description Locale =[%s][%s]", pAttrValue, pCharacters);
989 _PackageParser::OnCategoryValue(const char* pCharacters)
991 _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
992 SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
994 pPackageAppInfoImpl->AddCategory(new (std::nothrow) String(pCharacters));
996 SysLog(NID_APP, "Category = [%s]", pCharacters);
1002 _PackageParser::ParseAppAttribute(_PackageXmlAttribute* pAttr, bool isUiApp)
1004 _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(__pAppInfo);
1005 SysTryReturn(NID_APP, pPackageAppInfoImpl, false, E_SYSTEM, "pPackageAppInfoImpl is null.");
1007 char* pName = pAttr->Find("Name");
1008 SysTryReturn(NID_APP, pName, true, E_SYSTEM, "pName is null");
1010 SysLog(NID_APP, "Name = [%s]", pName);
1011 pPackageAppInfoImpl->SetAppName(pName);
1013 AppId appId = __pPackageInfoImpl->GetId() + L"." + pName;
1014 if (__isEflTpk == false)
1016 pPackageAppInfoImpl->SetAppId(appId);
1020 pPackageAppInfoImpl->SetAppId(__pPackageInfoImpl->GetId());
1023 char* pMain = pAttr->Find("Main");
1026 SysLog(NID_APP, "Main = [%s]", pMain);
1027 if (strcasecmp(pMain, "True") == 0)
1029 __isDefaultName = true;
1030 if (__isEflTpk == false)
1032 __pPackageInfoImpl->SetMainAppId(appId);
1036 __pPackageInfoImpl->SetMainAppId(__pPackageInfoImpl->GetId());
1038 pPackageAppInfoImpl->SetMainApp(true);
1042 if (isUiApp == true)
1044 char* pMenuIconVisible = pAttr->Find("MenuIconVisible");
1045 if (pMenuIconVisible)
1047 if (strcasecmp(pMenuIconVisible, "True") == 0)
1049 pPackageAppInfoImpl->SetMenuIconVisible(true);
1053 pPackageAppInfoImpl->SetMenuIconVisible(false);
1056 SysLog(NID_APP, "MenuIconVisible = [%s]", pMenuIconVisible);
1061 pPackageAppInfoImpl->SetMenuIconVisible(false);
1068 _PackageParser::FindElement(const char* pName)
1071 IEnumerator* pEnum = GetElementEnumeratorN();
1075 while(pEnum->MoveNext() == E_SUCCESS)
1077 String* pStr = static_cast< String* >(pEnum->GetCurrent());
1080 if (pStr->Equals(pName, false) == true)
1082 AppLog("[%s] is matched.", pName);
1095 } } } // Tizen::App::Package