calendarui/controller/inc/calencontroller.h
changeset 18 c198609911f9
parent 0 f979ecb2b13e
child 23 fd30d51f876b
equal deleted inserted replaced
0:f979ecb2b13e 18:c198609911f9
     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 // 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 "hb_calencommands.hrh"            // Calendar commands
    30 #include <calenservices.h>
    29 #include "calennotificationhandler.h"   // TCalenNotification
    31 class MCalenPreview;
    30 #include "calenservices.h"
    32 #include "calenglobaldata.h"            // TCalenContext
       
    33 #include "calenservicesfactory.h"       // MCalenServicesFactory
    31 #include "calenservicesfactory.h"       // MCalenServicesFactory
    34 
    32 
       
    33 
       
    34 #ifdef  CALENCONTROLLER_DLL
       
    35 #define CALENCONTROLLER_EXPORT Q_DECL_EXPORT
       
    36 #else
       
    37 #define CALENCONTROLLER_EXPORT Q_DECL_IMPORT
       
    38 #endif
       
    39 
    35 // FORWARD DECLARATIONS
    40 // FORWARD DECLARATIONS
       
    41 class CalenViewManager;
       
    42 class CalenView;
       
    43 class CalenServicesImpl;
       
    44 class HbMainWindow;
       
    45 class CalenNotifier;
       
    46 class CCalenStateMachine;
       
    47 class MCalenCommandHandler;
    36 class CCalenActionUi;
    48 class CCalenActionUi;
    37 class CCalenNotifier;
    49 class HbWidget;
    38 class CCalenViewManager;
       
    39 class CCalenAlarmManager;
       
    40 class CCalenView;
       
    41 class CAknViewAppUi;
       
    42 class CCalenStateMachine;
       
    43 class CCalenCmdLineLauncher;
       
    44 class CCalenCustomisationManager;
    50 class CCalenCustomisationManager;
    45 class CEikMenuPane;
    51 class CalenContextImpl;                // context implementation
    46 class CCoeControl;
    52 class QString;
    47 class CCalenViewInfo;
    53 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 
    54 
    57 // CLASS DEFINITIONS
    55 // CLASS DEFINITIONS
    58 
    56 
    59 /**
    57 /**
    60  * The controller handles events from the rest of Calendar and delegates
    58  * The controller handles events from the rest of Calendar and delegates
    61  * them to the appropriate place (i.e. the action ui classes).
    59  * them to the appropriate place (i.e. the action ui classes).
    62  */
    60  */
    63 class CCalenController : public CBase, 
    61 class CALENCONTROLLER_EXPORT CCalenController : public CBase ,
    64                          public MCalenServicesFactory
    62 							public MCalenServicesFactory
    65     {
    63     {
       
    64   
    66     public:  // Construction and destruction
    65     public:  // Construction and destruction
    67         /**
    66 	/**
    68          * Symbian 1st phase constructor
    67 		 * C++ constructor
    69          * @param aAppUi A reference to the CAknViewAppUi
    68 		 */
    70          * @return self pointer to CCalenController
    69 		CCalenController(bool isFromServiceFrmwrk);
    71          */
    70 		
    72         IMPORT_C static CCalenController* NewL( CAknViewAppUi& aAppUi );
    71 		/**
    73         
    72 			 * Constructs CCalenController with existing CAknViewAppUi. If the
    74         /**
    73 			 * controller has been previously initialized with the same CAknViewAppUi,
    75          * Constructs CCalenController with existing CAknViewAppUi. If the
    74 			 * the existing instance will be returned.
    76          * controller has been previously initialized with the same CAknViewAppUi,
    75 			 * @param aAppUi Reference to CAknViewAppUi
    77          * the existing instance will be returned.
    76 			 * @return CCalenController pointer
    78          * @param aAppUi Reference to CAknViewAppUi
    77 			 */
    79          * @return CCalenController pointer
    78 			static CCalenController* InstanceL();
    80          */
    79 
    81         IMPORT_C static CCalenController* InstanceL();
    80 			/**
    82 
    81 			 * CCalenController is a reference counting singleton. Call Release()
    83         /**
    82 			 * when you are done with it, it will clean itself when it needs to
    84          * CCalenController is a reference counting singleton. Call Release()
    83 			 */
    85          * when you are done with it, it will clean itself when it needs to
    84 			 void Release();
    86          */
    85 		
    87         IMPORT_C void Release();
    86 		/**
    88 
    87 		 * destructor
       
    88 		 */
       
    89 		~CCalenController(); 
       
    90            
    89     public:  // New functions
    91     public:  // New functions
    90         /**
    92         /**
    91          * Adds the passed command to the command queue. Command are handled
    93          * Adds the passed command to the command queue. Command are handled
    92          * asynchronously in HandleCommandL
    94          * asynchronously in HandleCommandL
    93          * @param aCommand Command that is passed in.
    95          * @param aCommand Command that is passed in.
    94          * @return EFalse if the passed command is not in the issuers command range
    96          * @return EFalse if the passed command is not in the issuers command range
    95          * ETrue otherwise
    97          * ETrue otherwise
    96          */
    98          */
    97         IMPORT_C TBool IssueCommandL( TInt aCommand );
    99         TBool IssueCommandL( TInt aCommand );
    98 
   100          /**
    99         /**
       
   100          * Passes the notification to the calendar notifier. The notification will be
   101          * Passes the notification to the calendar notifier. The notification will be
   101          * broadcast to all observers
   102          * broadcast to all observers
   102          * @param aNotification Notification to be broadcast
   103          * @param aNotification Notification to be broadcast
   103          */
   104          */
   104         IMPORT_C void BroadcastNotification( TCalenNotification aNotification );
   105         void BroadcastNotification( TCalenNotification aNotification );
   105         
   106         
   106         /**
   107         /**
   107          * Register the passed notification handler with the calendar notifier
   108          * Register the passed notification handler with the calendar notifier
   108          * @param aHandler Notification handler
   109          * @param aHandler Notification handler
   109          * @param aNotification Notification that handler wants to be notified
   110          * @param aNotification Notification that handler wants to be notified
   110          */ 
   111          */ 
   111         IMPORT_C void RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   112         void RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   112                                                  TCalenNotification aNotification );
   113                                                  TCalenNotification aNotification );
   113         
   114         
   114         
   115         
   115         /**
   116         /**
   116          * Register the passed notification handler with the calendar notifier
   117          * Register the passed notification handler with the calendar notifier
   117          * @param aHandler Notification handler
   118          * @param aHandler Notification handler
   118          * @param aNotifications Array of Notifications that handler wants to be notified
   119          * @param aNotifications Array of Notifications that handler wants to be notified
   119          */ 
   120          */ 
   120         IMPORT_C void RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   121         void RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   121                                                  RArray<TCalenNotification>& aNotifications );
   122                                                  RArray<TCalenNotification>& aNotifications );
   122         
   123         
   123         /**
   124         /**
   124          * Unregister the passed handler with the notifier
   125          * Unregister the passed handler with the notifier
   125          * @param aHandler Notification handler
   126          * @param aHandler Notification handler
   126          */
   127          */
   127         IMPORT_C void CancelNotifications( MCalenNotificationHandler* aHandler );
   128         void CancelNotifications( MCalenNotificationHandler* aHandler );
   128 
   129         
   129         /**
   130          /**
   130          * Process comamndline parameters
   131          * From MCalenServicesFactory
   131          * @param aCommand Not in use in this case
   132          */
   132          * @param aDocumentName Not in use in this case
   133         MCalenServices* NewServicesL();
   133          * @param aTail Descriptor contains the command
   134         
   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         /**
   135         /**
   146          * Get infobar based on the available area for infobar
   136          * Get infobar based on the available area for infobar
   147          * @param aRect The available area for Infobar
   137          * @param aRect The available area for Infobar
   148          * @return pointer to a Infobar control
   138          * @return pointer to a Infobar control
   149          */
   139          */
   150         IMPORT_C CCoeControl* Infobar( const TRect& aRect  );
   140         HbWidget* Infobar( );
   151 
   141         
   152         /**
   142         /**        
   153          * Get infobar based on the available area for infobar
   143          * Returns info bar text
   154          * @param aRect The available area for Infobar
   144          */
   155          * @return pointer to a Infobar control
   145         QString* InfobarTextL();
   156          */
   146         
   157 		IMPORT_C const TDesC& Infobar();
   147         
   158        
   148         /**
   159         /**
   149          * Offer the menu to Plugins to customisation
   160          * Get preview pane based on the available area
   150          * @param aMenu Where the customisation apply to
   161          * @param aRect The available area for preview pane
   151          */
   162          * @return pointer to a preview pane control
   152         void OfferMenu(HbMenu* aHbMenu);
   163          */
   153         /**
   164         IMPORT_C CCoeControl* PreviewPane(  TRect& aRect );
   154          * returns the interface to the agenda database
   165         
   155          * @return reference to agendainterface
       
   156          */
       
   157         AgendaUtil* agendaInterface();
       
   158         /**
       
   159          * returns the calendar context
       
   160          * @return reference to the calendar context
       
   161          */
       
   162         MCalenContext& context();
       
   163         /**
       
   164          * Launches the requested view 
       
   165          */
       
   166         void handleServiceManagerSlot(int view, const QDateTime& dateTime);
       
   167         /**
       
   168 		 * returns the first view with which calendar has been launched
       
   169 		 * @return view Id
       
   170 		 */
       
   171 		int getFirstView();
       
   172 
       
   173     public:  // public but not exported
       
   174     
   166          /**
   175          /**
   167          * Releases all plugins, should only be called when 
   176           * Get reference to the CCalenNotiffier
   168          * the application is exiting.
   177           */
   169          */
   178         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         
   179         
   190         /**
   180         /**
   191          * Get a command handler for a specific command
   181          * Get a command handler for a specific command
   192          * @param aCommand Command to find a command handler for
   182          * @param aCommand Command to find a command handler for
   193          */
   183          */
   194         MCalenCommandHandler* GetCommandHandlerL( TInt aCommand );
   184         MCalenCommandHandler* GetCommandHandlerL( TInt aCommand );       
   195         
   185        
   196         /**
   186         /**
   197          * Request activation of a specific view
   187          * Get viewmanager
   198          * @param aViewId View id
   188          * @return reference to CalenViewManager
   199          */
   189          */
   200         void RequestActivationL( const TVwsViewId& aViewId );
   190         CalenViewManager& ViewManager();
   201         
   191         
       
   192         /**
       
   193          * Get MainWindow
       
   194          * @return reference to HbMainWindow
       
   195          */
       
   196         HbMainWindow& MainWindow();
       
   197         
       
   198         /**
       
   199          * Get services
       
   200          * @return reference to controller's services object
       
   201          */
       
   202         MCalenServices& Services();
   202         /**
   203         /**
   203          * Get customisationmanager
   204          * Get customisationmanager
   204          * @return reference to CCalenCustomisationManager
   205          * @return reference to CCalenCustomisationManager
   205          */
   206          */
   206         CCalenCustomisationManager& CustomisationManager();
   207         CCalenCustomisationManager& CustomisationManager();
   207         
   208         
   208         /**
       
   209          * Get viewmanager
       
   210          * @return reference to CCalenViewManager
       
   211          */
       
   212         CCalenViewManager& ViewManager();
       
   213         
       
   214         /**
       
   215          * Get services
       
   216          * @return reference to controller's services object
       
   217          */
       
   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);
       
   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     private:  // Construction and destruction
   209     private:  // Construction and destruction
   334         /**
   210         
   335          * C++ constructor
   211         /**
   336          */
   212          * Sets the default context for today
   337         CCalenController( CAknViewAppUi& aAppUi );
   213          */        
   338         
   214         void SetDefaultContext();
   339         /**
   215         /**
   340          * Symbian 2nd phase constructor
   216 		* Stores the controller object in TLS
   341 	     */
   217 		*/
   342         void ConstructL();
   218         void checkMultipleCreation();
   343         
   219         
   344         /**
   220    
   345          * destructor
       
   346          */
       
   347          ~CCalenController(); 
       
   348         
       
   349     private:  // New functions     
       
   350         /**
       
   351          * Leaving form of HandleCommandL
       
   352          * @param aCommand Command to be handled
       
   353          */
       
   354         void HandleCommandL( TCalenCommand& aCommand );
       
   355           
       
   356         /**
       
   357          * Displays an information note if the system time changed 
       
   358          * while Calendar was inactive
       
   359          * @param aResourceId resource id for information note
       
   360          */
       
   361         void ShowSystemChangeInfoNoteL( TInt aResourceId );
       
   362 
       
   363         /**
       
   364          * This function is called when a System time is changed.
       
   365          * only at the startup
       
   366          * @param aThisPtr Specified to be TCallBack()
       
   367          * @return EFalse
       
   368          */
       
   369         static TInt SystemTimeChangeCallback(TAny* aThisPtr);
       
   370 
       
   371     public:   
       
   372         /**
       
   373          * Check system time change at startup 
       
   374          */
       
   375         void CheckSystemTimeAtStartUpL();
       
   376         
       
   377         /**
       
   378          * Returns a reference to the appui
       
   379          */
       
   380         CAknViewAppUi& AppUi();
       
   381         
       
   382         /**
       
   383          * Set the iIsExitOnDialogClose flag status from command line launcher.
       
   384          * @param aFlag , Sets the status 
       
   385          */
       
   386         void SetExitOnDialogFlag( TBool aFlag ); //updateflag
       
   387         
       
   388         /**
       
   389          * Get the iIsExitOnDialogClose flag status from command line launcher.
       
   390          * @return TBool, Status of the flag.
       
   391          */
       
   392         TBool GetExitOnDialogFlag(); // getflagstatus
       
   393         
       
   394     private:  // Data
   221     private:  // Data
   395         CAknViewAppUi&      iAppUi;      // Calendar AppUi
   222         CalenViewManager*  iViewManager;// Activate / deactivate views
       
   223         CalenContextImpl* mContext; 
       
   224         AgendaUtil *mAgendaUtil; // Agenda interface provider 
       
   225         CalenServicesImpl* iServices;   // Services. 
       
   226         HbMainWindow* iMainWindow;
       
   227         CalenNotifier*     iNotifier;   // Broadcasts calendar events
       
   228         CCalenStateMachine* iStateMachine;
   396         CCalenActionUi*     iActionUi;   // Default internal command handling
   229         CCalenActionUi*     iActionUi;   // Default internal command handling
   397         CCalenNotifier*     iNotifier;   // Broadcasts calendar events
       
   398         CCalenViewManager*  iViewManager;// Activate / deactivate views
       
   399         CCalenGlobalData*   iGlobalData; // Calendar Global Data
       
   400         CCalenSetting*      iSetting;    // Calendar settings
       
   401         CCalenServicesImpl* iServices;   // Services.
       
   402         CCalenAlarmManager* iAlarmManager; //Alarm Manager.
       
   403         CCalenMultipleDbManager* iMultipleDbmanager; //Multiple calendar
       
   404         CCalenAttachmentModel* iAttachmentData;
       
   405         TInt iRefCount;  // Reference counting singleton
       
   406 
       
   407         // Handles the cmd line launching of calendar
       
   408         CCalenCmdLineLauncher* iCmdLineLauncher;
       
   409         // Manages any customisation plugins
   230         // Manages any customisation plugins
   410         CCalenCustomisationManager* iCustomisationManager;     
   231         CCalenCustomisationManager* iCustomisationManager;
   411         CCalenStateMachine* iStateMachine;
   232         
   412 
   233         TInt iRefCount;  // Reference counting singleton  
   413         // Start point of the next command range
   234         // Start point of the next command range
   414         // to be assigned to a services instance.
   235         // to be assigned to a services instance.
   415         TInt iNextServicesCommandBase; 
   236         TInt iNextServicesCommandBase;
   416         TInt iResourceFileOffset;
   237         bool iIsFromServiceFrmWrk;
   417         CAsyncCallBack* iSystemTimeChangedMsgDelayer;   
   238 		
   418         TBool iFasterApp;
       
   419     };
   239     };
   420 
   240 
   421 #endif // CALENCONTROLLER_H
   241 #endif // CALENCONTROLLER_H
   422 
   242 
   423 // End of file
   243 // End of file