internetradio2.0/uisrc/irsettingsview.cpp
changeset 0 09774dfdd46b
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     1 /*
       
     2 * Copyright (c) 2006-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:  View class for Settings
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <akntitle.h>
       
    20 #include "irsettingscontainer.h"
       
    21 #include "irsettingsview.h"
       
    22 #include "ircommon.h"
       
    23 #include "irdebug.h"
       
    24 #include <internetradio.rsg>
       
    25 #include "irui.h"
       
    26 #include "irnetworkcontroller.h"
       
    27 #include <stringloader.h>
       
    28 #include "irviewstack.h"
       
    29 #include "ir.hrh"
       
    30 #include "irnowplayingwrapper.h"
       
    31 
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CIRSettingsView::NewL()
       
    35 // Two-phased constructor.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CIRSettingsView* CIRSettingsView::NewL()
       
    39     {
       
    40  	IRLOG_DEBUG( "CIRSettingsView::NewL" );
       
    41  	CIRSettingsView* self = CIRSettingsView::NewLC();
       
    42     CleanupStack::Pop( self );
       
    43     IRLOG_DEBUG( "CIRSettingsView::NewL - Exiting" );
       
    44     return self;
       
    45     }
       
    46 // ---------------------------------------------------------------------------
       
    47 // Two-phased constructor.
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CIRSettingsView* CIRSettingsView::NewLC( )
       
    51     {
       
    52 	IRLOG_DEBUG( "CIRSettingsView::NewLC - Entering" );
       
    53 	CIRSettingsView* self = new ( ELeave ) CIRSettingsView();
       
    54 	CleanupStack::PushL( self );
       
    55 	self->ConstructL();
       
    56 	IRLOG_DEBUG( "CIRSettingsView::NewLC - Exiting" );
       
    57 	return self;
       
    58     }
       
    59     
       
    60 // ---------------------------------------------------------------------------
       
    61 // Default constructor
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CIRSettingsView::CIRSettingsView()
       
    65     {
       
    66     IRLOG_DEBUG( "CIRSettingsView::CIRSettingsView" );
       
    67     }
       
    68     
       
    69 // ---------------------------------------------------------------------------
       
    70 // Second phase constructor
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CIRSettingsView::ConstructL()
       
    74     {
       
    75 	IRLOG_DEBUG( "CIRSettingsView::ConstructL - Entering" );
       
    76 	BaseConstructL();
       
    77 	IRLOG_DEBUG( "CIRSettingsView::ConstructL - Exiting" );
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // Destructor
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 CIRSettingsView::~CIRSettingsView()
       
    85     {
       
    86     IRLOG_DEBUG( "CIRSettingsView::~CIRSettingsView" );
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // Getter for the view id
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 TUid CIRSettingsView::Id() const
       
    94     {
       
    95     IRLOG_DEBUG( "CIRSettingsView::Id" );
       
    96     return KIRSettingsViewId;
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // View activation
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 void CIRSettingsView::DoActivateL( const TVwsViewId& aPrevViewId, TUid aCustomMessageId,
       
   104 					 const TDesC8& aCustomMessage )
       
   105     {
       
   106 	IRLOG_DEBUG( "CIRSettingsView::DoActivateL - Entering." );
       
   107     CIRUi* appUi = static_cast<CIRUi*>( AppUi() );
       
   108 	CIRSettingsViewBase::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
       
   109 	if(appUi->IsLandscapeOrientation())
       
   110 		{
       
   111 		StatusPane()->SwitchLayoutL(R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL);
       
   112 		}
       
   113 	else
       
   114 		{
       
   115 		StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT);
       
   116 		}
       
   117 	SetTitleL(R_IRAPP_SETTINGS);
       
   118 	if(aCustomMessageId==TUid::Uid(1))
       
   119 		{
       
   120 		return;
       
   121 		}
       
   122 	HandleViewStackL( );
       
   123 	IRLOG_DEBUG( "CIRSettingsView::DoActivateL - Exiting." );
       
   124     }
       
   125     
       
   126 // ---------------------------------------------------------------------------
       
   127 // HandleForegroundEventL()
       
   128 // Handles changes in keyboard focus when an application switches to foreground
       
   129 // ---------------------------------------------------------------------------
       
   130 // 
       
   131      
       
   132 void CIRSettingsView::HandleForegroundEventL( TBool aForeground )
       
   133 {
       
   134 	IRLOG_DEBUG( "CIRSettingsView::HandleForegroundEventL - Entering." );
       
   135 	CIRSettingsViewBase::HandleForegroundEventL(aForeground);
       
   136 	IRLOG_DEBUG( "CIRSettingsView::HandleForegroundEventL - Exiting." );
       
   137 }
       
   138 
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // HandleViewStackL()
       
   142 // Handles the view stack
       
   143 // ---------------------------------------------------------------------------
       
   144 // 
       
   145  
       
   146 void CIRSettingsView::HandleViewStackL( )
       
   147     {
       
   148     IRLOG_DEBUG( "CIRSettingsView::HandleViewStackL - Entering." );
       
   149     CIRUi* appUi = static_cast<CIRUi*>( AppUi() );
       
   150     CIRViewStack& viewStack = appUi->ViewStack();
       
   151     
       
   152     if( viewStack.Peek() == Id() )
       
   153         {
       
   154         viewStack.Pop( );
       
   155         }
       
   156     else if( appUi->ActiveView() != Id() )
       
   157         {
       
   158         viewStack.PushL( appUi->ActiveView() );
       
   159         }
       
   160     else
       
   161         {
       
   162         // DONE
       
   163         }
       
   164     IRLOG_DEBUG( "CIRSettingsView::HandleViewStackL - Exiting." );
       
   165     }
       
   166     
       
   167     
       
   168 // ---------------------------------------------------------------------------
       
   169 // View deactivation
       
   170 // ---------------------------------------------------------------------------
       
   171 //
       
   172 void CIRSettingsView::DoDeactivate()
       
   173     {
       
   174 	IRLOG_DEBUG( "CIRSettingsView::DoDeactivate - Entering." );
       
   175 	CIRSettingsViewBase::DoDeactivate();
       
   176 	IRLOG_DEBUG( "CIRSettingsView::DoDeactivate - Exiting." );
       
   177     }
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // System event handler
       
   181 // ---------------------------------------------------------------------------
       
   182 //
       
   183 
       
   184 void CIRSettingsView::HandleSystemEventL(TIRSystemEventType aEventType)
       
   185     {
       
   186     IRLOG_DEBUG( "CIRSettingsView::HandleSystemEventL - Entering." );
       
   187 	switch (aEventType)
       
   188 		{
       
   189 		case EIRCallActivated:
       
   190 			{
       
   191 			if (iContainer)
       
   192 				{
       
   193 				static_cast<CIRSettingsContainer*>(iContainer)->SetFaded(ETrue);
       
   194 				Cba()->AddCommandSetToStackL(R_IR_SOFTKEYS_EXIT);
       
   195 				Cba()->DrawDeferred();
       
   196 				}
       
   197 			break;
       
   198 			}
       
   199 		case EIRCallDeactivated:
       
   200 			{
       
   201 			if (iContainer)
       
   202 				{
       
   203 				//do not unfade the window if menu or dialog is displayed
       
   204 				if(!AppUi()->IsDisplayingMenuOrDialog() && AppUi()->IsForeground()) 
       
   205 					{
       
   206 					static_cast<CIRSettingsContainer*>(iContainer)->SetFaded(EFalse);
       
   207 					}
       
   208 				Cba()->RemoveCommandFromStack(0, 0);
       
   209 				Cba()->RemoveCommandFromStack(2, EAknSoftkeyExit);
       
   210 				Cba()->DrawDeferred();
       
   211 				}
       
   212 			break;
       
   213 			}
       
   214 		default:
       
   215 			{
       
   216 			break;
       
   217 			}
       
   218 		}
       
   219 		IRLOG_DEBUG( "CIRSettingsView::HandleSystemEventL - Exiting." );
       
   220     }
       
   221 
       
   222 // ---------------------------------------------------------------------------
       
   223 // Command handler.
       
   224 // ---------------------------------------------------------------------------
       
   225 //
       
   226 void CIRSettingsView::HandleCommandL( TInt aCommand )
       
   227     {
       
   228     IRLOG_DEBUG( "CIRSettingsView::HandleCommandL - Entering." );
       
   229     CIRUi* appUi = static_cast<	CIRUi*>(AppUi());
       
   230 
       
   231 		switch ( aCommand )
       
   232 			{
       
   233 			case EGotoNowPlayingViewCmd:
       
   234 				{
       
   235 				appUi->SetHistory(EFalse);
       
   236 				appUi->SavePrevIDL(KIRSettingsViewId, aCommand);
       
   237 				break; 			
       
   238 				}
       
   239 
       
   240 			case EAknSoftkeyBack:
       
   241 		  	case EIRBack:
       
   242 		   		{
       
   243 	    		CIRViewStack& viewStack = appUi->ViewStack();
       
   244 	        	// Check if Back Stepping Service consumes the command.
       
   245 	        	if ( !static_cast< CIRUi* >( AppUi() )->ForwardBackCommandToBsWrapperL() )
       
   246 	                {
       
   247 	                // Command not consumed by Back Stepping Service, handle here.
       
   248 	                appUi->ActivateLocalViewL( viewStack.Peek() );
       
   249 	                }
       
   250 		   		}
       
   251      		break;
       
   252          	
       
   253 			default:
       
   254 				CIRSettingsViewBase::HandleCommandL( aCommand );
       
   255 			break;
       
   256 			}
       
   257 		IRLOG_DEBUG( "CIRSettingsView::HandleCommandL - Exiting." );
       
   258     }
       
   259 
       
   260 // ---------------------------------------------------------------------------
       
   261 // Constructs new container
       
   262 // ---------------------------------------------------------------------------
       
   263 //
       
   264 void CIRSettingsView::CreateContainerL()
       
   265     {
       
   266     	IRLOG_DEBUG( "CIRSettingsView::CreateContainerL - Entering." );
       
   267        	//TInt defaultAccessPoint = 0; Just for PC-Lint commets :: SPP
       
   268    		if( !iContainer )
       
   269 		{
       
   270 		iContainer = CIRSettingsContainer::NewL(*this);
       
   271 		}
       
   272    		IRLOG_DEBUG( "CIRSettingsView::CreateContainerL - Exiting." );
       
   273     }
       
   274 
       
   275 
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // void CIRSettingsView::DynInitMenuPaneL()
       
   279 // Dynamically initialises a menu pane
       
   280 // ---------------------------------------------------------------------------
       
   281 //
       
   282 void CIRSettingsView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
   283 	{
       
   284 	IRLOG_DEBUG( "CIRSettingsView::DynInitMenuPaneL - Entering" );
       
   285 	CIRUi* appUi = static_cast<CIRUi*>( AppUi() );
       
   286 
       
   287 	if(!aMenuPane) User::Leave(KErrNotFound);
       
   288 		{
       
   289 		if(aResourceId == R_IR_MENU_SETTINGS)
       
   290 			{				
       
   291 			// Now Playing option
       
   292 			if(appUi->iNowPlayingWrapper->iPlaying)
       
   293 				{
       
   294 				 aMenuPane->SetItemDimmed(EGotoNowPlayingViewCmd,EFalse);
       
   295 				}
       
   296 			else
       
   297 				{
       
   298 				 aMenuPane->SetItemDimmed(EGotoNowPlayingViewCmd,ETrue);
       
   299 				}
       
   300 			}
       
   301 		}
       
   302 	IRLOG_DEBUG( "CIRSettingsView::DynInitMenuPaneL - Exiting" );
       
   303 	}
       
   304 // ======== GLOBAL FUNCTIONS ========