Modify the argument of notification_load for core-notification module requests. ...
[platform/framework/native/shell.git] / src / core / FShell_NotificationManagerImpl.cpp
index d26eee5..a84a6f4 100644 (file)
@@ -27,6 +27,7 @@
 #include <FBaseSysLog.h>
 #include <FIoFile.h>
 #include <FAppApp.h>
+#include <FGrpColor.h>
 #include <FShellNotificationManager.h>
 #include <FShellNotificationRequest.h>
 #include <FShellIBadgeEventListener.h>
@@ -40,6 +41,7 @@ using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::App;
 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);
@@ -174,6 +176,7 @@ _NotificationManagerImpl::_NotificationManagerImpl(void)
        : __notifyPrivateId(-1)
        , __notifyPrivateIdForOngoing(-1)
        , __lastNotifyPrivateId(-1)
+       , __lightActivated(false)
 {
 }
 
@@ -762,6 +765,10 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                }
        }
 
+       // light
+       Color lightColor;
+       int lightColor32 = 0;
+
        // Set - service
        int retVal = SERVICE_ERROR_NONE;
        int previousDisplaySet = NOTIFICATION_DISPLAY_APP_ALL;
@@ -897,6 +904,29 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing,
                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
@@ -955,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);