internetradio2.0/uisrc/irui.cpp
changeset 3 ee64f059b8e1
parent 2 2e1adbfc62af
child 4 3f2d53f144fe
child 5 0930554dc389
equal deleted inserted replaced
2:2e1adbfc62af 3:ee64f059b8e1
     1 /*
       
     2 * Copyright (c) 2009 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 *
       
    16 */
       
    17 
       
    18 /* ---------------------------------------------------------------------------
       
    19 *  Version history:
       
    20 *  Template version:
       
    21 *  <ccm_history>
       
    22 *
       
    23 *  Version: 2, Tue Feb 28 18:00:00 2008 by Rohit/Kranthi
       
    24 *  Ref:
       
    25 *  Added Workaround in CIRUi::ConstructL() to force display of IAP list.
       
    26 *  MIRCtrlCmdObserver::MCtrlCommand() function signature changed (Merged IRv1.0 Engine code changes)
       
    27 *
       
    28 *  </ccm_history>
       
    29 * ============================================================================
       
    30 */
       
    31 
       
    32 /* ---------------------------------------------------------------------------
       
    33 *  Version history:
       
    34 *  Template version:
       
    35 *  <ccm_history>
       
    36 *
       
    37 *  Version: 3, Tue Mar 19 18:00:00 2008 by Rohit
       
    38 *  Ref:
       
    39 *  Implemented change request to display Byte Counter in KB till 0.1 MB, and in MB threrafter
       
    40 *
       
    41 *  </ccm_history>
       
    42 * ============================================================================
       
    43 */
       
    44 #include "internetradioconfigurationflags.hrh"
       
    45 #include <akniconarray.h>
       
    46 #include <aknkeylock.h>
       
    47 #include <aknlayout2scalabledef.h>
       
    48 #include <aknlayoutfont.h>
       
    49 #include <aknnavi.h>
       
    50 #include <aknnavide.h>
       
    51 #include <akntitle.h>
       
    52 #include <aknvolumecontrol.h>
       
    53 #include <alf/alfdisplay.h>
       
    54 #include <alf/alfenv.h>
       
    55 #include <apgcli.h>
       
    56 #include <apgtask.h>
       
    57 #include <bautils.h>
       
    58 #include <featmgr.h>
       
    59 #include <features.hrh>
       
    60 #include <hlplch.h>
       
    61 #include <pstransaction.h>
       
    62 #include <stringloader.h>
       
    63 #include <uriutils.h>
       
    64 #include <aknutils.h>
       
    65 #include <internetradio.rsg>
       
    66 #include <commdb.h>
       
    67 #include <commsdattypesv1_1.h>
       
    68 #include <data_caging_path_literals.hrh>
       
    69 #include <hwrmpowerstatesdkpskeys.h>
       
    70 #include <aknwaitdialog.h>
       
    71 #include <ctsydomainpskeys.h>
       
    72 #include <utf.h>
       
    73 #include <proengfactory.h>
       
    74 #include <mproengnotifyhandler.h>
       
    75 /* no need to change to lower case  */
       
    76 #include <MProEngNotifyHandler.h>
       
    77 #include <profileenginesdkcrkeys.h>
       
    78 
       
    79 //For IAD
       
    80 #include <publicruntimeids.hrh>
       
    81 #ifdef FF_IAUPDATE
       
    82 #include <iaupdate.h>
       
    83 #include <iaupdateparameters.h>
       
    84 #include <iaupdateresult.h>
       
    85 #endif
       
    86 
       
    87 
       
    88 
       
    89 #include "ircommon.h"
       
    90 #include "irui.h"
       
    91 #include "irnowplayingview.h"
       
    92 #include "ir.hrh"
       
    93 #include "irmainview.h"
       
    94 #include "irmaincontainer.h"
       
    95 
       
    96 #include "irautomatedbitrateselection.h"
       
    97 #include "iralarmobserver.h"
       
    98 //#include "irmessageobserver.h"
       
    99 #include "ircommon.h"
       
   100 #include "irctrlcmdobserver.h"
       
   101 #include "irdataproviderconstants.h"
       
   102 #include "irdebug.h"
       
   103 #include "irdocument.h"
       
   104 #include "irfavoritesdb.h"
       
   105 #include "irhistory.h"
       
   106 #include "iriconloader.h"
       
   107 #include "irisdspreset.h"
       
   108 #include "irmediaclient.h"
       
   109 #include "irmetadata.h"
       
   110 #include "irnetworkcontroller.h"
       
   111 #include "irnwinfoobserver.h"
       
   112 #include "irpubsub.h"
       
   113 #include "irsessionlogger.h"
       
   114 #include "irsettings.h"
       
   115 #include "irstreamsource.h"
       
   116 #include "irstreamsourceerrors.h"
       
   117 #include "irui.h"
       
   118 #include "isdsclientdll.h"
       
   119 #include "irbrowsechannelitems.h"
       
   120 #include "irbrowsecatagoryitems.h"
       
   121 #include <internetradio.mbg>
       
   122 #include "irhistorylistview.h"
       
   123 #include "irsearchresultsview.h"
       
   124 #include "irIsdsWrapper.h"
       
   125 #include "irviewstack.h"
       
   126 #include "irstationdirectoryview.h"
       
   127 #include "irstationinformationdata.h"
       
   128 #include "ircategoryview.h"
       
   129 #include "irstationsview.h"
       
   130 #include "irtopstationsview.h"
       
   131 #include "irplsplaylist.h"
       
   132 #include "irplsplaylistitem.h"
       
   133 #include  "irplsview.h"
       
   134 #include "irfirsttimeview.h"
       
   135 #include "iraddmanuallystationview.h"
       
   136 #include "irsystemeventcollector.h" //For system events
       
   137 #include "irnowplayingwrapper.h"
       
   138 #include "ircostwarningview.h"
       
   139 #include "irstationinfoview.h"
       
   140 #include "irdatatransferobserver.h"
       
   141 #include "irdataprovider.h"
       
   142 #include "irhttpdataprovider.h"
       
   143 #include "irlogodownloadengine.h"
       
   144 #include "iriconloader.h"
       
   145 #include "irapplication.h"
       
   146 #include <remconcoreapitarget.h>
       
   147 #include <remconinterfaceselector.h>
       
   148 
       
   149 
       
   150 #ifdef FF_IAUPDATE
       
   151 _LIT( KIRParamExec, "InternetRadio.exe" );
       
   152 #endif
       
   153 
       
   154 #ifdef __IRA_FEATURE_BACKSTEPPING_SERVICE
       
   155 #include "irbacksteppingservicewrapper.h"
       
   156 #endif
       
   157 
       
   158 const TInt KFour = 4;
       
   159 
       
   160 //static variable declaration
       
   161 TInt CIRUi::iFindInMusicStoreCount = 0;
       
   162 
       
   163 
       
   164 //Added by Snigdha for HomeScreen
       
   165 _LIT8( KIRCommandLineActionHandler, "-a" );
       
   166 _LIT8( KIRCommandLineActionHandlerCommandStartNowPlayingView, "startnowplaying" );
       
   167 const TChar KIRCommandLineOptionPrefix = '-';
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // CIRUi::ConstructL(const TRect& aRect)
       
   171 // Second phase constructor
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 void CIRUi::ConstructL()
       
   175 	{
       
   176 	IRLOG_INFO( "CIRUi::ConstructL - Entering" );
       
   177 	CIRApplication *app = static_cast<CIRApplication*>(Document()->Application());
       
   178 	if(app->GetInstanceFlag())
       
   179 		{
       
   180     	BaseConstructL(ENoAppResourceFile);
       
   181     	return;
       
   182 		}
       
   183 	BaseConstructL(EAknEnableSkin);
       
   184 	UpdateLandscapeInformation();
       
   185 	iProfileId=DetermineCurrentProfile();
       
   186 	iSystemEventCollector = CIRSystemEventCollector::NewL();
       
   187 	iSystemEventCollector->AddObserverL( this );
       
   188 
       
   189 	iIRSettings =CIRSettings::OpenL();
       
   190     iSecondInstanceFlag = EFalse;
       
   191 	UpdateSubscriberIdL();
       
   192 
       
   193 	User::LeaveIfError(iFsSession.Connect());
       
   194 	//Instantiate NowPlaying View
       
   195 	iAlfEnv = CAlfEnv::NewL();
       
   196 	// Switch the layout to flat so that Alf will use right layout on Now playing view
       
   197     StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT );
       
   198 	TRect layoutRect;
       
   199 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, layoutRect );
       
   200 	CAlfDisplay& disp = iAlfEnv->NewDisplayL( layoutRect, CAlfEnv::ENewDisplayAsCoeControl );
       
   201 	disp.SetClearBackgroundL( CAlfDisplay::EClearWithSkinBackground );
       
   202 
       
   203 	//Whether The Station is Editiable or not
       
   204 	iIsEditStation = EFalse;
       
   205 	//Index of the Preset to Edit
       
   206 	iEditStationIndex = 0;
       
   207 
       
   208 	TParse parse;
       
   209 	parse.Set( KMIFFILE, &KDC_APP_RESOURCE_DIR, NULL );
       
   210 	iMifFilePath = parse.FullName();
       
   211 	CompleteWithAppPath( iMifFilePath );
       
   212 
       
   213 	//Create the instance of iconprovider
       
   214 	iIconProvider = CIconFileProvider::NewL(iMifFilePath);
       
   215 
       
   216 
       
   217 	// Network Controller Component
       
   218 	iNetworkController = CIRNetworkController::OpenL(this);
       
   219 	iNetworkController->DataTransferTracker().SetObserver( this );
       
   220     iIsOffline=iNetworkController->IsOfflineMode();
       
   221 	// Timer for Network indicator animation
       
   222 	iNetworkIndicatorTimer = CPeriodic::NewL(CPeriodic::EPriorityStandard);
       
   223 
       
   224 	iDialogLauncher = CIRDialogLauncher::NewL();
       
   225 
       
   226 	iFavPresets=CIRFavoritesDb::NewL();
       
   227 
       
   228 	iIsdsWrapper = CIRIsdsWrapper::NewL(*iIRSettings,*iFavPresets);
       
   229 	iNowPlayingWrapper = CIRNowPlayingWrapper::NewL(*this,*iIRSettings,*iIsdsWrapper);
       
   230  	RAknKeyLock keylock;
       
   231     User::LeaveIfError( keylock.Connect() );
       
   232     if ( keylock.IsKeyLockEnabled() )
       
   233         {
       
   234         BringToForeground();
       
   235         }
       
   236     keylock.Close();
       
   237 	// Display access points only if user has accepted Terms & Conditions
       
   238 /*	if( iIRSettings->IsFlagTermsAndConditionsL() )
       
   239 		{
       
   240 		iNetworkController->ChooseAccessPointL();
       
   241 		}
       
   242 */
       
   243 	//playing is terminated by call
       
   244 	iPlayTerminated = EFalse;
       
   245 	//checks whether call is active or not
       
   246 	iCallActive = EFalse;
       
   247 
       
   248 	//Call observer
       
   249 
       
   250 
       
   251 	// Create Channel list view
       
   252 	iLastPlayed = CIRLastPlayedStationInfo::NewL();
       
   253 	iMainView = CIRMainView::NewL();
       
   254 	AddViewL( iMainView );
       
   255 
       
   256 #ifdef __IRA_FEATURE_BACKSTEPPING_SERVICE
       
   257     // Create Back Stepping Service wrapper.
       
   258     iBsWrapper = CIRBackSteppingServiceWrapper::NewL( TUid::Uid( KUIDIRAPP ) );
       
   259 #endif
       
   260 
       
   261 	// Check whether phone is in low memory
       
   262 	TBool bIgnore = CheckAndNotifyLowDiskSpaceL();
       
   263 
       
   264 	iNowPlayingView = CIRNowPlayingView::NewL( *iAlfEnv );
       
   265 	AddViewL( iNowPlayingView );
       
   266 	//Instantiate AlarmObserver
       
   267 	iAlarmObserver = CIRAlarmObserver::NewL(this);
       
   268 	iAlarmObserver->Start();
       
   269 //	iMessageObserver = CIRMessageObserver::NewL(this);
       
   270 	if( iCallActive )
       
   271 		{
       
   272 		IRLOG_WARNING( "CIRUi::ConstructL - Call active during start up " );
       
   273 		}
       
   274 
       
   275 	//Create SearchResults View
       
   276 	iSearchResultsView = CIRSearchResultsView::NewL();
       
   277 	AddViewL( iSearchResultsView );
       
   278 
       
   279 	//Instantiate PublishSubscribe class
       
   280 	iPubSubManager = CIRPubSub::NewL();
       
   281 	iPubSubManager->PublishApplicationRunningStateL(EIRPSApplicationRunning);
       
   282 
       
   283 	// Create history list view
       
   284 	iHistoryListView = CIRHistoryListView::NewL();
       
   285 	AddViewL( iHistoryListView );
       
   286 
       
   287 
       
   288 	// Create Station Directory View
       
   289 	iStationdirView = CIRStationDirectoryView::NewL();
       
   290 	AddViewL( iStationdirView );
       
   291 
       
   292 	// Create Category View
       
   293 	iCategoryView = CIRCategoryView::NewL();
       
   294 	AddViewL( iCategoryView );
       
   295 
       
   296 	// Create Stations View
       
   297 	iStationsView = CIRStationsView::NewL();
       
   298 	AddViewL( iStationsView );
       
   299 
       
   300 	// Create TopStations View
       
   301 	iTopStationsView = CIRTopStationsView::NewL();
       
   302 	AddViewL( iTopStationsView );
       
   303 
       
   304 	iViewStack = CIRViewStack::NewL();
       
   305 
       
   306 	//Create First Time View
       
   307 	iFirstTimeView = CIRFirstTimeView::NewL();
       
   308 	AddViewL(iFirstTimeView);
       
   309 
       
   310 	//Create Add Manually View
       
   311 	iIRAddManually = CIRAddManuallyStationView::NewL( ApplicationRect() );
       
   312 	AddViewL(iIRAddManually);
       
   313 
       
   314 	// Create Settings view
       
   315 	CIRSettingsView* iSettingsView = CIRSettingsView::NewL();
       
   316 	AddViewL( iSettingsView );
       
   317 
       
   318 	//Plsveiw enabled flag set to False by default.
       
   319 	iPlsactivated = EFalse;
       
   320 
       
   321 	if (!iIRSettings->IsFlagTermsAndConditionsL() ||!iIRSettings->IsFlagCostWarningL())
       
   322 		{
       
   323 		iCostWarningView = CIRCostWarningView::NewL(ApplicationRect());
       
   324 		AddViewL( iCostWarningView );
       
   325 		SetDefaultViewL(*iCostWarningView);
       
   326 		}
       
   327 	else
       
   328 		{
       
   329 		if(iStartUpInNowPlayingView)
       
   330 			{
       
   331 		    //iViewStack->PushL(KIRMainChoiceViewID)
       
   332 			SetDefaultViewL(*iNowPlayingView);
       
   333 			iStartUpInNowPlayingView = EFalse;
       
   334 			}
       
   335 		else
       
   336 			{
       
   337 			if (IsFirstTime() && (!IsFlagIfAnyFavL()))
       
   338 				{
       
   339 				SetDefaultViewL(*iFirstTimeView);
       
   340 				}
       
   341 			else
       
   342 				{
       
   343 				SetDefaultViewL( *iMainView );
       
   344 				}
       
   345 			}
       
   346 		}
       
   347 
       
   348 	// Create Station Info view
       
   349 	iStationInfoView = CIRStationInfoView::NewL( ApplicationRect() );
       
   350 	AddViewL( iStationInfoView );
       
   351 
       
   352 	//call is answered
       
   353 	iCallConnected = EFalse;
       
   354 
       
   355 	iNwObserver = CIRNwInfoObserver::NewL(this);
       
   356 
       
   357 	//getting current thread's id
       
   358 	RThread thread;
       
   359 	iCurrentThreadID = thread.Id();
       
   360 	//Handle Background and foreground of the views.
       
   361 	iCoeEnv->AddForegroundObserverL(*this);
       
   362 	// Subscriber for bitrate value
       
   363 	iBitrateSubscriber = CIRPropertyObserver::NewL(*this,
       
   364 	KUidActiveInternetRadioApp,KIRPSBitrate,RProperty::EInt);
       
   365 
       
   366 	// Subscriber for Simultaneous play handling
       
   367 	iMultiplePlayHandler = CIRPropertyObserver::NewL(*this,
       
   368 	KUidActiveInternetRadioApp,KIRPSMultiplePlay,RProperty::EInt);
       
   369 	iMultiplePlayHandler->Subscribe();
       
   370 
       
   371 	//Storing the view to be actiavted when in Background.
       
   372 	iActivationPending = KNullUid;
       
   373 
       
   374 	//Set only when going to backgroung when keypad lock.
       
   375 	iBgWhenLock = EFalse;
       
   376 
       
   377 	//For nowplaying view
       
   378 ///*************testing*****************************
       
   379 
       
   380 	iSelector=CRemConInterfaceSelector::NewL();
       
   381 	iTarget = CRemConCoreApiTarget::NewL( *iSelector, *this );
       
   382 	iSelector->OpenTargetL();
       
   383 	iIsDisconnected = EFalse;
       
   384 	//****************offlineProfile***************//
       
   385 
       
   386 	iNotifyHandler = ProEngFactory::NewNotifyHandlerL();
       
   387     User::LeaveIfError( iNotifyHandler->
       
   388        RequestProfileActivationNotificationsL( *this ));
       
   389 
       
   390 	/**
       
   391      * Initialize feature manager, for IAD
       
   392      */
       
   393     IRRDEBUG2("CIRUi::ConstructL - Initializing FeatureManager Lib", KNullDesC);
       
   394     FeatureManager::InitializeLibL();
       
   395     iFeatureManagerInitialized = ETrue;
       
   396     IRRDEBUG2("CIRUi::ConstructL - Initialed FeatureManager Lib", KNullDesC);
       
   397 	IRRDEBUG2("CIRUi::ConstructL - Checking feature KFeatureIdIAUpdate", KNullDesC);
       
   398 #ifdef FF_IAUPDATE
       
   399     if (FeatureManager::FeatureSupported( KFeatureIdIAUpdate))
       
   400 		{
       
   401 		IRRDEBUG2("CIRUi::ConstructL - KFeatureIdIAUpdate Supporting", KNullDesC);
       
   402 		iUpdate = CIAUpdate::NewL(*this);
       
   403 		IRRDEBUG2("CIRUi::ConstructL  - CIAUpdate NewL", KNullDesC);
       
   404 
       
   405        	iParameters = CIAUpdateParameters::NewL();
       
   406         IRRDEBUG2("CIRUi::ConstructL  - CIAUpdateParameters::NewL()", KNullDesC);
       
   407 
       
   408         // Use SIS package UID
       
   409         iParameters->SetUid( TUid::Uid( KUIDIRAPP) );
       
   410         IRRDEBUG2("CIRUi::ConstructL  - Setting Package Uid", KNullDesC);
       
   411 
       
   412         /**
       
   413          * We want InternetRadio.exe to be started after update is finished
       
   414          */
       
   415         iParameters->SetCommandLineExecutableL( KIRParamExec );
       
   416         IRRDEBUG2("CIRUi::ConstructL - Setting CommandLineExecutableL", KNullDesC);
       
   417 
       
   418         iUpdate->CheckUpdates(*iParameters );
       
   419         IRRDEBUG2("CIRUi::ConstructL  - After CheckUpdates", KNullDesC);
       
   420 
       
   421         }
       
   422 #endif // FF_IAUPDATE
       
   423 
       
   424 
       
   425 		iControlEventObserver = CIRControlEventObserver::
       
   426     	NewL( *this, KUidActiveInternetRadioApp, KIRPSControlSetPlayState ,
       
   427     	RProperty::EInt);
       
   428 
       
   429     	iControlEventObserver->SecondConstructL();
       
   430 	IRLOG_DEBUG( "CIRUi::ConstructL - Exiting." );
       
   431 	}
       
   432 
       
   433 // ---------------------------------------------------------------------------
       
   434 // Returns pointer to the view stack.
       
   435 // ---------------------------------------------------------------------------
       
   436 //
       
   437 CIRViewStack& CIRUi::ViewStack()
       
   438     {
       
   439     IRLOG_INFO( "CIRUi::ViewStack" );
       
   440     return *iViewStack;
       
   441     }
       
   442 // ---------------------------------------------------------------------------
       
   443 // CIRUi::ForwardBackCommandToBSWrapperL
       
   444 // ---------------------------------------------------------------------------
       
   445 //
       
   446 TBool CIRUi::ForwardBackCommandToBsWrapperL()
       
   447 	{
       
   448 	IRLOG_DEBUG( "CIRUi::ForwardBackCommandToBsWrapperL - Entering" );
       
   449 	TBool retVal( EFalse ); // By default BS Service doesn't handle back command
       
   450 
       
   451 #ifdef __IRA_FEATURE_BACKSTEPPING_SERVICE
       
   452 	// Get active view UID.
       
   453 	TVwsViewId activeViewId; // Contains both view UID and app UID
       
   454 	GetActiveViewId( activeViewId );
       
   455 
       
   456 	// Let Back Stepping Service handle the event.
       
   457 	retVal = iBsWrapper->HandleBackCommandL( activeViewId );
       
   458 #endif
       
   459 	IRLOG_DEBUG( "CIRUi::ForwardBackCommandToBsWrapperL - Exiting" );
       
   460 	return retVal;
       
   461 	}
       
   462 
       
   463 
       
   464 // ---------------------------------------------------------------------------
       
   465 // CIRUi::ActiveView
       
   466 // ---------------------------------------------------------------------------
       
   467 //
       
   468 TUid CIRUi::ActiveView() const
       
   469     {
       
   470     IRLOG_INFO( "CIRUi::ActiveView" );
       
   471     return iView ? iView->Id() : KNullUid;
       
   472     }
       
   473 
       
   474 
       
   475 // ---------------------------------------------------------------------------
       
   476 // CIRUi::CIRUi()
       
   477 // Default constructor
       
   478 // ---------------------------------------------------------------------------
       
   479 //
       
   480 CIRUi::CIRUi()
       
   481 	{
       
   482 	IRLOG_DEBUG( "CIRUi::CIRUi - Entering" );
       
   483 	iIndex = 0;
       
   484 	iSelect = ETrue;
       
   485 	iCount = 0;
       
   486 	iCurrentPresetId = 0;
       
   487 	iSelectedBrowsingCategory = KErrNotFound;
       
   488 	iFeatureManagerInitialized = EFalse;
       
   489 	iMainViewLaunch = EFalse ;
       
   490 	iDialogLauncher = NULL;
       
   491 	iStartUpInNowPlayingView = EFalse;
       
   492 	IRLOG_DEBUG( "CIRUi::CIRUi - Exiting" );
       
   493 	}
       
   494 
       
   495 // ---------------------------------------------------------------------------
       
   496 // CIRUi::~CIRUi()
       
   497 // Destructor
       
   498 // ---------------------------------------------------------------------------
       
   499 //
       
   500 CIRUi::~CIRUi()
       
   501 	{
       
   502 	IRLOG_INFO( "CIRUi::~CIRUi - Entering" );
       
   503 
       
   504 	iStationsViewTitleString.Close();
       
   505 	if(iSystemEventCollector)
       
   506 		{
       
   507 		iSystemEventCollector->RemoveObserver( this );
       
   508 		delete iSystemEventCollector; iSystemEventCollector=NULL;
       
   509 		}
       
   510 	//singleton deletion
       
   511 	if ( iIRSettings )
       
   512 		{
       
   513 		iIRSettings->Close();
       
   514 		}
       
   515 
       
   516 #ifdef __IRA_FEATURE_BACKSTEPPING_SERVICE
       
   517         // Back Stepping FW is used, delete wrapper.
       
   518         delete iBsWrapper;
       
   519 #endif
       
   520 
       
   521 	delete iViewStack;
       
   522 	delete iIconProvider;
       
   523 	iFsSession.Close();
       
   524 	delete iAlarmObserver;
       
   525 //	delete iMessageObserver;
       
   526 	delete iAlfEnv;
       
   527 	if(iIsdsWrapper)
       
   528 		{
       
   529 		delete iIsdsWrapper;
       
   530 		iIsdsWrapper = NULL;
       
   531 		}
       
   532 	iPlsLength.Close();
       
   533 	if(iLastPlayed)
       
   534 		{
       
   535 		delete iLastPlayed;
       
   536 		iLastPlayed = NULL;
       
   537 		}
       
   538 	if(iNowPlayingWrapper)
       
   539 		{
       
   540 		delete iNowPlayingWrapper;
       
   541 		iNowPlayingWrapper = NULL;
       
   542 		}
       
   543 	delete iFavPresets;
       
   544 	delete iSettingsView;
       
   545 	delete iNwObserver;
       
   546 	delete iPubSubManager;
       
   547 
       
   548 	if (iNetworkController)
       
   549 		{
       
   550 		iNetworkController->Close();
       
   551 		//iNetworkController = NULL
       
   552 		}
       
   553 	// Cancel the network indicator timer
       
   554 	if( iNetworkIndicatorTimer )
       
   555 		{
       
   556 		if( iNetworkIndicatorTimer->IsActive() )
       
   557 			{
       
   558 			iNetworkIndicatorTimer->Cancel();
       
   559 			}
       
   560 		delete iNetworkIndicatorTimer;
       
   561 		}
       
   562 	delete iBitrateSubscriber;
       
   563 	delete iMultiplePlayHandler;
       
   564 
       
   565 	iURLs.ResetAndDestroy();
       
   566 	iURLs.Close();
       
   567 	iIsPresetSaved.Close();
       
   568 	iPlsPresetSaved.Close();
       
   569 	delete iSelector;
       
   570 
       
   571 #ifdef FF_IAUPDATE
       
   572 	delete iUpdate;
       
   573     delete iParameters;
       
   574 #endif
       
   575 
       
   576     if ( iFeatureManagerInitialized )
       
   577     	{
       
   578         /**
       
   579          *  We can safely call UnInitializeLib as we have really intialized it
       
   580          */
       
   581         FeatureManager::UnInitializeLib();  // Decreases ref.count
       
   582         }
       
   583 delete iNotifyHandler;
       
   584 
       
   585 	if( iDialogLauncher )
       
   586 		{
       
   587 		delete iDialogLauncher;
       
   588 		iDialogLauncher = NULL;
       
   589 		}
       
   590 
       
   591 	if(iControlEventObserver)
       
   592 		{
       
   593 		delete iControlEventObserver;
       
   594 		iControlEventObserver = NULL;
       
   595 		}
       
   596 
       
   597 	IRLOG_DEBUG( "CIRUi::~CIRUi - Exiting" );
       
   598 	}
       
   599 
       
   600 // ---------------------------------------------------------------------------
       
   601 // CIRUi::HandleCommandL(TInt aCommand)
       
   602 // Command handling function
       
   603 // ---------------------------------------------------------------------------
       
   604 //
       
   605 void CIRUi::HandleCommandL(TInt aCommand)
       
   606 	{
       
   607 	IRLOG_INFO2( "CIRUi::HandleCommandL (%d) ", aCommand );
       
   608 	switch(aCommand)
       
   609 		{
       
   610 		case EIRDelayedPlayStation:
       
   611 			{
       
   612 			if ( !CheckAndNotifyLowDiskSpaceL() )
       
   613 				{
       
   614 				iNowPlayingWrapper->DoPlayL();
       
   615 				}
       
   616 			}
       
   617 		break;
       
   618 		// Activate the AddStationManually View
       
   619 		case EAddStationManuallyCmd:
       
   620 			{
       
   621 			if ( !CheckAndNotifyLowDiskSpaceL() )
       
   622 				{
       
   623 				if ( IsForeground() || iBgWhenLock)
       
   624 					{
       
   625 					ActivateLocalViewL(KIRAddManuallyStationViewID);
       
   626 					iActivationPending = KNullUid ;
       
   627 					}
       
   628 				else
       
   629 					{
       
   630 					iActivationPending = KIRAddManuallyStationViewID;
       
   631 					}
       
   632 				}
       
   633 		}
       
   634 		break;
       
   635 		//Go to now playing view
       
   636 		case EGotoNowPlayingViewCmd:
       
   637 			{
       
   638 			if( ( iNowPlayingView ) && ( !iNowPlayingView->HasBeenActivated() ) )
       
   639 				{
       
   640 	    		// For the case that NP view is force-activated,
       
   641 	    		// but nothing should actually be played yet.
       
   642 	    	    *iNowPlayingWrapper->iNowPlayingPreset = *iLastPlayed->iLastPlayedStation;
       
   643 				}
       
   644 			if(iHistory)
       
   645 				{
       
   646 					ActivateLocalViewL( KIRNowPlayingViewID,
       
   647 					KHistoryLaunch,KIRNowPlayingViewCustomMessagePlayAfterActivation);
       
   648 
       
   649 				}
       
   650 			else if(iMainViewLaunch)
       
   651 				{
       
   652 				    _LIT8(KNull,"");
       
   653 					ActivateLocalViewL( KIRNowPlayingViewID,KNowPlayingFrmMainView,KNull);
       
   654 					iMainViewLaunch = EFalse ;
       
   655 
       
   656 				}
       
   657 			else
       
   658 			{
       
   659 			if ( IsForeground() || iBgWhenLock )
       
   660 					{
       
   661 					ActivateLocalViewL(KIRNowPlayingViewID);
       
   662 					iActivationPending = KNullUid ;
       
   663 					}
       
   664 				else
       
   665 					{
       
   666 					iActivationPending = KIRNowPlayingViewID;
       
   667 			}
       
   668 				}
       
   669 			}
       
   670 			break;
       
   671 		//violates PC lint  Warning 616
       
   672 		case EEikCmdExit:
       
   673 		case EExitCmd:  //lint -fallthrough
       
   674 		case EIRExit:
       
   675 		case EAknSoftkeyExit:
       
   676 			{
       
   677 			//This API is not there in 3.0
       
   678 			//Removing all the local item definitions set using setlocalitemdefL()
       
   679 			#ifndef __SERIES60_30__
       
   680 			AknsUtils::SkinInstance()->RemoveLocalItemDefs();
       
   681 			#endif
       
   682 			//needed only for 3.2
       
   683 			//part of active idle
       
   684 			#ifdef __SERIES60_32__
       
   685 			if ( iPubSubManager )
       
   686 				{
       
   687 				iPubSubManager->PublishApplicationRunningStateL
       
   688 				(EIRPSApplicationClosing);
       
   689 				}
       
   690 			#endif
       
   691 			if(iNowPlayingWrapper)
       
   692 			{
       
   693 			if( iNowPlayingWrapper->GetSessionStartState() )
       
   694 				{
       
   695 				TTerminationStatus terminationstatus = EUserTerminated;
       
   696 				iNowPlayingWrapper->GetReportGeneratorInstance()->UpdateTerminatedBy(terminationstatus);
       
   697 				iNowPlayingWrapper->GetReportGeneratorInstance()->SessionEndL(EFalse);
       
   698 				iNowPlayingWrapper->SetSessionStartState(EFalse);
       
   699 				}
       
   700 				}
       
   701 			Exit();
       
   702 			}
       
   703 		break;
       
   704 		default:
       
   705 			{
       
   706 			//No implementation
       
   707 			}
       
   708 		break;
       
   709 		}
       
   710 	IRLOG_DEBUG( "CIRUi::HandleCommandL - Exiting" );
       
   711 	}
       
   712 
       
   713 
       
   714 // ---------------------------------------------------------------------------
       
   715 // CIRUi::IRHandleCommandL().
       
   716 // Command handling function
       
   717 // Saves currently selected index from the listbox
       
   718 // ---------------------------------------------------------------------------
       
   719 //
       
   720 void CIRUi::IRHandleCommandL(TInt aIndex,TInt aCommand)
       
   721 	{
       
   722 	IRLOG_INFO3( "CIRUi::IRHandleCommandL (aIndex=%d, aCommand=%d)", aIndex, aCommand );
       
   723 	//Save the currently selected index from the listbox
       
   724 	iIndex = aIndex;
       
   725 	HandleCommandL(aCommand);
       
   726 	IRLOG_DEBUG( "CIRUi::IRHandleCommandL - Exiting" );
       
   727 	}
       
   728 
       
   729 // ---------------------------------------------------------------------------
       
   730 // CIRUi::SavePrevIDL(..).
       
   731 // Saves the previous View's Id
       
   732 // ---------------------------------------------------------------------------
       
   733 //
       
   734 void CIRUi::SavePrevIDL(const TUid& aPrevID,TInt aCommand)
       
   735 	{
       
   736 	IRLOG_DEBUG( "CIRUi::SavePrevIDL - Entering" );
       
   737 	//Save the previous view iD of NowPlaying View
       
   738 	iNPPrevViewId = aPrevID;
       
   739 	HandleCommandL(aCommand);
       
   740 	IRLOG_DEBUG( "CIRUi::SavePrevIDL - Exiting." );
       
   741 	}
       
   742 
       
   743 // ---------------------------------------------------------------------------
       
   744 // CIRUi::HandleStatusPaneSizeChange().
       
   745 // Handles resource changes, called by UI framework
       
   746 // ---------------------------------------------------------------------------
       
   747 //
       
   748 void CIRUi::HandleStatusPaneSizeChange()
       
   749 	{
       
   750 	IRLOG_INFO( "CIRUi::HandleStatusPaneSizeChange" );
       
   751 
       
   752 	}
       
   753 
       
   754 // ---------------------------------------------------------------------------
       
   755 // CIRUi::HandleKeyEventL().
       
   756 // Handles key events.
       
   757 // ---------------------------------------------------------------------------
       
   758 //
       
   759 TKeyResponse CIRUi::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/
       
   760 	,TEventCode /*aType*/)
       
   761  	{
       
   762  	IRLOG_DEBUG( "CIRUi::HandleKeyEventL" );
       
   763 	return EKeyWasNotConsumed;
       
   764  	}
       
   765 
       
   766 
       
   767 // ---------------------------------------------------------------------------
       
   768 // CIRUi::GetMifFilePath().
       
   769 // Returns the full path of mif file.
       
   770 // ---------------------------------------------------------------------------
       
   771 //
       
   772 TFileName CIRUi::GetMifFilePath() const
       
   773 	{
       
   774     IRLOG_DEBUG( "CIRUi::GetMifFilePath" );
       
   775     return iMifFilePath;
       
   776 	}
       
   777 
       
   778 // ---------------------------------------------------------------------------
       
   779 // CIRUi::GetPrivatePath().
       
   780 // Returns the full path of mif file. .
       
   781 // ---------------------------------------------------------------------------
       
   782 //
       
   783 TFileName CIRUi::GetPrivatePath() const
       
   784 	{
       
   785 	IRLOG_DEBUG( "CIRUi::GetPrivatePath" );
       
   786     return iIRSettings->PrivatePath();
       
   787 	}
       
   788 
       
   789 
       
   790 
       
   791 // ---------------------------------------------------------------------------
       
   792 // CIRUi::OpenFileL().
       
   793 // Open the file using Document's instance
       
   794 // ---------------------------------------------------------------------------
       
   795 //
       
   796 void CIRUi::OpenFileL(const TDesC& aFileName)
       
   797 	{
       
   798 	IRLOG_DEBUG( "CIRUi::OpenFileL - Entering" );
       
   799 	// File changed. Open new file with documents OpenFileL method.
       
   800 	iSecondInstanceFlag=ETrue;
       
   801 	CIRDocument* doc = static_cast<CIRDocument*> (Document());
       
   802 	doc->OpenFileL( ETrue, aFileName, iEikonEnv->FsSession() );
       
   803 	IRLOG_DEBUG( "CIRUi::OpenFileL - Exiting" );
       
   804 	}
       
   805 
       
   806 // ---------------------------------------------------------------------------
       
   807 // CIRUi::IsEmbedded().
       
   808 // ---------------------------------------------------------------------------
       
   809 //
       
   810 TBool CIRUi::IsEmbedded() const
       
   811     {
       
   812     IRLOG_DEBUG( "CIRUi::IsEmbedded" );
       
   813     return iEikonEnv->StartedAsServerApp();
       
   814     }
       
   815 
       
   816 
       
   817 // ---------------------------------------------------------------------------
       
   818 // CIRUi::UpdateCurrentNetwork
       
   819 // Updates the current network status
       
   820 // ---------------------------------------------------------------------------
       
   821 //
       
   822 void CIRUi::UpdateCurrentNetwork(const TDesC& aCurrentNetworkMCC
       
   823 	,const TDesC& aCurrentNetworkMNC)
       
   824 	{
       
   825 	IRLOG_INFO3( "CIRUi::UpdateCurrentNetwork (MCC=%S, MNC=%S)", &aCurrentNetworkMCC, &aCurrentNetworkMNC );
       
   826 	#ifdef __WINS__
       
   827 	iCurrentNetwork.Copy(aCurrentNetworkMCC);
       
   828 	iCurrentNetwork.Append(aCurrentNetworkMNC);
       
   829 	iCurrentOperator = 0;
       
   830 	#else
       
   831 	//updates the current network MCC+MNC
       
   832 	iCurrentNetwork.Copy(aCurrentNetworkMCC);
       
   833 	iCurrentNetwork.Append(aCurrentNetworkMNC);
       
   834 	TLex currentnetwork(iCurrentNetwork);
       
   835 	TInt error = currentnetwork.Val(iCurrentOperator);
       
   836 	if(error)
       
   837 		{
       
   838 		IRLOG_ERROR2( "CIRUi::UpdateCurrentNetwork - extracting operator value failed (error=%d)", error );
       
   839 		iCurrentOperator = 0;
       
   840 		}
       
   841 	#endif
       
   842 	iNowPlayingWrapper->GetReportGeneratorInstance()->UpdateCurrentBrowseNetwork(iCurrentOperator);
       
   843 	IRLOG_DEBUG( "CIRUi::UpdateCurrentNetwork - Exiting." );
       
   844 	}
       
   845 
       
   846 // ---------------------------------------------------------------------------
       
   847 // CIRUi::UpdateHomeNetwork
       
   848 // Updates the home network status
       
   849 // ---------------------------------------------------------------------------
       
   850 //
       
   851 void CIRUi::UpdateHomeNetwork(const TDesC& aCurrentNetworkMCC,
       
   852 	const TDesC& aCurrentNetworkMNC)
       
   853 	{
       
   854 	IRLOG_INFO3( "CIRUi::UpdateHomeNetwork (MCC=%S, MNC=%S)", &aCurrentNetworkMCC, &aCurrentNetworkMNC );
       
   855 	#ifdef __WINS__
       
   856 	iHomeNetwork.Copy(aCurrentNetworkMCC);
       
   857 	iHomeNetwork.Append(aCurrentNetworkMNC);
       
   858 	iHomeOperator = 0;
       
   859 	#else
       
   860 	//updates the home network MCC+MNC
       
   861 	iHomeNetwork.Copy(aCurrentNetworkMCC);
       
   862 	iHomeNetwork.Append(aCurrentNetworkMNC);
       
   863 	TLex currentnetwork(iHomeNetwork);
       
   864 	TInt error = currentnetwork.Val(iHomeOperator);
       
   865 	if(error)
       
   866 		{
       
   867 		IRLOG_ERROR2( "CIRUi::UpdateHomeNetwork - extracting operator value failed (error=%d)", error );
       
   868 		iHomeOperator = 0;
       
   869 		}
       
   870 
       
   871 	#endif
       
   872 	IRLOG_DEBUG( "CIRUi::UpdateHomeNetwork - Exiting." );
       
   873 	}
       
   874 
       
   875 // ---------------------------------------------------------------------------
       
   876 // CIRUi::SetCurrentNetworkType(..)
       
   877 // Sets the Current Network Type
       
   878 // ---------------------------------------------------------------------------
       
   879 //
       
   880 void CIRUi::SetCurrentNetworkType()
       
   881 	{
       
   882 	IRLOG_DEBUG( "CIRUi::SetCurrentNetworkType - Entering" );
       
   883 	switch(iNetworkController->IdentifyConnectionType())
       
   884 		{
       
   885 		case EGprs://GPRS
       
   886 			{
       
   887 			iConnectionType.Copy(KGprs);
       
   888 			//start monitoring network for operator change
       
   889 			iNwObserver->IRStartNwMonitor();
       
   890 			}
       
   891 		break;
       
   892 
       
   893 		case EEdge: // Edge
       
   894 			{
       
   895 			iConnectionType.Copy(KEdge);
       
   896 			//start monitoring network for operator change
       
   897 			iNwObserver->IRStartNwMonitor();
       
   898 			}
       
   899 		break;
       
   900 		case EWcdma:
       
   901 		case ECdma2000:
       
   902 			{
       
   903 			iConnectionType.Copy(K3G);
       
   904 			//start monitoring network for operator change
       
   905 			iNwObserver->IRStartNwMonitor();
       
   906 			}
       
   907 		break;
       
   908 
       
   909 		case EWiFi:
       
   910 			{
       
   911 			iConnectionType.Copy(KWiFi);
       
   912 			//start monitoring network for operator change
       
   913 			iNwObserver->IRStartNwMonitor();
       
   914 			}
       
   915 		break;
       
   916 		}
       
   917 	iNowPlayingWrapper->GetReportGeneratorInstance()->UpdateConnectionType(iConnectionType);
       
   918 	IRLOG_DEBUG( "CIRUi::SetCurrentNetworkType - Exiting." );
       
   919 	}
       
   920 
       
   921 // ---------------------------------------------------------------------------
       
   922 // CIRUi::GetCurrentNetworkType(..)
       
   923 // Returns the Current Network Type
       
   924 // ---------------------------------------------------------------------------
       
   925 //
       
   926 TDesC& CIRUi::GetCurrentNetworkType()
       
   927 {
       
   928 IRLOG_DEBUG( "CIRUi::GetCurrentNetworkType - Entering" );
       
   929 IRLOG_DEBUG( "CIRUi::GetCurrentNetworkType - Exiting." );
       
   930 return iConnectionType;
       
   931 }
       
   932 // CIRUi::MrccatoCommand()
       
   933 // This is call back function which observes hardware key events
       
   934 // ---------------------------------------------------------------------------
       
   935 //
       
   936 void CIRUi::MrccatoCommand(TRemConCoreApiOperationId aOperationId,
       
   937 	TRemConCoreApiButtonAction aButtonAct)
       
   938 	{
       
   939 	IRLOG_INFO3( "CIRUi::MrccatoCommand(aOperationId=%d, aButtonAct=%d)", aOperationId, aButtonAct );
       
   940 
       
   941 	IRLOG_DEBUG2("CIRUi::MrccatoCommand - MrccatoCommand()",
       
   942 	KNullDesC );
       
   943 	switch( aOperationId )
       
   944 		{
       
   945 
       
   946 		case ERemConCoreApiVolumeUp:   // -fall through
       
   947 		case ERemConCoreApiVolumeDown:
       
   948 			{
       
   949 			if(iNowPlayingWrapper->iPlaying ||iView->Id() == KIRNowPlayingViewID )
       
   950 				{
       
   951 				//volume is increased or reduced
       
   952 				if ( (ERemConCoreApiVolumeUp == aOperationId )|| (aOperationId == ERemConCoreApiVolumeDown))
       
   953 					{
       
   954 
       
   955 					TRAPD(err,iNowPlayingView->HandleMediaKeysL(aOperationId,aButtonAct);)
       
   956 					if(err!=KErrNone)
       
   957 						{
       
   958 						return;
       
   959 						}
       
   960 					}
       
   961 				}
       
   962 			}
       
   963 		break;
       
   964 		case ERemConCoreApiStop:
       
   965 			{
       
   966 			if(iNowPlayingView)
       
   967 				{
       
   968 				iNowPlayingView->MrccatoCommand(ERemConCoreApiStop,aButtonAct);
       
   969 				}
       
   970 			}
       
   971 		break;
       
   972 
       
   973 		default:
       
   974 		if (iNowPlayingView )
       
   975 			{
       
   976 			iNowPlayingView->MrccatoCommand( aOperationId, aButtonAct );
       
   977 			}
       
   978 		break;
       
   979 
       
   980 		}
       
   981 	IRLOG_DEBUG( "CIRUi::MrccatoCommand - Exiting." );
       
   982 	}
       
   983 
       
   984 // ---------------------------------------------------------
       
   985 // CIRUi::MrccatoPlay()
       
   986 // ---------------------------------------------------------
       
   987 //
       
   988 void CIRUi::MrccatoPlay(TRemConCoreApiPlaybackSpeed aSpeed, TRemConCoreApiButtonAction aButtonAct)
       
   989     {
       
   990     IRLOG_INFO3( "CIRUi::MrccatoPlay(aSpeed=%d, aButtonAct=%d)", aSpeed, aButtonAct );
       
   991 
       
   992     if( iView->Id() != KIRCostWarningViewId )
       
   993         {
       
   994         if(iNowPlayingView )
       
   995             {
       
   996             iNowPlayingView->MrccatoPlay( aSpeed, aButtonAct );
       
   997             }
       
   998         }
       
   999 
       
  1000     IRLOG_DEBUG( "CIRUi::MrccatoPlay - Exiting." );
       
  1001     }
       
  1002 
       
  1003 
       
  1004 // ---------------------------------------------------------------------------
       
  1005 // CIRUi::IsCallActive()
       
  1006 // Function returns whether the call is active or not
       
  1007 // ---------------------------------------------------------------------------
       
  1008 //
       
  1009 TBool CIRUi::IsCallActive()
       
  1010 	{
       
  1011 	IRLOG_DEBUG( "CIRUi::IsCallActive" );
       
  1012 	//returns whether call is active or not
       
  1013 	return iCallActive;
       
  1014 	}
       
  1015 
       
  1016 //-----------------------------------------------------------------------------
       
  1017 // GetWrapperInstance()
       
  1018 // Returns the instance of the IsdsWrapper class
       
  1019 //-----------------------------------------------------------------------------
       
  1020 CIRIsdsWrapper* CIRUi::GetWrapperInstance()
       
  1021 	{
       
  1022 	IRLOG_DEBUG( "CIRUi::GetWrapperInstance" );
       
  1023 	return iIsdsWrapper;
       
  1024 	}
       
  1025 
       
  1026 //-----------------------------------------------------------------------------
       
  1027 // GetNowPlayingWrapperInstance()
       
  1028 // Returns the instance of the NowPlayingWrapper class
       
  1029 //-----------------------------------------------------------------------------
       
  1030 CIRNowPlayingWrapper* CIRUi::GetNowPlayingWrapperInstance()
       
  1031 	{
       
  1032 	IRLOG_DEBUG( "CIRUi::GetNowPlayingWrapperInstance" );
       
  1033 	return iNowPlayingWrapper;
       
  1034 	}
       
  1035 // ---------------------------------------------------------------------------
       
  1036 // CIRUi::GetSystemEventCollector()
       
  1037 // returns the iSystemEventCollector
       
  1038 // ---------------------------------------------------------------------------
       
  1039 //
       
  1040 CIRSystemEventCollector& CIRUi::SystemEventCollector()
       
  1041     {
       
  1042     IRLOG_DEBUG( "CIRUi::SystemEventCollector" );
       
  1043     return *iSystemEventCollector;
       
  1044     }
       
  1045 
       
  1046 // ---------------------------------------------------------------------------
       
  1047 // CIRUi::IRNetworkEventL()
       
  1048 // network connection events
       
  1049 // ---------------------------------------------------------------------------
       
  1050 //
       
  1051 void CIRUi::IRNetworkEventL(TIRNetworkEvent aEvent)
       
  1052 	{
       
  1053 	IRLOG_INFO2("CIRUi::IRNetworkEventL( aEvent=%d)", aEvent );
       
  1054     IRRDEBUG2("CIRUi::IRNetworkEventL - Entering(aEvent=%d)", aEvent );
       
  1055 	switch(aEvent)
       
  1056 		{
       
  1057 		case ENetworkConnectionConnecting:
       
  1058 		    {
       
  1059 			// This value indicates the network icon blink duration
       
  1060 		    const TInt KNetworkIndicatorAnimation = 500000;
       
  1061 			// This value indicates the network icon blink duration
       
  1062             TTimeIntervalMicroSeconds32 interval(KNetworkIndicatorAnimation);
       
  1063             // Cancel the network indicator timer
       
  1064             iNetworkIndicatorTimer->Cancel();
       
  1065             // Start the network animation timer
       
  1066             iNetworkIndicatorTimer->Start(interval,interval,TCallBack(
       
  1067 			CIRUi::NetworkAnimationTimerExpired,this));
       
  1068 		    }
       
  1069 		    break;
       
  1070 
       
  1071 		case ENetworkConnectionEstablished:
       
  1072 			{
       
  1073             iNetworkIndicatorTimer->Cancel();
       
  1074             iIsDisconnected = EFalse;
       
  1075 			SetCurrentNetworkType();
       
  1076 			iIsdsWrapper->GetISDSInstance()->IRGetIRIDL();
       
  1077 			iNetworkController->NotifyActiveNetworkObserversL(ENetworkConnectionEstablished);
       
  1078 			}
       
  1079 		break;
       
  1080 
       
  1081 		case ENetworkConnectionDisconnected:
       
  1082 			{
       
  1083 			IRRDEBUG2("IRNetworkEventL Network DisConnected",KNullDesC);
       
  1084 
       
  1085 			//network got disconnected
       
  1086 				iNetworkIndicatorTimer->Cancel();
       
  1087 				//connection status is reset in network controller
       
  1088 				iNetworkController->ResetConnectionStatus();
       
  1089 	            if ( iIsdsWrapper->GetISDSInstance() )
       
  1090 	                {
       
  1091 	                if(iIsdsWrapper->GetListenRequest()||(iNowPlayingWrapper->iSyncPreset))
       
  1092 				  		{
       
  1093 						iNowPlayingWrapper->DestroyWaitDialogL();
       
  1094 				  		}
       
  1095 	                iIsdsWrapper->DestroyWaitDialogL();
       
  1096            			iIsdsWrapper->GetISDSInstance()->IRISDSCancelRequest();
       
  1097 	 			    iIsdsWrapper->GetISDSInstance()->ReleaseResources();
       
  1098 	                }
       
  1099             	if(iNowPlayingWrapper->iPlaying && (!iNowPlayingWrapper->IsProgress()))
       
  1100 					{
       
  1101 					iNowPlayingWrapper->StopNow();
       
  1102 					}
       
  1103 				else
       
  1104 					{
       
  1105 			        if(iNowPlayingWrapper->GetConnectToServerState() && !iNowPlayingWrapper->IsProgress())
       
  1106 						{
       
  1107 						iNowPlayingWrapper->CancelNetworkRequestL();
       
  1108 						iNowPlayingWrapper->DestroyWaitDialogL();
       
  1109 						}
       
  1110 					//player is stopped
       
  1111 					if( iNowPlayingWrapper->IsProgress() )
       
  1112 						{
       
  1113 						//if in progress bar view, progress bar is cancelled
       
  1114 						iNowPlayingWrapper->ProgressBarCancel();
       
  1115 						iNowPlayingWrapper->DestroyWaitDialogL();
       
  1116 						}
       
  1117 					}
       
  1118 
       
  1119 				iIsDisconnected = ETrue;
       
  1120 				}
       
  1121 
       
  1122 
       
  1123 		break;
       
  1124 
       
  1125 		case EDisplayNetworkMessageNoConnectivity:
       
  1126 			{
       
  1127 			if(iNowPlayingView->iContainer && iNowPlayingView->GetRequestPendingForNextOrPreV())
       
  1128 				{
       
  1129 				 	iNowPlayingView->SetRockerIndex(
       
  1130 					iNowPlayingView->GetPreviousIndex());
       
  1131 				}
       
  1132 			//display a message on no network connectivity
       
  1133 			DisplayErrorNoteL(R_IRAPP_NW_NOCONN_ERROR);
       
  1134 			iIsDisconnected = ETrue;
       
  1135 
       
  1136 			}
       
  1137 		break;
       
  1138 
       
  1139 		case EDisplayOfflineMode:
       
  1140 			{
       
  1141 			//if offline mode message is displayed
       
  1142 			//DisplayErrorNoteL(R_IRAPP_INFONOTE_OFFLINE)
       
  1143 			}
       
  1144 		break;
       
  1145 
       
  1146 		case EDisplayNoAccessPointsDefined:
       
  1147 			{
       
  1148 			//if access point is not defined
       
  1149 			DisplayErrorNoteL(R_IRAPP_NETWORKCONTROLLER_NOAP);
       
  1150 			}
       
  1151 		break;
       
  1152 		case EAccessPointSelectionCancelled:
       
  1153 			{
       
  1154 			// Called if the user chooses to cancel access point
       
  1155 			// selection
       
  1156 			}
       
  1157 		break;
       
  1158 		}
       
  1159     IRRDEBUG2("CIRUi::IRNetworkEventL - Exiting", KNullDesC );
       
  1160 
       
  1161 	IRLOG_DEBUG( "CIRUi::IRNetworkEventL - Exiting." );
       
  1162 	}
       
  1163 
       
  1164 // ---------------------------------------------------------------------------
       
  1165 // Function : NetworkAnimationTimerExpiredL
       
  1166 // Called when the buffering times out
       
  1167 // ---------------------------------------------------------------------------
       
  1168 //
       
  1169 TInt CIRUi::NetworkAnimationTimerExpired(TAny* /*aPtr*/)
       
  1170 	{
       
  1171     IRLOG_INFO( "CIRUi::NetworkAnimationTimerExpired - Entering" );
       
  1172     IRLOG_DEBUG( "CIRUi::NetworkAnimationTimerExpired - Exiting." );
       
  1173 	return KErrNone;
       
  1174 	}
       
  1175 
       
  1176 // ---------------------------------------------------------------------------
       
  1177 // CIRUi::ActivateCurrentView()
       
  1178 // Calls Draw of the currently activated view
       
  1179 // ---------------------------------------------------------------------------
       
  1180 //
       
  1181 void CIRUi::ActivateCurrentView(const TUid& aUid) const
       
  1182 	{
       
  1183 	IRLOG_DEBUG( "CIRUi::ActivateCurrentView - Entering" );
       
  1184 	//If NowPlaying View is activated
       
  1185 	if(aUid == KIRNowPlayingViewID)
       
  1186 		{
       
  1187 		if(iNowPlayingView->iContainer)
       
  1188 			{
       
  1189 		    }
       
  1190 		}
       
  1191 
       
  1192 	IRLOG_DEBUG( "CIRUi::ActivateCurrentView - Exiting." );
       
  1193 	}
       
  1194 
       
  1195 
       
  1196 // ---------------------------------------------------------------------------
       
  1197 // CIRUi::VerifyNetworkConnectivityL()
       
  1198 // Verifies the network connectivity
       
  1199 // This function can leave if displaying of info note leaves hence
       
  1200 // this leave can be ignored
       
  1201 // ---------------------------------------------------------------------------
       
  1202 //
       
  1203 TBool CIRUi::VerifyNetworkConnectivityL()
       
  1204 	{
       
  1205 	IRLOG_DEBUG( "CIRUi::VerifyNetworkConnectivityL - Entering" );
       
  1206 
       
  1207 	TBool returnValue = EFalse;
       
  1208 	iIsDisconnected =EFalse;
       
  1209 	if(!(iNetworkController->GetNetworkStatus()))
       
  1210 		{
       
  1211 	IRRDEBUG2("CIRUi::VerifyNetworkConnectivityL Entering ", KNullDesC);
       
  1212 
       
  1213 		if( iNetworkController->iIsConnectRequestIssued )
       
  1214 			{
       
  1215 			returnValue = ETrue;
       
  1216 			}
       
  1217 		else
       
  1218 			{
       
  1219 	        IRLOG_ERROR( "CIRUi::VerifyNetworkConnectivityL - No connection request issued." );
       
  1220 			//offer the user to connect to network
       
  1221 			ActivateCurrentView(iPresentViewID);
       
  1222 			//Choose the accesspoint
       
  1223 			iNetworkController->ChooseAccessPointL();
       
  1224 			returnValue = ETrue;
       
  1225 			}
       
  1226 		}
       
  1227 	IRRDEBUG2("CIRUi::VerifyNetworkConnectivityL Exiting ", KNullDesC);
       
  1228 
       
  1229 	IRLOG_DEBUG( "CIRUi::VerifyNetworkConnectivityL - Exiting" );
       
  1230 	return returnValue;
       
  1231 	}
       
  1232 
       
  1233 // ---------------------------------------------------------------------------
       
  1234 // CIRUi::FocusWhenSelectGot()
       
  1235 // Funtion is called to return the flag when a listbox item is selected
       
  1236 // so that the next view gets activated
       
  1237 // ---------------------------------------------------------------------------
       
  1238 //
       
  1239 TBool CIRUi::FocusWhenSelectGot()  const
       
  1240 	{
       
  1241 	IRLOG_DEBUG2( "CIRUi::FocusWhenSelectGot - Returning %d", iSelect );
       
  1242 	return(iSelect);
       
  1243 	}
       
  1244 
       
  1245 // ---------------------------------------------------------------------------
       
  1246 // CIRUi::FocusWhenSelectSet()
       
  1247 // Funtion is called to set flag when an listbox item is selected
       
  1248 // so that the next view gets activated
       
  1249 // ---------------------------------------------------------------------------
       
  1250 //
       
  1251 void CIRUi::FocusWhenSelectSet(TBool aFocus)
       
  1252 	{
       
  1253 	IRLOG_DEBUG2( "CIRUi::FocusWhenSelectSet(aFocus=%d)", aFocus );
       
  1254 	iSelect=aFocus;
       
  1255 	IRLOG_DEBUG2( "CIRUi::FocusWhenSelectSet(aFocus=%d)" , aFocus);
       
  1256 	}
       
  1257 
       
  1258 
       
  1259 // ---------------------------------------------------------------------------
       
  1260 // CIRUi::HandlePropertyChangeL
       
  1261 // Derived from class MIRPropertyChangeObserver
       
  1262 // ---------------------------------------------------------------------------
       
  1263 //
       
  1264 void CIRUi::HandlePropertyChangeL(const TUid& /*aCategory*/, const TUint /*aKey*/, const TIRTextProperty& /*aValue*/ )
       
  1265 	{
       
  1266 	IRLOG_DEBUG( "CIRUi::HandlePropertyChangeL" );
       
  1267 	return;
       
  1268 	}
       
  1269 
       
  1270 // ---------------------------------------------------------------------------
       
  1271 // CIRUi::HandlePropertyChangeL
       
  1272 // Derived from class MIRPropertyChangeObserver
       
  1273 // ---------------------------------------------------------------------------
       
  1274 //
       
  1275 void CIRUi::HandlePropertyChangeL(const TUid& /*aCategory*/,
       
  1276 								const TUint /*aKey*/, const TInt /*aValue*/ )
       
  1277 	{
       
  1278 	IRLOG_DEBUG( "CIRUi::HandlePropertyChangeL " );
       
  1279 	}
       
  1280 
       
  1281 // ---------------------------------------------------------------------------
       
  1282 // CIRUi::IsLandscapeOrientation
       
  1283 // ---------------------------------------------------------------------------
       
  1284 //
       
  1285 TBool CIRUi::IsLandscapeOrientation() const
       
  1286     {
       
  1287     IRLOG_DEBUG( "CIRUi::IsLandscapeOrientation" );
       
  1288     return iLandscape;
       
  1289     }
       
  1290 
       
  1291 
       
  1292 
       
  1293 // ---------------------------------------------------------------------------
       
  1294 // CIRUi::UpdateLandscapeInformation
       
  1295 // ---------------------------------------------------------------------------
       
  1296 //
       
  1297 void CIRUi::UpdateLandscapeInformation()
       
  1298     {
       
  1299     IRLOG_DEBUG( "CIRUi::UpdateLandscapeInformation - Entering" );
       
  1300     TSize screenSize;
       
  1301     AknLayoutUtils::LayoutMetricsSize( AknLayoutUtils::EScreen, screenSize );
       
  1302     // Is it portrait or landscape, compare height and width, since we can't
       
  1303     // be sure if EGraphicsOrientationNormal is portrait or landscape
       
  1304     if ( screenSize.iHeight < screenSize.iWidth )
       
  1305         {
       
  1306         iLandscape = ETrue;
       
  1307         }
       
  1308     else
       
  1309         {
       
  1310         iLandscape = EFalse;
       
  1311         }
       
  1312 
       
  1313     //Remove this hack notification when Alfred starts to notify the controls of portrait/landscape changes.
       
  1314     IRLOG_DEBUG( "CIRUi::UpdateLandscapeInformation - Exiting" );
       
  1315     }
       
  1316 
       
  1317 
       
  1318     // ---------------------------------------------------------------------------
       
  1319 // CIRUi::ChooseLayoutResource
       
  1320 // ---------------------------------------------------------------------------
       
  1321 //
       
  1322 TInt CIRUi::ChooseLayoutResource( TInt aNormalPortraitRes,
       
  1323         TInt aMirroredPortraitRes, TInt aNormalLandscapeRes,
       
  1324         TInt aMirroredLandscapeRes ) const
       
  1325     {
       
  1326     IRLOG_DEBUG( "CIRUi::ChooseLayoutResource - Entering" );
       
  1327     TInt resId = 0;
       
  1328 
       
  1329     if ( IsLandscapeOrientation() )
       
  1330         {
       
  1331         if ( AknLayoutUtils::LayoutMirrored() )
       
  1332             {
       
  1333             resId = aMirroredLandscapeRes;
       
  1334             }
       
  1335         else
       
  1336             {
       
  1337             resId = aNormalLandscapeRes;
       
  1338             }
       
  1339         }
       
  1340     else
       
  1341         {
       
  1342         if ( AknLayoutUtils::LayoutMirrored() )
       
  1343             {
       
  1344             resId = aMirroredPortraitRes;
       
  1345             }
       
  1346         else
       
  1347             {
       
  1348             resId = aNormalPortraitRes;
       
  1349             }
       
  1350         }
       
  1351     IRLOG_DEBUG( "CIRUi::ChooseLayoutResource - Exiting" );
       
  1352     return resId;
       
  1353     }
       
  1354 // ---------------------------------------------------------------------------
       
  1355 // CIRUi::HandlePropertyChangeErrorL
       
  1356 // Derived from class MIRPropertyChangeObserver
       
  1357 // ---------------------------------------------------------------------------
       
  1358 //
       
  1359 void CIRUi::HandlePropertyChangeErrorL(const TUid& /*aCategory*/,
       
  1360 						const TUint /*aKey*/, TInt /*aError*/)
       
  1361 	{
       
  1362 	IRLOG_DEBUG( "CIRUi::HandlePropertyChangeErrorL" );
       
  1363 	//Implementation is not required
       
  1364 	}
       
  1365 
       
  1366 
       
  1367 // ---------------------------------------------------------------------------
       
  1368 //  CIRUi::sGetLockInfo()
       
  1369 // gets information about keypad lock.
       
  1370 // ---------------------------------------------------------------------------
       
  1371 //
       
  1372 TBool CIRUi::GetLockInfo()
       
  1373 	{
       
  1374 	IRLOG_DEBUG( "CIRUi::GetLockInfo - Entering" );
       
  1375 	 TBool isLock(EFalse);
       
  1376 	 RAknKeyLock keylock;
       
  1377 	 TInt err = keylock.Connect();
       
  1378 	 if ( !err )
       
  1379 		{
       
  1380 		 //check if keypad is locked.
       
  1381 		 if ( keylock.IsKeyLockEnabled() )
       
  1382 		    {
       
  1383 		    isLock = ETrue;
       
  1384 		    }
       
  1385 		 else
       
  1386 			{
       
  1387 			isLock = EFalse;
       
  1388 			}
       
  1389 		keylock.Close();
       
  1390 		}
       
  1391 	 IRLOG_DEBUG( "CIRUi::GetLockInfo - Exiting" );
       
  1392 	return ( isLock );
       
  1393 	}
       
  1394 
       
  1395 // ---------------------------------------------------------------------------
       
  1396 // UpdateSubscriberIdL()
       
  1397 // Updates the IMSI code and sets the Terms & Conditions flag as necessary.
       
  1398 // ---------------------------------------------------------------------------
       
  1399 //
       
  1400 void CIRUi::UpdateSubscriberIdL()
       
  1401     {
       
  1402     IRLOG_DEBUG( "CIRUi::UpdateSubscriberIdL - Entering" );
       
  1403     CMDBSession* dbSession = CMDBSession::NewL( CMDBSession::LatestVersion() );
       
  1404     CleanupStack::PushL( dbSession );
       
  1405 
       
  1406     CMDBRecordSet<CCDModemBearerRecord>* recordSet = new ( ELeave )
       
  1407     				CMDBRecordSet<CCDModemBearerRecord>( KCDTIdModemBearerRecord );
       
  1408     CleanupStack::PushL( recordSet );
       
  1409 
       
  1410     recordSet->LoadL( *dbSession );
       
  1411     if ( !recordSet->iRecords.Count() )
       
  1412         {
       
  1413         IRLOG_WARNING( "CIRUi::UpdateSubscriberIdL - Loading subscriber record set failed." );
       
  1414         User::Leave( KErrNotFound );
       
  1415         }
       
  1416 
       
  1417     TInt index = 0;
       
  1418     CCDModemBearerRecord* record = NULL;
       
  1419     do
       
  1420         {
       
  1421         record = static_cast<CCDModemBearerRecord*>( recordSet->iRecords[index++] );
       
  1422         } while ( record->iTsyName.IsNull() && index < recordSet->iRecords.Count() );
       
  1423 
       
  1424     TPtrC tsyName( static_cast<const TDesC&>( record->iTsyName ) );
       
  1425 
       
  1426     RTelServer telServer;
       
  1427     User::LeaveIfError( telServer.Connect() );
       
  1428     CleanupClosePushL( telServer );
       
  1429     User::LeaveIfError( telServer.LoadPhoneModule( tsyName ) );
       
  1430 
       
  1431     TInt numPhones = 0;
       
  1432     User::LeaveIfError( telServer.EnumeratePhones( numPhones ) );
       
  1433 
       
  1434     TInt legalPhoneIndex = KErrNotFound;
       
  1435     RTelServer::TPhoneInfo phoneInfo;
       
  1436     for ( TInt i = 0; i < numPhones && legalPhoneIndex == KErrNotFound; i++ )
       
  1437         {
       
  1438         if ( telServer.GetPhoneInfo( i, phoneInfo ) == KErrNone )
       
  1439             {
       
  1440             if ( phoneInfo.iNetworkType == RTelServer::ENetworkTypeMobileDigital )
       
  1441                 {
       
  1442                 legalPhoneIndex = i;
       
  1443                 }
       
  1444             }
       
  1445         }
       
  1446     User::LeaveIfError( legalPhoneIndex );
       
  1447 
       
  1448     RMobilePhone phone;
       
  1449     User::LeaveIfError( phone.Open( telServer, phoneInfo.iName ) );
       
  1450     CleanupClosePushL( phone );
       
  1451 
       
  1452     TUint32 identityCaps;
       
  1453     User::LeaveIfError( phone.GetIdentityCaps( identityCaps ) );
       
  1454 
       
  1455     if ( identityCaps & RMobilePhone::KCapsGetSubscriberId )
       
  1456         {
       
  1457         TRequestStatus status;
       
  1458         RMobilePhone::TMobilePhoneSubscriberId subscriberId;
       
  1459         phone.GetSubscriberId( status, subscriberId );
       
  1460         User::WaitForRequest( status );
       
  1461         if ( !status.Int() && iIRSettings->SubscriberIdL().Compare( subscriberId ) )
       
  1462             {
       
  1463             iIRSettings->SetSubscriberIdL( subscriberId );
       
  1464             iIRSettings->ReSetFlagCostWarningL();
       
  1465             iIRSettings->ReSetFlagTermsAndConditionsL();
       
  1466             }
       
  1467         }
       
  1468     CleanupStack::PopAndDestroy( KFour, dbSession );
       
  1469     IRLOG_DEBUG( "CIRUi::UpdateSubscriberIdL - Exiting." );
       
  1470     }
       
  1471 // ---------------------------------------------------------------------------
       
  1472 // SelectedBrowsingCategory()
       
  1473 // Returns the last selected browsing category
       
  1474 // ---------------------------------------------------------------------------
       
  1475 //
       
  1476 TInt CIRUi::SelectedBrowsingCategory() const
       
  1477     {
       
  1478     IRLOG_DEBUG( "CIRUi::SelectedBrowsingCategory" );
       
  1479     return iSelectedBrowsingCategory;
       
  1480     }
       
  1481 // ---------------------------------------------------------------------------
       
  1482 // CancelDelayedAction()
       
  1483 // ---------------------------------------------------------------------------
       
  1484 //CIRUi::CreateWritablePrivatePath()
       
  1485 //Only for ROM SDK3.2
       
  1486 //creates a private path in c drive if it doesnot exist (for rom install)
       
  1487 // ---------------------------------------------------------------------------
       
  1488 //
       
  1489 void CIRUi::CreateWritablePrivatePath()
       
  1490 	{
       
  1491 	IRLOG_DEBUG( "CIRUi::CreateWritablePrivatePath - Entering." );
       
  1492 	TInt err;
       
  1493     err = iFsSession.CreatePrivatePath(EDriveC);
       
  1494     if(KErrNone != err)
       
  1495     	{
       
  1496     	TRAP_IGNORE(DisplayErrorNoteL(R_IRAPP_IRGENERAL_ERROR))
       
  1497     	}
       
  1498     IRLOG_DEBUG( "CIRUi::CreateWritablePrivatePath - Exiting." );
       
  1499 	}
       
  1500 // -----------------------------------------------------------------------------
       
  1501 // From class CEikAppUi.
       
  1502 // Handles a change to the application's resources which are shared across
       
  1503 // the environment.
       
  1504 // -----------------------------------------------------------------------------
       
  1505 //
       
  1506 void CIRUi::HandleResourceChangeL( TInt aType )
       
  1507 	{
       
  1508 	IRLOG_DEBUG( "CIRUi::HandleResourceChangeL - Entering." );
       
  1509 	CAknViewAppUi::HandleResourceChangeL( aType );
       
  1510 	UpdateLandscapeInformation();
       
  1511 
       
  1512 	CEikStatusPane* statP = StatusPane();
       
  1513 	if(IsLandscapeOrientation())
       
  1514 		{
       
  1515 		statP->SwitchLayoutL(R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL);
       
  1516 		}
       
  1517 	else
       
  1518 		{
       
  1519 		if ( ActiveView() == KIRAddManuallyStationViewID)
       
  1520 			{
       
  1521 			statP->SwitchLayoutL( R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL);
       
  1522 
       
  1523         	}
       
  1524 		else
       
  1525 			{
       
  1526 			statP->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT);
       
  1527 			}
       
  1528 
       
  1529 		}
       
  1530 	TriggerCommand();
       
  1531 
       
  1532 	IRLOG_DEBUG( "CIRUi::HandleResourceChangeL - Exiting." );
       
  1533 	}
       
  1534 
       
  1535 // ---------------------------------------------------------------------------
       
  1536 // Triggers the command to view handling
       
  1537 // ---------------------------------------------------------------------------
       
  1538 //
       
  1539 void CIRUi::TriggerCommand()
       
  1540     {
       
  1541     IRLOG_DEBUG( "CIRUi::TriggerCommand - Entering." );
       
  1542     TVwsViewId viewId( KNullUid, KNullUid );
       
  1543     CAknViewAppUi* appUi = static_cast<CAknViewAppUi*>( CCoeEnv::Static()->AppUi() );
       
  1544     TInt err = appUi->GetActiveViewId( viewId );
       
  1545     RProcess process;
       
  1546     TSecureId id = process.SecureId();
       
  1547     // GetActiveViewId doesn't always work (when switched back to VRA through RadioLauncher icon
       
  1548     if( !err && viewId.iAppUid.iUid == id.iId )
       
  1549         {
       
  1550         CAknView* view = appUi->View( viewId.iViewUid );
       
  1551         if( view )
       
  1552             {
       
  1553             view->HandleStatusPaneSizeChange();
       
  1554             }
       
  1555         }
       
  1556     IRLOG_DEBUG( "CIRUi::TriggerCommand - Exiting." );
       
  1557     }
       
  1558 
       
  1559 // ---------------------------------------------------------------------------
       
  1560 // CIRUi::HandleWsEventL(..)
       
  1561 // From class CEikAppUi.
       
  1562 // Handles window server events.
       
  1563 // ---------------------------------------------------------------------------
       
  1564 //
       
  1565 void CIRUi::HandleWsEventL( const TWsEvent& aEvent,
       
  1566                             CCoeControl* aDestination )
       
  1567 	{
       
  1568 	IRLOG_DEBUG( "CIRUi::HandleWsEventL - Entering" );
       
  1569 
       
  1570 
       
  1571 	// We don't want to shutdown on end key
       
  1572 	if ( aEvent.Type() != KAknUidValueEndKeyCloseEvent )
       
  1573 		{
       
  1574 		CAknViewAppUi::HandleWsEventL( aEvent, aDestination );
       
  1575 		}
       
  1576 	else
       
  1577 		{
       
  1578 		if(IsForeground())
       
  1579 			{
       
  1580 			//variable currenttask is used check whether current task is foreground
       
  1581 			//or background
       
  1582 			TApaTask currenttask( iEikonEnv->WsSession() );
       
  1583 			currenttask.SetWgId( iEikonEnv->RootWin().Identifier() );
       
  1584 			currenttask.SendToBackground();
       
  1585 			}
       
  1586 		}
       
  1587 	IRLOG_DEBUG( "CIRUi::HandleWsEventL - Exiting." );
       
  1588 	}
       
  1589 // ---------------------------------------------------------------------------
       
  1590 // CIRUi::GainingForeGroundL().
       
  1591 // Function handles when application gains foreground focus
       
  1592 // ---------------------------------------------------------------------------
       
  1593 //
       
  1594 void CIRUi::GainingForeGroundL()
       
  1595 	{
       
  1596 	IRLOG_DEBUG( "CIRUi::GainingForeGroundL - Entering" );
       
  1597 		if(iBgWhenLock )
       
  1598 			{
       
  1599 			iBgWhenLock = EFalse;
       
  1600 			}
       
  1601 
       
  1602 		if(iActivationPending != KNullUid)
       
  1603 			{
       
  1604 			TUid tempraryUid=iActivationPending;
       
  1605 		    // Reset even if ActivateLocalViewL leaves
       
  1606             iActivationPending = KNullUid;
       
  1607             ActivateLocalViewL( tempraryUid );
       
  1608 			}
       
  1609 
       
  1610 	IRLOG_DEBUG( "CIRUi::GainingForeGroundL - Exiting." );
       
  1611 	return;
       
  1612 	}
       
  1613 
       
  1614 // ---------------------------------------------------------------------------
       
  1615 // CIRUi::HandleGainingForeground().
       
  1616 // This is call back function which observes application focus gaining
       
  1617 // foreground
       
  1618 // ---------------------------------------------------------------------------
       
  1619 //
       
  1620 void CIRUi::HandleGainingForeground()
       
  1621 	{
       
  1622 	// GainingForeGroundL() handles the functionality of loading the iRAPP
       
  1623 	// view along with the buffering control if buffering crtl is present.
       
  1624 	// Handled while iRAPP is put to background & then gains foreground focus.
       
  1625 	IRLOG_DEBUG( "CIRUi::HandleGainingForeground - Entering" );
       
  1626 	if( IsForeground() )
       
  1627 		{
       
  1628 		TRAP_IGNORE(GainingForeGroundL())
       
  1629 		}
       
  1630 	IRLOG_DEBUG( "CIRUi::HandleGainingForeground - Exiting." );
       
  1631 	}
       
  1632 
       
  1633 
       
  1634 // ---------------------------------------------------------------------------
       
  1635 // CIRUi::HandleLosingForeground().
       
  1636 // This is call back function which observes application focus losing
       
  1637 // foreground
       
  1638 // ---------------------------------------------------------------------------
       
  1639 //
       
  1640 void CIRUi::HandleLosingForeground()
       
  1641 	{
       
  1642 	IRLOG_DEBUG( "CIRUi::HandleLosingForeground - Entering" );
       
  1643 	LosingForeground();
       
  1644 	IRLOG_DEBUG( "CIRUi::HandleLosingForeground - Exiting." );
       
  1645 	}
       
  1646 
       
  1647 // ---------------------------------------------------------------------------
       
  1648 // CIRUi::LosingForeground().
       
  1649 // Function handles when application looses foreground focus
       
  1650 // ---------------------------------------------------------------------------
       
  1651 //
       
  1652 void CIRUi::LosingForeground()
       
  1653 	{
       
  1654 	if( GetLockInfo()  )
       
  1655 		{
       
  1656 		iBgWhenLock = ETrue;
       
  1657 		}
       
  1658 	IRLOG_DEBUG( "CIRUi::LosingForeground" );
       
  1659 	}
       
  1660 
       
  1661 // ---------------------------------------------------------------------------
       
  1662 // CIRUi::IconProvider().
       
  1663 // Returns the instance of icon provider.
       
  1664 // ---------------------------------------------------------------------------
       
  1665 //
       
  1666 CIconFileProvider* CIRUi::IconProvider()
       
  1667 	{
       
  1668 	IRLOG_DEBUG( "CIRUi::IconProvider" );
       
  1669 	return iIconProvider;
       
  1670 	}
       
  1671 
       
  1672 
       
  1673 
       
  1674 // ---------------------------------------------------------------------------
       
  1675 // CIRUi::ParseAndPrepareUrl()
       
  1676 // Checks for the URL whether its valid or not
       
  1677 // ---------------------------------------------------------------------------
       
  1678 //
       
  1679 TBool CIRUi::ParseAndPrepareUrl(const TDesC& aUrl)
       
  1680 	{
       
  1681 	IRLOG_INFO2( "CIRUi::ParseAndPrepareUrl(aUrl=%S)", &aUrl );
       
  1682 	_LIT8(KHttp,"http");
       
  1683 	_LIT8(KMms, "mms");
       
  1684 	TInt err = CnvUtfConverter::ConvertFromUnicodeToUtf8(iUrl8,aUrl);
       
  1685 	if(err != KErrNone)
       
  1686 		{
       
  1687 	    IRLOG_ERROR2("CIRUi::ParseAndPrepareUrl - Unicode to Utf8 conversion failed (err=%d)", err );
       
  1688 		return EFalse;
       
  1689 		}
       
  1690 
       
  1691     IRLOG_DEBUG2( "CIRUi::ParseAndPrepareUrl - Converted URL=%S", &iUrl8 );
       
  1692 
       
  1693 
       
  1694 
       
  1695 	TUriParser8 uriParser;
       
  1696 
       
  1697 	// Initialize the Uri Parser
       
  1698 	if ( uriParser.Parse( iUrl8 ) != KErrNone )
       
  1699 	    {
       
  1700 	    IRLOG_ERROR( "CIRUi::ParseAndPrepareUrl - Error while parsing URI." );
       
  1701 		return EFalse;
       
  1702 	    }
       
  1703 
       
  1704 	//Extract protocol
       
  1705 	if( uriParser.Extract( EUriScheme ).Length() > KSmallBufSize )
       
  1706 		{
       
  1707 	    IRLOG_ERROR("CIRUi::ParseAndPrepareUrl - Extracted URI scheme component too large." );
       
  1708 		return EFalse;
       
  1709 		}
       
  1710 	else
       
  1711 		{
       
  1712 		TBuf8<KSmallBufSize> uriScheme;
       
  1713 		uriScheme.Copy( uriParser.Extract( EUriScheme ) );
       
  1714 		uriScheme.LowerCase();
       
  1715 		if ( uriScheme.Compare(KHttp) && uriScheme.Compare(KMms) )
       
  1716 			{
       
  1717 	        IRLOG_ERROR("CIRUi::ParseAndPrepareUrl - Invalid URI scheme." );
       
  1718 			return EFalse;
       
  1719 			}
       
  1720 		}
       
  1721 
       
  1722 	// Extract the Host Name
       
  1723 	if ( uriParser.Extract( EUriHost ).Length() > KMaxBufSize )
       
  1724 		{
       
  1725 	    IRLOG_ERROR( "CIRUi::ParseAndPrepareUrl - Extracted Host component too large." );
       
  1726 		return EFalse;
       
  1727 		}
       
  1728 	if ( uriParser.Extract( EUriHost ).Length() <= 0 )
       
  1729 	    {
       
  1730 	    IRLOG_ERROR( "CIRUi::ParseAndPrepareUrl - Empty Host component." );
       
  1731 	    return EFalse;
       
  1732 	    }
       
  1733 
       
  1734 	IRLOG_DEBUG( "CIRUi::ParseAndPrepareUrl - Exiting." );
       
  1735 	return ETrue;
       
  1736 	}
       
  1737 
       
  1738 /// ---------------------------------------------------------------------------
       
  1739 // CIRUi::DisplayErrorNoteL()
       
  1740 // Display the error note
       
  1741 // ---------------------------------------------------------------------------
       
  1742 //
       
  1743 void CIRUi::DisplayErrorNoteL(TInt aResourceId)
       
  1744 	{
       
  1745 	IRLOG_DEBUG( "CIRUi::DisplayErrorNoteL - Entering" );
       
  1746 	HBufC* error = StringLoader::LoadLC(aResourceId);
       
  1747 	iIsdsWrapper->GetDialogLauncherInstance()->ShowErrorNoteL(aResourceId,ETrue);
       
  1748 	CleanupStack::PopAndDestroy(error);
       
  1749 	IRLOG_DEBUG( "CIRUi::DisplayErrorNoteL - Exiting." );
       
  1750 	}
       
  1751 
       
  1752 // ---------------------------------------------------------------------------
       
  1753 // CIRUi::DisplayErrorNoteL()
       
  1754 // Display the error note
       
  1755 // ---------------------------------------------------------------------------
       
  1756 //
       
  1757 void CIRUi::DisplayErrorNoteL(TInt aResourceId, const TDesC &  aString)
       
  1758 	{
       
  1759 	IRLOG_DEBUG( "CIRUi::DisplayErrorNoteL - Entering" );
       
  1760 	HBufC* error = StringLoader::LoadLC(aResourceId, aString);
       
  1761 	CleanupStack::PopAndDestroy(error);
       
  1762 	IRLOG_DEBUG( "CIRUi::DisplayErrorNoteL - Exiting" );
       
  1763 	}
       
  1764 
       
  1765 
       
  1766 // ---------------------------------------------------------------------------
       
  1767 // CIRUi::UpdateNowPlayingByteCounter()
       
  1768 // Retrieves current Byte Counter for displaying in Now playing view
       
  1769 // ---------------------------------------------------------------------------
       
  1770 //
       
  1771 void CIRUi::UpdateNowPlayingByteCounter()
       
  1772 	{
       
  1773 	IRLOG_DEBUG( "CIRUi::UpdateNowPlayingByteCounter - Entering" );
       
  1774 	const MIRDataTransferTracker::TIRDataTransferPckg& data = iNetworkController->
       
  1775 				DataTransferTracker().TransferredData();
       
  1776 	TReal32  total_bytes = data.iBytesSentTotal + data.iBytesReceivedTotal;
       
  1777 	if(iNowPlayingView->iContainer)
       
  1778 		{
       
  1779 		TRAP_IGNORE(iNowPlayingView->DisplayByteCounterL(total_bytes))
       
  1780 		}
       
  1781 	IRLOG_DEBUG( "CIRUi::UpdateNowPlayingByteCounter - Exiting" );
       
  1782 	}
       
  1783 
       
  1784 // ---------------------------------------------------------------------------
       
  1785 // CIRUi::HandleDataTransferEventL( const MIRDataTransferTracker::TIRDataTransferPckg& aData )
       
  1786 // DataTransferObserver notification to receive byte counter
       
  1787 // ---------------------------------------------------------------------------
       
  1788 //
       
  1789 void  CIRUi::HandleDataTransferEventL( const MIRDataTransferTracker::TIRDataTransferPckg& aData )
       
  1790 	{
       
  1791 	IRLOG_DEBUG( "CIRUi::HandleDataTransferEventL - Entering" );
       
  1792 	TReal32 total_bytes = aData.iBytesSentTotal + aData.iBytesReceivedTotal;
       
  1793 	if(iNowPlayingView->iContainer)
       
  1794 		{
       
  1795 		iNowPlayingView->DisplayByteCounterL(total_bytes);
       
  1796 		}
       
  1797 	// Byte Counter Testing function (to be removed)
       
  1798 	IRLOG_DEBUG( "CIRUi::HandleDataTransferEventL - Exiting" );
       
  1799 	}
       
  1800 
       
  1801 // ---------------------------------------------------------------------------
       
  1802 // CIRUi::IsFirstTime()
       
  1803 // returns which view should be launched.
       
  1804 // ---------------------------------------------------------------------------
       
  1805 //
       
  1806 TBool CIRUi::IsFirstTime()
       
  1807 	{
       
  1808 	IRLOG_DEBUG( "CIRUi::IsFirstTime - Entering" );
       
  1809 	TInt returnValue=0;
       
  1810 	TRAP_IGNORE(returnValue=IsFlagIfAnyFavL());
       
  1811 	if(iFavPresets->iFavPresetList.Count())
       
  1812 		{
       
  1813 		if(returnValue == 0)
       
  1814 			{
       
  1815 			TRAP_IGNORE(iIRSettings->SetFlagIfAnyFavL();)
       
  1816 			}
       
  1817 		}
       
  1818 
       
  1819 	IRLOG_DEBUG( "CIRUi::IsFirstTime - Exiting" );
       
  1820 
       
  1821 	if((iLastPlayed->iLastPlayedStation->iUrlArray->Count() == 0) &&
       
  1822 				(iFavPresets->iFavPresetList.Count()== 0) && (!returnValue))
       
  1823 		{
       
  1824 		return ETrue;
       
  1825 		}
       
  1826 	else
       
  1827 		{
       
  1828 		return EFalse;
       
  1829 		}
       
  1830 	}
       
  1831 // ---------------------------------------------------------------------------
       
  1832 // CIRUi::SetCommandSetL()
       
  1833 // Dynamically changing the cba buttons.
       
  1834 // ---------------------------------------------------------------------------
       
  1835 //
       
  1836 void CIRUi::SetCommandSetL(TInt aResourceId)
       
  1837 	{
       
  1838 	IRLOG_DEBUG( "CIRUi::SetCommandSetL - Entering" );
       
  1839 	CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
  1840 	cba->SetCommandSetL( aResourceId );
       
  1841 	IRLOG_DEBUG( "CIRUi::SetCommandSetL - Exiting" );
       
  1842 	}
       
  1843 
       
  1844 //--------------------------------------------------------------------------
       
  1845 // CIRUi::IsForeground()
       
  1846 //IsForeground()	 overloaded
       
  1847 //---------------------------------------------------------------------------
       
  1848 
       
  1849 TBool CIRUi::IsForeground()
       
  1850 	{
       
  1851 	IRLOG_DEBUG( "CIRUi::IsForeground - Entering" );
       
  1852 	#ifdef __WINS__
       
  1853 	// Stop screen saver from activating
       
  1854 	User::ResetInactivityTime();
       
  1855 	#endif
       
  1856 	IRLOG_DEBUG( "CIRUi::IsForeground - Exiting" );
       
  1857 	TBool isForeground = CAknAppUiBase::IsForeground();
       
  1858 	return isForeground;
       
  1859 	}
       
  1860 // ---------------------------------------------------------------------------
       
  1861 // CIRUi::ParsePlsDataL(..).
       
  1862 // Parse the PLS data
       
  1863 // ---------------------------------------------------------------------------
       
  1864 //
       
  1865 void CIRUi::ParsePlsDataL(CFileStore*& /*aFileStore*/, RFile& aFile)
       
  1866 	{
       
  1867 	IRLOG_INFO( "CIRUi::ParsePlsDataL - Entering" );
       
  1868 	CIRPlsPlayList* playList= CIRPlsPlayList::NewLC(aFile);
       
  1869 	if(iURLs.Count()>0)
       
  1870 		{
       
  1871 		iURLs.ResetAndDestroy();
       
  1872 	    iListenFrmSecondPls = EFalse;
       
  1873 		iPlsPresetSaved.Close();
       
  1874 		}
       
  1875 
       
  1876 	for (TInt i=0; i<playList->Count(); i++)
       
  1877 		{
       
  1878 		CIRPlsPlayListItem* item = playList->ItemAt(i);
       
  1879 		if (item && item->File().Length())
       
  1880 			{
       
  1881 			if(item->Length()==-1)
       
  1882 				{
       
  1883 				HBufC8* fileBuf = HBufC8::NewLC( item->File().Length() );
       
  1884 				fileBuf->Des().Copy( item->File() );
       
  1885 				iURLs.AppendL( fileBuf );
       
  1886 				CleanupStack::Pop( fileBuf );
       
  1887 				HBufC8* titleBuf = HBufC8::NewLC( item->Title().Length() );
       
  1888 				titleBuf->Des().Copy( item->Title() );
       
  1889 				iURLs.AppendL( titleBuf );
       
  1890 				iPlsLength.AppendL(item->Length());
       
  1891 				CleanupStack::Pop( titleBuf );
       
  1892 				}
       
  1893 			}
       
  1894 		}
       
  1895 	for(TInt index=0;index < iURLs.Count()/2 ; index++ )
       
  1896 		{
       
  1897 		iPlsPresetSaved.Append(0);
       
  1898 		}
       
  1899 	CleanupStack::PopAndDestroy( playList );
       
  1900 	ConnectToPlsUrlL();
       
  1901 	IRLOG_DEBUG( "CIRUi::ParsePlsDataL - Exiting." );
       
  1902 	}
       
  1903 // ---------------------------------------------------------------------------
       
  1904 // CIRUi::ConnectToPlsUrlL()
       
  1905 // Connect to PLS URL
       
  1906 // ---------------------------------------------------------------------------
       
  1907 //
       
  1908 void CIRUi::ConnectToPlsUrlL()
       
  1909 	{
       
  1910 	IRLOG_DEBUG( "CIRUi::ConnectToPlsUrl - Entering" );
       
  1911 	//Instantiate PLS View
       
  1912 	if(!iPlsactivated)
       
  1913 		{
       
  1914 		iPlsView = CIRPlsView::NewL(ApplicationRect());
       
  1915 		AddViewL(iPlsView);
       
  1916 		}
       
  1917 	else
       
  1918 		{
       
  1919 		iPlsLength.Close();
       
  1920 		iPlsView->SecondConstruct();
       
  1921 		}
       
  1922 	if (!iIRSettings->IsFlagTermsAndConditionsL() ||
       
  1923 	!iIRSettings->IsFlagCostWarningL())
       
  1924 		{
       
  1925 		iPlsactivated = ETrue;
       
  1926 		ActivateLocalViewL(KIRCostWarningViewId);
       
  1927 		}
       
  1928 	//Activate the Pls view
       
  1929 	else
       
  1930 		{
       
  1931 		if( iPresentViewID == KIRUpdateWarningViewID )
       
  1932 			{
       
  1933 			iPlsactivated = ETrue;
       
  1934 			}
       
  1935 		else
       
  1936 			{
       
  1937 			iPlsactivated = ETrue;
       
  1938 			ActivateLocalViewL(KIRPlsViewID);
       
  1939 			}
       
  1940 		}
       
  1941 	IRLOG_DEBUG( "CIRUi::ConnectToPlsUrl - Exiting." );
       
  1942 	}
       
  1943 
       
  1944 // ---------------------------------------------------------------------------
       
  1945 // CIRUi::GetPlsActiavted()
       
  1946 // Returns bool whether T&C or cost warning view are accepted or not
       
  1947 // ---------------------------------------------------------------------------
       
  1948 //
       
  1949 TBool CIRUi::GetPlsActiavted() const
       
  1950 	{
       
  1951 	IRLOG_DEBUG( "CIRUi::GetPlsActiavted" );
       
  1952 	return(iPlsactivated);
       
  1953 	}
       
  1954 
       
  1955 // ---------------------------------------------------------------------------
       
  1956 // CIRUi::SetPlsActiavted(..)
       
  1957 // Sets bool if T&C or cost warning view are not accepted
       
  1958 // ---------------------------------------------------------------------------
       
  1959 //
       
  1960 void CIRUi::SetPlsActiavted(TBool aPlsactivated)
       
  1961 	{
       
  1962 	IRLOG_DEBUG( "CIRUi::SetPlsActiavted - Entering" );
       
  1963 	iPlsactivated=aPlsactivated;
       
  1964 	IRLOG_DEBUG( "CIRUi::SetPlsActiavted - Exiting" );
       
  1965 	}
       
  1966 
       
  1967 // ---------------------------------------------------------------------------
       
  1968 // CIRUi::DisplayInformationL
       
  1969 // Display the Information Note
       
  1970 // ----------------------------------------------------------------------------
       
  1971 
       
  1972 void CIRUi::DisplayInformationL(TInt aResourceId, TInt aInt)
       
  1973 	{
       
  1974 	IRLOG_DEBUG( "CIRUi::DisplayInformationL - Entering" );
       
  1975     RBuf channel;
       
  1976 	HBufC* displayinfo=StringLoader::LoadLC(aResourceId,aInt);
       
  1977 	channel.Create(*displayinfo);
       
  1978 	iDialogNote->ShowConfirmationNoteL( channel,ETrue );
       
  1979 	CleanupStack::PopAndDestroy(displayinfo);
       
  1980 	channel.Close();
       
  1981 	IRLOG_DEBUG( "CIRUi::DisplayInformationL - Exiting" );
       
  1982 	}
       
  1983 // ---------------------------------------------------------------------------
       
  1984 // CIRUi::DisplayInformationL
       
  1985 // Display the Information Note
       
  1986 // ----------------------------------------------------------------------------
       
  1987 
       
  1988 void CIRUi::DisplayInformationL(TInt aResourceId, const TDesC &  aString)
       
  1989 	{
       
  1990 	IRLOG_DEBUG( "CIRUi::DisplayInformationL - Entering" );
       
  1991     RBuf channel;
       
  1992 	HBufC* displayinfo=StringLoader::LoadLC(aResourceId,aString);
       
  1993 	channel.Create(*displayinfo);
       
  1994 	iDialogNote->ShowConfirmationNoteL( channel,ETrue );
       
  1995 	CleanupStack::PopAndDestroy(displayinfo);
       
  1996 	channel.Close();
       
  1997 	IRLOG_DEBUG( "CIRUi::DisplayInformationL - Exiting" );
       
  1998 	}
       
  1999 // ---------------------------------------------------------------------------
       
  2000 // CIRUi::GetBgWhenLockState()
       
  2001 // returns the iBgWhenLock lock state.
       
  2002 // ---------------------------------------------------------------------------
       
  2003 //
       
  2004 TBool CIRUi::GetBgWhenLockState()
       
  2005 	{
       
  2006 	IRLOG_DEBUG( "CIRUi::GetBgWhenLockState" );
       
  2007 	return iBgWhenLock;
       
  2008 	}
       
  2009 // ---------------------------------------------------------------------------
       
  2010 // CIRUi::GetCurrentOperatorValue()
       
  2011 // returns the iCurrentOperator value.
       
  2012 // ---------------------------------------------------------------------------
       
  2013 //
       
  2014 TInt CIRUi::GetCurrentOperatorValue()
       
  2015 	{
       
  2016 	IRLOG_DEBUG( "CIRUi::GetCurrentOperatorValue" );
       
  2017 	return iCurrentOperator;
       
  2018 	}
       
  2019 // ---------------------------------------------------------------------------
       
  2020 // CIRUi::GetHomeOperatorValue()
       
  2021 // returns the vallue of iHomeOperator.
       
  2022 // ---------------------------------------------------------------------------
       
  2023 //
       
  2024 TInt CIRUi::GetHomeOperatorValue()
       
  2025 	{
       
  2026 	IRLOG_DEBUG( "CIRUi::GetHomeOperatorValue" );
       
  2027 	return iHomeOperator;
       
  2028 	}
       
  2029 // ---------------------------------------------------------------------------
       
  2030 // CIRUi::GetCallActiveState()
       
  2031 // returns whether iCallActive variable is true/false.
       
  2032 // ---------------------------------------------------------------------------
       
  2033 //
       
  2034 TBool CIRUi::GetCallActiveState()
       
  2035 	{
       
  2036 	IRLOG_DEBUG( "CIRUi::GetCallActiveState" );
       
  2037 	return iCallActive;
       
  2038 	}
       
  2039 // ---------------------------------------------------------------------------
       
  2040 // CIRUi::GetNetworkControllerInstance()
       
  2041 // returns the iNetworkController .
       
  2042 // ---------------------------------------------------------------------------
       
  2043 //
       
  2044 CIRNetworkController* CIRUi::GetNetworkControllerInstance()
       
  2045 	{
       
  2046 	IRLOG_DEBUG( "CIRUi::GetNetworkControllerInstance" );
       
  2047 	return iNetworkController;
       
  2048 	}
       
  2049 // ---------------------------------------------------------------------------
       
  2050 // CIRUi::GetNowPlayingViewInstance()
       
  2051 // returns instance od nowplaying view.
       
  2052 // ---------------------------------------------------------------------------
       
  2053 //
       
  2054 CIRNowPlayingView* CIRUi::GetNowPlayingViewInstance()
       
  2055 	{
       
  2056 	IRLOG_DEBUG( "CIRUi::GetNowPlayingViewInstance" );
       
  2057 	return iNowPlayingView;
       
  2058 	}
       
  2059 // ---------------------------------------------------------------------------
       
  2060 // CIRUi::GetPubSubManagerInstance()
       
  2061 // returns instace of publish subscriber.
       
  2062 // ---------------------------------------------------------------------------
       
  2063 //
       
  2064 CIRPubSub* CIRUi::GetPubSubManagerInstance()
       
  2065 	{
       
  2066 	IRLOG_DEBUG( "CIRUi::GetPubSubManagerInstance" );
       
  2067 	return iPubSubManager;
       
  2068 	}
       
  2069 // ---------------------------------------------------------------------------
       
  2070 // CIRUi::GetCurrentThreadIDValue()
       
  2071 // returns the Current thread ID.
       
  2072 // ---------------------------------------------------------------------------
       
  2073 //
       
  2074 TUint64 CIRUi::GetCurrentThreadIDValue()
       
  2075 	{
       
  2076 	IRLOG_DEBUG( "CIRUi::GetCurrentThreadIDValue" );
       
  2077 	return iCurrentThreadID;
       
  2078 	}
       
  2079 // ---------------------------------------------------------------------------
       
  2080 // CIRUi::GetFavPresetsInstance()
       
  2081 // returns instace of Favourite preset.
       
  2082 // ---------------------------------------------------------------------------
       
  2083 //
       
  2084 CIRFavoritesDb* CIRUi::GetFavPresetsInstance()
       
  2085 	{
       
  2086 	IRLOG_DEBUG( "CIRUi::GetFavPresetsInstance" );
       
  2087 	return iFavPresets;
       
  2088 	}
       
  2089 // ---------------------------------------------------------------------------
       
  2090 // CIRUi::GetNetworkType()
       
  2091 // returns  Network Connection Type.
       
  2092 // ---------------------------------------------------------------------------
       
  2093 //
       
  2094 TIRConnectionType CIRUi::GetNetworkType()
       
  2095 	{
       
  2096 	IRLOG_DEBUG( "CIRUi::GetNetworkType" );
       
  2097 	return iNetWorkType;
       
  2098 	}
       
  2099 // ---------------------------------------------------------------------------
       
  2100 // CIRUi::GetCallConnectedState()
       
  2101 // returns the iCallConnected state.
       
  2102 // ---------------------------------------------------------------------------
       
  2103 //
       
  2104 TBool CIRUi::GetCallConnectedState()
       
  2105 	{
       
  2106 	IRLOG_DEBUG( "CIRUi::GetCallConnectedState" );
       
  2107 	return iCallConnected;
       
  2108 	}
       
  2109 // ---------------------------------------------------------------------------
       
  2110 // CIRUi::SetActivationPendingValue(TUid aUid)
       
  2111 // assign the Id value to iActionPending.
       
  2112 // ---------------------------------------------------------------------------
       
  2113 //
       
  2114 void CIRUi::SetActivationPendingValue(TUid aUid)
       
  2115 	{
       
  2116 	IRLOG_DEBUG( "CIRUi::SetActivationPendingValue - Entering" );
       
  2117 	iActivationPending = aUid;
       
  2118 	IRLOG_DEBUG( "CIRUi::SetActivationPendingValue - Exiting" );
       
  2119 	}
       
  2120 // ---------------------------------------------------------------------------
       
  2121 // CIRUi::GetPresentViewID()
       
  2122 // returns the present view ID.
       
  2123 // ---------------------------------------------------------------------------
       
  2124 //
       
  2125 TUid CIRUi::GetPresentViewID()
       
  2126 	{
       
  2127 	IRLOG_DEBUG( "CIRUi::GetPresentViewID" );
       
  2128 	return iPresentViewID;
       
  2129 	}
       
  2130 
       
  2131 // ---------------------------------------------------------------------------
       
  2132 // CIRUi::HandleCallActive(..)
       
  2133 // Display the battery icon depending upon the battery level
       
  2134 // ---------------------------------------------------------------------------
       
  2135 //
       
  2136 void  CIRUi::HandleCallActiveL(TIRSystemEventType aEventType)
       
  2137 {
       
  2138 IRLOG_DEBUG( "CIRUi::HandleCallActive - Entering" );
       
  2139 switch (aEventType)
       
  2140 	{
       
  2141 	case EIRCallActivated:
       
  2142 		{
       
  2143 		iCallActive=ETrue;
       
  2144 		if( iNowPlayingWrapper->IsProgress())
       
  2145 			{
       
  2146 			if(!(GetCurrentNetworkType().Compare(KWiFi)==0))
       
  2147 				{
       
  2148 				//if progress bar view we will go to the view from where we
       
  2149 				//launched progress bar
       
  2150 				iNowPlayingWrapper->ProgressBarCancel();
       
  2151 
       
  2152 				iNowPlayingWrapper->DestroyWaitDialogL();
       
  2153 				iNowPlayingWrapper->SetProgress(EFalse);
       
  2154 				}
       
  2155 			//current view is progress bar view then previous view has to
       
  2156 			//be activated
       
  2157 			}
       
  2158 		else if(iNowPlayingWrapper->iPlaying )
       
  2159 			{
       
  2160 			//if playing
       
  2161 			//if it was previously playing including rebuffering
       
  2162 			iPlayTerminated = ETrue;
       
  2163 			//the player is expected to stop under all condition when a call comes
       
  2164 			iNowPlayingWrapper->StopPlayer();
       
  2165 			iNowPlayingWrapper->DoPlayingStateChanged( EFalse );
       
  2166 			}
       
  2167 		else
       
  2168 			{
       
  2169 			if ( IsForeground() )
       
  2170 				{
       
  2171 				//if application is in foreground
       
  2172 				iPlayTerminated=EFalse;
       
  2173 				iTriggeringRequired = ETrue;
       
  2174 				}
       
  2175 			else
       
  2176 				{
       
  2177 				iPlayTerminated=EFalse;
       
  2178 				//if application is background
       
  2179 				iTriggeringRequired = EFalse;
       
  2180 				}
       
  2181 
       
  2182 			}
       
  2183 		}
       
  2184 
       
  2185 
       
  2186 
       
  2187 	break;
       
  2188 	case EIRCallDeactivated:
       
  2189 		{
       
  2190 		iCallActive=EFalse;
       
  2191 		//This is check is done to tackle immediate cutting of the call
       
  2192 		//sometimes it is found that it will remain in progress bar it self
       
  2193 		//cancellation is not efficent
       
  2194 		if( iNowPlayingWrapper->IsProgress())
       
  2195 			{
       
  2196 			//if progress bar view we will go to the view from where we
       
  2197 			//launched progress bar
       
  2198 			iNowPlayingWrapper->ProgressBarCancel();
       
  2199 
       
  2200 			iNowPlayingWrapper->DestroyWaitDialogL();
       
  2201 			}
       
  2202 		else if(!iNowPlayingWrapper->iPlaying && iPlayTerminated)
       
  2203 			{
       
  2204 			if(iNowPlayingView->iContainer)
       
  2205 				{
       
  2206 				iNowPlayingWrapper->SetLaunchNowPlayingView(ETrue);
       
  2207 				}
       
  2208 			else
       
  2209 				{
       
  2210 				iNowPlayingWrapper->SetLaunchNowPlayingView(EFalse);
       
  2211 				}
       
  2212 			iNowPlayingWrapper->DoPlayL();
       
  2213 			}
       
  2214 		else
       
  2215 			{
       
  2216 			if( iTriggeringRequired )
       
  2217 				{
       
  2218 				//bringing to fore ground
       
  2219 				ActivateCurrentView(iPresentViewID);
       
  2220 				}
       
  2221 
       
  2222 			}
       
  2223 
       
  2224 
       
  2225 
       
  2226 		}
       
  2227 }
       
  2228 IRLOG_DEBUG( "CIRUi::HandleCallActive - Exiting" );
       
  2229 }
       
  2230 
       
  2231 // ---------------------------------------------------------------------------
       
  2232 // CIRUi::HandleAlarmStart()
       
  2233 // Handles when an alarm starts
       
  2234 // ---------------------------------------------------------------------------
       
  2235 //
       
  2236 void CIRUi::HandleAlarmStart()
       
  2237 	{
       
  2238 	IRLOG_DEBUG( "CIRUi::HandleAlarmStart - Entering" );
       
  2239 	if( iNowPlayingWrapper->IsProgress())
       
  2240 		{
       
  2241 		//if progress bar view we will go to the view from where we
       
  2242 		//launched progress bar
       
  2243 		iNowPlayingWrapper->ProgressBarCancel();
       
  2244 
       
  2245 		TRAP_IGNORE(iNowPlayingWrapper->DestroyWaitDialogL());
       
  2246 		//current view is progress bar view then previous view has to
       
  2247 		//be activated
       
  2248 		}
       
  2249 	else
       
  2250 		{
       
  2251 		//if playing
       
  2252 		if(iNowPlayingWrapper->iPlaying )
       
  2253 			{
       
  2254 
       
  2255 
       
  2256 				iAlarmTerminated = ETrue;
       
  2257 			//if it was previously playing including rebuffering
       
  2258 			//iPlayCallTerminated = ETrue
       
  2259 			//the player is expected to stop under all condition when a call comes
       
  2260 			iNowPlayingWrapper->StopPlayer();
       
  2261 			iNowPlayingWrapper->DoPlayingStateChanged( EFalse );
       
  2262 			}
       
  2263 		}
       
  2264 
       
  2265 	IRLOG_DEBUG( "CIRUi::HandleAlarmStart - Exiting." );
       
  2266 }
       
  2267 
       
  2268 // ---------------------------------------------------------------------------
       
  2269 // CIRUi::HandleAlarmEnd()
       
  2270 // Handles when an alarm ends
       
  2271 // ---------------------------------------------------------------------------
       
  2272 //
       
  2273 void CIRUi::HandleAlarmEnd()
       
  2274 	{
       
  2275 	IRLOG_INFO( "CIRUi::HandleAlarmEnd - Entering" );
       
  2276 	if( iAlarmTerminated )
       
  2277 		{
       
  2278 		iAlarmTerminated = EFalse;
       
  2279 
       
  2280 		if(!iNowPlayingWrapper->iPlaying)
       
  2281 			{
       
  2282       IRRDEBUG2("CIRUi::HandleAlarmEnd - HandleAlarmEnd()",
       
  2283 			 KNullDesC );
       
  2284 
       
  2285 		TRAP_IGNORE(iNowPlayingWrapper->DoPlayL();)
       
  2286 			}
       
  2287 		}
       
  2288 	 if( iTriggeringRequired )
       
  2289 		{
       
  2290 		//bringing to fore ground
       
  2291 		ActivateCurrentView(iPresentViewID);
       
  2292 		}
       
  2293 	IRLOG_DEBUG( "CIRUi::HandleAlarmEnd - Exiting." );
       
  2294 	}
       
  2295 
       
  2296 // ---------------------------------------------------------------------------
       
  2297 // CIRUi::HandleInitialAlarmEvent()
       
  2298 // Handles when an alarm comes initial handling
       
  2299 // ---------------------------------------------------------------------------
       
  2300 //
       
  2301 
       
  2302 
       
  2303 void CIRUi::HandleInitialAlarmEvent()
       
  2304 	{
       
  2305 	IRLOG_DEBUG( "CIRUi::HandleInitialAlarmEvent - Entering" );
       
  2306 	if( iNowPlayingWrapper->IsProgress())
       
  2307 		{
       
  2308 		//if progress bar view we will go to the view from where we
       
  2309 		//launched progress bar
       
  2310 		iNowPlayingWrapper->ProgressBarCancel();
       
  2311 
       
  2312 		TRAP_IGNORE(iNowPlayingWrapper->DestroyWaitDialogL());
       
  2313 		iNowPlayingWrapper->SetProgress(EFalse);
       
  2314 		//current view is progress bar view then previous view has to
       
  2315 		//be activated
       
  2316 		}
       
  2317 	else
       
  2318 		{
       
  2319 		//if playing
       
  2320 		if(iNowPlayingWrapper->iPlaying )
       
  2321 			{
       
  2322 
       
  2323 			iAlarmTerminated = ETrue;
       
  2324 			//if it was previously playing including rebuffering
       
  2325 			//iPlayCallTerminated = ETrue
       
  2326 			//the player is expected to stop under all condition when a call comes
       
  2327 			iNowPlayingWrapper->StopPlayer();
       
  2328 			iNowPlayingWrapper->DoPlayingStateChanged( EFalse );
       
  2329 			}
       
  2330 		}
       
  2331 
       
  2332 		if ( IsForeground() )
       
  2333 		{
       
  2334 		//if application is in foreground
       
  2335 		iTriggeringRequired = ETrue;
       
  2336 		}
       
  2337 	else
       
  2338 		{
       
  2339 		//if application is background
       
  2340 		iTriggeringRequired = EFalse;
       
  2341 		}
       
  2342 	IRLOG_DEBUG( "CIRUi::HandleInitialAlarmEvent - Exiting." );
       
  2343 	}
       
  2344 
       
  2345 // ---------------------------------------------------------------------------
       
  2346 // CIRUi::HandleMessageAlertL()
       
  2347 // Handles when a new message comes
       
  2348 // ---------------------------------------------------------------------------
       
  2349 //
       
  2350 void CIRUi::HandleMessageAlertL()
       
  2351 	{
       
  2352 	IRLOG_DEBUG( "CIRUi::HandleMessageAlertL" );
       
  2353 	return;
       
  2354 	}
       
  2355 // ---------------------------------------------------------------------------
       
  2356 // CIRUi::SetPlsIndex()
       
  2357 // Sets the Pls Index
       
  2358 // ---------------------------------------------------------------------------
       
  2359 //
       
  2360 void CIRUi::SetPlsIndex(TInt aPlsIndex)
       
  2361 {
       
  2362 IRLOG_DEBUG( "CIRUi::SetPlsIndex - Entering" );
       
  2363 	iPlsIndex=aPlsIndex;
       
  2364 
       
  2365 IRLOG_DEBUG( "CIRUi::SetPlsIndex - Exiting." );
       
  2366 
       
  2367 }
       
  2368 // ---------------------------------------------------------------------------
       
  2369 // CIRUi::GetPlsIndex()
       
  2370 // Returns the Pls Index
       
  2371 // ---------------------------------------------------------------------------
       
  2372 //
       
  2373 TInt CIRUi::GetPlsIndex()
       
  2374 {
       
  2375 IRLOG_DEBUG( "CIRUi::GetPlsIndex - Entering" );
       
  2376 IRLOG_DEBUG( "CIRUi::GetPlsIndex - Exiting." );
       
  2377 	return iPlsIndex;
       
  2378 }
       
  2379 // ---------------------------------------------------------------------------
       
  2380 // CIRUi::SetBgLock()
       
  2381 //  Sets the BGround whether it is Locked or Unlocked
       
  2382 // ---------------------------------------------------------------------------
       
  2383 //
       
  2384 void CIRUi::SetBgLock(TInt aBgWhenLock)
       
  2385 {
       
  2386 IRLOG_DEBUG( "CIRUi::SetBgLock - Entering" );
       
  2387 IRLOG_DEBUG( "CIRUi::SetBgLock - Exiting." );
       
  2388 	iBgWhenLock=aBgWhenLock;
       
  2389 }
       
  2390 // ---------------------------------------------------------------------------
       
  2391 // CIRUi::GetPlsIndex()
       
  2392 // Returns whether the Bground is Locked or Unlocked
       
  2393 // ---------------------------------------------------------------------------
       
  2394 //
       
  2395 TBool CIRUi::GetBgLock()
       
  2396 {
       
  2397 IRLOG_DEBUG( "CIRUi::GetBgLock - Entering" );
       
  2398 IRLOG_DEBUG( "CIRUi::GetBgLock - Exiting." );
       
  2399 	return iBgWhenLock;
       
  2400 }
       
  2401 // ---------------------------------------------------------------------------
       
  2402 // CIRUi::SetEditStation()
       
  2403 // 	 Sets the iIsEditStation Flag To determine whether the station
       
  2404 //	 can be Edited
       
  2405 // ---------------------------------------------------------------------------
       
  2406 //
       
  2407 void CIRUi::SetEditStation(TInt aIsEditStation)
       
  2408 {
       
  2409 IRLOG_DEBUG( "CIRUi::SetEditStation - Entering" );
       
  2410 IRLOG_DEBUG( "CIRUi::SetEditStation - Exiting." );
       
  2411 	iIsEditStation=aIsEditStation;
       
  2412 }
       
  2413 // ---------------------------------------------------------------------------
       
  2414 // CIRUi::GetEditStation()
       
  2415 // Returns whether The station can be edited Or not
       
  2416 // ---------------------------------------------------------------------------
       
  2417 //
       
  2418 TBool CIRUi::GetEditStation()
       
  2419 {
       
  2420 IRLOG_DEBUG( "CIRUi::GetEditStation - Entering" );
       
  2421 IRLOG_DEBUG( "CIRUi::GetEditStation - Exiting." );
       
  2422 	return iIsEditStation;
       
  2423 }
       
  2424 // ---------------------------------------------------------------------------
       
  2425 // CIRUi::GetSkinColor()
       
  2426 // CIRUi::GetEditStation()
       
  2427 // Returns the Current Color
       
  2428 // ---------------------------------------------------------------------------
       
  2429 //
       
  2430 TRgb CIRUi::GetSkinColor()
       
  2431 {
       
  2432 	IRLOG_DEBUG( "CIRUi::GetSkinColor - Entering" );
       
  2433 
       
  2434 
       
  2435 	MAknsSkinInstance * skin=AknsUtils::SkinInstance () ;
       
  2436 
       
  2437     TRgb color;
       
  2438     TInt skinColor=AknsUtils::GetCachedColor(skin, color, KAknsIIDQsnTextColors,
       
  2439     				 EAknsCIQsnTextColorsCG6 );
       
  2440 	IRLOG_DEBUG( "CIRUi::GetSkinColor - Exiting" );
       
  2441     return color;
       
  2442 }
       
  2443 // ---------------------------------------------------------------------------
       
  2444 // CIRUi::ChooseToolBarIcons()
       
  2445 // Returns the ToolbarBirmap Id For The Current Theme
       
  2446 // ---------------------------------------------------------------------------
       
  2447 //
       
  2448 TInt  CIRUi::ChooseToolBarBitmaps(TInt aBlack,TInt aWhite)
       
  2449 {
       
  2450 IRLOG_DEBUG( "CIRUi::ChooseToolBarBitmaps - Entering" );
       
  2451 IRLOG_DEBUG( "CIRUi::ChooseToolBarBitmaps - Exiting" );
       
  2452  	if(GetSkinColor().Gray2()==0)
       
  2453     {
       
  2454     return aBlack;
       
  2455     }
       
  2456     else
       
  2457     {
       
  2458      return aWhite;
       
  2459     }
       
  2460 }
       
  2461 
       
  2462 // ---------------------------------------------------------------------------
       
  2463 // CIRUi::ChooseToolBarMaskId()
       
  2464 // Returns the Toolbar mask  Id For The Current Theme
       
  2465 // ---------------------------------------------------------------------------
       
  2466 //
       
  2467 TInt CIRUi::ChooseToolBarMaskId(TInt aBlackMask,TInt aWhiteMask)
       
  2468 {
       
  2469 
       
  2470 IRLOG_DEBUG( "CIRUi::ChooseToolBarMaskId - Entering" );
       
  2471 IRLOG_DEBUG( "CIRUi::ChooseToolBarMaskId - Exiting" );
       
  2472 	if(GetSkinColor().Gray2()==0)
       
  2473     {
       
  2474     return aBlackMask;
       
  2475     }
       
  2476     else
       
  2477     {
       
  2478     return aWhiteMask;
       
  2479     }
       
  2480 }
       
  2481 // ---------------------------------------------------------------------------
       
  2482 // CIRUi::SetHistory()
       
  2483 // Set the Flag From All the Views  When Go to nowplaying Is Done
       
  2484 // ---------------------------------------------------------------------------
       
  2485 //
       
  2486 void CIRUi::SetHistory(TBool aHistory)
       
  2487 {
       
  2488 IRLOG_DEBUG( "CIRUi::SetHistory - Entering" );
       
  2489 IRLOG_DEBUG( "CIRUi::SetHistory - Exiting" );
       
  2490 iHistory=aHistory;
       
  2491 }
       
  2492 // ---------------------------------------------------------------------------
       
  2493 // CIRUi::SetHistory()
       
  2494 // Return the iAlarmTerminated Flag
       
  2495 // ---------------------------------------------------------------------------
       
  2496 //
       
  2497 TBool CIRUi::GetAlarm()
       
  2498 {
       
  2499 IRLOG_DEBUG( "CIRUi::GetAlarm - Entering" );
       
  2500 IRLOG_DEBUG( "CIRUi::GetAlarm - Exiting" );
       
  2501 	return iAlarmTerminated;
       
  2502 }
       
  2503 
       
  2504 // ---------------------------------------------------------------------------
       
  2505 // CIRUi::SetPlayStateWhileCall
       
  2506 // Sets This Value When Stoping the Player
       
  2507 // While Call is Active
       
  2508 // ---------------------------------------------------------------------------
       
  2509 //
       
  2510 void CIRUi::SetPlayStateWhileCall(TBool aPlayTerminated)
       
  2511 {
       
  2512  iPlayTerminated = aPlayTerminated;
       
  2513 }
       
  2514 
       
  2515 // ---------------------------------------------------------------------------
       
  2516 // CIRUi::GetPlayStateWhileCall
       
  2517 // Returns the Value of Play state
       
  2518 // While Call is Active
       
  2519 // ---------------------------------------------------------------------------
       
  2520 //
       
  2521 TBool CIRUi::GetPlayStateWhileCall()
       
  2522 {
       
  2523  return iPlayTerminated ;
       
  2524 }
       
  2525 
       
  2526 
       
  2527 // ---------------------------------------------------------------------------
       
  2528 // IsFlagIfAnyFavL()
       
  2529 // Method to determine if any channel was added to favorites
       
  2530 // ---------------------------------------------------------------------------
       
  2531 //
       
  2532  TBool CIRUi::IsFlagIfAnyFavL()
       
  2533 	{
       
  2534 	IRLOG_DEBUG( "CIRUi::IsFlagIfAnyFavL - Entering" );
       
  2535 	IRLOG_DEBUG( "CIRUi::IsFlagIfAnyFavL - Exiting" );
       
  2536 	return (iIRSettings->IsFlagIfAnyFavL());
       
  2537 	 }
       
  2538 // ---------------------------------------------------------------------------
       
  2539 // SetMainView()
       
  2540 // Method to set that the now playing view flag is from the Main view
       
  2541 // ---------------------------------------------------------------------------
       
  2542 //
       
  2543 void CIRUi::SetMainView(TBool val)
       
  2544 	{
       
  2545 	iMainViewLaunch = val;
       
  2546 	}
       
  2547 
       
  2548 
       
  2549 #ifdef FF_IAUPDATE
       
  2550 void CIRUi::CheckUpdatesComplete( TInt aErrorCode, TInt aAvailableUpdates )
       
  2551     {
       
  2552     IRRDEBUG2("CIRUi:: CheckUpdatesComplete - Entered", KNullDesC);
       
  2553     IRRDEBUG2("CIRUi::CheckUpdatesComplete ErrorCode Received: %d", aErrorCode);
       
  2554     if ( aErrorCode == KErrNone )
       
  2555     	{
       
  2556     	IRRDEBUG2("CIRUi::CheckUpdatesComplete AvailableUpdates: %d", aAvailableUpdates);
       
  2557     	if ( aAvailableUpdates > 0 )
       
  2558     	    {
       
  2559     	    /**
       
  2560     		 * There were some updates available. Let's ask if the
       
  2561     		 * user wants to update them
       
  2562     		 */
       
  2563             iUpdate->UpdateQuery();
       
  2564             IRRDEBUG2("CIRUi::CheckUpdatesComplete After Call to UpdateQuery", KNullDesC);
       
  2565     	    }
       
  2566     	else
       
  2567     	    {
       
  2568             /**
       
  2569              * No updates available. CIAUpdate object could be deleted
       
  2570              * already now, since we are not going to call anything else
       
  2571              * from the API. This will also close down the IAUpdate server
       
  2572              */
       
  2573             IRRDEBUG2("CIRUi::CheckUpdatesComplete No Updates are available deleting handles", KNullDesC);
       
  2574             delete iUpdate;
       
  2575             iUpdate = NULL;
       
  2576             delete iParameters;
       
  2577             iParameters = NULL;
       
  2578     	    }
       
  2579     	}
       
  2580     IRRDEBUG2("CIRUi:: CheckUpdatesComplete - Leaving", KNullDesC);
       
  2581     }
       
  2582 
       
  2583 void CIRUi::UpdateComplete(TInt aErrorCode, CIAUpdateResult* aResult)
       
  2584     {
       
  2585     IRRDEBUG2("CIRUi:: UpdateComplete - Entered", KNullDesC);
       
  2586     IRRDEBUG2("CIRUi:: UpdateComplete - ErrorCode Received: %d", aErrorCode);
       
  2587     if ( aErrorCode == KErrNone )
       
  2588     	{
       
  2589         /**
       
  2590          * The update process that the user started from IAUpdate UI is
       
  2591          * now completed. If the client application itself was updated in
       
  2592          * the update process, this callback is never called, since the
       
  2593          * client is not running anymore
       
  2594          */
       
  2595         TInt successCount = aResult->SuccessCount();
       
  2596         IRRDEBUG2("CIRUi:: UpdateComplete - After Call to SuccessCount", KNullDesC);
       
  2597         }
       
  2598     /**
       
  2599      * Ownership was transferred, so this must be deleted by the client
       
  2600      */
       
  2601     delete aResult;
       
  2602 
       
  2603     /**
       
  2604      * We do not need the client-server session anymore, let's
       
  2605      * delete the object to close the session
       
  2606      */
       
  2607     delete iUpdate;
       
  2608     iUpdate = NULL;
       
  2609     delete iParameters;
       
  2610     iParameters = NULL;
       
  2611     IRRDEBUG2("CIRUi:: UpdateComplete - Leaving", KNullDesC);
       
  2612     }
       
  2613 
       
  2614 void CIRUi::UpdateQueryComplete( TInt aErrorCode, TBool aUpdateNow )
       
  2615     {
       
  2616     IRRDEBUG2("CIRUi:: UpdateQueryComplete - Entered", KNullDesC);
       
  2617     IRRDEBUG2("CIRUi:: UpdateQueryComplete - ErrorCode Received: %d", aErrorCode);
       
  2618     if ( aErrorCode == KErrNone )
       
  2619         {
       
  2620         IRRDEBUG2("CIRUi:: UpdateQueryComplete - aUpdateNow: %d", aUpdateNow);
       
  2621     	if ( aUpdateNow )
       
  2622     	    {
       
  2623             /**
       
  2624              * User choosed to update now, so let's launch the IAUpdate UI.
       
  2625              */
       
  2626             iUpdate->ShowUpdates( *iParameters );
       
  2627             IRRDEBUG2("CIRUi:: UpdateQueryComplete - After Call to ShowUpdates", KNullDesC);
       
  2628     	    }
       
  2629         else
       
  2630             {
       
  2631             /**
       
  2632              * The answer was 'Later'. CIAUpdate object could be deleted
       
  2633              * already now, since we are not going to call anything else
       
  2634              * from the API. This will also close down the IAUpdate server
       
  2635              */
       
  2636             delete iUpdate;
       
  2637             iUpdate = NULL;
       
  2638             delete iParameters;
       
  2639             iParameters = NULL;
       
  2640             }
       
  2641         }
       
  2642     IRRDEBUG2("CIRUi:: UpdateQueryComplete - Leaving", KNullDesC);
       
  2643     }
       
  2644 #endif // FF_IAUPDATE
       
  2645 
       
  2646 
       
  2647 void CIRUi::FindInMusicStoreCounter()
       
  2648 	{
       
  2649 	IRLOG_DEBUG("CIRUi::FindInMusicStoreCounter() - Entered");
       
  2650 	iFindInMusicStoreCount++;
       
  2651 	IRLOG_DEBUG("CIRUi::FindInMusicStoreCounter() - Leaving");
       
  2652 	}
       
  2653 
       
  2654 void CIRUi::GetFindInMusicStoreCount(TInt& aFindInMStoreCount)
       
  2655 	{
       
  2656 	IRLOG_DEBUG("CIRUi::GetFindInMusicStoreCount() - Entered");
       
  2657 	aFindInMStoreCount = iFindInMusicStoreCount;
       
  2658 	IRLOG_DEBUG("CIRUi::GetFindInMusicStoreCount() - Leaving");
       
  2659 	}
       
  2660 
       
  2661 TBool CIRUi::IsOfflineProfile()
       
  2662 	{
       
  2663 	IRLOG_DEBUG("CIRUi::IsOfflineProfile() - Entered");
       
  2664 	IRLOG_DEBUG("CIRUi::IsOfflineProfile() - Leaving");
       
  2665 	return iIsOffline;
       
  2666 	}
       
  2667 
       
  2668 // ---------------------------------------------------------------------------
       
  2669 // HandleProfileActivatedL()
       
  2670 // Method called whenever there is a change in the profile
       
  2671 // ---------------------------------------------------------------------------
       
  2672 //
       
  2673 void CIRUi::HandleProfileActivatedL(TInt aProfileId)
       
  2674 	{
       
  2675 	IRRDEBUG2("CIRUi::HandleProfileActivatedL - Entering aProfileId = %d",aProfileId );
       
  2676     const TInt KProfileId=5;
       
  2677 	if(iProfileId==aProfileId)
       
  2678 		{
       
  2679 		return;
       
  2680 		}
       
  2681 	if(aProfileId==KProfileId)
       
  2682 		{
       
  2683 		if ( iIsdsWrapper->GetISDSInstance() )
       
  2684 			{
       
  2685 			if(iIsdsWrapper->GetListenRequest()||(iNowPlayingWrapper->iSyncPreset))
       
  2686 				{
       
  2687 				iNowPlayingWrapper->DestroyWaitDialogL();
       
  2688 				}
       
  2689 			iNowPlayingWrapper->iSyncPreset=EFalse;
       
  2690 			iIsdsWrapper->DestroyWaitDialogL();
       
  2691 			iIsdsWrapper->GetISDSInstance()->IRISDSCancelRequest();
       
  2692 			iIsdsWrapper->GetISDSInstance()->ReleaseResources();
       
  2693 			}
       
  2694 		if(iNowPlayingWrapper->iPlaying && (!iNowPlayingWrapper->IsProgress()))
       
  2695 			{
       
  2696 			iNowPlayingWrapper->StopNow();
       
  2697 			if(ActiveView() == KIRMainChoiceViewID)
       
  2698 				{
       
  2699 				iMainView->GetMainContainer()->UpdateAllL();
       
  2700 				}
       
  2701 
       
  2702 			}
       
  2703 		else
       
  2704 			{
       
  2705 			if(iNowPlayingWrapper->GetConnectToServerState() && !iNowPlayingWrapper->IsProgress())
       
  2706 				{
       
  2707 				iNowPlayingWrapper->CancelNetworkRequestL();
       
  2708 				iNowPlayingWrapper->DestroyWaitDialogL();
       
  2709 				}
       
  2710 			//player is stopped
       
  2711 			if( iNowPlayingWrapper->IsProgress() )
       
  2712 				{
       
  2713 				//if in progress bar view, progress bar is cancelled
       
  2714 				iNowPlayingWrapper->ProgressBarCancel();
       
  2715 				iNowPlayingWrapper->DestroyWaitDialogL();
       
  2716 				}
       
  2717 			}
       
  2718 
       
  2719 		//network got disconnected
       
  2720 		/*iNetworkIndicatorTimer->Cancel();
       
  2721 		//connection status is reset in network controller
       
  2722 		iNetworkController->ResetConnectionStatus();
       
  2723 		if ( iIsdsWrapper->GetISDSInstance() )
       
  2724 		{
       
  2725 		iIsdsWrapper->DestroyWaitDialogL();
       
  2726 		iIsdsWrapper->GetISDSInstance()->IRISDSCancelRequest();
       
  2727 		iIsdsWrapper->GetISDSInstance()->ReleaseResources();
       
  2728 		}
       
  2729 		//player is stopped
       
  2730 		if( iNowPlayingWrapper->IsProgress() )
       
  2731 		{
       
  2732 		//if in progress bar view, progress bar is cancelled
       
  2733 		iNowPlayingWrapper->ProgressBarCancel();
       
  2734 
       
  2735 		iNowPlayingWrapper->DestroyWaitDialogL();
       
  2736 		}
       
  2737 		else
       
  2738 		{
       
  2739 		if(iNowPlayingWrapper->iPlaying)
       
  2740 		{
       
  2741 		iNowPlayingWrapper->StopNow();
       
  2742 		if(ActiveView() == KIRMainChoiceViewID)
       
  2743 		{
       
  2744 		iMainView->GetMainContainer()->UpdateAllL();
       
  2745 		}
       
  2746 		}
       
  2747 		}
       
  2748 		*/
       
  2749 		iProfileId=aProfileId;
       
  2750 		}
       
  2751 	else
       
  2752 		{
       
  2753 		iProfileId=aProfileId;
       
  2754 		}
       
  2755 	IRRDEBUG2("CIRUi::HandleProfileActivatedL - Exiting",KNullDesC );
       
  2756 
       
  2757 }
       
  2758 RArray<TInt>& CIRUi::GetPlsSaved()
       
  2759 	{
       
  2760 	return iPlsPresetSaved;
       
  2761 	}
       
  2762 void CIRUi::SetListenFromPls(TBool aValue)
       
  2763 	{
       
  2764 	iListenFromPls = aValue ;
       
  2765 	}
       
  2766 TBool CIRUi::GetListenFromPls()
       
  2767 	{
       
  2768 	return iListenFromPls ;
       
  2769 	}
       
  2770 void CIRUi::SetListenFromSecondPls(TBool aValue)
       
  2771 	{
       
  2772 	iListenFrmSecondPls = aValue;
       
  2773 	}
       
  2774 TBool CIRUi::GetListenFromSecondPls()
       
  2775 	{
       
  2776 	return iListenFrmSecondPls ;
       
  2777 	}
       
  2778 
       
  2779 // ---------------------------------------------------------------------------
       
  2780 // HandleProfileActivationNotificationError()
       
  2781 // Method called whenever there is an error while change in the profile
       
  2782 // ---------------------------------------------------------------------------
       
  2783 //
       
  2784 void CIRUi:: HandleProfileActivationNotificationError (TInt)
       
  2785 {
       
  2786 
       
  2787 }
       
  2788 
       
  2789 
       
  2790 // ---------------------------------------------------------------------------
       
  2791 // CIRUi::CheckAndNotifyLowDiskSpaceL
       
  2792 // ---------------------------------------------------------------------------
       
  2793 //
       
  2794 TBool CIRUi::CheckAndNotifyLowDiskSpaceL() const
       
  2795     {
       
  2796 	IRRDEBUG2("CIRUi::CheckAndNotifyLowDiskSpaceL - Entering", KNullDesC);
       
  2797     TBool isLow = iSystemEventCollector->IsDiskSpaceBelowCriticalLevel();
       
  2798     if ( isLow )
       
  2799 		{
       
  2800 		IRRDEBUG2("CIRUi::CheckAndNotifyLowDiskSpaceL - Phone LOW MEMORY detected", KNullDesC);
       
  2801 		iDialogLauncher->ShowInformationNoteL( R_IRAPP_MEMLO_RAM_OUT_OF_MEM, ETrue);
       
  2802 		}
       
  2803 
       
  2804 	IRRDEBUG2("CIRUi::CheckAndNotifyLowDiskSpaceL - Exiting", KNullDesC);
       
  2805     return isLow;
       
  2806     }
       
  2807 
       
  2808 
       
  2809 // ---------------------------------------------------------
       
  2810 // CIRUi::HandleSystemEventL
       
  2811 // from base class MIRSystemEventObserver
       
  2812 // ---------------------------------------------------------
       
  2813 //
       
  2814 void CIRUi::HandleSystemEventL(TIRSystemEventType aEventType)
       
  2815 	{
       
  2816 	IRLOG_DEBUG("CIRUi::HandleSystemEventL - Entering");
       
  2817 
       
  2818 	switch (aEventType)
       
  2819 		{
       
  2820 		case EIRHeadsetConnected:
       
  2821             {
       
  2822             StopDisplayingMenuBar();
       
  2823             break;
       
  2824             }
       
  2825         case EIRHeadsetDisconnected:
       
  2826             {
       
  2827             StopDisplayingMenuBar();
       
  2828             break;
       
  2829             }
       
  2830 		case EIRLowDiskSpace:
       
  2831 			{
       
  2832 			IRRDEBUG2("CIRUi::HandleSystemEventL - EIRLowDiskSpace reported", KNullDesC);
       
  2833 
       
  2834 			// Cancel pending logo requests
       
  2835 			iIsdsWrapper->GetISDSInstance()->GetDataProvider()->GetHttpDataProvider()->
       
  2836 			GetLogoDownloadEngine()->CancelTransaction();
       
  2837 
       
  2838 			// Cancel pending ISDS requests & Preset request for Listen
       
  2839             if ( iIsdsWrapper->GetISDSInstance() )
       
  2840                 {
       
  2841                 if(iIsdsWrapper->GetListenRequest())
       
  2842 			  		{
       
  2843 					iNowPlayingWrapper->DestroyWaitDialogL();
       
  2844 			  		}
       
  2845                 iIsdsWrapper->DestroyWaitDialogL();
       
  2846        			iIsdsWrapper->GetISDSInstance()->IRISDSCancelRequest();
       
  2847  			    iIsdsWrapper->GetISDSInstance()->ReleaseResources();
       
  2848                 }
       
  2849         	// Stop playing
       
  2850         	if(iNowPlayingWrapper->iPlaying && !iNowPlayingWrapper->IsProgress() )
       
  2851 				{
       
  2852 				iNowPlayingWrapper->StopNow();
       
  2853 				if(ActiveView() == KIRMainChoiceViewID)
       
  2854 					{
       
  2855 					iMainView->GetMainContainer()->UpdateAllL();
       
  2856 					}
       
  2857 				}
       
  2858 			// Cancel ConnectToServer requests
       
  2859 	        else if(iNowPlayingWrapper->GetConnectToServerState()
       
  2860 	        		&& !iNowPlayingWrapper->IsProgress())
       
  2861 				{
       
  2862 				iNowPlayingWrapper->CancelNetworkRequestL();
       
  2863 				iNowPlayingWrapper->DestroyWaitDialogL();
       
  2864 				}
       
  2865 			// Cancel Listen streaming requests
       
  2866 			else if( iNowPlayingWrapper->IsProgress() )
       
  2867 				{
       
  2868 				//if in progress bar view, progress bar is cancelled
       
  2869 				iNowPlayingWrapper->ProgressBarCancel();
       
  2870 				iNowPlayingWrapper->DestroyWaitDialogL();
       
  2871 				}
       
  2872 
       
  2873 			// Show Low Memory warning
       
  2874 			iDialogLauncher->ShowInformationNoteL( R_IRAPP_MEMLO_RAM_OUT_OF_MEM, ETrue);
       
  2875 			}
       
  2876 		break;
       
  2877 		default:
       
  2878 			{
       
  2879 			}
       
  2880 		break;
       
  2881 		}
       
  2882 	IRLOG_DEBUG( "CIRUi::HandleSystemEventL - Exiting." );
       
  2883 	}
       
  2884 // ---------------------------------------------------------------------------
       
  2885 // CIRUi::DetermineCurrentProfile
       
  2886 // Used to determine the current profile
       
  2887 // ---------------------------------------------------------------------------
       
  2888 //
       
  2889 TInt CIRUi::DetermineCurrentProfile() const
       
  2890 	{
       
  2891 	IRLOG_DEBUG( "CIRUi::DetermineCurrentProfile" );
       
  2892 	TInt value = KErrNone;
       
  2893 
       
  2894 	TRAPD(err,
       
  2895 	CRepository* cRepositoryHandle = CRepository::NewLC(KCRUidProfileEngine );
       
  2896 	cRepositoryHandle->Get(KProEngActiveProfile,value);
       
  2897 	CleanupStack::PopAndDestroy(cRepositoryHandle);	)
       
  2898 	if(err != KErrNone)
       
  2899 		{
       
  2900 		value = err;
       
  2901 		}
       
  2902 
       
  2903 	IRLOG_DEBUG( "CIRUi::DetermineCurrentProfile - Exiting." );
       
  2904 	return value;
       
  2905 	}
       
  2906 
       
  2907 
       
  2908 
       
  2909 
       
  2910 
       
  2911 
       
  2912 
       
  2913 //ADDED BY SNIGDHA FOR HOMESCREEN
       
  2914 
       
  2915 
       
  2916 
       
  2917 
       
  2918 // ---------------------------------------------------------------------------
       
  2919 // CIRUi::ProcessActionHandlerCommandParameter
       
  2920 // ---------------------------------------------------------------------------
       
  2921 void CIRUi::ProcessActionHandlerCommandParameter( const TDesC8& aTail )
       
  2922     {
       
  2923    IRRDEBUG2("CIRUi::ProcessActionHandlerCommandParameter entering", KNullDesC);
       
  2924 
       
  2925     if ( aTail.Compare( KIRCommandLineActionHandlerCommandStartNowPlayingView() ) == 0 )
       
  2926         {
       
  2927         iStartUpInNowPlayingView = ETrue;
       
  2928         }
       
  2929 
       
  2930    IRRDEBUG2("CIRUi::ProcessActionHandlerCommandParameter exiting", KNullDesC);
       
  2931 
       
  2932     }
       
  2933 
       
  2934 // ---------------------------------------------------------------------------
       
  2935 // CIRUi::ProcessCommandTailL
       
  2936 // ---------------------------------------------------------------------------
       
  2937 void CIRUi::ProcessCommandTailL( const TDesC8& aTail )
       
  2938     {
       
  2939 
       
  2940    IRRDEBUG2("CIRUi::ProcessCommandTailL entering", KNullDesC);
       
  2941 
       
  2942     TLex8 tailLex( aTail );
       
  2943     TChar peek = tailLex.Peek();
       
  2944 
       
  2945     if ( peek != KIRCommandLineOptionPrefix && peek != 0) // old CLI: expect only preset ID.
       
  2946         {
       
  2947         }
       
  2948     else if ( peek != 0 )
       
  2949         {
       
  2950         TPtrC8 option = tailLex.NextToken();
       
  2951 
       
  2952         // Get option
       
  2953         if ( option.Length() > 0 )
       
  2954             {
       
  2955             tailLex.SkipSpaceAndMark();
       
  2956             TPtrC8 rest = tailLex.Remainder();
       
  2957 
       
  2958             if ( option.Compare( KIRCommandLineActionHandler() )  == 0 )
       
  2959                 {
       
  2960                 ProcessActionHandlerCommandParameter( rest );
       
  2961                 }
       
  2962             else
       
  2963                 {
       
  2964                 User::Leave( KErrArgument );
       
  2965                 }
       
  2966             }
       
  2967         }
       
  2968     else
       
  2969         {
       
  2970         // NOP
       
  2971         }
       
  2972 
       
  2973        IRRDEBUG2("CIRUi::ProcessCommandTailL exiting", KNullDesC);
       
  2974 
       
  2975     }
       
  2976 
       
  2977 // ---------------------------------------------------------------------------
       
  2978 // From class CEikAppUi.
       
  2979 // Processes shell commands.
       
  2980 // ---------------------------------------------------------------------------
       
  2981 //
       
  2982 TBool CIRUi::ProcessCommandParametersL( TApaCommand aCommand, TFileName&
       
  2983         aDocumentName, const TDesC8& aTail )
       
  2984 	{
       
  2985 	IRRDEBUG2("CIRUi::ProcessCommandParametersL entering", KNullDesC);
       
  2986 
       
  2987 	TBool ret = CAknViewAppUi::ProcessCommandParametersL( aCommand,
       
  2988 	aDocumentName, aTail );
       
  2989 
       
  2990 
       
  2991 	ProcessCommandTailL( aTail );
       
  2992 	IRRDEBUG2("CIRUi::ProcessCommandParametersL exiting", KNullDesC);
       
  2993 
       
  2994 	return ret;
       
  2995 	}
       
  2996 
       
  2997 
       
  2998 // ---------------------------------------------------------------------------
       
  2999 // From class CEikAppUi.
       
  3000 // Handles window server messages.
       
  3001 // ---------------------------------------------------------------------------
       
  3002 //
       
  3003 MCoeMessageObserver::TMessageResponse CIRUi::HandleMessageL(
       
  3004         TUint32 aClientHandleOfTargetWindowGroup, TUid aMessageUid,
       
  3005         const TDesC8& aMessageParameters )
       
  3006     {
       
  3007     IRRDEBUG2("CIRUi::HandleMessageL Entering", KNullDesC);
       
  3008 
       
  3009     TMessageResponse resp = CAknViewAppUi::HandleMessageL(
       
  3010         aClientHandleOfTargetWindowGroup, aMessageUid, aMessageParameters );
       
  3011 
       
  3012     if ( resp == EMessageNotHandled && aMessageUid == KUidActiveInternetRadioApp)
       
  3013     	{
       
  3014         ProcessCommandTailL( aMessageParameters );
       
  3015         resp = EMessageHandled;
       
  3016 
       
  3017      	IRRDEBUG2("CIRUi::HandleMessageL iStartUpInNowPlayingView = %d", iStartUpInNowPlayingView);
       
  3018 
       
  3019         // Activate now playing view to now playing or last played channel
       
  3020         if ( iStartUpInNowPlayingView )
       
  3021 			{
       
  3022 			IRRDEBUG2("CIRUi::HandleMessageL ActivateLocalViewL", KNullDesC);
       
  3023 
       
  3024 			ActivateLocalViewL( KIRNowPlayingViewID );
       
  3025 
       
  3026 			iStartUpInNowPlayingView = EFalse;
       
  3027 			}
       
  3028     	}
       
  3029     else
       
  3030         {
       
  3031         // NOP
       
  3032         }
       
  3033     IRRDEBUG2("CIRUi::HandleMessageL exiting", KNullDesC);
       
  3034 
       
  3035     return resp;
       
  3036     }
       
  3037 
       
  3038 // ---------------------------------------------------------------------------
       
  3039 // CVRAppUi::BringToForeground
       
  3040 // ---------------------------------------------------------------------------
       
  3041 //
       
  3042 void CIRUi::BringToForeground() const
       
  3043     {
       
  3044     IRLOG_DEBUG( " *** S60VisualRadio -- CVRAppUi::BringToForeground" );
       
  3045 
       
  3046     TApaTask task( iEikonEnv->WsSession() );
       
  3047     task.SetWgId( iEikonEnv->RootWin().Identifier() );
       
  3048     task.BringToForeground();
       
  3049     }
       
  3050 // ---------------------------------------------------------------------------
       
  3051 // CVRAppUi::SendToBackground
       
  3052 // ---------------------------------------------------------------------------
       
  3053 //
       
  3054 void CIRUi::SendToBackground() const
       
  3055     {
       
  3056     IRLOG_DEBUG( " *** S60VisualRadio -- CVRAppUi::SendToBackground" );
       
  3057     TApaTask task( iEikonEnv->WsSession() );
       
  3058     task.SetWgId( iEikonEnv->RootWin().Identifier() );
       
  3059     task.SendToBackground();
       
  3060     }
       
  3061 // ---------------------------------------------------------------------------
       
  3062 // CIRUi::PlayerStateChangedL
       
  3063 // Changes the state of the player
       
  3064 // ---------------------------------------------------------------------------
       
  3065 //
       
  3066 
       
  3067 void CIRUi::PlayerStateChangedL(TIRStopPlayState /*aState*/)
       
  3068 	{
       
  3069 	IRRDEBUG2("CIRUi::PlayerStateChangedL entering",KNullDesC);
       
  3070 
       
  3071 
       
  3072 	iNowPlayingWrapper->PlayAndStopL();
       
  3073 	IRRDEBUG2("CIRUi::PlayerStateChangedL exitng",KNullDesC);
       
  3074 
       
  3075 	}
       
  3076 
       
  3077 
       
  3078 // ---------------------------------------------------------------------------
       
  3079 // From class MCoeViewActivationObserver.
       
  3080 // Notification that a view is being activated.
       
  3081 // ---------------------------------------------------------------------------
       
  3082 //
       
  3083 void CIRUi::HandleViewActivation( const TVwsViewId& aNewlyActivatedViewId,
       
  3084                                      const TVwsViewId& /*aViewIdToBeDeactivated*/ )
       
  3085     {
       
  3086     IRLOG_DEBUG( " *** S60VisualRadio -- CIRUi::HandleViewActivation" );
       
  3087     if ( aNewlyActivatedViewId.iAppUid == TUid::Uid( KUIDIRAPP ) )
       
  3088         {
       
  3089 #ifdef __IRA_FEATURE_BACKSTEPPING_SERVICE
       
  3090         TRAP_IGNORE( iBsWrapper->HandleViewActivationEventL( aNewlyActivatedViewId, ETrue ) )
       
  3091 #endif
       
  3092         }
       
  3093     }
       
  3094 
       
  3095 
       
  3096