From e892f8d3b535929ed185c1d91f286b01fc094fb8 Mon Sep 17 00:00:00 2001 From: "kyeongwoo.lee" Date: Wed, 5 Jun 2013 19:52:06 +0900 Subject: [PATCH] implementation for notification light Change-Id: I580d071f219ddbd06a869c78014e344feb8e500d --- inc/FShellNotificationRequest.h | 32 ++++++++++++++ src/core/CMakeLists.txt | 2 + src/core/FShellNotificationRequest.cpp | 18 ++++++++ src/core/FShell_NotificationManagerImpl.cpp | 30 +++++++++++++ src/core/FShell_NotificationRequestImpl.cpp | 66 +++++++++++++++++++++++++++++ src/inc/FShell_NotificationManagerImpl.h | 2 + src/inc/FShell_NotificationRequestImpl.h | 51 ++++++++++++++++++++++ 7 files changed, 201 insertions(+) diff --git a/inc/FShellNotificationRequest.h b/inc/FShellNotificationRequest.h index 1142bbb..16b5f83 100644 --- a/inc/FShellNotificationRequest.h +++ b/inc/FShellNotificationRequest.h @@ -27,6 +27,11 @@ #include #include +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; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a41de92..3802b83 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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" ) diff --git a/src/core/FShellNotificationRequest.cpp b/src/core/FShellNotificationRequest.cpp index 63e435a..a1b0851 100644 --- a/src/core/FShellNotificationRequest.cpp +++ b/src/core/FShellNotificationRequest.cpp @@ -21,11 +21,13 @@ #include #include +#include #include #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 { diff --git a/src/core/FShell_NotificationManagerImpl.cpp b/src/core/FShell_NotificationManagerImpl.cpp index d26eee5..653844d 100644 --- a/src/core/FShell_NotificationManagerImpl.cpp +++ b/src/core/FShell_NotificationManagerImpl.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -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 diff --git a/src/core/FShell_NotificationRequestImpl.cpp b/src/core/FShell_NotificationRequestImpl.cpp index 9d3f4d3..5beaaee 100644 --- a/src/core/FShell_NotificationRequestImpl.cpp +++ b/src/core/FShell_NotificationRequestImpl.cpp @@ -23,12 +23,14 @@ #include #include #include +#include #include #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(__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 { diff --git a/src/inc/FShell_NotificationManagerImpl.h b/src/inc/FShell_NotificationManagerImpl.h index fc4bac6..badadc2 100644 --- a/src/inc/FShell_NotificationManagerImpl.h +++ b/src/inc/FShell_NotificationManagerImpl.h @@ -507,6 +507,8 @@ private: int __lastNotifyPrivateId; Tizen::Base::String __lastAppId; Tizen::Base::Collection::LinkedListT __badgeEventListenerList; + bool __lightActivated; + }; //_NotificationManagerImpl diff --git a/src/inc/FShell_NotificationRequestImpl.h b/src/inc/FShell_NotificationRequestImpl.h index 8208c5f..8657f03 100644 --- a/src/inc/FShell_NotificationRequestImpl.h +++ b/src/inc/FShell_NotificationRequestImpl.h @@ -26,6 +26,11 @@ #include #include +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 -- 2.7.4