// // 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 #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::Package; using namespace Tizen::Io; using namespace Tizen::System; ManifestHandler::ManifestHandler(void) :__pContext(null) ,__pPrivilegeList(null) ,__pContentDataList(null) ,__pPackageInfoImpl(null) ,__pPackageAppInfoImpl(null) ,__pAppControlInfoImpl(null) ,__pAppControlCapabilityInfoImpl(null) ,__pAppControlResolutionInfoImpl(null) ,__pDataControlInfoImpl(null) ,__pDataControlTypeImpl(null) ,__pLaunchConditionImpl(null) ,__pNotificationImpl(null) ,__pContentData(null) ,__pDefaultIconType(null) ,__isDefaultMainmenu(false) ,__isDefaultSetting(false) ,__isDefaultTicker(false) ,__isDefaultQuickpanel(false) ,__isDefaultLaunchImage(false) ,__isDefaultName(false) ,__isDefaultAppDetected(false) ,__pAppData(null) ,__pSubModeAppControlDataList(null) ,__isParserMode(false) { } ManifestHandler::~ManifestHandler(void) { delete[] __pDefaultIconType; __pDefaultIconType = null; if (__pPackageAppInfoImpl) { delete __pPackageAppInfoImpl; __pPackageAppInfoImpl = null; } } bool ManifestHandler::Construct(InstallationContext* pContext) { __pContext = pContext; __pPackageInfoImpl = pContext->GetPackageInfoImpl(); 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, "[osp-installer] pName is null."); bool status = true; if (__isParserMode == true) { TryReturn(__pParser, false, "[osp-installer] __pParser is null"); return __pParser->OnStartElement(pName); } if (strcasecmp(pName, "Manifest") == 0) { AppLogTag(OSP_INSTALLER, "------------------------------------------"); AppLogTag(OSP_INSTALLER, "manifest.xml"); AppLogTag(OSP_INSTALLER, "------------------------------------------"); AppLogTag(OSP_INSTALLER, "<%s>", pName); } else if (strcasecmp(pName, "Apps") == 0) { AppLogTag(OSP_INSTALLER, "<%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) { status = OnLiveboxesStartElement(pName); } else if (strcasecmp(pName, "Accounts") == 0) { status = OnAccountsStartElement(pName); } else if (strcasecmp(pName, "AppControls") == 0) { status = OnAppControlsStartElement(pName); } if (!status) { __isParserMode = false; return false; } return true; } bool ManifestHandler::OnEndElement(const char *pName) { TryReturn(pName, true, "[osp-installer] pName is null."); bool status = true; if (__isParserMode == true) { TryReturn(__pParser, false, "[osp-installer] __pParser is null"); __pParser->OnEndElement(pName); if (strcasecmp(pName, "Liveboxes") == 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, "Condition") == 0) { status = OnConditionEndElement(); } else if (strcasecmp(pName, "Notification") == 0) { status = OnNotificationEndElement(); } else if (strcasecmp(pName, "Apps") == 0) { status = OnAppsEndElement(); } else if (strcasecmp(pName, "UiScalability") == 0) { AppLogTag(OSP_INSTALLER, "", 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, "[osp-installer] __pParser is null"); return __pParser->OnCharacters(pCharacters); } char *pName = GetElementName(); TryReturn(pName, false, "[osp-installer] 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, "[osp-installer] __pPrivilegeList is null"); AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnUiAppStartElement(void) { __pPackageAppInfoImpl = new (std::nothrow) _PackageAppInfoImpl; TryReturn(__pPackageAppInfoImpl, false, "[osp-installer] __pPackageAppInfoImpl is null"); __pAppData = new (std::nothrow) AppData; TryReturn(__pAppData, false, "[osp-installer] __pAppData is null"); AppLogTag(OSP_INSTALLER, ""); XmlAttribute *pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); ParseAppAttribute(pAttr, true); return true; } bool ManifestHandler::OnServiceAppStartElement(void) { __pPackageAppInfoImpl = new (std::nothrow) _PackageAppInfoImpl; TryReturn(__pPackageAppInfoImpl, false, "[osp-installer] __pPackageAppInfoImpl is null"); __pAppData = new (std::nothrow) AppData; TryReturn(__pAppData, false, "[osp-installer] __pAppData is null"); AppLogTag(OSP_INSTALLER, ""); 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; AppLogTag(OSP_INSTALLER, ""); r = _SystemInfoImpl::GetSysInfo(L"ScreenWidth", width); if (IsFailed(r)) { defaultIconType = L"Xhigh"; } else { if (width == 480) { defaultIconType = L"High"; } else { defaultIconType = L"Xhigh"; } } AppLogTag(OSP_INSTALLER, "ScreenWidth = [%d]", width); __pDefaultIconType = _StringConverter::CopyToCharArrayN(defaultIconType); TryReturn(__pDefaultIconType, false, "[osp-installer] __pDefaultIconType is null."); AppLogTag(OSP_INSTALLER, "DefaultIconType = [%s]", __pDefaultIconType); return true; } bool ManifestHandler::OnUiScalabilityStartElement(void) { XmlAttribute *pAttr = null; char *pCoordinateSystem = null; char *pBaseScreenSize = null; char *pLogicalCoordinate = null; AppLogTag(OSP_INSTALLER, ""); pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); pCoordinateSystem = pAttr->Find("CoordinateSystem"); if (pCoordinateSystem) { _AppFeatureInfoImpl* pAppFeatureInfo = new (std::nothrow) _AppFeatureInfoImpl; TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null"); pAppFeatureInfo->SetName("CoordinateSystem"); pAppFeatureInfo->SetValue(pCoordinateSystem); __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo); AppLogTag(OSP_INSTALLER, "", pCoordinateSystem); } pBaseScreenSize = pAttr->Find("BaseScreenSize"); if (pBaseScreenSize) { _AppFeatureInfoImpl* pAppFeatureInfo = new (std::nothrow) _AppFeatureInfoImpl; TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null"); pAppFeatureInfo->SetName("BaseScreenSize"); pAppFeatureInfo->SetValue(pBaseScreenSize); __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo); AppLogTag(OSP_INSTALLER, "", pBaseScreenSize); } pLogicalCoordinate = pAttr->Find("LogicalCoordinate"); if (pLogicalCoordinate) { _AppFeatureInfoImpl* pAppFeatureInfo = new (std::nothrow) _AppFeatureInfoImpl; TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null"); pAppFeatureInfo->SetName("LogicalCoordinate"); pAppFeatureInfo->SetValue(pLogicalCoordinate); __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo); AppLogTag(OSP_INSTALLER, "", pLogicalCoordinate); } return true; } bool ManifestHandler::OnUiThemeStartElement(void) { XmlAttribute *pAttr = null; char *pSystemTheme = null; char *pUserDefinedTheme = null; AppLogTag(OSP_INSTALLER, ""); pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); pSystemTheme = pAttr->Find("SystemTheme"); if (pSystemTheme) { _AppFeatureInfoImpl* pAppFeatureInfo = new (std::nothrow) _AppFeatureInfoImpl; TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null"); pAppFeatureInfo->SetName("SystemTheme"); pAppFeatureInfo->SetValue(pSystemTheme); __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo); AppLogTag(OSP_INSTALLER, "", pSystemTheme); } pUserDefinedTheme = pAttr->Find("UserDefinedTheme"); if (pUserDefinedTheme) { _AppFeatureInfoImpl* pAppFeatureInfo = new (std::nothrow) _AppFeatureInfoImpl; TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null"); pAppFeatureInfo->SetName("UserDefinedTheme"); pAppFeatureInfo->SetValue(pUserDefinedTheme); __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo); AppLogTag(OSP_INSTALLER, "", pUserDefinedTheme); } return true; } bool ManifestHandler::OnDataControlStartElement(void) { XmlAttribute *pAttr = null; char *pProviderId = null; pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); pProviderId = pAttr->Find("ProviderId"); TryReturn(pProviderId, true, "[osp-installer] pProviderId is null"); __pDataControlInfoImpl = new (std::nothrow) _DataControlInfoImpl; TryReturn(__pDataControlInfoImpl, false, "[osp-installer] __pDataControlInfoImpl is null"); __pDataControlInfoImpl->SetProviderId(pProviderId); AppLogTag(OSP_INSTALLER, "", pProviderId); return true; } bool ManifestHandler::OnContentsStartElement(void) { __pContentDataList = new (std::nothrow) ArrayList; TryReturn(__pContentDataList, false, "[osp-installer] __pContentDataList is null"); AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnContentStartElement(void) { TryReturn(__pContentData == null, false, "[osp-installer] __pContentData is not null"); XmlAttribute *pAttr = null; char *pDefault = null; __pContentData = new (std::nothrow) ContentData; TryReturn(__pContentData, false, "[osp-installer] __pContentData is null"); pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] 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; } } AppLogTag(OSP_INSTALLER, "", pId, pEntryName); return true; } bool ManifestHandler::OnLiveboxesStartElement(const char *pName) { __pParser = new (std::nothrow) ManifestLiveboxesParser; TryReturn(__pParser, false, "[osp-installer] __pParser is null"); __isParserMode = true; AppLogTag(OSP_INSTALLER, "------------------------------------------"); __pParser->Construct(this); return __pParser->OnStartElement(pName); } bool ManifestHandler::OnAccountsStartElement(const char *pName) { __pParser = new (std::nothrow) ManifestAccountsParser; TryReturn(__pParser, false, "[osp-installer] __pParser is null"); __isParserMode = true; AppLogTag(OSP_INSTALLER, "------------------------------------------"); __pParser->Construct(this); return __pParser->OnStartElement(pName); } bool ManifestHandler::OnAppControlsStartElement(const char *pName) { __pParser = new (std::nothrow) ManifestAppControlsParser; TryReturn(__pParser, false, "[osp-installer] __pParser is null"); __isParserMode = true; AppLogTag(OSP_INSTALLER, "------------------------------------------"); __pParser->Construct(this); return __pParser->OnStartElement(pName); } bool ManifestHandler::OnPrivilegesEndElement(void) { if (__pContext->IsVerificationMode() == false) { AppLogTag(OSP_INSTALLER, "no signature file[%ls]", __pContext->GetSignatureXmlPath().GetPointer()); result r = E_SUCCESS; String privileges; String hmacPrivileges; String appId = __pPackageInfoImpl->GetId(); r = PrivilegeHandler::GenerateCipherPrivilege(appId, *__pPrivilegeList, privileges, hmacPrivileges); if (IsFailed(r)) { fprintf(stderr, "PrivilegeHandler::GenerateCipherPrivilege is failded. [%ls][%ls][%ls]\n", appId.GetPointer(), privileges.GetPointer(), hmacPrivileges.GetPointer()); } TryReturn(!IsFailed(r), false, "[osp-installer] privMgr.GeneratePrivilegeString() failed"); __pPackageInfoImpl->SetPrivilegesValue(privileges, hmacPrivileges); } __pContext->SetPrivilegeList(__pPrivilegeList); AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnUiAppEndElement(void) { if (__pContext->__isSubMode == true) { __pSubModeAppControlDataList = __pAppData->__pAppControlDataList; __pAppData->__pAppControlDataList = null; __pContext->__subModeAppName = __pPackageAppInfoImpl->GetName(); } __pPackageInfoImpl->AddAppInfo(*__pPackageAppInfoImpl); __pPackageAppInfoImpl = null; __isDefaultName = false; __pContext->__pAppDataList->Add(__pAppData); __pAppData = null; AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnServiceAppEndElement(void) { if (__pContext->__isSubMode == true) { __pSubModeAppControlDataList = __pAppData->__pAppControlDataList; __pAppData->__pAppControlDataList = null; __pContext->__subModeAppName = __pPackageAppInfoImpl->GetName(); } __pPackageInfoImpl->AddAppInfo(*__pPackageAppInfoImpl); __pPackageAppInfoImpl = null; __isDefaultName = false; __pContext->__pAppDataList->Add(__pAppData); __pAppData = null; AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnAppsEndElement(void) { if (__pContext->__isSubMode == true) { __pAppData = new (std::nothrow) AppData; TryReturn(__pAppData, false, "[osp-installer] __pAppData is null"); __pAppData->__pAppControlDataList = __pSubModeAppControlDataList; __pSubModeAppControlDataList = null; __pContext->__pAppDataList->Add(__pAppData); } AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnIconsEndElement(void) { AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnDataControlEndElement(void) { __pPackageAppInfoImpl->AddDataControl(__pDataControlInfoImpl); __pDataControlInfoImpl = null; AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnDataControlTypeEndElement(void) { __pDataControlInfoImpl->AddControlType(__pDataControlTypeImpl); __pDataControlTypeImpl = null; AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnConditionEndElement(void) { __pPackageAppInfoImpl->AddLaunchCondition(*__pLaunchConditionImpl); __pLaunchConditionImpl = null; AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnNotificationEndElement(void) { __pPackageAppInfoImpl->AddNotification(*__pNotificationImpl); __pNotificationImpl = null; AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnContentsEndElement(void) { __pContext->SetContentDataList(__pContentDataList); __pContentDataList = null; AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnContentEndElement(void) { __pContentDataList->Add(*__pContentData); __pContentData = null; AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnLiveboxesEndElement(void) { delete __pParser; __isParserMode = false; AppLogTag(OSP_INSTALLER, "------------------------------------------"); return true; } bool ManifestHandler::OnAccountsEndElement(void) { delete __pParser; __isParserMode = false; AppLogTag(OSP_INSTALLER, "------------------------------------------"); return true; } bool ManifestHandler::OnAppControlsEndElement(void) { delete __pParser; __isParserMode = false; AppLogTag(OSP_INSTALLER, "------------------------------------------"); return true; } bool ManifestHandler::OnManifestEndElement(void) { if (__isDefaultAppDetected == false) { fprintf(stderr, "__isDefaultAppDetected is false.\n"); } TryReturn(__isDefaultAppDetected, false, "[osp-installer][Error] Default App is not detected..."); AppLogTag(OSP_INSTALLER, ""); return true; } bool ManifestHandler::OnIdValue(const char *pCharacters) { AppLogTag(OSP_INSTALLER, "%s", pCharacters); __pPackageInfoImpl->SetId(pCharacters); return true; } bool ManifestHandler::OnVersionValue(const char *pCharacters) { AppLogTag(OSP_INSTALLER, "%s", pCharacters); __pPackageInfoImpl->SetVersion(pCharacters); return true; } bool ManifestHandler::OnTypeValue(const char *pCharacters) { AppLogTag(OSP_INSTALLER, "%s", pCharacters); //__pPackageInfoImpl->SetAppType(pCharacters); if (strcasecmp(pCharacters, "Contents") == 0) { __pPackageInfoImpl->SetAppApiVersion("3.0"); } return true; } bool ManifestHandler::OnAuthorValue(const char *pCharacters) { // XmlAttribute *pAttr = 0; // char *pAttrValue = 0; // // pAttr = GetAttribute(); // TryReturn(pAttr, true, "[osp-installer] pAttr is null"); // // pAttrValue = pAttr->Find("Locale"); // TryReturn(pAttrValue, true, "[osp-installer] pAttrValue is null"); // // if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0) // { // // Set default name // __pPackageInfoImpl->SetAppVendor(pCharacters); // } AppLogTag(OSP_INSTALLER, "%s", pCharacters); __pPackageInfoImpl->SetAuthor(pCharacters); return true; } bool ManifestHandler::OnUrlValue(const char *pCharacters) { __pPackageInfoImpl->SetUrl(pCharacters); AppLogTag(OSP_INSTALLER, "%s", pCharacters); return true; } bool ManifestHandler::OnApiVersionValue(const char *pCharacters) { __pPackageInfoImpl->SetAppApiVersion(pCharacters); AppLogTag(OSP_INSTALLER, "%s", pCharacters); XmlAttribute *pAttr = GetAttribute(); if (pAttr) { char* pOspCompat = pAttr->Find("OspCompat"); if (pOspCompat) { AppLogTag(OSP_INSTALLER, " - OspCompat=%s", pOspCompat); __pContext->__isOspCompat = true; } } return true; } bool ManifestHandler::OnPrivilegeValue(const char *pCharacters) { __pPrivilegeList->Add(*new (std::nothrow) String(pCharacters)); AppLogTag(OSP_INSTALLER, "%s", pCharacters); return true; } bool ManifestHandler::OnIconValue(const char *pCharacters) { XmlAttribute *pAttr = 0; char *pAttrValue1 = 0; char *pTypeValue = 0; pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); pAttrValue1 = pAttr->Find("Section"); TryReturn(pAttrValue1, true, "[osp-installer] pAttrValue1 is null"); pTypeValue = pAttr->Find("Type"); TryReturn(pTypeValue, true, "[osp-installer] pTypeValue is null"); char icon[1024] = {0,}; if (strcasecmp(pTypeValue, "Xhigh") == 0) { snprintf(icon, sizeof(icon), "%s/%s", "screen-density-xhigh", pCharacters); } else if (strcasecmp(pTypeValue, "High") == 0) { snprintf(icon, sizeof(icon), "%s/%s", "screen-density-high", pCharacters); } else { AppLogTag(OSP_INSTALLER, "Invalid Type [%s]", __pDefaultIconType); return false; } if (FindElement("Content") == true) { TryReturn(__pContentData, false, "[osp-installer] __pContentData is null"); __pContentData->SetIcon(icon); } else { if (strcasecmp(pAttrValue1, "MainMenu") == 0) { if (__isDefaultMainmenu == false) { __pPackageAppInfoImpl->SetMainmenuIcon(icon); } if (strcasecmp(pTypeValue, __pDefaultIconType) == 0) { __isDefaultMainmenu = true; } } else if (strcasecmp(pAttrValue1, "Setting") == 0) { if (__isDefaultSetting == false) { __pPackageAppInfoImpl->SetSettingIcon(icon); } if (strcasecmp(pTypeValue, __pDefaultIconType) == 0) { __isDefaultSetting = true; } } else if (strcasecmp(pAttrValue1, "Notification") == 0) { if (__isDefaultQuickpanel == false) { __pPackageAppInfoImpl->SetQuickpanelIcon(icon); } if (strcasecmp(pTypeValue, __pDefaultIconType) == 0) { __isDefaultQuickpanel = true; } } } AppLogTag(OSP_INSTALLER, "%s", pAttrValue1, pTypeValue, pCharacters); return true; } bool ManifestHandler::OnNameValue(const char *pCharacters) { XmlAttribute* pAttr = 0; char* pAttrValue = 0; pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); pAttrValue = pAttr->Find("Locale"); TryReturn(pAttrValue, true, "[osp-installer] pAttrValue is null"); if (FindElement("Content") == true) { TryReturn(__pContentData, false, "[osp-installer] __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) { __pPackageInfoImpl->SetDisplayName(pCharacters); } } if (__pPackageAppInfoImpl) { String* pValue = new (std::nothrow) String; StringUtil::Utf8ToString(pCharacters, *pValue); __pPackageAppInfoImpl->AddName(*(new (std::nothrow) String(pAttrValue)), *pValue); } } AppLogTag(OSP_INSTALLER, "%s", pAttrValue, pCharacters); return true; } bool ManifestHandler::OnDescriptionValue(const char *pCharacters) { XmlAttribute *pAttr = 0; char *pAttrValue = 0; pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); pAttrValue = pAttr->Find("Locale"); TryReturn(pAttrValue, true, "[osp-installer] pAttrValue is null"); if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0) { // Set default name __pPackageInfoImpl->SetDescription(pCharacters); } AppLogTag(OSP_INSTALLER, "%s", pAttrValue, pCharacters); return true; } bool ManifestHandler::OnDataControlTypeValue(const char *pCharacters) { XmlAttribute *pAttr = null; char *pAccessValue = null; pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); pAccessValue = pAttr->Find("Access"); TryReturn(pAccessValue, true, "[osp-installer] pAccessValue is null"); __pDataControlTypeImpl = new (std::nothrow) _DataControlTypeImpl; TryReturn(__pDataControlTypeImpl, false, "[osp-installer] __pDataControlTypeImpl is null"); __pDataControlTypeImpl->SetType(pCharacters); __pDataControlTypeImpl->SetAccess(pAccessValue); AppLogTag(OSP_INSTALLER, "", pAccessValue, pCharacters); return true; } bool ManifestHandler::OnConditionValue(const char *pCharacters) { XmlAttribute *pAttr = null; char *pName = null; pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); pName = pAttr->Find("Name"); TryReturn(pName, true, "[osp-installer] pName is null"); __pLaunchConditionImpl = new (std::nothrow) _LaunchConditionInfoImpl; TryReturn(__pLaunchConditionImpl, false, "[osp-installer] __pLaunchConditionImpl is null"); __pLaunchConditionImpl->SetName(pName); __pLaunchConditionImpl->SetValue(pCharacters); AppLogTag(OSP_INSTALLER, "", pName, pCharacters); return true; } bool ManifestHandler::OnNotificationValue(const char *pCharacters) { XmlAttribute *pAttr = null; char *pName = null; pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); pName = pAttr->Find("Name"); TryReturn(pName, true, "[osp-installer] pName is null"); __pNotificationImpl = new (std::nothrow) _NotificationInfoImpl; TryReturn(__pNotificationImpl, false, "[osp-installer] __pNotificationImpl is null"); __pNotificationImpl->SetName(pName); __pNotificationImpl->SetValue(pCharacters); AppLogTag(OSP_INSTALLER, "", pName, pCharacters); return true; } bool ManifestHandler::OnInstallationLocationValue(const char *pCharacters) { AppLogTag(OSP_INSTALLER, "%s", pCharacters); if ((strcasecmp(pCharacters, "UserPreferred") == 0) && (File::IsFileExist(DIR_MEMORYCARD_INSTALLATION) == true)) { AppLogTag(OSP_INSTALLER, "INSTALLATION_STORAGE = [EXTERNAL]"); __pContext->SetInstallationStorage(InstallationContext::INSTALLATION_STORAGE_EXTERNAL); __pPackageInfoImpl->SetInstalledInExternalStorage(true); } return true; } bool ManifestHandler::OnCategoryValue(const char *pCharacters) { TryReturn(__pAppData, false, "[osp-installer] __pAppData is null"); __pAppData->__pCategoryList->Add(new (std::nothrow) String(pCharacters)); 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) { AppLogTag(OSP_INSTALLER, "[%s] is matched.", pName); res = true; break; } } } delete pEnum; } return res; } bool ManifestHandler::AddAppFeature(const Tizen::Base::String& name, const Tizen::Base::String& value) { _AppFeatureInfoImpl* pAppFeatureInfo = new (std::nothrow) _AppFeatureInfoImpl; TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null"); pAppFeatureInfo->SetName(name); pAppFeatureInfo->SetValue(value); __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo); return true; } bool ManifestHandler::ParseAppAttribute(XmlAttribute* pAttr, bool isUiApp) { char* pName = pAttr->Find("Name"); if (pName == null) { pName = pAttr->Find("ExecutableName"); } if (pName) { AppLogTag(OSP_INSTALLER, " - Name=%s", pName); __pPackageAppInfoImpl->SetName(pName); } char* pMain = pAttr->Find("Main"); if (pMain == null) { pMain = pAttr->Find("Default"); } if (pMain) { AppLogTag(OSP_INSTALLER, " - Main=%s", pMain); __pPackageAppInfoImpl->SetDefault(pMain); if (strcasecmp(pMain, "True") == 0) { __isDefaultName = true; __isDefaultAppDetected = true; } } else { __pPackageAppInfoImpl->SetDefault("False"); } char* pHwAcceleration = pAttr->Find("HwAcceleration"); if (pHwAcceleration) { AddAppFeature("HwAcceleration", pHwAcceleration); AppLogTag(OSP_INSTALLER, " - HwAcceleration=%s", pHwAcceleration); } else { char* pGlFrame = pAttr->Find("GlFrame"); if (pGlFrame) { AddAppFeature("GlFrame", pGlFrame); AppLogTag(OSP_INSTALLER, " - GlFrame=%s", pGlFrame); } } char* pCategory = pAttr->Find("Category"); if (pCategory) { AppLogTag(OSP_INSTALLER, " - 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)); } CategoryType categoryType = InstallerUtil::GetCategoryType(pCategory); __pPackageAppInfoImpl->SetAppFeature(categoryType); } char* pSubMode = pAttr->Find("SubMode"); if (pSubMode) { if (strcasecmp(pSubMode, "True") == 0) { __pContext->__isSubMode = true; AppLogTag(OSP_INSTALLER, " - SubMode=%s", pSubMode); } } if (isUiApp == true) { __pPackageAppInfoImpl->SetType("UiApp"); char* pMenuIconVisible = pAttr->Find("MenuIconVisible"); if (pMenuIconVisible == null) { pMenuIconVisible = pAttr->Find("MainmenuVisible"); } if (pMenuIconVisible) { if (strcasecmp(pMenuIconVisible, "True") == 0) { __pPackageAppInfoImpl->SetMainmenuVisible(true); } else { __pPackageAppInfoImpl->SetMainmenuVisible(false); } AddAppFeature("MenuIconVisible", pMenuIconVisible); AppLogTag(OSP_INSTALLER, " - MenuIconVisible=%s", pMenuIconVisible); } } else { __pPackageAppInfoImpl->SetType("ServiceApp"); __pPackageAppInfoImpl->SetMainmenuVisible(false); char *pUseUi = pAttr->Find("UseUi"); if (pUseUi) { AddAppFeature("UseUi", pUseUi); AppLogTag(OSP_INSTALLER, " - UseUi=%s", pUseUi); } char *pLifeDuration = pAttr->Find("LifeDuration"); if (pLifeDuration) { AddAppFeature("LifeDuration", pLifeDuration); AppLogTag(OSP_INSTALLER, " - LifeDuration=%s", pLifeDuration); } char *pLaunchOnBoot = pAttr->Find("LaunchOnBoot"); if (pLaunchOnBoot) { AddAppFeature("LaunchOnBoot", pLaunchOnBoot); AppLogTag(OSP_INSTALLER, " - LaunchOnBoot=%s", pLaunchOnBoot); } char *pAutoRestart = pAttr->Find("AutoRestart"); if (pAutoRestart) { AddAppFeature("AutoRestart", pAutoRestart); AppLogTag(OSP_INSTALLER, " - AutoRestart=%s", pAutoRestart); } } String appId; appId.Format(1024, PACKAGE_NAME_RULE, __pPackageInfoImpl->GetId().GetPointer(), pName); __pPackageAppInfoImpl->SetPackageName(appId); AppLogTag(OSP_INSTALLER, " - appId=%ls", appId.GetPointer()); return true; } AppData* ManifestHandler::GetAppData(void) { return __pAppData; } char* ManifestHandler::GetDefaultIconType(void) { return __pDefaultIconType; }