// // 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 ManifestLiveboxesParser.cpp * @brief This is the implementation file for %ManifestLiveboxesParser class. */ #include #include #include #include #include "ManifestLiveboxesParser.h" #include "InstallerUtil.h" #include "XmlAttribute.h" #include "ManifestHandler.h" #include "InstallationContextData.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; ManifestLiveboxesParser::ManifestLiveboxesParser(void) :__pContext(null) ,__pLiveboxDataList(null) ,__pLiveboxData(null) { } ManifestLiveboxesParser::~ManifestLiveboxesParser(void) { } bool ManifestLiveboxesParser::OnStartElement(const char *pName) { TryReturn(pName, true, "[osp-installer] pName is null"); bool status = true; if (strcasecmp(pName, "Liveboxes") == 0) { status = OnLiveboxesStartElement(); } else if (strcasecmp(pName, "Livebox") == 0) { status = OnLiveboxStartElement(); } return status; } bool ManifestLiveboxesParser::OnEndElement(const char *pName) { TryReturn(pName, true, "[osp-installer] pName is null"); bool status = true; if (strcasecmp(pName, "Liveboxes") == 0) { status = OnLiveboxesEndElement(); } else if (strcasecmp(pName, "Livebox") == 0) { status = OnLiveboxEndElement(); } return status; } bool ManifestLiveboxesParser::OnCharacters(const char *pCharacters) { TryReturn(pCharacters, true, "[osp-installer] pCharacters is null"); bool status = true; ManifestHandler* pHandler = GetHandler(); TryReturn(pHandler, false, "[osp-installer] pHandler is null"); char *pName = pHandler->GetElementName(); TryReturn(pName, false, "[osp-installer] pName is null"); if (strcasecmp(pName, "DisplayName") == 0) { status = OnDisplayNameValue(pCharacters); } else if (strcasecmp(pName, "Size") == 0) { status = OnSizeValue(pCharacters); } else if (strcasecmp(pName, "ConfigurationAppControlAppId") == 0) { status = OnConfigurationAppControlAppIdValue(pCharacters); } return status; } bool ManifestLiveboxesParser::OnLiveboxesStartElement() { ManifestHandler* __pHandler = GetHandler(); TryReturn(__pHandler, false, "[osp-installer] __pHandler is null"); __pContext = __pHandler->GetContext(); TryReturn(__pContext, false, "[osp-installer] __pContext is null"); __pLiveboxDataList = new (std::nothrow) ArrayList; TryReturn(__pLiveboxDataList, false, "[osp-installer] __pLiveboxDataList is null"); AppLogTag(OSP_INSTALLER, " "); return true; } bool ManifestLiveboxesParser::OnLiveboxStartElement(void) { XmlAttribute *pAttr = null; __pLiveboxData = new (std::nothrow) LiveboxData; TryReturn(__pLiveboxData, false, "[osp-installer] __pLiveboxData is null"); ManifestHandler* pHandler = GetHandler(); TryReturn(pHandler, false, "[osp-installer] pHandler is null"); pAttr = pHandler->GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); AppLogTag(OSP_INSTALLER, " "); char *pProviderName = pAttr->Find("ProviderName"); if (pProviderName) { __pLiveboxData->SetProviderName(pProviderName); AppLogTag(OSP_INSTALLER, " - ProviderName=%s", pProviderName); } char *pUpdatePeriod = pAttr->Find("UpdatePeriod"); if (pUpdatePeriod) { long long updatePeriod = atoll(pUpdatePeriod); __pLiveboxData->SetUpdatePeriod(updatePeriod); AppLogTag(OSP_INSTALLER, " - UpdatePeriod=%lld", updatePeriod); } char *pLiveboxPopupEnabled = pAttr->Find("LiveboxPopupEnabled"); if (pLiveboxPopupEnabled) { __pLiveboxData->SetPopupEnabled(pLiveboxPopupEnabled); AppLogTag(OSP_INSTALLER, " - LiveboxPopupEnabled=%s", pLiveboxPopupEnabled); } char *pMain = pAttr->Find("Main"); if (pMain) { __pLiveboxData->__main = pMain; AppLogTag(OSP_INSTALLER, " - Main=%s", pMain); } return true; } bool ManifestLiveboxesParser::OnLiveboxesEndElement(void) { __pContext->SetLiveboxDataList(__pLiveboxDataList); __pLiveboxDataList = null; AppLogTag(OSP_INSTALLER, " "); return true; } bool ManifestLiveboxesParser::OnLiveboxEndElement(void) { __pLiveboxDataList->Add(*__pLiveboxData); __pLiveboxData = null; AppLogTag(OSP_INSTALLER, " "); return true; } bool ManifestLiveboxesParser::OnSizeValue(const char *pCharacters) { __pLiveboxData->AddSize(*(new (std::nothrow) String(pCharacters))); AppLogTag(OSP_INSTALLER, " %s", pCharacters); return true; } bool ManifestLiveboxesParser::OnDisplayNameValue(const char *pCharacters) { XmlAttribute* pAttr = 0; char* pAttrValue = 0; ManifestHandler* pHandler = GetHandler(); TryReturn(pHandler, false, "[osp-installer] pHandler is null"); pAttr = pHandler->GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); pAttrValue = pAttr->Find("Locale"); TryReturn(pAttrValue, true, "[osp-installer] pAttrValue is null"); String* pValue = new (std::nothrow) String; StringUtil::Utf8ToString(pCharacters, *pValue); __pLiveboxData->AddName(*(new (std::nothrow) String(pAttrValue)), *pValue); AppLogTag(OSP_INSTALLER, " %s", pCharacters); return true; } bool ManifestLiveboxesParser::OnConfigurationAppControlAppIdValue(const char* pCharacters) { __pLiveboxData->__configurationAppControlAppId = pCharacters; AppLogTag(OSP_INSTALLER, " %s", pCharacters); return true; }