#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
*
* @since 2.1
*/
- virtual ~IBadgeEventListener() {}
+ virtual ~IBadgeEventListener(void) {}
/**
* Called when requested to add a shortcut @n
#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
private:
static LiveboxManager* __pTheInstance;\r
- friend struct std::default_delete< LiveboxManager >;
class _LiveboxManagerImpl* __pLiveboxManagerImpl;
+ friend struct std::default_delete< LiveboxManager >;
};
}} // Tizen::Shell
#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.
//
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
{
class NotificationRequest;
+class IBadgeEventListener;
/**
* The maximum length of a notification message.
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.
#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.
#include <FShellLiveboxManager.h>
#include <FShellLiveboxProviderInfo.h>
+#include <FShellILiveboxAddRequestListener.h>
#include "FShell_LiveboxManagerImpl.h"
using namespace std;
#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;
#include <FShellLiveboxFrame.h>
#include <FShellLiveboxPopup.h>
+#include <FShellILiveboxAddRequestListener.h>
#include <FShellILiveboxProviderFactory.h>
#include <FShellILiveboxPopupProviderFactory.h>
#include <new>
-#include <FShellNotificationManager.h>
-
#include <FBaseSysLog.h>
+#include <FShellNotificationManager.h>
+#include <FShellIBadgeEventListener.h>
#include <FSec_AccessController.h>
#include "FShell_NotificationManagerImpl.h"
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
#include <FBaseSysLog.h>
#include <FShellShortcutManager.h>
+#include <FShellIShortcutRequestListener.h>
#include <FApp_Types.h>
#include <FApp_AppInfo.h>
#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>
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)
_NotificationManagerImpl::~_NotificationManagerImpl(void)
{
+ bool isListeningBadgeEvent = (__badgeEventListenerList.GetCount() > 0)? true : false;
+ if( isListeningBadgeEvent == true )
+ {
+ _BadgeManagerImpl::GetInstance()->RemovePrimaryBadgeEventListener(*this);
+ }
}
result
}
}
+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
#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
{
class _OSP_EXPORT_ _NotificationManagerImpl
: public Tizen::Base::Object
+ , virtual public Tizen::Shell::IBadgeEventListener
{
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);
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_