voicerecorder/RecViewInc/CVRRecView.h
changeset 0 845549f293a7
child 13 4e5b531d23cb
equal deleted inserted replaced
-1:000000000000 0:845549f293a7
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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: 
       
    15 *     CVRRecView is an CAknView inherited view class that implements
       
    16 *     the recorder view functionality of Voicer Recorder.
       
    17 *     It owns the view container (which, in turn, owns all the ui controls)
       
    18 *     and the view model.
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 #ifndef __CVRRECVIEW_H__
       
    24 #define __CVRRECVIEW_H__
       
    25 
       
    26 // INCLUDES
       
    27 #include <aknview.h>
       
    28 #include "MVRSelectionProvider.h"
       
    29 #include "MVRLayoutChangeObserver.h"
       
    30 #include <VoiceRecorderContexts.h>
       
    31 #include "voicerecorder.hrh"
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class CAknLaunchAppService;
       
    35 class CSendUi;
       
    36 class CVRRecViewContainer;
       
    37 class CVRRecViewActivationContainer;
       
    38 class CVRRecViewModel;
       
    39 
       
    40 // CLASS DEFINITION
       
    41 /**
       
    42 * CVRRecView is an CAknView inherited view class that implements
       
    43 * the recorder view functionality of Voicer Recorder.
       
    44 * It owns the view container (which, in turn, owns all the ui controls)
       
    45 * and the view model.
       
    46 */
       
    47 class CVRRecView 
       
    48 	: public CAknView, public MVRSelectionProvider, 
       
    49 	  public MVRLayoutChangeObserver
       
    50 	{
       
    51 	private:	// nested classes
       
    52 
       
    53         /*
       
    54         * One shot class for model activation. Receives a pointer to
       
    55         * constructed CVRRecViewModel object and activates it asynchronically
       
    56         * when Activate() is called.
       
    57         */
       
    58         NONSHARABLE_CLASS( CVRRecViewModelActivator ) 
       
    59             : public CAsyncOneShot
       
    60             {
       
    61             public:  // constructor and destructor
       
    62                 CVRRecViewModelActivator( CVRRecViewModel* aModel );
       
    63                 ~CVRRecViewModelActivator(); 
       
    64 
       
    65             public: // New functions:
       
    66 
       
    67 				/**
       
    68 				 * Activate model in given context
       
    69                  */
       
    70                 void Activate( TVRRecViewContexts aContext, TCallBack aCallback );
       
    71                 
       
    72             private: // Functions from base classes
       
    73 
       
    74                 /**
       
    75                  * From CActive.
       
    76                  */
       
    77                 void RunL();
       
    78                 void DoCancel();
       
    79 
       
    80             private: // Data:
       
    81 
       
    82                 /*
       
    83                 * State machine model, not owned
       
    84                 */
       
    85                 CVRRecViewModel* iModel;
       
    86 
       
    87 				/*
       
    88 				* Context that is used to activate model in RunL
       
    89 				*/                
       
    90                 TVRRecViewContexts iContext;
       
    91                 
       
    92                 /*
       
    93                 * Callback that is called after model is activated
       
    94                 */
       
    95                 TCallBack iCallback;
       
    96             };
       
    97 	
       
    98 	
       
    99 	public: // Constructors and destructor
       
   100 
       
   101 		/**
       
   102 		* Static constructor.
       
   103 		* @param aViewResourceId The resource used in view construction.
       
   104 		* @param aModelResourceId The resource used in model construction.
       
   105 		*/
       
   106 		IMPORT_C static CVRRecView* NewLC( TInt aViewResourceId,
       
   107 										   TInt aModelResourceId );
       
   108 
       
   109 		/**
       
   110 		* Destructor
       
   111 		*/
       
   112 		~CVRRecView();
       
   113 
       
   114 	private: // Constructors
       
   115 
       
   116 		/**
       
   117 		* Default constructor.
       
   118 		* The inline saves a few bytes.
       
   119 		*/
       
   120 		inline CVRRecView() {};
       
   121 
       
   122 		/**
       
   123 		* 2nd phase constructor.
       
   124 		* @param aViewResourceId The resource used in view construction.
       
   125 		* @param aModelResourceId The resource used in model construction.
       
   126 		*/
       
   127 		void ConstructL( TInt aViewResourceId, TInt aModelResourceId );
       
   128 
       
   129 	public: // from MVRSelectionProvider
       
   130 
       
   131 		/**
       
   132 		* Returns an array of currently selected files.
       
   133 		* Ownership is transferred. Caller must destroy the returned array.
       
   134 		* @param aStyle Used to return the style of selection
       
   135 		*               (empty/focused/marked)
       
   136 		* @return An array of selected files (0 or more).
       
   137 		*/
       
   138 		MDesCArray* GetSelectedFilesLC( TVRSelectionStyle& aStyle ) const;
       
   139 
       
   140 		/**
       
   141 		* Pass the file handle to recview.
       
   142 		* Recorded memo is placed there.
       
   143 		* @param aFile File handle
       
   144 		*/
       
   145 		void SetFileHandle( RFile& aFile );
       
   146 		
       
   147 		/**
       
   148 		* Return the recorded open file handle
       
   149 		* @param aFile File handle
       
   150 		*/
       
   151 		RFile& GetFile();		
       
   152 
       
   153 	public: // from MVRLayoutChangeObserver
       
   154 
       
   155 		/**
       
   156 		* This method gets called by the AppUI when a dynamic layout change
       
   157 		* event occurs.
       
   158 		*/
       
   159 		void LayoutChangedL( TInt aType );
       
   160 
       
   161 	public: // from CAknView
       
   162 		
       
   163 		/**
       
   164 		* Returns the id of the view.
       
   165 		* @return KVRRecViewUID
       
   166 		*/
       
   167 		TUid Id() const;
       
   168 
       
   169 		/**
       
   170         * Handles menu commands.
       
   171  		* @param aCommand Command identifier.
       
   172         */
       
   173 		void HandleCommandL( TInt aCommandId );
       
   174 
       
   175 	protected: // from CAknView
       
   176 
       
   177 		/**
       
   178 		* Dynamically initialises a menu pane. The Uikon framework calls this
       
   179 		* function, immediately before the menu pane is activated.
       
   180 		* @param aResourceId Resource ID identifying a menu pane to initialise
       
   181 		* @param aMenuPane The in-memory representation of the menu pane.
       
   182 		*/
       
   183 		void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
       
   184 
       
   185         /** 
       
   186          * Foreground event handling function.
       
   187          *
       
   188          * Called by UI Framework when view switches to and from foreground
       
   189          *  
       
   190          * @param aForeground True if view is switched to foreground else false.
       
   191          */	
       
   192 //		void HandleForegroundEventL( TBool aForeground );
       
   193 		
       
   194 	private: // from CAknView
       
   195 		
       
   196         /**
       
   197  		* Is called by the framework when the view is activated.
       
   198 		* @param aPrevViewId Id of the previous view that was active
       
   199 		* @param aCustomMessageId Id of the custom message passed
       
   200 		* @param aCustomMessage Descriptor containing the custom message data
       
   201         */
       
   202 		void DoActivateL( const TVwsViewId& aPrevViewId,
       
   203 						  TUid aCustomMessageId,
       
   204 						  const TDesC8& aCustomMessage );
       
   205 
       
   206         /**
       
   207  		* Is called by the framework when the view is deactivated.
       
   208         */
       
   209 		void DoDeactivate();
       
   210 
       
   211 	protected: // from MCoeView
       
   212 
       
   213 		/**
       
   214 		* Is called by the view server when the application goes to background.
       
   215 		*/
       
   216 		void ViewDeactivated();
       
   217 
       
   218 		/**
       
   219 		* Is called by the view server when the application goes to the foreground.
       
   220 		*/
       
   221 		void ViewActivatedL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,const TDesC8& aCustomMessage);
       
   222 
       
   223 	public: // from CAknView
       
   224 
       
   225 		/**
       
   226 		* Returns a pointer to the CBA container
       
   227 		* Calls base class Cba() (which is protected)
       
   228 		*/
       
   229 		CEikButtonGroupContainer* Cba() const;
       
   230 
       
   231     	/**
       
   232 		* Returns a the StateId
       
   233 		* 
       
   234 		*/
       
   235         TUint GetStateId() const;
       
   236 
       
   237 		/**
       
   238 		* Returns embedding status.
       
   239 		* @param ETrue if the current context is an embedded one.
       
   240 		*/
       
   241 		TBool IsEmbedded() const;
       
   242 
       
   243         /**
       
   244 		* Returns the active quality setting.
       
   245 		* @return Quality setting of the active memo
       
   246 		*/
       
   247 		TVRQuality Quality() const;
       
   248 
       
   249 	private: // new methods
       
   250 
       
   251 		/**
       
   252 		* Dynamically adds a Send Via menu item plus associated cascade
       
   253 		* to the given menu pane.
       
   254 		* @param aResourceId Resource ID identifying a menu pane
       
   255 		* @param aMenuPane The in-memory representation of the menu pane.
       
   256 		*/
       
   257 		void AddSendToMenuL( TInt aResourceId, CEikMenuPane* aMenuPane );
       
   258 
       
   259 		/*
       
   260 		* Trappable version of DoActivateL. Activates an empty UI container
       
   261 		* and starts asynchronic model activation.
       
   262 		* See CAknView::DoActivateL for parameters
       
   263 		*/
       
   264 		void ReallyDoActivateL( const TVwsViewId& aPrevViewId,
       
   265 								  TUid aCustomMessageId,
       
   266 								  const TDesC8& aCustomMessage );
       
   267 
       
   268 		/*
       
   269 		* Called by iModelActivator object after model has been
       
   270 		* fully activated.
       
   271 		* @param aRecView Always a valid pointer to CVRRecView object
       
   272 		* @return Return value required by TCallBack, not used.
       
   273 		*/
       
   274 		static TInt ActivationCallBack( TAny* aRecView );
       
   275 		
       
   276 		/*
       
   277 		* Non-static method called by ActivationCallBack. Activates
       
   278 		* the actual UI container and deletes the empty one.
       
   279 		*/
       
   280 		void ActivateContainerL();
       
   281 								  
       
   282 	private: // data
       
   283 		
       
   284 		/**
       
   285 		* Pointer to the UI control container. Owned.
       
   286 		*/
       
   287 		CVRRecViewContainer* iContainer;
       
   288 		
       
   289 		/**
       
   290 		* Pointer to the container that is displayed during
       
   291 		* model construction. Owned
       
   292 		*/
       
   293 		CVRRecViewActivationContainer* iActivationContainer;		
       
   294 
       
   295 		/**
       
   296 		* Pointer to the view model (statemachine). Owned.
       
   297 		*/
       
   298 		CVRRecViewModel* iModel;
       
   299 
       
   300 		/**
       
   301 		* SendUi used to implement the Send Via feature. Owned.
       
   302 		*/
       
   303 		CSendUi* iSendUi;			
       
   304 		
       
   305 		/**
       
   306 		* One shot object that is used to activate model in correct context
       
   307 		* asynchronically. Owned.
       
   308 		*/
       
   309 		CVRRecViewModelActivator* iModelActivator;
       
   310 
       
   311 		/**
       
   312 		* The command that passed to Handlecommand
       
   313 		* 
       
   314 		*/
       
   315         TInt iCommand;
       
   316         
       
   317         CAknLaunchAppService* iLaunchService;
       
   318 	};
       
   319 
       
   320 #endif // __CVRRECVIEW_H__
       
   321