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);
174 __isParserMode = false;
182 ManifestHandler::OnEndElement(const char *pName)
184 TryReturn(pName, true, "pName is null.");
188 if (__isParserMode == true)
190 TryReturn(__pParser, false, "__pParser is null");
191 __pParser->OnEndElement(pName);
193 if ((strcasecmp(pName, "Liveboxes") == 0) || strcasecmp(pName, "AppWidgets") == 0)
195 status = OnLiveboxesEndElement();
197 else if (strcasecmp(pName, "Accounts") == 0)
199 status = OnAccountsEndElement();
201 else if (strcasecmp(pName, "AppControls") == 0)
203 status = OnAppControlsEndElement();
209 if (strcasecmp(pName, "Privileges") == 0)
211 status = OnPrivilegesEndElement();
213 else if (strcasecmp(pName, "UiApp") == 0)
215 status = OnUiAppEndElement();
217 else if (strcasecmp(pName, "ServiceApp") == 0)
219 status = OnServiceAppEndElement();
221 else if (strcasecmp(pName, "DataControl") == 0)
223 status = OnDataControlEndElement();
225 else if (strcasecmp(pName, "DataControlType") == 0)
227 status = OnDataControlTypeEndElement();
229 else if (strcasecmp(pName, "Apps") == 0)
231 status = OnAppsEndElement();
233 else if (strcasecmp(pName, "UiScalability") == 0)
235 AppLog("</%s>", pName);
237 else if (strcasecmp(pName, "Icons") == 0)
239 status = OnIconsEndElement();
241 else if (strcasecmp(pName, "Contents") == 0)
243 status = OnContentsEndElement();
245 else if (strcasecmp(pName, "Content") == 0)
247 status = OnContentEndElement();
249 else if (strcasecmp(pName, "Metadata") == 0)
251 status = OnMetadataEndElement();
253 else if (strcasecmp(pName, "Manifest") == 0)
255 status = OnManifestEndElement();
267 ManifestHandler::OnCharacters(const char *pCharacters)
271 char* pName = GetElementName();
272 TryReturn(pName, true, "pName is null.");
274 if (__isParserMode == true)
276 TryReturn(__pParser, false, "__pParser is null");
277 return __pParser->OnCharacters(pCharacters);
280 if (strcasecmp(pName, "Id") == 0)
282 status = OnIdValue(pCharacters);
284 else if (strcasecmp(pName, "Version") == 0)
286 status = OnVersionValue(pCharacters);
288 else if (strcasecmp(pName, "Type") == 0)
290 status = OnTypeValue(pCharacters);
292 else if (strcasecmp(pName, "Url") == 0)
294 status = OnUrlValue(pCharacters);
296 else if (strcasecmp(pName, "ApiVersion") == 0)
298 status = OnApiVersionValue(pCharacters);
300 else if (strcasecmp(pName, "Privilege") == 0)
302 status = OnPrivilegeValue(pCharacters);
304 else if (strcasecmp(pName, "Name") == 0)
306 status = OnNameValue(pCharacters);
308 else if (strcasecmp(pName, "DisplayName") == 0)
310 status = OnNameValue(pCharacters);
312 else if (strcasecmp(pName, "Author") == 0)
314 status = OnAuthorValue(pCharacters);
316 else if (strcasecmp(pName, "Description") == 0)
318 status = OnDescriptionValue(pCharacters);
320 else if (strcasecmp(pName, "Icon") == 0)
322 status = OnIconValue(pCharacters);
324 else if (strcasecmp(pName, "DataControlType") == 0)
326 status = OnDataControlTypeValue(pCharacters);
328 else if (strcasecmp(pName, "Condition") == 0)
330 status = OnConditionValue(pCharacters);
332 else if (strcasecmp(pName, "Notification") == 0)
334 status = OnNotificationValue(pCharacters);
336 else if (strcasecmp(pName, "InstallLocation") == 0)
338 status = OnInstallLocationValue(pCharacters);
340 else if (strcasecmp(pName, "Category") == 0)
342 status = OnCategoryValue(pCharacters);
344 else if (strcasecmp(pName, "Metadata") == 0)
346 status = OnMetadataValue(pCharacters);
358 ManifestHandler::OnPrivilegesStartElement(void)
360 __pPrivilegeList = new (std::nothrow) ArrayList;
361 TryReturn(__pPrivilegeList, false, "__pPrivilegeList is null");
363 AppLog("<Privileges>");
369 ManifestHandler::OnUiAppStartElement(void)
371 __pAppData = new (std::nothrow) AppData;
372 TryReturn(__pAppData, false, "__pAppData is null");
374 InstallerError error = __pAppData->Construct();
375 TryReturn(error == INSTALLER_ERROR_NONE, false, "pAppData->Construct() failed.");
379 XmlAttribute *pAttr = GetAttribute();
380 TryReturn(pAttr, true, "pAttr is null");
382 ParseAppAttribute(pAttr, true);
388 ManifestHandler::OnServiceAppStartElement(void)
390 __pAppData = new (std::nothrow) AppData;
391 TryReturn(__pAppData, false, "__pAppData is null");
393 InstallerError error = __pAppData->Construct();
394 TryReturn(error == INSTALLER_ERROR_NONE, false, "pAppData->Construct() failed.");
396 AppLog("<ServiceApp>");
398 XmlAttribute *pAttr = GetAttribute();
399 TryReturn(pAttr, true, "pAttr is null");
401 ParseAppAttribute(pAttr, false);
407 ManifestHandler::OnIconsStartElement(void)
411 String defaultIconType;
415 res = system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_WIDTH, &width);
416 if (res != SYSTEM_INFO_ERROR_NONE)
418 AppLog("system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_WIDTH) failed. res = [%d]", res);
419 defaultIconType = L"Xhigh";
425 defaultIconType = L"High";
429 defaultIconType = L"Xhigh";
433 AppLog("ScreenWidth = [%d]", width);
435 __pDefaultIconType = _StringConverter::CopyToCharArrayN(defaultIconType);
436 TryReturn(__pDefaultIconType, false, "__pDefaultIconType is null.");
438 AppLog("DefaultIconType = [%s]", __pDefaultIconType);
444 ManifestHandler::OnUiScalabilityStartElement(void)
446 XmlAttribute *pAttr = null;
447 char* pCoordinateSystem = null;
448 char* pBaseScreenSize = null;
449 char* pLogicalCoordinate = null;
451 AppLog("<UiScalability>");
453 pAttr = GetAttribute();
454 TryReturn(pAttr, true, "pAttr is null");
456 pCoordinateSystem = pAttr->Find("CoordinateSystem");
457 if (pCoordinateSystem)
459 String* pKey = new (std::nothrow) String("CoordinateSystem");
460 TryReturn(pKey, false, "pKey is null");
461 String* pValue = new (std::nothrow) String(pCoordinateSystem);
462 TryReturn(pValue, false, "pValue is null");
464 __pAppData->__pFeatureList->Add(pKey, pValue);
465 AppLog("<CoordinateSystem=%s>", pCoordinateSystem);
468 pBaseScreenSize = pAttr->Find("BaseScreenSize");
471 String* pKey = new (std::nothrow) String("BaseScreenSize");
472 TryReturn(pKey, false, "pKey is null");
473 String* pValue = new (std::nothrow) String(pBaseScreenSize);
474 TryReturn(pValue, false, "pValue is null");
476 __pAppData->__pFeatureList->Add(pKey, pValue);
477 AppLog("<BaseScreenSize=%s>", pBaseScreenSize);
480 pLogicalCoordinate = pAttr->Find("LogicalCoordinate");
481 if (pLogicalCoordinate)
483 String* pKey = new (std::nothrow) String("LogicalCoordinate");
484 TryReturn(pKey, false, "pKey is null");
485 String* pValue = new (std::nothrow) String(pLogicalCoordinate);
486 TryReturn(pValue, false, "pValue is null");
488 __pAppData->__pFeatureList->Add(pKey, pValue);
489 AppLog("<LogicalCoordinate=%s>", pLogicalCoordinate);
496 ManifestHandler::OnUiThemeStartElement(void)
498 XmlAttribute *pAttr = null;
499 char *pSystemTheme = null;
500 char *pUserDefinedTheme = null;
504 pAttr = GetAttribute();
505 TryReturn(pAttr, true, "pAttr is null");
507 pSystemTheme = pAttr->Find("SystemTheme");
510 String* pKey = new (std::nothrow) String("SystemTheme");
511 TryReturn(pKey, false, "pKey is null");
512 String* pValue = new (std::nothrow) String(pSystemTheme);
513 TryReturn(pValue, false, "pValue is null");
515 __pAppData->__pFeatureList->Add(pKey, pValue);
516 AppLog("<SystemTheme=%s>", pSystemTheme);
519 pUserDefinedTheme = pAttr->Find("UserDefinedTheme");
520 if (pUserDefinedTheme)
522 String* pKey = new (std::nothrow) String("UserDefinedTheme");
523 TryReturn(pKey, false, "pKey is null");
524 String* pValue = new (std::nothrow) String(pUserDefinedTheme);
525 TryReturn(pValue, false, "pValue is null");
527 __pAppData->__pFeatureList->Add(pKey, pValue);
528 AppLog("<UserDefinedTheme=%s>", pUserDefinedTheme);
535 ManifestHandler::OnDataControlStartElement(void)
537 XmlAttribute* pAttr = null;
538 char* pProviderId = null;
540 pAttr = GetAttribute();
541 TryReturn(pAttr, true, "pAttr is null");
543 pProviderId = pAttr->Find("ProviderId");
544 TryReturn(pProviderId, true, "pProviderId is null");
546 __pDataControlInfo = new (std::nothrow) DataControlInfo;
547 TryReturn(__pDataControlInfo, false, "__pDataControlInfo is null");
549 __pDataControlInfo->__providerId = pProviderId;
551 AppLog("<DataControl Provider=\"%s\">", pProviderId);
557 ManifestHandler::OnContentsStartElement(void)
559 __pContentDataList = new (std::nothrow) ArrayList;
560 TryReturn(__pContentDataList, false, "__pContentDataList is null");
562 AppLog("<Contents>");
568 ManifestHandler::OnContentStartElement(void)
570 TryReturn(__pContentData == null, false, "__pContentData is not null");
572 XmlAttribute *pAttr = null;
573 char *pDefault = null;
575 __pContentData = new (std::nothrow) ContentData;
576 TryReturn(__pContentData, false, "__pContentData is null");
578 pAttr = GetAttribute();
579 TryReturn(pAttr, true, "pAttr is null");
581 char* pId = pAttr->Find("Id");
584 __pContentData->SetContentId(pId);
587 char* pEntryName = pAttr->Find("EntryName");
590 __pContentData->SetContentId(pEntryName);
593 pDefault = pAttr->Find("Default");
596 if (strcasecmp(pDefault, "True") == 0)
598 __isDefaultAppDetected = true;
602 AppLog("<Content=\"%s\" EntryName=\"%s\">", pId, pEntryName);
608 ManifestHandler::OnMetadataStartElement()
610 AppLog("<Metadata>");
611 __metadataKey.Clear();
613 XmlAttribute* pAttr = GetAttribute();
614 TryReturn(pAttr, true, "pAttr is null");
616 char* pKey = pAttr->Find("Key");
619 __metadataKey = pKey;
626 ManifestHandler::OnLiveboxesStartElement(const char *pName)
628 __pParser = new (std::nothrow) ManifestLiveboxesParser;
629 TryReturn(__pParser, false, "__pParser is null");
631 __isParserMode = true;
632 AppLog("------------------------------------------");
633 __pParser->Construct(this);
635 return __pParser->OnStartElement(pName);
639 ManifestHandler::OnAccountsStartElement(const char *pName)
641 __pParser = new (std::nothrow) ManifestAccountsParser;
642 TryReturn(__pParser, false, "__pParser is null");
644 __isParserMode = true;
645 AppLog("------------------------------------------");
646 __pParser->Construct(this);
648 return __pParser->OnStartElement(pName);
652 ManifestHandler::OnAppControlsStartElement(const char *pName)
654 __pParser = new (std::nothrow) ManifestAppControlsParser;
655 TryReturn(__pParser, false, "__pParser is null");
657 __isParserMode = true;
658 AppLog("------------------------------------------");
659 __pParser->Construct(this);
661 return __pParser->OnStartElement(pName);
665 ManifestHandler::OnPermissionStartElement(const char* pName)
667 XmlAttribute* pAttr = null;
670 pAttr = GetAttribute();
671 TryReturn(pAttr, true, "pAttr is null.");
673 pType = pAttr->Find("Type");
674 TryReturn(pType, true, "pType is null.");
676 if (__pAppData->__permissionType.IsEmpty() == true)
678 __pAppData->__permissionType = pType;
683 if (__pAppData->__permissionType.Equals(type, true) == false)
685 AppLog("Invalid Permission Type [%ls][%ls]", __pAppData->__permissionType.GetPointer(), type.GetPointer());
690 AppLog("<Permission Type=\"%s\">", pType);
696 ManifestHandler::OnPrivilegesEndElement(void)
698 if (__pContext->__isVerificationMode == false)
700 AppLog("no signature file[%ls]", __pContext->GetSignatureXmlPath().GetPointer());
702 result r = E_SUCCESS;
704 String hmacPrivileges;
705 ArrayList stringPrivilegeList;
706 stringPrivilegeList.Construct(125);
707 PackageId packageId = __pContext->__packageId;
709 if (__pPrivilegeList != null)
711 r = PrivilegeHandler::GenerateCipherPrivilege(packageId, *__pPrivilegeList, privileges, hmacPrivileges, stringPrivilegeList);
712 TryReturn(!IsFailed(r), false, "privMgr.GeneratePrivilegeString() failed");
715 __pContext->__privileges = privileges;
716 __pContext->__hmacPrivileges = hmacPrivileges;
717 __pContext->__pStringPrivilegeList = new ArrayList;
718 __pContext->__pStringPrivilegeList->Construct(stringPrivilegeList);
721 __pContext->SetPrivilegeList(__pPrivilegeList);
723 AppLog("</Privileges>");
729 ManifestHandler::OnUiAppEndElement(void)
731 if (__pAppData->__isSubMode == true)
733 __pAppData->__pSubModeAppControlDataList = __pAppData->__pAppControlDataList;
734 __pAppData->__pAppControlDataList = null;
735 __pAppData->__subModeAppName = __pAppData->__name;
738 __isDefaultName = false;
740 __pContext->__pAppDataList->Add(__pAppData);
749 ManifestHandler::OnServiceAppEndElement(void)
751 if (__pAppData->__isSubMode == true)
753 __pAppData->__pSubModeAppControlDataList = __pAppData->__pAppControlDataList;
754 __pAppData->__pAppControlDataList = null;
755 __pAppData->__subModeAppName = __pAppData->__name;
758 __isDefaultName = false;
760 __pContext->__pAppDataList->Add(__pAppData);
763 AppLog("</ServiceApp>");
769 ManifestHandler::OnAppsEndElement(void)
773 if ((__isInternalStorage == false) && (File::IsFileExist(DIR_MEMORYCARD_INSTALLATION) == true))
775 AppLog("INSTALLATION_STORAGE = [EXTERNAL]");
776 __pContext->__storage = INSTALLATION_STORAGE_EXTERNAL;
783 ManifestHandler::OnIconsEndElement(void)
791 ManifestHandler::OnDataControlEndElement(void)
793 __pAppData->__pDataControlList->Add(__pDataControlInfo);
794 __pDataControlInfo = null;
795 AppLog("</DataControl>");
801 ManifestHandler::OnDataControlTypeEndElement(void)
803 __pDataControlInfo->__pControlTypeList->Add(__pDataControlType);
804 __pDataControlType = null;
805 AppLog("</DataControlType>");
811 ManifestHandler::OnContentsEndElement(void)
813 __pContext->SetContentDataList(__pContentDataList);
814 __pContentDataList = null;
815 AppLog("</Contents>");
821 ManifestHandler::OnContentEndElement(void)
823 __pContentDataList->Add(*__pContentData);
824 __pContentData = null;
825 AppLog("</Content>");
831 ManifestHandler::OnMetadataEndElement(void)
833 AppLog("</Metadata>");
835 if (__metadataKey.IsEmpty() == false)
837 __pAppData->__pMetadataMap->Add(*(new (std::nothrow) String(__metadataKey)), *(new (std::nothrow) String(L"")));
838 __metadataKey.Clear();
845 ManifestHandler::OnLiveboxesEndElement(void)
848 __isParserMode = false;
849 AppLog("------------------------------------------");
855 ManifestHandler::OnAccountsEndElement(void)
858 __isParserMode = false;
859 AppLog("------------------------------------------");
865 ManifestHandler::OnAppControlsEndElement(void)
868 __isParserMode = false;
869 AppLog("------------------------------------------");
875 ManifestHandler::OnManifestEndElement(void)
877 TryReturn(__isDefaultAppDetected, false, "[osp-installer][Error] Main tag is not detected...");
878 AppLog("</Manifest>");
884 ManifestHandler::OnIdValue(const char* pCharacters)
886 AppLog("<Package>%s</Package>", pCharacters);
888 if (__pContext->__packageId.IsEmpty() == true)
890 __pContext->__packageId = pCharacters;
894 String id(pCharacters);
895 if (__pContext->__packageId != id)
897 AppLog("input package = [%ls], manifest = [%s] is different.", __pContext->__packageId.GetPointer(), pCharacters);
902 AppLog("input package = [%ls], manifest = [%s] is the same.", __pContext->__packageId.GetPointer(), pCharacters);
910 ManifestHandler::OnVersionValue(const char* pCharacters)
912 AppLog("<Version>%s</Version>", pCharacters);
913 __pContext->__version = pCharacters;
919 ManifestHandler::OnTypeValue(const char* pCharacters)
921 AppLog("<Type>%s</Type>", pCharacters);
923 if (strcasecmp(pCharacters, "Contents") == 0)
925 __pContext->__apiVersion = L"3.0";
932 ManifestHandler::OnAuthorValue(const char* pCharacters)
934 AppLog("<Author>%s</Author>", pCharacters);
935 __pContext->__author = pCharacters;
941 ManifestHandler::OnUrlValue(const char* pCharacters)
943 __pContext->__url = pCharacters;
944 AppLog("<Url>%s</Url>", pCharacters);
950 ManifestHandler::OnApiVersionValue(const char* pCharacters)
952 __pContext->__apiVersion = pCharacters;
953 AppLog("<ApiVersion>%s</ApiVersion>", pCharacters);
955 XmlAttribute *pAttr = GetAttribute();
958 char* pOspCompat = pAttr->Find("OspCompat");
961 AppLog(" - OspCompat=%s", pOspCompat);
962 __pContext->__isOspCompat = true;
970 ManifestHandler::OnPrivilegeValue(const char* pCharacters)
972 __pPrivilegeList->Add(*new (std::nothrow) String(pCharacters));
973 AppLog("<Privilege>%s</Privilege>", pCharacters);
979 ManifestHandler::OnIconValue(const char* pCharacters)
981 AppLog("<Icon>%s</Icon>", pCharacters);
983 XmlAttribute* pAttr = GetAttribute();
984 TryReturn(pAttr, true, "pAttr is null");
986 char* pSection = pAttr->Find("Section");
987 TryReturn(pSection, true, "pSection is null");
988 AppLog(" - Section=%s", pSection);
990 TryReturn(__pDefaultIconType, false, "__pDefaultIconType is null");
993 char* pType = pAttr->Find("Type");
996 AppLog("__pDefaultIconType=%s", __pDefaultIconType);
997 if (strcasecmp(__pDefaultIconType, "Xhigh") == 0)
999 iconRelPath.Format(1024, L"screen-density-xhigh/%s", pCharacters);
1001 else if (strcasecmp(__pDefaultIconType, "High") == 0)
1003 iconRelPath.Format(1024, L"screen-density-high/%s", pCharacters);
1007 TryReturn(0, false, "Invalid __pDefaultIconType[%s]", __pDefaultIconType);
1012 AppLog(" - Type=%s", pType);
1013 if (strcasecmp(pType, "Xhigh") == 0)
1015 iconRelPath.Format(1024, L"screen-density-xhigh/%s", pCharacters);
1017 else if (strcasecmp(pType, "High") == 0)
1019 iconRelPath.Format(1024, L"screen-density-high/%s", pCharacters);
1023 TryReturn(0, false, "Invalid IconType [%s]", __pDefaultIconType);
1027 if (FindElement("Content") == true)
1029 TryReturn(__pContentData, false, "__pContentData is null");
1030 __pContentData->SetIcon(iconRelPath);
1036 if (strcasecmp(pSection, "MainMenu") == 0)
1038 __pAppData->__menuIcon = iconRelPath;
1040 else if (strcasecmp(pSection, "Setting") == 0)
1042 __pAppData->__settingIcon = iconRelPath;
1044 else if (strcasecmp(pSection, "Notification") == 0)
1046 __pAppData->__notificationIcon = iconRelPath;
1051 if (strcasecmp(pSection, "MainMenu") == 0)
1053 if (__isDefaultMainmenu == false)
1055 __pAppData->__menuIcon = iconRelPath;
1058 if (strcasecmp(pType, __pDefaultIconType) == 0)
1060 __isDefaultMainmenu = true;
1063 else if (strcasecmp(pSection, "Setting") == 0)
1065 if (__isDefaultSetting == false)
1067 __pAppData->__settingIcon = iconRelPath;
1070 if (strcasecmp(pType, __pDefaultIconType) == 0)
1072 __isDefaultSetting = true;
1075 else if (strcasecmp(pSection, "Notification") == 0)
1077 if (__isDefaultQuickpanel == false)
1079 __pAppData->__notificationIcon = iconRelPath;
1082 if (strcasecmp(pType, __pDefaultIconType) == 0)
1084 __isDefaultQuickpanel = true;
1094 ManifestHandler::OnNameValue(const char* pCharacters)
1096 XmlAttribute* pAttr = 0;
1097 char* pAttrValue = 0;
1099 pAttr = GetAttribute();
1100 TryReturn(pAttr, true, "pAttr is null");
1102 pAttrValue = pAttr->Find("Locale");
1103 TryReturn(pAttrValue, true, "pAttrValue is null");
1105 if (FindElement("Content") == true)
1107 TryReturn(__pContentData, false, "__pContentData is null");
1109 String* pValue = new (std::nothrow) String;
1110 StringUtil::Utf8ToString(pCharacters, *pValue);
1111 __pContentData->AddName(*(new (std::nothrow) String(pAttrValue)), *pValue);
1115 if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
1117 if (__isDefaultName == true)
1119 __pContext->__displayName = pCharacters;
1123 String* pValue = new (std::nothrow) String;
1124 StringUtil::Utf8ToString(pCharacters, *pValue);
1126 __pAppData->__pNameList->Add((new (std::nothrow) String(pAttrValue)), pValue);
1129 AppLog("<DisplayName Locale=\"%s\">%s</DisplayName>", pAttrValue, pCharacters);
1135 ManifestHandler::OnDescriptionValue(const char* pCharacters)
1137 XmlAttribute *pAttr = 0;
1138 char *pAttrValue = 0;
1140 pAttr = GetAttribute();
1141 TryReturn(pAttr, true, "pAttr is null");
1143 pAttrValue = pAttr->Find("Locale");
1144 TryReturn(pAttrValue, true, "pAttrValue is null");
1146 if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
1148 __pContext->__description = pCharacters;
1151 AppLog("<Description Locale=\"%s\">%s</Description>", pAttrValue, pCharacters);
1157 ManifestHandler::OnDataControlTypeValue(const char* pCharacters)
1159 XmlAttribute* pAttr = null;
1160 char* pAccessValue = null;
1162 pAttr = GetAttribute();
1163 TryReturn(pAttr, true, "pAttr is null");
1165 pAccessValue = pAttr->Find("Access");
1166 TryReturn(pAccessValue, true, "pAccessValue is null");
1168 __pDataControlType = new (std::nothrow) DataControlType;
1169 TryReturn(__pDataControlType, false, "__pDataControlType is null");
1171 __pDataControlType->__type = pCharacters;
1172 __pDataControlType->__access = pAccessValue;
1174 AppLog("<DataControlType Access=\"%s\", Type=\"%s\">", pAccessValue, pCharacters);
1180 ManifestHandler::OnConditionValue(const char* pCharacters)
1182 XmlAttribute *pAttr = null;
1185 pAttr = GetAttribute();
1186 TryReturn(pAttr, true, "pAttr is null");
1188 pName = pAttr->Find("Name");
1189 TryReturn(pName, true, "pName is null");
1191 String* pKey = new (std::nothrow) String(pName);
1192 TryReturn(pKey, false, "pKey is null");
1193 String* pValue = new (std::nothrow) String(pCharacters);
1194 TryReturn(pValue, false, "pValue is null");
1196 __pAppData->__pLaunchConditionList->Add(pKey, pValue);
1197 AppLog("<LaunchCondition Name=\"%s\", Value=\"%s\">", pName, pCharacters);
1203 ManifestHandler::OnNotificationValue(const char* pCharacters)
1205 XmlAttribute *pAttr = null;
1206 const char *pName = null;
1208 pAttr = GetAttribute();
1209 TryReturn(pAttr, true, "pAttr is null.");
1211 pName = pAttr->Find("Name");
1212 TryReturn(pName, true, "pName is null.");
1214 if (strcasecmp(pName, "Ticker") == 0)
1216 pName = "Notification";
1218 else if (strcasecmp(pName, "Notification") == 0 || strcasecmp(pName, "Sounds") == 0
1219 || strcasecmp(pName, "Badge") == 0 || strcasecmp(pName, "Contents") == 0)
1221 // known notification attributes
1225 TryReturn(0, true, "Unknown notification attributes=%s", pCharacters);
1228 String* pKey = new (std::nothrow) String(pName);
1229 TryReturn(pKey, false, "pKey is null.");
1231 String* pValue = new (std::nothrow) String(pCharacters);
1232 TryReturn(pValue, false, "pValue is null.");
1234 pKey->ToLowerCase();
1235 pValue->ToLowerCase();
1237 __pAppData->__pNotificationMap->Add(pKey, pValue);
1238 AppLog("<Notification Name=\"%s\", Value=\"%s\">", pName, pCharacters);
1244 ManifestHandler::OnInstallLocationValue(const char* pCharacters)
1246 AppLog("<InstallLocation>%s</InstallLocation>", pCharacters);
1248 if (strcasecmp(pCharacters, "Internal") == 0)
1250 AppLog("INSTALLATION_STORAGE = [INTERNAL]");
1251 __isInternalStorage = true;
1258 ManifestHandler::OnCategoryValue(const char* pCharacters)
1260 TryReturn(__pAppData, false, "__pAppData is null");
1262 __pAppData->__pCategoryList->Add(new (std::nothrow) String(pCharacters));
1264 if (strcasecmp(pCharacters, TIZEN_CATEGORY_IME) == 0)
1266 __pAppData->__feature = CATEGORY_TYPE_IME;
1268 else if (strcasecmp(pCharacters, TIZEN_CATEGORY_ANTIVIRUS) == 0)
1270 AppLog("ANTIVIRUS Package is detected.");
1271 __pContext->__isAntiVirus = true;
1278 ManifestHandler::OnMetadataValue(const char* pCharacters)
1280 TryReturn(__pAppData, false, "__pAppData is null");
1282 XmlAttribute* pAttr = null;
1285 pAttr = GetAttribute();
1286 TryReturn(pAttr, true, "pAttr is null.");
1288 pKey = pAttr->Find("Key");
1289 TryReturn(pKey, true, "pKey is null.");
1291 __pAppData->__pMetadataMap->Add(*(new (std::nothrow) String(pKey)), *(new (std::nothrow) String(pCharacters)));
1292 __metadataKey.Clear();
1294 AppLog("<Metadata Key=\"%s\">%s</Metadata>", pKey, pCharacters);
1300 ManifestHandler::FindElement(const char *pName)
1303 Tizen::Base::Collection::IEnumerator* pEnum = GetElementEnumeratorN();
1307 while(pEnum->MoveNext() == E_SUCCESS)
1309 String* pStr = static_cast<String*>(pEnum->GetCurrent());
1312 if (pStr->Equals(pName, false) == true)
1314 AppLog("[%s] is matched.", pName);
1328 ManifestHandler::AddAppFeature(const Tizen::Base::String& name, const Tizen::Base::String& value)
1330 String* pKey = new (std::nothrow) String(name);
1331 TryReturn(pKey, false, "pKey is null");
1332 String* pValue = new (std::nothrow) String(value);
1333 TryReturn(pValue, false, "pValue is null");
1335 __pAppData->__pFeatureList->Add(pKey, pValue);
1340 ManifestHandler::ParseAppAttribute(XmlAttribute* pAttr, bool isUiApp)
1342 char* pName = pAttr->Find("Name");
1345 pName = pAttr->Find("ExecutableName");
1350 AppLog(" - Name=%s", pName);
1351 __pAppData->__name = pName;
1352 __pAppData->__appId = __pContext->__packageId + L"." + pName;
1355 char* pMain = pAttr->Find("Main");
1358 pMain = pAttr->Find("Default");
1363 AppLog(" - Main=%s", pMain);
1364 __pAppData->__main = pMain;
1366 if (strcasecmp(pMain, "True") == 0)
1368 __isDefaultName = true;
1369 __isDefaultAppDetected = true;
1370 __pContext->__mainAppName = pName;
1375 __pAppData->__main = L"False";
1378 char* pRecent = pAttr->Find("LaunchingHistoryVisible");
1381 AppLog(" - LaunchingHistoryVisible=%s", pRecent);
1382 __pAppData->__launchingHistoryVisible = pRecent;
1385 char* pHwAcceleration = pAttr->Find("HwAcceleration");
1386 if (pHwAcceleration)
1388 AddAppFeature("HwAcceleration", pHwAcceleration);
1389 AppLog(" - HwAcceleration=%s", pHwAcceleration);
1393 char* pGlFrame = pAttr->Find("GlFrame");
1396 AddAppFeature("GlFrame", pGlFrame);
1397 AppLog(" - GlFrame=%s", pGlFrame);
1401 char* pCategory = pAttr->Find("Category");
1404 AppLog(" - Category=%s", pCategory);
1406 if (strcasecmp(pCategory, "home-screen") == 0)
1408 __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_HOMESCREEN));
1410 else if (strcasecmp(pCategory, "lock-screen") == 0)
1412 __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_LOCKSCREEN));
1414 else if (strcasecmp(pCategory, "Ime") == 0)
1416 __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_IME));
1419 int categoryType = InstallerUtil::GetCategoryType(pCategory);
1420 __pAppData->__feature = categoryType;
1423 char* pSubMode = pAttr->Find("SubMode");
1426 if (strcasecmp(pSubMode, "True") == 0)
1428 __pAppData->__isSubMode = true;
1429 AppLog(" - SubMode=%s", pSubMode);
1433 if (isUiApp == true)
1435 __pAppData->__type = L"UiApp";
1437 char* pMenuIconVisible = pAttr->Find("MenuIconVisible");
1438 if (pMenuIconVisible == null)
1440 pMenuIconVisible = pAttr->Find("MainmenuVisible");
1443 if (pMenuIconVisible)
1445 if (strcasecmp(pMenuIconVisible, "True") == 0)
1447 __pAppData->__menuIconVisible = true;
1451 __pAppData->__menuIconVisible = false;
1454 AddAppFeature("MenuIconVisible", pMenuIconVisible);
1455 AppLog(" - MenuIconVisible=%s", pMenuIconVisible);
1460 __pAppData->__type = L"ServiceApp";
1461 __pAppData->__menuIconVisible = false;
1463 char *pUseUi = pAttr->Find("UseUi");
1466 AddAppFeature("UseUi", pUseUi);
1467 AppLog(" - UseUi=%s", pUseUi);
1470 char *pLifeDuration = pAttr->Find("LifeDuration");
1473 AddAppFeature("LifeDuration", pLifeDuration);
1474 AppLog(" - LifeDuration=%s", pLifeDuration);
1477 char *pLaunchOnBoot = pAttr->Find("LaunchOnBoot");
1480 AddAppFeature("LaunchOnBoot", pLaunchOnBoot);
1481 AppLog(" - LaunchOnBoot=%s", pLaunchOnBoot);
1484 char *pAutoRestart = pAttr->Find("AutoRestart");
1487 AddAppFeature("AutoRestart", pAutoRestart);
1488 AppLog(" - AutoRestart=%s", pAutoRestart);
1491 char *pSystemService = pAttr->Find("SystemService");
1494 if (strcasecmp(pSystemService, "True") == 0)
1496 __pAppData->__isSystemService = true;
1497 AppLog(" - SystemService=%s", pSystemService);
1502 AppLog(" - app=%ls", __pAppData->__appId.GetPointer());
1508 ManifestHandler::GetAppData(void)
1514 ManifestHandler::GetDefaultIconType(void)
1516 return __pDefaultIconType;