Modify the argument of notification_load for core-notification module requests. ...
[platform/framework/native/shell.git] / src / core / FShell_NotificationManagerImpl.cpp
index 1f0166a..a84a6f4 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
 //
 
 /**
- * @file               FShell_NotificationManagerImpl.cpp
- * @brief              This is the placeholder for _NotificationManagerImpl class.
+ * @file       FShell_NotificationManagerImpl.cpp
+ * @brief      This is the implementation for _NotificationManagerImpl class.
  */
 
 #include <unique_ptr.h>
-#include <appsvc/appsvc.h>
-#include <bundle.h>
 #include <notification/notification.h>
 #include <appfw/app.h>
 #include <appfw/app_manager.h>
-#include <appfw/app_ui_notification.h>
 #include <badge.h>
-
 #include <FBaseSysLog.h>
-#include <FApp.h>
+#include <FIoFile.h>
+#include <FAppApp.h>
+#include <FGrpColor.h>
 #include <FShellNotificationManager.h>
 #include <FShellNotificationRequest.h>
 #include <FShellIBadgeEventListener.h>
-
-//#include <FBaseInternalTypes.h>
 #include <FBase_StringConverter.h>
-#include "FApp_AppInfo.h"
-#include "FApp_Aul.h"
-#include "FIoFile.h"
-#include "FAppPkg_PackageManagerImpl.h"
-#include "FApp_AppArg.h"
-#include "FAppPkgPackageAppInfo.h"
-#include "FAppPkg_PackageAppInfoImpl.h"
+#include <FApp_Aul.h>
+#include <FApp_AppArg.h>
 #include "FShell_NotificationManagerImpl.h"
 #include "FShell_NotificationRequestImpl.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::App;
-using namespace Tizen::App::Package;
 using namespace Tizen::Io;
-using namespace Tizen::Shell;
+using namespace Tizen::Graphics;
 
 extern "C" int service_create_request(bundle *data, service_h *service);
 extern "C" int service_to_bundle(service_h service, bundle** data);
@@ -102,34 +91,6 @@ ConvertAppManagerResult(int error)
        }
 }
 
-bool
-IsPosted(ui_notification_h handle)
-{
-       struct ui_notification_s
-       {
-               void* raw_handle;
-               bool ongoing;
-               bool posted;
-               bool removed;
-               char *icon;
-               struct tm *time;
-               char *title;
-               char *content;
-               service_h service;
-               char *sound;
-               bool vibration;
-       };
-
-       if (handle == NULL)
-       {
-               return false;
-       }
-
-       ui_notification_s* pStruct = reinterpret_cast<ui_notification_s*>(handle);
-
-       return pStruct->posted;
-}
-
 } // namespace
 
 
@@ -153,7 +114,7 @@ BadgeChangedCallback(unsigned int action, const char *pkgname, unsigned int coun
        {
                pListener = null;
                pEnum->GetCurrent(pListener);
-               if!pListener)
+               if (!pListener)
                {
                        SysLog(NID_SHELL, "pListener is null!");
                        continue;
@@ -167,9 +128,11 @@ _BadgeManagerImpl*
 _BadgeManagerImpl::GetInstance(void)
 {
        static _BadgeManagerImpl* pTheInstance = null;
-       ifpTheInstance == null)
+       if (pTheInstance == null)
        {
                pTheInstance = new (std::nothrow) _BadgeManagerImpl;
+               SysTryReturn(NID_SHELL, pTheInstance != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
                pTheInstance->Construct();
        }
        return pTheInstance;
@@ -187,7 +150,7 @@ _BadgeManagerImpl::AddPrimaryBadgeEventListener(IBadgeEventListener& primaryList
        if( __primaryBadgeEventListenerList.GetCount() == 0)
        {
                int ret = badge_register_changed_cb(BadgeChangedCallback, &__primaryBadgeEventListenerList);
-               SysTryReturnResult(NID_SHELL, ret == BADGE_ERROR_NONE, E_SYSTEM, "Failed to badge_unregister_changed_cb, (%d)", ret);
+               SysTryReturnResult(NID_SHELL, ret == BADGE_ERROR_NONE, E_SYSTEM, "Failed to badge_register_changed_cb, (%d)", ret);
        }
 
        return __primaryBadgeEventListenerList.Add(&primaryListener);
@@ -212,6 +175,8 @@ _BadgeManagerImpl::RemovePrimaryBadgeEventListener(IBadgeEventListener& primaryL
 _NotificationManagerImpl::_NotificationManagerImpl(void)
        : __notifyPrivateId(-1)
        , __notifyPrivateIdForOngoing(-1)
+       , __lastNotifyPrivateId(-1)
+       , __lightActivated(false)
 {
 }
 
@@ -245,14 +210,14 @@ _NotificationManagerImpl::GetInstance(NotificationManager& notiMgr)
 int
 _NotificationManagerImpl::GetBadgeNumber(void) const
 {
+       ClearLastResult();
+
        Tizen::App::App* pApp = Tizen::App::App::GetInstance();
        std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(pApp->GetAppId()));
 
        int count = GetBadgeCount(pAppId.get());
-       SysTryReturn(NID_SHELL, count != -1, count, E_OPERATION_FAILED, "[%s] The operation has failed. Badge may not exist.",
-                                GetErrorMessage(E_OPERATION_FAILED));
+       SysTryReturn(NID_SHELL, count != -1, count, E_OPERATION_FAILED, "[E_OPERATION_FAILED] The operation has failed. Badge may not exist.");
 
-       ClearLastResult();
        return count;
 }
 
@@ -272,33 +237,34 @@ _NotificationManagerImpl::NotifyMessageImpl(const AppId& appId, const Notificati
 result
 _NotificationManagerImpl::Notify(int badgeNumber)
 {
-       SysTryReturnResult(NID_SHELL, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
-
-       if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
-       {
-               badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
-       }
+       SysTryReturnResult(NID_SHELL, badgeNumber >= 0 && badgeNumber <= MAX_NOTIFICATION_BADGE_NUMBER, E_INVALID_ARG,
+                                               "badgeNumber is less than 0 or greater than MAX_NOTIFICATION_BADGE_NUMBER.");
 
        Tizen::App::App* pApp = Tizen::App::App::GetInstance();
        std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(pApp->GetAppId()));
 
+       result r = E_SUCCESS;
+
        if (badgeNumber == 0)
        {
-               RemoveBadge(pAppId.get());
+               r = RemoveBadge(pAppId.get());
+               SysTryReturnResult(NID_SHELL, !IsFailed(r), r, "Failed to remove the badge.");
        }
        else
        if (badgeNumber > 0)
        {
-               SetBadgeCount(pAppId.get(), badgeNumber);
+               r = SetBadgeCount(pAppId.get(), badgeNumber);
+               SysTryReturnResult(NID_SHELL, !IsFailed(r), r, "Failed to set the badge.");
        }
 
-       return E_SUCCESS;
+       return r;
 }
 
 result
 _NotificationManagerImpl::Notify(const String& messageText)
 {
-       SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
+       SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
+                                               "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
 
        NotificationRequest request;
        request.SetAlertText(messageText);
@@ -310,13 +276,10 @@ _NotificationManagerImpl::Notify(const String& messageText)
 result
 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber)
 {
-       SysTryReturnResult(NID_SHELL, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
-       SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
-
-       if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
-       {
-               badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
-       }
+       SysTryReturnResult(NID_SHELL, badgeNumber >= 0 && badgeNumber <= MAX_NOTIFICATION_BADGE_NUMBER, E_INVALID_ARG,
+                                               "badgeNumber is less than 0 or greater than MAX_NOTIFICATION_BADGE_NUMBER.");
+       SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
+                                               "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
 
        NotificationRequest request;
        request.SetAlertText(messageText);
@@ -329,18 +292,12 @@ _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber)
 result
 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments)
 {
-       SysTryReturnResult(NID_SHELL, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
-       SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
-       SysTryReturnResult(NID_SHELL, launchArguments != null && launchArguments.GetLength() > 0, E_INVALID_ARG,
-                                          "launchArguments is less than 0.");
-
-       SysTryReturnResult(NID_SHELL, launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
-                                          "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
-
-       if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
-       {
-               badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
-       }
+       SysTryReturnResult(NID_SHELL, badgeNumber >= 0 && badgeNumber <= MAX_NOTIFICATION_BADGE_NUMBER, E_INVALID_ARG,
+                                               "badgeNumber is less than 0 or greater than MAX_NOTIFICATION_BADGE_NUMBER.");
+       SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
+                                               "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
+       SysTryReturnResult(NID_SHELL, launchArguments.GetLength() > 0 && launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
+                                          "launchArguments is less than 1 or greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
 
        NotificationRequest request;
        request.SetAlertText(messageText);
@@ -353,15 +310,15 @@ _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, con
 int
 _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
 {
+       ClearLastResult();
+
        bool b = _Aul::IsInstalled(appId);
-       SysTryReturn(NID_SHELL, b == true, -1, E_APP_NOT_INSTALLED, "[E_OBJ_NOT_FOUND] The application %ls is not installed",
+       SysTryReturn(NID_SHELL, b == true, -1, E_APP_NOT_INSTALLED, "[E_APP_NOT_INSTALLED] The application %ls is not installed",
                                 appId.GetPointer());
        std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
        int count = GetBadgeCount(pAppId.get());
 
-       SysTryReturn(NID_SHELL, count != -1, count, E_OPERATION_FAILED, "[%s] The operation has failed. Badge may not exist.",
-                                GetErrorMessage(E_OPERATION_FAILED));
-       ClearLastResult();
+       SysTryReturn(NID_SHELL, count != -1, count, E_OPERATION_FAILED, "[E_OPERATION_FAILED] The operation has failed. Badge may not exist.");
 
        return count;
 }
@@ -369,7 +326,8 @@ _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
 result
 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText)
 {
-       SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
+       SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
+                                               "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
 
        NotificationRequest request;
        request.SetAlertText(messageText);
@@ -380,7 +338,8 @@ _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText)
 result
 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments)
 {
-       SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
+       SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
+                                               "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
        SysTryReturnResult(NID_SHELL, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
        SysTryReturnResult(NID_SHELL, launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
                                           "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
@@ -408,7 +367,8 @@ _NotificationManagerImpl::RemoveNotificationByAppId(const AppId& appId)
 result
 _NotificationManagerImpl::NotifyTextMessage(const String& messageText) const
 {
-       SysTryReturnResult(NID_SHELL, !messageText.IsEmpty(), E_INVALID_ARG, "MessageText is less than 0.");
+       SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
+                                               "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
 
        std::unique_ptr<char[]> pMsg(_StringConverter::CopyToCharArrayN(messageText));
        int res = notification_status_message_post(pMsg.get());
@@ -423,10 +383,10 @@ _NotificationManagerImpl::NotifyTextMessage(const String& messageText) const
                r = E_INVALID_ARG;
                break;
        case NOTIFICATION_ERROR_IO:
-               r = E_SYSTEM;
+               r = E_OPERATION_FAILED;
                break;
        default:
-               r = E_SYSTEM;
+               r = E_OPERATION_FAILED;
                break;
        }
 
@@ -454,7 +414,13 @@ _NotificationManagerImpl::NotifyOngoingActivityByAppControl(const Tizen::Base::S
        return r;
 }
 
-
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_APP_NOT_INSTALLED - If AppId is invalid, it can occur.
+// E_OPERATION_FAILED
+// E_OUT_OF_MEMORY
+//
 result
 _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing, const NotificationRequest& notifyRequest, const AppId* pAppId,
                                                                                const Tizen::Base::String* pOperationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pDataType, const Tizen::Base::Collection::IMap* pExtraData)
@@ -467,22 +433,17 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
        // Set pAppIdChar
        if ((notifyType == NOTIFY_TYPE_SIMPLE) || (notifyType == NOTIFY_TYPE_APP_CONTROL))
        {
-//             char* pkgname = null;
-//             app_get_id(&pkgname);   // AppId. (Not package Id)
-//             SysTryReturnResult(NID_SHELL, pkgname != NULL, E_OBJ_NOT_FOUND,"Cannot acquire package name for current application.");
-//             const String currentAppId(pkgname);
-//             free(pkgname);
                Tizen::App::App* pApp = Tizen::App::App::GetInstance();
                const String currentAppId = pApp->GetAppId();
                std::unique_ptr<char[]> pAppIdTemp(_StringConverter::CopyToCharArrayN(currentAppId));
                pAppIdChar = std::move(pAppIdTemp);
-               SysLog(NID_SHELL, "app_get_id: %ls", currentAppId.GetPointer());
+               SysLog(NID_SHELL, "App ID is %ls.", currentAppId.GetPointer());
        }
        else
        if (notifyType == NOTIFY_TYPE_APP_ID)
        {
                bool isAppInstalled = _Aul::IsInstalled(*pAppId);
-               SysTryReturnResult(NID_SHELL, isAppInstalled == true, E_APP_NOT_INSTALLED, "The application %ls is not installed", pAppId->GetPointer());
+               SysTryReturnResult(NID_SHELL, isAppInstalled == true, E_APP_NOT_INSTALLED, "The application %ls is not installed.", pAppId->GetPointer());
                std::unique_ptr<char[]> pAppIdTemp(_StringConverter::CopyToCharArrayN(*pAppId));
                pAppIdChar = std::move(pAppIdTemp);
        }
@@ -490,12 +451,13 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
        {
                SysTryReturnResult(NID_SHELL, false, E_INVALID_ARG, "Invalid argument is used.");
        }
+       __lastAppId = pAppIdChar.get();
 
        const int badgeNumber = notifyRequest.GetBadgeNumber();
        const int badgeOffset = notifyRequest.GetBadgeOffset();
        const String& contentText = notifyRequest.GetAlertText();
        // Allow change the badge without other properties.
-       if (badgeNumber != -1 || badgeOffset != -1)
+       if (badgeNumber != -1 || badgeOffset != 0)
        {
                // Set - Badge
                if (badgeOffset != 0)
@@ -514,12 +476,14 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                {
                        if (badgeNumber == 0)
                        {
-                               RemoveBadge(pAppIdChar.get());
+                               r = RemoveBadge(pAppIdChar.get());
+                               SysTryReturnResult(NID_SHELL, !IsFailed(r), r, "Failed to remove the badge.");
                        }
                        else
                        if (badgeNumber > 0)
                        {
-                               SetBadgeCount(pAppIdChar.get(), badgeNumber);
+                               r = SetBadgeCount(pAppIdChar.get(), badgeNumber);
+                               SysTryReturnResult(NID_SHELL, !IsFailed(r), r, "Failed to set the badge.");
                        }
                }
                if (!(isOngoing || !contentText.IsEmpty()))
@@ -536,6 +500,7 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
        const String& soundPath = notifyRequest.GetSoundFilePath();
        const notification_type_e notiType = isOngoing ? NOTIFICATION_TYPE_ONGOING : NOTIFICATION_TYPE_NOTI;
        int notiPrivateId = isOngoing ? __notifyPrivateIdForOngoing : __notifyPrivateId;
+       __lastNotifyPrivateId = notiPrivateId;
        notification_h notiHandle = null;
        bundle* pBundle = null;
        bool needUpdate = false;
@@ -561,7 +526,7 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
        {
                needUpdate = true;              // No need to notification_insert.
        }
-       SysTryReturnResult(NID_SHELL, notiHandle != null , E_SYSTEM, "A system error has been occurred. Notification creation/load failed ");
+       SysTryReturnResult(NID_SHELL, notiHandle != null, E_OPERATION_FAILED, "Notification creation or loading failed.");
 
        // Content text(Alert text)
        std::unique_ptr<char[]> pMsg(_StringConverter::CopyToCharArrayN(contentText));
@@ -583,7 +548,7 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                        std::unique_ptr<char[]> pTitleTextTemp(_StringConverter::CopyToCharArrayN(appName));
                        pTitleText = std::move(pTitleTextTemp);
                        free(pAppName);
-                       //SysLog(NID_SHELL, "Application Id is %ls.", appName.GetPointer());
+                       SysSecureLog(NID_SHELL, "App name is %ls.", appName.GetPointer());
                }
                SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Failed to get title from app_manager_get_app_name for default setting.", GetErrorMessage(r));
        }
@@ -605,7 +570,7 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                        pIconPath = std::move(pIconPathTemp);
                        free(pDefaultIconPath);
                }
-               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set icon path failed.", GetErrorMessage(r));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the icon path failed.", GetErrorMessage(r));
        }
        // Sound file path
        std::unique_ptr<char[]> pSoundPath(null);
@@ -618,33 +583,47 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
        if (notifyType == NOTIFY_TYPE_APP_ID)
        {
                r = ConvertNotificationResult(notification_set_pkgname(notiHandle, pAppIdChar.get()));
-               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set Package name failed.", GetErrorMessage(r));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the package name failed.", GetErrorMessage(r));
        }
        // Set - title text
        if (pTitleText.get())
        {
                r = ConvertNotificationResult(notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_TITLE, pTitleText.get(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
-               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set Title Text failed.", GetErrorMessage(r));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the title text failed.", GetErrorMessage(r));
        }
        // Set - content text
        if (pMsg.get())
        {
-               r = notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg.get(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set Title Text failed.", GetErrorMessage(r));
+               r = ConvertNotificationResult(notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg.get(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting content text failed.", GetErrorMessage(r));
        }
        // Set - icon file path
        r = ConvertNotificationResult(notification_set_image(notiHandle, NOTIFICATION_IMAGE_TYPE_ICON, pIconPath.get()));
-       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set icon path failed.", GetErrorMessage(r));
+       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the icon path failed.", GetErrorMessage(r));
        // Set - sound file path
        if (pSoundPath.get())
        {
-               r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_USER_DATA, pSoundPath.get()));
+               if (isOngoing && needUpdate)
+               {
+                       r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_NONE, NULL));
+               }
+               else
+               {
+                       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));
+               if (isOngoing)
+               {
+                       r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_NONE, NULL));
+               }
+               else
+               {
+                       r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL));
+               }
        }
-       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set sound failed.", GetErrorMessage(r));
+       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the sound failed.", GetErrorMessage(r));
 
        // Set extended - text, thumbnail and background image
        if (!isOngoing)
@@ -674,7 +653,7 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                {
                        std::unique_ptr<char[]> pBgImageFilePath(_StringConverter::CopyToCharArrayN(bgImageFilePath));
                        r = ConvertNotificationResult(notification_set_image(notiHandle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, pBgImageFilePath.get()));
-                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set Background image path failed.", GetErrorMessage(r));
+                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the background image path failed.", GetErrorMessage(r));
                }
 
 
@@ -694,16 +673,14 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                                for (int i = 0; i < itemCount; i++)
                                {
                                        const String* pThumbnailPath = static_cast<const String*>(pThumbnailList->GetAt(i));
-                                       // TODO: check pThumbnailPath
                                        std::unique_ptr<char[]> filePath(_StringConverter::CopyToCharArrayN(*pThumbnailPath));
                                        r = ConvertNotificationResult(notification_set_image(notiHandle, thumbnailListEnum[i], filePath.get()));
-                                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set thumnail path  failed.", GetErrorMessage(r));
+                                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the thumbnail path failed.", GetErrorMessage(r));
                                }
                        }
                }
                else
                {
-                       // TODO: Check the valid
                        const IList* pMessageTextList = pRequestImpl->GetMessageTextList();
                        if (pMessageTextList && pMessageTextList->GetCount())
                        {
@@ -719,14 +696,14 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                                                std::unique_ptr<char[]> leftText(_StringConverter::CopyToCharArrayN(subText));
                                                r = ConvertNotificationResult(notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_INFO_1, leftText.get(),
                                                                                                                                                        NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
-                                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set Info1 Text failed.", GetErrorMessage(r));
+                                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the Info1 text failed.", GetErrorMessage(r));
                                                subText.Clear();
                                                if (E_SUCCESS == pText1->SubString(matchIndex+1, subText))
                                                {
                                                        std::unique_ptr<char[]> rightText(_StringConverter::CopyToCharArrayN(subText));
                                                        r = ConvertNotificationResult(notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, rightText.get(),
                                                                                                                                                                NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
-                                                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set Info1 Sub Text failed.", GetErrorMessage(r));
+                                                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the Info1 sub text failed.", GetErrorMessage(r));
                                                }
                                        }
                                        else
@@ -734,7 +711,7 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                                                std::unique_ptr<char[]> leftText(_StringConverter::CopyToCharArrayN(*pText1));
                                                r = ConvertNotificationResult(notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_INFO_1, leftText.get(),
                                                                                                                                                        NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
-                                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set Info1 Text failed.", GetErrorMessage(r));
+                                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the Info1 text failed.", GetErrorMessage(r));
                                        }
                                }
                                const String* pText2 = static_cast<const String*>(pMessageTextList->GetAt(1));
@@ -742,7 +719,7 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                                {
                                        int matchIndex;
                                        // 2.1: Multiple layout has single line text for 2nd information text.
-                                       if ((layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE && E_SUCCESS) == (pText2->IndexOf(L'\t', 0, matchIndex)))
+                                       if ((layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE) && (E_SUCCESS == (pText2->IndexOf(L'\t', 0, matchIndex))))
                                        {
                                                // Make two token
                                                String subText;
@@ -750,14 +727,14 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                                                std::unique_ptr<char[]> leftText(_StringConverter::CopyToCharArrayN(subText));
                                                r = ConvertNotificationResult(notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_INFO_2, leftText.get(),
                                                                                                                                                        NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
-                                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set Info1 Text failed.", GetErrorMessage(r));
+                                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the Info2 text failed.", GetErrorMessage(r));
                                                subText.Clear();
                                                if (E_SUCCESS == pText2->SubString(matchIndex+1, subText))
                                                {
                                                        std::unique_ptr<char[]> rightText(_StringConverter::CopyToCharArrayN(subText));
                                                        r = ConvertNotificationResult(notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_2, rightText.get(),
                                                                                                                                                                NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
-                                                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set Info1 Sub Text failed.", GetErrorMessage(r));
+                                                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the Info2 sub text failed.", GetErrorMessage(r));
                                                }
                                        }
                                        else
@@ -765,13 +742,13 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                                                std::unique_ptr<char[]> leftText(_StringConverter::CopyToCharArrayN(*pText2));
                                                r = ConvertNotificationResult(notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_INFO_2, leftText.get(),
                                                                                                                                                        NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
-                                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set Info1 Text failed.", GetErrorMessage(r));
+                                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the Info2 text failed.", GetErrorMessage(r));
                                        }
                                }
                        }
                        else
                        if (needUpdate)
-                       {       // Reset text for update case. also must be check the previous text with get_text
+                       {       // Reset text for update case. also must be checked the previous text with get_text
                                char* pRetStr = null;
                                notification_get_text(notiHandle, NOTIFICATION_TEXT_TYPE_INFO_1, &pRetStr);
                                if (pRetStr)
@@ -780,41 +757,54 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                                                                                                                                                         NOTIFICATION_TEXT_TYPE_INFO_2, NOTIFICATION_TEXT_TYPE_INFO_SUB_2 };
                                        for (unsigned int i = 0; i < sizeof(infoTextEnums)/sizeof(infoTextEnums[0]); i++)
                                        {
-                                               notification_set_text(notiHandle, infoTextEnums[i], null, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+                                               r = ConvertNotificationResult(notification_set_text(notiHandle, infoTextEnums[i], null, NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
+                                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the initial text failed.", GetErrorMessage(r));
                                        }
                                }
                        }
                }
        }
 
+       // light
+       Color lightColor;
+       int lightColor32 = 0;
+
        // Set - service
+       int retVal = SERVICE_ERROR_NONE;
+       int previousDisplaySet = NOTIFICATION_DISPLAY_APP_ALL;
+       int newDisplaySet = 0;
+
        r = arg.Construct(launchArguments);
-       SysTryCatch(NID_SHELL, !IsFailed(r), , r, "[%s] Propagated.", GetErrorMessage(r));
+       SysTryCatch(NID_SHELL, !IsFailed(r), r = E_OPERATION_FAILED, r, "[E_OPERATION_FAILED] Failed to construct _AppArg.");
 
        pBundle = arg.GetBundle();
 
        service_create_request(pBundle, &hSvc);
-       SysTryCatch(NID_SHELL, hSvc != null, r = E_SYSTEM, r, "[%s] A system error has been occurred. service_create_request failed.", GetErrorMessage(E_SYSTEM));
+       SysTryCatch(NID_SHELL, hSvc != null, r = E_OPERATION_FAILED, r, "[E_OPERATION_FAILED] service_create_request failed.");
 
        if (notifyType == NOTIFY_TYPE_SIMPLE || notifyType == NOTIFY_TYPE_APP_ID)
        {
-               service_set_app_id(hSvc, pRequestImpl->IsAppBinding() ? pAppIdChar.get() : null);
+               retVal = service_set_app_id(hSvc, pRequestImpl->IsAppBinding() ? pAppIdChar.get() : null);
+               SysTryCatch(NID_SHELL, retVal == SERVICE_ERROR_NONE, r = E_OPERATION_FAILED, r, "[E_OPERATION_FAILED] service_set_app_id failed(%d).", retVal);
        }
        else
        if (notifyType == NOTIFY_TYPE_APP_CONTROL)
        {
-
                std::unique_ptr<char[]> pOperationIdChar(_StringConverter::CopyToCharArrayN(*pOperationId));
-               service_set_operation(hSvc, pOperationIdChar.get());
+               retVal = service_set_operation(hSvc, pOperationIdChar.get());
+               SysTryCatch(NID_SHELL, retVal == SERVICE_ERROR_NONE, r = E_OPERATION_FAILED, r, "[E_OPERATION_FAILED] service_set_operation failed(%d).", retVal);
+
                if (pUriData)
                {
                        std::unique_ptr<char[]> pUri(_StringConverter::CopyToCharArrayN(*pUriData));
-                       service_set_uri(hSvc, pUri.get());
+                       retVal = service_set_uri(hSvc, pUri.get());
+                       SysTryLog(NID_SHELL, retVal == SERVICE_ERROR_NONE, "service_set_uri failed(%d).", retVal);
                }
                if (pDataType)
                {
                        std::unique_ptr<char[]> pMime(_StringConverter::CopyToCharArrayN(*pDataType));
-                       service_set_mime(hSvc, pMime.get());
+                       retVal = service_set_mime(hSvc, pMime.get());
+                       SysTryLog(NID_SHELL, retVal == SERVICE_ERROR_NONE, "service_set_mime failed(%d).", retVal);
                }
                if (pExtraData)
                {
@@ -829,30 +819,26 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                                        {
                                                std::unique_ptr<char[]> pKeyString(_StringConverter::CopyToCharArrayN(*pKey));
                                                std::unique_ptr<char[]> pValueString(_StringConverter::CopyToCharArrayN(*pValue));
-                                               service_add_extra_data(hSvc, pKeyString.get(), pValueString.get());
+                                               retVal = service_add_extra_data(hSvc, pKeyString.get(), pValueString.get());
+                                               SysTryLog(NID_SHELL, retVal == SERVICE_ERROR_NONE, "service_add_extra_data failed(%d).", retVal);
                                        }
                                        else
                                        {
-                                               SysLog(NID_SHELL, "pKey or pValue is ivalid.");
+                                               SysLog(NID_SHELL, "pKey or pValue is invalid.");
                                        }
                                }
                        }
                }
        }
 
-       if (service_to_bundle(hSvc, &service_data) == SERVICE_ERROR_NONE)
-       {
-               r = ConvertNotificationResult(notification_set_property(notiHandle, 0));
-               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] notification_set_property failed.", GetErrorMessage(r));
-               r = ConvertNotificationResult(notification_set_execute_option(notiHandle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
-                                                                                                                                         NULL, NULL, service_data));
-               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Nnotification_set_execute_option failed.", GetErrorMessage(r));
-               SysLog(NID_SHELL, "notification_set_execute_option");
-       }
-       else
-       {
-               SysLog(NID_SHELL, "service_to_bundle failed");
-       }
+       retVal = service_to_bundle(hSvc, &service_data);
+       SysTryCatch(NID_SHELL, retVal == SERVICE_ERROR_NONE, r = E_OPERATION_FAILED, r, "[E_OPERATION_FAILED] service_to_bundle failed(%d).", retVal);
+
+       r = ConvertNotificationResult(notification_set_property(notiHandle, 0));
+       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification property failed.", GetErrorMessage(r));
+
+       r = ConvertNotificationResult(notification_set_execute_option(notiHandle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data));
+       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the execute option failed.", GetErrorMessage(r));
 
        // Set layout
        if (isOngoing)
@@ -867,7 +853,8 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                        layout = NOTIFICATION_LY_ONGOING_PROGRESS;
                }
        }
-       notification_set_layout(notiHandle, layout);
+       r = ConvertNotificationResult(notification_set_layout(notiHandle, layout));
+       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification layout failed.", GetErrorMessage(r));
 
        // For ongoing
        if (isOngoing)
@@ -881,41 +868,73 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                        if (needUpdate)
                        {
                                r = ConvertNotificationResult(notification_set_size(notiHandle, 0));    // Reset for override BYTE type
-                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] notification_set_size failure.", GetErrorMessage(r));
+                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification size failed.", GetErrorMessage(r));
                        }
-                       r = ConvertNotificationResult(notification_set_progress(notiHandle, 0));
-                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] notification_set_progress failure.", GetErrorMessage(r));
+                       r = ConvertNotificationResult(notification_set_progress(notiHandle, progress/100.));
+                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification progress failed.", GetErrorMessage(r));
                        break;
 
                case ONGOING_ACTIVITY_TYPE_PROGRESS_BYTE:
                        if (needUpdate)
                        {
                                r = ConvertNotificationResult(notification_set_progress(notiHandle, 0.0));      // Reset for override PERCENTAGE type
-                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] notification_set_progress failure.", GetErrorMessage(r));
+                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification progress failed.", GetErrorMessage(r));
                        }
                        r = ConvertNotificationResult(notification_set_size(notiHandle, progress));
-                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] notification_set_size failure.", GetErrorMessage(r));
+                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification size failed.", GetErrorMessage(r));
                        break;
 
                case ONGOING_ACTIVITY_TYPE_TEXT:
                        r = ConvertNotificationResult(notification_set_progress(notiHandle, 0.0));      // Reset the progress
-                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] notification_set_size failure.", GetErrorMessage(r));
+                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification progress failed.", GetErrorMessage(r));
                        r = ConvertNotificationResult(notification_set_size(notiHandle, 0));
-                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] notification_set_size failure.", GetErrorMessage(r));
+                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification size failed.", GetErrorMessage(r));
                        break;
 
                default:
                        r = E_OPERATION_FAILED;
                        break;
                }
+
+               r = ConvertNotificationResult(notification_get_display_applist(notiHandle, &previousDisplaySet));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification area failed.", GetErrorMessage(r));
+
+               newDisplaySet = previousDisplaySet & ~NOTIFICATION_DISPLAY_APP_TICKER;
+               r = ConvertNotificationResult(notification_set_display_applist(notiHandle, newDisplaySet));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification area failed.", GetErrorMessage(r));
+       }
+
+       // Set LED
+       lightColor = pRequestImpl->GetColor();
+       lightColor32 = lightColor.GetRGB32();
+
+       if (lightColor32 == 0 || (pRequestImpl->GetOnTime() == 0))
+       {       // Turn off case
+               if (needUpdate && __lightActivated)
+               {       // Not for first insertion
+                       r = ConvertNotificationResult(notification_set_led(notiHandle, NOTIFICATION_LED_OP_OFF, 0x00000000));
+                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification led failed.", GetErrorMessage(r));
+                       __lightActivated = false;
+               }
+       }
+       else
+       {
+               r = ConvertNotificationResult(notification_set_led(notiHandle, NOTIFICATION_LED_OP_ON_CUSTOM_COLOR, lightColor32));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification led failed.", GetErrorMessage(r));
+
+               r = ConvertNotificationResult(notification_set_led_time_period(notiHandle, pRequestImpl->GetOnTime(), pRequestImpl->GetOffTime()));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification led time period failed.", GetErrorMessage(r));
+               __lightActivated = true;
        }
 
        // insert for new notification
        if (!needUpdate)
        {       // new
                r = ConvertNotificationResult(notification_insert(notiHandle, &notiPrivateId));
-               SysLog(NID_SHELL, "Insert notification and get new notiPrivateId(%d)", notiPrivateId);
-               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting new notification failed.", GetErrorMessage(r));
+
+               SysLog(NID_SHELL, "Getting new notiPrivateId(%d)", notiPrivateId);
+
                if (isOngoing)
                {
                        __notifyPrivateIdForOngoing  = notiPrivateId;
@@ -924,29 +943,19 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                {
                        __notifyPrivateId = notiPrivateId;
                }
+               __lastNotifyPrivateId = notiPrivateId;
        }
        else
        {
-               int previousDisplaySet = NOTIFICATION_DISPLAY_APP_ALL;
-               if (isOngoing)
-               {
-                       r = ConvertNotificationResult(notification_get_display_applist(notiHandle, &previousDisplaySet));
-                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] notification_set_display_applist failure.", GetErrorMessage(r));
-                       int newDisplaySet = previousDisplaySet & ~NOTIFICATION_DISPLAY_APP_TICKER;
-                       r = ConvertNotificationResult(notification_set_display_applist(notiHandle, newDisplaySet));
-                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] notification_set_display_applist failure.", GetErrorMessage(r));
-               }
-
                r = ConvertNotificationResult(notification_update(notiHandle));
-               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] notification_update failure. notiPrivateId(%d)", GetErrorMessage(r), notiPrivateId);
-
-               if (isOngoing)
-               {
-                       r = ConvertNotificationResult(notification_set_display_applist(notiHandle, previousDisplaySet));
-                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] notification_set_display_applist failure.", GetErrorMessage(r));
-               }
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Updating the notification failed. notiPrivateId(%d)", GetErrorMessage(r), notiPrivateId);
        }
 
+       if (isOngoing)
+       {
+               r = ConvertNotificationResult(notification_set_display_applist(notiHandle, previousDisplaySet));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification area failed.", GetErrorMessage(r));
+       }
 
 CATCH:
        service_destroy(hSvc);
@@ -976,7 +985,8 @@ _NotificationManagerImpl::RemoveNotification(bool onGoing)
 
        if (notiPrivateId != -1)
        {
-               notification_h notiHandle = notification_load(null, notiPrivateId);
+               std::unique_ptr<char[]> pAppIdTemp(_StringConverter::CopyToCharArrayN(__lastAppId));
+               notification_h notiHandle = notification_load(pAppIdTemp.get(), notiPrivateId);
                if (notiHandle)
                {
                        err = notification_delete(notiHandle);
@@ -986,29 +996,15 @@ _NotificationManagerImpl::RemoveNotification(bool onGoing)
                {
                        SysLog(NID_SHELL, "Notification already deleted.");
                }
-               notification_free(notiHandle);
+               err = notification_free(notiHandle);
        }
        else
        {
                err = notification_delete_all_by_type(null, notiType);
-               SysLog(NID_SHELL, "All [%s] notification deleted.", onGoing ? "Ongoing" : "Normal");
-       }
-
-       switch (err)
-       {
-       case NOTIFICATION_ERROR_NONE:
-               r = E_SUCCESS;
-               break;
-
-       case NOTIFICATION_ERROR_INVALID_DATA:
-               r = E_INVALID_ARG;
-               break;
-
-       default:
-               r = E_SYSTEM;
-               break;
+               SysLog(NID_SHELL, "All [%s] notifications deleted.", onGoing ? "Ongoing" : "Normal");
        }
 
+       SysTryReturnResult(NID_SHELL, err == NOTIFICATION_ERROR_NONE, E_OPERATION_FAILED, "Failed to RemoveNotification with reason (%d).", err);
        return r;
 }
 
@@ -1036,60 +1032,53 @@ _NotificationManagerImpl::RemoveNotificationByAppId(const Tizen::App::AppId& app
                {
                        SysLog(NID_SHELL, "Notification already deleted.");
                }
-               notification_free(notiHandle);
+               err = notification_free(notiHandle);
        }
        else
        {
                err = notification_delete_all_by_type(pAppId.get(), notiType);
-               SysLog(NID_SHELL, "All [%s] notification deleted.", onGoing ? "Ongoing" : "Normal");
-       }
-
-       switch (err)
-       {
-       case NOTIFICATION_ERROR_NONE:
-               r = E_SUCCESS;
-               break;
-
-       case NOTIFICATION_ERROR_INVALID_DATA:
-               r = E_INVALID_ARG;
-               break;
-
-       default:
-               r = E_SYSTEM;
-               break;
+               SysLog(NID_SHELL, "All [%s] notifications deleted.", onGoing ? "Ongoing" : "Normal");
        }
 
+       SysTryReturnResult(NID_SHELL, err == NOTIFICATION_ERROR_NONE, E_OPERATION_FAILED, "Failed to RemoveNotificationByAppId with reason (%d).", err);
        return r;
 }
 
-void
+result
 _NotificationManagerImpl::RemoveBadge(const char* pkgName) const
 {
        bool badgeExist = false;
        badge_error_e badgeError = badge_is_existing(pkgName, &badgeExist);
-       SysLog(NID_SHELL, "badge_is_existing: exitst= %d, error= %d.", badgeExist, badgeError); //#####
+       SysTryLog(NID_SHELL, badgeError == BADGE_ERROR_NONE, "badge_is_existing failed(%d).", badgeError);
+
        if (badgeExist)
        {
                badgeError = badge_remove(pkgName);
-               SysLog(NID_SHELL, "badge_remove: error= %d.", badgeError);      //#####
+               SysTryReturnResult(NID_SHELL, badgeError == BADGE_ERROR_NONE, E_OPERATION_FAILED, "badge_remove failed(%d).", badgeError);
        }
-       SysLog(NID_SHELL, "Badge removed.");
+
+       SysLog(NID_SHELL, "Badge is removed.");
+       return E_SUCCESS;
 }
 
-void
+result
 _NotificationManagerImpl::SetBadgeCount(const char* pkgName, int badgeCount) const
 {
        bool badgeExist;
        badge_error_e badgeError = badge_is_existing(pkgName, &badgeExist);
-       SysLog(NID_SHELL, "badge_is_existing: error= %d.", badgeError); //#####
+       SysTryLog(NID_SHELL, badgeError == BADGE_ERROR_NONE, "badge_is_existing failed(%d).", badgeError);
+
        if (!badgeExist)
        {
                badgeError = badge_create(pkgName, pkgName);
-               SysLog(NID_SHELL, "badge_create: error= %d.", badgeError);      //#####
+               SysTryReturnResult(NID_SHELL, badgeError == BADGE_ERROR_NONE, E_OPERATION_FAILED, "badge_create failed(%d).", badgeError);
        }
 
-       badge_set_count(pkgName, badgeCount);
-       SysLog(NID_SHELL, "badge_set_count: badgeNumber= %d.", badgeCount);
+       badgeError = badge_set_count(pkgName, badgeCount);
+       SysTryLog(NID_SHELL, badgeError == BADGE_ERROR_NONE, "badge_set_count failed(%d).", badgeError);
+
+       SysLog(NID_SHELL, "Badge count is %d.", badgeCount);
+       return E_SUCCESS;
 }
 
 int
@@ -1100,12 +1089,12 @@ _NotificationManagerImpl::GetBadgeCount(const char* pkgName) const
        badge_error_e badgeError = badge_get_count(pkgName, &count);
        if (badgeError == BADGE_ERROR_NONE)
        {
-               SysLog(NID_SHELL, "badge_get_count: ret= %d.", count);
+               SysLog(NID_SHELL, "badge_get_count(%d)", count);
                return count;
        }
        else
        {
-               SysLog(NID_SHELL, "badge_get_count: error= %d.", badgeError);
+               SysLog(NID_SHELL, "badge_get_count failed(%d).", badgeError);
                return -1;
        }
 }
@@ -1114,7 +1103,7 @@ result
 _NotificationManagerImpl::AddBadgeEventListener(IBadgeEventListener& listener)
 {
        SysTryReturnResult(NID_SHELL, !__badgeEventListenerList.Contains(&listener), E_OBJ_ALREADY_EXIST, "The listener is already added.");
-       SysLog(NID_SHELL, "(%x)", &listener);
+       SysLog(NID_SHELL, "AddBadgeEventListener (%x)", &listener);
 
        result r = _BadgeManagerImpl::GetInstance()->AddPrimaryBadgeEventListener(*this);
        SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to AddPrimaryBadgeEventListener with reason (%s)", GetErrorMessage(r) );
@@ -1125,13 +1114,26 @@ _NotificationManagerImpl::AddBadgeEventListener(IBadgeEventListener& listener)
 result
 _NotificationManagerImpl::RemoveBadgeEventListener(IBadgeEventListener& listener)
 {
-       SysLog(NID_SHELL, "(%x)", &listener);
-       result r = __badgeEventListenerList.Remove(&listener);
+       SysLog(NID_SHELL, "RemoveBadgeEventListener (%x)", &listener);
+
+       result r = __badgeEventListenerList.Remove(&listener);  // Remove() can return E_SUCCESS and E_OBJ_NOT_FOUND.
        SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "Failed to RemoveBadgeEventListener with reason (%s)", GetErrorMessage(r) );
 
        return _BadgeManagerImpl::GetInstance()->RemovePrimaryBadgeEventListener(*this);
 }
 
+int
+_NotificationManagerImpl::GetLastNotificationId(void) const
+{
+       return __lastNotifyPrivateId;
+}
+
+const Tizen::Base::String&
+_NotificationManagerImpl::GetLastAppId(void) const
+{
+       return __lastAppId;
+}
+
 void
 _NotificationManagerImpl::OnBadgeUpdated(const Tizen::App::AppId& appId, int badgeNumber)
 {