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