add IBadgeEventListener and setters to NotificaionManager and apply forward declarati...
authorjungmin76.park <jungmin76.park@samsung.com>
Thu, 14 Mar 2013 04:58:12 +0000 (13:58 +0900)
committerjungmin76.park <jungmin76.park@samsung.com>
Thu, 14 Mar 2013 06:09:08 +0000 (15:09 +0900)
Change-Id: I079a5d45cad6737bbf511200e4b68fe61dab9a0d
Signed-off-by: jungmin76.park <jungmin76.park@samsung.com>
13 files changed:
inc/FShell.h
inc/FShellIBadgeEventListener.h
inc/FShellLiveboxManager.h
inc/FShellLiveboxProviderManager.h
inc/FShellNotificationManager.h [changed mode: 0644->0755]
inc/FShellShortcutManager.h
src/FShellLiveboxManager.cpp
src/FShellLiveboxProviderManager.cpp
src/FShell_LiveboxManagerImpl.cpp
src/core/FShellNotificationManager.cpp
src/core/FShellShortcutManager.cpp
src/core/FShell_NotificationManagerImpl.cpp
src/inc/FShell_NotificationManagerImpl.h

index 49b1aaf..b8ac8fb 100644 (file)
 #ifndef _FSHELL_H_
 #define _FSHELL_H_
 
-#include <FShellILiveboxAddRequestListener.h>
-#include <FShellILiveboxPopupProviderFactory.h>
-#include <FShellILiveboxProviderFactory.h>
-#include <FShellLiveboxFrame.h>
-#include <FShellLiveboxManager.h>
-#include <FShellLiveboxPopup.h>
-#include <FShellLiveboxPopupProvider.h>
-#include <FShellLiveboxProvider.h>
-#include <FShellLiveboxProviderInfo.h>
-#include <FShellLiveboxProviderManager.h>
-#include <FShellLiveboxSizeInfo.h>
-#include <FShellLiveboxView.h>
 #include <FShellNotificationManager.h>
 #include <FShellNotificationRequest.h>
+#include <FShellIBadgeEventListener.h>
 #include <FShellQuickPanelFrame.h>
+#include <FShellLiveboxView.h>
+#include <FShellLiveboxManager.h>
+#include <FShellLiveboxProviderInfo.h>
+#include <FShellLiveboxSizeInfo.h>
+#include <FShellLiveboxProvider.h>
+#include <FShellILiveboxProviderFactory.h>
+#include <FShellLiveboxPopupProvider.h>
+#include <FShellILiveboxPopupProviderFactory.h>
+#include <FShellLiveboxProviderManager.h>
+#include <FShellLiveboxFrame.h>
+#include <FShellLiveboxPopup.h>
+#include <FShellILiveboxAddRequestListener.h>
+#include <FShellShortcutManager.h>
+#include <FShellIShortcutRequestListener.h>
+#include <FShellLockManager.h>
 
 /**
  * @namespace  Tizen::Shell
index d1e6a0d..78f5f51 100755 (executable)
@@ -49,7 +49,7 @@ public:
         *
         * @since       2.1
         */
-       virtual ~IBadgeEventListener() {}
+       virtual ~IBadgeEventListener(void) {}
 
        /**
         * Called when requested to add a shortcut @n
index 03bf0a9..84cd6d9 100755 (executable)
 #include <unique_ptr.h>
 #include <FBaseString.h>
 #include <FAppTypes.h>
-#include <FShellILiveboxAddRequestListener.h>
 
 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
 namespace Tizen { namespace Shell
 {
 
 class LiveboxProviderInfo;
+class ILiveboxAddRequestListener;
 
 /**
  * @class              LiveboxManager
@@ -172,8 +172,8 @@ private:
 private:
        
        static LiveboxManager* __pTheInstance;\r
-       friend struct std::default_delete< LiveboxManager >;
        class _LiveboxManagerImpl* __pLiveboxManagerImpl;
+       friend struct std::default_delete< LiveboxManager >;
 };
 
 }} // Tizen::Shell
index 3f6a12c..6d2a3fb 100755 (executable)
 #include <unique_ptr.h>
 #include <FBaseString.h>
 #include <FAppTypes.h>
-#include <FShellILiveboxProviderFactory.h>
-#include <FShellILiveboxPopupProviderFactory.h>
 
 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
 namespace Tizen { namespace Shell
 {
 
+class ILiveboxProviderFactory;
+class ILiveboxPopupProviderFactory;
+
 /**
  * @class              LiveboxProviderManager
  * @brief              Manages all the Livebox providers.
@@ -178,10 +179,14 @@ private:
        //
        result Construct(void);
 
+
+       static void InitSingleton(void);
+       static void DestroySingleton(void);
+
 private:
+       static LiveboxProviderManager* __pTheInstance;
        class _LiveboxProviderManagerImpl* __pLiveboxProviderManagerImpl;
        friend struct std::default_delete< LiveboxProviderManager >;
-
 }; // LiveboxProviderManager
 
 }} // Tizen::Shell
old mode 100644 (file)
new mode 100755 (executable)
index 76ae380..c16b7c8
@@ -40,6 +40,7 @@ namespace Tizen { namespace Shell
 {
 
 class NotificationRequest;
+class IBadgeEventListener;
 
 /**
  * The maximum length of a notification message.
@@ -528,6 +529,38 @@ public:
        result 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);
 
+       /**\r
+     * Adds an IBadgeEventListener event listener to the NotificationManager @n\r
+     * The listener gets notified when a badge number is updated. @n\r
+     *\r
+     * @since            2.1\r
+     *\r
+     * @return         An error code\r
+     * @param[in]      listener                                        The listener to be added.\r
+     * @exception      E_SUCCESS                                       The method is successful.\r
+     * @exception      E_OBJ_ALREADY_EXIST                     The listener is already added.\r
+     * @exception      E_SYSTEM                                        The method cannot proceed due to a severe system error.\r
+     *\r
+     * @see              NotificationManager::Notify()\r
+     * @remarks          Internally Platform does not have the ownership of this pointer, So caller should manage the listener object properly.\r
+     */\r
+    result AddBadgeEventListener(IBadgeEventListener& listener);\r
+\r
+       /**\r
+     * Removes an IBadgeEventListener event listener from the NotificationManager @n\r
+     *\r
+     * @since            2.1\r
+     *\r
+     * @return      An error code\r
+     * @param[in]      listener                        The listener to be removed.\r
+     * @exception      E_SUCCESS           The method is successful.\r
+     * @exception      E_OBJ_NOT_FOUND         The listner is not found.\r
+     * @exception      E_SYSTEM            The method cannot proceed due to a severe system error.\r
+     *\r
+     * @remarks          Internally Platform does not have the ownership of this pointer, So caller should manage the listener object properly.\r
+     */\r
+       result RemoveBadgeEventListener(IBadgeEventListener& listener);
+
 private:
        /**
         * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
index 2dd0ac4..3444a71 100755 (executable)
 #include <FBaseObject.h>
 #include <FBaseString.h>
 #include <FAppTypes.h>
-#include <FShellIShortcutRequestListener.h>
+
 
 namespace Tizen { namespace Shell
 {
 
+class IShortcutRequestListener;
+
 /*
  * @class              ShortcutManager
  * @brief              Helps an application can add its shortcut to the Home app.
index bc1d25a..f24505e 100755 (executable)
@@ -37,6 +37,7 @@
 
 #include <FShellLiveboxManager.h>
 #include <FShellLiveboxProviderInfo.h>
+#include <FShellILiveboxAddRequestListener.h>
 #include "FShell_LiveboxManagerImpl.h"
 
 using namespace std;
index 81a8133..86fb5b4 100644 (file)
 #include <FGraphics.h>
 #include <FApp.h>
 #include <FAppPkgPackageInfo.h>
+#include <FShellLiveboxProviderManager.h>
+#include <FShellLiveboxProviderInfo.h>
+#include <FShellILiveboxProviderFactory.h>
+#include <FShellILiveboxPopupProviderFactory.h>
+
 #include <FApp_Types.h>
 #include <FApp_AppInfo.h>
 #include <FAppPkg_PackageManagerImpl.h>
 #include <FBase_StringConverter.h>
 
-#include <FShellLiveboxProviderManager.h>
-#include <FShellLiveboxProviderInfo.h>
 #include "FShell_LiveboxProviderManagerImpl.h"
 
 using namespace std;
index 8e129ed..c200c13 100644 (file)
@@ -38,6 +38,7 @@
 #include <FShellLiveboxFrame.h>
 #include <FShellLiveboxPopup.h>
 
+#include <FShellILiveboxAddRequestListener.h>
 #include <FShellILiveboxProviderFactory.h>
 #include <FShellILiveboxPopupProviderFactory.h>
 
index 048acd7..d566d07 100644 (file)
@@ -22,9 +22,9 @@
 
 #include <new>
 
-#include <FShellNotificationManager.h>
-
 #include <FBaseSysLog.h>
+#include <FShellNotificationManager.h>
+#include <FShellIBadgeEventListener.h>
 #include <FSec_AccessController.h>
 #include "FShell_NotificationManagerImpl.h"
 
@@ -271,4 +271,16 @@ NotificationManager::NotifyOngoingActivityByAppControl(const Tizen::Base::String
        return __pNotificationManagerImpl->NotifyOngoingActivityByAppControl(operationId, pUriData, pDataType, pExtraData, request);
 }
 
+result
+NotificationManager::AddBadgeEventListener(IBadgeEventListener& listener)
+{
+       return __pNotificationManagerImpl->AddBadgeEventListener(listener);
+}
+
+result
+NotificationManager::RemoveBadgeEventListener(IBadgeEventListener& listener)
+{
+       return __pNotificationManagerImpl->RemoveBadgeEventListener(listener);
+}
+
 } }    // Tizen::Shell
index a740b88..32d7788 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <FBaseSysLog.h>
 #include <FShellShortcutManager.h>
+#include <FShellIShortcutRequestListener.h>
 
 #include <FApp_Types.h>
 #include <FApp_AppInfo.h>
index a420133..73dde17 100644 (file)
 
 #include <FBaseSysLog.h>
 #include <FApp.h>
-//#include <FAppTypes.h>
+
 #include <FShellNotificationManager.h>
 #include <FShellNotificationRequest.h>
+#include <FShellIBadgeEventListener.h>
 
 //#include <FBaseInternalTypes.h>
 #include <FBase_StringConverter.h>
@@ -116,6 +117,79 @@ IsPosted(ui_notification_h handle)
 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_APP, pEnum.get(), E_OUT_OF_MEMORY, "Failed to GetEnumeratorN()!");
+
+       IBadgeEventListener* pListener;
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pListener = null;
+               pEnum->GetCurrent(pListener);
+               if( !pListener)
+               {
+                       SysLog(NID_APP, "pListener is null!");
+                       continue;
+               }
+
+               pListener->OnBadgeUpdated(pkgname, count);
+       }
+}
+
+_BadgeManagerImpl*
+_BadgeManagerImpl::GetInstance(void)
+{
+       static _BadgeManagerImpl* pTheInstance = null;
+       if( pTheInstance == null)
+       {
+               pTheInstance = new (std::nothrow) _BadgeManagerImpl;
+               pTheInstance->Construct();
+       }
+       return pTheInstance;
+}
+
+result
+_BadgeManagerImpl::Construct(void)
+{
+       return E_SUCCESS;
+}
+
+result
+_BadgeManagerImpl::AddPrimaryBadgeEventListener(IBadgeEventListener& primaryListener)
+{
+       if( __primaryBadgeEventListenerList.GetCount() == 0)
+       {
+               int ret = badge_register_changed_cb(BadgeChangedCallback, &__primaryBadgeEventListenerList);
+               SysTryReturnResult(NID_APP, ret == BADGE_ERROR_NONE, E_SYSTEM, "Failed to badge_unregister_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_APP, ret == BADGE_ERROR_NONE, E_SYSTEM, "Failed to badge_unregister_changed_cb, (%d)", ret);
+       }
+       return E_SUCCESS;
+}
+
+
+///////////////////////////////////////////////////////////////////
+// _NotificationManagerImpl
+///////////////////////////////////////////////////////////////////
 _NotificationManagerImpl::_NotificationManagerImpl(void)
        : __notifyPrivitId(-1)
        , __notifyPrivitIdForOngoing(-1)
@@ -124,6 +198,11 @@ _NotificationManagerImpl::_NotificationManagerImpl(void)
 
 _NotificationManagerImpl::~_NotificationManagerImpl(void)
 {
+       bool isListeningBadgeEvent = (__badgeEventListenerList.GetCount() > 0)? true : false;
+       if( isListeningBadgeEvent == true )
+       {
+               _BadgeManagerImpl::GetInstance()->RemovePrimaryBadgeEventListener(*this);
+       }
 }
 
 result
@@ -1007,4 +1086,46 @@ _NotificationManagerImpl::GetBadgeCount(const char* pkgName) const
        }
 }
 
+result
+_NotificationManagerImpl::AddBadgeEventListener(IBadgeEventListener& listener)
+{
+       SysTryReturnResult(NID_APP, !__badgeEventListenerList.Contains(&listener), E_OBJ_ALREADY_EXIST, "The listener is already added.");
+       SysLog(NID_APP, "(%x)", &listener);
+
+       result r = _BadgeManagerImpl::GetInstance()->AddPrimaryBadgeEventListener(*this);
+       SysTryReturnResult(NID_APP, !IsFailed(r), E_SYSTEM, "Failed to AddPrimaryBadgeEventListener with reason (%s)", GetErrorMessage(r) );
+
+       return __badgeEventListenerList.Add(&listener);
+}
+
+result
+_NotificationManagerImpl::RemoveBadgeEventListener(IBadgeEventListener& listener)
+{
+       SysLog(NID_APP, "(%x)", &listener);
+       result r = __badgeEventListenerList.Remove(&listener);
+       SysTryReturn(NID_APP, !IsFailed(r), r, r, "Failed to RemoveBadgeEventListener with reason (%s)", GetErrorMessage(r) );
+
+       return _BadgeManagerImpl::GetInstance()->RemovePrimaryBadgeEventListener(*this);
+}
+
+void
+_NotificationManagerImpl::OnBadgeUpdated(const Tizen::App::AppId& appId, int badgeNumber)
+{
+       std::unique_ptr<IEnumeratorT<Tizen::Shell::IBadgeEventListener* > > pEnum(__badgeEventListenerList.GetEnumeratorN());
+       SysTryReturnVoidResult(NID_APP, pEnum.get(), E_OUT_OF_MEMORY, "Failed to GetEnumeratorN()!");
+
+       IBadgeEventListener* pListener;
+       while (pEnum->MoveNext() == E_SUCCESS)
+       {
+               pListener = null;
+               pEnum->GetCurrent(pListener);
+               if( !pListener)
+               {
+                       SysLog(NID_APP, "pListener is null!");
+                       continue;
+               }
+               pListener->OnBadgeUpdated(appId, badgeNumber);
+       }
+}
+
 } }    // Tizen::Shell
index fd6f922..f2ea3bc 100644 (file)
@@ -23,8 +23,8 @@
 #ifndef _FSHELL_INTERNAL_NOTIFICATION_MANAGER_IMPL_H_
 #define _FSHELL_INTERNAL_NOTIFICATION_MANAGER_IMPL_H_
 
-#include <FBaseObject.h>
 #include <FOspConfig.h>
+#include <FBaseObject.h>
 
 namespace Tizen { namespace Shell
 {
@@ -40,6 +40,7 @@ enum _NotifyType
 
 class _OSP_EXPORT_ _NotificationManagerImpl
        : public Tizen::Base::Object
+       , virtual public Tizen::Shell::IBadgeEventListener
 {
 
 public:
@@ -436,11 +437,45 @@ public:
        result 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);
 
+       /**
+        * Adds an IBadgeEventListener event listener to the NotificationManager @n
+        * The listener gets notified when a badge number is updated. @n
+        *
+        * @since            2.1
+        *
+        * @return              An error code
+        * @param[in]   listener                                        The listener to be added.
+        * @exception   E_SUCCESS                                       The method is successful.
+        * @exception   E_OBJ_ALREADY_EXIST                     The listener is already added.
+        * @exception   E_SYSTEM                                        The method cannot proceed due to a severe system error.
+        *
+        * @see              NotificationManager::Notify()
+        * @remarks          Internally Platform does not have the ownership of this pointer, So caller should manage the listener object properly.
+        */
+       result AddBadgeEventListener(IBadgeEventListener& listener);
+
+       /**
+        * Removes an IBadgeEventListener event listener from the NotificationManager @n
+        *
+        * @since            2.1
+        *
+        * @return      An error code
+        * @param[in]   listener                        The listener to be removed.
+        * @exception   E_SUCCESS           The method is successful.
+        * @exception   E_OBJ_NOT_FOUND         The listner is not found.
+        * @exception   E_SYSTEM            The method cannot proceed due to a severe system error.
+        *
+        * @remarks          Internally Platform does not have the ownership of this pointer, So caller should manage the listener object properly.
+        */
+       result RemoveBadgeEventListener(IBadgeEventListener& listener);
+
+       virtual void OnBadgeUpdated(const Tizen::App::AppId& appId, int badgeNumber);
 
        static const _NotificationManagerImpl* GetInstance(const NotificationManager& notiMgr);
 
        static _NotificationManagerImpl* GetInstance(NotificationManager& notiMgr);
 
+
 private:
        result NotifyMessage(_NotifyType notifyType, bool isOngoing, const NotificationRequest& notifyRequest, const Tizen::App::AppId* pAppId = null,
                                                 const Tizen::Base::String* pOperationId = null, const Tizen::Base::String* pUriData = null, const Tizen::Base::String* pDataType = null, const Tizen::Base::Collection::IMap* pExtraData = null);
@@ -460,8 +495,24 @@ private:
 private:
        int __notifyPrivitId;
        int __notifyPrivitIdForOngoing;
+       Tizen::Base::Collection::LinkedListT<IBadgeEventListener*> __badgeEventListenerList;
 };     //_NotificationManagerImpl
 
+
+class _BadgeManagerImpl
+       : public Tizen::Base::Object
+{
+public:
+       static _BadgeManagerImpl* GetInstance(void);
+       result Construct(void);
+       result AddPrimaryBadgeEventListener(IBadgeEventListener& item);
+       result RemovePrimaryBadgeEventListener(IBadgeEventListener& item);
+
+private:
+       Tizen::Base::Collection::LinkedListT<Tizen::Shell::IBadgeEventListener*> __primaryBadgeEventListenerList;// Each NotificaitonManager is a IBadgeEventListener, and has it's own IBadgeEventListener list again.
+
+};
+
 } } // Tizen::Shell
 
 #endif // _FSHELL_INTERNAL_NOTIFICATION_MANAGER_IMPL_H_