2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file ManifestHandler.cpp
19 * @brief This is the implementation file for %ManifestHandler class.
22 #include <system_info.h>
25 #include <FBase_StringConverter.h>
27 #include "ManifestHandler.h"
28 #include "PrivilegeHandler.h"
29 #include "InstallerUtil.h"
30 #include "ManifestLiveboxesParser.h"
31 #include "ManifestAccountsParser.h"
32 #include "ManifestAppControlsParser.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Utility;
37 using namespace Tizen::App;
38 using namespace Tizen::Io;
40 ManifestHandler::ManifestHandler(void)
42 ,__pPrivilegeList(null)
43 ,__pContentDataList(null)
44 ,__pAppControlInfoImpl(null)
45 ,__pAppControlCapabilityInfoImpl(null)
46 ,__pAppControlResolutionInfoImpl(null)
47 ,__pDataControlInfo(null)
48 ,__pDataControlType(null)
50 ,__pDefaultIconType(null)
51 ,__isDefaultMainmenu(false)
52 ,__isDefaultSetting(false)
53 ,__isDefaultTicker(false)
54 ,__isDefaultQuickpanel(false)
55 ,__isDefaultLaunchImage(false)
56 ,__isDefaultName(false)
57 ,__isDefaultAppDetected(false)
58 ,__isInternalStorage(false)
60 ,__isParserMode(false)
65 ManifestHandler::~ManifestHandler(void)
67 delete[] __pDefaultIconType;
68 __pDefaultIconType = null;
72 ManifestHandler::Construct(InstallationContext* pContext)
74 __pContext = pContext;
80 ManifestHandler::GetContext(void)
86 ManifestHandler::Parse(const char *pFilepath)
88 return ParseDocument(pFilepath);
92 ManifestHandler::OnStartElement(const char *pName)
94 TryReturn(pName, true, "pName is null.");
98 if (__isParserMode == true)
100 TryReturn(__pParser, false, "__pParser is null");
101 return __pParser->OnStartElement(pName);
104 if (strcasecmp(pName, "Manifest") == 0)
106 AppLog("------------------------------------------");
107 AppLog("manifest.xml");
108 AppLog("------------------------------------------");
109 AppLog("<%s>", pName);
111 else if (strcasecmp(pName, "Apps") == 0)
113 AppLog("<%s>", pName);
115 else if (strcasecmp(pName, "UiApp") == 0)
117 status = OnUiAppStartElement();
119 else if (strcasecmp(pName, "ServiceApp") == 0)
121 status = OnServiceAppStartElement();
123 else if (strcasecmp(pName, "DataControl") == 0)
125 status = OnDataControlStartElement();
127 else if (strcasecmp(pName, "Privileges") == 0)
129 status = OnPrivilegesStartElement();
131 else if (strcasecmp(pName, "UiScalability") == 0)
133 status = OnUiScalabilityStartElement();
135 else if (strcasecmp(pName, "UiTheme") == 0)
137 status = OnUiThemeStartElement();
139 else if (strcasecmp(pName, "Icons") == 0)
141 status = OnIconsStartElement();
143 else if (strcasecmp(pName, "Contents") == 0)
145 status = OnContentsStartElement();
147 else if (strcasecmp(pName, "Content") == 0)
149 status = OnContentStartElement();
151 else if (strcasecmp(pName, "Metadata") == 0)
153 status = OnMetadataStartElement();
155 else if ((strcasecmp(pName, "Liveboxes") == 0) || strcasecmp(pName, "AppWidgets") == 0)
157 status = OnLiveboxesStartElement(pName);
159 else if (strcasecmp(pName, "Accounts") == 0)
161 status = OnAccountsStartElement(pName);
163 else if (strcasecmp(pName, "AppControls") == 0)
165 status = OnAppControlsStartElement(pName);
167 else if (strcasecmp(pName, "Permission") == 0)
169 status = OnPermissionStartElement(pName);
171 else if (strcasecmp(pName, "DirectoryConfig") == 0)
173 status = OnDirectoryConfigStartElement();
175 else if (strcasecmp(pName, "SymbolicLink") == 0)
177 status = OnSymbolicLinkStartElement();
182 __isParserMode = false;
190 ManifestHandler::OnEndElement(const char *pName)
192 TryReturn(pName, true, "pName is null.");
196 if (__isParserMode == true)
198 TryReturn(__pParser, false, "__pParser is null");
199 __pParser->OnEndElement(pName);
201 if ((strcasecmp(pName, "Liveboxes") == 0) || strcasecmp(pName, "AppWidgets") == 0)
203 status = OnLiveboxesEndElement();
205 else if (strcasecmp(pName, "Accounts") == 0)
207 status = OnAccountsEndElement();
209 else if (strcasecmp(pName, "AppControls") == 0)
211 status = OnAppControlsEndElement();
217 if (strcasecmp(pName, "Privileges") == 0)
219 status = OnPrivilegesEndElement();
221 else if (strcasecmp(pName, "UiApp") == 0)
223 status = OnUiAppEndElement();
225 else if (strcasecmp(pName, "ServiceApp") == 0)
227 status = OnServiceAppEndElement();
229 else if (strcasecmp(pName, "DataControl") == 0)
231 status = OnDataControlEndElement();
233 else if (strcasecmp(pName, "DataControlType") == 0)
235 status = OnDataControlTypeEndElement();
237 else if (strcasecmp(pName, "Apps") == 0)
239 status = OnAppsEndElement();
241 else if (strcasecmp(pName, "UiScalability") == 0)
243 AppLog("</%s>", pName);
245 else if (strcasecmp(pName, "Icons") == 0)
247 status = OnIconsEndElement();
249 else if (strcasecmp(pName, "Contents") == 0)
251 status = OnContentsEndElement();
253 else if (strcasecmp(pName, "Content") == 0)
255 status = OnContentEndElement();
257 else if (strcasecmp(pName, "Metadata") == 0)
259 status = OnMetadataEndElement();
261 else if (strcasecmp(pName, "Manifest") == 0)
263 status = OnManifestEndElement();
275 ManifestHandler::OnCharacters(const char *pCharacters)
279 char* pName = GetElementName();
280 TryReturn(pName, true, "pName is null.");
282 if (__isParserMode == true)
284 TryReturn(__pParser, false, "__pParser is null");
285 return __pParser->OnCharacters(pCharacters);
288 if (strcasecmp(pName, "Id") == 0)
290 status = OnIdValue(pCharacters);
292 else if (strcasecmp(pName, "Version") == 0)
294 status = OnVersionValue(pCharacters);
296 else if (strcasecmp(pName, "Type") == 0)
298 status = OnTypeValue(pCharacters);
300 else if (strcasecmp(pName, "Url") == 0)
302 status = OnUrlValue(pCharacters);
304 else if (strcasecmp(pName, "ApiVersion") == 0)
306 status = OnApiVersionValue(pCharacters);
308 else if (strcasecmp(pName, "Privilege") == 0)
310 status = OnPrivilegeValue(pCharacters);
312 else if (strcasecmp(pName, "Name") == 0)
314 status = OnNameValue(pCharacters);
316 else if (strcasecmp(pName, "DisplayName") == 0)
318 status = OnNameValue(pCharacters);
320 else if (strcasecmp(pName, "Author") == 0)
322 status = OnAuthorValue(pCharacters);
324 else if (strcasecmp(pName, "Description") == 0)
326 status = OnDescriptionValue(pCharacters);
328 else if (strcasecmp(pName, "Icon") == 0)
330 status = OnIconValue(pCharacters);
332 else if (strcasecmp(pName, "DataControlType") == 0)
334 status = OnDataControlTypeValue(pCharacters);
336 else if (strcasecmp(pName, "Condition") == 0)
338 status = OnConditionValue(pCharacters);
340 else if (strcasecmp(pName, "Notification") == 0)
342 status = OnNotificationValue(pCharacters);
344 else if (strcasecmp(pName, "InstallLocation") == 0)
346 status = OnInstallLocationValue(pCharacters);
348 else if (strcasecmp(pName, "Category") == 0)
350 status = OnCategoryValue(pCharacters);
352 else if (strcasecmp(pName, "Metadata") == 0)
354 status = OnMetadataValue(pCharacters);
366 ManifestHandler::OnPrivilegesStartElement(void)
368 __pPrivilegeList = new (std::nothrow) ArrayList;
369 TryReturn(__pPrivilegeList, false, "__pPrivilegeList is null");
371 AppLog("<Privileges>");
377 ManifestHandler::OnUiAppStartElement(void)
379 __pAppData = new (std::nothrow) AppData;
380 TryReturn(__pAppData, false, "__pAppData is null");
382 InstallerError error = __pAppData->Construct();
383 TryReturn(error == INSTALLER_ERROR_NONE, false, "pAppData->Construct() failed.");
387 XmlAttribute *pAttr = GetAttribute();
388 TryReturn(pAttr, true, "pAttr is null");
390 ParseAppAttribute(pAttr, true);
396 ManifestHandler::OnServiceAppStartElement(void)
398 __pAppData = new (std::nothrow) AppData;
399 TryReturn(__pAppData, false, "__pAppData is null");
401 InstallerError error = __pAppData->Construct();
402 TryReturn(error == INSTALLER_ERROR_NONE, false, "pAppData->Construct() failed.");
404 AppLog("<ServiceApp>");
406 XmlAttribute *pAttr = GetAttribute();
407 TryReturn(pAttr, true, "pAttr is null");
409 ParseAppAttribute(pAttr, false);
415 ManifestHandler::OnIconsStartElement(void)
419 String defaultIconType;
423 res = system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_WIDTH, &width);
424 if (res != SYSTEM_INFO_ERROR_NONE)
426 AppLog("system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_WIDTH) failed. res = [%d]", res);
427 defaultIconType = L"Xhigh";
433 defaultIconType = L"High";
437 defaultIconType = L"Xhigh";
441 AppLog("ScreenWidth = [%d]", width);
443 __pDefaultIconType = _StringConverter::CopyToCharArrayN(defaultIconType);
444 TryReturn(__pDefaultIconType, false, "__pDefaultIconType is null.");
446 AppLog("DefaultIconType = [%s]", __pDefaultIconType);
452 ManifestHandler::OnUiScalabilityStartElement(void)
454 XmlAttribute *pAttr = null;
455 char* pCoordinateSystem = null;
456 char* pBaseScreenSize = null;
457 char* pLogicalCoordinate = null;
459 AppLog("<UiScalability>");
461 pAttr = GetAttribute();
462 TryReturn(pAttr, true, "pAttr is null");
464 pCoordinateSystem = pAttr->Find("CoordinateSystem");
465 if (pCoordinateSystem)
467 String* pKey = new (std::nothrow) String("CoordinateSystem");
468 TryReturn(pKey, false, "pKey is null");
469 String* pValue = new (std::nothrow) String(pCoordinateSystem);
470 TryReturn(pValue, false, "pValue is null");
472 __pAppData->__pFeatureList->Add(pKey, pValue);
473 AppLog("<CoordinateSystem=%s>", pCoordinateSystem);
476 pBaseScreenSize = pAttr->Find("BaseScreenSize");
479 String* pKey = new (std::nothrow) String("BaseScreenSize");
480 TryReturn(pKey, false, "pKey is null");
481 String* pValue = new (std::nothrow) String(pBaseScreenSize);
482 TryReturn(pValue, false, "pValue is null");
484 __pAppData->__pFeatureList->Add(pKey, pValue);
485 AppLog("<BaseScreenSize=%s>", pBaseScreenSize);
488 pLogicalCoordinate = pAttr->Find("LogicalCoordinate");
489 if (pLogicalCoordinate)
491 String* pKey = new (std::nothrow) String("LogicalCoordinate");
492 TryReturn(pKey, false, "pKey is null");
493 String* pValue = new (std::nothrow) String(pLogicalCoordinate);
494 TryReturn(pValue, false, "pValue is null");
496 __pAppData->__pFeatureList->Add(pKey, pValue);
497 AppLog("<LogicalCoordinate=%s>", pLogicalCoordinate);
504 ManifestHandler::OnUiThemeStartElement(void)
506 XmlAttribute *pAttr = null;
507 char *pSystemTheme = null;
508 char *pUserDefinedTheme = null;
512 pAttr = GetAttribute();
513 TryReturn(pAttr, true, "pAttr is null");
515 pSystemTheme = pAttr->Find("SystemTheme");
518 String* pKey = new (std::nothrow) String("SystemTheme");
519 TryReturn(pKey, false, "pKey is null");
520 String* pValue = new (std::nothrow) String(pSystemTheme);
521 TryReturn(pValue, false, "pValue is null");
523 __pAppData->__pFeatureList->Add(pKey, pValue);
524 AppLog("<SystemTheme=%s>", pSystemTheme);
527 pUserDefinedTheme = pAttr->Find("UserDefinedTheme");
528 if (pUserDefinedTheme)
530 String* pKey = new (std::nothrow) String("UserDefinedTheme");
531 TryReturn(pKey, false, "pKey is null");
532 String* pValue = new (std::nothrow) String(pUserDefinedTheme);
533 TryReturn(pValue, false, "pValue is null");
535 __pAppData->__pFeatureList->Add(pKey, pValue);
536 AppLog("<UserDefinedTheme=%s>", pUserDefinedTheme);
543 ManifestHandler::OnDataControlStartElement(void)
545 XmlAttribute* pAttr = null;
546 char* pProviderId = null;
548 pAttr = GetAttribute();
549 TryReturn(pAttr, true, "pAttr is null");
551 pProviderId = pAttr->Find("ProviderId");
552 TryReturn(pProviderId, true, "pProviderId is null");
554 __pDataControlInfo = new (std::nothrow) DataControlInfo;
555 TryReturn(__pDataControlInfo, false, "__pDataControlInfo is null");
557 __pDataControlInfo->__providerId = pProviderId;
559 AppLog("<DataControl Provider=\"%s\">", pProviderId);
565 ManifestHandler::OnContentsStartElement(void)
567 __pContentDataList = new (std::nothrow) ArrayList;
568 TryReturn(__pContentDataList, false, "__pContentDataList is null");
570 AppLog("<Contents>");
576 ManifestHandler::OnContentStartElement(void)
578 TryReturn(__pContentData == null, false, "__pContentData is not null");
580 XmlAttribute *pAttr = null;
581 char *pDefault = null;
583 __pContentData = new (std::nothrow) ContentData;
584 TryReturn(__pContentData, false, "__pContentData is null");
586 pAttr = GetAttribute();
587 TryReturn(pAttr, true, "pAttr is null");
589 char* pId = pAttr->Find("Id");
592 __pContentData->SetContentId(pId);
595 char* pEntryName = pAttr->Find("EntryName");
598 __pContentData->SetContentId(pEntryName);
601 pDefault = pAttr->Find("Default");
604 if (strcasecmp(pDefault, "True") == 0)
606 __isDefaultAppDetected = true;
610 AppLog("<Content=\"%s\" EntryName=\"%s\">", pId, pEntryName);
616 ManifestHandler::OnMetadataStartElement()
618 AppLog("<Metadata>");
619 __metadataKey.Clear();
621 XmlAttribute* pAttr = GetAttribute();
622 TryReturn(pAttr, true, "pAttr is null");
624 char* pKey = pAttr->Find("Key");
627 __metadataKey = pKey;
634 ManifestHandler::OnDirectoryConfigStartElement()
636 XmlAttribute* pAttr = GetAttribute();
637 TryReturn(pAttr, true, "pAttr is null.");
639 char* pVirtualRoot = pAttr->Find("VirtualRoot");
640 TryReturn(pVirtualRoot, false, "pVirtualRoot is null.");
642 if (strcasecmp(pVirtualRoot, "true") == 0)
644 __pContext->__isVirtualRoot = true;
647 AppLog("<DirectoryConfig VirtualRoot=\"%s\">", pVirtualRoot);
653 ManifestHandler::OnSymbolicLinkStartElement()
655 XmlAttribute* pAttr = GetAttribute();
656 TryReturn(pAttr, true, "pAttr is null.");
658 char* pSource = pAttr->Find("Source");
659 TryReturn(pSource, false, "pSource is null.");
661 char* pDestination = pAttr->Find("Destination");
662 TryReturn(pDestination, false, "pDestination is null.");
664 __pContext->__pSymbolicLinkList->Add(new (std::nothrow) String(pSource), new (std::nothrow) String(pDestination));
666 AppLog("<SymbolicLink Source=\"%s\", Destination=\"%s\">", pSource, pDestination);
672 ManifestHandler::OnLiveboxesStartElement(const char *pName)
674 __pParser = new (std::nothrow) ManifestLiveboxesParser;
675 TryReturn(__pParser, false, "__pParser is null");
677 __isParserMode = true;
678 AppLog("------------------------------------------");
679 __pParser->Construct(this);
681 return __pParser->OnStartElement(pName);
685 ManifestHandler::OnAccountsStartElement(const char *pName)
687 __pParser = new (std::nothrow) ManifestAccountsParser;
688 TryReturn(__pParser, false, "__pParser is null");
690 __isParserMode = true;
691 AppLog("------------------------------------------");
692 __pParser->Construct(this);
694 return __pParser->OnStartElement(pName);
698 ManifestHandler::OnAppControlsStartElement(const char *pName)
700 __pParser = new (std::nothrow) ManifestAppControlsParser;
701 TryReturn(__pParser, false, "__pParser is null");
703 __isParserMode = true;
704 AppLog("------------------------------------------");
705 __pParser->Construct(this);
707 return __pParser->OnStartElement(pName);
711 ManifestHandler::OnPermissionStartElement(const char* pName)
713 XmlAttribute* pAttr = null;
716 pAttr = GetAttribute();
717 TryReturn(pAttr, true, "pAttr is null.");
719 pType = pAttr->Find("Type");
720 TryReturn(pType, true, "pType is null.");
722 if (__pAppData->__permissionType.IsEmpty() == true)
724 __pAppData->__permissionType = pType;
729 if (__pAppData->__permissionType.Equals(type, true) == false)
731 AppLog("Invalid Permission Type [%ls][%ls]", __pAppData->__permissionType.GetPointer(), type.GetPointer());
736 AppLog("<Permission Type=\"%s\">", pType);
742 ManifestHandler::OnPrivilegesEndElement(void)
744 if (__pContext->__isVerificationMode == false)
746 AppLog("no signature file[%ls]", __pContext->GetSignatureXmlPath().GetPointer());
748 result r = E_SUCCESS;
750 String hmacPrivileges;
751 ArrayList stringPrivilegeList;
752 stringPrivilegeList.Construct(125);
753 PackageId packageId = __pContext->__packageId;
755 if (__pPrivilegeList != null)
757 r = PrivilegeHandler::GenerateCipherPrivilege(packageId, *__pPrivilegeList, privileges, hmacPrivileges, stringPrivilegeList);
758 TryReturn(!IsFailed(r), false, "privMgr.GeneratePrivilegeString() failed");
761 __pContext->__privileges = privileges;
762 __pContext->__hmacPrivileges = hmacPrivileges;
763 __pContext->__pStringPrivilegeList = new ArrayList;
764 __pContext->__pStringPrivilegeList->Construct(stringPrivilegeList);
767 __pContext->SetPrivilegeList(__pPrivilegeList);
769 AppLog("</Privileges>");
775 ManifestHandler::OnUiAppEndElement(void)
777 if (__pAppData->__isSubMode == true)
779 __pAppData->__pSubModeAppControlDataList = __pAppData->__pAppControlDataList;
780 __pAppData->__pAppControlDataList = null;
781 __pAppData->__subModeAppName = __pAppData->__name;
784 __isDefaultName = false;
786 __pContext->__pAppDataList->Add(__pAppData);
795 ManifestHandler::OnServiceAppEndElement(void)
797 if (__pAppData->__isSubMode == true)
799 __pAppData->__pSubModeAppControlDataList = __pAppData->__pAppControlDataList;
800 __pAppData->__pAppControlDataList = null;
801 __pAppData->__subModeAppName = __pAppData->__name;
804 __isDefaultName = false;
806 __pContext->__pAppDataList->Add(__pAppData);
809 AppLog("</ServiceApp>");
811 AppLog("INSTALLATION_STORAGE = [INTERNAL]");
812 __isInternalStorage = true;
818 ManifestHandler::OnAppsEndElement(void)
822 if (__isInternalStorage == true)
824 AppLog("INSTALLATION_STORAGE = [INTERNAL]");
825 __pContext->__storage = INSTALLATION_STORAGE_INTERNAL;
829 if (InstallerUtil::IsDefaultExternalStorage() == true)
831 AppLog("INSTALLATION_STORAGE = [EXTERNAL]");
832 __pContext->__storage = INSTALLATION_STORAGE_EXTERNAL;
840 ManifestHandler::OnIconsEndElement(void)
848 ManifestHandler::OnDataControlEndElement(void)
850 __pAppData->__pDataControlList->Add(__pDataControlInfo);
851 __pDataControlInfo = null;
852 AppLog("</DataControl>");
858 ManifestHandler::OnDataControlTypeEndElement(void)
860 __pDataControlInfo->__pControlTypeList->Add(__pDataControlType);
861 __pDataControlType = null;
862 AppLog("</DataControlType>");
868 ManifestHandler::OnContentsEndElement(void)
870 __pContext->SetContentDataList(__pContentDataList);
871 __pContentDataList = null;
872 AppLog("</Contents>");
878 ManifestHandler::OnContentEndElement(void)
880 __pContentDataList->Add(*__pContentData);
881 __pContentData = null;
882 AppLog("</Content>");
888 ManifestHandler::OnMetadataEndElement(void)
890 AppLog("</Metadata>");
892 if (__metadataKey.IsEmpty() == false)
894 __pAppData->__pMetadataMap->Add(*(new (std::nothrow) String(__metadataKey)), *(new (std::nothrow) String(L"")));
895 __metadataKey.Clear();
902 ManifestHandler::OnLiveboxesEndElement(void)
905 __isParserMode = false;
906 AppLog("------------------------------------------");
912 ManifestHandler::OnAccountsEndElement(void)
915 __isParserMode = false;
916 AppLog("------------------------------------------");
922 ManifestHandler::OnAppControlsEndElement(void)
925 __isParserMode = false;
926 AppLog("------------------------------------------");
932 ManifestHandler::OnManifestEndElement(void)
934 TryReturn(__isDefaultAppDetected, false, "[osp-installer][Error] Main tag is not detected...");
935 AppLog("</Manifest>");
941 ManifestHandler::OnIdValue(const char* pCharacters)
943 AppLog("<Package>%s</Package>", pCharacters);
945 if (__pContext->__packageId.IsEmpty() == true)
947 __pContext->__packageId = pCharacters;
951 String id(pCharacters);
952 if (__pContext->__packageId != id)
954 AppLog("input package = [%ls], manifest = [%s] is different.", __pContext->__packageId.GetPointer(), pCharacters);
959 AppLog("input package = [%ls], manifest = [%s] is the same.", __pContext->__packageId.GetPointer(), pCharacters);
967 ManifestHandler::OnVersionValue(const char* pCharacters)
969 AppLog("<Version>%s</Version>", pCharacters);
970 __pContext->__version = pCharacters;
976 ManifestHandler::OnTypeValue(const char* pCharacters)
978 AppLog("<Type>%s</Type>", pCharacters);
980 if (strcasecmp(pCharacters, "Contents") == 0)
982 __pContext->__apiVersion = L"3.0";
989 ManifestHandler::OnAuthorValue(const char* pCharacters)
991 AppLog("<Author>%s</Author>", pCharacters);
992 __pContext->__author = pCharacters;
998 ManifestHandler::OnUrlValue(const char* pCharacters)
1000 __pContext->__url = pCharacters;
1001 AppLog("<Url>%s</Url>", pCharacters);
1007 ManifestHandler::OnApiVersionValue(const char* pCharacters)
1009 __pContext->__apiVersion = pCharacters;
1010 AppLog("<ApiVersion>%s</ApiVersion>", pCharacters);
1012 XmlAttribute *pAttr = GetAttribute();
1015 char* pOspCompat = pAttr->Find("OspCompat");
1018 AppLog(" - OspCompat=%s", pOspCompat);
1019 __pContext->__isOspCompat = true;
1021 AppLog("INSTALLATION_STORAGE = [INTERNAL]");
1022 __isInternalStorage = true;
1030 ManifestHandler::OnPrivilegeValue(const char* pCharacters)
1032 __pPrivilegeList->Add(*new (std::nothrow) String(pCharacters));
1033 AppLog("<Privilege>%s</Privilege>", pCharacters);
1039 ManifestHandler::OnIconValue(const char* pCharacters)
1041 AppLog("<Icon>%s</Icon>", pCharacters);
1043 XmlAttribute* pAttr = GetAttribute();
1044 TryReturn(pAttr, true, "pAttr is null");
1046 char* pSection = pAttr->Find("Section");
1047 TryReturn(pSection, true, "pSection is null");
1048 AppLog(" - Section=%s", pSection);
1050 TryReturn(__pDefaultIconType, false, "__pDefaultIconType is null");
1053 char* pType = pAttr->Find("Type");
1056 AppLog("__pDefaultIconType=%s", __pDefaultIconType);
1057 if (strcasecmp(__pDefaultIconType, "Xhigh") == 0)
1059 iconRelPath.Format(1024, L"screen-density-xhigh/%s", pCharacters);
1061 else if (strcasecmp(__pDefaultIconType, "High") == 0)
1063 iconRelPath.Format(1024, L"screen-density-high/%s", pCharacters);
1067 TryReturn(0, false, "Invalid __pDefaultIconType[%s]", __pDefaultIconType);
1072 AppLog(" - Type=%s", pType);
1073 if (strcasecmp(pType, "Xhigh") == 0)
1075 iconRelPath.Format(1024, L"screen-density-xhigh/%s", pCharacters);
1077 else if (strcasecmp(pType, "High") == 0)
1079 iconRelPath.Format(1024, L"screen-density-high/%s", pCharacters);
1083 TryReturn(0, false, "Invalid IconType [%s]", __pDefaultIconType);
1087 if (FindElement("Content") == true)
1089 TryReturn(__pContentData, false, "__pContentData is null");
1090 __pContentData->SetIcon(iconRelPath);
1096 if (strcasecmp(pSection, "MainMenu") == 0)
1098 __pAppData->__menuIcon = iconRelPath;
1100 else if (strcasecmp(pSection, "Setting") == 0)
1102 __pAppData->__settingIcon = iconRelPath;
1104 else if (strcasecmp(pSection, "Notification") == 0)
1106 __pAppData->__notificationIcon = iconRelPath;
1111 if (strcasecmp(pSection, "MainMenu") == 0)
1113 if (__isDefaultMainmenu == false)
1115 __pAppData->__menuIcon = iconRelPath;
1118 if (strcasecmp(pType, __pDefaultIconType) == 0)
1120 __isDefaultMainmenu = true;
1123 else if (strcasecmp(pSection, "Setting") == 0)
1125 if (__isDefaultSetting == false)
1127 __pAppData->__settingIcon = iconRelPath;
1130 if (strcasecmp(pType, __pDefaultIconType) == 0)
1132 __isDefaultSetting = true;
1135 else if (strcasecmp(pSection, "Notification") == 0)
1137 if (__isDefaultQuickpanel == false)
1139 __pAppData->__notificationIcon = iconRelPath;
1142 if (strcasecmp(pType, __pDefaultIconType) == 0)
1144 __isDefaultQuickpanel = true;
1154 ManifestHandler::OnNameValue(const char* pCharacters)
1156 XmlAttribute* pAttr = 0;
1157 char* pAttrValue = 0;
1159 pAttr = GetAttribute();
1160 TryReturn(pAttr, true, "pAttr is null");
1162 pAttrValue = pAttr->Find("Locale");
1163 TryReturn(pAttrValue, true, "pAttrValue is null");
1165 if (FindElement("Content") == true)
1167 TryReturn(__pContentData, false, "__pContentData is null");
1169 String* pValue = new (std::nothrow) String;
1170 StringUtil::Utf8ToString(pCharacters, *pValue);
1171 __pContentData->AddName(*(new (std::nothrow) String(pAttrValue)), *pValue);
1175 if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
1177 if (__isDefaultName == true)
1179 __pContext->__displayName = pCharacters;
1183 String* pValue = new (std::nothrow) String;
1184 StringUtil::Utf8ToString(pCharacters, *pValue);
1186 __pAppData->__pNameList->Add((new (std::nothrow) String(pAttrValue)), pValue);
1189 AppLog("<DisplayName Locale=\"%s\">%s</DisplayName>", pAttrValue, pCharacters);
1195 ManifestHandler::OnDescriptionValue(const char* pCharacters)
1197 XmlAttribute *pAttr = 0;
1198 char *pAttrValue = 0;
1200 pAttr = GetAttribute();
1201 TryReturn(pAttr, true, "pAttr is null");
1203 pAttrValue = pAttr->Find("Locale");
1204 TryReturn(pAttrValue, true, "pAttrValue is null");
1206 if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
1208 __pContext->__description = pCharacters;
1211 AppLog("<Description Locale=\"%s\">%s</Description>", pAttrValue, pCharacters);
1217 ManifestHandler::OnDataControlTypeValue(const char* pCharacters)
1219 XmlAttribute* pAttr = null;
1220 char* pAccessValue = null;
1222 pAttr = GetAttribute();
1223 TryReturn(pAttr, true, "pAttr is null");
1225 pAccessValue = pAttr->Find("Access");
1226 TryReturn(pAccessValue, true, "pAccessValue is null");
1228 __pDataControlType = new (std::nothrow) DataControlType;
1229 TryReturn(__pDataControlType, false, "__pDataControlType is null");
1231 __pDataControlType->__type = pCharacters;
1232 __pDataControlType->__access = pAccessValue;
1234 AppLog("<DataControlType Access=\"%s\", Type=\"%s\">", pAccessValue, pCharacters);
1240 ManifestHandler::OnConditionValue(const char* pCharacters)
1242 XmlAttribute *pAttr = null;
1245 pAttr = GetAttribute();
1246 TryReturn(pAttr, true, "pAttr is null");
1248 pName = pAttr->Find("Name");
1249 TryReturn(pName, true, "pName is null");
1251 String* pKey = new (std::nothrow) String(pName);
1252 TryReturn(pKey, false, "pKey is null");
1253 String* pValue = new (std::nothrow) String(pCharacters);
1254 TryReturn(pValue, false, "pValue is null");
1256 __pAppData->__pLaunchConditionList->Add(pKey, pValue);
1257 AppLog("<LaunchCondition Name=\"%s\", Value=\"%s\">", pName, pCharacters);
1263 ManifestHandler::OnNotificationValue(const char* pCharacters)
1265 XmlAttribute *pAttr = null;
1266 const char *pName = null;
1268 pAttr = GetAttribute();
1269 TryReturn(pAttr, true, "pAttr is null.");
1271 pName = pAttr->Find("Name");
1272 TryReturn(pName, true, "pName is null.");
1274 if (strcasecmp(pName, "Ticker") == 0)
1276 pName = "Notification";
1278 else if (strcasecmp(pName, "Notification") == 0 || strcasecmp(pName, "Sounds") == 0
1279 || strcasecmp(pName, "Badge") == 0 || strcasecmp(pName, "Contents") == 0)
1281 // known notification attributes
1285 TryReturn(0, true, "Unknown notification attributes=%s", pCharacters);
1288 String* pKey = new (std::nothrow) String(pName);
1289 TryReturn(pKey, false, "pKey is null.");
1291 String* pValue = new (std::nothrow) String(pCharacters);
1292 TryReturn(pValue, false, "pValue is null.");
1294 pKey->ToLowerCase();
1295 pValue->ToLowerCase();
1297 __pAppData->__pNotificationMap->Add(pKey, pValue);
1298 AppLog("<Notification Name=\"%s\", Value=\"%s\">", pName, pCharacters);
1304 ManifestHandler::OnInstallLocationValue(const char* pCharacters)
1306 AppLog("<InstallLocation>%s</InstallLocation>", pCharacters);
1308 if (strcasecmp(pCharacters, "Internal") == 0)
1310 AppLog("INSTALLATION_STORAGE = [INTERNAL]");
1311 __isInternalStorage = true;
1318 ManifestHandler::OnCategoryValue(const char* pCharacters)
1320 TryReturn(__pAppData, false, "__pAppData is null");
1322 __pAppData->__pCategoryList->Add(new (std::nothrow) String(pCharacters));
1324 if (strcasecmp(pCharacters, TIZEN_CATEGORY_IME) == 0)
1326 __pAppData->__feature = CATEGORY_TYPE_IME;
1328 else if (strcasecmp(pCharacters, TIZEN_CATEGORY_ANTIVIRUS) == 0)
1330 AppLog("ANTIVIRUS Package is detected.");
1331 __pContext->__isAntiVirus = true;
1338 ManifestHandler::OnMetadataValue(const char* pCharacters)
1340 TryReturn(__pAppData, false, "__pAppData is null");
1342 XmlAttribute* pAttr = null;
1345 pAttr = GetAttribute();
1346 TryReturn(pAttr, true, "pAttr is null.");
1348 pKey = pAttr->Find("Key");
1349 TryReturn(pKey, true, "pKey is null.");
1351 __pAppData->__pMetadataMap->Add(*(new (std::nothrow) String(pKey)), *(new (std::nothrow) String(pCharacters)));
1352 __metadataKey.Clear();
1354 AppLog("<Metadata Key=\"%s\">%s</Metadata>", pKey, pCharacters);
1360 ManifestHandler::FindElement(const char *pName)
1363 Tizen::Base::Collection::IEnumerator* pEnum = GetElementEnumeratorN();
1367 while(pEnum->MoveNext() == E_SUCCESS)
1369 String* pStr = static_cast<String*>(pEnum->GetCurrent());
1372 if (pStr->Equals(pName, false) == true)
1374 AppLog("[%s] is matched.", pName);
1388 ManifestHandler::AddAppFeature(const Tizen::Base::String& name, const Tizen::Base::String& value)
1390 String* pKey = new (std::nothrow) String(name);
1391 TryReturn(pKey, false, "pKey is null");
1392 String* pValue = new (std::nothrow) String(value);
1393 TryReturn(pValue, false, "pValue is null");
1395 __pAppData->__pFeatureList->Add(pKey, pValue);
1400 ManifestHandler::ParseAppAttribute(XmlAttribute* pAttr, bool isUiApp)
1402 char* pName = pAttr->Find("Name");
1405 pName = pAttr->Find("ExecutableName");
1410 AppLog(" - Name=%s", pName);
1411 __pAppData->__name = pName;
1412 __pAppData->__appId = __pContext->__packageId + L"." + pName;
1415 char* pMain = pAttr->Find("Main");
1418 pMain = pAttr->Find("Default");
1423 AppLog(" - Main=%s", pMain);
1424 __pAppData->__main = pMain;
1426 if (strcasecmp(pMain, "True") == 0)
1428 __isDefaultName = true;
1429 __isDefaultAppDetected = true;
1430 __pContext->__mainAppName = pName;
1435 __pAppData->__main = L"False";
1438 char* pRecent = pAttr->Find("LaunchingHistoryVisible");
1441 AppLog(" - LaunchingHistoryVisible=%s", pRecent);
1442 __pAppData->__launchingHistoryVisible = pRecent;
1445 char* pHwAcceleration = pAttr->Find("HwAcceleration");
1446 if (pHwAcceleration)
1448 AddAppFeature("HwAcceleration", pHwAcceleration);
1449 AppLog(" - HwAcceleration=%s", pHwAcceleration);
1453 char* pGlFrame = pAttr->Find("GlFrame");
1456 AddAppFeature("GlFrame", pGlFrame);
1457 AppLog(" - GlFrame=%s", pGlFrame);
1461 char* pCategory = pAttr->Find("Category");
1464 AppLog(" - Category=%s", pCategory);
1466 if (strcasecmp(pCategory, "home-screen") == 0)
1468 __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_HOMESCREEN));
1470 else if (strcasecmp(pCategory, "lock-screen") == 0)
1472 __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_LOCKSCREEN));
1474 else if (strcasecmp(pCategory, "Ime") == 0)
1476 __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_IME));
1479 int categoryType = InstallerUtil::GetCategoryType(pCategory);
1480 __pAppData->__feature = categoryType;
1483 char* pSubMode = pAttr->Find("SubMode");
1486 if (strcasecmp(pSubMode, "True") == 0)
1488 __pAppData->__isSubMode = true;
1489 AppLog(" - SubMode=%s", pSubMode);
1493 if (isUiApp == true)
1495 __pAppData->__type = L"UiApp";
1497 char* pMenuIconVisible = pAttr->Find("MenuIconVisible");
1498 if (pMenuIconVisible == null)
1500 pMenuIconVisible = pAttr->Find("MainmenuVisible");
1503 if (pMenuIconVisible)
1505 if (strcasecmp(pMenuIconVisible, "True") == 0)
1507 __pAppData->__menuIconVisible = true;
1511 __pAppData->__menuIconVisible = false;
1514 AddAppFeature("MenuIconVisible", pMenuIconVisible);
1515 AppLog(" - MenuIconVisible=%s", pMenuIconVisible);
1520 __pAppData->__type = L"ServiceApp";
1521 __pAppData->__menuIconVisible = false;
1523 char *pUseUi = pAttr->Find("UseUi");
1526 AddAppFeature("UseUi", pUseUi);
1527 AppLog(" - UseUi=%s", pUseUi);
1530 char *pLifeDuration = pAttr->Find("LifeDuration");
1533 AddAppFeature("LifeDuration", pLifeDuration);
1534 AppLog(" - LifeDuration=%s", pLifeDuration);
1537 char *pLaunchOnBoot = pAttr->Find("LaunchOnBoot");
1540 AddAppFeature("LaunchOnBoot", pLaunchOnBoot);
1541 AppLog(" - LaunchOnBoot=%s", pLaunchOnBoot);
1544 char *pAutoRestart = pAttr->Find("AutoRestart");
1547 AddAppFeature("AutoRestart", pAutoRestart);
1548 AppLog(" - AutoRestart=%s", pAutoRestart);
1551 char *pSystemService = pAttr->Find("SystemService");
1554 if (strcasecmp(pSystemService, "True") == 0)
1556 __pAppData->__isSystemService = true;
1557 AppLog(" - SystemService=%s", pSystemService);
1562 AppLog(" - app=%ls", __pAppData->__appId.GetPointer());
1568 ManifestHandler::GetAppData(void)
1574 ManifestHandler::GetDefaultIconType(void)
1576 return __pDefaultIconType;