// // Open Service Platform // Copyright (c) 2012 Samsung Electronics Co., Ltd. // // Licensed under the Apache License, Version 2.0 (the License); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // /** * @file ManifestHandler.cpp * @brief This is the implementation file for %ManifestHandler class. */ #include #include #include #include "ManifestHandler.h" #include "PrivilegeHandler.h" #include "InstallerUtil.h" #include "ManifestLiveboxesParser.h" #include "ManifestAccountsParser.h" #include "ManifestAppControlsParser.h" using namespace Tizen::Base; using namespace Tizen::Base::Collection; using namespace Tizen::Base::Utility; using namespace Tizen::App; using namespace Tizen::Io; using namespace Tizen::System; ManifestHandler::ManifestHandler(void) :__pContext(null) ,__pPrivilegeList(null) ,__pContentDataList(null) ,__pAppControlInfoImpl(null) ,__pAppControlCapabilityInfoImpl(null) ,__pAppControlResolutionInfoImpl(null) ,__pDataControlInfo(null) ,__pDataControlType(null) ,__pContentData(null) ,__pDefaultIconType(null) ,__isDefaultMainmenu(false) ,__isDefaultSetting(false) ,__isDefaultTicker(false) ,__isDefaultQuickpanel(false) ,__isDefaultLaunchImage(false) ,__isDefaultName(false) ,__isDefaultAppDetected(false) ,__pAppData(null) ,__isParserMode(false) ,__pParser(null) { } ManifestHandler::~ManifestHandler(void) { delete[] __pDefaultIconType; __pDefaultIconType = null; } bool ManifestHandler::Construct(InstallationContext* pContext) { __pContext = pContext; return true; } InstallationContext* ManifestHandler::GetContext(void) { return __pContext; } bool ManifestHandler::Parse(const char *pFilepath) { return ParseDocument(pFilepath); } bool ManifestHandler::OnStartElement(const char *pName) { TryReturn(pName, true, "pName is null."); bool status = true; if (__isParserMode == true) { TryReturn(__pParser, false, "__pParser is null"); return __pParser->OnStartElement(pName); } if (strcasecmp(pName, "Manifest") == 0) { AppLog("------------------------------------------"); AppLog("manifest.xml"); AppLog("------------------------------------------"); AppLog("<%s>", pName); } else if (strcasecmp(pName, "Apps") == 0) { AppLog("<%s>", pName); } else if (strcasecmp(pName, "UiApp") == 0) { status = OnUiAppStartElement(); } else if (strcasecmp(pName, "ServiceApp") == 0) { status = OnServiceAppStartElement(); } else if (strcasecmp(pName, "DataControl") == 0) { status = OnDataControlStartElement(); } else if (strcasecmp(pName, "Privileges") == 0) { status = OnPrivilegesStartElement(); } else if (strcasecmp(pName, "UiScalability") == 0) { status = OnUiScalabilityStartElement(); } else if (strcasecmp(pName, "UiTheme") == 0) { status = OnUiThemeStartElement(); } else if (strcasecmp(pName, "Icons") == 0) { status = OnIconsStartElement(); } else if (strcasecmp(pName, "Contents") == 0) { status = OnContentsStartElement(); } else if (strcasecmp(pName, "Content") == 0) { status = OnContentStartElement(); } else if ((strcasecmp(pName, "Liveboxes") == 0) || strcasecmp(pName, "AppWidgets") == 0) { status = OnLiveboxesStartElement(pName); } else if (strcasecmp(pName, "Accounts") == 0) { status = OnAccountsStartElement(pName); } else if (strcasecmp(pName, "AppControls") == 0) { status = OnAppControlsStartElement(pName); } else if (strcasecmp(pName, "Permission") == 0) { status = OnPermissionStartElement(pName); } if (!status) { __isParserMode = false; return false; } return true; } bool ManifestHandler::OnEndElement(const char *pName) { TryReturn(pName, true, "pName is null."); bool status = true; if (__isParserMode == true) { TryReturn(__pParser, false, "__pParser is null"); __pParser->OnEndElement(pName); if ((strcasecmp(pName, "Liveboxes") == 0) || strcasecmp(pName, "AppWidgets") == 0) { status = OnLiveboxesEndElement(); } else if (strcasecmp(pName, "Accounts") == 0) { status = OnAccountsEndElement(); } else if (strcasecmp(pName, "AppControls") == 0) { status = OnAppControlsEndElement(); } return status; } if (strcasecmp(pName, "Privileges") == 0) { status = OnPrivilegesEndElement(); } else if (strcasecmp(pName, "UiApp") == 0) { status = OnUiAppEndElement(); } else if (strcasecmp(pName, "ServiceApp") == 0) { status = OnServiceAppEndElement(); } else if (strcasecmp(pName, "DataControl") == 0) { status = OnDataControlEndElement(); } else if (strcasecmp(pName, "DataControlType") == 0) { status = OnDataControlTypeEndElement(); } else if (strcasecmp(pName, "Apps") == 0) { status = OnAppsEndElement(); } else if (strcasecmp(pName, "UiScalability") == 0) { AppLog("", pName); } else if (strcasecmp(pName, "Icons") == 0) { status = OnIconsEndElement(); } else if (strcasecmp(pName, "Contents") == 0) { status = OnContentsEndElement(); } else if (strcasecmp(pName, "Content") == 0) { status = OnContentEndElement(); } else if (strcasecmp(pName, "Manifest") == 0) { status = OnManifestEndElement(); } if (!status) { return false; } return true; } bool ManifestHandler::OnCharacters(const char *pCharacters) { bool status = true; if (__isParserMode == true) { TryReturn(__pParser, false, "__pParser is null"); return __pParser->OnCharacters(pCharacters); } char *pName = GetElementName(); TryReturn(pName, false, "pName is null."); if (strcasecmp(pName, "Id") == 0) { status = OnIdValue(pCharacters); } else if (strcasecmp(pName, "Version") == 0) { status = OnVersionValue(pCharacters); } else if (strcasecmp(pName, "Type") == 0) { status = OnTypeValue(pCharacters); } else if (strcasecmp(pName, "Url") == 0) { status = OnUrlValue(pCharacters); } else if (strcasecmp(pName, "ApiVersion") == 0) { status = OnApiVersionValue(pCharacters); } else if (strcasecmp(pName, "Privilege") == 0) { status = OnPrivilegeValue(pCharacters); } else if (strcasecmp(pName, "Name") == 0) { status = OnNameValue(pCharacters); } else if (strcasecmp(pName, "DisplayName") == 0) { status = OnNameValue(pCharacters); } else if (strcasecmp(pName, "Author") == 0) { status = OnAuthorValue(pCharacters); } else if (strcasecmp(pName, "Description") == 0) { status = OnDescriptionValue(pCharacters); } else if (strcasecmp(pName, "Icon") == 0) { status = OnIconValue(pCharacters); } else if (strcasecmp(pName, "DataControlType") == 0) { status = OnDataControlTypeValue(pCharacters); } else if (strcasecmp(pName, "Condition") == 0) { status = OnConditionValue(pCharacters); } else if (strcasecmp(pName, "Notification") == 0) { status = OnNotificationValue(pCharacters); } else if (strcasecmp(pName, "InstallationLocation") == 0) { status = OnInstallationLocationValue(pCharacters); } else if (strcasecmp(pName, "Category") == 0) { status = OnCategoryValue(pCharacters); } if (!status) { return false; } return true; } bool ManifestHandler::OnPrivilegesStartElement(void) { __pPrivilegeList = new (std::nothrow) ArrayList; TryReturn(__pPrivilegeList, false, "__pPrivilegeList is null"); AppLog(""); return true; } bool ManifestHandler::OnUiAppStartElement(void) { __pAppData = new (std::nothrow) AppData; TryReturn(__pAppData, false, "__pAppData is null"); InstallerError error = __pAppData->Construct(); TryReturn(error == INSTALLER_ERROR_NONE, false, "pAppData->Construct() failed."); AppLog(""); XmlAttribute *pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); ParseAppAttribute(pAttr, true); return true; } bool ManifestHandler::OnServiceAppStartElement(void) { __pAppData = new (std::nothrow) AppData; TryReturn(__pAppData, false, "__pAppData is null"); InstallerError error = __pAppData->Construct(); TryReturn(error == INSTALLER_ERROR_NONE, false, "pAppData->Construct() failed."); AppLog(""); XmlAttribute *pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); ParseAppAttribute(pAttr, false); return true; } bool ManifestHandler::OnIconsStartElement(void) { result r = E_SUCCESS; int width = 0; String defaultIconType; AppLog(""); r = _SystemInfoImpl::GetSysInfo(L"ScreenWidth", width); if (IsFailed(r)) { defaultIconType = L"Xhigh"; } else { if (width == 480) { defaultIconType = L"High"; } else { defaultIconType = L"Xhigh"; } } AppLog("ScreenWidth = [%d]", width); __pDefaultIconType = _StringConverter::CopyToCharArrayN(defaultIconType); TryReturn(__pDefaultIconType, false, "__pDefaultIconType is null."); AppLog("DefaultIconType = [%s]", __pDefaultIconType); return true; } bool ManifestHandler::OnUiScalabilityStartElement(void) { XmlAttribute *pAttr = null; char* pCoordinateSystem = null; char* pBaseScreenSize = null; char* pLogicalCoordinate = null; AppLog(""); pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); pCoordinateSystem = pAttr->Find("CoordinateSystem"); if (pCoordinateSystem) { String* pKey = new (std::nothrow) String("CoordinateSystem"); TryReturn(pKey, false, "pKey is null"); String* pValue = new (std::nothrow) String(pCoordinateSystem); TryReturn(pValue, false, "pValue is null"); __pAppData->__pFeatureList->Add(pKey, pValue); AppLog("", pCoordinateSystem); } pBaseScreenSize = pAttr->Find("BaseScreenSize"); if (pBaseScreenSize) { String* pKey = new (std::nothrow) String("BaseScreenSize"); TryReturn(pKey, false, "pKey is null"); String* pValue = new (std::nothrow) String(pBaseScreenSize); TryReturn(pValue, false, "pValue is null"); __pAppData->__pFeatureList->Add(pKey, pValue); AppLog("", pBaseScreenSize); } pLogicalCoordinate = pAttr->Find("LogicalCoordinate"); if (pLogicalCoordinate) { String* pKey = new (std::nothrow) String("LogicalCoordinate"); TryReturn(pKey, false, "pKey is null"); String* pValue = new (std::nothrow) String(pLogicalCoordinate); TryReturn(pValue, false, "pValue is null"); __pAppData->__pFeatureList->Add(pKey, pValue); AppLog("", pLogicalCoordinate); } return true; } bool ManifestHandler::OnUiThemeStartElement(void) { XmlAttribute *pAttr = null; char *pSystemTheme = null; char *pUserDefinedTheme = null; AppLog(""); pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); pSystemTheme = pAttr->Find("SystemTheme"); if (pSystemTheme) { String* pKey = new (std::nothrow) String("SystemTheme"); TryReturn(pKey, false, "pKey is null"); String* pValue = new (std::nothrow) String(pSystemTheme); TryReturn(pValue, false, "pValue is null"); __pAppData->__pFeatureList->Add(pKey, pValue); AppLog("", pSystemTheme); } pUserDefinedTheme = pAttr->Find("UserDefinedTheme"); if (pUserDefinedTheme) { String* pKey = new (std::nothrow) String("UserDefinedTheme"); TryReturn(pKey, false, "pKey is null"); String* pValue = new (std::nothrow) String(pUserDefinedTheme); TryReturn(pValue, false, "pValue is null"); __pAppData->__pFeatureList->Add(pKey, pValue); AppLog("", pUserDefinedTheme); } return true; } bool ManifestHandler::OnDataControlStartElement(void) { XmlAttribute* pAttr = null; char* pProviderId = null; pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); pProviderId = pAttr->Find("ProviderId"); TryReturn(pProviderId, true, "pProviderId is null"); __pDataControlInfo = new (std::nothrow) DataControlInfo; TryReturn(__pDataControlInfo, false, "__pDataControlInfo is null"); __pDataControlInfo->__providerId = pProviderId; AppLog("", pProviderId); return true; } bool ManifestHandler::OnContentsStartElement(void) { __pContentDataList = new (std::nothrow) ArrayList; TryReturn(__pContentDataList, false, "__pContentDataList is null"); AppLog(""); return true; } bool ManifestHandler::OnContentStartElement(void) { TryReturn(__pContentData == null, false, "__pContentData is not null"); XmlAttribute *pAttr = null; char *pDefault = null; __pContentData = new (std::nothrow) ContentData; TryReturn(__pContentData, false, "__pContentData is null"); pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); char* pId = pAttr->Find("Id"); if (pId) { __pContentData->SetContentId(pId); } char* pEntryName = pAttr->Find("EntryName"); if (pEntryName) { __pContentData->SetContentId(pEntryName); } pDefault = pAttr->Find("Default"); if (pDefault) { if (strcasecmp(pDefault, "True") == 0) { __isDefaultAppDetected = true; } } AppLog("", pId, pEntryName); return true; } bool ManifestHandler::OnLiveboxesStartElement(const char *pName) { __pParser = new (std::nothrow) ManifestLiveboxesParser; TryReturn(__pParser, false, "__pParser is null"); __isParserMode = true; AppLog("------------------------------------------"); __pParser->Construct(this); return __pParser->OnStartElement(pName); } bool ManifestHandler::OnAccountsStartElement(const char *pName) { __pParser = new (std::nothrow) ManifestAccountsParser; TryReturn(__pParser, false, "__pParser is null"); __isParserMode = true; AppLog("------------------------------------------"); __pParser->Construct(this); return __pParser->OnStartElement(pName); } bool ManifestHandler::OnAppControlsStartElement(const char *pName) { __pParser = new (std::nothrow) ManifestAppControlsParser; TryReturn(__pParser, false, "__pParser is null"); __isParserMode = true; AppLog("------------------------------------------"); __pParser->Construct(this); return __pParser->OnStartElement(pName); } bool ManifestHandler::OnPermissionStartElement(const char* pName) { XmlAttribute* pAttr = null; char* pType = null; pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null."); pType = pAttr->Find("Type"); TryReturn(pType, true, "pType is null."); if (__pAppData->__permissionType.IsEmpty() == true) { __pAppData->__permissionType = pType; } else { String type = pType; if (__pAppData->__permissionType.Equals(type, true) == false) { AppLog("Invalid Permission Type [%ls][%ls]", __pAppData->__permissionType.GetPointer(), type.GetPointer()); return false; } } AppLog("", pType); return true; } bool ManifestHandler::OnPrivilegesEndElement(void) { if (__pContext->__isVerificationMode == false) { AppLog("no signature file[%ls]", __pContext->GetSignatureXmlPath().GetPointer()); result r = E_SUCCESS; String privileges; String hmacPrivileges; ArrayList stringPrivilegeList; stringPrivilegeList.Construct(125); PackageId packageId = __pContext->__packageId; r = PrivilegeHandler::GenerateCipherPrivilege(packageId, *__pPrivilegeList, privileges, hmacPrivileges, stringPrivilegeList); TryReturn(!IsFailed(r), false, "privMgr.GeneratePrivilegeString() failed"); __pContext->__privileges = privileges; __pContext->__hmacPrivileges = hmacPrivileges; __pContext->__pStringPrivilegeList = new ArrayList; __pContext->__pStringPrivilegeList->Construct(stringPrivilegeList); } __pContext->SetPrivilegeList(__pPrivilegeList); AppLog(""); return true; } bool ManifestHandler::OnUiAppEndElement(void) { if (__pAppData->__isSubMode == true) { __pAppData->__pSubModeAppControlDataList = __pAppData->__pAppControlDataList; __pAppData->__pAppControlDataList = null; __pAppData->__subModeAppName = __pAppData->__name; } __isDefaultName = false; __pContext->__pAppDataList->Add(__pAppData); __pAppData = null; AppLog(""); return true; } bool ManifestHandler::OnServiceAppEndElement(void) { if (__pAppData->__isSubMode == true) { __pAppData->__pSubModeAppControlDataList = __pAppData->__pAppControlDataList; __pAppData->__pAppControlDataList = null; __pAppData->__subModeAppName = __pAppData->__name; } __isDefaultName = false; __pContext->__pAppDataList->Add(__pAppData); __pAppData = null; AppLog(""); return true; } bool ManifestHandler::OnAppsEndElement(void) { AppLog(""); return true; } bool ManifestHandler::OnIconsEndElement(void) { AppLog(""); return true; } bool ManifestHandler::OnDataControlEndElement(void) { __pAppData->__pDataControlList->Add(__pDataControlInfo); __pDataControlInfo = null; AppLog(""); return true; } bool ManifestHandler::OnDataControlTypeEndElement(void) { __pDataControlInfo->__pControlTypeList->Add(__pDataControlType); __pDataControlType = null; AppLog(""); return true; } bool ManifestHandler::OnContentsEndElement(void) { __pContext->SetContentDataList(__pContentDataList); __pContentDataList = null; AppLog(""); return true; } bool ManifestHandler::OnContentEndElement(void) { __pContentDataList->Add(*__pContentData); __pContentData = null; AppLog(""); return true; } bool ManifestHandler::OnLiveboxesEndElement(void) { delete __pParser; __isParserMode = false; AppLog("------------------------------------------"); return true; } bool ManifestHandler::OnAccountsEndElement(void) { delete __pParser; __isParserMode = false; AppLog("------------------------------------------"); return true; } bool ManifestHandler::OnAppControlsEndElement(void) { delete __pParser; __isParserMode = false; AppLog("------------------------------------------"); return true; } bool ManifestHandler::OnManifestEndElement(void) { TryReturn(__isDefaultAppDetected, false, "[osp-installer][Error] Main tag is not detected..."); AppLog(""); return true; } bool ManifestHandler::OnIdValue(const char *pCharacters) { AppLog("%s", pCharacters); __pContext->__packageId = pCharacters; return true; } bool ManifestHandler::OnVersionValue(const char *pCharacters) { AppLog("%s", pCharacters); __pContext->__version = pCharacters; return true; } bool ManifestHandler::OnTypeValue(const char *pCharacters) { AppLog("%s", pCharacters); if (strcasecmp(pCharacters, "Contents") == 0) { __pContext->__apiVersion = L"3.0"; } return true; } bool ManifestHandler::OnAuthorValue(const char *pCharacters) { AppLog("%s", pCharacters); __pContext->__author = pCharacters; return true; } bool ManifestHandler::OnUrlValue(const char *pCharacters) { __pContext->__url = pCharacters; AppLog("%s", pCharacters); return true; } bool ManifestHandler::OnApiVersionValue(const char *pCharacters) { __pContext->__apiVersion = pCharacters; AppLog("%s", pCharacters); XmlAttribute *pAttr = GetAttribute(); if (pAttr) { char* pOspCompat = pAttr->Find("OspCompat"); if (pOspCompat) { AppLog(" - OspCompat=%s", pOspCompat); __pContext->__isOspCompat = true; } } return true; } bool ManifestHandler::OnPrivilegeValue(const char *pCharacters) { __pPrivilegeList->Add(*new (std::nothrow) String(pCharacters)); AppLog("%s", pCharacters); return true; } bool ManifestHandler::OnIconValue(const char *pCharacters) { AppLog("%s", pCharacters); XmlAttribute* pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); char* pSection = pAttr->Find("Section"); TryReturn(pSection, true, "pSection is null"); AppLog(" - Section=%s", pSection); TryReturn(__pDefaultIconType, false, "__pDefaultIconType is null"); String iconRelPath; char* pType = pAttr->Find("Type"); if (pType == null) { AppLog("__pDefaultIconType=%s", __pDefaultIconType); if (strcasecmp(__pDefaultIconType, "Xhigh") == 0) { iconRelPath.Format(1024, L"screen-density-xhigh/%s", pCharacters); } else if (strcasecmp(__pDefaultIconType, "High") == 0) { iconRelPath.Format(1024, L"screen-density-high/%s", pCharacters); } else { TryReturn(0, false, "Invalid __pDefaultIconType[%s]", __pDefaultIconType); } } else // legacy { AppLog(" - Type=%s", pType); if (strcasecmp(pType, "Xhigh") == 0) { iconRelPath.Format(1024, L"screen-density-xhigh/%s", pCharacters); } else if (strcasecmp(pType, "High") == 0) { iconRelPath.Format(1024, L"screen-density-high/%s", pCharacters); } else { TryReturn(0, false, "Invalid IconType [%s]", __pDefaultIconType); } } if (FindElement("Content") == true) { TryReturn(__pContentData, false, "__pContentData is null"); __pContentData->SetIcon(iconRelPath); } else { if (pType == null) { if (strcasecmp(pSection, "MainMenu") == 0) { __pAppData->__mainmenuIcon = iconRelPath; } else if (strcasecmp(pSection, "Setting") == 0) { __pAppData->__settingIcon = iconRelPath; } else if (strcasecmp(pSection, "Notification") == 0) { __pAppData->__notificationIcon = iconRelPath; } } else // legacy { if (strcasecmp(pSection, "MainMenu") == 0) { if (__isDefaultMainmenu == false) { __pAppData->__mainmenuIcon = iconRelPath; } if (strcasecmp(pType, __pDefaultIconType) == 0) { __isDefaultMainmenu = true; } } else if (strcasecmp(pSection, "Setting") == 0) { if (__isDefaultSetting == false) { __pAppData->__settingIcon = iconRelPath; } if (strcasecmp(pType, __pDefaultIconType) == 0) { __isDefaultSetting = true; } } else if (strcasecmp(pSection, "Notification") == 0) { if (__isDefaultQuickpanel == false) { __pAppData->__notificationIcon = iconRelPath; } if (strcasecmp(pType, __pDefaultIconType) == 0) { __isDefaultQuickpanel = true; } } } } return true; } bool ManifestHandler::OnNameValue(const char *pCharacters) { XmlAttribute* pAttr = 0; char* pAttrValue = 0; pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); pAttrValue = pAttr->Find("Locale"); TryReturn(pAttrValue, true, "pAttrValue is null"); if (FindElement("Content") == true) { TryReturn(__pContentData, false, "__pContentData is null"); String* pValue = new (std::nothrow) String; StringUtil::Utf8ToString(pCharacters, *pValue); __pContentData->AddName(*(new (std::nothrow) String(pAttrValue)), *pValue); } else { if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0) { if (__isDefaultName == true) { __pContext->__displayName = pCharacters; } } String* pValue = new (std::nothrow) String; StringUtil::Utf8ToString(pCharacters, *pValue); __pAppData->__pNameList->Add((new (std::nothrow) String(pAttrValue)), pValue); } AppLog("%s", pAttrValue, pCharacters); return true; } bool ManifestHandler::OnDescriptionValue(const char *pCharacters) { XmlAttribute *pAttr = 0; char *pAttrValue = 0; pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); pAttrValue = pAttr->Find("Locale"); TryReturn(pAttrValue, true, "pAttrValue is null"); if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0) { __pContext->__description = pCharacters; } AppLog("%s", pAttrValue, pCharacters); return true; } bool ManifestHandler::OnDataControlTypeValue(const char *pCharacters) { XmlAttribute* pAttr = null; char* pAccessValue = null; pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); pAccessValue = pAttr->Find("Access"); TryReturn(pAccessValue, true, "pAccessValue is null"); __pDataControlType = new (std::nothrow) DataControlType; TryReturn(__pDataControlType, false, "__pDataControlType is null"); __pDataControlType->__type = pCharacters; __pDataControlType->__access = pAccessValue; AppLog("", pAccessValue, pCharacters); return true; } bool ManifestHandler::OnConditionValue(const char *pCharacters) { XmlAttribute *pAttr = null; char *pName = null; pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null"); pName = pAttr->Find("Name"); TryReturn(pName, true, "pName is null"); String* pKey = new (std::nothrow) String(pName); TryReturn(pKey, false, "pKey is null"); String* pValue = new (std::nothrow) String(pCharacters); TryReturn(pValue, false, "pValue is null"); __pAppData->__pLaunchConditionList->Add(pKey, pValue); AppLog("", pName, pCharacters); return true; } bool ManifestHandler::OnNotificationValue(const char *pCharacters) { XmlAttribute *pAttr = null; const char *pName = null; pAttr = GetAttribute(); TryReturn(pAttr, true, "pAttr is null."); pName = pAttr->Find("Name"); TryReturn(pName, true, "pName is null."); if (strcasecmp(pName, "Ticker") == 0) { pName = "Notification"; } else if (strcasecmp(pName, "Notification") == 0 || strcasecmp(pName, "Sounds") == 0 || strcasecmp(pName, "Badge") == 0 || strcasecmp(pName, "Contents") == 0) { // known notification attributes } else { TryReturn(0, true, "Unknown notification attributes=%s", pCharacters); } String* pKey = new (std::nothrow) String(pName); TryReturn(pKey, false, "pKey is null."); String* pValue = new (std::nothrow) String(pCharacters); TryReturn(pValue, false, "pValue is null."); pKey->ToLowerCase(); pValue->ToLowerCase(); __pAppData->__pNotificationMap->Add(pKey, pValue); AppLog("", pName, pCharacters); return true; } bool ManifestHandler::OnInstallationLocationValue(const char *pCharacters) { AppLog("%s", pCharacters); if ((strcasecmp(pCharacters, "UserPreferred") == 0) && (File::IsFileExist(DIR_MEMORYCARD_INSTALLATION) == true)) { AppLog("INSTALLATION_STORAGE = [EXTERNAL]"); __pContext->__storage = INSTALLATION_STORAGE_EXTERNAL; } return true; } bool ManifestHandler::OnCategoryValue(const char *pCharacters) { TryReturn(__pAppData, false, "__pAppData is null"); __pAppData->__pCategoryList->Add(new (std::nothrow) String(pCharacters)); if (strcasecmp(pCharacters, TIZEN_CATEGORY_IME) == 0) { __pAppData->__feature = CATEGORY_TYPE_IME; } return true; } bool ManifestHandler::FindElement(const char *pName) { bool res = false; Tizen::Base::Collection::IEnumerator* pEnum = GetElementEnumeratorN(); if (pEnum) { while(pEnum->MoveNext() == E_SUCCESS) { String* pStr = static_cast(pEnum->GetCurrent()); if (pStr) { if (pStr->Equals(pName, false) == true) { AppLog("[%s] is matched.", pName); res = true; break; } } } delete pEnum; } return res; } bool ManifestHandler::AddAppFeature(const Tizen::Base::String& name, const Tizen::Base::String& value) { String* pKey = new (std::nothrow) String(name); TryReturn(pKey, false, "pKey is null"); String* pValue = new (std::nothrow) String(value); TryReturn(pValue, false, "pValue is null"); __pAppData->__pFeatureList->Add(pKey, pValue); return true; } bool ManifestHandler::ParseAppAttribute(XmlAttribute* pAttr, bool isUiApp) { char* pName = pAttr->Find("Name"); if (pName == null) { pName = pAttr->Find("ExecutableName"); } if (pName) { AppLog(" - Name=%s", pName); __pAppData->__name = pName; __pAppData->__appId = __pContext->__packageId + L"." + pName; } char* pMain = pAttr->Find("Main"); if (pMain == null) { pMain = pAttr->Find("Default"); } if (pMain) { AppLog(" - Main=%s", pMain); __pAppData->__main = pMain; if (strcasecmp(pMain, "True") == 0) { __isDefaultName = true; __isDefaultAppDetected = true; __pContext->__mainAppName = pName; } } else { __pAppData->__main = L"False"; } char* pRecent = pAttr->Find("LaunchingHistoryVisible"); if (pRecent) { AppLog(" - LaunchingHistoryVisible=%s", pRecent); __pAppData->__launchingHistoryVisible = pRecent; } char* pHwAcceleration = pAttr->Find("HwAcceleration"); if (pHwAcceleration) { AddAppFeature("HwAcceleration", pHwAcceleration); AppLog(" - HwAcceleration=%s", pHwAcceleration); } else { char* pGlFrame = pAttr->Find("GlFrame"); if (pGlFrame) { AddAppFeature("GlFrame", pGlFrame); AppLog(" - GlFrame=%s", pGlFrame); } } char* pCategory = pAttr->Find("Category"); if (pCategory) { AppLog(" - Category=%s", pCategory); if (strcasecmp(pCategory, "home-screen") == 0) { __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_HOMESCREEN)); } else if (strcasecmp(pCategory, "lock-screen") == 0) { __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_LOCKSCREEN)); } else if (strcasecmp(pCategory, "Ime") == 0) { __pAppData->__pCategoryList->Add(new (std::nothrow) String(TIZEN_CATEGORY_IME)); } int categoryType = InstallerUtil::GetCategoryType(pCategory); __pAppData->__feature = categoryType; } char* pSubMode = pAttr->Find("SubMode"); if (pSubMode) { if (strcasecmp(pSubMode, "True") == 0) { __pAppData->__isSubMode = true; AppLog(" - SubMode=%s", pSubMode); } } if (isUiApp == true) { __pAppData->__type = L"UiApp"; char* pMenuIconVisible = pAttr->Find("MenuIconVisible"); if (pMenuIconVisible == null) { pMenuIconVisible = pAttr->Find("MainmenuVisible"); } if (pMenuIconVisible) { if (strcasecmp(pMenuIconVisible, "True") == 0) { __pAppData->__mainmenuVisible = true; } else { __pAppData->__mainmenuVisible = false; } AddAppFeature("MenuIconVisible", pMenuIconVisible); AppLog(" - MenuIconVisible=%s", pMenuIconVisible); } } else { __pAppData->__type = L"ServiceApp"; __pAppData->__mainmenuVisible = false; char *pUseUi = pAttr->Find("UseUi"); if (pUseUi) { AddAppFeature("UseUi", pUseUi); AppLog(" - UseUi=%s", pUseUi); } char *pLifeDuration = pAttr->Find("LifeDuration"); if (pLifeDuration) { AddAppFeature("LifeDuration", pLifeDuration); AppLog(" - LifeDuration=%s", pLifeDuration); } char *pLaunchOnBoot = pAttr->Find("LaunchOnBoot"); if (pLaunchOnBoot) { AddAppFeature("LaunchOnBoot", pLaunchOnBoot); AppLog(" - LaunchOnBoot=%s", pLaunchOnBoot); } char *pAutoRestart = pAttr->Find("AutoRestart"); if (pAutoRestart) { AddAppFeature("AutoRestart", pAutoRestart); AppLog(" - AutoRestart=%s", pAutoRestart); } char *pSystemService = pAttr->Find("SystemService"); if (pSystemService) { if (strcasecmp(pSystemService, "True") == 0) { __pAppData->__isSystemService = true; AppLog(" - SystemService=%s", pSystemService); } } } AppLog(" - appId=%ls", __pAppData->__appId.GetPointer()); return true; } AppData* ManifestHandler::GetAppData(void) { return __pAppData; } char* ManifestHandler::GetDefaultIconType(void) { return __pDefaultIconType; }