Implementation for notification
authorDongeup Ham <dongeup.ham@samsung.com>
Tue, 26 Feb 2013 09:32:28 +0000 (18:32 +0900)
committerDongeup Ham <dongeup.ham@samsung.com>
Tue, 26 Feb 2013 09:32:28 +0000 (18:32 +0900)
Change-Id: Ic18ca93b7789a737cd7f97eabd2ff1ceba1afb24
Signed-off-by: Dongeup Ham <dongeup.ham@samsung.com>
inc/InstallerDefs.h
src/Context/InstallationContextData.cpp
src/Context/InstallationContextData.h
src/XmlHandler/ManifestGenerator.cpp
src/XmlHandler/ManifestGenerator.h
src/XmlHandler/ManifestHandler.cpp

index 81f03b1..c54e6ce 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130226.2]"
+#define OSP_INSTALLER_VERSION "version=[20130226.3]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
index 668ac96..06a8004 100755 (executable)
@@ -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;
 }
index 869dd82..0ed5287 100755 (executable)
@@ -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;
 
index 506e959..150e3d6 100755 (executable)
@@ -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;
+}
index c3cda00..0cb3878 100755 (executable)
@@ -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;
index b26d7f7..baa1771 100755 (executable)
@@ -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;