Modify the argument of notification_load for core-notification module requests. ...
[platform/framework/native/shell.git] / src / core / FShell_NotificationManagerImpl.cpp
index 3721a41..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 <FAppTypes.h>
+#include <FIoFile.h>
+#include <FAppApp.h>
+#include <FGrpColor.h>
 #include <FShellNotificationManager.h>
 #include <FShellNotificationRequest.h>
-
-#include <FBaseInternalTypes.h>
+#include <FShellIBadgeEventListener.h>
 #include <FBase_StringConverter.h>
-#include "FApp_AppInfo.h"
-#include "FAppPkg_PackageManagerImpl.h"
-#include "FApp_AppArg.h"
+#include <FApp_Aul.h>
+#include <FApp_AppArg.h>
 #include "FShell_NotificationManagerImpl.h"
-#include "FShell_NotificationManagerProxy.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::Shell;
+using namespace Tizen::Io;
+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);
@@ -64,9 +61,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:
@@ -74,66 +71,128 @@ ConvertNotificationResult(int error)
        }
 }
 
-bool
-IsPosted(ui_notification_h handle)
+result
+ConvertAppManagerResult(int error)
 {
-       struct ui_notification_s
+       switch (error)
        {
-               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;
-       };
+       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;
+       }
+}
+
+} // namespace
 
-       if (handle == NULL)
+
+namespace Tizen { namespace Shell
+{
+
+///////////////////////////////////////////////////////////////////
+// _BadgeManagerImpl
+///////////////////////////////////////////////////////////////////
+void
+BadgeChangedCallback(unsigned int action, const char *pkgname, unsigned int count, void *data)
+{
+       Tizen::Base::Collection::LinkedListT<Tizen::Shell::IBadgeEventListener*>* pBadgeEventListenerList = static_cast<Tizen::Base::Collection::LinkedListT<Tizen::Shell::IBadgeEventListener*>*>(data);
+       SysAssert(pBadgeEventListenerList);
+
+       std::unique_ptr<IEnumeratorT<Tizen::Shell::IBadgeEventListener* > > pEnum(pBadgeEventListenerList->GetEnumeratorN());
+       SysTryReturnVoidResult(NID_SHELL, pEnum.get(), E_OUT_OF_MEMORY, "Failed to GetEnumeratorN()!");
+
+       IBadgeEventListener* pListener;
+       while (pEnum->MoveNext() == E_SUCCESS)
        {
-               return false;
+               pListener = null;
+               pEnum->GetCurrent(pListener);
+               if (!pListener)
+               {
+                       SysLog(NID_SHELL, "pListener is null!");
+                       continue;
+               }
+
+               pListener->OnBadgeUpdated(pkgname, count);
        }
+}
 
-       ui_notification_s* pStruct = reinterpret_cast<ui_notification_s*>(handle);
+_BadgeManagerImpl*
+_BadgeManagerImpl::GetInstance(void)
+{
+       static _BadgeManagerImpl* pTheInstance = 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.");
 
-       return pStruct->posted;
+               pTheInstance->Construct();
+       }
+       return pTheInstance;
 }
 
+result
+_BadgeManagerImpl::Construct(void)
+{
+       return E_SUCCESS;
 }
 
-namespace Tizen { namespace Shell
+result
+_BadgeManagerImpl::AddPrimaryBadgeEventListener(IBadgeEventListener& primaryListener)
 {
+       if( __primaryBadgeEventListenerList.GetCount() == 0)
+       {
+               int ret = badge_register_changed_cb(BadgeChangedCallback, &__primaryBadgeEventListenerList);
+               SysTryReturnResult(NID_SHELL, ret == BADGE_ERROR_NONE, E_SYSTEM, "Failed to badge_register_changed_cb, (%d)", ret);
+       }
 
+       return __primaryBadgeEventListenerList.Add(&primaryListener);
+}
+
+result
+_BadgeManagerImpl::RemovePrimaryBadgeEventListener(IBadgeEventListener& primaryListener)
+{
+       __primaryBadgeEventListenerList.Remove(&primaryListener);
+       if( __primaryBadgeEventListenerList.GetCount() == 0)
+       {
+               int ret = badge_unregister_changed_cb(BadgeChangedCallback);
+               SysTryReturnResult(NID_SHELL, ret == BADGE_ERROR_NONE, E_SYSTEM, "Failed to badge_unregister_changed_cb, (%d)", ret);
+       }
+       return E_SUCCESS;
+}
+
+
+///////////////////////////////////////////////////////////////////
+// _NotificationManagerImpl
+///////////////////////////////////////////////////////////////////
 _NotificationManagerImpl::_NotificationManagerImpl(void)
-: __pNotificationManager(null)
+       : __notifyPrivateId(-1)
+       , __notifyPrivateIdForOngoing(-1)
+       , __lastNotifyPrivateId(-1)
+       , __lightActivated(false)
 {
 }
 
 _NotificationManagerImpl::~_NotificationManagerImpl(void)
 {
+       bool isListeningBadgeEvent = (__badgeEventListenerList.GetCount() > 0)? true : false;
+       if(isListeningBadgeEvent == true)
+       {
+               _BadgeManagerImpl::GetInstance()->RemovePrimaryBadgeEventListener(*this);
+       }
 }
 
 result
 _NotificationManagerImpl::Construct(void)
 {
-       result r = E_SUCCESS;
-
-       __pNotificationManager = new (std::nothrow) _NotificationManagerProxy;
-       SysTryReturnResult(NID_APP, __pNotificationManager != null, E_OUT_OF_MEMORY, "__pNotificationManagerProxy creation failed.");
-
-       r = __pNotificationManager->Construct();
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "__pNotificationManager->Construct() failed [%s].", GetErrorMessage(r));
-
        return E_SUCCESS;
-
-CATCH:
-       delete __pNotificationManager;
-       __pNotificationManager = null;
-
-       return r;
 }
 
 const _NotificationManagerImpl*
@@ -151,606 +210,948 @@ _NotificationManagerImpl::GetInstance(NotificationManager& notiMgr)
 int
 _NotificationManagerImpl::GetBadgeNumber(void) const
 {
-       int count = -1;
-       notification_get_badge(NULL, NOTIFICATION_GROUP_ID_NONE, &count);
+       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, "[E_OPERATION_FAILED] The operation has failed. Badge may not exist.");
+
        return count;
 }
 
 result
-_NotificationManagerImpl::OngoingImpl(const String& messageText, const String& launchArguments) const
+_NotificationManagerImpl::NotifyMessageImpl(const NotificationRequest& notiMessage, bool isOngoing)
 {
-       return NotifyImpl(messageText, -1, launchArguments, true);
+       return NotifyMessage(NOTIFY_TYPE_SIMPLE, isOngoing, notiMessage);
 }
 
 result
-_NotificationManagerImpl::OngoingImpl(const AppId& appId, const String& messageText, const String& launchArguments) const
+_NotificationManagerImpl::NotifyMessageImpl(const AppId& appId, const NotificationRequest& notiMessage, bool isOngoing)
 {
-
-       return NotifyImpl(appId, messageText, -1, launchArguments, true);
+       return NotifyMessage(NOTIFY_TYPE_APP_ID, isOngoing, notiMessage, &appId);
 }
 
+
 result
-_NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber,
-                                                                        const String& launchArguments,
-                                                                        bool isOngoing) const
+_NotificationManagerImpl::Notify(int badgeNumber)
 {
-       result r = E_SUCCESS;
-       char* pMsg = null;
-       notification_h core = NULL;
-       char* pkgname = NULL;
-       bundle* pKb = NULL;
-       bundle* service_data = NULL;
-       service_h svc = NULL;
-       _AppArg arg;
+       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.");
 
-       if (!messageText.IsEmpty())
-       {
-               SysTryReturnResult(NID_APP,
-                                         messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
-                                         "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
+       Tizen::App::App* pApp = Tizen::App::App::GetInstance();
+       std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(pApp->GetAppId()));
 
-               if (isOngoing)
-               {
-                       core = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
-                       SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
-               }
-               else
-               {
-                       core = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
-                       SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
-               }
+       result r = E_SUCCESS;
 
-               pMsg = _StringConverter::CopyToCharArrayN(messageText);
-               notification_set_text(core, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+       if (badgeNumber == 0)
+       {
+               r = RemoveBadge(pAppId.get());
+               SysTryReturnResult(NID_SHELL, !IsFailed(r), r, "Failed to remove the badge.");
+       }
+       else
+       if (badgeNumber > 0)
+       {
+               r = SetBadgeCount(pAppId.get(), badgeNumber);
+               SysTryReturnResult(NID_SHELL, !IsFailed(r), r, "Failed to set the badge.");
+       }
 
-               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.");
+       return r;
+}
 
-               r = arg.Construct(launchArguments);
-               SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+result
+_NotificationManagerImpl::Notify(const String& messageText)
+{
+       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.");
 
-               pKb = arg.GetBundle();
-               service_create_request(pKb, &svc);
-               service_set_package(svc, pkgname);
-               
-               if (service_to_bundle(svc, &service_data) == SERVICE_ERROR_NONE)
-               {
-                        notification_set_property(core, 0);
-                        notification_set_execute_option(core, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
-                        SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), pkgname);
-               }
+       NotificationRequest request;
+       request.SetAlertText(messageText);
+       request.SetAppMessage(L"");
 
-               r = ConvertNotificationResult(notification_insert(core, NULL));
-               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
-       }
+       return NotifyMessage(NOTIFY_TYPE_SIMPLE, false, request);
+}
 
-       if (badgeNumber >= 0)
-       {
-               notification_set_badge(NULL, NOTIFICATION_GROUP_ID_NONE, badgeNumber);
-               SysLog(NID_APP, "Badge number is set to %d.", badgeNumber);
-       }
+result
+_NotificationManagerImpl::Notify(const String& messageText, int badgeNumber)
+{
+       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.");
 
-CATCH:
-       delete[] pMsg;
-       if (pkgname)
-       {
-               free(pkgname);
-       }
+       NotificationRequest request;
+       request.SetAlertText(messageText);
+       request.SetBadgeNumber(badgeNumber);
+       request.SetAppMessage(L"");
 
-       if (core)
-       {
-               notification_free(core);
-       }
-       service_destroy(svc);
-       return r;
+       return NotifyMessage(NOTIFY_TYPE_SIMPLE, false, request);
 }
 
 result
-_NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageText, int badgeNumber,
-                                                                        const String& launchArguments,
-                                                                        bool isOngoing) const
+_NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments)
 {
-       result r = E_SUCCESS;
-       char* pMsg = null;
-       char* pIcon = NULL;
-       char* pName = NULL;
-       notification_h core = NULL;
-       char buffer[256];
-       bundle* pKb = NULL;
-       bundle* service_data = NULL;
-       service_h svc = NULL;
-       _AppArg arg;
+       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);
+       request.SetBadgeNumber(badgeNumber);
+       request.SetAppMessage(launchArguments);
+
+       return NotifyMessage(NOTIFY_TYPE_SIMPLE, false, request);
+}
 
-       memset(buffer, 0, 256);
+int
+_NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
+{
+       ClearLastResult();
 
-       bool b = _PackageManagerImpl::IsAppInstalled(appId);
+       bool b = _Aul::IsInstalled(appId);
+       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());
 
-       SysTryReturnResult(NID_APP, b == true, E_APP_NOT_INSTALLED, "The application %ls is not installed", appId.GetPointer());
+       SysTryReturn(NID_SHELL, count != -1, count, E_OPERATION_FAILED, "[E_OPERATION_FAILED] The operation has failed. Badge may not exist.");
 
-       if (isOngoing || !messageText.IsEmpty())
-       {
-               SysTryReturnResult(NID_APP,
-                                         messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
-                                         "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
+       return count;
+}
 
-               if (isOngoing)
-               {
-                       core = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
-                       SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
-               }
-               else
-               {
-                       core = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
-                       SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
-               }
+result
+_NotificationManagerImpl::NotifyOngoingActivity(const String& messageText)
+{
+       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.");
 
-               pMsg = _StringConverter::CopyToCharArrayN(messageText);
-               notification_set_text(core, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+       NotificationRequest request;
+       request.SetAlertText(messageText);
 
-               snprintf(buffer, 256, "%ls", appId.GetPointer());
+       return NotifyMessage(NOTIFY_TYPE_SIMPLE, true, request);
+}
 
-               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));
+result
+_NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments)
+{
+       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.");
 
-               app_manager_get_app_name(buffer, &pName);
-               r = ConvertNotificationResult(notification_set_text(core, NOTIFICATION_TEXT_TYPE_TITLE, pName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
-               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title text failed.", GetErrorMessage(r));
+       NotificationRequest request;
+       request.SetAlertText(messageText);
+       request.SetAppMessage(launchArguments);
 
-               r = arg.Construct(launchArguments);
-               SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+       return NotifyMessage(NOTIFY_TYPE_SIMPLE, true, request);
+}
 
-               pKb = arg.GetBundle();
-               service_create_request(pKb, &svc);
-               service_set_app_id(svc, buffer);
-               
-               if (service_to_bundle(svc, &service_data) == SERVICE_ERROR_NONE)
-               {
-                        notification_set_property(core, 0);
-                        notification_set_execute_option(core, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
-                        SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), buffer);
-               }
+result
+_NotificationManagerImpl::RemoveOngoingActivityNotificationByAppId(const AppId& appId)
+{
+       return RemoveNotificationByAppId(appId, true);
+}
 
-               r = ConvertNotificationResult(notification_insert(core,NULL));
-               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
-       }
 
-       if (badgeNumber >= 0)
-       {
-               notification_set_badge(buffer, NOTIFICATION_GROUP_ID_NONE, badgeNumber);
-               SysLog(NID_APP, "Badge number is set to %d.", badgeNumber);
-       }
+result
+_NotificationManagerImpl::RemoveNotificationByAppId(const AppId& appId)
+{
+       return RemoveNotificationByAppId(appId, false);
+}
 
-CATCH:
-       delete[] pMsg;
+result
+_NotificationManagerImpl::NotifyTextMessage(const String& messageText) const
+{
+       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.");
 
-       if (core)
-       {
-               notification_free(core);
-       }
+       std::unique_ptr<char[]> pMsg(_StringConverter::CopyToCharArrayN(messageText));
+       int res = notification_status_message_post(pMsg.get());
 
-       if (pIcon)
+       result r = E_SUCCESS;
+       switch (res)
        {
-               free(pIcon);
+       case NOTIFICATION_ERROR_NONE:
+               // success
+               break;
+       case NOTIFICATION_ERROR_INVALID_DATA:
+               r = E_INVALID_ARG;
+               break;
+       case NOTIFICATION_ERROR_IO:
+               r = E_OPERATION_FAILED;
+               break;
+       default:
+               r = E_OPERATION_FAILED;
+               break;
        }
 
-       if (pName)
-       {
-               free(pName);
-       }
-       service_destroy(svc);
+       SysLog(NID_SHELL, "[%s] %ls posted.", GetErrorMessage(r), messageText.GetPointer());
        return r;
 }
 
+result
+_NotificationManagerImpl::NotifyByAppControl(const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pDataType,
+                                                                                        const Tizen::Base::Collection::IMap* pExtraData, const NotificationRequest& request)
+{
+       result r = E_SUCCESS;
+
+       r = NotifyMessage(NOTIFY_TYPE_APP_CONTROL, false, request, null, &operationId, pUriData, pDataType, pExtraData);
+       return r;
+}
 
 result
-_NotificationManagerImpl::NotifyMessageImpl(const NotificationRequest& notiMessage, bool isOngoing)
+_NotificationManagerImpl::NotifyOngoingActivityByAppControl(const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pDataType,
+                                                                                                                       const Tizen::Base::Collection::IMap* pExtraData, const NotificationRequest& request)
+{
+       result r = E_SUCCESS;
+
+       r = NotifyMessage(NOTIFY_TYPE_APP_CONTROL, true, request, null, &operationId, pUriData, pDataType, pExtraData);
+       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)
 {
        result r = E_SUCCESS;
-       int progress = -1;
-       notification_h core = NULL;
-       char* pkgname = NULL;
-       char* pTitleText = NULL;
-       char* pIconPath = NULL;
-       char* pSoundPath = NULL;
-       bundle* pKb = NULL;
-       bundle* service_data = NULL;
-       service_h svc = NULL;
+       std::unique_ptr<char[]> pAppIdChar(null);
+       const _NotificationRequestImpl* pRequestImpl = _NotificationRequestImpl::GetInstance(notifyRequest);
+       SysTryReturnResult(NID_SHELL, pRequestImpl != null, E_INVALID_ARG, "Invalid argument is used.");
+
+       // Set pAppIdChar
+       if ((notifyType == NOTIFY_TYPE_SIMPLE) || (notifyType == NOTIFY_TYPE_APP_CONTROL))
+       {
+               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 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());
+               std::unique_ptr<char[]> pAppIdTemp(_StringConverter::CopyToCharArrayN(*pAppId));
+               pAppIdChar = std::move(pAppIdTemp);
+       }
+       else
+       {
+               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 != 0)
+       {
+               // Set - Badge
+               if (badgeOffset != 0)
+               {
+                       int badgeNumber = GetBadgeCount(pAppIdChar.get());
+                       if (badgeNumber <= 0)
+                       {
+                               SetBadgeCount(pAppIdChar.get(), badgeOffset);
+                       }
+                       else
+                       {
+                               SetBadgeCount(pAppIdChar.get(), badgeNumber + badgeOffset);
+                       }
+               }
+               else
+               {
+                       if (badgeNumber == 0)
+                       {
+                               r = RemoveBadge(pAppIdChar.get());
+                               SysTryReturnResult(NID_SHELL, !IsFailed(r), r, "Failed to remove the badge.");
+                       }
+                       else
+                       if (badgeNumber > 0)
+                       {
+                               r = SetBadgeCount(pAppIdChar.get(), badgeNumber);
+                               SysTryReturnResult(NID_SHELL, !IsFailed(r), r, "Failed to set the badge.");
+                       }
+               }
+               if (!(isOngoing || !contentText.IsEmpty()))
+               {
+                       SysLog(NID_SHELL, "No valid for Notification, just for set a badgeNumber update.");
+                       return E_SUCCESS;
+               }
+       }
+       SysTryReturnResult(NID_SHELL, (isOngoing || !contentText.IsEmpty()), E_INVALID_ARG, "Invalid argument is used. MessageText is Empty");
+
+       const String& titleText = notifyRequest.GetTitleText();
+       const String& launchArguments = notifyRequest.GetAppMessage();
+       const String& iconPath = notifyRequest.GetIconFilePath();
+       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;
+       bundle* service_data = null;
        _AppArg arg;
+       service_h hSvc = null;
+       notification_ly_type_e layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
 
-       const String& messageText = notiMessage.GetAlertText();
-       const String& launchArguments = notiMessage.GetAppMessage();
-       const String& titleText = notiMessage.GetTitleText();
-       const String& iconPath = notiMessage.GetIconFilePath();
-       const String& soundPath = notiMessage.GetSoundFilePath();
-       const int badgeNumber = notiMessage.GetBadgeNumber();
-       const int badgeOffset = notiMessage.GetBadgeOffset();
+       // Notification creation
+       if (notiPrivateId != -1)
+       {
+               notiHandle = notification_load(pAppIdChar.get(), notiPrivateId);
+               SysTryLog(NID_SHELL, notiHandle != null, "Get notiHandle(%d) from notiPrivateId(%d).", notiHandle, notiPrivateId);
+       }
 
-       if (isOngoing || !messageText.IsEmpty())
+       if (notiHandle == null)
+       {
+               SysLog(NID_SHELL, "Previous notification(%d) no more valid - create new notification", notiPrivateId);
+               notiPrivateId = -1;             // reset
+               notiHandle = notification_create(notiType);
+       }
+       else
        {
-               SysTryReturnResult(NID_APP,
-                                         messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
-                                         "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
+               needUpdate = true;              // No need to notification_insert.
+       }
+       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));
 
+       // Title text
+       std::unique_ptr<char[]> pTitleText(null);
+       if (!titleText.IsEmpty())
+       {
+               std::unique_ptr<char[]> pTitleTextTemp(_StringConverter::CopyToCharArrayN(titleText));
+               pTitleText = std::move(pTitleTextTemp);
+       }
+       else
+       {
+               char* pAppName = null;
+               r = ConvertAppManagerResult(app_manager_get_app_name(pAppIdChar.get(), &pAppName));
+               if (pAppName)
+               {
+                       String appName(pAppName);
+                       std::unique_ptr<char[]> pTitleTextTemp(_StringConverter::CopyToCharArrayN(appName));
+                       pTitleText = std::move(pTitleTextTemp);
+                       free(pAppName);
+                       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));
+       }
+       // Icon file path
+       std::unique_ptr<char[]> pIconPath(null);
+       if (!iconPath.IsEmpty())
+       {
+               std::unique_ptr<char[]> pIconPathTemp(_StringConverter::CopyToCharArrayN(iconPath));
+               pIconPath = std::move(pIconPathTemp);
+       }
+       else
+       {
+               char* pDefaultIconPath = null;
+               r = ConvertAppManagerResult(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_SHELL, !IsFailed(r), "[%s] Setting the icon path failed.", GetErrorMessage(r));
+       }
+       // Sound file path
+       std::unique_ptr<char[]> pSoundPath(null);
+       if (!soundPath.IsEmpty())
+       {
+               std::unique_ptr<char[]> pSoundPathTemp(_StringConverter::CopyToCharArrayN(soundPath));
+               pSoundPath = std::move(pSoundPathTemp);
+       }
+       // Set - AppId
+       if (notifyType == NOTIFY_TYPE_APP_ID)
+       {
+               r = ConvertNotificationResult(notification_set_pkgname(notiHandle, pAppIdChar.get()));
+               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] Setting the title text failed.", GetErrorMessage(r));
+       }
+       // Set - content text
+       if (pMsg.get())
+       {
+               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] Setting the icon path failed.", GetErrorMessage(r));
+       // Set - sound file path
+       if (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
+       {
                if (isOngoing)
-               {
-                       core = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
-                               SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
-                       }
-               else
-               {
-                       core = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
-                       SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
-               }
-
-               std::unique_ptr<char[]> pMsg(_StringConverter::CopyToCharArrayN(messageText));
-
-               if (pMsg)
                {
-                       r = ConvertNotificationResult(notification_set_text(core, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg.get(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
-                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title text failed.", GetErrorMessage(r));
+                       r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_NONE, NULL));
                }
-
-               if (!titleText.IsEmpty())
+               else
                {
-                       pTitleText = _StringConverter::CopyToCharArrayN(titleText);
-                       r = ConvertNotificationResult(notification_set_text(core, NOTIFICATION_TEXT_TYPE_TITLE, pTitleText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
-                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title text failed.", GetErrorMessage(r));
+                       r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL));
                }
+       }
+       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the sound failed.", GetErrorMessage(r));
 
-               if (!iconPath.IsEmpty())
+       // Set extended - text, thumbnail and background image
+       if (!isOngoing)
+       {
+               // Extended style set
+               String countText = notifyRequest.GetNotificationCountText();
+               NotificationStyle notiStyle= notifyRequest.GetNotificationStyle();
+               if (notiStyle == NOTIFICATION_STYLE_THUMBNAIL)
                {
-                       pIconPath = _StringConverter::CopyToCharArrayN(iconPath);
-                       r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIconPath));
-                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
+                       layout = NOTIFICATION_LY_NOTI_THUMBNAIL;
                }
-
-               if (!soundPath.IsEmpty())
+               else
+               if (notiStyle == NOTIFICATION_STYLE_NORMAL && !countText.IsEmpty())
                {
-                       pSoundPath = _StringConverter::CopyToCharArrayN(soundPath);
-                       r = ConvertNotificationResult(notification_set_sound(core, NOTIFICATION_SOUND_TYPE_USER_DATA, pSoundPath));
-                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set sound failed.", GetErrorMessage(r));
+                       layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE;
                }
 
-               app_get_id(&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.");
-
-               r = arg.Construct(launchArguments);
-               SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+               if (!countText.IsEmpty())
+               {
+                       std::unique_ptr<char[]> text(_StringConverter::CopyToCharArrayN(countText));
+                       r = ConvertNotificationResult(notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, text.get(),
+                                                                                                                               NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
+               }
 
-               pKb = arg.GetBundle();
-               service_create_request(pKb, &svc);
-               service_set_app_id(svc, pkgname);
+               String bgImageFilePath = notifyRequest.GetBackgroundImageFilePath();
+               if (!bgImageFilePath.IsEmpty() && File::IsFileExist(bgImageFilePath))
+               {
+                       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] Setting the background image path failed.", GetErrorMessage(r));
+               }
 
-               if (service_to_bundle(svc, &service_data) == SERVICE_ERROR_NONE)
-               {
-                        notification_set_property(core, 0);
-                        notification_set_execute_option(core, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
-                        SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), pkgname);
-               }
 
-               if (isOngoing)
+               if (notiStyle == NOTIFICATION_STYLE_THUMBNAIL)
                {
-                       OngoingActivityType activityType = notiMessage.GetOngoingActivityType();
-                       progress = notiMessage.GetOngoingActivityProgress();
-                       switch (activityType)
+                       const IList* pThumbnailList = pRequestImpl->GetMessageThumbnailFilePathList();
+                       if (pThumbnailList)
                        {
-                       case ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE:
-                               r = ConvertNotificationResult(notification_insert(core,NULL));
-                               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
-                               r = ConvertNotificationResult(notification_update_progress(core, NOTIFICATION_PRIV_ID_NONE, progress/100.));
-                               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification update failure.", GetErrorMessage(r));
-                               break;
-                       case ONGOING_ACTIVITY_TYPE_PROGRESS_BYTE:
-                               r = ConvertNotificationResult(notification_insert(core,NULL));
-                               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
-                               r = ConvertNotificationResult(notification_update_size(core, NOTIFICATION_PRIV_ID_NONE, progress));
-                               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification update failure.", GetErrorMessage(r));
-                               break;
-                       case ONGOING_ACTIVITY_TYPE_TEXT:
-                               r = ConvertNotificationResult(notification_insert(core,NULL));
-                               SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
-                               break;
-                       default:
-                               r = E_OPERATION_FAILED;
-                               // ui_notification_set_content() is done already
-                               break;
+                               const static notification_image_type_e thumbnailListEnum[] = {NOTIFICATION_IMAGE_TYPE_LIST_1, NOTIFICATION_IMAGE_TYPE_LIST_2,
+                                               NOTIFICATION_IMAGE_TYPE_LIST_3, NOTIFICATION_IMAGE_TYPE_LIST_4, NOTIFICATION_IMAGE_TYPE_LIST_5 };
+                               int itemCount = pThumbnailList->GetCount();
+                               const int maxCount = sizeof(thumbnailListEnum)/sizeof(thumbnailListEnum[0]);
+                               if (itemCount > maxCount)
+                               {
+                                       itemCount = maxCount;
+                               }
+                               for (int i = 0; i < itemCount; i++)
+                               {
+                                       const String* pThumbnailPath = static_cast<const String*>(pThumbnailList->GetAt(i));
+                                       std::unique_ptr<char[]> filePath(_StringConverter::CopyToCharArrayN(*pThumbnailPath));
+                                       r = ConvertNotificationResult(notification_set_image(notiHandle, thumbnailListEnum[i], filePath.get()));
+                                       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the thumbnail path failed.", GetErrorMessage(r));
+                               }
                        }
                }
                else
                {
-                       r = ConvertNotificationResult(notification_insert(core,NULL));
-                       SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
+                       const IList* pMessageTextList = pRequestImpl->GetMessageTextList();
+                       if (pMessageTextList && pMessageTextList->GetCount())
+                       {
+                               const String* pText1 = static_cast<const String*>(pMessageTextList->GetAt(0));
+                               if (pText1)
+                               {
+                                       int matchIndex;
+                                       if (E_SUCCESS == pText1->IndexOf(L'\t', 0, matchIndex))
+                                       {
+                                               // Make two token
+                                               String subText;
+                                               pText1->SubString(0, matchIndex+1, subText);
+                                               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] 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] Setting the Info1 sub text failed.", GetErrorMessage(r));
+                                               }
+                                       }
+                                       else
+                                       {
+                                               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] Setting the Info1 text failed.", GetErrorMessage(r));
+                                       }
+                               }
+                               const String* pText2 = static_cast<const String*>(pMessageTextList->GetAt(1));
+                               if (pText2)
+                               {
+                                       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))))
+                                       {
+                                               // Make two token
+                                               String subText;
+                                               pText2->SubString(0, matchIndex+1, subText);
+                                               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] 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] Setting the Info2 sub text failed.", GetErrorMessage(r));
+                                               }
+                                       }
+                                       else
+                                       {
+                                               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] Setting the Info2 text failed.", GetErrorMessage(r));
+                                       }
+                               }
+                       }
+                       else
+                       if (needUpdate)
+                       {       // 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)
+                               {
+                                       const static notification_text_type_e infoTextEnums[] = { NOTIFICATION_TEXT_TYPE_INFO_1, NOTIFICATION_TEXT_TYPE_INFO_SUB_1,
+                                                                                                                                                        NOTIFICATION_TEXT_TYPE_INFO_2, NOTIFICATION_TEXT_TYPE_INFO_SUB_2 };
+                                       for (unsigned int i = 0; i < sizeof(infoTextEnums)/sizeof(infoTextEnums[0]); i++)
+                                       {
+                                               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 = 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_OPERATION_FAILED, r, "[E_OPERATION_FAILED] service_create_request failed.");
+
+       if (notifyType == NOTIFY_TYPE_SIMPLE || notifyType == NOTIFY_TYPE_APP_ID)
+       {
+               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)
        {
-               SysTryReturnResult(NID_APP, 0, E_INVALID_ARG, "MessageText is Empty");
+               std::unique_ptr<char[]> pOperationIdChar(_StringConverter::CopyToCharArrayN(*pOperationId));
+               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));
+                       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));
+                       retVal = service_set_mime(hSvc, pMime.get());
+                       SysTryLog(NID_SHELL, retVal == SERVICE_ERROR_NONE, "service_set_mime failed(%d).", retVal);
+               }
+               if (pExtraData)
+               {
+                       std::unique_ptr<Tizen::Base::Collection::IMapEnumerator> pMapEnum(pExtraData->GetMapEnumeratorN());
+                       if (pMapEnum)
+                       {
+                               while (pMapEnum->MoveNext() == E_SUCCESS)
+                               {
+                                       String* pKey = static_cast<String* > (pMapEnum->GetKey());
+                                       String* pValue = static_cast<String* > (pMapEnum->GetValue());
+                                       if (pKey && pValue)
+                                       {
+                                               std::unique_ptr<char[]> pKeyString(_StringConverter::CopyToCharArrayN(*pKey));
+                                               std::unique_ptr<char[]> pValueString(_StringConverter::CopyToCharArrayN(*pValue));
+                                               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 invalid.");
+                                       }
+                               }
+                       }
+               }
        }
 
-       if (badgeNumber >= 0)
+       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)
        {
-               notification_set_badge(NULL, NOTIFICATION_GROUP_ID_NONE, badgeNumber);
-               SysLog(NID_APP, "Badge number is set to %d.", badgeNumber);
+               OngoingActivityType activityType = notifyRequest.GetOngoingActivityType();
+               if (activityType == ONGOING_ACTIVITY_TYPE_TEXT)
+               {
+                       layout = NOTIFICATION_LY_ONGOING_EVENT;
+               }
+               else
+               {
+                       layout = NOTIFICATION_LY_ONGOING_PROGRESS;
+               }
        }
+       r = ConvertNotificationResult(notification_set_layout(notiHandle, layout));
+       SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification layout failed.", GetErrorMessage(r));
 
-       if (badgeOffset != 0)
+       // For ongoing
+       if (isOngoing)
        {
-               // badge offset is exclusive to badge number
+               OngoingActivityType activityType = notifyRequest.GetOngoingActivityType();
+               int progress = notifyRequest.GetOngoingActivityProgress();
 
-               int count = 0;
-               notification_error_e noti_err = notification_get_badge(NULL, NOTIFICATION_GROUP_ID_NONE, &count);
-               if (noti_err == NOTIFICATION_ERROR_NONE)
+               switch (activityType)
                {
-                       count += badgeOffset;
-                       if (count > 0)
+               case ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE:
+                       if (needUpdate)
+                       {
+                               r = ConvertNotificationResult(notification_set_size(notiHandle, 0));    // Reset for override BYTE type
+                               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification size failed.", 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)
                        {
-                               notification_set_badge(NULL, NOTIFICATION_GROUP_ID_NONE, count);
-                               SysLog(NID_APP, "Badge number is set to %d.", count);
+                               r = ConvertNotificationResult(notification_set_progress(notiHandle, 0.0));      // Reset for override PERCENTAGE type
+                               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] 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] Setting the notification progress failed.", GetErrorMessage(r));
+                       r = ConvertNotificationResult(notification_set_size(notiHandle, 0));
+                       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));
        }
 
-CATCH:
-       delete[] pIconPath;
-       delete[] pTitleText;
-       delete[] pSoundPath;
-       if (pkgname)
-       {
-               free(pkgname);
+       // 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;
+               }
        }
-       if (core)
+       else
        {
-               notification_free(core);
-       }
-       service_destroy(svc);
-       return r;
-}
+               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));
 
-result
-_NotificationManagerImpl::NotifyMessageImpl(const AppId& appId, const NotificationRequest& notiMessage, bool isOngoing)
-{
-       return __pNotificationManager->NotifyMessage(appId, notiMessage, isOngoing);
-}
+               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));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting new notification failed.", GetErrorMessage(r));
 
-result
-_NotificationManagerImpl::Notify(int badgeNumber) const
-{
-       SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
+               SysLog(NID_SHELL, "Getting new notiPrivateId(%d)", notiPrivateId);
 
-       if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
+               if (isOngoing)
+               {
+                       __notifyPrivateIdForOngoing  = notiPrivateId;
+               }
+               else
+               {
+                       __notifyPrivateId = notiPrivateId;
+               }
+               __lastNotifyPrivateId = notiPrivateId;
+       }
+       else
        {
-               badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
+               r = ConvertNotificationResult(notification_update(notiHandle));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Updating the notification failed. notiPrivateId(%d)", GetErrorMessage(r), notiPrivateId);
        }
 
-       String messageText = String(L"");
-       String appMessage = String(L"");
+       if (isOngoing)
+       {
+               r = ConvertNotificationResult(notification_set_display_applist(notiHandle, previousDisplaySet));
+               SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Setting the notification area failed.", GetErrorMessage(r));
+       }
 
-       return NotifyImpl(messageText, badgeNumber, appMessage, false);
+CATCH:
+       service_destroy(hSvc);
+       notification_free(notiHandle);
+       return r;
 }
 
 result
-_NotificationManagerImpl::Notify(const String& messageText) const
+_NotificationManagerImpl::RemoveNotification(void)
 {
-       SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
-
-       String appMessage = String(L"");
-
-       return NotifyImpl(messageText, -1, appMessage, false);
+       return RemoveNotification(false);
 }
 
 result
-_NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) const
+_NotificationManagerImpl::RemoveOngoingActivityNotification(void)
 {
-       SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
-       SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
-
-       if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
-       {
-               badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
-       }
-
-       String appMessage = String(L"");
-
-       return NotifyImpl(messageText, badgeNumber, appMessage, false);
+       return RemoveNotification(true);
 }
 
 result
-_NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments) const
+_NotificationManagerImpl::RemoveNotification(bool onGoing)
 {
-       SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
-       SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
-       SysTryReturnResult(NID_APP,
-                                         launchArguments != null && launchArguments.GetLength() > 0, E_INVALID_ARG,
-                                         "launchArguments is less than 0.");
-
-       SysTryReturnResult(NID_APP,
-                                         launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
-                                         "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
+       result r = E_SUCCESS;
+       notification_error_e err = NOTIFICATION_ERROR_NONE;
+       const notification_type_e notiType = onGoing ? NOTIFICATION_TYPE_ONGOING : NOTIFICATION_TYPE_NOTI;
+       const int notiPrivateId = onGoing ? __notifyPrivateIdForOngoing : __notifyPrivateId;
 
-       if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
+       if (notiPrivateId != -1)
        {
-               badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
+               std::unique_ptr<char[]> pAppIdTemp(_StringConverter::CopyToCharArrayN(__lastAppId));
+               notification_h notiHandle = notification_load(pAppIdTemp.get(), notiPrivateId);
+               if (notiHandle)
+               {
+                       err = notification_delete(notiHandle);
+                       SysLog(NID_SHELL, "Notification deleted.");
+               }
+               else
+               {
+                       SysLog(NID_SHELL, "Notification already deleted.");
+               }
+               err = notification_free(notiHandle);
+       }
+       else
+       {
+               err = notification_delete_all_by_type(null, notiType);
+               SysLog(NID_SHELL, "All [%s] notifications deleted.", onGoing ? "Ongoing" : "Normal");
        }
 
-       return NotifyImpl(messageText, badgeNumber, launchArguments, false);
+       SysTryReturnResult(NID_SHELL, err == NOTIFICATION_ERROR_NONE, E_OPERATION_FAILED, "Failed to RemoveNotification with reason (%d).", err);
+       return r;
 }
 
-int
-_NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
+result
+_NotificationManagerImpl::RemoveNotificationByAppId(const Tizen::App::AppId& appId, bool onGoing)
 {
-       bool b = _PackageManagerImpl::IsAppInstalled(appId);
-
-       SysTryReturn(NID_APP, b == true, -1, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The application %ls is not installed",
-                               appId.GetPointer());
-
-       char buffer[256];
-       int count = -1;
-
-       memset(buffer, 0, 256);
+       result r = E_SUCCESS;
+       notification_error_e err = NOTIFICATION_ERROR_NONE;
+       bool isValidAppId = _Aul::IsInstalled(appId);
+       SysTryReturnResult(NID_SHELL, isValidAppId == true, E_APP_NOT_INSTALLED, "The application %ls is not installed", appId.GetPointer());
 
-       snprintf(buffer, 256, "%ls", appId.GetPointer());
+       std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+       const notification_type_e notiType = onGoing ? NOTIFICATION_TYPE_ONGOING : NOTIFICATION_TYPE_NOTI;
+       const int notiPrivateId = onGoing ? __notifyPrivateIdForOngoing : __notifyPrivateId;
 
-       notification_get_badge(buffer, NOTIFICATION_GROUP_ID_NONE, &count);
+       if (notiPrivateId != -1)
+       {
+               notification_h notiHandle = notification_load(pAppId.get(), notiPrivateId);
+               if (notiHandle)
+               {
+                       err = notification_delete(notiHandle);
+                       SysLog(NID_SHELL, "Notification deleted.");
+               }
+               else
+               {
+                       SysLog(NID_SHELL, "Notification already deleted.");
+               }
+               err = notification_free(notiHandle);
+       }
+       else
+       {
+               err = notification_delete_all_by_type(pAppId.get(), notiType);
+               SysLog(NID_SHELL, "All [%s] notifications deleted.", onGoing ? "Ongoing" : "Normal");
+       }
 
-       return count;
+       SysTryReturnResult(NID_SHELL, err == NOTIFICATION_ERROR_NONE, E_OPERATION_FAILED, "Failed to RemoveNotificationByAppId with reason (%d).", err);
+       return r;
 }
 
-
 result
-_NotificationManagerImpl::NotifyByAppId(const AppId& appId, int badgeNumber) const
+_NotificationManagerImpl::RemoveBadge(const char* pkgName) const
 {
-       SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
+       bool badgeExist = false;
+       badge_error_e badgeError = badge_is_existing(pkgName, &badgeExist);
+       SysTryLog(NID_SHELL, badgeError == BADGE_ERROR_NONE, "badge_is_existing failed(%d).", badgeError);
 
-       String messageText = String(L"");
-       String appMessage = String(L"");
-       return NotifyImpl(appId, messageText, badgeNumber, appMessage);
-}
-
-result
-_NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText) const
-{
-       SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
+       if (badgeExist)
+       {
+               badgeError = badge_remove(pkgName);
+               SysTryReturnResult(NID_SHELL, badgeError == BADGE_ERROR_NONE, E_OPERATION_FAILED, "badge_remove failed(%d).", badgeError);
+       }
 
-       return NotifyImpl(appId, messageText, -1, String(L""));
+       SysLog(NID_SHELL, "Badge is removed.");
+       return E_SUCCESS;
 }
 
 result
-_NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText, int badgeNumber) const
+_NotificationManagerImpl::SetBadgeCount(const char* pkgName, int badgeCount) const
 {
-       SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
-       SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
+       bool badgeExist;
+       badge_error_e badgeError = badge_is_existing(pkgName, &badgeExist);
+       SysTryLog(NID_SHELL, badgeError == BADGE_ERROR_NONE, "badge_is_existing failed(%d).", badgeError);
 
-       return NotifyImpl(appId, messageText, badgeNumber, String(L""));
-}
+       if (!badgeExist)
+       {
+               badgeError = badge_create(pkgName, pkgName);
+               SysTryReturnResult(NID_SHELL, badgeError == BADGE_ERROR_NONE, E_OPERATION_FAILED, "badge_create failed(%d).", badgeError);
+       }
 
-result
-_NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText, const String& launchArguments) const
-{
-       SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
-       SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
-       SysTryReturnResult(NID_APP,
-                                         launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
-                                         "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
+       badgeError = badge_set_count(pkgName, badgeCount);
+       SysTryLog(NID_SHELL, badgeError == BADGE_ERROR_NONE, "badge_set_count failed(%d).", badgeError);
 
-       return NotifyImpl(appId, messageText, -1, launchArguments);
+       SysLog(NID_SHELL, "Badge count is %d.", badgeCount);
+       return E_SUCCESS;
 }
 
-result
-_NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText, int badgeNumber,
-                                                                                const String& launchArguments) const
+int
+_NotificationManagerImpl::GetBadgeCount(const char* pkgName) const
 {
-       SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
-       SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
-       SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
-       SysTryReturnResult(NID_APP,
-                                         launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
-                                         "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
+       unsigned int count = 0;
 
-       return NotifyImpl(appId, messageText, badgeNumber, launchArguments);
+       badge_error_e badgeError = badge_get_count(pkgName, &count);
+       if (badgeError == BADGE_ERROR_NONE)
+       {
+               SysLog(NID_SHELL, "badge_get_count(%d)", count);
+               return count;
+       }
+       else
+       {
+               SysLog(NID_SHELL, "badge_get_count failed(%d).", badgeError);
+               return -1;
+       }
 }
 
 result
-_NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) const
+_NotificationManagerImpl::AddBadgeEventListener(IBadgeEventListener& listener)
 {
-       SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
-
-       return OngoingImpl(messageText, String(L""));
-}
+       SysTryReturnResult(NID_SHELL, !__badgeEventListenerList.Contains(&listener), E_OBJ_ALREADY_EXIST, "The listener is already added.");
+       SysLog(NID_SHELL, "AddBadgeEventListener (%x)", &listener);
 
-result
-_NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments) const
-{
-       SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
-       SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
-       SysTryReturnResult(NID_APP,
-                                         launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
-                                         "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
+       result r = _BadgeManagerImpl::GetInstance()->AddPrimaryBadgeEventListener(*this);
+       SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to AddPrimaryBadgeEventListener with reason (%s)", GetErrorMessage(r) );
 
-       return OngoingImpl(messageText, launchArguments);
+       return __badgeEventListenerList.Add(&listener);
 }
 
 result
-_NotificationManagerImpl::NotifyOngoingActivityByAppId(const AppId& appId, const String& messageText) const
+_NotificationManagerImpl::RemoveBadgeEventListener(IBadgeEventListener& listener)
 {
-       SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
+       SysLog(NID_SHELL, "RemoveBadgeEventListener (%x)", &listener);
 
-       return OngoingImpl(appId, messageText, String(L""));
-}
-
-result
-_NotificationManagerImpl::NotifyOngoingActivityByAppId(const AppId& appId, const String& messageText,
-                                                                                                               const String& launchArguments) const
-{
-       SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
-       SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
-       SysTryReturnResult(NID_APP,
-                                         launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
-                                         "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
+       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 OngoingImpl(appId, messageText, launchArguments);
+       return _BadgeManagerImpl::GetInstance()->RemovePrimaryBadgeEventListener(*this);
 }
 
-result
-_NotificationManagerImpl::RemoveOngoingActivityNotification(void)
+int
+_NotificationManagerImpl::GetLastNotificationId(void) const
 {
-       result r = E_SUCCESS;
-
-       notification_error_e err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_ONGOING);
-       switch (err)
-       {
-       case NOTIFICATION_ERROR_NONE:
-               r = E_SUCCESS;
-               break;
-
-       case NOTIFICATION_ERROR_INVALID_DATA:
-               r = E_INVALID_ARG;
-               break;
-
-       default:
-               r = E_OPERATION_FAILED;
-               break;
-       }
-
-       return r;
+       return __lastNotifyPrivateId;
 }
 
-result
-_NotificationManagerImpl::RemoveOngoingActivityNotificationByAppId(const AppId& appId)
+const Tizen::Base::String&
+_NotificationManagerImpl::GetLastAppId(void) const
 {
-       return __pNotificationManager->RemoveNotification(appId, true);
+       return __lastAppId;
 }
 
-result
-_NotificationManagerImpl::RemoveNotification(void)
+void
+_NotificationManagerImpl::OnBadgeUpdated(const Tizen::App::AppId& appId, int badgeNumber)
 {
-       result r = E_SUCCESS;
+       std::unique_ptr<IEnumeratorT<Tizen::Shell::IBadgeEventListener* > > pEnum(__badgeEventListenerList.GetEnumeratorN());
+       SysTryReturnVoidResult(NID_SHELL, pEnum.get(), E_OUT_OF_MEMORY, "Failed to GetEnumeratorN()!");
 
-       notification_error_e err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
-       switch (err)
+       IBadgeEventListener* pListener;
+       while (pEnum->MoveNext() == E_SUCCESS)
        {
-       case NOTIFICATION_ERROR_NONE:
-               r = E_SUCCESS;
-               break;
-
-       case NOTIFICATION_ERROR_INVALID_DATA:
-               r = E_INVALID_ARG;
-               break;
-
-       default:
-               r = E_OPERATION_FAILED;
-               break;
+               pListener = null;
+               pEnum->GetCurrent(pListener);
+               if( !pListener)
+               {
+                       SysLog(NID_SHELL, "pListener is null!");
+                       continue;
+               }
+               pListener->OnBadgeUpdated(appId, badgeNumber);
        }
-
-       return r;
-}
-
-result
-_NotificationManagerImpl::RemoveNotificationByAppId(const AppId& appId)
-{
-       return __pNotificationManager->RemoveNotification(appId,false);
 }
 
-};
-};    // Tizen::Shell
+} }    // Tizen::Shell