eventsui/eventsengine/inc/evtmgmtuiengine.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Engine class for Events Management UI.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef EVTMGMTUIENGINE_H
       
    20 #define EVTMGMTUIENGINE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "evtstoragedbobserver.h"
       
    24 #include "evtmgmtuilbtobserver.h"
       
    25 #include "evtdefs.h"
       
    26 #include "evtbasiceventinfo.h"
       
    27 #include "evtevent.h"
       
    28 
       
    29 // forward declarations go here:
       
    30 class CEvtEventManager;
       
    31 class CEvtEvent;
       
    32 class CEvtMgmtUiLbtAdapter;
       
    33 typedef TUint32 TEvtEventAttributeMask;
       
    34 
       
    35 class MEvtMgmtUiEngineObserver
       
    36     {
       
    37 public:
       
    38     /**
       
    39      * It will be used to notify observer that event operation
       
    40      * has been completed
       
    41      * @param aTriggerId trigger id of newly created trigger
       
    42      * @param aErrorCode It will contain the status of the operation
       
    43      *                KErrNone if successful otherwise error status code          
       
    44      */
       
    45     virtual void NotifyEventChangeL(TInt aErrorCode, TInt aState ) = 0;
       
    46     
       
    47     /**
       
    48      * It will be used to notify observer that database
       
    49      * has been completed
       
    50      */
       
    51     virtual void NotifyModelChangeL() = 0;
       
    52     };
       
    53 
       
    54 
       
    55 /**
       
    56  *  @class CEvtMgmtUiEngine
       
    57  *  Class that represents the engine for evtmgmtui application
       
    58  *  
       
    59  *  It  is used to create, update, delete, retrive events.
       
    60  *  It is also used to change state of the event.
       
    61  *
       
    62  *  @since Symbian v9.1
       
    63  */
       
    64 class CEvtMgmtUiEngine : public CBase,
       
    65                          public MEvtMgmtUiLbtObserver,
       
    66                          public MEvtStorageDbObserver
       
    67     {
       
    68     public:
       
    69         /**
       
    70          * Enumeration to Filter based on status.
       
    71          */
       
    72         enum TEvtEventStatusFilter
       
    73             {
       
    74             /**
       
    75              * To retrive active events
       
    76              */
       
    77             EEvtFilterActive                               = 0,
       
    78             
       
    79             /**
       
    80              * To retrive draft events
       
    81              */
       
    82             EEvtFilterDraft                                = 1,
       
    83             
       
    84             /**
       
    85              * To retrive completed events
       
    86              */
       
    87             EEvtFilterCompleted                            = 2,
       
    88             
       
    89             /**
       
    90              * To retrieve all events
       
    91              */
       
    92             EEvtFilterAll                                  = 3
       
    93             };
       
    94 
       
    95         /**
       
    96          * Enumeration to identify the modified attributes for an event
       
    97          */
       
    98         enum TEvtEventAttribute
       
    99             {
       
   100             EEvtEventAttributeSubject = 1,
       
   101             EEvtEventAttributePlace = 2,
       
   102             EEvtEventAttributeRadius = 16,
       
   103             EEvtEventAttributeRepeat = 32,
       
   104             EEvtEventAttributeDesc = 64,
       
   105             EEvtEventAttributeTone = 128,
       
   106             EEvtEventAttributeAudioLoop = 256,
       
   107             EEvtEventAttributeStatus = 512
       
   108             };
       
   109     public: // Constructor and destructor  
       
   110         /**
       
   111          * Static Two phase constructor
       
   112          */
       
   113         IMPORT_C static CEvtMgmtUiEngine* NewL();
       
   114         /**
       
   115          * Static Two phase constructor
       
   116          */
       
   117         IMPORT_C static CEvtMgmtUiEngine* NewLC();
       
   118     
       
   119         /**
       
   120          * Virtual destructor
       
   121          */
       
   122          virtual ~CEvtMgmtUiEngine();
       
   123      
       
   124     public://new functions
       
   125         
       
   126         /**
       
   127           * Set observer to notify engine operation is completed.
       
   128           *
       
   129           * @since S60 v5.0    
       
   130           * @paramp[in] aObserver - Observer which wants to get notifications.
       
   131           */
       
   132         IMPORT_C void SetObserver(MEvtMgmtUiEngineObserver* aObserver);
       
   133         
       
   134         /**
       
   135           * Remove observer to notify engine operation is completed.
       
   136           *
       
   137           * @since S60 v5.0    
       
   138           * @paramp[in] aObserver - Observer which wants to get notifications.
       
   139           */    
       
   140         IMPORT_C void RemoveObserver(MEvtMgmtUiEngineObserver* aObserver);
       
   141         
       
   142         /**
       
   143          * returns event object
       
   144          *
       
   145          * @since S60 v5.0    
       
   146          * 
       
   147          * @param[in] aId - event id of the event to be retrieved. 
       
   148          * @ret event object 
       
   149          */
       
   150         IMPORT_C CEvtEvent* EventL( TEvtEventId aId );
       
   151               
       
   152         /**
       
   153           * Updates model
       
   154           *
       
   155           * @since S60 v5.0 
       
   156           * 
       
   157           * TODO: should be removed
       
   158           */
       
   159         IMPORT_C void UpdateModelL( RPointerArray<CEvtBasicEventInfo>& aEventsArray,
       
   160                                         TEvtEventStatusFilter  aEventStatusFilter );
       
   161         
       
   162          /**
       
   163           * It will add an event to database
       
   164           * @since S60 v5.0    
       
   165           */
       
   166          IMPORT_C void AddEventL( CEvtEvent& aEvtEvent );
       
   167          
       
   168          /**
       
   169            * It will modify event to database
       
   170            * @since S60 v5.0    
       
   171            */
       
   172          IMPORT_C void ModifyEventL( CEvtEvent& aEvtEvent, 
       
   173                              TEvtEventAttributeMask aEventAttributeMask );
       
   174           
       
   175          /**
       
   176            * It will delete the list of Events from the database.
       
   177            * @param[in] aId id of event to be deleted
       
   178            * @since S60 v5.0    
       
   179            */
       
   180          IMPORT_C void DeleteEventL(  TEvtEventId aId = -1 );
       
   181          
       
   182          /**
       
   183           * It will delete event from database
       
   184           * @param[in] aEvtIdArray aEventArray Reference to the Events Id array that  
       
   185           *                          are to be removed form the database.  
       
   186           * @since S60 v5.0    
       
   187           */
       
   188          IMPORT_C void DeleteEventsL(  const RArray<TEvtEventId>* aEvtIdArray );
       
   189          
       
   190          /*
       
   191           * Retrieve location details
       
   192           */
       
   193          IMPORT_C void RetrieveLocationL( TEvtEventId aEventId, TCoordinate& aCoordinate );
       
   194          
       
   195          /**
       
   196            * It will set state of the event.   
       
   197            * @param[in] aId id of event to be updated
       
   198            * @param aEvtStatus status of the event
       
   199            * @since S60 v5.0    
       
   200            */
       
   201          IMPORT_C void SetEventStateL( TEvtEventStatus aEvtStatus, TEvtEventId aId = -1 );
       
   202          
       
   203          /**
       
   204           * It will set state of the events.   
       
   205           * @param[in] aEvtIdArray idlist of events to be updated
       
   206           * @param aEvtStatus status of the event
       
   207           * @since S60 v5.0    
       
   208           */
       
   209          IMPORT_C void SetEventsStateL( TEvtEventStatus aEvtStatus, 
       
   210                      const RArray<TEvtEventId>* aEvtIdArray );
       
   211     
       
   212          /**
       
   213           * Synchronizes the LBT and EvtStorage Db.     
       
   214           * @since S60 v5.0    
       
   215           */
       
   216          IMPORT_C void SyncDbsL();     
       
   217          
       
   218          /**
       
   219           * Calculates the Accuracy of Fired Trigger.     
       
   220           * @since S60 v5.0    
       
   221           */
       
   222          IMPORT_C TEvtFireAccuracy CalculateFiredAccuracyL( 
       
   223                                                 const TEvtEventId aEventId );
       
   224                                                 
       
   225          /**
       
   226           * Handle Fired Trigger state.    
       
   227           * Trigger State should be completed if fired Event is not repetitive. 
       
   228           * @since S60 v5.0    
       
   229           */
       
   230          IMPORT_C void HandleFiredTriggerStateL( 
       
   231                                                 const TEvtEventId aEventId );
       
   232          /**
       
   233           * Cancels all the outstanding lbt request.    
       
   234           * @since S60 v5.0    
       
   235           */
       
   236          IMPORT_C void CancelRequest();
       
   237           
       
   238     public: //Derived
       
   239         /**
       
   240          * Derived from MEvtMgmtUiLbtObserver
       
   241          */
       
   242         void NotifyTriggerChangeL( const TLbtTriggerId &  /*aTriggerId*/,
       
   243                                         TLbtTriggerChangeType aType );
       
   244         /**
       
   245          * Derived from MEvtMgmtUiLbtObserver
       
   246          */
       
   247         void NotifyLbtChangeL(TLbtTriggerId &  aTriggerId, TInt aState );
       
   248         
       
   249         /**
       
   250         * Derived from MEvtMgmtUiLbtObserver
       
   251         */
       
   252         void NotifyLbtError(TInt aErrorCode, TInt aState );
       
   253         /**
       
   254         * Derived from MEvtStorageDbObserver
       
   255         */
       
   256         void HandleStorageDbChangedL();
       
   257     
       
   258     private:
       
   259     // constructor and the Symbian second-phase constructor
       
   260     
       
   261         CEvtMgmtUiEngine();
       
   262     
       
   263         void ConstructL();
       
   264        
       
   265     private: // data
       
   266          
       
   267         /**
       
   268         * event manager
       
   269         * Owns
       
   270         */
       
   271         CEvtEventManager*       iEventManager; 
       
   272        
       
   273         /**
       
   274         * event 
       
   275         * Owns
       
   276         */
       
   277         CEvtMgmtUiLbtAdapter*   iLbtAdapter;
       
   278         
       
   279         /*
       
   280          * Observer to notify engine operation is completed.
       
   281          * Does not own
       
   282          */
       
   283         RPointerArray< MEvtMgmtUiEngineObserver > iObserverArray;
       
   284         
       
   285         /*
       
   286          * Temporary Event to hold till the Event is added/Updated to lbt.
       
   287          * Does not own
       
   288          */
       
   289         CEvtEvent* iEvent;
       
   290         
       
   291         /*
       
   292          * Temporary array to hold idlist till the Events are deleted/status changed to lbt.
       
   293          * Does not own
       
   294          */
       
   295         const RArray<TEvtEventId>* iEvtIdArray;
       
   296         
       
   297         /*
       
   298          * Temporary variable to hold state till the Events status changed to lbt.
       
   299          * 
       
   300          */
       
   301         TEvtEventStatus iEvtStatus;
       
   302 
       
   303     };
       
   304 
       
   305 #endif // C_EVTMGMTUIMODEL_H