update codes for notification icon and sound
authorkyeongwoo.lee <kyeongwoo.lee@samsung.com>
Fri, 29 Mar 2013 04:56:36 +0000 (13:56 +0900)
committerkyeongwoo.lee <kyeongwoo.lee@samsung.com>
Fri, 29 Mar 2013 04:56:36 +0000 (13:56 +0900)
Change-Id: I4d977cdec50e1feacf8233821be67eb6e140520d

src/core/FShell_NotificationManagerImpl.cpp

index 00b6d62..8534082 100644 (file)
@@ -72,9 +72,9 @@ ConvertNotificationResult(int error)
        case NOTIFICATION_ERROR_NO_MEMORY:
                return E_OUT_OF_MEMORY;
        case NOTIFICATION_ERROR_FROM_DB:
-               return E_DATABASE;
+               // fall through
        case NOTIFICATION_ERROR_ALREADY_EXIST_ID:
-               return E_OPERATION_FAILED;
+               // fall through
        case NOTIFICATION_ERROR_NOT_EXIST_ID:
                return E_OPERATION_FAILED;
        default:
@@ -82,6 +82,26 @@ ConvertNotificationResult(int error)
        }
 }
 
+result
+ConvertAppManagerResult(int error)
+{
+       switch (error)
+       {
+       case APP_MANAGER_ERROR_NONE:
+               return E_SUCCESS;
+       case APP_MANAGER_ERROR_INVALID_PARAMETER:
+               // fall through
+       case APP_MANAGER_ERROR_INVALID_PACKAGE:
+               return E_INVALID_ARG;
+       case NOTIFICATION_ERROR_NO_MEMORY:
+               return E_OUT_OF_MEMORY;
+       case APP_MANAGER_ERROR_DB_FAILED:
+               return E_OPERATION_FAILED;
+       default:
+               return E_OPERATION_FAILED;
+       }
+}
+
 bool
 IsPosted(ui_notification_h handle)
 {
@@ -198,7 +218,7 @@ _NotificationManagerImpl::_NotificationManagerImpl(void)
 _NotificationManagerImpl::~_NotificationManagerImpl(void)
 {
        bool isListeningBadgeEvent = (__badgeEventListenerList.GetCount() > 0)? true : false;
-       if( isListeningBadgeEvent == true )
+       if(isListeningBadgeEvent == true)
        {
                _BadgeManagerImpl::GetInstance()->RemovePrimaryBadgeEventListener(*this);
        }
@@ -556,7 +576,7 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
        else
        {
                char* pAppName = null;
-               app_manager_get_app_name(pAppIdChar.get(), &pAppName);
+               r = ConvertAppManagerResult(app_manager_get_app_name(pAppIdChar.get(), &pAppName));
                if (pAppName)
                {
                        String appName(pAppName);
@@ -565,10 +585,7 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                        free(pAppName);
                        //SysLog(NID_APP, "Application Id is %ls.", appName.GetPointer());
                }
-               else
-               {
-                       SysTryLog(NID_APP, pTitleText, "Failed to get title from app_manager_get_app_name for default setting.");
-               }
+               SysTryLog(NID_APP, !IsFailed(r), "[%s] Failed to get title from app_manager_get_app_name for default setting.", GetErrorMessage(r));
        }
        // Icon file path
        std::unique_ptr<char[]> pIconPath(null);
@@ -579,27 +596,16 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
        }
        else
        {
-               std::unique_ptr<PackageAppInfo> pPackageAppInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(pAppIdChar.get()));
-               const String& appIconPath(_PackageAppInfoImpl::GetInstance(pPackageAppInfo.get())->GetAppNotificationIconPath());
-
-               if (!appIconPath.IsEmpty() && File::IsFileExist(appIconPath))
+               char* pDefaultIconPath = null;
+               r = ConvertAppManagerResult(app_manager_get_app_icon_path(pAppIdChar.get(), &pDefaultIconPath));
+               if (pDefaultIconPath)
                {
-                       std::unique_ptr<char[]> pIconPathTemp(_StringConverter::CopyToCharArrayN(appIconPath));
+                       String iconPath(pDefaultIconPath);
+                       std::unique_ptr<char[]> pIconPathTemp(_StringConverter::CopyToCharArrayN(iconPath));
                        pIconPath = std::move(pIconPathTemp);
+                       free(pDefaultIconPath);
                }
-               else
-               {
-                       char* pDefaultIconPath = null;
-                       app_manager_get_app_icon_path(pAppIdChar.get(), &pDefaultIconPath);
-                       if (pDefaultIconPath)
-                       {
-                               String iconPath(pDefaultIconPath);
-                               std::unique_ptr<char[]> pIconPathTemp(_StringConverter::CopyToCharArrayN(iconPath));
-                               pIconPath = std::move(pIconPathTemp);
-                               free(pDefaultIconPath);
-                       }
-                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set icon path  failed.", GetErrorMessage(r));
-               }
+               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set icon path failed.", GetErrorMessage(r));
        }
        // Sound file path
        std::unique_ptr<char[]> pSoundPath(null);
@@ -628,10 +634,17 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
        }
        // Set - icon file path
        r = ConvertNotificationResult(notification_set_image(notiHandle, NOTIFICATION_IMAGE_TYPE_ICON, pIconPath.get()));
-       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set icon path  failed.", GetErrorMessage(r));
+       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set icon path failed.", GetErrorMessage(r));
        // Set - sound file path
-       r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_USER_DATA, pSoundPath.get()));
-       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set sound  failed.", GetErrorMessage(r));
+       if (pSoundPath.get())
+       {
+               r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_USER_DATA, pSoundPath.get()));
+       }
+       else
+       {
+               r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL));
+       }
+       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set sound failed.", GetErrorMessage(r));
 
        // Set extended - text, thumbnail and background image
        if (!isOngoing)