diff options
author | Dongeup Ham <dongeup.ham@samsung.com> | 2013-01-03 10:19:00 +0900 |
---|---|---|
committer | Dongeup Ham <dongeup.ham@samsung.com> | 2013-01-03 11:21:50 +0900 |
commit | d022ec4cda436708492eca82f2af43f290fe1f26 (patch) | |
tree | 51272c244c021d471aed0d57bad4128b1b126b2e /src/XmlHandler/ManifestHandler.cpp | |
parent | 89c8b72b28db94d693be40e2840810a4c9ef9a8f (diff) | |
download | installer-d022ec4cda436708492eca82f2af43f290fe1f26.tar.gz installer-d022ec4cda436708492eca82f2af43f290fe1f26.tar.bz2 installer-d022ec4cda436708492eca82f2af43f290fe1f26.zip |
Implementation Livebox, Accounts parsers.
Change-Id: Iee2b4bf218636a2ece19a7cd2378ec04d39b8a09
Signed-off-by: Dongeup Ham <dongeup.ham@samsung.com>
Diffstat (limited to 'src/XmlHandler/ManifestHandler.cpp')
-rwxr-xr-x | src/XmlHandler/ManifestHandler.cpp | 255 |
1 files changed, 110 insertions, 145 deletions
diff --git a/src/XmlHandler/ManifestHandler.cpp b/src/XmlHandler/ManifestHandler.cpp index d70f1bd..6e23824 100755 --- a/src/XmlHandler/ManifestHandler.cpp +++ b/src/XmlHandler/ManifestHandler.cpp @@ -27,7 +27,8 @@ #include "ManifestHandler.h" #include "PrivilegeHandler.h" #include "InstallerUtil.h" - +#include "ManifestAccountsParser.h" +#include "ManifestLiveboxesParser.h" using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -39,8 +40,7 @@ using namespace Tizen::System; ManifestHandler::ManifestHandler(void) :__pContext(null) ,__pPrivilegeList(null) -,__pLiveBoxList(null) -,__pContentInfoList(null) +,__pContentDataList(null) ,__pPackageInfoImpl(null) ,__pPackageAppInfoImpl(null) ,__pAppControlInfoImpl(null) @@ -50,8 +50,7 @@ ManifestHandler::ManifestHandler(void) ,__pDataControlTypeImpl(null) ,__pLaunchConditionImpl(null) ,__pNotificationImpl(null) -,__pLiveboxInfo(null) -,__pContentInfo(null) +,__pContentData(null) ,__pDefaultIconType(null) ,__isDefaultMainmenu(false) ,__isDefaultSetting(false) @@ -63,11 +62,15 @@ ManifestHandler::ManifestHandler(void) ,__pAppData(null) ,__pSubModeAppControlData(null) ,__pOperationData(null) +,__isParserMode(false) { } ManifestHandler::~ManifestHandler(void) { + delete[] __pDefaultIconType; + __pDefaultIconType = null; + if (__pPackageAppInfoImpl) { delete __pPackageAppInfoImpl; @@ -84,6 +87,12 @@ ManifestHandler::Construct(InstallationContext* pContext) return true; } +InstallationContext* +ManifestHandler::GetContext(void) +{ + return __pContext; +} + bool ManifestHandler::Parse(const char *pFilepath) { @@ -97,6 +106,12 @@ ManifestHandler::OnStartElement(const char *pName) 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, "------------------------------------------"); @@ -148,14 +163,6 @@ ManifestHandler::OnStartElement(const char *pName) { status = OnIconsStartElement(); } - else if (strcasecmp(pName, "LiveBoxes") == 0) - { - status = OnLiveBoxesStartElement(); - } - else if (strcasecmp(pName, "LiveBox") == 0) - { - status = OnLiveBoxStartElement(); - } else if (strcasecmp(pName, "Contents") == 0) { status = OnContentsStartElement(); @@ -168,9 +175,18 @@ ManifestHandler::OnStartElement(const char *pName) { status = OnOperationStartElement(); } + else if (strcasecmp(pName, "Liveboxes") == 0) + { + status = OnLiveboxesStartElement(pName); + } + else if (strcasecmp(pName, "Accounts") == 0) + { + status = OnAccountsStartElement(pName); + } if (!status) { + __isParserMode = false; return false; } @@ -184,6 +200,23 @@ ManifestHandler::OnEndElement(const char *pName) bool status = true; + if (__isParserMode == true) + { + TryReturn(__pParser, false, "[osp-installer] __pParser is null"); + __pParser->OnEndElement(pName); + + if (strcasecmp(pName, "Accounts") == 0) + { + status = OnAccountsEndElement(); + } + else if (strcasecmp(pName, "Liveboxes") == 0) + { + status = OnLiveboxesEndElement(); + } + + return status; + } + if (strcasecmp(pName, "Privileges") == 0) { status = OnPrivilegesEndElement(); @@ -236,18 +269,10 @@ ManifestHandler::OnEndElement(const char *pName) { status = OnIconsEndElement(); } - else if (strcasecmp(pName, "LiveBoxes") == 0) - { - status = OnLiveBoxesEndElement(); - } else if (strcasecmp(pName, "Contents") == 0) { status = OnContentsEndElement(); } - else if (strcasecmp(pName, "LiveBox") == 0) - { - status = OnLiveBoxEndElement(); - } else if (strcasecmp(pName, "Content") == 0) { status = OnContentEndElement(); @@ -273,9 +298,14 @@ bool ManifestHandler::OnCharacters(const char *pCharacters) { bool status = true; - char *pName = 0; - pName = GetElementName(); + 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) @@ -334,10 +364,6 @@ ManifestHandler::OnCharacters(const char *pCharacters) { status = OnNotificationValue(pCharacters); } - else if (strcasecmp(pName, "Size") == 0) - { - status = OnSizeValue(pCharacters); - } else if (strcasecmp(pName, "InstallationLocation") == 0) { status = OnInstallationLocationValue(pCharacters); @@ -354,10 +380,6 @@ ManifestHandler::OnCharacters(const char *pCharacters) { status = OnUriValue(pCharacters); } - else if (strcasecmp(pName, "ConfigurationAppControlAppId") == 0) - { - status = OnConfigurationAppControlAppIdValue(pCharacters); - } if (!status) { @@ -686,8 +708,8 @@ ManifestHandler::OnDataControlStartElement(void) bool ManifestHandler::OnContentsStartElement(void) { - __pContentInfoList = new (std::nothrow) ArrayList; - TryReturn(__pContentInfoList, false, "[osp-installer] __pContentInfoList is null"); + __pContentDataList = new (std::nothrow) ArrayList; + TryReturn(__pContentDataList, false, "[osp-installer] __pContentDataList is null"); AppLogTag(OSP_INSTALLER, "<Contents>"); @@ -697,13 +719,13 @@ ManifestHandler::OnContentsStartElement(void) bool ManifestHandler::OnContentStartElement(void) { - TryReturn(__pContentInfo == null, false, "[osp-installer] __pContentInfo is not null"); + TryReturn(__pContentData == null, false, "[osp-installer] __pContentData is not null"); XmlAttribute *pAttr = null; char *pDefault = null; - __pContentInfo = new (std::nothrow) ContentInfo; - TryReturn(__pContentInfo, false, "[osp-installer] __pLiveboxInfo is null"); + __pContentData = new (std::nothrow) ContentData; + TryReturn(__pContentData, false, "[osp-installer] __pContentData is null"); pAttr = GetAttribute(); TryReturn(pAttr, true, "[osp-installer] pAttr is null"); @@ -711,13 +733,13 @@ ManifestHandler::OnContentStartElement(void) char* pId = pAttr->Find("Id"); if (pId) { - __pContentInfo->SetContentId(pId); + __pContentData->SetContentId(pId); } char* pEntryName = pAttr->Find("EntryName"); if (pEntryName) { - __pContentInfo->SetContentId(pEntryName); + __pContentData->SetContentId(pEntryName); } pDefault = pAttr->Find("Default"); @@ -735,61 +757,29 @@ ManifestHandler::OnContentStartElement(void) } bool -ManifestHandler::OnLiveBoxesStartElement(void) +ManifestHandler::OnLiveboxesStartElement(const char *pName) { - __pLiveBoxList = new (std::nothrow) ArrayList; - TryReturn(__pLiveBoxList, false, "[osp-installer] __pLiveBoxList is null"); + __pParser = new (std::nothrow) ManifestLiveboxesParser; + TryReturn(__pParser, false, "[osp-installer] __pParser is null"); - AppLogTag(OSP_INSTALLER, "<LiveBoxes>"); + __isParserMode = true; + AppLogTag(OSP_INSTALLER, "------------------------------------------"); + __pParser->Construct(this); - return true; + return __pParser->OnStartElement(pName); } bool -ManifestHandler::OnLiveBoxStartElement(void) +ManifestHandler::OnAccountsStartElement(const char *pName) { - TryReturn(__pLiveboxInfo == null, false, "[osp-installer] __pLiveboxInfo is not null"); - - XmlAttribute *pAttr = null; - - __pLiveboxInfo = new (std::nothrow) LiveboxInfo; - TryReturn(__pLiveboxInfo, false, "[osp-installer] __pLiveboxInfo is null"); - - pAttr = GetAttribute(); - TryReturn(pAttr, true, "[osp-installer] pAttr is null"); - - AppLogTag(OSP_INSTALLER, "<Livebox>"); + __pParser = new (std::nothrow) ManifestAccountsParser; + TryReturn(__pParser, false, "[osp-installer] __pParser is null"); - char *pProviderName = pAttr->Find("ProviderName"); - if (pProviderName) - { - __pLiveboxInfo->SetName(pProviderName); - AppLogTag(OSP_INSTALLER, " - ProviderName=%s", pProviderName); - } + __isParserMode = true; + AppLogTag(OSP_INSTALLER, "------------------------------------------"); + __pParser->Construct(this); - char *pUpdatePeriod = pAttr->Find("UpdatePeriod"); - if (pUpdatePeriod) - { - long long updatePeriod = atoll(pUpdatePeriod); - __pLiveboxInfo->SetUpdatePeriod(updatePeriod); - AppLogTag(OSP_INSTALLER, " - UpdatePeriod=%lld", updatePeriod); - } - - char *pLiveboxPopupEnabled = pAttr->Find("LiveBoxPopupEnabled"); - if (pLiveboxPopupEnabled) - { - __pLiveboxInfo->SetPopupEnabled(pLiveboxPopupEnabled); - AppLogTag(OSP_INSTALLER, " - LiveBoxPopupEnabled=%s", pLiveboxPopupEnabled); - } - - char *pMain = pAttr->Find("Main"); - if (pMain) - { - __pLiveboxInfo->__main = pMain; - AppLogTag(OSP_INSTALLER, " - Main=%s", pMain); - } - - return true; + return __pParser->OnStartElement(pName); } bool @@ -797,7 +787,7 @@ ManifestHandler::OnPrivilegesEndElement(void) { if (__pContext->IsVerificationMode() == false) { - AppLogTag(OSP_INSTALLER, "Signature file not found. [%ls]\n", __pContext->GetSignatureXmlPath().GetPointer()); + AppLogTag(OSP_INSTALLER, "no signature file[%ls]\n", __pContext->GetSignatureXmlPath().GetPointer()); result r = E_SUCCESS; String privileges; @@ -874,8 +864,6 @@ ManifestHandler::OnAppsEndElement(void) bool ManifestHandler::OnIconsEndElement(void) { - delete[] __pDefaultIconType; - __pDefaultIconType = null; AppLogTag(OSP_INSTALLER, "</Icons>"); return true; @@ -971,8 +959,8 @@ ManifestHandler::OnNotificationEndElement(void) bool ManifestHandler::OnContentsEndElement(void) { - __pContext->SetContentInfoList(__pContentInfoList); - __pContentInfoList = null; + __pContext->SetContentDataList(__pContentDataList); + __pContentDataList = null; AppLogTag(OSP_INSTALLER, "</Contents>"); return true; @@ -981,29 +969,29 @@ ManifestHandler::OnContentsEndElement(void) bool ManifestHandler::OnContentEndElement(void) { - __pContentInfoList->Add(*__pContentInfo); - __pContentInfo = null; + __pContentDataList->Add(*__pContentData); + __pContentData = null; AppLogTag(OSP_INSTALLER, "</Content>"); return true; } bool -ManifestHandler::OnLiveBoxesEndElement(void) +ManifestHandler::OnAccountsEndElement(void) { - __pContext->SetLiveBoxList(__pLiveBoxList); - __pLiveBoxList = null; - AppLogTag(OSP_INSTALLER, "</LiveBoxes>"); + delete __pParser; + __isParserMode = false; + AppLogTag(OSP_INSTALLER, "------------------------------------------"); return true; } bool -ManifestHandler::OnLiveBoxEndElement(void) +ManifestHandler::OnLiveboxesEndElement(void) { - __pLiveBoxList->Add(*__pLiveboxInfo); - __pLiveboxInfo = null; - AppLogTag(OSP_INSTALLER, "</LiveBox>"); + delete __pParser; + __isParserMode = false; + AppLogTag(OSP_INSTALLER, "------------------------------------------"); return true; } @@ -1024,8 +1012,8 @@ ManifestHandler::OnManifestEndElement(void) bool ManifestHandler::OnIdValue(const char *pCharacters) { - __pPackageInfoImpl->SetAppId(pCharacters); AppLogTag(OSP_INSTALLER, "<Id>%s</Id>", pCharacters); + __pPackageInfoImpl->SetAppId(pCharacters); return true; } @@ -1033,8 +1021,8 @@ ManifestHandler::OnIdValue(const char *pCharacters) bool ManifestHandler::OnVersionValue(const char *pCharacters) { - __pPackageInfoImpl->SetAppVersion(pCharacters); AppLogTag(OSP_INSTALLER, "<Version>%s</Version>", pCharacters); + __pPackageInfoImpl->SetAppVersion(pCharacters); return true; } @@ -1042,6 +1030,7 @@ ManifestHandler::OnVersionValue(const char *pCharacters) bool ManifestHandler::OnTypeValue(const char *pCharacters) { + AppLogTag(OSP_INSTALLER, "<Type>%s</Type>", pCharacters); __pPackageInfoImpl->SetAppType(pCharacters); if (strcasecmp(pCharacters, "Contents") == 0) @@ -1049,8 +1038,6 @@ ManifestHandler::OnTypeValue(const char *pCharacters) __pPackageInfoImpl->SetAppApiVersion("3.0"); } - AppLogTag(OSP_INSTALLER, "<Type>%s</Type>", pCharacters); - return true; } @@ -1072,8 +1059,8 @@ ManifestHandler::OnAuthorValue(const char *pCharacters) // __pPackageInfoImpl->SetAppVendor(pCharacters); // } - __pPackageInfoImpl->SetAppVendor(pCharacters); AppLogTag(OSP_INSTALLER, "<Author>%s</Author>", pCharacters); + __pPackageInfoImpl->SetAppVendor(pCharacters); return true; } @@ -1137,15 +1124,10 @@ ManifestHandler::OnIconValue(const char *pCharacters) return false; } - if (FindElement("Livebox") == true) - { - TryReturn(__pLiveboxInfo, false, "[osp-installer] __pLiveboxInfo is null"); - __pLiveboxInfo->SetIcon(icon); - } - else if (FindElement("Content") == true) + if (FindElement("Content") == true) { - TryReturn(__pContentInfo, false, "[osp-installer] __pContentInfo is null"); - __pContentInfo->SetIcon(icon); + TryReturn(__pContentData, false, "[osp-installer] __pContentData is null"); + __pContentData->SetIcon(icon); } else { @@ -1204,21 +1186,13 @@ ManifestHandler::OnNameValue(const char *pCharacters) pAttrValue = pAttr->Find("Locale"); TryReturn(pAttrValue, true, "[osp-installer] pAttrValue is null"); - if (FindElement("Livebox") == true) + if (FindElement("Content") == true) { - TryReturn(__pLiveboxInfo, false, "[osp-installer] __pLiveboxInfo is null"); + TryReturn(__pContentData, false, "[osp-installer] __pContentData is null"); String* pValue = new (std::nothrow) String; StringUtil::Utf8ToString(pCharacters, *pValue); - __pLiveboxInfo->AddName(*(new (std::nothrow) String(pAttrValue)), *pValue); - } - else if (FindElement("Content") == true) - { - TryReturn(__pContentInfo, false, "[osp-installer] __pContentInfo is null"); - - String* pValue = new (std::nothrow) String; - StringUtil::Utf8ToString(pCharacters, *pValue); - __pContentInfo->AddName(*(new (std::nothrow) String(pAttrValue)), *pValue); + __pContentData->AddName(*(new (std::nothrow) String(pAttrValue)), *pValue); } else { @@ -1336,17 +1310,6 @@ ManifestHandler::OnNotificationValue(const char *pCharacters) } bool -ManifestHandler::OnSizeValue(const char *pCharacters) -{ - TryReturn(__pLiveboxInfo, false, "[osp-installer] __pLiveboxInfo is null"); - - __pLiveboxInfo->AddSize(*(new (std::nothrow) String(pCharacters))); - AppLogTag(OSP_INSTALLER, "<Size>%s</Size>", pCharacters); - - return true; -} - -bool ManifestHandler::OnInstallationLocationValue(const char *pCharacters) { AppLogTag(OSP_INSTALLER, "<InstallationLocation>%s</InstallationLocation>", pCharacters); @@ -1391,17 +1354,6 @@ ManifestHandler::OnUriValue(const char* pCharacters) } bool -ManifestHandler::OnConfigurationAppControlAppIdValue(const char* pCharacters) -{ - TryReturn(__pLiveboxInfo, true, "[osp-installer] __pLiveboxInfo is null"); - - __pLiveboxInfo->__configurationAppControlAppId = pCharacters; - AppLogTag(OSP_INSTALLER, "<ConfigurationAppControlAppId>%s</ConfigurationAppControlAppId>", pCharacters); - - return true; -} - -bool ManifestHandler::FindElement(const char *pName) { bool res = false; @@ -1595,3 +1547,16 @@ ManifestHandler::ParseAppAttribute(XmlAttribute* pAttr, bool isUiApp) return true; } + +AppData* +ManifestHandler::GetAppData(void) +{ + return __pAppData; +} + +char* +ManifestHandler::GetDefaultIconType(void) +{ + return __pDefaultIconType; +} + |