calendarui/controller/inc/calencontroller.h
branchRCL_3
changeset 29 12af337248b1
parent 16 55d60436f00b
child 30 bd7edf625bdd
equal deleted inserted replaced
28:96907930389d 29:12af337248b1
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:   Calendar controller
    14 * Description:  Calendar controller
    15 *
    15 *
    16 */
    16 */
    17 
       
    18 
    17 
    19 
    18 
    20 #ifndef CALENCONTROLLER_H
    19 #ifndef CALENCONTROLLER_H
    21 #define CALENCONTROLLER_H
    20 #define CALENCONTROLLER_H
    22 
    21 
    23 // INCLUDES
    22 // System includes
    24 #include <e32base.h>                    // CAsyncCallBack
    23 #include <e32base.h>// CAsyncCallBack
    25 #include <vwsdef.h>                     // TVwsViewId
    24 #include <vwsdef.h>// TVwsViewId
    26 #include <apadef.h>                     // TApaCommand
    25 #include <apadef.h>// TApaCommand
    27 #include <calencommands.hrh>            // Calendar commands
    26 #include <qglobal.h>// Q_DECL_EXPORT macro
    28 #include <caleninstanceid.h>            // TCalenInstanceId
    27 #include <agendautil.h>
    29 #include <calennotificationhandler.h>   // TCalenNotification
    28 #include <qobject>
    30 #include <calenservices.h>
    29 
    31 class MCalenPreview;
    30 // User includes
    32 #include "calenglobaldata.h"            // TCalenContext
    31 #include "hb_calencommands.hrh"// Calendar commands
       
    32 #include "calennotificationhandler.h"// TCalenNotification
       
    33 #include "calenservices.h"
    33 #include "calenservicesfactory.h"       // MCalenServicesFactory
    34 #include "calenservicesfactory.h"       // MCalenServicesFactory
    34 
    35 
       
    36 
       
    37 #ifdef  CALENCONTROLLER_DLL
       
    38 #define CALENCONTROLLER_EXPORT Q_DECL_EXPORT
       
    39 #else
       
    40 #define CALENCONTROLLER_EXPORT Q_DECL_IMPORT
       
    41 #endif
       
    42 
    35 // FORWARD DECLARATIONS
    43 // FORWARD DECLARATIONS
       
    44 class CalenViewManager;
       
    45 class CalenView;
       
    46 class CalenServicesImpl;
       
    47 class HbMainWindow;
       
    48 class CalenNotifier;
       
    49 class CCalenStateMachine;
       
    50 class MCalenCommandHandler;
    36 class CCalenActionUi;
    51 class CCalenActionUi;
    37 class CCalenNotifier;
    52 class HbWidget;
    38 class CCalenViewManager;
       
    39 class CCalenAlarmManager;
       
    40 class CCalenView;
       
    41 class CAknViewAppUi;
       
    42 class CCalenStateMachine;
       
    43 class CCalenCmdLineLauncher;
       
    44 class CCalenCustomisationManager;
    53 class CCalenCustomisationManager;
    45 class CEikMenuPane;
    54 class CalenContextImpl;                // context implementation
    46 class CCoeControl;
    55 class QString;
    47 class CCalenViewInfo;
    56 class HbMenu;
    48 class CCalenSetting;
       
    49 class CCalenServicesImpl;
       
    50 class MCalenCommandHandler;
       
    51 class TCalenCommand;
       
    52 class CMissedAlarmStore;
       
    53 class CCalenMultipleDbManager;
       
    54 class CCalenInfo;
       
    55 class CCalenAttachmentModel;
       
    56 
    57 
    57 // CLASS DEFINITIONS
    58 // CLASS DEFINITIONS
    58 
    59 
    59 /**
    60 /**
    60  * The controller handles events from the rest of Calendar and delegates
    61  * The controller handles events from the rest of Calendar and delegates
    61  * them to the appropriate place (i.e. the action ui classes).
    62  * them to the appropriate place (i.e. the action ui classes).
    62  */
    63  */
    63 class CCalenController : public CBase, 
    64 class CALENCONTROLLER_EXPORT CCalenController : public QObject, public MCalenServicesFactory
    64                          public MCalenServicesFactory
       
    65     {
    65     {
       
    66 	Q_OBJECT
       
    67 	
    66     public:  // Construction and destruction
    68     public:  // Construction and destruction
    67         /**
    69 		/**
    68          * Symbian 1st phase constructor
    70 		 * C++ constructor
    69          * @param aAppUi A reference to the CAknViewAppUi
    71 		 */
    70          * @return self pointer to CCalenController
    72 		CCalenController();
    71          */
    73 		
    72         IMPORT_C static CCalenController* NewL( CAknViewAppUi& aAppUi );
    74 		/**
    73         
    75 		 * Second phase contruction for controller
    74         /**
    76 		 */
    75          * Constructs CCalenController with existing CAknViewAppUi. If the
    77 		void constructController();
    76          * controller has been previously initialized with the same CAknViewAppUi,
    78 
    77          * the existing instance will be returned.
    79 		/**
    78          * @param aAppUi Reference to CAknViewAppUi
    80 		 * Constructs CCalenController with existing CAknViewAppUi. If the
    79          * @return CCalenController pointer
    81 		 * controller has been previously initialized with the same CAknViewAppUi,
    80          */
    82 		 * the existing instance will be returned.
    81         IMPORT_C static CCalenController* InstanceL();
    83 		 * @param aAppUi Reference to CAknViewAppUi
    82 
    84 		 * @return CCalenController pointer
    83         /**
    85 		 */
    84          * CCalenController is a reference counting singleton. Call Release()
    86 		static CCalenController* InstanceL();
    85          * when you are done with it, it will clean itself when it needs to
    87 
    86          */
    88 		 
    87         IMPORT_C void Release();
    89 		 /**
    88 
    90 		 * Releases all plugins, should only be called when 
       
    91 		 * the application is exiting.
       
    92 		 */
       
    93 		void ReleaseCustomisations();
       
    94 
       
    95 		/**
       
    96 		 * CCalenController is a reference counting singleton. Call Release()
       
    97 		 * when you are done with it, it will clean itself when it needs to
       
    98 		 */
       
    99 		void Release();
       
   100 		
       
   101 		/**
       
   102 		 * destructor
       
   103 		 */
       
   104 		~CCalenController(); 
       
   105 
       
   106 	signals:
       
   107 		void appReady();
       
   108 		
    89     public:  // New functions
   109     public:  // New functions
    90         /**
   110         /**
    91          * Adds the passed command to the command queue. Command are handled
   111          * Adds the passed command to the command queue. Command are handled
    92          * asynchronously in HandleCommandL
   112          * asynchronously in HandleCommandL
    93          * @param aCommand Command that is passed in.
   113          * @param aCommand Command that is passed in.
    94          * @return EFalse if the passed command is not in the issuers command range
   114          * @return EFalse if the passed command is not in the issuers command range
    95          * ETrue otherwise
   115          * ETrue otherwise
    96          */
   116          */
    97         IMPORT_C TBool IssueCommandL( TInt aCommand );
   117         TBool IssueCommandL( TInt aCommand );
    98 
   118          /**
    99         /**
       
   100          * Passes the notification to the calendar notifier. The notification will be
   119          * Passes the notification to the calendar notifier. The notification will be
   101          * broadcast to all observers
   120          * broadcast to all observers
   102          * @param aNotification Notification to be broadcast
   121          * @param aNotification Notification to be broadcast
   103          */
   122          */
   104         IMPORT_C void BroadcastNotification( TCalenNotification aNotification );
   123         void BroadcastNotification( TCalenNotification aNotification );
   105         
   124         
   106         /**
   125         /**
   107          * Register the passed notification handler with the calendar notifier
   126          * Register the passed notification handler with the calendar notifier
   108          * @param aHandler Notification handler
   127          * @param aHandler Notification handler
   109          * @param aNotification Notification that handler wants to be notified
   128          * @param aNotification Notification that handler wants to be notified
   110          */ 
   129          */ 
   111         IMPORT_C void RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   130         void RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   112                                                  TCalenNotification aNotification );
   131                                                  TCalenNotification aNotification );
   113         
   132         
   114         
   133         
   115         /**
   134         /**
   116          * Register the passed notification handler with the calendar notifier
   135          * Register the passed notification handler with the calendar notifier
   117          * @param aHandler Notification handler
   136          * @param aHandler Notification handler
   118          * @param aNotifications Array of Notifications that handler wants to be notified
   137          * @param aNotifications Array of Notifications that handler wants to be notified
   119          */ 
   138          */ 
   120         IMPORT_C void RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   139         void RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   121                                                  RArray<TCalenNotification>& aNotifications );
   140                                                  RArray<TCalenNotification>& aNotifications );
   122         
   141         
   123         /**
   142         /**
   124          * Unregister the passed handler with the notifier
   143          * Unregister the passed handler with the notifier
   125          * @param aHandler Notification handler
   144          * @param aHandler Notification handler
   126          */
   145          */
   127         IMPORT_C void CancelNotifications( MCalenNotificationHandler* aHandler );
   146         void CancelNotifications( MCalenNotificationHandler* aHandler );
   128 
   147         
   129         /**
   148          /**
   130          * Process comamndline parameters
   149          * From MCalenServicesFactory
   131          * @param aCommand Not in use in this case
   150          */
   132          * @param aDocumentName Not in use in this case
   151         MCalenServices* NewServicesL();
   133          * @param aTail Descriptor contains the command
   152         
   134          */
       
   135         IMPORT_C void ProcessCommandParametersL( TApaCommand aCommand,
       
   136                                                  TFileName& aDocumentName,
       
   137                                                  const TDesC8& aTail );
       
   138         /**
       
   139          * Offer the menu pane to Plugins to customisation
       
   140          * @param aMenuPane Where the customisation apply to
       
   141          */
       
   142         IMPORT_C void OfferMenuPaneL( TInt aResourceId, 
       
   143                                       CEikMenuPane* aMenuPane );
       
   144        
       
   145         /**
   153         /**
   146          * Get infobar based on the available area for infobar
   154          * Get infobar based on the available area for infobar
   147          * @param aRect The available area for Infobar
   155          * @param aRect The available area for Infobar
   148          * @return pointer to a Infobar control
   156          * @return pointer to a Infobar control
   149          */
   157          */
   150         IMPORT_C CCoeControl* Infobar( const TRect& aRect  );
   158         HbWidget* Infobar( );
   151 
   159         
   152         /**
   160         /**        
   153          * Get infobar based on the available area for infobar
   161          * Returns info bar text
   154          * @param aRect The available area for Infobar
   162          */
   155          * @return pointer to a Infobar control
   163         QString* InfobarTextL();
   156          */
   164         
   157 		IMPORT_C const TDesC& Infobar();
   165         
   158        
   166         /**
   159         /**
   167          * Offer the menu to Plugins to customisation
   160          * Get preview pane based on the available area
   168          * @param aMenu Where the customisation apply to
   161          * @param aRect The available area for preview pane
   169          */
   162          * @return pointer to a preview pane control
   170         void OfferMenu(HbMenu* aHbMenu);
   163          */
   171         /**
   164         IMPORT_C CCoeControl* PreviewPane(  TRect& aRect );
   172          * returns the interface to the agenda database
   165         
   173          * @return reference to agendainterface
       
   174          */
       
   175         AgendaUtil* agendaInterface();
       
   176         /**
       
   177          * returns the calendar context
       
   178          * @return reference to the calendar context
       
   179          */
       
   180         MCalenContext& context();
       
   181         /**
       
   182          * Launches the requested view 
       
   183          */
       
   184         void handleServiceManagerSlot(int view, const QDateTime& dateTime);
       
   185         /**
       
   186 		 * returns the first view with which calendar has been launched
       
   187 		 * @return view Id
       
   188 		 */
       
   189 		int getFirstView();
       
   190 
       
   191     public:  // public but not exported
       
   192     
   166          /**
   193          /**
   167          * Releases all plugins, should only be called when 
   194           * Get reference to the CCalenNotiffier
   168          * the application is exiting.
   195           */
   169          */
   196         CalenNotifier& Notifier();
   170         IMPORT_C void ReleaseCustomisations();
       
   171         
       
   172         /**
       
   173          * From MCalenServicesFactory
       
   174          */
       
   175         IMPORT_C MCalenServices* NewServicesL();
       
   176         
       
   177         /*
       
   178          * Get custom preview pane to replace the native one.
       
   179          * @param aRect TRect of preview pane area.
       
   180          * @return MCalenPreview* pointer to MCalenPreview class 
       
   181          */
       
   182         IMPORT_C MCalenPreview* CustomPreviewPaneL( TRect& aRect );
       
   183 
       
   184     public:  // public but not exported
       
   185         /**
       
   186          * Get reference to the CCalenNotiffier
       
   187          */
       
   188         CCalenNotifier& Notifier();
       
   189         
   197         
   190         /**
   198         /**
   191          * Get a command handler for a specific command
   199          * Get a command handler for a specific command
   192          * @param aCommand Command to find a command handler for
   200          * @param aCommand Command to find a command handler for
   193          */
   201          */
   194         MCalenCommandHandler* GetCommandHandlerL( TInt aCommand );
   202         MCalenCommandHandler* GetCommandHandlerL( TInt aCommand );       
   195         
   203        
   196         /**
   204         /**
   197          * Request activation of a specific view
   205          * Get viewmanager
   198          * @param aViewId View id
   206          * @return reference to CalenViewManager
   199          */
   207          */
   200         void RequestActivationL( const TVwsViewId& aViewId );
   208         CalenViewManager& ViewManager();
   201         
   209         
       
   210         /**
       
   211          * Get MainWindow
       
   212          * @return reference to HbMainWindow
       
   213          */
       
   214         HbMainWindow& MainWindow();
       
   215         
       
   216         /**
       
   217          * Get services
       
   218          * @return reference to controller's services object
       
   219          */
       
   220         MCalenServices& Services();
   202         /**
   221         /**
   203          * Get customisationmanager
   222          * Get customisationmanager
   204          * @return reference to CCalenCustomisationManager
   223          * @return reference to CCalenCustomisationManager
   205          */
   224          */
   206         CCalenCustomisationManager& CustomisationManager();
   225         CCalenCustomisationManager& CustomisationManager();
   207         
   226         
   208         /**
   227 	    /**
   209          * Get viewmanager
   228          * Filters the events eg. Locale/language change events
   210          * @return reference to CCalenViewManager
   229          * @param event
   211          */
   230          */
   212         CCalenViewManager& ViewManager();
   231         bool eventFilter(QObject *object, QEvent *event);
   213         
   232         
   214         /**
   233         /**
   215          * Get services
   234          * Emits appReady signal.
   216          * @return reference to controller's services object
   235          */
   217          */
   236         void emitAppReady();
   218         MCalenServices& Services();
       
   219         
       
   220         /**
       
   221          * Checks to see if the system time was changed while Calendar was
       
   222          * not running, potentially causing alarms to be missed
       
   223          */
       
   224         void HandleSystemTimeChangeL();
       
   225         
       
   226         /**
       
   227          * Check for faster app flag 
       
   228          */
       
   229         TBool IsFasterAppFlagEnabled();
       
   230         
       
   231         /**
       
   232          * Set faster app flag
       
   233          */
       
   234         void SetFasterAppFlag( TBool aFlag );
       
   235         
       
   236         /**
       
   237          * Get Missed alarm store
       
   238          * @return reference to Missed alarm store
       
   239          */
       
   240         CMissedAlarmStore* MissedAlarmStore();
       
   241 		
       
   242 		/**
       
   243 		 * Get missed alarms list
       
   244 		 * @return list of missed alarms
       
   245 		 */
       
   246 		void GetMissedAlarmsList(RArray<TCalenInstanceId>& aMissedAlarmList);
       
   247 
       
   248 		/**
       
   249 		 * returns a reference to the calendar settings
       
   250 		 */
       
   251 		CCalenSetting& Settings();
       
   252 		
       
   253         /**
       
   254          * Get calendar icon of specific type
       
   255          * @return CGulIcon*
       
   256          */
       
   257 		CGulIcon* GetIconL(MCalenServices::TCalenIcons aIndex, const TInt aViewId = 0 ); 
       
   258 
       
   259         /* Get multipledb manager
       
   260         * @return reference to CCalenMultipleDbManager
       
   261         */
       
   262         CCalenMultipleDbManager& MultipleDbManager();
       
   263         
       
   264         /*
       
   265          * Get all active collection id 
       
   266          * @param aCollectionIds array for collection on return
       
   267          * @return void
       
   268          */
       
   269         void GetActiveCollectionidsL(RArray<TInt>& aCollectionIds);
       
   270         
       
   271         /*
       
   272          * Form calendar name based dbid for eg:for 
       
   273          * c:Calendar append dbid 1 as c:Calendar1
       
   274          * @return HBufC* calendar name ownership return to caller.
       
   275          * @param TInt aDbId db id for which calendar name should be formed.
       
   276          */
       
   277         HBufC* GetCalendarNameFromDbIdL(const TInt aDbId);
       
   278 
       
   279        
       
   280         /**
       
   281          * Get State Machine
       
   282          * @return reference to CCalenStateMachine
       
   283          */
       
   284         CCalenStateMachine& StateMachine();
       
   285         
       
   286         /**
       
   287          * Get action ui
       
   288          * 
       
   289          * @return reference to CCalenActionUi
       
   290          */
       
   291         CCalenAttachmentModel& AttachmentData();
       
   292 
       
   293 		 /**
       
   294          * Function to tell whether editor is active or not
       
   295          * @return ETrue if editor is active else EFalse
       
   296          */
       
   297         TBool IsEditorActive();
       
   298 
       
   299         /**
       
   300          * @brief adds a new calendar info to the calendar file
       
   301          * 
       
   302          * @param aCalendarInfo meatadata to be set to calendar file
       
   303          */
       
   304         void AddCalendarL(CCalCalendarInfo* aCalendarInfo);
       
   305         
       
   306         /**
       
   307          * @brief removes a calendar
       
   308          * 
       
   309          * @param aCalendarFileName name of the calendar file to be deleted
       
   310          */
       
   311         void RemoveCalendarL(const TDesC& aCalendarFileName);
       
   312 
       
   313         /**
       
   314          * @brief removes all dead calendars from the file system.
       
   315          */
       
   316 		void RemoveDeadCalendarsL();
       
   317 
       
   318         /**
       
   319          * @brief updates a calendar file with new metadata
       
   320          * 
       
   321          * @param aCalendarInfo updated metadata to be set to calendar file
       
   322          */
       
   323         void UpdateCalendarL(CCalCalendarInfo* aCalendarInfo);
       
   324         
       
   325         /**
       
   326          * @brief get all available calendar info
       
   327          * 
       
   328          * @param aCalendarInfoList reference to the calendar info list
       
   329          */
       
   330         void GetAllCalendarInfoL( 
       
   331                     RPointerArray<CCalCalendarInfo>& aCalendarInfoList );
       
   332         
       
   333         /**
       
   334          * @brief sets the flag if the calendar application is launched
       
   335          *  from external application.
       
   336          * 
       
   337          * @param aFlag The flag to be set.
       
   338          */
       
   339         void SetLaunchFromExternalApp( TBool aFlag );
       
   340         
       
   341         /**
       
   342          * @brief Checks whether the calendar application is launched
       
   343          * from external application.
       
   344          * 
       
   345          * @return ETrue If the calendar application is launched from
       
   346          * external application else EFalse.
       
   347          */
       
   348         TBool IsLaunchFromExternalApp();
       
   349         
   237         
   350     private:  // Construction and destruction
   238     private:  // Construction and destruction
   351         /**
   239         
   352          * C++ constructor
   240         /**
   353          */
   241          * Sets the default context for today
   354         CCalenController( CAknViewAppUi& aAppUi );
   242          */        
   355         
   243         void SetDefaultContext();
   356         /**
   244         /**
   357          * Symbian 2nd phase constructor
   245 		* Stores the controller object in TLS
   358 	     */
   246 		*/
   359         void ConstructL();
   247         void checkMultipleCreation();
   360         
   248         
   361         /**
   249 private slots:
   362          * destructor
   250     void raiseWindow();
   363          */
   251    
   364          ~CCalenController(); 
       
   365         
       
   366     private:  // New functions     
       
   367         /**
       
   368          * Leaving form of HandleCommandL
       
   369          * @param aCommand Command to be handled
       
   370          */
       
   371         void HandleCommandL( TCalenCommand& aCommand );
       
   372           
       
   373         /**
       
   374          * Displays an information note if the system time changed 
       
   375          * while Calendar was inactive
       
   376          * @param aResourceId resource id for information note
       
   377          */
       
   378         void ShowSystemChangeInfoNoteL( TInt aResourceId );
       
   379 
       
   380         /**
       
   381          * This function is called when a System time is changed.
       
   382          * only at the startup
       
   383          * @param aThisPtr Specified to be TCallBack()
       
   384          * @return EFalse
       
   385          */
       
   386         static TInt SystemTimeChangeCallback(TAny* aThisPtr);
       
   387 
       
   388     public:   
       
   389         /**
       
   390          * Check system time change at startup 
       
   391          */
       
   392         void CheckSystemTimeAtStartUpL();
       
   393         
       
   394         /**
       
   395          * Returns a reference to the appui
       
   396          */
       
   397         CAknViewAppUi& AppUi();
       
   398         
       
   399         /**
       
   400          * Set the iIsExitOnDialogClose flag status from command line launcher.
       
   401          * @param aFlag , Sets the status 
       
   402          */
       
   403         void SetExitOnDialogFlag( TBool aFlag ); //updateflag
       
   404         
       
   405         /**
       
   406          * Get the iIsExitOnDialogClose flag status from command line launcher.
       
   407          * @return TBool, Status of the flag.
       
   408          */
       
   409         TBool GetExitOnDialogFlag(); // getflagstatus
       
   410         
       
   411     private:  // Data
   252     private:  // Data
   412         CAknViewAppUi&      iAppUi;      // Calendar AppUi
   253         CalenViewManager*  iViewManager;// Activate / deactivate views
       
   254         CalenContextImpl* mContext; 
       
   255         AgendaUtil *mAgendaUtil; // Agenda interface provider 
       
   256         CalenServicesImpl* iServices;   // Services. 
       
   257         CalenNotifier*     iNotifier;   // Broadcasts calendar events
       
   258         CCalenStateMachine* iStateMachine;
   413         CCalenActionUi*     iActionUi;   // Default internal command handling
   259         CCalenActionUi*     iActionUi;   // Default internal command handling
   414         CCalenNotifier*     iNotifier;   // Broadcasts calendar events
       
   415         CCalenViewManager*  iViewManager;// Activate / deactivate views
       
   416         CCalenGlobalData*   iGlobalData; // Calendar Global Data
       
   417         CCalenSetting*      iSetting;    // Calendar settings
       
   418         CCalenServicesImpl* iServices;   // Services.
       
   419         CCalenAlarmManager* iAlarmManager; //Alarm Manager.
       
   420         CCalenMultipleDbManager* iMultipleDbmanager; //Multiple calendar
       
   421         CCalenAttachmentModel* iAttachmentData;
       
   422         TInt iRefCount;  // Reference counting singleton
       
   423 
       
   424         // Handles the cmd line launching of calendar
       
   425         CCalenCmdLineLauncher* iCmdLineLauncher;
       
   426         // Manages any customisation plugins
   260         // Manages any customisation plugins
   427         CCalenCustomisationManager* iCustomisationManager;     
   261         CCalenCustomisationManager* iCustomisationManager;
   428         CCalenStateMachine* iStateMachine;
   262         
   429 
   263         TInt iRefCount;  // Reference counting singleton  
   430         // Start point of the next command range
   264         // Start point of the next command range
   431         // to be assigned to a services instance.
   265         // to be assigned to a services instance.
   432         TInt iNextServicesCommandBase; 
   266         TInt iNextServicesCommandBase;
   433         TInt iResourceFileOffset;
   267         bool iIsFromServiceFrmWrk;
   434         CAsyncCallBack* iSystemTimeChangedMsgDelayer;   
   268 		
   435         TBool iFasterApp;
       
   436         TBool iLaunchFromExternalApp;
       
   437     };
   269     };
   438 
   270 
   439 #endif // CALENCONTROLLER_H
   271 #endif // CALENCONTROLLER_H
   440 
   272 
   441 // End of file
   273 // End of file