implementation for notification light
authorkyeongwoo.lee <kyeongwoo.lee@samsung.com>
Wed, 5 Jun 2013 10:52:06 +0000 (19:52 +0900)
committerkyeongwoo.lee <kyeongwoo.lee@samsung.com>
Wed, 5 Jun 2013 10:52:06 +0000 (19:52 +0900)
Change-Id: I580d071f219ddbd06a869c78014e344feb8e500d

inc/FShellNotificationRequest.h
src/core/CMakeLists.txt
src/core/FShellNotificationRequest.cpp
src/core/FShell_NotificationManagerImpl.cpp
src/core/FShell_NotificationRequestImpl.cpp
src/inc/FShell_NotificationManagerImpl.h
src/inc/FShell_NotificationRequestImpl.h

index 1142bbb..16b5f83 100644 (file)
 #include <FBase.h>
 #include <FShellNotificationManager.h>
 
+namespace Tizen { namespace Graphics
+{
+       class Color;
+}}
+
 namespace Tizen { namespace Shell
 {
 
@@ -447,6 +452,33 @@ public:
         */
        result SetBackgroundImageFilePath(const Tizen::Base::String& imagePath);
 
+       /**
+       * Gets the notification light operation properties.
+       *
+       * @since        2.2
+       *
+       * @param[out]   color           The light color
+       * @param[out]   onTime          The milliseconds for which the light is on
+       * @param[out]   offTime The milliseconds for which the light is off
+       */
+       void GetLight(Tizen::Graphics::Color& color, int& onTime, int& offTime) const;
+
+       /**
+       * Sets the notification light operation properties.
+       *
+       * @since       2.2
+       *
+       * @return               An error code
+       * @param[in]    color                   The light color
+       * @param[in]    onTime                  The milliseconds for which the light is on
+       * @param[in]    offTime         The milliseconds for which the light is off
+       * @exception    E_SUCCESS               The method is successful.
+       * @exception    E_INVALID_ARG   The specified input parameter is invalid.
+       * @remarks              This method has effects only on devices with notification light.
+       * @remarks              The light flash continuously toggles on(@c onTime) and off(@c offTime).
+       * @remarks              To turn the light off, set Color(0, 0, 0, 0) to color or set 0 to onTime.
+       */
+       result SetLight(const Tizen::Graphics::Color& color, int onTime, int offTime);
 
 private:
        class _NotificationRequestImpl* __pNotificationRequestImpl;
index a41de92..3802b83 100644 (file)
@@ -10,6 +10,7 @@ INCLUDE_DIRECTORIES(
        /usr/include/osp/base
        /usr/include/osp/io
        /usr/include/osp/security
+       /usr/include/osp/graphics
        
        /usr/include/appfw
        /usr/include/notification
@@ -52,6 +53,7 @@ SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -
 TARGET_LINK_LIBRARIES(${this_target} "-lpthread" )
 TARGET_LINK_LIBRARIES(${this_target} "-lchromium" )
 TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" )
+TARGET_LINK_LIBRARIES(${this_target} "-losp-uifw" )
 TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-application" )
 TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-app-manager" )
 TARGET_LINK_LIBRARIES(${this_target} "-lnotification" )
index 63e435a..a1b0851 100644 (file)
 
 #include <new>
 #include <FBaseSysLog.h>
+#include <FGrpColor.h>
 #include <FShellNotificationRequest.h>
 #include "FShell_NotificationRequestImpl.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Security;
+using namespace Tizen::Graphics;
 
 namespace Tizen { namespace Shell
 {
@@ -77,6 +79,22 @@ NotificationRequest::GetHashCode(void) const
        return __pNotificationRequestImpl->GetHashCode();
 }
 
+void
+NotificationRequest::GetLight(Color& color, int& onTime, int& offTime) const
+{
+       SysAssertf(__pNotificationRequestImpl != null, "Instance is not constructed properly.");
+
+       return __pNotificationRequestImpl->GetLight(color, onTime, offTime);
+}
+
+result
+NotificationRequest::SetLight(const Color& color, int onTime, int offTime)
+{
+       SysAssertf(__pNotificationRequestImpl != null, "Instance is not constructed properly.");
+
+       return __pNotificationRequestImpl->SetLight(color, onTime, offTime);
+}
+
 int
 NotificationRequest::GetBadgeNumber(void) const
 {
index d26eee5..653844d 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
index 9d3f4d3..5beaaee 100644 (file)
 #include <unique_ptr.h>
 #include <FBaseSysLog.h>
 #include <FIoFile.h>
+#include <FGrpColor.h>
 #include <FShellNotificationRequest.h>
 #include "FShell_NotificationRequestImpl.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Io;
+using namespace Tizen::Graphics;
 
 namespace Tizen { namespace Shell
 {
@@ -42,6 +44,8 @@ _NotificationRequestImpl::_NotificationRequestImpl(bool appBinding)
        , __notificationStyle(NOTIFICATION_STYLE_NORMAL)
        , __pTextList(null)
        , __pThumbnailPathList(null)
+       , __lightOnTime(0)
+       , __lightOffTime(0)
 {
 }
 
@@ -61,6 +65,9 @@ _NotificationRequestImpl::_NotificationRequestImpl(const _NotificationRequestImp
        , __pThumbnailPathList(notificationMessage.__pThumbnailPathList)
        , __notificationCountText(notificationMessage.__notificationCountText)
        , __backgroundImagePath(notificationMessage.__backgroundImagePath)
+       , __lightColor(notificationMessage.__lightColor)
+       , __lightOnTime(notificationMessage.__lightOnTime)
+       , __lightOffTime(notificationMessage.__lightOffTime)
 {
 }
 
@@ -89,6 +96,10 @@ _NotificationRequestImpl::operator =(const _NotificationRequestImpl& notificatio
                __pThumbnailPathList = notificationMessage.__pThumbnailPathList;
                __notificationCountText = notificationMessage.__notificationCountText;
                __backgroundImagePath = notificationMessage.__backgroundImagePath;
+
+               __lightColor = notificationMessage.__lightColor;
+               __lightOnTime = notificationMessage.__lightOnTime;
+               __lightOffTime = notificationMessage.__lightOffTime;
        }
        return *this;
 }
@@ -183,6 +194,18 @@ _NotificationRequestImpl::Equals(const Object& rhs) const
        {
                return false;
        }
+       if (__lightColor != pMsgImpl->__lightColor)
+       {
+               return false;
+       }
+       if (__lightOnTime != pMsgImpl->__lightOnTime)
+       {
+               return false;
+       }
+       if (__lightOffTime != pMsgImpl->__lightOffTime)
+       {
+               return false;
+       }
 
        return true;
 }
@@ -205,9 +228,52 @@ _NotificationRequestImpl::GetHashCode(void) const
                ^ reinterpret_cast<int>(__pThumbnailPathList)
                ^ __notificationCountText.GetHashCode()
                ^ __backgroundImagePath.GetHashCode()
+               ^ __lightColor.GetHashCode()
+               ^ Integer(__lightOnTime).GetHashCode()
+               ^ Integer(__lightOffTime).GetHashCode()
                ;
 }
 
+void
+_NotificationRequestImpl::GetLight(Color& color, int& onTime, int& offTime) const
+{
+       color = __lightColor;
+       onTime = __lightOnTime;
+       offTime = __lightOffTime;
+}
+
+Color
+_NotificationRequestImpl::GetColor(void) const
+{
+       return __lightColor;
+}
+
+int
+_NotificationRequestImpl::GetOnTime(void) const
+{
+       return __lightOnTime;
+}
+
+int
+_NotificationRequestImpl::GetOffTime(void) const
+{
+       return __lightOffTime;
+}
+
+result
+_NotificationRequestImpl::SetLight(const Color& color, int onTime, int offTime)
+{
+       SysTryReturnResult(NID_SHELL, onTime >= 0 && offTime >= 0, E_INVALID_ARG, "onTime or offTime are less than 0.");
+
+       __lightColor = color;
+       SysLog(NID_SHELL, "light color is %0X", __lightColor.GetRGB32());
+
+       __lightOnTime = onTime;
+       __lightOffTime = offTime;
+
+       return E_SUCCESS;
+}
+
 int
 _NotificationRequestImpl::GetBadgeNumber(void) const
 {
index fc4bac6..badadc2 100644 (file)
@@ -507,6 +507,8 @@ private:
        int __lastNotifyPrivateId;
        Tizen::Base::String __lastAppId;
        Tizen::Base::Collection::LinkedListT<IBadgeEventListener*> __badgeEventListenerList;
+       bool __lightActivated;
+
 };     //_NotificationManagerImpl
 
 
index 8208c5f..8657f03 100644 (file)
 #include <FAppTypes.h>
 #include <FOspConfig.h>
 
+namespace Tizen { namespace Graphics
+{
+       class Color;
+}}
+
 namespace Tizen { namespace Shell
 {
 
@@ -422,6 +427,33 @@ public:
         */
        result SetBackgroundImageFilePath(const Tizen::Base::String& imagePath);
 
+       /**
+       * Gets the notification light operation properties.
+       *
+       * @since        2.2
+       *
+       * @param[out]   color           The light color
+       * @param[out]   onTime          The milliseconds for which the light is on
+       * @param[out]   offTime The milliseconds for which the light is off
+       */
+       void GetLight(Tizen::Graphics::Color& color, int& onTime, int& offTime) const;
+
+       /**
+       * Sets the notification light operation properties.
+       *
+       * @since       2.2
+       *
+       * @return               An error code
+       * @param[in]    color                   The light color
+       * @param[in]    onTime                  The milliseconds for which the light is on
+       * @param[in]    offTime         The milliseconds for which the light is off
+       * @exception    E_SUCCESS               The method is successful.
+       * @exception    E_INVALID_ARG   The specified input parameter is invalid.
+       * @remarks              This method has effects only on devices with notification light.
+       * @remarks              The light flash continuously toggles on(@c onTime) and off(@c offTime).
+       * @remarks              To turn the light off, set Color(0, 0, 0, 0) to color or set 0 to onTime.
+       */
+       result SetLight(const Tizen::Graphics::Color& color, int onTime, int offTime);
 
        /*
         * Get internal pointer of TextList for internal reference
@@ -433,6 +465,21 @@ public:
         */
        const Tizen::Base::Collection::IList* GetMessageThumbnailFilePathList() const;
 
+       /*
+        * Get internal value for the light(color)
+        */
+       Tizen::Graphics::Color GetColor(void) const;
+
+       /*
+        * Get internal value for the light(onTime)
+        */
+       int GetOnTime(void) const;
+
+       /*
+        * Get internal value for the light(offTime)
+        */
+       int GetOffTime(void) const;
+
        //
        // Gets the implementation.
        //
@@ -468,6 +515,10 @@ private:
        Tizen::Base::Collection::IList* __pThumbnailPathList;
        Tizen::Base::String __notificationCountText;
        Tizen::Base::String __backgroundImagePath;
+       // 2.2
+       Tizen::Graphics::Color __lightColor;
+       int __lightOnTime;
+       int __lightOffTime;
 
 };     //_NotificationRequestImpl