fmradio/fmradio/inc/fmradioscanlocalstationsview.h
changeset 0 f3d95d9c00ab
child 7 95ac6b0f7f5b
equal deleted inserted replaced
-1:000000000000 0:f3d95d9c00ab
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  definition of the class CFMRadioScanLocalStationsView
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef FMRADIOSCANLOCALSTATIONSVIEW_H
       
    20 #define FMRADIOSCANLOCALSTATIONSVIEW_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <aknview.h>
       
    24 #include <AknProgressDialog.h>
       
    25 #include <akntoolbarobserver.h>
       
    26  
       
    27 #include "fmradioscanlocalstationscontainer.h"
       
    28 #include "mfmradiolayoutchangeobserver.h"
       
    29 #include "fmradiordsobserver.h"
       
    30 #include "mchannellisthandler.h"
       
    31 #include "fmradiosvkevents.h"
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class CFMRadioScanLocalStationsContainer;
       
    35 class CRadioEngine;
       
    36 class CAknWaitDialog;
       
    37 class CFMRadioPreset;
       
    38 
       
    39 
       
    40 // CLASS DECLARATION  
       
    41 
       
    42 /**
       
    43 * CFMRadioScanLocalStationsView view class.
       
    44 * @since 2.6
       
    45 */
       
    46 class CFMRadioScanLocalStationsView : public CAknView,
       
    47                                 	  public MCoeControlObserver,
       
    48                                 	  public MFMRadioLayoutChangeObserver,
       
    49                                 	  public MProgressDialogCallback,
       
    50                                       public MFMRadioRdsObserver,
       
    51                                       public MAknToolbarObserver
       
    52     {
       
    53     public: // Constructors and destructor
       
    54         /**
       
    55         * Two-phase constructor of CFMRadioScanLocalStationsView
       
    56         * @since 2.6
       
    57         * @param aRadioEngine pointer to a radio engine object
       
    58         * @param aObserver channel list observer
       
    59         */
       
    60         static CFMRadioScanLocalStationsView* NewL( CRadioEngine& aRadioEngine,
       
    61         		MChannelListHandler& aObserver );
       
    62         /**
       
    63         * Destructor.
       
    64         * @since 2.6
       
    65         */
       
    66         virtual ~CFMRadioScanLocalStationsView();
       
    67     public:  // New functions
       
    68         /**
       
    69         * Return the unique identifier corresponding to this view
       
    70         * @since 2.6
       
    71         * @return the unique identifier corresponding to this view
       
    72         */
       
    73         TUid Id() const;
       
    74         /**
       
    75         * Keep track of the last selected channel
       
    76         * @since 2.6
       
    77         * @param aIndex the index of the last listened to channel
       
    78         */
       
    79         void SetLastListenedChannel( TInt aIndex );
       
    80         /**
       
    81         * Keep track of the current selected channel
       
    82         * @param aChannelIndex the index of the current channel
       
    83         */
       
    84         void SetNowPlayingChannelL ( TInt aChannelIndex );
       
    85          /**
       
    86         * Returns the index of the playing channel item from the 
       
    87         * channel list. 
       
    88         * @return the currently playing channel
       
    89         */
       
    90         TInt CurrentlyPlayingChannel();
       
    91         /**
       
    92         * Returns the index of the selected channel item from the 
       
    93         * channel list. If the container is active get the info from 
       
    94         * it, because it may have more up-to-date info.
       
    95         * @since 2.6
       
    96         * @return the currently selected channel
       
    97         */
       
    98         TInt CurrentlySelectedChannel();
       
    99         /**
       
   100         * Make a request to the channel container to update the 
       
   101         * content of the channel at aIndex with the values specified
       
   102         * @since 2.6
       
   103         * @param aIndex the index of the channel to update
       
   104         * @param aChannelFrequency the new frequency
       
   105         */
       
   106         void UpdateChannelListContentL( TInt aIndex, TInt aChannelFrequency );
       
   107         /**
       
   108         * Return true/false to indicate whether the channel specified is in use
       
   109         * @since 2.6
       
   110         * @param aIndex the index of the channel to check
       
   111         * @return true/false to indicate whether the channel is currently being used
       
   112         */
       
   113         TBool ChannelInUse( const TInt aIndex ) const;
       
   114         /**
       
   115         * Return true/false to indicate whether the channel specified is in play
       
   116         * @param aChannelIndex the index of the channel to check
       
   117         * @return true/false to indicate whether the channel is currently being played
       
   118         */
       
   119         TBool ChannelInPlay( TInt aChannelIndex ) const; 
       
   120         /**
       
   121         * Retrieve the index of the next channel that has been set.
       
   122         * @since 2.6
       
   123         * @return the index of the next "in use" channel
       
   124         */
       
   125         TInt NextChannel();
       
   126         /**
       
   127         * Retrieve the index of the previous channel that has been set.
       
   128         * @since 2.6
       
   129         * @return the index of the previous "in use" channel
       
   130         */
       
   131         TInt PreviousChannel();
       
   132         /**
       
   133         * Fade the view and all controls associated with it. Change
       
   134         * the soft keys so that "Exit" is displayed
       
   135         * @since 2.6
       
   136         * @param aFaded true/false to indicate whether the view should fade/unfade.
       
   137         */
       
   138         void FadeAndShowExit( TBool aFaded );
       
   139         /**
       
   140         * Update display when focus regained
       
   141         * @since 3.0
       
   142         */
       
   143         void UpdateDisplayForFocusGained();
       
   144         /**
       
   145         * Display a wait note while the channel fill is occuring.
       
   146         * @since 2.6        *  
       
   147         */
       
   148         void DisplayScanningInProgressNoteL();
       
   149         /**
       
   150         * Remove and destroy the scanning note.
       
   151         * @since 2.6
       
   152         */
       
   153         void RemoveScanningInProgressNoteL();
       
   154         /**
       
   155         * from MFMRadioLayoutChangeObserver
       
   156 		* This method gets called by the AppUI when a dynamic layout change
       
   157 		* event occurs.
       
   158 		*/
       
   159 		void LayoutChangedL( TInt aType );
       
   160 
       
   161 		/**
       
   162 		 * Invoked by AppUi when a new radio station is found.
       
   163 		 */
       
   164 		void StopSeekL();
       
   165 		/**
       
   166          * Restores the radio after scanning
       
   167          */
       
   168         void RestoreRadio( TBool aTuneInitialFrequency = ETrue );
       
   169 		/**
       
   170 		 * Called when a new scan is activated.
       
   171 		 */
       
   172 		void ResetListAndStartScanL();
       
   173 		/**
       
   174 		 * Saves all the scanned channels into Radio Engine's presets.
       
   175 		 */
       
   176 		void SaveAllChannelsL();
       
   177 		/**
       
   178 		* Sets toolbar visibility
       
   179 		* @param aVisible 
       
   180 		* @return none
       
   181 		*/
       
   182 		void ShowToolbar( TBool aVisible );
       
   183 		
       
   184 		 // from base class MFMRadioRdsObserver
       
   185 	    void RdsDataProgrammeService( const TDesC& aProgramService );
       
   186 	    void RdsDataPsNameIsStatic( TBool aStatic );
       
   187 	    void RdsDataRadioText( const TDesC& aRadioText );
       
   188         void RdsDataRadioTextPlus( const TInt /*aRTPlusClass*/, const TDesC& /*aRadioText*/ ){}; 	    
       
   189 	    void RdsAfSearchBegin();
       
   190 	    void RdsAfSearchEnd( TUint32 aFrequency, TInt aError );
       
   191 	    void RdsAfSearchStateChange( TBool aEnabled );
       
   192 	    void RdsAvailable( TBool aAvailable );
       
   193 	    
       
   194 	    //for canceling the wizard
       
   195 	    void SetScanCanceled( TFMRadioCancelScanType aType );
       
   196 	    TFMRadioCancelScanType CancelType();
       
   197         /**
       
   198          * Dim or undim save and saveall buttons.
       
   199          */ 
       
   200         void UpdateToolbar();
       
   201         
       
   202         /*
       
   203          * Handle view specific remote control events
       
   204          * @param aEvent accessory event
       
   205          */
       
   206         void HandleScanListRemConEventL( TAccessoryEvent aEvent );
       
   207 
       
   208     private: // Functions from base classes
       
   209         /**
       
   210         * Activate the channel list view
       
   211         * @since 2.6
       
   212         */
       
   213         void DoActivateL( const TVwsViewId& aPrevViewId,TUid aCustomMessageId, const TDesC8& aCustomMessage );
       
   214         /**
       
   215         * Deactivate the channel list view
       
   216         * @since 2.6
       
   217         */
       
   218         void DoDeactivate();
       
   219         /**
       
   220         * Interprets view's menu,softkey and other commands and acts 
       
   221         * accordingly by calling the appropriate command handler 
       
   222         * function for further action.
       
   223         * @since 2.6
       
   224         * @param aCommand the command to process
       
   225         */
       
   226         void HandleCommandL( TInt aCommand );
       
   227         /**
       
   228         * From MCoeControlObserver, control event observing. In this case,
       
   229         * the user selection from the list is reported by container class
       
   230         * and observed here.
       
   231         * @since 2.6
       
   232         * @param aControl the control that caused the event
       
   233         * @param aEventType the type of event that was triggered
       
   234         */
       
   235         void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType );
       
   236         /**
       
   237         * Sets the state of menu items dynamically according to the 
       
   238         * state of application data.
       
   239         * @since 2.6
       
   240         * @param aResourceId Resource ID identifying the menu pane to initialise.
       
   241         * @param aMenuPane The in-memory representation of the menu pane.
       
   242         */
       
   243         void DynInitMenuPaneL( TInt aResourceId,CEikMenuPane* aMenuPane );
       
   244         
       
   245         /**
       
   246         * SetMiddleSoftKeyLabelL, sets the MSK label
       
   247         * from resource
       
   248         */
       
   249         void SetMiddleSoftKeyLabelL( const TInt aResourceId, const TInt aCommandId );        
       
   250         /**
       
   251         * SetMiddleSoftKeyIconL, sets the MSK icon
       
   252         * 
       
   253         */
       
   254         void SetMiddleSoftKeyIconL();        
       
   255         /**
       
   256         * Called when user cancels waiting note or process finishes
       
   257         */       
       
   258         void DialogDismissedL( TInt  aButtonId );
       
   259         /**
       
   260         * from MAknToolbarObserver
       
   261         * Handle commands from toolbar.
       
   262         * @param aCommandId The command id
       
   263         */        
       
   264         void OfferToolbarEventL( TInt aCommandId );
       
   265         /**
       
   266         * SetContextMenu, to set MSK context
       
   267         */
       
   268 	    void SetContextMenu( TInt aMenuTitleResourceId );
       
   269     private: // new functions
       
   270 
       
   271 		/** modes for channel saving */
       
   272 		enum TSavingMode
       
   273 			{
       
   274 			EAppend = 0x1,
       
   275 			EReplace
       
   276 			};	
       
   277 	    /**
       
   278 		* C++ default constructor
       
   279 		*/
       
   280 	 	CFMRadioScanLocalStationsView( CRadioEngine& aRadioEngine, MChannelListHandler& aObserver );
       
   281 	    /**
       
   282 	    * EPOC default constructor.
       
   283 	    * @since 2.6
       
   284 	    */
       
   285 	    void ConstructL();
       
   286 		/**
       
   287 		* Save scanned channels to presets
       
   288 		*/        
       
   289 		void SaveFoundChannelsToPresetsL( TSavingMode aSavingMode );         
       
   290 		/**
       
   291 		* Add found channel to the frequency list
       
   292 		*/           
       
   293 		void AddTunedFrequencyToListL();
       
   294 		/**
       
   295 		* Tune to the selected channel
       
   296 		*/        
       
   297 		void PlayCurrentlySelectedChannelL();
       
   298 		
       
   299 		/**
       
   300 		 * Show aResQuery confimation query with aResText.
       
   301 		 * aResText and aResQuery must be real resource ids.  
       
   302 		 * Returns users response, 0 if user denied.
       
   303 		 */
       
   304 		TInt ShowConfirmationQueryL(TInt aResText, TInt aResQuery);		
       
   305 		/**
       
   306         * Prepare toolbar for FMRadio command buttons
       
   307         */
       
   308 		void PrepareToolbar();
       
   309 		        /**
       
   310         * Set the current dimmed state of the toolbar 
       
   311         * 
       
   312         * @param aState the new toolbar dimmed state
       
   313         */
       
   314         void SetToolbarDimmedState( const TBool aState );        
       
   315         /**
       
   316          * check if the frequency is already found
       
   317          * @param aFrequency frequency to check
       
   318 		 * @return list index or KErrNotFound if the frequency is not in the list
       
   319          */
       
   320         TInt FrequencyIndex( TInt aFrequency );
       
   321         /**
       
   322          * Handle single channel save
       
   323          */
       
   324         void HandleOneChannelSaveL();
       
   325         /*
       
   326          * Activates main view. Doesn't bring radio to
       
   327          * foreground if the app is in the background
       
   328          */
       
   329         void ActivateMainViewL();
       
   330         
       
   331         /*
       
   332          * Resolves index number for the given frequency.
       
   333          * Frequencies are sorted from smallest to largest.
       
   334          * @param aFrequency frequency to add
       
   335          */
       
   336         TInt SortedFrequencyListIndex( TInt aFrequency );
       
   337     	
       
   338     private: // Data
       
   339     	CFMRadioScanLocalStationsContainer* iContainer;
       
   340         TInt iChIndex;
       
   341         TInt iNowPlayingIndex;
       
   342         TBool iScanAndSaveActivated;
       
   343         TInt iCurrentMSKCommandId; //owned
       
   344 		TBool iFaded;
       
   345 		TBool iScanCancelled;
       
   346         CRadioEngine& iRadioEngine; 
       
   347 		TInt iLowerFrequencyBound;
       
   348 		TInt iUpperFrequencyBound;
       
   349 		
       
   350 		TBool iScanningNoteIsVisible;
       
   351 		// array for the scanned channels
       
   352 		RPointerArray<CFMRadioPreset> iScannedChannels; 
       
   353 		
       
   354 		TInt iInitialTunedFrequency;
       
   355 		// A wait used when channel fill in progress
       
   356         CAknWaitDialog* iScanningNote;
       
   357         TBool iTuneRequested;
       
   358        	/**
       
   359 		* Toolbar for controlling the application.	
       
   360 		*/
       
   361 		CAknToolbar* iToolbar;
       
   362         /**
       
   363         * channel list handler observer
       
   364         */
       
   365         MChannelListHandler& iObserver; 
       
   366         TFMRadioCancelScanType iCancelType;
       
   367     };
       
   368 
       
   369 #endif
       
   370 
       
   371 // End of File