diff options
author | Dongeup Ham <dongeup.ham@samsung.com> | 2013-02-26 18:32:28 +0900 |
---|---|---|
committer | Dongeup Ham <dongeup.ham@samsung.com> | 2013-02-26 18:32:28 +0900 |
commit | be4f370b5c15078a39e7ad0babdb416df65a9d90 (patch) | |
tree | db94d9d8adee857cbe578dab5e2c86ee665c08de /src | |
parent | 59d64a305d07a8344809bd9fc7fe92e77cc206c3 (diff) | |
download | installer-be4f370b5c15078a39e7ad0babdb416df65a9d90.tar.gz installer-be4f370b5c15078a39e7ad0babdb416df65a9d90.tar.bz2 installer-be4f370b5c15078a39e7ad0babdb416df65a9d90.zip |
Implementation for notification
Change-Id: Ic18ca93b7789a737cd7f97eabd2ff1ceba1afb24
Signed-off-by: Dongeup Ham <dongeup.ham@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/Context/InstallationContextData.cpp | 19 | ||||
-rwxr-xr-x | src/Context/InstallationContextData.h | 1 | ||||
-rwxr-xr-x | src/XmlHandler/ManifestGenerator.cpp | 50 | ||||
-rwxr-xr-x | src/XmlHandler/ManifestGenerator.h | 1 | ||||
-rwxr-xr-x | src/XmlHandler/ManifestHandler.cpp | 30 |
5 files changed, 96 insertions, 5 deletions
diff --git a/src/Context/InstallationContextData.cpp b/src/Context/InstallationContextData.cpp index 668ac96..06a8004 100755 --- a/src/Context/InstallationContextData.cpp +++ b/src/Context/InstallationContextData.cpp @@ -412,10 +412,18 @@ AppData::AppData() :__pCategoryList(null) ,__pAccountDataList(null) ,__pAppControlDataList(null) +,__pAppControlImplList(null) +,__pDataControlList(null) +,__pSubModeAppControlDataList(null) +,__pNameList(null) +,__pFeatureList(null) +,__pLaunchConditionList(null) +,__pNotificationMap(null) ,__feature(0) ,__isSubMode(false) ,__legacyAppControls(false) ,__isSystemService(false) +,__mainmenuVisible(false) { } @@ -474,6 +482,12 @@ AppData::~AppData() __pLaunchConditionList->RemoveAll(); delete __pLaunchConditionList; } + + if (__pNotificationMap) + { + __pNotificationMap->RemoveAll(); + delete __pNotificationMap; + } } InstallerError @@ -514,5 +528,10 @@ AppData::Construct(void) r = __pLaunchConditionList->Construct(); TryReturn(!IsFailed(r), INSTALLER_ERROR_OUT_OF_MEMORY, "__pLaunchConditionList->Construct() failed."); + __pNotificationMap = new (std::nothrow) HashMap(SingleObjectDeleter); + TryReturn(__pNotificationMap, INSTALLER_ERROR_OUT_OF_MEMORY, "__pNotificationMap is null."); + r = __pNotificationMap->Construct(); + TryReturn(!IsFailed(r), INSTALLER_ERROR_OUT_OF_MEMORY, "__pNotificationMap->Construct() failed."); + return INSTALLER_ERROR_NONE; } diff --git a/src/Context/InstallationContextData.h b/src/Context/InstallationContextData.h index 869dd82..0ed5287 100755 --- a/src/Context/InstallationContextData.h +++ b/src/Context/InstallationContextData.h @@ -265,6 +265,7 @@ public: Tizen::Base::Collection::HashMap* __pNameList; Tizen::Base::Collection::HashMap* __pFeatureList; Tizen::Base::Collection::HashMap* __pLaunchConditionList; + Tizen::Base::Collection::HashMap* __pNotificationMap; int __feature; diff --git a/src/XmlHandler/ManifestGenerator.cpp b/src/XmlHandler/ManifestGenerator.cpp index 506e959..150e3d6 100755 --- a/src/XmlHandler/ManifestGenerator.cpp +++ b/src/XmlHandler/ManifestGenerator.cpp @@ -641,7 +641,7 @@ ManifestGenerator::WriteApp(int index, AppData* pAppData) WriteAppControl(index); } - __pWriter->EndElement(); + __pWriter->EndElement(); // end of "ui-application" if (pAppData->__type == L"ServiceApp") { @@ -649,6 +649,7 @@ ManifestGenerator::WriteApp(int index, AppData* pAppData) } WriteAccounts(index); + WriteNotifications(index); return true; } @@ -805,7 +806,7 @@ ManifestGenerator::WriteAccounts(int index) TryReturn(pAccountDataList, false, "pAccountDataList is null"); int accountCount = pAccountDataList->GetCount(); - if (accountCount == 0) + if (accountCount <= 0) { return true; } @@ -860,3 +861,48 @@ ManifestGenerator::WriteAccounts(int index) return true; } + +bool +ManifestGenerator::WriteNotifications(int index) +{ + IListT<AppData*>* pAppDataList = __pContext->__pAppDataList; + TryReturn(pAppDataList, false, "pAppDataList is null"); + + AppData* pAppData = null; + pAppDataList->GetAt(index, pAppData); + TryReturn(pAppData, false, "pAppData is null"); + + HashMap* pNotificationMap = pAppData->__pNotificationMap; + TryReturn(pNotificationMap, false, "pNotificationMap is null"); + + int count = pNotificationMap->GetCount(); + if (count <= 0) + { + return true; + } + + IMapEnumerator* pMapEnum = pNotificationMap->GetMapEnumeratorN(); + TryReturn(pMapEnum, false, "pMapEnum is null"); + + __pWriter->StartElement("notifications"); + __pWriter->WriteAttribute("appid", pAppData->__appId); + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + String* pKey = null; + String* pValue = null; + + pKey = static_cast<String*> (pMapEnum->GetKey()); + pValue = static_cast<String*> (pMapEnum->GetValue()); + + __pWriter->StartElement("notification"); + __pWriter->WriteAttribute("section", *pKey); + __pWriter->WriteString(*pValue); + __pWriter->EndElement(); // end of "notification" + } + + __pWriter->EndElement(); // end of "notifications" + + delete pMapEnum; + return true; +} diff --git a/src/XmlHandler/ManifestGenerator.h b/src/XmlHandler/ManifestGenerator.h index c3cda00..0cb3878 100755 --- a/src/XmlHandler/ManifestGenerator.h +++ b/src/XmlHandler/ManifestGenerator.h @@ -60,6 +60,7 @@ private: bool WriteSubModeApp(int index, AppData* pAppData); bool WriteAppControl(int index, bool subMode = false); bool WriteAccounts(int index); + bool WriteNotifications(int index); private: InstallationContext* __pContext; diff --git a/src/XmlHandler/ManifestHandler.cpp b/src/XmlHandler/ManifestHandler.cpp index b26d7f7..baa1771 100755 --- a/src/XmlHandler/ManifestHandler.cpp +++ b/src/XmlHandler/ManifestHandler.cpp @@ -1091,14 +1091,38 @@ bool ManifestHandler::OnNotificationValue(const char *pCharacters) { XmlAttribute *pAttr = null; - char *pName = null; + const char *pName = null; pAttr = GetAttribute(); - TryReturn(pAttr, true, "pAttr is null"); + TryReturn(pAttr, true, "pAttr is null."); pName = pAttr->Find("Name"); - TryReturn(pName, true, "pName is null"); + 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("<Notification Name=\"%s\", Value=\"%s\">", pName, pCharacters); return true; |