updated code for Notification Icon from IDE
authorJiban Prakash <p.jiban@samsung.com>
Tue, 5 Feb 2013 18:34:35 +0000 (00:04 +0530)
committerJiban Prakash <p.jiban@samsung.com>
Wed, 6 Feb 2013 04:50:21 +0000 (10:20 +0530)
Change-Id: If465f1e4204af7645ef2b12cd78c87f636163b12
Signed-off-by: Jiban Prakash <p.jiban@samsung.com>
src/core/FShell_NotificationManagerImpl.cpp

index bd718c5..0bd4792 100644 (file)
@@ -41,6 +41,8 @@
 #include "FApp_AppArg.h"
 #include "FShell_NotificationManagerImpl.h"
 #include "FShell_NotificationManagerProxy.h"
+#include "FAppPkgPackageAppInfo.h"
+#include "FAppPkg_PackageAppInfoImpl.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::App;
@@ -179,10 +181,13 @@ _NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber,
        char* pMsg = null;
        notification_h core = NULL;
        char* pkgname = NULL;
+       char* pIcon = null;
        bundle* pKb = NULL;
        bundle* service_data = NULL;
        service_h svc = NULL;
        _AppArg arg;
+       String iconPath;
+       PackageAppInfo* pPackageAppInfo = null;
 
        if (!messageText.IsEmpty())
        {
@@ -204,6 +209,18 @@ _NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber,
                pMsg = _StringConverter::CopyToCharArrayN(messageText);
                notification_set_text(core, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
 
+               const String& currappId = _AppInfo::GetApplicationId();
+
+               pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(currappId);
+               iconPath = _PackageAppInfoImpl::GetInstance(pPackageAppInfo)->GetAppNotificationIconPath();
+
+               if (!iconPath.IsEmpty())
+               {
+                       pIcon = _StringConverter::CopyToCharArrayN(iconPath);
+                       r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIcon));
+                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
+               }
+
                app_get_package(&pkgname);
                SysTryCatch(NID_APP, pkgname != NULL, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Cannot acquire package name for current application.");
 
@@ -232,12 +249,13 @@ _NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber,
        }
 
 CATCH:
+       delete pPackageAppInfo;
        delete[] pMsg;
+       delete[] pIcon;
        if (pkgname)
        {
                free(pkgname);
        }
-
        if (core)
        {
                notification_free(core);
@@ -253,7 +271,8 @@ _NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageTe
 {
        result r = E_SUCCESS;
        char* pMsg = null;
-       char* pIcon = NULL;
+       char* pIcon = null;
+       char* pDefaultIconPath = NULL;
        char* pName = NULL;
        notification_h core = NULL;
        char buffer[256];
@@ -261,11 +280,13 @@ _NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageTe
        bundle* service_data = NULL;
        service_h svc = NULL;
        _AppArg arg;
+       String iconPath;
+       PackageAppInfo* pPackageAppInfo = null;
 
        memset(buffer, 0, 256);
 
-       bool b = _Aul::IsInstalled(appId);
-       SysTryReturnResult(NID_APP, b == true, E_APP_NOT_INSTALLED, "The application %ls is not installed", appId.GetPointer());
+       bool isInstalled = _Aul::IsInstalled(appId);
+       SysTryReturnResult(NID_APP, isInstalled == true, E_APP_NOT_INSTALLED, "The application %ls is not installed", appId.GetPointer());
 
        if (isOngoing || !messageText.IsEmpty())
        {
@@ -289,9 +310,21 @@ _NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageTe
 
                snprintf(buffer, 256, "%ls", appId.GetPointer());
 
-               app_manager_get_app_icon_path(buffer, &pIcon);
-               r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIcon));
-               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
+               pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId);
+               iconPath = _PackageAppInfoImpl::GetInstance(pPackageAppInfo)->GetAppNotificationIconPath();
+
+               if (!iconPath.IsEmpty())
+               {
+                       pIcon = _StringConverter::CopyToCharArrayN(iconPath);
+                       r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIcon));
+                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
+               }
+               else
+               {
+                       app_manager_get_app_icon_path(buffer, &pDefaultIconPath);
+                       r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pDefaultIconPath));
+                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set icon path  failed.", GetErrorMessage(r));
+               }
 
                app_manager_get_app_name(buffer, &pName);
                r = ConvertNotificationResult(notification_set_text(core, NOTIFICATION_TEXT_TYPE_TITLE, pName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
@@ -323,15 +356,15 @@ _NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageTe
 
 CATCH:
        delete[] pMsg;
-
-       if (core)
+       delete[] pIcon;
+       delete pPackageAppInfo;
+       if (pDefaultIconPath)
        {
-               notification_free(core);
+               free(pDefaultIconPath);
        }
-
-       if (pIcon)
+       if (core)
        {
-               free(pIcon);
+               notification_free(core);
        }
 
        if (pName)
@@ -351,12 +384,14 @@ _NotificationManagerImpl::NotifyMessageImpl(const NotificationRequest& notiMessa
        notification_h core = NULL;
        char* pkgname = NULL;
        char* pTitleText = NULL;
-       char* pIconPath = NULL;
+       char* pIconPath = null;
        char* pSoundPath = NULL;
        bundle* pKb = NULL;
        bundle* service_data = NULL;
        service_h svc = NULL;
        _AppArg arg;
+       String appiconPath;
+       PackageAppInfo* pPackageAppInfo = null;
 
        const String& messageText = notiMessage.GetAlertText();
        const String& launchArguments = notiMessage.GetAppMessage();
@@ -404,6 +439,20 @@ _NotificationManagerImpl::NotifyMessageImpl(const NotificationRequest& notiMessa
                        r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIconPath));
                        SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
                }
+               else
+               {
+                       const String& currappId = _AppInfo::GetApplicationId();
+                       pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(currappId);
+
+                       appiconPath = _PackageAppInfoImpl::GetInstance(pPackageAppInfo)->GetAppNotificationIconPath();
+
+                       if (!iconPath.IsEmpty())
+                       {
+                               pIconPath = _StringConverter::CopyToCharArrayN(appiconPath);
+                               r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIconPath));
+                               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
+                       }
+               }
 
                if (!soundPath.IsEmpty())
                {
@@ -495,6 +544,8 @@ CATCH:
        delete[] pIconPath;
        delete[] pTitleText;
        delete[] pSoundPath;
+       delete pPackageAppInfo;
+
        if (pkgname)
        {
                free(pkgname);