calendarui/controller/inc/calenviewmanager.h
branchRCL_3
changeset 65 12af337248b1
parent 36 9c5b1510919f
child 66 bd7edf625bdd
equal deleted inserted replaced
60:96907930389d 65:12af337248b1
    18 
    18 
    19 #ifndef CALENVIEWMANAGER_H
    19 #ifndef CALENVIEWMANAGER_H
    20 #define CALENVIEWMANAGER_H
    20 #define CALENVIEWMANAGER_H
    21 
    21 
    22 // INCLUDES
    22 // INCLUDES
       
    23 
    23 #include <vwsdef.h>
    24 #include <vwsdef.h>
    24 #include <coeview.h>                    // MCoeViewActivationObserver
    25 #include <QDate>
    25 #include <calencommandhandler.h>
    26 
    26 #include <calennotificationhandler.h>   // MCalenNotificationHandler
    27 #include "calennotificationhandler.h"   // MCalenNotificationHandler
    27 
    28 #include "hb_calencommands.hrh"
    28 // FORWARD DECLARATIONS
    29 #include "calencommandhandler.h"
    29 class CAknViewAppUi;
    30 
    30 class CCalenGlobalData;
    31 class CalenNativeView;
    31 class CCalenViewPopulator;
       
    32 class CCalenController;
    32 class CCalenController;
    33 class CCalenView;
    33 class CalenMonthView;
    34 class CEikMenuPane;
    34 class CalenAgendaView;
    35 class CCalenToolbarImpl;
    35 class AgendaEventViewer;
    36 class MCalenToolbar;
    36 class CalenLandscapeDayView;
    37 class CCalenSetting;
    37 class CalenSettingsView;
    38 class CCalenViewInfo;
    38 class CalenDocLoader;
    39 class CCalenCustomisationManager;
    39 class CalenDayView;
    40 class MCalenServices;
       
    41 class CCalenIcons; 
       
    42 class CCalenToolbarImpl;
       
    43 
       
    44 typedef CCalenView* (*NativeView)(MCalenServices&);
       
    45 
    40 
    46 /**
    41 /**
    47  * The action ui handles events passed from the controller and delegates
    42  * The action ui handles events passed from the controller and delegates
    48  * them to the appropriate place (i.e. the specific action ui classes).
    43  * them to the appropriate place (i.e. the specific action ui classes).
    49  */
    44  */
    50 class CCalenViewManager : public CBase,
    45 class  CalenViewManager :	public QObject,
    51                           public MCoeViewActivationObserver,
    46 							public MCalenNotificationHandler,
    52                           public MCalenNotificationHandler,
    47 							public MCalenCommandHandler
    53                           public MCalenCommandHandler
    48     {   
    54     {
    49     
       
    50 	Q_OBJECT
       
    51 	
    55     public:  // Construction and destruction
    52     public:  // Construction and destruction
    56         /**
    53 		/**
    57          * Symbian 1st phase constructor
    54 		 * Constructor
    58          * @param aAppUi Reference to the CAknViewAppUi
    55 		 */
    59          * @param aController Reference to the CCalenController
    56 		CalenViewManager ( CCalenController& aController);
    60          * @return Pointer to CCalenViewManager
    57 		
    61          */
    58 		/**
    62         static CCalenViewManager* NewL( CAknViewAppUi& aAppUi,  
    59 		 * Second Phase Constructor
    63                                         CCalenController& aController );
    60 		 */
       
    61 		void SecondPhaseConstruction();
       
    62 		
    64         /**
    63         /**
    65          * Destructor
    64          * Destructor
    66          */                             
    65          */                             
    67         virtual ~CCalenViewManager();
    66         virtual ~CalenViewManager();
    68 
    67 	    
    69     public:  // New functions
    68 	public: 
    70         /**
    69        /**
    71          * Constructs the custom views
    70          * Handles view manager commands.
    72          * @param aCustomisationmManager Reference to CCalenCustomisationManager
    71          * @return ETrue if command is handled, EFalse otherwise
    73          */
       
    74         void ConstructCustomViewsL(
       
    75                            CCalenCustomisationManager& aCustomisationManager );
       
    76 
       
    77         /**
       
    78          * Get info array
       
    79          * @return Reference to RPointerArray<CCalenViewInfo>
       
    80          */
       
    81         RPointerArray<CCalenViewInfo>& ViewInfoArray();
       
    82 
       
    83         /**
       
    84          * From MCalenCommandHandler.
       
    85          * Handles key presses.
       
    86          * 
       
    87          * @param aCommand The command Id of the key.
       
    88          */
    72          */
    89         TBool HandleCommandL( const TCalenCommand& aCommand );
    73         TBool HandleCommandL( const TCalenCommand& aCommand );
    90 
    74         
    91         /**
    75         /**
    92          * From MCalenCommandHandler.
    76          * Refresh current view.
    93          * Allows extending this API without breaking BC.
    77          */
    94          * 
    78         void refreshCurrentViewL();
    95          * @param aExtensionUid specifies
    79         
    96          * @return extension of the requested type
    80         /**
    97          */
    81          * Returns the settings view
    98         TAny* CalenCommandHandlerExtensionL( TUid aExtensionUid );
    82          */
    99 
    83         CalenSettingsView* settingsView();
   100         /**
    84 		/*
   101          * Returns the current view.
    85 		* @brief Returns CCalenController
   102          * @return TUid of current view
    86 		*/
   103          */
    87 		CCalenController&  calenController();
   104         TUid CurrentView() const;
    88 		/**
   105 
    89 		 * Constructs and activates the requested view
   106         /**
    90 		 */
   107          * Removes the current view from the switch menu
    91 		void constructAndActivateView(int view);
   108          * @param aMenuPane Where the currenct view should be removed from
    92 		/**
   109          */
    93 		 * Returns the first view
   110         void RemoveCurrentViewFromMenu( CEikMenuPane* aMenuPane );
    94 		 */
   111 
    95 		int getFirstView();
   112         /**
    96 		
   113          * Request activation of a specific view
    97 		void showNextDay();
   114          * @param aViewId Reference to TVwsViewId of the view to be activated
    98 		
   115          */
    99 		void showPrevDay();
   116         void RequestActivationL( const TVwsViewId& aViewId );
   100 		
   117         
   101 		void removePreviousView();
   118         /**
   102 		
   119          * Get a pointer to the Calendar toolbar, or NULL if none is available.
   103 		void constructOtherViews();
   120          * Ownership is not transferred.
   104 		
   121          * @return Calendar toolbar if available
   105 		void launchSettingsView();
   122          */
   106 				
   123         MCalenToolbar* ToolbarOrNull();
   107 		/**
   124         
   108 		 * @brief check if Agenda Event Viewer is active
   125         /**
   109 		 */
   126          * Activates the default view, as retrieved from settings.
   110 		bool isEventViewerActive();
   127          */
   111 
   128         void ActivateDefaultViewL( TUid aDefaultView );
   112 		/**
   129         
   113 		 * save the entry and close the editor
   130         /**
   114 		 */
   131          * Returns if the first view activation on start-up has taken place
   115 		void saveAndCloseEditor();
   132          */
   116 		
   133         TBool ViewsActivated() const;
   117 
   134         
   118         /**
   135         /** 
   119          * close agenda event view
   136          * Interupts the population of the current view.
   120          * should be call if agenda eevent view is open
   137          */
   121          */
   138         void InterruptPopulationL();
   122 		void closeAgendaEventView();
   139         
   123         
   140         /**
   124 		/**
   141          * Try to activate a view
   125          * remove the setting view
   142          * @param aViewUid View id to be activated
   126          */
   143          * @param aMessageId Message id
   127 		void removeSettingsView();
   144          * @param aMessage Message send along activation query
   128 		
   145          */
   129 	public: // from MCalenNotificationHandler
   146         void RequestActivationL( const TUid& aViewUid,
       
   147                                  const TUid& aMessageId = KNullUid,
       
   148                                  const TDesC8& aMessage = KNullDesC8 );
       
   149         
       
   150         /**
       
   151          * Started population of the current view
       
   152          */
       
   153         void StartActiveStepL();
       
   154         
       
   155         /**
       
   156          * Returns a reference to the calendar icon array
       
   157          * @return reference to a CCalenIcons array
       
   158          */
       
   159         CCalenIcons& IconsL();  
       
   160          
       
   161         /**
       
   162          * Gets next view icon
       
   163          */
       
   164         CGulIcon* GetNextViewIconL();
       
   165         
       
   166         /**
       
   167          * Repopulate the view.
       
   168          */
       
   169         void SetRepopulation(TBool aRePopulate);
       
   170 
       
   171         /**
       
   172          * Returns calendar toolbar
       
   173          */
       
   174         CCalenToolbarImpl* CalenToolbar();
       
   175         
       
   176         /**
       
   177          * Unload all plugins on fake exit
       
   178          */
       
   179         void UnLoadAllPluginsL();
       
   180         
       
   181         /**
       
   182          * Reload all plugins when application comes to
       
   183          * foreground after fake exit
       
   184          */
       
   185         void ReloadAllPluginsL();
       
   186         
       
   187 		/**
       
   188          * Gets the view Id of previous view.
       
   189          * @return TUid, Uid of previous view.
       
   190          */
       
   191         TUid GetPreviousViewUid();
       
   192 		
       
   193         /**
       
   194          * Check for native view.
       
   195          * @param aViewUid Uid of the View  
       
   196          * @returns ETrue if aViewUid is any of the native views
       
   197          */
       
   198         TBool IsNativeView(TUid aViewUid);
       
   199         
       
   200         /**
       
   201          * Activate view depending upon the current default view
       
   202 		 * If plugin views is default view, then dummy view will be activated
       
   203 		 * else the native view
       
   204 		 * @param	aDefView	current default view frm calendar settings
       
   205          */
       
   206         void ActivateViewOnFakeExitL(TUid aDefView);
       
   207         
       
   208         /**
       
   209          * Activate the local view if application already in back ground
       
   210          * @param   aDefView    current default view which needs to be activated.
       
   211          */
       
   212         void ActivateLocalViewL(TUid aDefView);
       
   213         
       
   214     private:  // New functions
       
   215 
       
   216         /**
       
   217          * From MCoeViewActivationObserver
       
   218          * Called just before a view in this application is activated by the view server
       
   219          * @param aNewlyActivatedViewId View id to be activated
       
   220          * @param aViewIdToBeDeactivated View id to be deactivated
       
   221          */
       
   222         void HandleViewActivation( const TVwsViewId& aNewlyActivatedViewId,
       
   223                                    const TVwsViewId& aViewIdToBeDeactivated );
       
   224                                                                                           
       
   225         /**
       
   226          * Requests activation for the next view in the view cycle
       
   227          */
       
   228         void CycleNextViewL();
       
   229         
       
   230         /**
       
   231          * Requests activation for the previous view in the view cycle
       
   232          */
       
   233         void CyclePrevViewL();
       
   234         
       
   235         /**
       
   236          * Constructs the s60 native views and registers them with the view server
       
   237          */
       
   238         void ConstructNativeViewsL();
       
   239         
       
   240         /**
       
   241          * Constructs any custom views from plugins and registers them with the view server
       
   242          */
       
   243         void ConstructCustomViewsL();
       
   244         
       
   245          /**
       
   246          * Constructs any custom views from a plugin and registers them with the view server
       
   247          */
       
   248         void ConstructCustomViewL( TUid aPluginUid );
       
   249           
       
   250         /**
       
   251          * Prompts the user to choose a view to switch to. If cancelled returns 
       
   252          * KErrCancel, otherwise one of the ECalenView*
       
   253          */
       
   254         void ShowSwitchViewQueryL();
       
   255         
       
   256         /**
       
   257          * Adds a view to the array
       
   258          * @param aView Pointer to the view that is going to be added
       
   259          */
       
   260         void AddNativeViewL( CCalenView* aView );
       
   261         
       
   262         /** 
       
   263          * Removes a native view from the view manager
       
   264          * @param aViewUid  view uid of view that is going to be removed
       
   265          */
       
   266         void RemoveNativeViewL( TUid aViewUid );
       
   267         
       
   268         /**
       
   269          * Creates native view 
       
   270          */
       
   271         TBool CreateNativeViewL( TUid aViewUid );
       
   272 
       
   273         /**
       
   274          * Return reference to the customisation manager
       
   275          * @return Reference to CCalenCustomisationManager
       
   276          */
       
   277         CCalenCustomisationManager& CustomisationManager();
       
   278 
       
   279         /**
       
   280          * Compares the list of active plugins and plugins the view manager
       
   281          * knows about, to discover which plugins have been enabled or
       
   282          * disabled
       
   283          */
       
   284         void UpdatePluginListL();
       
   285         
       
   286         /**
       
   287          * Removes the custom views supplied by the plugin list from the view 
       
   288          * server.
       
   289          * @param   uids 
       
   290          */
       
   291         void RemoveDisabledPluginsViewsL( RArray<TUid>& aDisabledPlugins );
       
   292                                  
       
   293         /**
       
   294          * Asyncronous callback function to remove the current view after 
       
   295          * it has been disabled.
       
   296          */
       
   297         static TInt RemoveDeActivatedView( TAny* aObject );
       
   298         
       
   299         /**
       
   300          * Asyncronous callback function to remove the current view after 
       
   301          * it has been disabled. Leaving version
       
   302          */
       
   303         void RemoveDeActivatedViewL();
       
   304         
       
   305         /**
       
   306          * Handles notifications (Leaving)
       
   307          */
       
   308         void HandleNotificationL( TCalenNotification aNotification );
       
   309         
       
   310         /**
       
   311          * Updates the nextview icon on the toolbar when default view is not month view
       
   312          */
       
   313         void UpdateToolbarNextViewIconL(TUid defViewUid);
       
   314         
       
   315         /**
       
   316          * Handles Faster app exit
       
   317          */
       
   318         void HandleFasterAppExitCommandL();
       
   319         
       
   320         /**
       
   321          * Handles ECalenNotifySettingsChanged notification 
       
   322          */
       
   323         void HandleSettingsChangeNotificationL();
       
   324         
       
   325         /**
       
   326          * Handles ECalenNotifyEntryDeleted and ECalenNotifyInstanceDeleted
       
   327          * notifications 
       
   328          */
       
   329         void HandleEntryDeleteNotificationL();
       
   330         
       
   331         /**
       
   332          * Handles ECalenNotifyEntryClosed notification
       
   333          */
       
   334         void HandleEntryClosedNotificationL();
       
   335         
       
   336         /**
       
   337          * Handles ECalenNotifySystemTimeChanged notification
       
   338          */ 
       
   339         void HandleSystemTimeChangeNotificationL();
       
   340         
       
   341     private: // from MCalenNotificationHandler
       
   342    
   130    
   343         /**
   131         /**
   344          * Handles notifications
   132          * Handles notifications
   345          */
   133          */
   346         void HandleNotification( const TCalenNotification aNotification );
   134         void HandleNotification( const TCalenNotification aNotification );
   347         
   135         
   348     private:  // Construction and destruction
   136 	private:
   349         /**
   137         /**
   350          * C++ constructor
   138          * Loads month view frm the docml
   351          * @param aAppUi Reference to CAknViewAppUi
   139          */
   352          * @param aController Reference to CCalenController
   140         void loadMonthView();
   353          */
   141         /**
   354         CCalenViewManager( CAknViewAppUi& aAppUi,
   142 		 * Loads agenda view from the docml
   355                                      CCalenController& aController  );
   143 		 */
   356 
   144         void loadAgendaView();
   357         /**
   145 
   358          * Symbian 2nd phase constructor
   146         /**
   359          */
   147          * Loads day view from the docml
   360         void ConstructL();
   148          */
   361 
   149         void loadDayView();
   362     private:  // Data
   150                 
   363         TVwsViewId              iCurrentViewId;
   151 	    /**
   364         CCalenGlobalData*       iGlobalData;
   152 	     * Activates the default view, as retrieved from settings.
   365         CAknViewAppUi&          iAppUi;
   153 	     */
   366         TInt                    iViewCycleIndex;
   154 	    void ActivateDefaultViewL( int defaultView );
   367         CCalenViewPopulator*    iPopulator;
   155 	    
   368         CCalenSetting*          iSetting;
   156 	    /**
   369         CCalenToolbarImpl*      iToolbar;
   157           * Activate current view.
   370         CCalenCustomisationManager* iCustomisationManager;
   158           */
   371         RPointerArray<CCalenViewInfo> iViewInfoArray;
   159 		void activateCurrentView();
   372         CCalenController&           iController;
   160 		
   373 
   161 		/**
   374         // Stores the uids of the plugins, the view manager is
   162 		 * Launch event view.
   375         // aware of.
   163 		 */
   376         RArray<TUid> iKnownPlugins;
   164 		void launchEventView();
   377         // Pointer to CCalenViewInfo for an active view which has
   165 		
   378         // been disabled. 
   166 		/**
   379         CCalenViewInfo* iRemovedActiveView;
   167 		 * @brief Constructs the auxilliary view used
   380         // Remove the current view asynchronously
   168 		 * to provide illusion of swiping to next or prev
   381         CAsyncCallBack*  iViewRemovalCallback;   
   169 		 * day
   382         CCalenIcons* iIcons;
   170 		 */
   383         
   171 		void loadAlternateAgendaView();
   384         // The first view on start-up has been activated.
   172         
   385         TBool iViewsActivated; 
   173     private slots:
   386         TVwsViewId  iPreviousViewId;
   174 		void handleMainViewReady();
   387         TVwsViewId  iPreviousToDayView;
   175 		void handleViewingCompleted(const QDate date);
   388         TVwsViewId iPreviousToWeekView;
   176 		void handleEditingStarted();
   389         TBool iAvoidRepopulation;
   177 		void handleEditingCompleted();
   390         TBool iStartupComplete;
   178 		void handleDeletingStarted();
   391     };
   179 		void handleDeletingCompleted();
       
   180 		void handleInstanceViewCreation(int status);
       
   181 		void handleEntryViewCreation(int status);
       
   182 		void handleEntriesChanged(QList<ulong>);
       
   183 		void handleEntryUpdation(ulong id);
       
   184 		
       
   185     private:  // Data        
       
   186 
       
   187 		CCalenController		&mController;
       
   188 		CalenMonthView			*mCalenMonthView;
       
   189 		CalenAgendaView			*mCalenAgendaView;
       
   190 		AgendaEventViewer		*mCalenEventViewer;
       
   191 		CalenLandscapeDayView	*mCalenLandscapeDayView;
       
   192 		CalenSettingsView		*mSettingsView;
       
   193 		CalenDocLoader			*mAgendaViewDocLoader;
       
   194 		CalenDocLoader			*mMonthViewDocLoader;
       
   195 		CalenAgendaView         *mCalenAgendaViewAlt;
       
   196 		CalenDocLoader          *mAgendaViewAltDocLoader;
       
   197 		CalenDayView			*mCalenDayView;
       
   198         
       
   199 		int  mCurrentViewId;
       
   200 		int  mPreviousViewsId;
       
   201 		int  mFirstView;
       
   202 		bool mInstanceViewCreated;
       
   203         };
   392 
   204 
   393 #endif // CALENVIEWMANAGER_H
   205 #endif // CALENVIEWMANAGER_H
   394 
   206 
   395 // End of file
   207 // End of file