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.
23 #include <FSys_SystemInfoImpl.h>
24 #include <FBase_StringConverter.h>
26 #include "ManifestHandler.h"
27 #include "PrivilegeHandler.h"
28 #include "InstallerUtil.h"
29 #include "ManifestLiveboxesParser.h"
30 #include "ManifestAccountsParser.h"
31 #include "ManifestAppControlsParser.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Base::Utility;
36 using namespace Tizen::App;
37 using namespace Tizen::Io;
38 using namespace Tizen::System;
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)
59 ,__isParserMode(false)
64 ManifestHandler::~ManifestHandler(void)
66 delete[] __pDefaultIconType;
67 __pDefaultIconType = null;
71 ManifestHandler::Construct(InstallationContext* pContext)
73 __pContext = pContext;
79 ManifestHandler::GetContext(void)
85 ManifestHandler::Parse(const char *pFilepath)
87 return ParseDocument(pFilepath);
91 ManifestHandler::OnStartElement(const char *pName)
93 TryReturn(pName, true, "pName is null.");
97 if (__isParserMode == true)
99 TryReturn(__pParser, false, "__pParser is null");
100 return __pParser->OnStartElement(pName);
103 if (strcasecmp(pName, "Manifest") == 0)
105 AppLog("------------------------------------------");
106 AppLog("manifest.xml");
107 AppLog("------------------------------------------");
108 AppLog("<%s>", pName);
110 else if (strcasecmp(pName, "Apps") == 0)
112 AppLog("<%s>", pName);
114 else if (strcasecmp(pName, "UiApp") == 0)
116 status = OnUiAppStartElement();
118 else if (strcasecmp(pName, "ServiceApp") == 0)
120 status = OnServiceAppStartElement();
122 else if (strcasecmp(pName, "DataControl") == 0)
124 status = OnDataControlStartElement();
126 else if (strcasecmp(pName, "Privileges") == 0)
128 status = OnPrivilegesStartElement();
130 else if (strcasecmp(pName, "UiScalability") == 0)
132 status = OnUiScalabilityStartElement();
134 else if (strcasecmp(pName, "UiTheme") == 0)
136 status = OnUiThemeStartElement();
138 else if (strcasecmp(pName, "Icons") == 0)
140 status = OnIconsStartElement();
142 else if (strcasecmp(pName, "Contents") == 0)
144 status = OnContentsStartElement();
146 else if (strcasecmp(pName, "Content") == 0)
148 status = OnContentStartElement();
150 else if ((strcasecmp(pName, "Liveboxes") == 0) || strcasecmp(pName, "AppWidgets") == 0)
152 status = OnLiveboxesStartElement(pName);
154 else if (strcasecmp(pName, "Accounts") == 0)
156 status = OnAccountsStartElement(pName);
158 else if (strcasecmp(pName, "AppControls") == 0)
160 status = OnAppControlsStartElement(pName);
162 else if (strcasecmp(pName, "Permission") == 0)
164 status = OnPermissionStartElement(pName);
169 __isParserMode = false;
177 ManifestHandler::OnEndElement(const char *pName)
179 TryReturn(pName, true, "pName is null.");
183 if (__isParserMode == true)
185 TryReturn(__pParser, false, "__pParser is null");
186 __pParser->OnEndElement(pName);
188 if ((strcasecmp(pName, "Liveboxes") == 0) || strcasecmp(pName, "AppWidgets") == 0)
190 status = OnLiveboxesEndElement();
192 else if (strcasecmp(pName, "Accounts") == 0)
194 status = OnAccountsEndElement();
196 else if (strcasecmp(pName, "AppControls") == 0)
198 status = OnAppControlsEndElement();
204 if (strcasecmp(pName, "Privileges") == 0)
206 status = OnPrivilegesEndElement();
208 else if (strcasecmp(pName, "UiApp") == 0)
210 status = OnUiAppEndElement();
212 else if (strcasecmp(pName, "ServiceApp") == 0)
214 status = OnServiceAppEndElement();
216 else if (strcasecmp(pName, "DataControl") == 0)
218 status = OnDataControlEndElement();
220 else if (strcasecmp(pName, "DataControlType") == 0)
222 status = OnDataControlTypeEndElement();
224 else if (strcasecmp(pName, "Apps") == 0)
226 status = OnAppsEndElement();
228 else if (strcasecmp(pName, "UiScalability") == 0)
230 AppLog("</%s>", pName);
232 else if (strcasecmp(pName, "Icons") == 0)
234 status = OnIconsEndElement();
236 else if (strcasecmp(pName, "Contents") == 0)
238 status = OnContentsEndElement();
240 else if (strcasecmp(pName, "Content") == 0)
242 status = OnContentEndElement();
244 else if (strcasecmp(pName, "Manifest") == 0)
246 status = OnManifestEndElement();
258 ManifestHandler::OnCharacters(const char *pCharacters)
262 if (__isParserMode == true)
264 TryReturn(__pParser, false, "__pParser is null");
265 return __pParser->OnCharacters(pCharacters);
268 char *pName = GetElementName();
269 TryReturn(pName, false, "pName is null.");
271 if (strcasecmp(pName, "Id") == 0)
273 status = OnIdValue(pCharacters);
275 else if (strcasecmp(pName, "Version") == 0)
277 status = OnVersionValue(pCharacters);
279 else if (strcasecmp(pName, "Type") == 0)
281 status = OnTypeValue(pCharacters);
283 else if (strcasecmp(pName, "Url") == 0)
285 status = OnUrlValue(pCharacters);
287 else if (strcasecmp(pName, "ApiVersion") == 0)
289 status = OnApiVersionValue(pCharacters);
291 else if (strcasecmp(pName, "Privilege") == 0)
293 status = OnPrivilegeValue(pCharacters);
295 else if (strcasecmp(pName, "Name") == 0)
297 status = OnNameValue(pCharacters);
299 else if (strcasecmp(pName, "DisplayName") == 0)
301 status = OnNameValue(pCharacters);
303 else if (strcasecmp(pName, "Author") == 0)
305 status = OnAuthorValue(pCharacters);
307 else if (strcasecmp(pName, "Description") == 0)
309 status = OnDescriptionValue(pCharacters);
311 else if (strcasecmp(pName, "Icon") == 0)
313 status = OnIconValue(pCharacters);
315 else if (strcasecmp(pName, "DataControlType") == 0)
317 status = OnDataControlTypeValue(pCharacters);
319 else if (strcasecmp(pName, "Condition") == 0)
321 status = OnConditionValue(pCharacters);
323 else if (strcasecmp(pName, "Notification") == 0)
325 status = OnNotificationValue(pCharacters);
327 else if (strcasecmp(pName, "InstallationLocation") == 0)
329 status = OnInstallationLocationValue(pCharacters);
331 else if (strcasecmp(pName, "Category") == 0)
333 status = OnCategoryValue(pCharacters);
335 else if (strcasecmp(pName, "Metadata") == 0)
337 status = OnMetadataValue(pCharacters);
349 ManifestHandler::OnPrivilegesStartElement(void)
351 __pPrivilegeList = new (std::nothrow) ArrayList;
352 TryReturn(__pPrivilegeList, false, "__pPrivilegeList is null");
354 AppLog("<Privileges>");
360 ManifestHandler::OnUiAppStartElement(void)
362 __pAppData = new (std::nothrow) AppData;
363 TryReturn(__pAppData, false, "__pAppData is null");
365 InstallerError error = __pAppData->Construct();
366 TryReturn(error == INSTALLER_ERROR_NONE, false, "pAppData->Construct() failed.");
370 XmlAttribute *pAttr = GetAttribute();
371 TryReturn(pAttr, true, "pAttr is null");
373 ParseAppAttribute(pAttr, true);
379 ManifestHandler::OnServiceAppStartElement(void)
381 __pAppData = new (std::nothrow) AppData;
382 TryReturn(__pAppData, false, "__pAppData is null");
384 InstallerError error = __pAppData->Construct();
385 TryReturn(error == INSTALLER_ERROR_NONE, false, "pAppData->Construct() failed.");
387 AppLog("<ServiceApp>");
389 XmlAttribute *pAttr = GetAttribute();
390 TryReturn(pAttr, true, "pAttr is null");
392 ParseAppAttribute(pAttr, false);
398 ManifestHandler::OnIconsStartElement(void)
400 result r = E_SUCCESS;
402 String defaultIconType;
406 r = _SystemInfoImpl::GetSysInfo(L"ScreenWidth", width);
409 defaultIconType = L"Xhigh";
415 defaultIconType = L"High";
419 defaultIconType = L"Xhigh";
423 AppLog("ScreenWidth = [%d]", width);
425 __pDefaultIconType = _StringConverter::CopyToCharArrayN(defaultIconType);
426 TryReturn(__pDefaultIconType, false, "__pDefaultIconType is null.");
428 AppLog("DefaultIconType = [%s]", __pDefaultIconType);
434 ManifestHandler::OnUiScalabilityStartElement(void)
436 XmlAttribute *pAttr = null;
437 char* pCoordinateSystem = null;
438 char* pBaseScreenSize = null;
439 char* pLogicalCoordinate = null;
441 AppLog("<UiScalability>");
443 pAttr = GetAttribute();
444 TryReturn(pAttr, true, "pAttr is null");
446 pCoordinateSystem = pAttr->Find("CoordinateSystem");
447 if (pCoordinateSystem)
449 String* pKey = new (std::nothrow) String("CoordinateSystem");
450 TryReturn(pKey, false, "pKey is null");
451 String* pValue = new (std::nothrow) String(pCoordinateSystem);
452 TryReturn(pValue, false, "pValue is null");
454 __pAppData->__pFeatureList->Add(pKey, pValue);
455 AppLog("<CoordinateSystem=%s>", pCoordinateSystem);
458 pBaseScreenSize = pAttr->Find("BaseScreenSize");
461 String* pKey = new (std::nothrow) String("BaseScreenSize");
462 TryReturn(pKey, false, "pKey is null");
463 String* pValue = new (std::nothrow) String(pBaseScreenSize);
464 TryReturn(pValue, false, "pValue is null");
466 __pAppData->__pFeatureList->Add(pKey, pValue);
467 AppLog("<BaseScreenSize=%s>", pBaseScreenSize);
470 pLogicalCoordinate = pAttr->Find("LogicalCoordinate");
471 if (pLogicalCoordinate)
473 String* pKey = new (std::nothrow) String("LogicalCoordinate");
474 TryReturn(pKey, false, "pKey is null");
475 String* pValue = new (std::nothrow) String(pLogicalCoordinate);
476 TryReturn(pValue, false, "pValue is null");
478 __pAppData->__pFeatureList->Add(pKey, pValue);
479 AppLog("<LogicalCoordinate=%s>", pLogicalCoordinate);
486 ManifestHandler::OnUiThemeStartElement(void)
488 XmlAttribute *pAttr = null;
489 char *pSystemTheme = null;
490 char *pUserDefinedTheme = null;
494 pAttr = GetAttribute();
495 TryReturn(pAttr, true, "pAttr is null");
497 pSystemTheme = pAttr->Find("SystemTheme");
500 String* pKey = new (std::nothrow) String("SystemTheme");
501 TryReturn(pKey, false, "pKey is null");
502 String* pValue = new (std::nothrow) String(pSystemTheme);
503 TryReturn(pValue, false, "pValue is null");
505 __pAppData->__pFeatureList->Add(pKey, pValue);
506 AppLog("<SystemTheme=%s>", pSystemTheme);
509 pUserDefinedTheme = pAttr->Find("UserDefinedTheme");
510 if (pUserDefinedTheme)
512 String* pKey = new (std::nothrow) String("UserDefinedTheme");
513 TryReturn(pKey, false, "pKey is null");
514 String* pValue = new (std::nothrow) String(pUserDefinedTheme);
515 TryReturn(pValue, false, "pValue is null");
517 __pAppData->__pFeatureList->Add(pKey, pValue);
518 AppLog("<UserDefinedTheme=%s>", pUserDefinedTheme);
525 ManifestHandler::OnDataControlStartElement(void)
527 XmlAttribute* pAttr = null;
528 char* pProviderId = null;
530 pAttr = GetAttribute();
531 TryReturn(pAttr, true, "pAttr is null");
533 pProviderId = pAttr->Find("ProviderId");
534 TryReturn(pProviderId, true, "pProviderId is null");
536 __pDataControlInfo = new (std::nothrow) DataControlInfo;
537 TryReturn(__pDataControlInfo, false, "__pDataControlInfo is null");
539 __pDataControlInfo->__providerId = pProviderId;
541 AppLog("<DataControl ProviderId=\"%s\">", pProviderId);
547 ManifestHandler::OnContentsStartElement(void)
549 __pContentDataList = new (std::nothrow) ArrayList;
550 TryReturn(__pContentDataList, false, "__pContentDataList is null");
552 AppLog("<Contents>");
558 ManifestHandler::OnContentStartElement(void)
560 TryReturn(__pContentData == null, false, "__pContentData is not null");
562 XmlAttribute *pAttr = null;
563 char *pDefault = null;
565 __pContentData = new (std::nothrow) ContentData;
566 TryReturn(__pContentData, false, "__pContentData is null");
568 pAttr = GetAttribute();
569 TryReturn(pAttr, true, "pAttr is null");
571 char* pId = pAttr->Find("Id");
574 __pContentData->SetContentId(pId);
577 char* pEntryName = pAttr->Find("EntryName");
580 __pContentData->SetContentId(pEntryName);
583 pDefault = pAttr->Find("Default");
586 if (strcasecmp(pDefault, "True") == 0)
588 __isDefaultAppDetected = true;
592 AppLog("<Content Id=\"%s\" EntryName=\"%s\">", pId, pEntryName);
598 ManifestHandler::OnLiveboxesStartElement(const char *pName)
600 __pParser = new (std::nothrow) ManifestLiveboxesParser;
601 TryReturn(__pParser, false, "__pParser is null");
603 __isParserMode = true;
604 AppLog("------------------------------------------");
605 __pParser->Construct(this);
607 return __pParser->OnStartElement(pName);
611 ManifestHandler::OnAccountsStartElement(const char *pName)
613 __pParser = new (std::nothrow) ManifestAccountsParser;
614 TryReturn(__pParser, false, "__pParser is null");
616 __isParserMode = true;
617 AppLog("------------------------------------------");
618 __pParser->Construct(this);
620 return __pParser->OnStartElement(pName);
624 ManifestHandler::OnAppControlsStartElement(const char *pName)
626 __pParser = new (std::nothrow) ManifestAppControlsParser;
627 TryReturn(__pParser, false, "__pParser is null");
629 __isParserMode = true;
630 AppLog("------------------------------------------");
631 __pParser->Construct(this);
633 return __pParser->OnStartElement(pName);
637 ManifestHandler::OnPermissionStartElement(const char* pName)
639 XmlAttribute* pAttr = null;
642 pAttr = GetAttribute();
643 TryReturn(pAttr, true, "pAttr is null.");
645 pType = pAttr->Find("Type");
646 TryReturn(pType, true, "pType is null.");
648 if (__pAppData->__permissionType.IsEmpty() == true)
650 __pAppData->__permissionType = pType;
655 if (__pAppData->__permissionType.Equals(type, true) == false)
657 AppLog("Invalid Permission Type [%ls][%ls]", __pAppData->__permissionType.GetPointer(), type.GetPointer());
662 AppLog("<Permission Type=\"%s\">", pType);
668 ManifestHandler::OnPrivilegesEndElement(void)
670 if (__pContext->__isVerificationMode == false)
672 AppLog("no signature file[%ls]", __pContext->GetSignatureXmlPath().GetPointer());
674 result r = E_SUCCESS;
676 String hmacPrivileges;
677 ArrayList stringPrivilegeList;
678 stringPrivilegeList.Construct(125);
679 PackageId packageId = __pContext->__packageId;
681 if (__pPrivilegeList != null)
683 r = PrivilegeHandler::GenerateCipherPrivilege(packageId, *__pPrivilegeList, privileges, hmacPrivileges, stringPrivilegeList);
684 TryReturn(!IsFailed(r), false, "privMgr.GeneratePrivilegeString() failed");
687 __pContext->__privileges = privileges;
688 __pContext->__hmacPrivileges = hmacPrivileges;
689 __pContext->__pStringPrivilegeList = new ArrayList;
690 __pContext->__pStringPrivilegeList->Construct(stringPrivilegeList);
693 __pContext->SetPrivilegeList(__pPrivilegeList);
695 AppLog("</Privileges>");
701 ManifestHandler::OnUiAppEndElement(void)
703 if (__pAppData->__isSubMode == true)
705 __pAppData->__pSubModeAppControlDataList = __pAppData->__pAppControlDataList;
706 __pAppData->__pAppControlDataList = null;
707 __pAppData->__subModeAppName = __pAppData->__name;
710 __isDefaultName = false;
712 __pContext->__pAppDataList->Add(__pAppData);
721 ManifestHandler::OnServiceAppEndElement(void)
723 if (__pAppData->__isSubMode == true)
725 __pAppData->__pSubModeAppControlDataList = __pAppData->__pAppControlDataList;
726 __pAppData->__pAppControlDataList = null;
727 __pAppData->__subModeAppName = __pAppData->__name;
730 __isDefaultName = false;
732 __pContext->__pAppDataList->Add(__pAppData);
735 AppLog("</ServiceApp>");
741 ManifestHandler::OnAppsEndElement(void)
749 ManifestHandler::OnIconsEndElement(void)
757 ManifestHandler::OnDataControlEndElement(void)
759 __pAppData->__pDataControlList->Add(__pDataControlInfo);
760 __pDataControlInfo = null;
761 AppLog("</DataControl>");
767 ManifestHandler::OnDataControlTypeEndElement(void)
769 __pDataControlInfo->__pControlTypeList->Add(__pDataControlType);
770 __pDataControlType = null;
771 AppLog("</DataControlType>");
777 ManifestHandler::OnContentsEndElement(void)
779 __pContext->SetContentDataList(__pContentDataList);
780 __pContentDataList = null;
781 AppLog("</Contents>");
787 ManifestHandler::OnContentEndElement(void)
789 __pContentDataList->Add(*__pContentData);
790 __pContentData = null;
791 AppLog("</Content>");
797 ManifestHandler::OnLiveboxesEndElement(void)
800 __isParserMode = false;
801 AppLog("------------------------------------------");
807 ManifestHandler::OnAccountsEndElement(void)
810 __isParserMode = false;
811 AppLog("------------------------------------------");
817 ManifestHandler::OnAppControlsEndElement(void)
820 __isParserMode = false;
821 AppLog("------------------------------------------");
827 ManifestHandler::OnManifestEndElement(void)
829 TryReturn(__isDefaultAppDetected, false, "[osp-installer][Error] Main tag is not detected...");
830 AppLog("</Manifest>");
836 ManifestHandler::OnIdValue(const char *pCharacters)
838 AppLog("<Id>%s</Id>", pCharacters);
839 __pContext->__packageId = pCharacters;
845 ManifestHandler::OnVersionValue(const char *pCharacters)
847 AppLog("<Version>%s</Version>", pCharacters);
848 __pContext->__version = pCharacters;
854 ManifestHandler::OnTypeValue(const char *pCharacters)
856 AppLog("<Type>%s</Type>", pCharacters);
858 if (strcasecmp(pCharacters, "Contents") == 0)
860 __pContext->__apiVersion = L"3.0";
867 ManifestHandler::OnAuthorValue(const char *pCharacters)
869 AppLog("<Author>%s</Author>", pCharacters);
870 __pContext->__author = pCharacters;
876 ManifestHandler::OnUrlValue(const char *pCharacters)
878 __pContext->__url = pCharacters;
879 AppLog("<Url>%s</Url>", pCharacters);
885 ManifestHandler::OnApiVersionValue(const char *pCharacters)
887 __pContext->__apiVersion = pCharacters;
888 AppLog("<ApiVersion>%s</ApiVersion>", pCharacters);
890 XmlAttribute *pAttr = GetAttribute();
893 char* pOspCompat = pAttr->Find("OspCompat");
896 AppLog(" - OspCompat=%s", pOspCompat);
897 __pContext->__isOspCompat = true;
905 ManifestHandler::OnPrivilegeValue(const char *pCharacters)
907 __pPrivilegeList->Add(*new (std::nothrow) String(pCharacters));
908 AppLog("<Privilege>%s</Privilege>", pCharacters);
914 ManifestHandler::OnIconValue(const char *pCharacters)
916 AppLog("<Icon>%s</Icon>", pCharacters);
918 XmlAttribute* pAttr = GetAttribute();
919 TryReturn(pAttr, true, "pAttr is null");
921 char* pSection = pAttr->Find("Section");
922 TryReturn(pSection, true, "pSection is null");
923 AppLog(" - Section=%s", pSection);
925 TryReturn(__pDefaultIconType, false, "__pDefaultIconType is null");
928 char* pType = pAttr->Find("Type");
931 AppLog("__pDefaultIconType=%s", __pDefaultIconType);
932 if (strcasecmp(__pDefaultIconType, "Xhigh") == 0)
934 iconRelPath.Format(1024, L"screen-density-xhigh/%s", pCharacters);
936 else if (strcasecmp(__pDefaultIconType, "High") == 0)
938 iconRelPath.Format(1024, L"screen-density-high/%s", pCharacters);
942 TryReturn(0, false, "Invalid __pDefaultIconType[%s]", __pDefaultIconType);
947 AppLog(" - Type=%s", pType);
948 if (strcasecmp(pType, "Xhigh") == 0)
950 iconRelPath.Format(1024, L"screen-density-xhigh/%s", pCharacters);
952 else if (strcasecmp(pType, "High") == 0)
954 iconRelPath.Format(1024, L"screen-density-high/%s", pCharacters);
958 TryReturn(0, false, "Invalid IconType [%s]", __pDefaultIconType);
962 if (FindElement("Content") == true)
964 TryReturn(__pContentData, false, "__pContentData is null");
965 __pContentData->SetIcon(iconRelPath);
971 if (strcasecmp(pSection, "MainMenu") == 0)
973 __pAppData->__mainmenuIcon = iconRelPath;
975 else if (strcasecmp(pSection, "Setting") == 0)
977 __pAppData->__settingIcon = iconRelPath;
979 else if (strcasecmp(pSection, "Notification") == 0)
981 __pAppData->__notificationIcon = iconRelPath;
986 if (strcasecmp(pSection, "MainMenu") == 0)
988 if (__isDefaultMainmenu == false)
990 __pAppData->__mainmenuIcon = iconRelPath;
993 if (strcasecmp(pType, __pDefaultIconType) == 0)
995 __isDefaultMainmenu = true;
998 else if (strcasecmp(pSection, "Setting") == 0)
1000 if (__isDefaultSetting == false)
1002 __pAppData->__settingIcon = iconRelPath;
1005 if (strcasecmp(pType, __pDefaultIconType) == 0)
1007 __isDefaultSetting = true;
1010 else if (strcasecmp(pSection, "Notification") == 0)
1012 if (__isDefaultQuickpanel == false)
1014 __pAppData->__notificationIcon = iconRelPath;
1017 if (strcasecmp(pType, __pDefaultIconType) == 0)
1019 __isDefaultQuickpanel = true;
1029 ManifestHandler::OnNameValue(const char *pCharacters)
1031 XmlAttribute* pAttr = 0;
1032 char* pAttrValue = 0;
1034 pAttr = GetAttribute();
1035 TryReturn(pAttr, true, "pAttr is null");
1037 pAttrValue = pAttr->Find("Locale");
1038 TryReturn(pAttrValue, true, "pAttrValue is null");
1040 if (FindElement("Content") == true)
1042 TryReturn(__pContentData, false, "__pContentData is null");
1044 String* pValue = new (std::nothrow) String;
1045 StringUtil::Utf8ToString(pCharacters, *pValue);
1046 __pContentData->AddName(*(new (std::nothrow) String(pAttrValue)), *pValue);
1050 if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
1052 if (__isDefaultName == true)
1054 __pContext->__displayName = pCharacters;
1058 String* pValue = new (std::nothrow) String;
1059 StringUtil::Utf8ToString(pCharacters, *pValue);
1061 __pAppData->__pNameList->Add((new (std::nothrow) String(pAttrValue)), pValue);
1064 AppLog("<DisplayName Locale=\"%s\">%s</DisplayName>", pAttrValue, pCharacters);
1070 ManifestHandler::OnDescriptionValue(const char *pCharacters)
1072 XmlAttribute *pAttr = 0;
1073 char *pAttrValue = 0;
1075 pAttr = GetAttribute();
1076 TryReturn(pAttr, true, "pAttr is null");
1078 pAttrValue = pAttr->Find("Locale");
1079 TryReturn(pAttrValue, true, "pAttrValue is null");
1081 if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
1083 __pContext->__description = pCharacters;
1086 AppLog("<Description Locale=\"%s\">%s</Description>", pAttrValue, pCharacters);
1092 ManifestHandler::OnDataControlTypeValue(const char *pCharacters)
1094 XmlAttribute* pAttr = null;
1095 char* pAccessValue = null;
1097 pAttr = GetAttribute();
1098 TryReturn(pAttr, true, "pAttr is null");
1100 pAccessValue = pAttr->Find("Access");
1101 TryReturn(pAccessValue, true, "pAccessValue is null");
1103 __pDataControlType = new (std::nothrow) DataControlType;
1104 TryReturn(__pDataControlType, false, "__pDataControlType is null");
1106 __pDataControlType->__type = pCharacters;
1107 __pDataControlType->__access = pAccessValue;
1109 AppLog("<DataControlType Access=\"%s\", Type=\"%s\">", pAccessValue, pCharacters);
1115 ManifestHandler::OnConditionValue(const char *pCharacters)
1117 XmlAttribute *pAttr = null;
1120 pAttr = GetAttribute();
1121 TryReturn(pAttr, true, "pAttr is null");
1123 pName = pAttr->Find("Name");
1124 TryReturn(pName, true, "pName is null");
1126 String* pKey = new (std::nothrow) String(pName);
1127 TryReturn(pKey, false, "pKey is null");
1128 String* pValue = new (std::nothrow) String(pCharacters);
1129 TryReturn(pValue, false, "pValue is null");
1131 __pAppData->__pLaunchConditionList->Add(pKey, pValue);
1132 AppLog("<LaunchCondition Name=\"%s\", Value=\"%s\">", pName, pCharacters);
1138 ManifestHandler::OnNotificationValue(const char *pCharacters)
1140 XmlAttribute *pAttr = null;
1141 const char *pName = null;
1143 pAttr = GetAttribute();
1144 TryReturn(pAttr, true, "pAttr is null.");
1146 pName = pAttr->Find("Name");
1147 TryReturn(pName, true, "pName is null.");
1149 if (strcasecmp(pName, "Ticker") == 0)
1151 pName = "Notification";
1153 else if (strcasecmp(pName, "Notification") == 0 || strcasecmp(pName, "Sounds") == 0
1154 || strcasecmp(pName, "Badge") == 0 || strcasecmp(pName, "Contents") == 0)
1156 // known notification attributes
1160 TryReturn(0, true, "Unknown notification attributes=%s", pCharacters);
1163 String* pKey = new (std::nothrow) String(pName);
1164 TryReturn(pKey, false, "pKey is null.");
1166 String* pValue = new (std::nothrow) String(pCharacters);
1167 TryReturn(pValue, false, "pValue is null.");
1169 pKey->ToLowerCase();
1170 pValue->ToLowerCase();
1172 __pAppData->__pNotificationMap->Add(pKey, pValue);
1173 AppLog("<Notification Name=\"%s\", Value=\"%s\">", pName, pCharacters);
1179 ManifestHandler::OnInstallationLocationValue(const char *pCharacters)
1181 AppLog("<InstallationLocation>%s</InstallationLocation>", pCharacters);
1183 if ((strcasecmp(pCharacters, "UserPreferred") == 0) &&
1184 (File::IsFileExist(DIR_MEMORYCARD_INSTALLATION) == true))
1186 AppLog("INSTALLATION_STORAGE = [EXTERNAL]");
1187 __pContext->__storage = INSTALLATION_STORAGE_EXTERNAL;
1194 ManifestHandler::OnCategoryValue(const char *pCharacters)
1196 TryReturn(__pAppData, false, "__pAppData is null");
1198 __pAppData->__pCategoryList->Add(new (std::nothrow) String(pCharacters));
1200 if (strcasecmp(pCharacters, TIZEN_CATEGORY_IME) == 0)
1202 __pAppData->__feature = CATEGORY_TYPE_IME;
1209 ManifestHandler::OnMetadataValue(const char* pCharacters)
1211 TryReturn(__pAppData, false, "__pAppData is null");
1213 XmlAttribute* pAttr = null;
1216 pAttr = GetAttribute();
1217 TryReturn(pAttr, true, "pAttr is null.");
1219 pKey = pAttr->Find("Key");
1220 TryReturn(pKey, true, "pKey is null.");
1222 __pAppData->__pMetadataMap->Add(*(new (std::nothrow) String(pKey)), *(new (std::nothrow) String(pCharacters)));
1224 AppLog("<Metadata Key=\"%s\">%s</Metadata>", pKey, pCharacters);
1230 ManifestHandler::FindElement(const char *pName)
1233 Tizen::Base::Collection::IEnumerator* pEnum = GetElementEnumeratorN();
1237 while(pEnum->MoveNext() == E_SUCCESS)
1239 String* pStr = static_cast<String*>(pEnum->GetCurrent());
1242 if (pStr->Equals(pName, false) == true)
1244 AppLog("[%s] is matched.", pName);
1258 ManifestHandler::AddAppFeature(const Tizen::Base::String& name, const Tizen::Base::String& value)
1260 String* pKey = new (std::nothrow) String(name);
1261 TryReturn(pKey, false, "pKey is null");
1262 String* pValue = new (std::nothrow) String(value);
1263 TryReturn(pValue, false, "pValue is null");
1265 __pAppData->__pFeatureList->Add(pKey, pValue);
1270 ManifestHandler::ParseAppAttribute(XmlAttribute* pAttr, bool isUiApp)
1272 char* pName = pAttr->Find("Name");
1275 pName = pAttr->Find("ExecutableName");
1280 AppLog(" - Name=%s", pName);
1281 __pAppData->__name = pName;
1282 __pAppData->__appId = __pContext->__packageId + L"." + pName;
1285 char* pMain = pAttr->Find("Main");
1288 pMain = pAttr->Find("Default");
1293 AppLog(" - Main=%s", pMain);
1294 __pAppData->__main = pMain;
1296 if (strcasecmp(pMain, "True") == 0)
1298 __isDefaultName = true;
1299 __isDefaultAppDetected = true;
1300 __pContext->__mainAppName = pName;
1305 __pAppData->__main = L"False";
1308 char* pRecent = pAttr->Find("LaunchingHistoryVisible");
1311 AppLog(" - LaunchingHistoryVisible=%s", pRecent);
1312 __pAppData->__launchingHistoryVisible = pRecent;
1315 char* pHwAcceleration = pAttr->Find("HwAcceleration");
1316 if (pHwAcceleration)
1318 AddAppFeature("HwAcceleration", pHwAcceleration);
1319 AppLog(" - HwAcceleration=%s", pHwAcceleration);
1323 char* pGlFrame = pAttr->Find("GlFrame");
1326 AddAppFeature("GlFrame", pGlFrame);
1327 AppLog(" - GlFrame=%s", pGlFrame);
1331 char* pCategory = pAttr->Find("Category");
1334 AppLog(" - Category=%s", pCategory);
1336 if (strcasecmp(pCategory, "home-screen") == 0)
1338 __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_HOMESCREEN));
1340 else if (strcasecmp(pCategory, "lock-screen") == 0)
1342 __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_LOCKSCREEN));
1344 else if (strcasecmp(pCategory, "Ime") == 0)
1346 __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_IME));
1349 int categoryType = InstallerUtil::GetCategoryType(pCategory);
1350 __pAppData->__feature = categoryType;
1353 char* pSubMode = pAttr->Find("SubMode");
1356 if (strcasecmp(pSubMode, "True") == 0)
1358 __pAppData->__isSubMode = true;
1359 AppLog(" - SubMode=%s", pSubMode);
1363 if (isUiApp == true)
1365 __pAppData->__type = L"UiApp";
1367 char* pMenuIconVisible = pAttr->Find("MenuIconVisible");
1368 if (pMenuIconVisible == null)
1370 pMenuIconVisible = pAttr->Find("MainmenuVisible");
1373 if (pMenuIconVisible)
1375 if (strcasecmp(pMenuIconVisible, "True") == 0)
1377 __pAppData->__mainmenuVisible = true;
1381 __pAppData->__mainmenuVisible = false;
1384 AddAppFeature("MenuIconVisible", pMenuIconVisible);
1385 AppLog(" - MenuIconVisible=%s", pMenuIconVisible);
1390 __pAppData->__type = L"ServiceApp";
1391 __pAppData->__mainmenuVisible = false;
1393 char *pUseUi = pAttr->Find("UseUi");
1396 AddAppFeature("UseUi", pUseUi);
1397 AppLog(" - UseUi=%s", pUseUi);
1400 char *pLifeDuration = pAttr->Find("LifeDuration");
1403 AddAppFeature("LifeDuration", pLifeDuration);
1404 AppLog(" - LifeDuration=%s", pLifeDuration);
1407 char *pLaunchOnBoot = pAttr->Find("LaunchOnBoot");
1410 AddAppFeature("LaunchOnBoot", pLaunchOnBoot);
1411 AppLog(" - LaunchOnBoot=%s", pLaunchOnBoot);
1414 char *pAutoRestart = pAttr->Find("AutoRestart");
1417 AddAppFeature("AutoRestart", pAutoRestart);
1418 AppLog(" - AutoRestart=%s", pAutoRestart);
1421 char *pSystemService = pAttr->Find("SystemService");
1424 if (strcasecmp(pSystemService, "True") == 0)
1426 __pAppData->__isSystemService = true;
1427 AppLog(" - SystemService=%s", pSystemService);
1432 AppLog(" - appId=%ls", __pAppData->__appId.GetPointer());
1438 ManifestHandler::GetAppData(void)
1444 ManifestHandler::GetDefaultIconType(void)
1446 return __pDefaultIconType;