bluetoothengine/btnotif/btnotifsrv/inc/btnotificationmanager.h
changeset 19 43824b19ee35
child 31 a0ea99b6fa53
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/btnotificationmanager.h	Fri May 14 16:01:46 2010 +0300
@@ -0,0 +1,145 @@
+/*
+* ============================================================================
+*  Name        : btnotificationmanager.h
+*  Part of     : bluetoothengine / btnotif
+*  Description : Class for managing user notification and query objects, and for serializing access to the notification server.
+*
+*  Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies).
+*  All rights reserved.
+*  This component and the accompanying materials are made available
+*  under the terms of "Eclipse Public License v1.0"
+*  which accompanies this distribution, and is available
+*  at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+*  Initial Contributors:
+*  Nokia Corporation - initial contribution.
+*
+*  Contributors:
+*  Nokia Corporation
+* ============================================================================
+* Template version: 4.2
+*/
+
+#ifndef BTNOTIFICATIONMANAGER_H
+#define BTNOTIFICATIONMANAGER_H
+
+
+#include <e32base.h>
+
+class CBTNotifServer;
+class CBluetoothNotification;
+
+/**
+ *  CBTNotificationManager manages Bt Notifications
+ *  
+ *  @since Symbian^4
+ */
+NONSHARABLE_CLASS( CBTNotificationManager ) : public CBase
+    {
+
+public:
+
+    /**  Enumeration for the priority of the notification. */
+    enum TNotificationPriority
+        {
+        EPriorityLow,
+        EPriorityStandard,
+        EPriorityHigh
+        };
+
+    /**
+     * Two-phased constructor.
+     * @param aServer Pointer to our parent
+     */
+    static CBTNotificationManager* NewL( const CBTNotifServer* aServer );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CBTNotificationManager();
+
+    CBluetoothNotification* GetNotification();
+
+    void ReleaseNotification( CBluetoothNotification* aNotification );
+
+    /**
+     * Add a notification to the queue of notifications scheduled to be 
+     * shown. Notifications are serialized, to avoid overlapping notes.
+     * The queue is managed on priority of each notification.
+     *
+     * @since Symbian^4
+     * @param aNotification The notification to be added.
+     * @param aPriority The priority of the notification. EPriorityHigh means 
+     *                  that the note is put to the front of the queue.
+     *                  EPriorityStandard means that it is appended to the end,
+     *                  and should be used for most notes. EPriorityLow is not 
+     *                  used yet.
+     * @return Error code.
+     */
+    TInt QueueNotification( CBluetoothNotification* aNotification, 
+                TNotificationPriority aPriority = EPriorityStandard );
+
+private:
+
+    CBTNotificationManager( const CBTNotifServer* aServer );
+
+    void ConstructL();
+
+    /**
+     * Process the notification queue and launch the next notification.
+     *
+     * @since Symbian^4
+     */
+    void ProcessNotificationQueueL();
+
+    /**
+     * Process the notification queue and launch the next notification.
+     *
+     * @since Symbian^4
+     */
+    void CleanupUnusedQueueL();
+
+    /**
+     * Create and queue an idle timer if there are no outstanding notifications,
+     * otherwise cancel the idle timer.
+     *
+     * @since Symbian^4
+     */
+    void CheckIdle();
+
+    /**
+     * Callback function for asynchronous processing of 
+     * queued notification requests.
+     *
+     * @since Symbian^4
+     * @param aPtr Pointer to notification manager instance.
+     */
+    static TInt AsyncCallback( TAny* aPtr );
+
+private: // data
+
+    /**
+     * The queue of notifications to be shown to the user.
+     */
+    RPointerArray<CBluetoothNotification> iNotificationQ;
+
+    /**
+     * The queue of spare notifications.
+     */
+    RPointerArray<CBluetoothNotification> iUnusedQ;
+
+    /**
+     * Callback for asynchronous processing.
+     * Own.
+     */
+    CAsyncCallBack* iAsyncCb;
+    
+    /**
+     * Pointer to our parent.
+     * Not own.
+     */
+    const CBTNotifServer* iServer;
+
+    };
+
+#endif // BTNOTIFICATIONMANAGER_H