phonebookengines_old/contactsmodel/tsrc/CContactViewEventQueue.h
changeset 40 b46a585f6909
equal deleted inserted replaced
37:fd64c38c277d 40:b46a585f6909
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // ContactViewEventQueue Test module
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 #ifndef CContactViewEventQueue_H
       
    20 #define CContactViewEventQueue_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <cntview.h>
       
    24 #include "cfixedqueue.h"
       
    25 
       
    26 
       
    27 // CLASS DECLARATION
       
    28 
       
    29 /**
       
    30  * Contact view event queue class.
       
    31  */ 
       
    32 class CContactViewEventQueue : 
       
    33         public CTimer, public MContactViewObserver
       
    34     {
       
    35     public:
       
    36         /**
       
    37          * Creates a new event queue.
       
    38          * @param aView contact view to listen for events.
       
    39          * @param aMaxQueueSize maximum size of event queue.
       
    40          * @return a new instance of this class.
       
    41          */
       
    42         static CContactViewEventQueue* NewL
       
    43             (CContactViewBase* aView=NULL, TInt aMaxQueueSize=128);
       
    44         ~CContactViewEventQueue();
       
    45 
       
    46         /**
       
    47          * Waits for an event from the database.
       
    48          * @param aTimeOut  max time to wait for an event.
       
    49          * @param aEvent    the received event, undefined if this function returns false.
       
    50          * @return true if an event was received, false if timeout expired first.
       
    51          */
       
    52         TBool ListenForEvent
       
    53             (TTimeIntervalSeconds aTimeOut, 
       
    54             TContactViewEvent& aEvent);
       
    55 
       
    56         /**
       
    57          * Removes all previously arrived events from the queue.
       
    58          */
       
    59         inline void Flush()
       
    60             {
       
    61             iQueue.Reset();
       
    62             }
       
    63 
       
    64 		/**
       
    65 		 * Tells this observer to remove itself from the view
       
    66 		 * if an ItemRemoved event is received
       
    67 		 */
       
    68 		inline void CloseOnItemRemoved(TBool val = ETrue)
       
    69 			{
       
    70 			iCloseOnItemRemoved = val;
       
    71 			}
       
    72 
       
    73     private:  // from CTimer
       
    74         void RunL();
       
    75 
       
    76     private: // From MContactViewObserver.
       
    77 	    void HandleContactViewEvent
       
    78             (const CContactViewBase& aView, const TContactViewEvent& aEvent);
       
    79 
       
    80     private:  // Implementation
       
    81         CContactViewEventQueue();
       
    82         void ConstructL(CContactViewBase* aView, TInt aMaxQueueSize);
       
    83 
       
    84     private:  // Data
       
    85         // Ref: the view to listen for events
       
    86         CContactViewBase* iView;
       
    87         // Own: event queue array
       
    88         CFixedQueue<TContactViewEvent> iQueue;
       
    89 		// Flag for observer response to item removed event
       
    90 		TBool iCloseOnItemRemoved;
       
    91     };
       
    92 
       
    93 #endif
       
    94 
       
    95 // End of File
       
    96