internetradio2.0/uisrc/irmainview.cpp
changeset 0 09774dfdd46b
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:  Main View
       
    15 *
       
    16 */
       
    17 /*
       
    18 * ============================================================================
       
    19 *  Name        : irmainview.cpp
       
    20 *  Part of     : InternetRadio
       
    21 *  Description : Main View
       
    22 *  Version    :
       
    23 * ============================================================================
       
    24 *
       
    25 */
       
    26 
       
    27 /* ---------------------------------------------------------------------------
       
    28 *  Version history:
       
    29 *  Template version:
       
    30 *  <ccm_history>
       
    31 *
       
    32 *  Version: 2, Tue Feb 28 18:00:00 2008 by Neelima
       
    33 *  Ref:
       
    34 *  Added Workaround in CIRMainView::HandleCommandL() Listen/Add to Favourates is implemented and the dummy functionality is removed
       
    35 *
       
    36 *
       
    37 *  </ccm_history>
       
    38 * ============================================================================
       
    39 */
       
    40 /* ---------------------------------------------------------------------------
       
    41 *  Version history:
       
    42 *  Template version:
       
    43 *  <ccm_history>
       
    44 *
       
    45 *  Version: 2, Sat Feb 18:12:00 2008 by Neelima
       
    46 *  Ref:
       
    47 *  Added Workaround in CIRMainView::Handlecommandl() for deleting the stations and necessary dialogs  .
       
    48 *  and also handled necessary cases for add to favourites.
       
    49 *  </ccm_history>
       
    50 * ============================================================================
       
    51 */
       
    52 /* ---------------------------------------------------------------------------
       
    53 *  Version history:
       
    54 *  Template version:
       
    55 *  <ccm_history>
       
    56 *
       
    57 *  Version: 1, Thrus Feb 20 07:35:00 2008 by Neelima
       
    58 *  Ref:
       
    59 *  Added Workaround in CIRMainView::DynInitMenuPaneL() for displaying "Go to Now playing" & "update" options .
       
    60 *  </ccm_history>
       
    61 * ============================================================================
       
    62 */
       
    63 /* ---------------------------------------------------------------------------
       
    64 *  Version history:
       
    65 *  Template version:
       
    66 *  <ccm_history>
       
    67 *
       
    68 *  Version: 10, July 8 tue 18:44:00 2008 by Rohit
       
    69 *  Implemented delayed activation for Station Information view in case of no network connectivity
       
    70 *
       
    71 *  Version: 9, May 28 wed 16:34:00 2008 by Rohit
       
    72 *  Fixed bug to verify network before invoking Station Information view
       
    73 *
       
    74 *  Version: 8, May 5 wed 19:14:00 2008 by Rohit
       
    75 *  Fixed bug to show Song Information view for last played station
       
    76 *
       
    77 *  Version: 7, Apr 30 wed 14:10:00 2008 by Rohit
       
    78 *  Added handler to invoke Song Information view
       
    79 *
       
    80 *  Version: 6, April 29 tue 12:15:00 2008 by Neelima
       
    81 *  Changed the container to CCoeControl and implemented dynamic filtering
       
    82 *
       
    83 *  Version: 5, April 18 wed 10:41:00 2008 by Neelima
       
    84 *  Updated after pc-lint run
       
    85 *
       
    86 *  Version: 4, April 17 wed 08:06:00 2008 by Neelima
       
    87 *  Ref:
       
    88 *  Customisation of  mark/unmark
       
    89 *
       
    90 *  Version: 3, April 9 wed 19:12:00 2008 by Neelima
       
    91 *  Ref:
       
    92 *  Added Workaround in CIRMainContainer::DeleteMultiStationsL() the code for deleting the stations and necessary dialogs  .
       
    93 *
       
    94 *  Version: 2, Thrus Feb 20 08:52:00 2008 by Neelima
       
    95 *  Ref:
       
    96 *  Added Workaround in CIRMainView::Handlecommandl() Added marm/unmark commands and necessary functionality
       
    97 *  also implemented delete for marked items
       
    98 *  </ccm_history>
       
    99 * ============================================================================
       
   100 */
       
   101 /* ---------------------------------------------------------------------------
       
   102 *  Version history:
       
   103 *  Template version:
       
   104 *  <ccm_history>
       
   105 *
       
   106 *  Version: 9, may 13 Wed 05:55:00 2008 by Neelima
       
   107 * Implemeted Listen on dynamic filtered stations.
       
   108 * ============================================================================
       
   109 */
       
   110 
       
   111 
       
   112 #include <stringloader.h>
       
   113 #include <hlplch.h>
       
   114 #include <internetradio.rsg>
       
   115 #include <internetradio.mbg>
       
   116 //For Touch Toolbar
       
   117 #include <akntoolbar.h>
       
   118 
       
   119 
       
   120 
       
   121 #include "irui.h"
       
   122 #include "ir.hrh"
       
   123 #include "ircommon.h"
       
   124 #include "irdebug.h"
       
   125 #include "irbaseview.h"
       
   126 #include "irmainview.h"
       
   127 #include "irmaincontainer.h"
       
   128 #include "irisdswrapper.h"
       
   129 #include "irstationinfoview.h"
       
   130 #include "irchannelserverurl.h"
       
   131 #include "irhistory.h"
       
   132 #include "irnowplayingview.h"
       
   133 #include "irdialoglauncher.h"
       
   134 #include "irnowplayingwrapper.h"
       
   135 #include "irnetworkcontroller.h"
       
   136 #include "irfilteredmodel.h"
       
   137 #include "iradvertisinglistbox.h"
       
   138 #include "msyncpresetobserver.h"	// MSyncPresetObserver
       
   139 #include "irlogodownloadengine.h"
       
   140 #include "irdataprovider.h"
       
   141 #include "irhttpdataprovider.h"
       
   142 #include "irpubsub.h"
       
   143 
       
   144 
       
   145 const TInt KUrlbufMaxLength = 256;
       
   146 const TInt KDummyLength = 10;
       
   147 const TInt KNull = 0;
       
   148 const TInt KIsdsPreset = 1;
       
   149 const TInt KLPLogoSize = 59;
       
   150 const TInt KLPReqFrom = 0;
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // CIRMainView::CIRMainView()
       
   154 // C++ default constructor can NOT contain any code, that might leave.
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 CIRMainView::CIRMainView()
       
   158     {
       
   159 	IRLOG_DEBUG( "CIRMainView::CIRMainView - Entering" );
       
   160     SetCurrentFocus(0);
       
   161    	SetCurrentTopItem(0);
       
   162    	iMarkedFlag = EFalse;
       
   163    	iRequestPending = EFalse;
       
   164    	iFavListen = EFalse;
       
   165    	iStationDetailsCmd = EFalse;
       
   166    	iAddtoStationsCmd = EFalse;
       
   167 	iMarkedAllFlag = EFalse;
       
   168 	iMarkedFlag = EFalse;
       
   169 	iMarkedItemCount = 0;
       
   170 	iMarkedIndexArray.Reset();
       
   171 	iUnMarkedArray.Reset();
       
   172 	IRLOG_DEBUG( "CIRMainView::CIRMainView - Exiting" );
       
   173     }
       
   174 
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // void CIRMainView::ConstructL()
       
   178 // EPOC default constructor can leave.
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 void CIRMainView::ConstructL()
       
   182     {
       
   183 	IRLOG_DEBUG( "CIRMainView::ConstructL - Entering" );
       
   184     CIRBaseView::ConstructL( R_IR_FAV );
       
   185 	MAknsSkinInstance * skin=AknsUtils::SkinInstance () ;
       
   186 	TRgb color;
       
   187 	TInt skinColor=AknsUtils::GetCachedColor(skin, color, KAknsIIDQsnTextColors,
       
   188 					                                      EAknsCIQsnTextColorsCG6 );
       
   189 	if(color.Gray2()!=0)
       
   190 		{
       
   191 		CreateAndSetToolbarL(R_IR_MAINVIEW_WHITE_TOOLBAR);
       
   192 		}
       
   193 	else
       
   194 		{
       
   195 		CreateAndSetToolbarL(R_IR_MAINVIEW_BLACK_TOOLBAR);
       
   196 		}
       
   197 	if( AknLayoutUtils::PenEnabled() && Toolbar() )
       
   198 		{
       
   199 		Toolbar()->SetToolbarObserver( this );
       
   200 		}
       
   201 	IRLOG_DEBUG( "CIRMainView::ConstructL - Exiting" );
       
   202    	}
       
   203 // -----------------------------------------------------------------------------
       
   204 // CIRMainView::NewL()
       
   205 // Two-phased constructor.
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 CIRMainView* CIRMainView::NewL()
       
   209     {
       
   210  	IRLOG_DEBUG( "CIRMainView::NewL" );
       
   211     CIRMainView* self = CIRMainView::NewLC();
       
   212     CleanupStack::Pop( self );
       
   213     IRLOG_DEBUG( "CIRMainView::NewL - Exiting" );
       
   214     return self;
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 // CIRMainView* CIRMainView::NewLC()
       
   219 // Two-phased constructor.
       
   220 // ---------------------------------------------------------------------------
       
   221 //
       
   222 CIRMainView* CIRMainView::NewLC()
       
   223     {
       
   224     IRLOG_DEBUG( "CIRMainView::NewLC - Entering" );
       
   225     CIRMainView* self = new( ELeave ) CIRMainView;
       
   226     CleanupStack::PushL( self );
       
   227     self->ConstructL();
       
   228     IRLOG_DEBUG( "CIRMainView::NewL - Exiting." );
       
   229     return self;
       
   230     }
       
   231 
       
   232 
       
   233 // ---------------------------------------------------------------------------
       
   234 // CIRMainView::~CIRMainView()
       
   235 // Destructor
       
   236 // ---------------------------------------------------------------------------
       
   237 //
       
   238 CIRMainView::~CIRMainView()
       
   239 	{
       
   240 	IRLOG_DEBUG( "CIRMainView::~CIRMainView - Entering" );
       
   241 	if ( iContainer )
       
   242 		{
       
   243 		AppUi()->RemoveFromViewStack( *this, iContainer );
       
   244 		delete iContainer;
       
   245 		iContainer = NULL;
       
   246 		}
       
   247 	if( AknLayoutUtils::PenEnabled() && Toolbar() )
       
   248 		{
       
   249 		Toolbar()->SetToolbarVisibility(EFalse, EFalse);
       
   250 		Toolbar()->SetToolbarObserver( NULL );
       
   251 		}
       
   252 	iMarkedIndexArray.Close();
       
   253 	iUnMarkedArray.Close();
       
   254 	IRLOG_DEBUG( "CIRMainView::~CIRMainView - Exiting" );
       
   255     }
       
   256 
       
   257 // ---------------------------------------------------------------------------
       
   258 // TUid CIRMainView::Id() const
       
   259 // From class CAknView.
       
   260 // Returns view id.
       
   261 // ---------------------------------------------------------------------------
       
   262 //
       
   263 TUid CIRMainView::Id() const
       
   264     {
       
   265 	IRLOG_DEBUG( "CIRMainView::Id" );
       
   266     return KIRMainChoiceViewID;
       
   267     }
       
   268 
       
   269 // ---------------------------------------------------------------------------
       
   270 // void CIRMainView::DoActivateL( )
       
   271 // From class CAknView.
       
   272 // Handles view activation.
       
   273 // ---------------------------------------------------------------------------
       
   274 //
       
   275 void CIRMainView::DoActivateL( const TVwsViewId& aPrevViewId,
       
   276         TUid aCustomMessageId, const TDesC8& aCustomMessage )
       
   277 	{
       
   278 	IRLOG_DEBUG( "CIRMainView::DoActivateL - Entering" );
       
   279 	iMarkedItemCount =0;
       
   280 	iMarkedFlag = EFalse;
       
   281 	iAddToFavouratesFlag = EFalse;
       
   282 
       
   283 	if(GetCurrentFocus() == -1)
       
   284 		{
       
   285 		SetCurrentFocus(0);
       
   286 		SetCurrentTopItem(0);
       
   287 		}
       
   288 	iUi->iFavPresets->AddObserver( *this );
       
   289 	iUi->iPresentViewID = KIRMainChoiceViewID;
       
   290 	if ( !iContainer )
       
   291 		{
       
   292  	    iContainer = CIRMainContainer::NewL( *this, ClientRect() );
       
   293      	iContainer->CreateCustomListBoxL();
       
   294         AppUi()->AddToViewStackL( *this, iContainer);
       
   295         TInt index = GetCurrentFocus();
       
   296         if( aPrevViewId.iViewUid == KIRNowPlayingViewID )
       
   297 	        {
       
   298 	        if(iNowPlayingWrapper->GetFavFocus()!= GetCurrentFocus()
       
   299 	        	&& iNowPlayingWrapper->GetFavFocus()>=0 )
       
   300 		        {
       
   301 		        index = iNowPlayingWrapper->GetFavFocus();
       
   302 		        }
       
   303 	        }
       
   304        iContainer->GetListPointer()->SetCurrentItemIndex(index);
       
   305        if( aPrevViewId.iViewUid != KIRAddManuallyStationViewID )
       
   306 	       {
       
   307 	       iContainer->HandleResourceChange(KEikDynamicLayoutVariantSwitch);
       
   308 	       }
       
   309        }
       
   310     else
       
   311         {
       
   312 		// we must notify a resource change in order to update the skin context
       
   313 		// This is a flaw of CEikFormattedCellListBox
       
   314 		iContainer->SetRect(ClientRect());
       
   315         iContainer->HandleResourceChange(KEikDynamicLayoutVariantSwitch);
       
   316         }
       
   317 
       
   318 	ConstructToolbarL();
       
   319 
       
   320     iContainer->ActivateL();
       
   321     iContainer->MakeVisible( ETrue );
       
   322    	MenuBar()->SetContextMenuTitleResourceId(R_IR_MENUBAR_FAV);
       
   323    	SetTitleL( R_IRAPP_MAIN_MENU_TITLE);
       
   324 	if(	iUi->GetPlsActiavted())
       
   325 		{
       
   326 		CIRBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
       
   327 		}
       
   328 	else
       
   329 		{
       
   330 		CIRBaseView::DoActivateL( aPrevViewId, TUid::Uid(1), aCustomMessage );
       
   331 		}
       
   332 	HandleStatusPaneSizeChange();
       
   333 	iUi->iNetworkController->RegisterActiveNetworkObserverL(*this);
       
   334 	HandleCommandL(EUnmarkAll);
       
   335 	IRLOG_DEBUG( "CIRMainView::DoActivateL - Exiting" );
       
   336 	}
       
   337 
       
   338 // ---------------------------------------------------------------------------
       
   339 // void CIRMainView::DoDeactivate()
       
   340 // From class CAknView.
       
   341 // Handles view deactivation.
       
   342 // ---------------------------------------------------------------------------
       
   343 //
       
   344 void CIRMainView::DoDeactivate()
       
   345     {
       
   346 	IRLOG_DEBUG( "CIRMainView::DoDeactivate - Entering" );
       
   347 	CIRBaseView::DoDeactivate();
       
   348 	if ( iContainer )
       
   349 		{
       
   350         if(iContainer->GetListPointer() && iContainer->GetSearchBoxPointer())
       
   351 		    {
       
   352 		    TBuf<KDummyLength> findstring;
       
   353 			iContainer->GetSearchBoxPointer()->GetSearchText(findstring);
       
   354 			if( findstring.Length()!=0)
       
   355 				{
       
   356 				SetCurrentFocus(iContainer->GetCurrentItemIndex());
       
   357 				if(GetCurrentFocus() != -1)
       
   358 					{
       
   359 					iContainer->Comparestrings();
       
   360 					SetCurrentFocus(iFilteredIndex);
       
   361 					SetCurrentTopItem(iFilteredIndex);
       
   362 					}
       
   363 				}
       
   364 			else
       
   365 				{
       
   366 				SetCurrentFocus(iContainer->GetCurrentItemIndex());
       
   367 				SetCurrentTopItem(iContainer->GetListBoxTopIndex());
       
   368 				}
       
   369 			}
       
   370 		iUi->RemoveFromStack(iContainer );
       
   371 		delete iContainer;
       
   372 		iContainer = NULL;
       
   373 		}
       
   374 	if( AknLayoutUtils::PenEnabled() && Toolbar() )
       
   375 		{
       
   376 		Toolbar()->SetToolbarVisibility(EFalse, EFalse);
       
   377 		Toolbar()->SetToolbarObserver( NULL );
       
   378 		}
       
   379 	iMarkedIndexArray.Close();
       
   380 	iUnMarkedArray.Close();
       
   381     iUi->iNetworkController->DeleteActiveNetworkObserver(*this);
       
   382 
       
   383 	IRLOG_DEBUG( "CIRMainView::DoDeactivate - Exiting" );
       
   384     }
       
   385 
       
   386 // ---------------------------------------------------------------------------
       
   387 // void CIRMainView::HandleCommandL( TInt aCommand )
       
   388 // From class CAknView.
       
   389 // Command handling function.
       
   390 // ---------------------------------------------------------------------------
       
   391 //
       
   392 void CIRMainView::HandleCommandL( TInt aCommand )
       
   393 	{
       
   394 	IRLOG_DEBUG( "CIRMainView::HandleCommandL - Entering" );
       
   395 	switch ( aCommand )
       
   396 		{
       
   397 		case EMark:
       
   398 			{
       
   399 			TInt currentIndex = iContainer->GetCurrentItemIndex();
       
   400 			TInt index = 0;
       
   401 			if(currentIndex <=iUi->iFavPresets->iFavPresetList.Count())
       
   402 				{
       
   403 				if(iUi->iLastPlayed->FileExists())
       
   404 					{
       
   405 					if(currentIndex ==0)
       
   406 						{
       
   407 						index = iUi->iFavPresets->iFavPresetList[currentIndex]->Index();
       
   408 						}
       
   409 					else
       
   410 						{
       
   411 						index = iUi->iFavPresets->iFavPresetList[currentIndex-1]->Index();
       
   412 						}
       
   413 					}
       
   414 				else
       
   415 					{
       
   416 					index = iUi->iFavPresets->iFavPresetList[currentIndex]->Index();
       
   417 					}
       
   418 				}
       
   419 			if(currentIndex !=-1)
       
   420 				{
       
   421 				if(currentIndex ==0 &&iUi->iLastPlayed->FileExists())
       
   422 					{
       
   423 					// if the current item index is Zero and the Last palyed exists i.e., it is the lastplayed station then do nothing on mark/unmark.
       
   424 					}
       
   425 				else
       
   426 					{
       
   427 					iContainer->cmdMarkL(currentIndex,ETrue);
       
   428 					iMarkedFlag = ETrue;
       
   429 					}
       
   430 				}
       
   431 
       
   432 			if (index != KErrNotFound )
       
   433 				{
       
   434 				if(iMarkedIndexArray.Count())
       
   435 					{
       
   436 					currentIndex = GetCurrentIndex();
       
   437 					for(TInt i=0;i<iMarkedIndexArray.Count();i++)
       
   438 						{
       
   439 						// check whether the marked index already exists in the marked array.
       
   440 						if(iMarkedIndexArray[i]==currentIndex)
       
   441 							{
       
   442 							iIndexExisting = ETrue;
       
   443 							}
       
   444 						}
       
   445 					}
       
   446 				currentIndex = iContainer->GetCurrentItemIndex();
       
   447 				if(!(currentIndex ==0 &&iUi->iLastPlayed->FileExists()))
       
   448 					{
       
   449 					if(iIndexExisting)
       
   450 						{
       
   451 						//If the index is already marked do nothing.
       
   452 						}
       
   453 					else
       
   454 						{
       
   455 						//If the index is not marked before then insert that into marked array.
       
   456 						currentIndex = GetCurrentIndex();
       
   457 						iMarkedIndexArray.InsertInOrderL(currentIndex);
       
   458 						(iMarkedItemCount)++ ;
       
   459 						}
       
   460 					}
       
   461 				}
       
   462 			if(iUnMarkedArray.Count())
       
   463 				{
       
   464 				for(TInt i=0;i<iUnMarkedArray.Count();i++)
       
   465 					{
       
   466 					if(iUnMarkedArray[i]==currentIndex)
       
   467 						{
       
   468 						iUnMarkedArray.Remove(i);
       
   469 						}
       
   470 					}
       
   471 				}
       
   472 			iIndexExisting = EFalse;
       
   473 			SetToolbarItems();
       
   474 			SetCurrentFocus(currentIndex);
       
   475 			}
       
   476 		break;
       
   477 		case EMarkAll:
       
   478 			{
       
   479 			iMarkedAllFlag = ETrue;
       
   480 			iMarkedIndexArray.Reset();
       
   481 			if(iUi->iLastPlayed->FileExists())
       
   482 				{
       
   483 				// If Last Played station exists then mark all the stations in the favourate list except the Last played.
       
   484 				iContainer->cmdMarkL(0,ETrue);
       
   485 				}
       
   486 			else
       
   487 				{
       
   488 				// If Last Played station doesn't exist, then mark all the stations in the favourite list .
       
   489 				iContainer->cmdMarkL(-1,ETrue);
       
   490 				}
       
   491 			TBuf<KDummyLength> findString ;
       
   492 			// if elements in the listbox r not filtered
       
   493 			if(iContainer->GetSearchBoxPointer())
       
   494 				{
       
   495 				iContainer->GetSearchBoxPointer()->GetSearchText(findString);
       
   496 				}
       
   497 			// If the elements in the listbox are not filtered
       
   498 			if((findString.Length()==0))
       
   499 				{
       
   500 				TInt listboxCount ;
       
   501 				// If last played exists
       
   502 				if(iUi->iLastPlayed->FileExists())
       
   503 					{
       
   504 					// Except Last played mark all the elements in the favourite list
       
   505 					// and  all the marked elements are to be inserted into the array.
       
   506 					listboxCount = iContainer->GetListBoxCount()-1;
       
   507 					}
       
   508 				else
       
   509 					{
       
   510 					// If last played doesn't exist Mark all the elements in the list and all the
       
   511 					// elements are to be inserted into the array.
       
   512 					listboxCount = iContainer->GetListBoxCount();
       
   513 					}
       
   514 				for(TInt i=0;i<listboxCount;i++)
       
   515 					{
       
   516 					iMarkedIndexArray.InsertInOrderL(i);
       
   517 					}
       
   518 				iMarkedItemCount = iContainer->GetListPointer()->Model()->NumberOfItems();
       
   519 				}
       
   520 			// If the elements in the listbox are filtered
       
   521 			else
       
   522 				{
       
   523 				iContainer->FilteredIndexL();
       
   524 				iMarkedItemCount = iMarkedIndexArray.Count();
       
   525 				}
       
   526 			SetToolbarItems();
       
   527 			SetCurrentFocus(iContainer->GetCurrentItemIndex());
       
   528 			}
       
   529 		break;
       
   530 		case EUnmark:
       
   531 			{
       
   532 			TInt currentIndex = iContainer->GetCurrentItemIndex();
       
   533 			if(currentIndex != -1)
       
   534 				{
       
   535 				if(currentIndex ==0 &&iUi->iLastPlayed->FileExists())
       
   536 					{
       
   537 					iContainer->cmdMarkL(currentIndex,EFalse);
       
   538 					}
       
   539 				else
       
   540 					{
       
   541 					iContainer->cmdMarkL(currentIndex,EFalse);
       
   542 					}
       
   543 				currentIndex = GetCurrentIndex();
       
   544 				for(TInt j=0;j<iMarkedIndexArray.Count();j++)
       
   545 					{
       
   546 					// check which element of marked array is unmarked and remove from the marked array.
       
   547 					if(iMarkedIndexArray[j] ==currentIndex )
       
   548 						{
       
   549 						iMarkedIndexArray.Remove(j);
       
   550 						}
       
   551 					}
       
   552 				if(iMarkedAllFlag)
       
   553 					{
       
   554 					iUnMarkedArray.InsertInOrderL(currentIndex);
       
   555 					}
       
   556 				(iMarkedItemCount)-- ;
       
   557 				}
       
   558 			if(iMarkedIndexArray.Count()==0)
       
   559 				{
       
   560 				iMarkedFlag = EFalse;
       
   561 				iMarkedAllFlag = EFalse;
       
   562 				iContainer->SetContextSenstiveFlag(EFalse) ;
       
   563 				}
       
   564 			SetToolbarItems();
       
   565 			SetCurrentFocus(currentIndex);
       
   566 			}
       
   567 		break;
       
   568 		case EUnmarkAll:
       
   569 			{
       
   570 			iMarkedAllFlag = EFalse;
       
   571 			iMarkedFlag = EFalse;
       
   572 			// If Last played Exists
       
   573 			if(iUi->iLastPlayed->FileExists())
       
   574 				{
       
   575 				iContainer->cmdMarkL(0,EFalse);
       
   576 				}
       
   577 			// If last played doesn't exist
       
   578 			else
       
   579 				{
       
   580 				iContainer->cmdMarkL(-1,EFalse);
       
   581 				}
       
   582 			iMarkedItemCount = 0;
       
   583 			iMarkedIndexArray.Reset();
       
   584 			iUnMarkedArray.Reset();
       
   585 			iContainer->SetContextSenstiveFlag(EFalse) ;
       
   586 			SetToolbarItems();
       
   587 		//	SetCurrentFocus(iContainer->GetCurrentItemIndex())
       
   588 			}
       
   589 		break;
       
   590 		case EAknSoftkeyOptions:
       
   591 			{
       
   592 			Cba()->DrawDeferred();
       
   593 			break;
       
   594 			}
       
   595 		case EListenCmd:
       
   596 			{
       
   597 			if( iUi->CheckAndNotifyLowDiskSpaceL() )
       
   598 				{
       
   599 				break;
       
   600 				}
       
   601 
       
   602 			iUi->SetListenFromPls(EFalse);
       
   603 			if(iContainer->GetListBoxCount()!=-1)
       
   604 				{
       
   605 				SetCurrentFocus(iContainer->GetCurrentItemIndex());
       
   606 				}
       
   607 
       
   608 			if( iUi->VerifyNetworkConnectivityL() )
       
   609 				{
       
   610 				iRequestPending = ETrue;
       
   611 				iListenRequest = ETrue;
       
   612 				break;
       
   613 				}
       
   614 
       
   615 			ConnectToSelectedStationL();
       
   616 			break;
       
   617 			}
       
   618 		case ESelectCmd:
       
   619 			{
       
   620 			break;
       
   621 			}
       
   622 		case EFindStationsCmd:
       
   623 			{
       
   624 			if( iUi->CheckAndNotifyLowDiskSpaceL() )
       
   625 				{
       
   626 				break;
       
   627 				}
       
   628 
       
   629 			if(iContainer->GetListBoxCount()!=-1)
       
   630 				{
       
   631 				if((iContainer->GetListBoxCount()!=0)&&(iContainer->GetCurrentItemIndex()
       
   632 					 <= iContainer->GetListBoxCount()))
       
   633 					{
       
   634 					SetCurrentFocus(iContainer->GetCurrentItemIndex());
       
   635 					}
       
   636 				}
       
   637 			TBuf8<2> dummy;
       
   638 			TVwsViewId viewId(TUid::Uid(KUIDIRAPP),KIRFirstTimeViewId);
       
   639 			AppUi()->ActivateViewL(viewId ,TUid::Uid(1),dummy);
       
   640 			break;
       
   641 			}
       
   642 		case EHistoryCmd:
       
   643 			{
       
   644 			if(iContainer->GetListBoxCount()!=-1)
       
   645 				{
       
   646 				if((iContainer->GetListBoxCount()!=0)&&(iContainer->GetCurrentItemIndex()
       
   647 					 <= iContainer->GetListBoxCount()))
       
   648 					{
       
   649 					SetCurrentFocus(iContainer->GetCurrentItemIndex());
       
   650 					}
       
   651 				}
       
   652 			AppUi()->ActivateLocalViewL( KIRHistoryListViewId );
       
   653 			break;
       
   654 			}
       
   655 		case EDeleteCmd:
       
   656 			{
       
   657 			TInt dlgValue ;
       
   658 			if(iContainer->GetCurrentItemIndex()!=-1)
       
   659 				{
       
   660 				RBuf deleteStation;
       
   661 				HBufC* textResource ;
       
   662 				// If elements are marked in the list
       
   663 				if(iMarkedItemCount)
       
   664 					{
       
   665 					// If only one station in the list is marked.
       
   666 					if(iMarkedIndexArray.Count()==1)
       
   667 						{
       
   668 						TInt index = iMarkedIndexArray[0];
       
   669 						textResource = StringLoader::LoadLC( R_IRAPP_NOTE_DELETE,
       
   670 										iUi->iFavPresets->iFavPresetList[index]->Name() );
       
   671 						}
       
   672 					// If more than one station in the list is marked
       
   673 					else
       
   674 						{
       
   675 						textResource = StringLoader::LoadLC( R_IRAPP_NOTE_DELETE_MANY,
       
   676 													iMarkedIndexArray.Count());
       
   677 						}
       
   678 					deleteStation.Create(*textResource);
       
   679 					iIsdsWrapper->GetDialogLauncherInstance()->
       
   680 							ShowQueryDialogDeletionL(deleteStation,dlgValue);
       
   681 					if(dlgValue)
       
   682 						{
       
   683 						iContainer->DeleteMultiStationsL();
       
   684 						}
       
   685 					}
       
   686 				// If elements are not marked
       
   687 				else
       
   688 					{
       
   689 					TBuf<KDummyLength> findString;
       
   690 					TInt currentIndex;
       
   691 					if(iContainer->GetSearchBoxPointer())
       
   692 						{
       
   693 						iContainer->GetSearchBoxPointer()->GetSearchText(findString);
       
   694 						}
       
   695 					// If elements in the listbox are not filtered
       
   696 					if((findString.Length()==0))
       
   697 						{
       
   698 						TInt index;
       
   699 						currentIndex = iContainer->GetListPointer()->CurrentItemIndex();
       
   700 						SetCurrentFocus(iContainer->GetCurrentItemIndex());
       
   701 						SetCurrentTopItem(iContainer->GetListBoxTopIndex());
       
   702 						// If the last played exists
       
   703 						if(iUi->iLastPlayed->FileExists())
       
   704 							{
       
   705 							index = currentIndex-1;
       
   706 							textResource = StringLoader::LoadLC( R_IRAPP_NOTE_DELETE,
       
   707 								iUi->iFavPresets->iFavPresetList[currentIndex-1]->Name() );
       
   708 							}
       
   709 						// If the last played doesn't exist
       
   710 						else
       
   711 							{
       
   712 							index = currentIndex;
       
   713 							textResource = StringLoader::LoadLC( R_IRAPP_NOTE_DELETE,
       
   714 							iUi->iFavPresets->iFavPresetList[currentIndex]->Name() );
       
   715 							}
       
   716 						deleteStation.Create(*textResource);
       
   717 						iIsdsWrapper->GetDialogLauncherInstance()->
       
   718 								ShowQueryDialogDeletionL(deleteStation,dlgValue);
       
   719 						if(dlgValue)
       
   720 							{
       
   721 							iContainer->DeleteChannelL(index );
       
   722 							}
       
   723 						}
       
   724 					// If elements are  filtered
       
   725 					else
       
   726 						{
       
   727 						currentIndex = GetCurrentIndex();
       
   728 						textResource = StringLoader::LoadLC( R_IRAPP_NOTE_DELETE,
       
   729 									iUi->iFavPresets->iFavPresetList[currentIndex]->Name() );
       
   730 						deleteStation.Create(*textResource);
       
   731 						iIsdsWrapper->GetDialogLauncherInstance()->
       
   732 							ShowQueryDialogDeletionL(deleteStation,dlgValue);
       
   733 						if(dlgValue)
       
   734 							{
       
   735 							iContainer->DeleteChannelL( currentIndex);
       
   736 							}
       
   737 						}
       
   738 					}
       
   739 				CleanupStack::PopAndDestroy( textResource );
       
   740 				deleteStation.Close();
       
   741 				SetToolbarItems();
       
   742 				}
       
   743 			break;
       
   744 			}
       
   745 		case EGotoNowPlayingViewCmd:
       
   746 			{
       
   747 			iUi->SetHistory(EFalse);
       
   748 			iUi->SetMainView(ETrue);
       
   749 			iUi->SavePrevIDL(KIRMainChoiceViewID,aCommand);
       
   750 			break;
       
   751 			}
       
   752 		case EExportFavCmd:
       
   753 			{
       
   754 			break;
       
   755 			}
       
   756 		case EEditStationsCmd:
       
   757 			{
       
   758 			if(iContainer->GetListBoxCount()!=-1)
       
   759 				{
       
   760 				SetCurrentFocus(iContainer->GetCurrentItemIndex());
       
   761 				}
       
   762 			iUi->SetEditStation(ETrue);
       
   763 			iUi->iEditStationIndex = iContainer->GetListPointer()->CurrentItemIndex();
       
   764 			if(iUi->iLastPlayed->FileExists())
       
   765 				{
       
   766 				iUi->iFavPresets->iFavPresetList[iUi->iEditStationIndex-1]->
       
   767 				CopyPresetData(*iNowPlayingWrapper->iEditStationPreset);
       
   768 				}
       
   769 			else
       
   770 				{
       
   771 				iUi->iFavPresets->iFavPresetList[iUi->iEditStationIndex]->
       
   772 				CopyPresetData(*iNowPlayingWrapper->iEditStationPreset);
       
   773 				}
       
   774 
       
   775 			iUi->SetEditStation(ETrue);
       
   776 			AppUi()->ActivateLocalViewL(KIRAddManuallyStationViewID);
       
   777 			break;
       
   778 			}
       
   779 		case EStationsCmd:
       
   780 			{
       
   781 			break;
       
   782 			}
       
   783 		case EAddtoStationsCmd:
       
   784 			{
       
   785 			if ( iUi->CheckAndNotifyLowDiskSpaceL() )
       
   786 				{
       
   787 				break;
       
   788 				}
       
   789 			iAddToFavouratesFlag = ETrue;
       
   790 
       
   791 			////////verifying network connectivity/////////////////////////////////
       
   792 			TBool bNoNetwork = iUi->VerifyNetworkConnectivityL();
       
   793 			if( bNoNetwork )
       
   794 				{
       
   795 				iRequestPending = ETrue;
       
   796 				iAddtoStationsCmd = ETrue;
       
   797 
       
   798 				break;
       
   799 				}
       
   800 			else
       
   801 				{
       
   802 				AddStationtoFavoritesL();
       
   803 				}
       
   804 
       
   805 
       
   806 			break;
       
   807 			}
       
   808 		case EAddStationManuallyCmd:
       
   809 			{
       
   810 			if ( !iUi->CheckAndNotifyLowDiskSpaceL() )
       
   811 				{
       
   812 				iUi->SetEditStation(EFalse);
       
   813 				AppUi()->ActivateLocalViewL(KIRAddManuallyStationViewID);
       
   814 				}
       
   815 			break;
       
   816 			}
       
   817 		case EHelpCmd:
       
   818 			{
       
   819 			if ( !iUi->CheckAndNotifyLowDiskSpaceL() )
       
   820 				{
       
   821 				HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   822 							AppUi()->AppHelpContextL() );
       
   823 				}
       
   824 			}
       
   825 		break;
       
   826 		case ESettingsCmd:
       
   827 			{
       
   828 			if(iContainer->GetListBoxCount()!=-1)
       
   829 				{
       
   830 				SetCurrentFocus(iContainer->GetCurrentItemIndex());
       
   831 				}
       
   832 			AppUi()->ActivateLocalViewL(KIRSettingsViewId);
       
   833 			break;
       
   834 			}
       
   835 		case EAknSoftkeyBack:
       
   836 			{
       
   837 			if(	iUi->GetPlsActiavted() )
       
   838 				{
       
   839 				CIRBaseView::HandleCommandL( EAknSoftkeyBack );
       
   840 				}
       
   841 			else
       
   842 				{
       
   843 				CIRBaseView::HandleCommandL( EAknSoftkeyExit );
       
   844 				}
       
   845 			break;
       
   846 			}
       
   847 
       
   848 		case EStationDetailsCmd:
       
   849 			{
       
   850 			if( iUi->CheckAndNotifyLowDiskSpaceL() )
       
   851 				{
       
   852 				break;
       
   853 				}
       
   854 
       
   855 			TInt presetIndex = -1;
       
   856 			if(iContainer->GetListBoxCount()!=-1)
       
   857 				{
       
   858 				SetCurrentFocus(iContainer->GetCurrentItemIndex());
       
   859 				}
       
   860 			// Last Played channel selected
       
   861 			if(iContainer->GetCurrentItemIndex()==0 && iContainer->GetLastPlayedChannel())
       
   862 				{
       
   863 				iUi->iStationInfoView->SetStationPresetL( iUi->iLastPlayed->iLastPlayedStation );
       
   864 				}
       
   865 			else
       
   866 				{
       
   867 				presetIndex = GetCurrentIndex();
       
   868 				iUi->iStationInfoView->SetStationPresetL( iUi->iFavPresets->
       
   869 														  iFavPresetList[presetIndex] );
       
   870 				}
       
   871 
       
   872 			if( iUi->iStationInfoView->GetStationPresetL()->GetChannelType() == CIRIsdsPreset::EIsdsPreset
       
   873 				&& iUi->VerifyNetworkConnectivityL() )
       
   874 				{
       
   875 				iRequestPending = ETrue;
       
   876 				iStationDetailsCmd = ETrue;
       
   877 				}
       
   878 			else
       
   879 				{
       
   880 				AppUi()->ActivateLocalViewL(KIRStationInfoViewId);
       
   881 				}
       
   882 			break;
       
   883 			}
       
   884 		case EMoveCmd:
       
   885 			{
       
   886 			TInt currentIndex = iContainer->GetCurrentItemIndex();
       
   887 
       
   888 			Toolbar()->SetItemDimmed(EFindStationsCmd,ETrue,ETrue);
       
   889 			Toolbar()->SetItemDimmed(EListenCmd,ETrue,ETrue);
       
   890 			Toolbar()->SetItemDimmed(EHistoryCmd,ETrue,ETrue);
       
   891 			Toolbar()->DrawNow();
       
   892 
       
   893 			if(iMarkedIndexArray.Count()==1)
       
   894 				{
       
   895 				if(!iUi->iLastPlayed->FileExists())
       
   896 					{
       
   897 					iIndexFrom = iMarkedIndexArray[0];
       
   898 					iMovedItemIndex=iMarkedIndexArray[0];
       
   899 					iChannelIdFrom = iUi->iFavPresets->iFavPresetList[iIndexFrom]->Id();
       
   900 					}
       
   901 				else
       
   902 					{
       
   903 					iIndexFrom = iMarkedIndexArray[0];
       
   904 					iMovedItemIndex=iMarkedIndexArray[0] + 1;
       
   905 					iChannelIdFrom = iUi->iFavPresets->iFavPresetList[iIndexFrom]->Id();
       
   906 					}
       
   907 				iMarkedIndexArray.Reset();
       
   908 				SetListBoxMarkedCount(0);
       
   909 				iMarkedFlag = EFalse;
       
   910 				iMoveMarkedFlag = ETrue;
       
   911 				}
       
   912 			else
       
   913 				{
       
   914 				if(!iUi->iLastPlayed->FileExists())
       
   915 					{
       
   916 					iIndexFrom = currentIndex;
       
   917 					iMovedItemIndex=currentIndex;
       
   918 					iChannelIdFrom = iUi->iFavPresets->iFavPresetList[iIndexFrom]->Id();
       
   919 					}
       
   920 				else
       
   921 					{
       
   922 					iIndexFrom = currentIndex-1;
       
   923 					iMovedItemIndex=currentIndex;
       
   924 					iChannelIdFrom = iUi->iFavPresets->iFavPresetList[iIndexFrom]->Id();
       
   925 					}
       
   926 				if(currentIndex !=-1)
       
   927 					{
       
   928 					if(currentIndex ==0 &&iUi->iLastPlayed->FileExists())
       
   929 						{
       
   930 						// if the current item index is Zero and the Last palyed exists i.e., it is the lastplayed station then do nothing on mark/unmark.
       
   931 						}
       
   932 					else
       
   933 						{
       
   934 						iContainer->cmdMarkL(currentIndex,ETrue);
       
   935 						iMoveMarkedFlag = ETrue;
       
   936 						}
       
   937 					}
       
   938 				}
       
   939 			Cba()->SetCommandSetL( R_IR_CBA_DONE_CANCEL );
       
   940 			Cba()->DrawDeferred();
       
   941 			break;
       
   942 			}
       
   943 		case EAknSoftkeyCancel:
       
   944 		case EIRCancel:
       
   945 			{
       
   946 			TInt currentIndex =iMovedItemIndex;
       
   947 			if(currentIndex != -1)
       
   948 				{
       
   949 				iContainer->cmdMarkL(currentIndex,EFalse);
       
   950 				iMoveMarkedFlag = EFalse;
       
   951 				}
       
   952 			Toolbar()->SetItemDimmed(EFindStationsCmd,EFalse,ETrue);
       
   953 			Toolbar()->SetItemDimmed(EListenCmd,EFalse,ETrue);
       
   954 			Toolbar()->SetItemDimmed(EHistoryCmd,EFalse,ETrue);
       
   955 			Toolbar()->DrawNow();
       
   956 			Cba()->SetCommandSetL( R_IRAPP_SOFTKEYS_OPTIONS_BACK_CBA );
       
   957 			Cba()->DrawDeferred();
       
   958 			break;
       
   959 			}
       
   960 		case EAknSoftkeyDone:
       
   961 			{
       
   962 			TInt movedIndex =iMovedItemIndex;
       
   963 			TInt currentIndex = iContainer->GetCurrentItemIndex();
       
   964 			SetCurrentFocus(currentIndex);
       
   965 			if(currentIndex==0)
       
   966 				{
       
   967 				iIndexTo=0;
       
   968 				iChannelIdTo = iUi->iFavPresets->iFavPresetList[iIndexTo]->Id();
       
   969 				}
       
   970 			else
       
   971 				{
       
   972 				if(!iUi->iLastPlayed->FileExists())
       
   973 					{
       
   974 					iIndexTo = currentIndex;
       
   975 					iChannelIdTo = iUi->iFavPresets->iFavPresetList[iIndexTo]->Id();
       
   976 					}
       
   977 				else
       
   978 					{
       
   979 					iIndexTo = currentIndex-1;
       
   980 					iChannelIdTo = iUi->iFavPresets->iFavPresetList[iIndexTo]->Id();
       
   981 					}
       
   982 				}
       
   983 			iUi->iFavPresets->SwapPresetsInDbL(iChannelIdFrom,iChannelIdTo,iIndexFrom,iIndexTo);
       
   984 			if(movedIndex != -1)
       
   985 				{
       
   986 				iContainer->cmdMarkL(movedIndex,EFalse);
       
   987 				}
       
   988 			Toolbar()->SetItemDimmed(EFindStationsCmd,EFalse,ETrue);
       
   989 			Toolbar()->SetItemDimmed(EListenCmd,EFalse,ETrue);
       
   990 			Toolbar()->SetItemDimmed(EHistoryCmd,EFalse,ETrue);
       
   991 			Toolbar()->DrawNow();
       
   992 			Cba()->SetCommandSetL( R_IRAPP_SOFTKEYS_OPTIONS_BACK_CBA );
       
   993 			Cba()->DrawDeferred();
       
   994 			break;
       
   995 			}
       
   996 		default:
       
   997 			{
       
   998 			CIRBaseView::HandleCommandL( aCommand );
       
   999 			break;
       
  1000 			}
       
  1001 		}
       
  1002 	IRLOG_DEBUG( "CIRMainView::HandleCommandL - Exiting." );
       
  1003 	}
       
  1004 // ---------------------------------------------------------------------------
       
  1005 // void CIRMainView::DynInitMenuPaneL()
       
  1006 // Dynamically initialises a menu pane
       
  1007 // ---------------------------------------------------------------------------
       
  1008 //
       
  1009 void CIRMainView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
  1010 	{
       
  1011 	IRLOG_DEBUG( "CIRMainView::DynInitMenuPaneL - Entering" );
       
  1012 	if(iContainer->GetListBoxCount()!=-1)
       
  1013 		{
       
  1014 		AknSelectionService::HandleMarkableListDynInitMenuPane
       
  1015 		(aResourceId, aMenuPane, iContainer->GetListPointer());
       
  1016 		}
       
  1017 	if(aResourceId == R_IR_MENU_FAV)
       
  1018 		{
       
  1019 		if(!aMenuPane) User::Leave(KErrNotFound);
       
  1020 			{
       
  1021 			if ( iContainer )
       
  1022 				{
       
  1023 				if(!(iContainer->GetContextSenstiveFlag()))
       
  1024 					{
       
  1025 					TInt filteredCount = iContainer->GetFilterdModelPointer()->NumberOfItems();
       
  1026 					if(filteredCount == 0)
       
  1027 						{
       
  1028 						// After dynamic filtering if no matches are present, if user presses
       
  1029 						// option menu only add stations manually,settings,help,
       
  1030 						// exit should be displayed
       
  1031 						aMenuPane->SetItemDimmed(EAddStationManuallyCmd, EFalse);
       
  1032 						aMenuPane->SetItemDimmed(EEditStationsCmd, ETrue);
       
  1033 						if(iContainer->GetLastPlayedChannel())
       
  1034 							{
       
  1035 							aMenuPane->SetItemDimmed(EAddtoStationsCmd, EFalse);
       
  1036 							}
       
  1037 						else
       
  1038 							{
       
  1039 							aMenuPane->SetItemDimmed(EAddtoStationsCmd, ETrue);
       
  1040 							aMenuPane->SetItemDimmed(EMarkUnmark,ETrue );
       
  1041 							aMenuPane->SetItemDimmed(EDeleteCmd,ETrue );
       
  1042 							aMenuPane->SetItemDimmed(EStationsCmd, ETrue);
       
  1043 							aMenuPane->SetItemDimmed(ESettingsCmd, EFalse);
       
  1044 							aMenuPane->SetItemDimmed(EHelpCmd, EFalse);
       
  1045 							aMenuPane->SetItemDimmed(EExitCmd, EFalse);
       
  1046 							}
       
  1047 						}
       
  1048 					else
       
  1049 						{
       
  1050 						if(filteredCount == iMarkedIndexArray.Count()|| iMarkedIndexArray.Count())
       
  1051 							{
       
  1052 							aMenuPane->SetItemDimmed(EEditStationsCmd, ETrue);
       
  1053 							}
       
  1054 						else
       
  1055 							{
       
  1056 							aMenuPane->SetItemDimmed(EEditStationsCmd, GetEditDimmingStatus());
       
  1057 							}
       
  1058 						aMenuPane->SetItemDimmed(EAddtoStationsCmd, GetAddDimmingStatus());
       
  1059 						aMenuPane->SetItemDimmed(EMarkUnmark,GetLastPlayedStatus() );
       
  1060 						aMenuPane->SetItemDimmed(EDeleteCmd,ETrue );
       
  1061 						}
       
  1062 					// Now Playing option
       
  1063 					if(iNowPlayingWrapper->iPlaying)
       
  1064 						{
       
  1065 						aMenuPane->SetItemDimmed(EGotoNowPlayingViewCmd,EFalse);
       
  1066 						}
       
  1067 					else
       
  1068 						{
       
  1069 						aMenuPane->SetItemDimmed(EGotoNowPlayingViewCmd,ETrue);
       
  1070 						}
       
  1071 					}
       
  1072 				else
       
  1073 					{
       
  1074 					// After marking of any station, if user  taps on any station
       
  1075 					// only delete and mark/unmark options should be shown.
       
  1076 					aMenuPane->SetItemDimmed(EDeleteCmd,EFalse );
       
  1077 					aMenuPane->SetItemDimmed(EMarkUnmark, EFalse);
       
  1078 					aMenuPane->SetItemDimmed(EAddStationManuallyCmd, ETrue);
       
  1079 					aMenuPane->SetItemDimmed(EAddtoStationsCmd, ETrue);
       
  1080 					aMenuPane->SetItemDimmed(EEditStationsCmd, ETrue);
       
  1081 					aMenuPane->SetItemDimmed(EStationsCmd, ETrue);
       
  1082 					aMenuPane->SetItemDimmed(ESettingsCmd, ETrue);
       
  1083 					aMenuPane->SetItemDimmed(EHelpCmd, ETrue);
       
  1084 					aMenuPane->SetItemDimmed(EExitCmd, ETrue);
       
  1085 					aMenuPane->SetItemDimmed(EGotoNowPlayingViewCmd,ETrue);
       
  1086 					iContainer->SetContextSenstiveFlag(EFalse) ;
       
  1087 					}
       
  1088 				} /*iContainer */
       
  1089 			} /*aMenuPane */
       
  1090 		} /*aResource */
       
  1091 
       
  1092 	else if(aResourceId == R_IR_MENU_STATIONS_SUB_MENU)
       
  1093 		{
       
  1094 		aMenuPane->SetItemDimmed(EDeleteCmd,GetLastPlayedStatus() );
       
  1095 		aMenuPane->SetItemDimmed(EStationDetailsCmd,EFalse );
       
  1096 		aMenuPane->SetItemDimmed(EMoveCmd,GetLastPlayedStatus() );
       
  1097 		if(iMarkedIndexArray.Count())
       
  1098 			{
       
  1099 			// If any element is marked then sation details option should be disabled
       
  1100 			// from options menu
       
  1101 			if(iContainer->GetLastPlayedChannel() && iContainer->GetListPointer()->CurrentItemIndex()==0)
       
  1102 				{
       
  1103 				aMenuPane->SetItemDimmed(EStationDetailsCmd,EFalse );
       
  1104 				}
       
  1105 			else
       
  1106 				{
       
  1107 				aMenuPane->SetItemDimmed(EStationDetailsCmd,ETrue );
       
  1108 				}
       
  1109 			}
       
  1110 		if(  iMarkedIndexArray.Count()>1 ||
       
  1111 		iContainer->GetFilteredFlag() ||
       
  1112 		(iContainer->GetListBoxCount()==2 && iContainer->GetLastPlayedChannel() ) ||
       
  1113 		iContainer->GetListBoxCount()==1  )
       
  1114 			{
       
  1115 			aMenuPane->SetItemDimmed(EMoveCmd,ETrue );
       
  1116 			}
       
  1117 		}
       
  1118 	else if(aResourceId == R_IR_MENUPANE_MARKABLE_LIST)
       
  1119 		{
       
  1120 		aMenuPane->SetItemDimmed(EMark, EFalse);
       
  1121 		aMenuPane->SetItemDimmed(EMarkAll, EFalse);
       
  1122 		aMenuPane->SetItemDimmed(EUnmark, ETrue);
       
  1123 		aMenuPane->SetItemDimmed(EUnmarkAll, ETrue);
       
  1124 		if(iMarkedIndexArray.Count())
       
  1125 			{
       
  1126 			TBool markedflag;
       
  1127 			TInt noOfSelectedIndexes = 0;
       
  1128 			TInt filteredCount = iContainer->GetFilterdModelPointer()->NumberOfItems();
       
  1129 			if(iContainer->GetLastPlayedChannel())
       
  1130 				{
       
  1131 				filteredCount = filteredCount-1	;
       
  1132 				}
       
  1133 
       
  1134 			markedflag = EFalse;
       
  1135 			TInt CurrentItemIndex = GetCurrentIndex();
       
  1136 			for(TInt i=0;i<iMarkedIndexArray.Count();i++)
       
  1137 				{
       
  1138 				if(iMarkedIndexArray[i]==CurrentItemIndex)
       
  1139 					{
       
  1140 					markedflag = ETrue;
       
  1141 					}
       
  1142 				noOfSelectedIndexes++;
       
  1143 				}
       
  1144 			if((markedflag && iMarkedFlag)||(markedflag && iMarkedAllFlag))
       
  1145 				{
       
  1146 				aMenuPane->SetItemDimmed(EMark, ETrue);
       
  1147 				aMenuPane->SetItemDimmed(EMarkAll, EFalse);
       
  1148 				aMenuPane->SetItemDimmed(EUnmark, EFalse);
       
  1149 				aMenuPane->SetItemDimmed(EUnmarkAll, EFalse);
       
  1150 				}
       
  1151 			else
       
  1152 				{
       
  1153 				aMenuPane->SetItemDimmed(EMark, EFalse);
       
  1154 				aMenuPane->SetItemDimmed(EMarkAll, EFalse);
       
  1155 				aMenuPane->SetItemDimmed(EUnmark, ETrue);
       
  1156 				aMenuPane->SetItemDimmed(EUnmarkAll, EFalse);
       
  1157 				}
       
  1158 			if((markedflag && iMarkedAllFlag && noOfSelectedIndexes == filteredCount)
       
  1159 			||(markedflag && noOfSelectedIndexes == filteredCount))
       
  1160 				{
       
  1161 				aMenuPane->SetItemDimmed(EMark, ETrue);
       
  1162 				aMenuPane->SetItemDimmed(EMarkAll, ETrue);
       
  1163 				aMenuPane->SetItemDimmed(EUnmark, EFalse);
       
  1164 				aMenuPane->SetItemDimmed(EUnmarkAll, EFalse);
       
  1165 				}
       
  1166 			}
       
  1167 		}
       
  1168 	IRLOG_DEBUG( "CIRMainView::DynInitMenuPaneL - Exiting" );
       
  1169 	}
       
  1170 
       
  1171 // ---------------------------------------------------------------------------
       
  1172 // Touch Toolbar
       
  1173 //
       
  1174 // ---------------------------------------------------------------------------
       
  1175 
       
  1176 void CIRMainView::ConstructToolbarL()
       
  1177     {
       
  1178 	IRLOG_DEBUG( "CIRMainView::ConstructToolbarL - Entering" );
       
  1179 	SetToolbarItems();
       
  1180 	// Update rect, as changes in toolbar visibility also affect layout.
       
  1181 	if(iContainer)
       
  1182 		{
       
  1183 		iContainer->SetRect( ClientRect() );
       
  1184 		iContainer->DrawDeferred();
       
  1185 		}
       
  1186 
       
  1187 	IRLOG_DEBUG( "CIRMainView::ConstructToolbarL - Exiting" );
       
  1188     }
       
  1189 
       
  1190 // ---------------------------------------------------------------------------
       
  1191 // From class CAknView.
       
  1192 // Foreground event handling function.
       
  1193 // ---------------------------------------------------------------------------
       
  1194 //
       
  1195 void CIRMainView::HandleForegroundEventL( TBool aForeground )
       
  1196     {
       
  1197 	IRLOG_DEBUG( "CIRMainView::HandleForegroundEventL - Entering" );
       
  1198 	CIRBaseView::HandleForegroundEventL( aForeground );
       
  1199 
       
  1200 	if ( aForeground )
       
  1201 		{
       
  1202 		if ( iContainer )
       
  1203 			{
       
  1204 			MAknsSkinInstance * skin=AknsUtils::SkinInstance () ;
       
  1205 			TRgb color;
       
  1206 			TInt skinColor=AknsUtils::GetCachedColor(skin, color, KAknsIIDQsnTextColors,
       
  1207 							                                      EAknsCIQsnTextColorsCG6 );
       
  1208 			if(color.Gray2()!=0)
       
  1209 				{
       
  1210 				CreateAndSetToolbarL(R_IR_MAINVIEW_WHITE_TOOLBAR);
       
  1211 				}
       
  1212 			else
       
  1213 				{
       
  1214 				CreateAndSetToolbarL(R_IR_MAINVIEW_BLACK_TOOLBAR);
       
  1215 				}
       
  1216 			if( AknLayoutUtils::PenEnabled() && Toolbar() )
       
  1217 				{
       
  1218 				Toolbar()->SetToolbarObserver( this );
       
  1219 				}
       
  1220 			ConstructToolbarL();
       
  1221 			iContainer->DrawDeferred();
       
  1222 			}
       
  1223 		}
       
  1224 	IRLOG_DEBUG( "CIRMainView::HandleForegroundEventL---Exiting" );
       
  1225     }
       
  1226 
       
  1227 // ---------------------------------------------------------------------------
       
  1228 // From class CAknView.
       
  1229 // Event handler for status pane size changes.
       
  1230 // ---------------------------------------------------------------------------
       
  1231 //
       
  1232 void CIRMainView::HandleStatusPaneSizeChange()
       
  1233     {
       
  1234 	IRLOG_DEBUG( "CIRMainView::HandleStatusPaneSizeChange - Entering" );
       
  1235     CIRBaseView::HandleStatusPaneSizeChange();
       
  1236 
       
  1237     if ( iContainer )
       
  1238         {
       
  1239         iContainer->SetRect( ClientRect() );
       
  1240         }
       
  1241 	IRLOG_DEBUG( "CIRMainView::HandleStatusPaneSizeChange - Exiting" );
       
  1242     }
       
  1243 
       
  1244 // ---------------------------------------------------------------------------
       
  1245 // CIRMainView::OfferToolbarEventL()
       
  1246 // catch the selection key event and perform the operation according to it...
       
  1247 // ---------------------------------------------------------------------------
       
  1248 void CIRMainView::OfferToolbarEventL( TInt aCommand )
       
  1249 	{
       
  1250 	IRLOG_DEBUG( "CIRMainView::OfferToolbarEventL - Entering" );
       
  1251 	HandleCommandL(aCommand);
       
  1252 	IRLOG_DEBUG( "CIRMainView::OfferToolbarEventL - Exiting" );
       
  1253 	}
       
  1254 
       
  1255 // ---------------------------------------------------------------------------
       
  1256 // void CIRMainView::SetToolbarItems()
       
  1257 // Setting toolbar items when text is entered
       
  1258 //  ---------------------------------------------------------------------------
       
  1259 void CIRMainView:: SetToolbarItems()
       
  1260 	{
       
  1261 	IRLOG_DEBUG( "CIRMainView::SetToolbarItems - Entering" );
       
  1262 	if(Toolbar())
       
  1263 		{
       
  1264 		if(iContainer)
       
  1265 			{
       
  1266 			Toolbar()->SetToolbarVisibility(ETrue, EFalse);
       
  1267 			TBuf<KFindStringLength> findstring ;
       
  1268 			if(iContainer->GetSearchBoxPointer())
       
  1269 				{
       
  1270 				iContainer->GetSearchBoxPointer()->GetSearchText(findstring);
       
  1271 				}
       
  1272 			TInt filterModelCount = iContainer->GetFilterdModelPointer()->NumberOfItems();
       
  1273 			if(iContainer->GetSearchBoxPointer() && findstring.Length()!=0
       
  1274 			&& filterModelCount == 0)
       
  1275 				{
       
  1276 				Toolbar()->SetItemDimmed(EFindStationsCmd,ETrue,ETrue);
       
  1277 				Toolbar()->SetItemDimmed(EListenCmd,ETrue,ETrue);
       
  1278 				Toolbar()->SetItemDimmed(EHistoryCmd,ETrue,ETrue);
       
  1279 				}
       
  1280 			else
       
  1281 				{
       
  1282 				if(iMarkedItemCount||iContainer->GetListPointer()->Model()->NumberOfItems()==0 )
       
  1283 					{
       
  1284 					Toolbar()->SetItemDimmed(EListenCmd,ETrue,ETrue);
       
  1285 					}
       
  1286 				else
       
  1287 					{
       
  1288 		            Toolbar()->SetItemDimmed(EFindStationsCmd,EFalse,ETrue);
       
  1289 					Toolbar()->SetItemDimmed(EListenCmd,EFalse,ETrue);
       
  1290 					Toolbar()->SetItemDimmed(EHistoryCmd,EFalse,ETrue);
       
  1291 					}
       
  1292 	            if(iMoveMarkedFlag)
       
  1293 		            {
       
  1294 		            Toolbar()->SetItemDimmed(EFindStationsCmd,ETrue,ETrue);
       
  1295 					Toolbar()->SetItemDimmed(EListenCmd,ETrue,ETrue);
       
  1296 					Toolbar()->SetItemDimmed(EHistoryCmd,ETrue,ETrue);
       
  1297 		            }
       
  1298 				}
       
  1299 
       
  1300 			Toolbar()->DrawNow();
       
  1301 			}
       
  1302 		}
       
  1303 	IRLOG_DEBUG( "CIRMainView::SetToolbarItems - Exiting" );
       
  1304 	}
       
  1305 
       
  1306 // ---------------------------------------------------------------------------
       
  1307 // CIRMainView::HandlePresetChangedL( TInt aId, TUid aDataHandler, MPSPresetObserver::TPSReason aType )
       
  1308 // This is called by CIRFavoritesDb when values of presets stations has been changed
       
  1309 // ---------------------------------------------------------------------------
       
  1310 //
       
  1311 void CIRMainView::HandlePresetChangedL( TInt aId, TUid aDataHandler,
       
  1312 						 MPSPresetObserver::TPSReason aType )
       
  1313 	{
       
  1314 	IRLOG_DEBUG( "CIRMainView::HandlePresetChangedL  - Entering." );
       
  1315 	if(iContainer)
       
  1316 		{
       
  1317 		iContainer->HandlePresetChangedL(aId,aDataHandler,aType);
       
  1318 		}
       
  1319 	IRLOG_DEBUG( "CIRMainView::HandlePresetChangedL - Exiting." );
       
  1320 	}
       
  1321 
       
  1322 
       
  1323 // ---------------------------------------------------------------------------
       
  1324 //Notifies all observers whose network request is active
       
  1325 // to reissue the request
       
  1326 //NotifyActiveNetworkObserversL()
       
  1327 // ---------------------------------------------------------------------------
       
  1328 
       
  1329 void CIRMainView::NotifyActiveNetworkObserversL(TIRNetworkEvent aEvent)
       
  1330 	{
       
  1331 	IRLOG_DEBUG( "CIRMainView::NotifyActiveNetworkObserversL  - Entering." );
       
  1332 
       
  1333 	switch(aEvent)
       
  1334 		{
       
  1335 		case ENetworkConnectionDisconnected:
       
  1336 			{
       
  1337 			iNowPlayingWrapper->HandleNetworkDisconnected();
       
  1338 			}
       
  1339 			break;
       
  1340 		case ENetworkConnectionEstablished:
       
  1341 			{
       
  1342 
       
  1343 			if(iContainer)
       
  1344 				{
       
  1345 
       
  1346 				if(iRequestPending || iUi->iNetworkController->IsHandingOverConnection())
       
  1347 					{
       
  1348 					if(iFavListen)
       
  1349 						{
       
  1350 						DoConnectToChannelL( iContainer->GetUrlIndex() );
       
  1351 						}
       
  1352 					else if( iStationDetailsCmd )
       
  1353 						{
       
  1354 						iStationDetailsCmd = ETrue;
       
  1355 						AppUi()->ActivateLocalViewL(KIRStationInfoViewId);
       
  1356 						}
       
  1357 					else if(iListenRequest)
       
  1358 						{
       
  1359 						ConnectToSelectedStationL();
       
  1360 						}
       
  1361 					else if(iAddtoStationsCmd)
       
  1362 						{
       
  1363 						AddStationtoFavoritesL();
       
  1364 						}
       
  1365 					else if(iSyncReq)
       
  1366 						{
       
  1367 						HandleCommandL(EListenCmd);
       
  1368 						}
       
  1369 					}
       
  1370 				}
       
  1371 
       
  1372 			ResetPendingRequests(EFalse);
       
  1373 			}
       
  1374 			break;
       
  1375 		}
       
  1376 
       
  1377 	IRLOG_DEBUG( "CIRMainView::NotifyActiveNetworkObserversL  - Exiting." );
       
  1378 	}
       
  1379 
       
  1380 
       
  1381 // -----------------------------------------------------------------------------
       
  1382 // Notified by network controller when user cancels network connection, to reset
       
  1383 // the pending requests
       
  1384 // ResetPendingRequests()
       
  1385 // -----------------------------------------------------------------------------
       
  1386 void CIRMainView::ResetPendingRequests(TBool aValue)
       
  1387 	{
       
  1388 	IRLOG_DEBUG( "CIRMainView::ResetPendingRequests  - Entering." );
       
  1389 	iRequestPending = aValue;
       
  1390 	iListenRequest  = aValue;
       
  1391 	iStationDetailsCmd = aValue;
       
  1392 	iFavListen = aValue;
       
  1393 	iAddtoStationsCmd = aValue;
       
  1394 	IRLOG_DEBUG( "CIRMainView::ResetPendingRequests  - Exiting." );
       
  1395 
       
  1396 	}
       
  1397 
       
  1398 
       
  1399 // ---------------------------------------------------------------------------
       
  1400 // CIRMainView :: GetAddDimmingStatus()
       
  1401 // Returns status for making the edit option dimmed or not..
       
  1402 // ---------------------------------------------------------------------------
       
  1403 //
       
  1404 TBool CIRMainView::GetAddDimmingStatus()
       
  1405 	{
       
  1406 	IRLOG_DEBUG( "CIRMainView::GetAddDimmingStatus  - Entering." );
       
  1407 	IRLOG_DEBUG( "CIRMainView::GetAddDimmingStatus  - Exiting." );
       
  1408 	if(iContainer->GetListPointer()->CurrentItemIndex()==0 && iContainer->GetLastPlayedChannel())
       
  1409 		{
       
  1410 		return EFalse;
       
  1411 		}
       
  1412 	else
       
  1413 		{
       
  1414 		return ETrue;
       
  1415 		}
       
  1416 	}
       
  1417 
       
  1418 // ---------------------------------------------------------------------------
       
  1419 // CIRMainView :: GetEditDimmingStatus()
       
  1420 // Returns status for making the edit option dimmed or not..
       
  1421 // ---------------------------------------------------------------------------
       
  1422 //
       
  1423 TBool CIRMainView::GetEditDimmingStatus()
       
  1424 	{
       
  1425 	IRLOG_DEBUG( "CIRMainView::GetEditDimmingStatus  - Entering." );
       
  1426 	TInt favIndex = 0;
       
  1427 	TInt currentIndex = 0;
       
  1428 	currentIndex = iContainer->GetListPointer()->CurrentItemIndex();
       
  1429 	if(currentIndex!= -1)
       
  1430 		{
       
  1431 		// If last played station exist
       
  1432 		if(iContainer->GetLastPlayedChannel())
       
  1433 			{
       
  1434 		 	favIndex = GetCurrentIndex();
       
  1435 			}
       
  1436 		else
       
  1437 			{
       
  1438 			favIndex = iContainer->GetListPointer()->CurrentItemIndex();
       
  1439 			}
       
  1440 		// If focus is on last played station
       
  1441 		if((currentIndex == 0) && (iContainer->GetLastPlayedChannel()))
       
  1442 			{
       
  1443 			return ETrue;
       
  1444 			}
       
  1445 		if(favIndex <=iUi->iFavPresets->iFavPresetList.Count() &&
       
  1446 				iUi->iFavPresets->iFavPresetList[favIndex]->GetChannelType() == 0)
       
  1447 			{
       
  1448 			return EFalse;
       
  1449 			}
       
  1450 		}
       
  1451 	IRLOG_DEBUG( "CIRMainView::GetEditDimmingStatus  - Exiting." );
       
  1452 	return ETrue;
       
  1453 	}
       
  1454 // ---------------------------------------------------------------------------
       
  1455 // CIRMainView :: GetMainContainer()
       
  1456 // returns pointer to main container..
       
  1457 // ---------------------------------------------------------------------------
       
  1458 //
       
  1459 CIRMainContainer* CIRMainView::GetMainContainer()
       
  1460 	{
       
  1461 	IRLOG_DEBUG( "CIRMainView::GetMainContainer  - Entering." );
       
  1462 	return iContainer;
       
  1463 	}
       
  1464 // ---------------------------------------------------------------------------
       
  1465 // CIRMainView::ConnectToLastPlayedStationL()
       
  1466 // Connects to the last played station.
       
  1467 // ---------------------------------------------------------------------------
       
  1468 //
       
  1469 void CIRMainView::ConnectToLastPlayedStationL()
       
  1470 	{
       
  1471 	IRLOG_DEBUG( "CIRMainView::ConnectToLastPlayedStationL - Entering" );
       
  1472 	if(iNowPlayingWrapper->iNowPlayingPreset)
       
  1473 	*iNowPlayingWrapper->iNowPlayingPreset=*iUi->iLastPlayed->iLastPlayedStation;
       
  1474 	TBuf8<KUrlbufMaxLength> urlbuf;
       
  1475 	urlbuf.Copy(iUi->iLastPlayed->iLastPlayedStation->iUrlArray->At(0)->iURL->Des());
       
  1476 	iUi->iNPPrevViewId = KIRMainChoiceViewID;
       
  1477 	iNowPlayingWrapper->SetView(ELastplayed);
       
  1478 	TConnectedFrom connectedfrom = EIRPresetIsds;
       
  1479 	iNowPlayingWrapper->SetCurrentConnectionSource(connectedfrom);
       
  1480 	iNowPlayingWrapper->ConnectToChannelL(*iUi->iLastPlayed->iLastPlayedStation);
       
  1481 	IRLOG_DEBUG( "CIRMainView::ConnectToLastPlayedStationL - Exiting." );
       
  1482 	}
       
  1483 
       
  1484 // ----------------------------------------------------------------------------
       
  1485 // CIRMainView::SetUrlFromPresetL( TInt aUrlIndex )
       
  1486 // Checks whether the url name contains only spaces and if the descriptor really was.
       
  1487 // empty replaces its content with default name
       
  1488 // ----------------------------------------------------------------------------
       
  1489 //
       
  1490 void CIRMainView::SetUrlFromPresetL(TInt aUrlIndex)
       
  1491 	{
       
  1492 	IRLOG_DEBUG( "CIRMainView::SetUrlFromPresetL - Entering" );
       
  1493 	iNowPlayingWrapper->SetView(EFav);
       
  1494 	//iNowPlayingWrapper->SetConnectToServerState(ETrue)
       
  1495 	if(aUrlIndex <= iUi->iFavPresets->iFavPresetList.Count())
       
  1496 	iUi->iFavPresets->iFavPresetList[aUrlIndex]->CopyPresetData(*iNowPlayingWrapper->
       
  1497 													iNowPlayingPreset);
       
  1498 	iUi->iNPPrevViewId = KIRSavedStationsViewID;
       
  1499 	//connected from saved preset
       
  1500 	iNowPlayingWrapper->SetCurrentConnectionSource(EIRPresetIsds);
       
  1501 	//Checking for valid url, Start
       
  1502 	TBool urlStatus = FALSE;
       
  1503 	//executed for user defined channels
       
  1504 	if( !iNowPlayingWrapper->iNowPlayingPreset->GetId() &&
       
  1505 					iNowPlayingWrapper->iNowPlayingPreset->GetUrlCount() > 0 )
       
  1506 		{
       
  1507 		//to get the only url available for user defined channel
       
  1508 		urlStatus = iUi->ParseAndPrepareUrl(iNowPlayingWrapper->
       
  1509 									iNowPlayingPreset->GetChannelUrlAtL(0));
       
  1510 		if( !urlStatus )
       
  1511 			{
       
  1512 			HBufC *infoBuf = StringLoader::LoadL(R_IRAPP_ERROR_ADDRESS);
       
  1513 			delete infoBuf;
       
  1514 			return;
       
  1515 			}
       
  1516 		}
       
  1517 	//Checking for valid url, End
       
  1518 	if( iContainer )
       
  1519 		{
       
  1520 		iContainer->CheckConnectionL(aUrlIndex);
       
  1521 		}
       
  1522 	IRLOG_DEBUG( "CIRMainView::SetUrlFromPresetL - Exiting." );
       
  1523 	}
       
  1524 
       
  1525 // ---------------------------------------------------------------------------
       
  1526 // CIRMainView::DoConnectChannelL()
       
  1527 // Connects to the channel identified by the supplied index.
       
  1528 // ---------------------------------------------------------------------------
       
  1529 //
       
  1530 void CIRMainView::DoConnectToChannelL( TInt /*aUrlIndex*/ )
       
  1531 	{
       
  1532 	IRLOG_DEBUG( "CIRMainView::DoConnectToChannelL - Entering" );
       
  1533 /*d	if(aUrlIndex <= iUi->iFavPresets->iFavPresetList.Count() &&
       
  1534 		iUi->iFavPresets->iFavPresetList[aUrlIndex]->GetChannelType())
       
  1535 		{
       
  1536 		iIsdsWrapper->SetSyncPresetObserver(this);
       
  1537 		SyncPresetL(iUi->iFavPresets->iFavPresetList[aUrlIndex]->GetId(),
       
  1538 		iUi->iFavPresets->iFavPresetList[aUrlIndex]->GetLastModifiedTime());
       
  1539 		}
       
  1540 d*/
       
  1541 	iNowPlayingWrapper->ConnectToChannelL(*iNowPlayingWrapper->iNowPlayingPreset);
       
  1542 	IRLOG_DEBUG( "CIRMainView::DoConnectToChannelL - Exiting." );
       
  1543 	}
       
  1544 // ---------------------------------------------------------------------------
       
  1545 // CIRMainView::SyncPresetL()
       
  1546 // Connects to the channel identified by the supplied index.
       
  1547 // ---------------------------------------------------------------------------
       
  1548 //
       
  1549 void CIRMainView::SyncPresetL(TInt aChid,const TDesC &aModifiedTime)
       
  1550 	{
       
  1551 	IRLOG_DEBUG( "CIRMainView::SyncPresetL  - Entering." );
       
  1552 	//sync state set to pending
       
  1553 	//	iUi->SetSyncState(ESyncReqPending)
       
  1554 	iUi->iNowPlayingWrapper->CreateWaitDialogL();
       
  1555 	iUi->GetPubSubManagerInstance()->PublishBufferingState(EIRStateBufferingStart);
       
  1556 	iSyncReq = ETrue;
       
  1557 	iUi->iNowPlayingWrapper->iSyncPreset = ETrue;
       
  1558 	iIsdsWrapper->SetSyncPresetObserver(this,this);
       
  1559 	iIsdsWrapper->SetSyncReqFromMainView(ETrue);
       
  1560 	iIsdsWrapper->GetISDSInstance()->SyncPresetL(aChid,aModifiedTime);
       
  1561 	IRLOG_DEBUG( "CIRMainView::SyncPresetL - Exiting." );
       
  1562 	}
       
  1563 // ---------------------------------------------------------------------------
       
  1564 // CIRMainView::GetListBoxMarkedCount()
       
  1565 // returns the listbox count.
       
  1566 // ---------------------------------------------------------------------------
       
  1567 //
       
  1568 TInt CIRMainView::GetListBoxMarkedCount()
       
  1569 	{
       
  1570 	IRLOG_DEBUG( "CIRMainView::GetListBoxMarkedCount" );
       
  1571 	return iMarkedItemCount;
       
  1572 	}
       
  1573 // ---------------------------------------------------------
       
  1574 // CIRMainView::SetListBoxMarkedCount
       
  1575 // Sets the listbox marked count
       
  1576 // ---------------------------------------------------------
       
  1577 //
       
  1578 void CIRMainView::SetListBoxMarkedCount(TInt aMarkedItemCount)
       
  1579 	{
       
  1580 	IRLOG_DEBUG( "CIRMainView::SetListBoxMarkedCount - Entering." );
       
  1581 	iMarkedItemCount = aMarkedItemCount;
       
  1582 	IRLOG_DEBUG( "CIRMainView::SetListBoxMarkedCount - Exiting." );
       
  1583 	}
       
  1584 // ---------------------------------------------------------------------------
       
  1585 // CIRMainView::GetMarkedIndexArray()
       
  1586 // returns the Marked array Index.
       
  1587 // ---------------------------------------------------------------------------
       
  1588 //
       
  1589 RArray<TInt> CIRMainView::GetMarkedIndexArray()
       
  1590 	{
       
  1591 	IRLOG_DEBUG( "CIRMainView::GetMarkedIndexArray" );
       
  1592 	return iMarkedIndexArray;
       
  1593 	}
       
  1594 // ---------------------------------------------------------------------------
       
  1595 // CIRMainView::GetMarkedFlag()
       
  1596 // returns marked flag
       
  1597 // ---------------------------------------------------------------------------
       
  1598 //
       
  1599 TInt CIRMainView::GetMarkedFlag()
       
  1600 	{
       
  1601 	IRLOG_DEBUG( "CIRMainView::GetMarkedFlag" );
       
  1602 	return iMarkedFlag;
       
  1603 	}
       
  1604 // ---------------------------------------------------------
       
  1605 // CIRBaseView::SetMarkedFlag
       
  1606 // Sets the marked flag
       
  1607 // ---------------------------------------------------------
       
  1608 //
       
  1609 void CIRMainView::SetMarkedFlag(TInt aMarkedFlag)
       
  1610 	{
       
  1611 	IRLOG_DEBUG( "CIRMainView::SetMarkedFlag - Entering." );
       
  1612 	iMarkedFlag = aMarkedFlag;
       
  1613 	IRLOG_DEBUG( "CIRMainView::SetMarkedFlag - Exiting." );
       
  1614 	}
       
  1615 // ---------------------------------------------------------------------------
       
  1616 // CIRMainView::GetMarkedAllFlag()
       
  1617 // returns marked all flag.
       
  1618 // ---------------------------------------------------------------------------
       
  1619 //
       
  1620 TInt CIRMainView::GetMarkedAllFlag()
       
  1621 	{
       
  1622 	IRLOG_DEBUG( "CIRMainView::GetMarkedAllFlag" );
       
  1623 	return iMarkedAllFlag;
       
  1624 	}
       
  1625 // ---------------------------------------------------------
       
  1626 // CIRMainView::SetMarkedAllFlag
       
  1627 // Sets the marked all flag
       
  1628 // ---------------------------------------------------------
       
  1629 //
       
  1630 void CIRMainView::SetMarkedAllFlag(TInt aMarkedAllFlag)
       
  1631 	{
       
  1632 	IRLOG_DEBUG( "CIRMainView::SetMarkedAllFlag - Entering." );
       
  1633 	iMarkedAllFlag = aMarkedAllFlag;
       
  1634 	IRLOG_DEBUG( "CIRMainView::SetMarkedAllFlag - Exiting." );
       
  1635 	}
       
  1636 
       
  1637 // ---------------------------------------------------------------------------
       
  1638 // CIRMainView::GetAddToFavouratesFlag()
       
  1639 // returns whether any station has been added to favourates or not
       
  1640 // ---------------------------------------------------------------------------
       
  1641 //
       
  1642 TInt CIRMainView::GetAddToFavouratesFlag()
       
  1643 	{
       
  1644 	IRLOG_DEBUG( "CIRMainView::GetAddToFavouratesFlag" );
       
  1645 	return iAddToFavouratesFlag;
       
  1646 	}
       
  1647 
       
  1648 // ---------------------------------------------------------------------------
       
  1649 // CIRMainView :: GetLastPlayedStatus()
       
  1650 // Returns status for making the edit option dimmed or not..
       
  1651 // ---------------------------------------------------------------------------
       
  1652 //
       
  1653 TBool CIRMainView::GetLastPlayedStatus()
       
  1654 	{
       
  1655 	IRLOG_DEBUG( "CIRMainView::GetLastPlayedStatus - Entering." );
       
  1656 	IRLOG_DEBUG( "CIRMainView::GetLastPlayedStatus - Exiting." );
       
  1657 	if(iContainer && iContainer->GetListPointer()->CurrentItemIndex()==0
       
  1658 	   && iContainer->GetLastPlayedChannel())
       
  1659 		{
       
  1660 		return ETrue;
       
  1661 		}
       
  1662 	else
       
  1663 		{
       
  1664 		return EFalse;
       
  1665 		}
       
  1666 	}
       
  1667 
       
  1668 // ---------------------------------------------------------------------------
       
  1669 // CIRMainView :: GetCurrentIndex()
       
  1670 // Returns actual index of the station depending on the lastplayed/ filtering.
       
  1671 // ---------------------------------------------------------------------------
       
  1672 //
       
  1673 TInt CIRMainView::GetCurrentIndex()
       
  1674 	{
       
  1675 	IRLOG_DEBUG( "CIRMainView::GetCurrentIndex - Entering." );
       
  1676 	TInt currentIndex ;
       
  1677 	SetCurrentFocus(iContainer->GetListPointer()->CurrentItemIndex());
       
  1678 	if(iContainer->GetSearchBoxPointer())
       
  1679 		{
       
  1680 		TBuf<KDummyLength> findString;
       
  1681 		iContainer->GetSearchBoxPointer()->GetSearchText(findString);
       
  1682 		if((findString.Length()==0))
       
  1683 			{
       
  1684 			// If current item index is other than Last played station
       
  1685 			// If Last played Exists then the index of Favorite preset is one less than the current item index.
       
  1686 			if(iUi->iLastPlayed->FileExists())
       
  1687 				{
       
  1688 				currentIndex = iContainer->GetListPointer()->CurrentItemIndex()-1;
       
  1689 				}
       
  1690 			// If Last played doesn't exists then the index of Favorite preset is the same as current item index.
       
  1691 			else
       
  1692 				{
       
  1693 				currentIndex = iContainer->GetListPointer()->CurrentItemIndex();
       
  1694 				}
       
  1695 			}
       
  1696 		else
       
  1697 			{
       
  1698 			if(findString.Length()!=0)
       
  1699 				{
       
  1700 				iContainer->Comparestrings();
       
  1701 				SetCurrentFocus(iFilteredIndex);
       
  1702 				if(iUi->iLastPlayed->FileExists())
       
  1703 					{
       
  1704 					iFilteredIndex = iFilteredIndex -1;
       
  1705 					}
       
  1706 
       
  1707 				currentIndex = iFilteredIndex;
       
  1708 				}
       
  1709 			}
       
  1710 		}
       
  1711 	else
       
  1712 		{
       
  1713 		// If Last played Exists then the index of Favorite preset is one less than the current item index.
       
  1714 		if(iUi->iLastPlayed->FileExists())
       
  1715 			{
       
  1716 			currentIndex = iContainer->GetListPointer()->CurrentItemIndex()-1;
       
  1717 			}
       
  1718 		// If Last played doesn't exists then the index of Favorite preset is the same as current item index.
       
  1719 		else
       
  1720 			{
       
  1721 			currentIndex = iContainer->GetListPointer()->CurrentItemIndex();
       
  1722 			}
       
  1723 
       
  1724 		}
       
  1725 	IRLOG_DEBUG( "CIRMainView::GetCurrentIndex - Exiting." );
       
  1726 	return currentIndex;
       
  1727 	}
       
  1728 // ---------------------------------------------------------------------------
       
  1729 // CIRMainView::GetRequestPendingStatus()
       
  1730 // returns whether an active request is pending.
       
  1731 // ---------------------------------------------------------------------------
       
  1732 //
       
  1733 TBool CIRMainView::GetRequestPendingStatus()
       
  1734 	{
       
  1735 	IRLOG_DEBUG( "CIRMainContainer::GetRequestPendingStatus" );
       
  1736 	return iRequestPending;
       
  1737 	}
       
  1738 // ---------------------------------------------------------
       
  1739 // CIRMainView::SetRequestPendingStatus ()
       
  1740 // Sets the request pending state
       
  1741 // ---------------------------------------------------------
       
  1742 //
       
  1743 void CIRMainView::SetRequestPendingStatus(TBool aRequestPending)
       
  1744 	{
       
  1745 	IRLOG_DEBUG( "CIRMainView::SetRequestPendingStatus - Entering." );
       
  1746 	iRequestPending = aRequestPending;
       
  1747 	IRLOG_DEBUG( "CIRMainView::SetRequestPendingStatus - Exiting." );
       
  1748 	}
       
  1749 // ---------------------------------------------------------------------------
       
  1750 // CIRMainView::GetFavListen()
       
  1751 // returns Checks whether request is listen to favorites.
       
  1752 // ---------------------------------------------------------------------------
       
  1753 //
       
  1754 TBool CIRMainView::GetFavListen()
       
  1755 	{
       
  1756 	IRLOG_DEBUG( "CIRMainContainer::GetFavListen" );
       
  1757 	return iFavListen;
       
  1758 	}
       
  1759 // ---------------------------------------------------------
       
  1760 // CIRMainView::SetFavListen ()
       
  1761 // Sets the listen is from favourites or not
       
  1762 // ---------------------------------------------------------
       
  1763 //
       
  1764 void CIRMainView::SetFavListen(TBool aFavListen)
       
  1765 	{
       
  1766 	IRLOG_DEBUG( "CIRMainView::SetFavListen - Entering." );
       
  1767 	iFavListen = aFavListen;
       
  1768 	IRLOG_DEBUG( "CIRMainView::SetFavListen - Exiting." );
       
  1769 	}
       
  1770 // ---------------------------------------------------------
       
  1771 // CIRMainView::SetActualFilteredItemIndex ()
       
  1772 // Sets the actual index of the station
       
  1773 // ---------------------------------------------------------
       
  1774 //
       
  1775 void CIRMainView::SetActualFilteredItemIndex(TInt aFilteredIndex)
       
  1776 	{
       
  1777 	IRLOG_DEBUG( "CIRMainView::SetActualFilteredItemIndex - Entering." );
       
  1778 	iFilteredIndex = aFilteredIndex;
       
  1779 	IRLOG_DEBUG( "CIRMainView::SetActualFilteredItemIndex - Exiting." );
       
  1780 	}
       
  1781 // ---------------------------------------------------------------------------
       
  1782 // CIRMainView :: GetMovingFlag()
       
  1783 // Gets the view is in move mode or not.
       
  1784 // ---------------------------------------------------------------------------
       
  1785 //
       
  1786 TBool CIRMainView::GetMovingFlag()
       
  1787 	{
       
  1788 	return iMoveMarkedFlag;
       
  1789 	}
       
  1790 // ---------------------------------------------------------------------------
       
  1791 // CIRMainView :: SetMovingFlag()
       
  1792 // Sets the view is in move mode .
       
  1793 // ---------------------------------------------------------------------------
       
  1794 //
       
  1795 void CIRMainView::SetMovingFlag(TBool aValue)
       
  1796 	{
       
  1797 	iMoveMarkedFlag = aValue;
       
  1798 	}
       
  1799 
       
  1800 
       
  1801 // ------------------------------------------------------------------------
       
  1802 // from MSyncPresetObserver
       
  1803 // SyncPresetRemovedL()
       
  1804 // called back when the preset that is synced was removed from isds
       
  1805 // @param TInt,the preset id
       
  1806 // -----------------------------------------------------------------------
       
  1807 void CIRMainView::SyncPresetRemovedL(TInt aId)
       
  1808 	{
       
  1809 	IRLOG_DEBUG( "CIRMainView::SyncPresetRemovedL - Entering." );
       
  1810 
       
  1811 	iSyncReq = EFalse;
       
  1812 
       
  1813 	if( !iContainer )
       
  1814 		return;
       
  1815 
       
  1816 	if( iUi->iLastPlayed->FileExists() &&
       
  1817 	iUi->iLastPlayed->iLastPlayedStation->GetId() == aId)
       
  1818 		{
       
  1819 		// update the last played station
       
  1820 		//convert the flag to user defined and commit
       
  1821 		//0 for EUserDefined
       
  1822 		iUi->iLastPlayed->iLastPlayedStation->SetChannelType(KNull);
       
  1823 		//assign null id
       
  1824 		iUi->iLastPlayed->iLastPlayedStation->SetId(KNull);
       
  1825 
       
  1826 		//make logo as null
       
  1827 		_LIT8(KEmpty, "");
       
  1828 		RBuf8 tempLogo;
       
  1829 		tempLogo.Create(KEmpty);
       
  1830 		iUi->iLastPlayed->iLastPlayedStation->SetLogoData(tempLogo);
       
  1831 		tempLogo.Close();
       
  1832 		_LIT(KEmptyString, "");
       
  1833 		RBuf tempString;
       
  1834 		tempString.Create(KEmptyString);
       
  1835 		//set imgurl to null
       
  1836 		iUi->iLastPlayed->iLastPlayedStation->SetImgUrl(tempString);
       
  1837 		//set genre to null
       
  1838 		iUi->iLastPlayed->iLastPlayedStation->SetGenreName(tempString);
       
  1839 		iUi->iLastPlayed->iLastPlayedStation->SetGenreId(tempString);
       
  1840 		//set language to null
       
  1841 		iUi->iLastPlayed->iLastPlayedStation->SetLang(tempString);
       
  1842 		//set country to null
       
  1843 		iUi->iLastPlayed->iLastPlayedStation->SetCountryName(tempString);
       
  1844 		tempString.Close();
       
  1845 		//set musicStoreEnabled filed to "no"
       
  1846 		_LIT(KNo, "no");
       
  1847 		RBuf tempMusicStoreEnabled;
       
  1848 		tempMusicStoreEnabled.Create(KNo);
       
  1849 		iUi->iLastPlayed->iLastPlayedStation->SetMusicStoreStatus(tempMusicStoreEnabled);
       
  1850 		tempMusicStoreEnabled.Close();
       
  1851 
       
  1852 		//save the changes to the lastplayed file
       
  1853 		TRAPD(err,iUi->iLastPlayed->CommitLastPlayedChannelL());
       
  1854 		TInt error=KErrNone;
       
  1855 		if(err != KErrNone)
       
  1856 			{
       
  1857 			error = iUi->iLastPlayed->RemoveLastPlayedFile();
       
  1858 			User::Leave(error);
       
  1859 			}
       
  1860 		}
       
  1861 	iContainer->RefreshViewL();
       
  1862 	TInt currentIndex = GetCurrentIndex();
       
  1863 	if(iContainer->GetCurrentItemIndex() ==0 && iUi->iLastPlayed->FileExists())
       
  1864 		{
       
  1865 		iUi->iLastPlayed->RetriveLastPlayedChannelL();
       
  1866 		ConnectToLastPlayedStationL();
       
  1867 		}
       
  1868 	else
       
  1869 		{
       
  1870 		SetUrlFromPresetL(currentIndex);
       
  1871 		}
       
  1872 	IRLOG_DEBUG( "CIRMainView::SyncPresetRemovedL - Entering." );
       
  1873 	}
       
  1874 
       
  1875 // -----------------------------------------------------------------------
       
  1876 // from MSyncPresetObserver
       
  1877 // SyncPresetChangedL()
       
  1878 // called back when the preset that is synced has been changed in the isds
       
  1879 // @param CIRIsdsPreset&,the new preset data
       
  1880 // ----------------------------------------------------------------------
       
  1881 void CIRMainView::SyncPresetChangedL(CIRIsdsPreset& aPreset)
       
  1882 	{
       
  1883 	IRLOG_DEBUG( "CIRMainView::SyncPresetChangedL - Entering." );
       
  1884 
       
  1885 	iSyncReq = EFalse;
       
  1886 
       
  1887 	if( !iContainer )
       
  1888 		return;
       
  1889 
       
  1890 	if( iUi->iLastPlayed->FileExists() &&
       
  1891 		iUi->iLastPlayed->iLastPlayedStation->GetId() == aPreset.GetId())
       
  1892 		{
       
  1893 		aPreset.SetChannelType(KIsdsPreset);
       
  1894 		*iUi->iLastPlayed->iLastPlayedStation = aPreset;
       
  1895 		//save the changes to the lastplayed file
       
  1896 		TRAPD(err,iUi->iLastPlayed->CommitLastPlayedChannelL());
       
  1897 		TInt error=KErrNone;
       
  1898 		if(err != KErrNone)
       
  1899 			{
       
  1900 			error = iUi->iLastPlayed->RemoveLastPlayedFile();
       
  1901 			User::Leave(error);
       
  1902 			}
       
  1903 		}
       
  1904 	iContainer->RefreshViewL();
       
  1905 	TInt currentIndex = GetCurrentIndex();
       
  1906 	if(iContainer->GetCurrentItemIndex() ==0 && iUi->iLastPlayed->FileExists())
       
  1907 		{
       
  1908 		iUi->iLastPlayed->RetriveLastPlayedChannelL();
       
  1909 		ConnectToLastPlayedStationL();
       
  1910 		}
       
  1911 	else
       
  1912 		{
       
  1913 		SetUrlFromPresetL(currentIndex);
       
  1914 		}
       
  1915 	IRLOG_DEBUG( "CIRMainView::SyncPresetChangedL - Entering." );
       
  1916 	}
       
  1917 
       
  1918 // -----------------------------------------------------------------------
       
  1919 // from MSyncPresetObserver
       
  1920 // SyncPresetNoChangeL()
       
  1921 // called back when the preset that is synced has not been changed
       
  1922 // -----------------------------------------------------------------------
       
  1923 void CIRMainView::SyncPresetNoChangeL()
       
  1924 	{
       
  1925 	IRLOG_DEBUG( "CIRMainView::SyncPresetNoChangeL - Entering." );
       
  1926 
       
  1927 	iSyncReq = EFalse;
       
  1928 
       
  1929 	if( !iContainer )
       
  1930 		return;
       
  1931 	iUi->iNowPlayingWrapper->iSyncPreset = EFalse;
       
  1932 	TInt currentIndex = GetCurrentIndex();
       
  1933 	if(iContainer->GetCurrentItemIndex() ==0 &&iUi->iLastPlayed->FileExists())
       
  1934 		{
       
  1935 		ConnectToLastPlayedStationL();
       
  1936 		}
       
  1937 	else
       
  1938 		{
       
  1939 		SetUrlFromPresetL(currentIndex);
       
  1940 		}
       
  1941 	IRLOG_DEBUG( "CIRMainView::SyncPresetNoChangeL - Entering." );
       
  1942 	}
       
  1943 
       
  1944 // ----------------------------------------------------------------------
       
  1945 // CIRMainView::ConnectToSelectedStationL()
       
  1946 // Used to synchronize the LastPlayed preset before listen
       
  1947 // ----------------------------------------------------------------------
       
  1948 void CIRMainView::ConnectToSelectedStationL()
       
  1949 	{
       
  1950 	IRLOG_DEBUG("CIRMainView::ConnectToSelectedStationL - Entering");
       
  1951 
       
  1952 	if( !iContainer )
       
  1953 		return;
       
  1954 
       
  1955 	TInt currentIndex = GetCurrentIndex();
       
  1956 
       
  1957 	// Connect to User defined / Last Played preset
       
  1958 	if(iContainer->GetCurrentItemIndex() == 0
       
  1959 		&& iUi->iLastPlayed->FileExists()
       
  1960 		&& iUi->iLastPlayed->iLastPlayedStation->GetChannelType() == CIRIsdsPreset::EUserDefined)
       
  1961 		{
       
  1962 		if(iNowPlayingWrapper->iPlaying)
       
  1963 			{
       
  1964 			HandleCommandL(EGotoNowPlayingViewCmd);
       
  1965 			}
       
  1966 		else
       
  1967 			{
       
  1968 			ConnectToLastPlayedStationL();
       
  1969 			}
       
  1970 		}
       
  1971 
       
  1972 	// Sync ISDS / Last Played preset
       
  1973 	else if(iContainer->GetCurrentItemIndex() == 0
       
  1974 		&& iUi->iLastPlayed->FileExists()
       
  1975 		&& iUi->iLastPlayed->iLastPlayedStation->GetChannelType())
       
  1976 		{
       
  1977 		if(iNowPlayingWrapper->iPlaying)
       
  1978 			{
       
  1979 			HandleCommandL(EGotoNowPlayingViewCmd);
       
  1980 			}
       
  1981 		else
       
  1982 		{
       
  1983 		SyncPresetL(iUi->iLastPlayed->iLastPlayedStation->GetId(),
       
  1984 			iUi->iLastPlayed->iLastPlayedStation->GetLastModifiedTime());
       
  1985 		}
       
  1986 		}
       
  1987 
       
  1988 	// Connect to User defined preset
       
  1989 	else if(currentIndex <= iUi->iFavPresets->iFavPresetList.Count()
       
  1990 		&& iUi->iFavPresets->iFavPresetList[currentIndex]->GetChannelType()
       
  1991 		   == CIRIsdsPreset::EUserDefined)
       
  1992 		{
       
  1993 		SetUrlFromPresetL(currentIndex);
       
  1994 		}
       
  1995 
       
  1996 	// Sync ISDS preset
       
  1997 	else if(currentIndex <= iUi->iFavPresets->iFavPresetList.Count()
       
  1998 		&& iUi->iFavPresets->iFavPresetList[currentIndex]->GetChannelType())
       
  1999 		{
       
  2000 		SyncPresetL(iUi->iFavPresets->iFavPresetList[currentIndex]->GetId(),
       
  2001 					iUi->iFavPresets->iFavPresetList[currentIndex]->GetLastModifiedTime());
       
  2002 		}
       
  2003 
       
  2004 	IRLOG_DEBUG("CIRMainView::ConnectToSelectedStationL - Exiting");
       
  2005 	}
       
  2006 
       
  2007 
       
  2008 void CIRMainView::AddStationtoFavoritesL()
       
  2009 	{
       
  2010 	IRLOG_DEBUG("CIRMainView::AddStationtoFavoritesL - Entering");
       
  2011 	TInt err = KErrNone;
       
  2012 	if(iUi->iLastPlayed->iLastPlayedStation->GetChannelType())
       
  2013 		{
       
  2014 		iUi->iFavPresets->AddPresetL(*iUi->iLastPlayed->iLastPlayedStation,err,1);
       
  2015 		}
       
  2016 	else
       
  2017 		{
       
  2018 		iUi->iFavPresets->AddPresetL(*iUi->iLastPlayed->iLastPlayedStation,err);
       
  2019 		}
       
  2020 	RBuf channel;
       
  2021 	HBufC* textResource = StringLoader::LoadLC( R_IRAPP_STATIONS_POPUP_SAVED,
       
  2022 		iUi->iLastPlayed->iLastPlayedStation->GetName() );
       
  2023 	channel.Create(*textResource);
       
  2024 
       
  2025 	//If favourites is full then display an error message
       
  2026 	if(err==KErrNoMemory)
       
  2027 		{
       
  2028 		iIsdsWrapper->GetDialogLauncherInstance()->ShowErrorNoteL
       
  2029 						(R_IRAPP_ADDFAVOURITES_ERROR,ETrue);
       
  2030 		return;
       
  2031 		}
       
  2032 	else
       
  2033 		{
       
  2034 		if((err==KErrAlreadyExists )&&
       
  2035 		 ( iUi->iFavPresets->iFavPresetList.Count() == KPresetsArrayMaxLength) )
       
  2036 			{
       
  2037 			iIsdsWrapper->GetDialogLauncherInstance()->ShowErrorNoteL
       
  2038 							(R_IRAPP_ADDFAVOURITES_ERROR,ETrue);
       
  2039 			return;
       
  2040 			}
       
  2041 		else
       
  2042 			{
       
  2043 			iIsdsWrapper->GetDialogLauncherInstance()->
       
  2044 			ShowConfirmationNoteL( channel,ETrue );
       
  2045 			}
       
  2046 		}
       
  2047 	CleanupStack::PopAndDestroy(textResource);
       
  2048 	channel.Close();
       
  2049 	IRLOG_DEBUG("CIRMainView::AddStationtoFavoritesL - Exiting");
       
  2050 	}
       
  2051 
       
  2052 // ---------------------------------------------------------------------------
       
  2053 // CIRMainView::LogoRequestL()
       
  2054 // called from the container
       
  2055 // ---------------------------------------------------------------------------
       
  2056 //
       
  2057 void CIRMainView::LogoRequestL()
       
  2058 	{
       
  2059 	IRLOG_DEBUG( "CIRMainView::LogoRequestL - Entering" );
       
  2060 	if(iContainer)
       
  2061 		{
       
  2062 		iUi->iIsdsWrapper->GetISDSInstance()->GetDataProvider()->GetHttpDataProvider()->
       
  2063 		GetLogoDownloadEngine()->SendRequestL(iContainer->GetTempPreset(),this,
       
  2064 									KLPReqFrom,KLPLogoSize,KLPLogoSize);
       
  2065 		}
       
  2066 	IRLOG_DEBUG( "CIRMainView::LogoRequestL - Exiting" );
       
  2067 	}
       
  2068 
       
  2069 
       
  2070 
       
  2071 // ---------------------------------------------------------------------------
       
  2072 // CIRMainView::PresetLogoDownloadedL()
       
  2073 // from base class MLogoDownloadObserver
       
  2074 // ---------------------------------------------------------------------------
       
  2075 //
       
  2076 void CIRMainView::PresetLogoDownloadedL(CIRIsdsPreset* aPreset)
       
  2077 	{
       
  2078 	IRLOG_DEBUG( "CIRMainView::PresetLogoDownloadedL - Entering" );
       
  2079 	if(iContainer)
       
  2080 		{
       
  2081 		// store the last played station
       
  2082 		iUi->iLastPlayed->iLastPlayedStation->SetLogoData(aPreset->GetLogoData());
       
  2083 		TRAPD(err,iUi->iLastPlayed->CommitLastPlayedChannelL());
       
  2084 		TInt error=KErrNone;
       
  2085 		if(err != KErrNone)
       
  2086 			{
       
  2087 			error = iUi->iLastPlayed->RemoveLastPlayedFile();
       
  2088 			User::Leave(error);
       
  2089 			}
       
  2090 		iUi->iLastPlayed->RetriveLastPlayedChannelL();
       
  2091 		iContainer->PresetLogoDownloadL(aPreset);
       
  2092 		}
       
  2093 	IRLOG_DEBUG( "CIRMainView::PresetLogoDownloadedL - Exiting" );
       
  2094 	}
       
  2095 
       
  2096 
       
  2097 // ---------------------------------------------------------------------------
       
  2098 // CIRMainView::PresetLogoDownloadError()
       
  2099 // from base class MLogoDownloadObserver
       
  2100 // ---------------------------------------------------------------------------
       
  2101 //
       
  2102 void CIRMainView::PresetLogoDownloadError(CIRIsdsPreset* /*aPreset*/)
       
  2103 	{
       
  2104 	IRLOG_DEBUG( "CIRMainView::PresetLogoDownloadError " );
       
  2105 	//call the API of search results view container
       
  2106 	if(iContainer)
       
  2107 		{
       
  2108 		TRAP_IGNORE(iContainer->HandleLogoErrorL());
       
  2109 		}
       
  2110 	IRLOG_DEBUG( "CIRMainView::PresetLogoDownloadErrorL - Exiting" );
       
  2111 	}
       
  2112 
       
  2113 
       
  2114 // ---------------------------------------------------------------------
       
  2115 // ResponseL()
       
  2116 // From the class MViewsResponseAndErrorObserver
       
  2117 // ---------------------------------------------------------------------
       
  2118 void CIRMainView::ResponseL(CIRIsdsPreset* /*aPreset*/)
       
  2119 	{
       
  2120 	IRLOG_DEBUG( "CIRMainView::ResponseL " );
       
  2121 	IRLOG_DEBUG( "CIRMainView::ResponseL - Exiting" );
       
  2122 	}
       
  2123 
       
  2124 // ---------------------------------------------------------------------
       
  2125 // PresetResponseL()
       
  2126 // From the class MViewsResponseAndErrorObserver
       
  2127 // ---------------------------------------------------------------------
       
  2128 void CIRMainView::PresetResponseL(CIRIsdsPreset* /*aPreset*/)
       
  2129 	{
       
  2130 	IRLOG_DEBUG( "CIRMainView::PresetResponseL " );
       
  2131 	IRLOG_DEBUG( "CIRMainView::PresetResponseL - Exiting" );
       
  2132 	}
       
  2133 
       
  2134 // ---------------------------------------------------------------------
       
  2135 // ErrorL()
       
  2136 // From the class MViewsResponseAndErrorObserver
       
  2137 // ---------------------------------------------------------------------
       
  2138 void CIRMainView::ErrorL()
       
  2139 	{
       
  2140 	IRLOG_DEBUG( "CIRMainView::ErrorL " );
       
  2141 	IRRDEBUG2("CIRMAINVIEW::ERRORL",KNullDesC);
       
  2142 	if(iSyncReq)
       
  2143 		{
       
  2144 		iSyncReq = EFalse;
       
  2145 		iUi->GetPubSubManagerInstance()->PublishBufferingState(EIRStateBufferingError);
       
  2146 
       
  2147 		iUi->iNowPlayingWrapper->DestroyWaitDialogL();
       
  2148 		}
       
  2149 	IRLOG_DEBUG( "CIRMainView::ErrorL - Exiting" );
       
  2150 	}
       
  2151 
       
  2152 
       
  2153 
       
  2154