internetradio2.0/uisrc/irstationsviewcontainer.cpp
changeset 0 09774dfdd46b
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Container class for Stations View
       
    15 *
       
    16 */
       
    17 
       
    18 /* ---------------------------------------------------------------------------
       
    19 *  Version history:
       
    20 *  Template version:
       
    21 *  <ccm_history>
       
    22 *
       
    23 *  Version: 2, Thurs March 20 15:50:00 2008 by Prabina
       
    24 *  Ref:
       
    25 *  Created new views for the Station Directory Views , Enabled the Touch toolbar functionality , 
       
    26 *  Help Options enabled
       
    27 *
       
    28 *  </ccm_history>
       
    29 * ============================================================================
       
    30 */
       
    31 /* ---------------------------------------------------------------------------
       
    32 *  Version history:
       
    33 *  Template version:
       
    34 *  <ccm_history>
       
    35 *
       
    36 *  Version: 3, Fri March 21 17:20:00 2008 by Prabina
       
    37 *  Ref:
       
    38 *  Added WorkAround for supporting different Resolutions , Added Wait Dialog for Loading of stations , 
       
    39 *  Handled Single/Double tapping on the list itmes
       
    40 *
       
    41 *  </ccm_history>
       
    42 * ============================================================================
       
    43 */
       
    44 /* ---------------------------------------------------------------------------
       
    45 *  Version history:
       
    46 *  Template version:
       
    47 *  <ccm_history>
       
    48 *
       
    49 *  Version: 4, Mon March 24 18:00:00 2008 by Prabina
       
    50 *  Ref:
       
    51 *  Added WorkAround for adding different stations to favourites list , Added Wait dialog for adding to favourites
       
    52 *
       
    53 *
       
    54 *  </ccm_history>
       
    55 * ============================================================================
       
    56 */
       
    57 /* ---------------------------------------------------------------------------
       
    58 *  Version history:
       
    59 *  Template version:
       
    60 *  <ccm_history>
       
    61 *
       
    62 *  Version: 5, Tues March 25 17:30:00 2008 by Prabina
       
    63 *  Ref:
       
    64 *  Fixing the PCLint errors
       
    65 *
       
    66 *
       
    67 *  </ccm_history>
       
    68 * ============================================================================
       
    69 */
       
    70 /* ---------------------------------------------------------------------------
       
    71 *  Version history:
       
    72 *  Template version:
       
    73 *  <ccm_history>
       
    74 *
       
    75 *  Version: 6, Tues March 29 10:30:00 2008 by Prabina
       
    76 *  Ref:
       
    77 *  Stations View Container Derived from CCoeControl
       
    78 *
       
    79 *
       
    80 *  </ccm_history>
       
    81 * ============================================================================
       
    82 */
       
    83 /* ---------------------------------------------------------------------------
       
    84 *  Version history:
       
    85 *  Template version:
       
    86 *  <ccm_history>
       
    87 *
       
    88 *  Version: 7, may 7 Wed 08:35:00 2008 by Neelima
       
    89 *  Removed change Resoultion function.
       
    90 * changed code in HandleResourcechange and Size changed  for handling layout changes 
       
    91 * in dynamic filtering
       
    92 * ============================================================================
       
    93 */
       
    94 /* ---------------------------------------------------------------------------
       
    95 *  Version history:
       
    96 *  Template version:
       
    97 *  <ccm_history>
       
    98 *
       
    99 *  Version: 8, Thurs July 18 12:00:00 2008 by Prabina
       
   100 *  Ref:
       
   101 *  Code Review Comments Fixed
       
   102 *
       
   103 *
       
   104 *  </ccm_history>
       
   105 * ============================================================================
       
   106 */
       
   107 
       
   108 #include <AknIconArray.h>
       
   109 #include <aknlists.h>
       
   110 #include <aknview.h>
       
   111 #include <barsread.h>
       
   112 #include <eikenv.h>
       
   113 #include <eiklabel.h>
       
   114 #include <eikmenub.h>
       
   115 #include <stringloader.h>
       
   116 #include <internetradio.rsg>
       
   117 #include <internetradio.mbg>
       
   118 #include <eikenv.h>
       
   119 #include <apgcli.h>
       
   120 #include <akntoolbar.h>
       
   121 
       
   122 
       
   123 #include "irui.h"
       
   124 #include "ir.hrh"
       
   125 #include "ircommon.h"
       
   126 #include "irdebug.h"
       
   127 #include "irbaseview.h"
       
   128 #include "irstationsview.h"
       
   129 #include "irstationsviewcontainer.h"
       
   130 #include "irapplication.h"
       
   131 #include "ircategoryview.h"
       
   132 #include "iraap.hlp.hrh"
       
   133 #include "irisdswrapper.h"
       
   134 #include "irimageconverter.h"
       
   135 #include "irdataprovider.h"
       
   136 #include "irhttpdataprovider.h"
       
   137 #include "irlogodownloadengine.h"
       
   138 /* no need to change to lower case  */
       
   139 #include <AknsBasicBackgroundControlContext.h> 
       
   140 #include "irfilteredmodel.h"
       
   141 #include "mirlistboxarray.h"
       
   142 #include "iradvertisinglistbox.h"
       
   143 #include "irlayoututils.h"
       
   144 //For Ads
       
   145 #include <akniconutils.h> 
       
   146 #include <aknsfld.h> 
       
   147 /** Mime type when opening web browser */
       
   148 _LIT8( KIRHtmlMimeType, "text/html" );
       
   149 /** Browser prefix: See browser API specification */
       
   150 _LIT( KBrowserPrefix, "4 " );
       
   151 _LIT(KFalse,"false");
       
   152 
       
   153 const TInt KAdvSize = 30;
       
   154 const TSize KLogoSize = TSize(320,350);
       
   155 const TInt KSize = 10;
       
   156 #define KCONTROLSCOUNT 0
       
   157  
       
   158 const TInt KIRNoLogo = -1;
       
   159 // Length of list item with known sized elements: (the number of column separators) + 3 (maximum length for icon id)
       
   160 const TInt KIRListItemBaseLength = 5;
       
   161 const TInt KRange = 999;
       
   162 // ==================== LOCAL FUNCTIONS ====================
       
   163 
       
   164 // ================= MEMBER FUNCTIONS =======================
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CIRStationsViewContainer::NewL()
       
   168 // Two-phased constructor.
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 CIRStationsViewContainer* CIRStationsViewContainer::NewL( CIRStationsView& aView,
       
   172 					 const TRect& aRect )
       
   173     {
       
   174  	IRLOG_DEBUG( "CIRStationsViewContainer::NewL" );
       
   175     CIRStationsViewContainer* self = CIRStationsViewContainer::NewLC( aView, aRect );
       
   176     CleanupStack::Pop( self );
       
   177     IRLOG_DEBUG( "CIRStationsViewContainer::NewL - Exiting" );
       
   178     return self;
       
   179     }
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CIRStationsViewContainer::NewLC()
       
   183 // Two-phased constructor.
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 CIRStationsViewContainer* CIRStationsViewContainer::NewLC( CIRStationsView& aView,
       
   187 					 const TRect& aRect )
       
   188     {
       
   189  	IRLOG_DEBUG( "CIRStationsViewContainer::NewLC" );
       
   190     CIRStationsViewContainer* self = new ( ELeave ) CIRStationsViewContainer(aView);
       
   191     CleanupStack::PushL( self );
       
   192     self->ConstructL( aRect );
       
   193     IRLOG_DEBUG( "CIRStationsViewContainer::NewLC - Exiting" );
       
   194     return self;
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // CIRStationsViewContainer::CIRStationsViewContainer()  
       
   199 // C++ default constructor can NOT contain any code, that might leave.
       
   200 // ---------------------------------------------------------------------------
       
   201 //
       
   202 CIRStationsViewContainer::CIRStationsViewContainer(CIRStationsView& aView) :iView(aView)
       
   203 	{
       
   204 	IRLOG_DEBUG( "CIRStationsViewContainer::CIRStationsViewContainer" );
       
   205 	iFilteredFlag = EFalse;
       
   206 	iAdRequestStatusFlag = EFalse;
       
   207 	}
       
   208     
       
   209 // ---------------------------------------------------------------------------
       
   210 // CIRStationsViewContainer::ConstructL
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 void CIRStationsViewContainer::ConstructL( const TRect& aRect)
       
   214     {
       
   215 	IRLOG_DEBUG( "CIRStationsViewContainer::ConstructL - Entering" );
       
   216     CreateWindowL();
       
   217     
       
   218     SetRect(aRect);
       
   219     iBgContext = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgScreen , aRect, ETrue); 
       
   220 
       
   221 	iAdPresent = EFalse;
       
   222     iConverter = CIRImageConverter::NewL();
       
   223 	iConverter->EnableAnimations( EFalse );
       
   224 	iConverter->SetObserver( this );
       
   225 
       
   226 	iCurrentItemConverter = CIRImageConverter::NewL();
       
   227 	iCurrentItemConverter->SetObserver( this );
       
   228     
       
   229     // Added For Dynamic Filtering
       
   230     iFilteredModel=new(ELeave) CIRFilteredModel;
       
   231     iFilteredModel->ConstructL();
       
   232        
       
   233    	iListBoxArray = MIRListBoxArray::NewL();
       
   234     
       
   235 	
       
   236 	IRLOG_DEBUG( "CIRStationsViewContainer::ConstructL - Exiting" );
       
   237 	}
       
   238 // ---------------------------------------------------------------------------
       
   239 // CIRStationsViewContainer::CreateListBoxL()
       
   240 // Creates ListBox depending upon the presence of Advertisement
       
   241 // ---------------------------------------------------------------------------
       
   242 //
       
   243 void CIRStationsViewContainer::CreateListBoxL()
       
   244 	{
       
   245 	IRLOG_DEBUG( "CIRStationsViewContainer::CreateListBoxL - Entering" );
       
   246 	if (iView.iUi->iIsdsWrapper->GetBannerUrl())
       
   247 		{
       
   248 		if((iView.iUi->iIsdsWrapper->GetBannerUrl()->Length())!=0)
       
   249 			{
       
   250 			iAdPresent = ETrue;
       
   251 			if(iAdvPreset)
       
   252 				{
       
   253 				delete iAdvPreset;
       
   254 				iAdvPreset = NULL;
       
   255 				}
       
   256 			iAdvPreset=CIRIsdsPreset::NewL();
       
   257 			iAdvPreset->SetChannelType(1);
       
   258 			iAdvPreset->SetImgUrl(*iView.iUi->iIsdsWrapper->GetBannerUrl());
       
   259 			iAdRequestStatusFlag = ETrue;
       
   260 			CreateCustomListBoxL();
       
   261 			iLogoDownloadError	= ETrue;
       
   262 			iFilteredModel->SetAdvFlag(EFalse,*iAdvString);
       
   263 			iView.AdRequestL();
       
   264 			}
       
   265 		}  
       
   266 	else
       
   267 		{
       
   268 		if(iView.iUi->iIsdsWrapper->iChannelBannerTag)
       
   269 			{
       
   270 			iView.SetCurrentFocus(0);	
       
   271 			iLogoDownloadError	= ETrue;
       
   272 			iFilteredModel->SetAdvFlag(EFalse,*iAdvString);
       
   273 			iAdRequestStatusFlag = EFalse;
       
   274 			}
       
   275 	    iStationsListBox = new (ELeave) CIRAdvertisingListBox;
       
   276 		CreateCustomListBoxL();	
       
   277 		}
       
   278 	IRLOG_DEBUG( "CIRStationsViewContainer::CreateListBoxL - Exiting" );
       
   279 
       
   280 	}
       
   281 // ---------------------------------------------------------------------------
       
   282 // CIRStationsViewContainer::~CIRStationsViewContainer()
       
   283 // Destructor
       
   284 // ---------------------------------------------------------------------------
       
   285 //
       
   286 void CIRStationsViewContainer::CreateCustomListBoxL()
       
   287 	{
       
   288 	IRLOG_DEBUG( "CIRStationsViewContainer::CreateCustomListBoxL - Entering" );
       
   289 	iLandScapeCount = 0;
       
   290 	if(iAdPresent)
       
   291 		{
       
   292 		iStationsListBox = new (ELeave) CIRAdvertisingListBox;
       
   293 		}
       
   294 	//For displaying Ads
       
   295 	iStationsListBox->SetContainerWindowL(*this);
       
   296 	// Added For Dynamic Filtering
       
   297 	iStationsListBox->ConstructL (this,EAknListBoxSelectionList,iFilteredModel);
       
   298 
       
   299 
       
   300 	// Construct list.
       
   301 	TResourceReader rr;
       
   302 	iCoeEnv->CreateResourceReaderLC( rr, R_IR_SEARCHRESULTS_LIST );
       
   303 	ConstructFromResourceL( rr );
       
   304 	CleanupStack::PopAndDestroy(); // rr
       
   305 
       
   306 	iItemArray = static_cast<CDesCArray*>( iStationsListBox->Model()->ItemTextArray());
       
   307 	iListBoxArray->SetListArray(iItemArray);
       
   308 	iFilteredModel->SetListArray(iListBoxArray); 
       
   309 	
       
   310 	if (iView.iUi->iIsdsWrapper->GetBannerUrl())
       
   311 		{
       
   312 		// Added For Dynamic Filtering
       
   313 		if(iAdvString)
       
   314 			{
       
   315 			delete iAdvString;
       
   316 			iAdvString = NULL;	
       
   317 			}
       
   318 		iAdvString = HBufC::NewL(KAdvSize);
       
   319 		TPtr ptr(iAdvString->Des());
       
   320 		_LIT(KTabFormat,"\t \t ");
       
   321 		ptr.Copy(KTabFormat);
       
   322 
       
   323 		iFilteredModel->SetAdvFlag(iAdPresent,*iAdvString);
       
   324 		iStationsListBox->SetListItemFormat( iAdvString );
       
   325 		}
       
   326 
       
   327 	TInt resultsCount = iView.iIsdsWrapper->iStationsData->Count();
       
   328 
       
   329 	CAknIconArray* iconArray = new ( ELeave ) CAknIconArray( resultsCount );
       
   330 	CleanupStack::PushL( iconArray );
       
   331 
       
   332 	for ( TInt i = 0; i < resultsCount; i++ )
       
   333 		{
       
   334 		CGulIcon* icon = CreateDefaultIconL();
       
   335         CleanupStack::PushL( icon );
       
   336         iconArray->AppendL( icon );
       
   337 	    CleanupStack::Pop( icon );
       
   338 		}
       
   339 
       
   340 	CleanupStack::Pop( iconArray  );
       
   341 	iStationsListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( iconArray );  
       
   342 
       
   343 	iStationsListBox->SetRect( Rect());
       
   344 	iStationsListBox->ActivateL();
       
   345 
       
   346 	iStationsListBox->CreateScrollBarFrameL( ETrue );
       
   347 	iStationsListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, 
       
   348 	CEikScrollBarFrame::EAuto);
       
   349 	iStationsListBox->SetListBoxObserver( this );     
       
   350 
       
   351 
       
   352 	// Set the icon array for this list. List takes ownership of the array. 
       
   353 	for ( TInt i = 0; i < resultsCount; i++ )
       
   354 		{
       
   355 		RBuf tempImgUrlStatus;
       
   356 		tempImgUrlStatus.Create(KSize);
       
   357 		tempImgUrlStatus.Copy(KFalse);
       
   358 
       
   359 		RBuf tempImgUrl;
       
   360 		tempImgUrl.Create(iView.iIsdsWrapper->iChannelImgUrl->MdcaPoint(i).Size());
       
   361 		tempImgUrl.Copy(iView.iIsdsWrapper->iChannelImgUrl->MdcaPoint(i));
       
   362 
       
   363 		if(!(tempImgUrlStatus == tempImgUrl))
       
   364 			{
       
   365 			iInvalidIconIndices.InsertInOrderL(i);
       
   366 			}
       
   367 		iNoLogosArray.InsertInOrderL(i);
       
   368 		tempImgUrlStatus.Close();
       
   369 		tempImgUrl.Close();
       
   370 		}
       
   371 
       
   372 	UpdateStationsViewL();
       
   373 	iStationsListBox->ItemDrawer()->FormattedCellData()->SetMarqueeParams
       
   374 							(KLoop, KScrollAmount, KScrollDelay, KInterval);
       
   375 	iStationsListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
       
   376 
       
   377 	if(resultsCount>1)
       
   378 		{
       
   379 		if(iStationsSearchBox)
       
   380 			{
       
   381 			delete iStationsSearchBox;
       
   382 			iStationsSearchBox = NULL;
       
   383 			}
       
   384 
       
   385 		// Added For Dynamic Filtering
       
   386 		iStationsSearchBox = CreateFindBoxL(iStationsListBox, iFilteredModel,
       
   387 		CAknSearchField::ESearch);
       
   388 		SizeChanged();	
       
   389 		}
       
   390 	else
       
   391 		{
       
   392 		DisableFindBox();	
       
   393 		}
       
   394 	if((!iAdRequestStatusFlag))
       
   395 		{
       
   396 		if ( iInvalidIconIndices.Count() )
       
   397 			{
       
   398 			StartConvertL( *iConverter, iInvalidIconIndices[0], KErrUnknown );
       
   399 			}
       
   400 		}
       
   401 	IRLOG_DEBUG( "CIRStationsViewContainer::CreateCustomListBoxL - Exiting" );
       
   402 	}
       
   403 // ---------------------------------------------------------------------------
       
   404 // CIRStationsViewContainer::CreateDefaultIconL
       
   405 // ---------------------------------------------------------------------------
       
   406 //
       
   407 CGulIcon* CIRStationsViewContainer::CreateDefaultIconL()
       
   408     {
       
   409 	IRLOG_DEBUG( "CIRStationsViewContainer::CreateDefaultIconL - Entering" );
       
   410     CFbsBitmap* bitmap = new ( ELeave ) CFbsBitmap;
       
   411     CleanupStack::PushL( bitmap );
       
   412     User::LeaveIfError( bitmap->Create( TSize(), EGray2 ) );
       
   413     CFbsBitmap* mask = new ( ELeave ) CFbsBitmap;
       
   414     CleanupStack::PushL( mask );
       
   415     User::LeaveIfError( mask->Create( TSize(), EGray2 ) );
       
   416     CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
       
   417     icon->SetBitmapsOwnedExternally( EFalse );
       
   418     CleanupStack::Pop( 2, bitmap );
       
   419 	IRLOG_DEBUG( "CIRStationsViewContainer::CreateDefaultIconL - Exiting" );
       
   420     return icon;
       
   421     }
       
   422 // ---------------------------------------------------------------------------
       
   423 // CIRStationsViewContainer::~CIRStationsViewContainer()
       
   424 // Destructor
       
   425 // ---------------------------------------------------------------------------
       
   426 //
       
   427 CIRStationsViewContainer::~CIRStationsViewContainer()
       
   428     {
       
   429 	IRLOG_DEBUG( "CIRStationsViewContainer::~CIRStationsViewContainer - Entering" );
       
   430 	delete iConverter;
       
   431 	delete iCurrentItemConverter;
       
   432 	iLogosArray.Close();
       
   433 	iNoLogosArray.Close();  
       
   434 	iInvalidIconIndices.Close();
       
   435     if(iStationsListBox)
       
   436     	{
       
   437     	delete iStationsListBox;
       
   438     	iStationsListBox = NULL;
       
   439     	}
       
   440     if(iStationsSearchBox)
       
   441 		{
       
   442 		delete iStationsSearchBox;
       
   443 		iStationsSearchBox = NULL;
       
   444 		}
       
   445 	if(iTempPreset)
       
   446 		{
       
   447 		delete iTempPreset;
       
   448 		iTempPreset =NULL;
       
   449 		}
       
   450 	if(iAdvPreset)
       
   451 		{
       
   452 		delete iAdvPreset;
       
   453 		iAdvPreset = NULL;
       
   454 		}
       
   455 	if(iAdBitmap)
       
   456 		{
       
   457 		delete iAdBitmap;
       
   458 		iAdBitmap = NULL;	
       
   459 		}
       
   460 	if(iBgContext)
       
   461 		{
       
   462 		delete iBgContext;
       
   463 		iBgContext = NULL;	
       
   464 		}
       
   465 	if(iAdvString)
       
   466 		{
       
   467 		delete iAdvString;
       
   468 		iAdvString = NULL;	
       
   469 		}
       
   470     if(iListBoxArray )
       
   471 	    {
       
   472 	    delete iListBoxArray ;
       
   473 	    iListBoxArray = NULL;	
       
   474 	    }
       
   475 	IRLOG_DEBUG( "CIRStationsViewContainer::~CIRStationsViewContainer - Exiting" );
       
   476     }
       
   477 
       
   478 // ---------------------------------------------------------------------------
       
   479 // TKeyResponse CIRStationsViewContainer::OfferKeyEventL()
       
   480 // From class CCoeControl.
       
   481 // We need to catch the selection key event in order to do a couple of things
       
   482 // in moving state make the movement, and in normal state open channel 
       
   483 // specific popup menu. Up and down buttons are forwarded to the list.
       
   484 // ---------------------------------------------------------------------------
       
   485 //
       
   486 TKeyResponse CIRStationsViewContainer::OfferKeyEventL( 
       
   487         const TKeyEvent& aKeyEvent, TEventCode aType )
       
   488 	{
       
   489 	IRLOG_DEBUG( "CIRStationsViewContainer::OfferKeyEventL - Entering" );
       
   490 	TKeyResponse keyResp( EKeyWasNotConsumed );
       
   491 	TInt currentIndex = 0;
       
   492 	switch ( aKeyEvent.iCode )
       
   493 		{
       
   494 		case EKeyLeftArrow: // fall-through intended here
       
   495 		case EKeyRightArrow:
       
   496 		case EKeyIncVolume:
       
   497 		case EKeyDecVolume:
       
   498 			{
       
   499 			keyResp = EKeyWasNotConsumed;
       
   500 			break;
       
   501 			}
       
   502 		case EKeyOK:        
       
   503 			{
       
   504 			if( iView.iUi->CheckAndNotifyLowDiskSpaceL() )
       
   505 				{
       
   506 				break;
       
   507 				}
       
   508 			currentIndex = GetCurrentItemIndex();
       
   509 			if (currentIndex == 0)  
       
   510 				{
       
   511 				if (iView.iUi->iIsdsWrapper->GetBannerUrl() && !iLogoDownloadError)
       
   512 					{
       
   513 					if(iView.iUi->iIsdsWrapper->GetBannerUrl()->Length() != 0)
       
   514 						{
       
   515 						iView.HandleCommandL(EAdvertisementUrl);
       
   516 						}
       
   517 					}
       
   518 				else
       
   519 					{
       
   520 					iView.SetCurrentFocus(GetCurrentItemIndex());
       
   521 					iView.HandleCommandL(EListenCmd);
       
   522 					}
       
   523 				}
       
   524 			else
       
   525 				{
       
   526 				iView.SetCurrentFocus(GetCurrentItemIndex());
       
   527 				iView.HandleCommandL(EListenCmd);
       
   528 				}
       
   529 			break;
       
   530 			}
       
   531 		default:
       
   532 			{
       
   533 			if(iStationsListBox)
       
   534 				{
       
   535 				iView.SetToolbarItems();
       
   536 				if ( iStationsSearchBox )
       
   537 					{
       
   538 					iFilteredFlag = ETrue;
       
   539 					keyResp = iStationsSearchBox->OfferKeyEventL( aKeyEvent, aType );
       
   540 					if( keyResp == EKeyWasNotConsumed )
       
   541 						{
       
   542 						keyResp = iStationsListBox->OfferKeyEventL( aKeyEvent, aType );
       
   543 						}
       
   544 					CAknFilteredTextListBoxModel* model = 
       
   545 					static_cast<CAknFilteredTextListBoxModel*>( iStationsListBox->Model() );
       
   546 					model->Filter()->HandleOfferkeyEventL();					
       
   547 					TInt filterModelCount = iFilteredModel->NumberOfItems();	
       
   548 					if(filterModelCount == 0 && 
       
   549 					!(iView.iUi->iIsdsWrapper->GetBannerUrl()))
       
   550 						{
       
   551 						HBufC* noMatchesTextResource = 
       
   552 						StringLoader::LoadLC(R_IRAPP_STATIONLIST_NOMATCHES);
       
   553 						iStationsListBox->View()->SetListEmptyTextL(*noMatchesTextResource);
       
   554 						CleanupStack::PopAndDestroy( noMatchesTextResource );
       
   555 						}
       
   556 					iStationsSearchBox->GetSearchText(iFindString);
       
   557 					if(iFindString.Length()!=0)
       
   558 						{
       
   559 						if(!iLogoDownloadError && 
       
   560 						iView.iUi->iIsdsWrapper->GetBannerUrl() && 
       
   561 						filterModelCount > 1 )
       
   562 							{
       
   563 							iStationsListBox->SetCurrentItemIndex(1);
       
   564 							}
       
   565 						else
       
   566 							{
       
   567 							iStationsListBox->SetCurrentItemIndex(0);
       
   568 							}
       
   569 						}
       
   570 					}
       
   571 				}
       
   572 			if(	aKeyEvent.iScanCode==EStdKeyBackspace)
       
   573 				{
       
   574 				if(iStationsSearchBox)
       
   575 					{
       
   576 					iStationsSearchBox->GetSearchText(iFindString);
       
   577 					if(iFindString.Length()==0)
       
   578 						{
       
   579 						iFilteredFlag = EFalse;
       
   580 						}
       
   581 					}
       
   582 				}
       
   583 
       
   584 			iView.SetToolbarItems();
       
   585 			break;
       
   586 			}
       
   587 		}
       
   588 	IRLOG_DEBUG( "CIRStationsViewContainer::OfferKeyEventL - Exiting" );
       
   589 	return keyResp; 
       
   590 	}
       
   591 
       
   592 // ---------------------------------------------------------------------------
       
   593 // From class MEikListBoxObserver.
       
   594 // List box event handler.
       
   595 // ---------------------------------------------------------------------------
       
   596 //
       
   597 void CIRStationsViewContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
       
   598 	{
       
   599 	IRLOG_DEBUG( "CIRStationsViewContainer::HandleListBoxEventL - Entering" );
       
   600 	TInt currentIndex = 0;
       
   601 	switch ( aEventType )
       
   602 		{
       
   603 		case EEventEnterKeyPressed:/**  Keypress event. */
       
   604 		case EEventItemDoubleClicked:
       
   605 			{
       
   606 			if( iView.iUi->CheckAndNotifyLowDiskSpaceL() )
       
   607 				{
       
   608 				break;
       
   609 				}
       
   610 			currentIndex = GetCurrentItemIndex();
       
   611 			if (currentIndex == 0)  
       
   612 				{
       
   613 				if (iView.iUi->iIsdsWrapper->GetBannerUrl() && !iLogoDownloadError)
       
   614 					{
       
   615 					if(iView.iUi->iIsdsWrapper->GetBannerUrl()->Length() != 0)
       
   616 						{
       
   617 						iView.HandleCommandL(EAdvertisementUrl);
       
   618 						}
       
   619 					}
       
   620 				else
       
   621 					{
       
   622 					iView.SetCurrentFocus(GetCurrentItemIndex());
       
   623 					iView.HandleCommandL(EListenCmd);
       
   624 					}
       
   625 				}
       
   626 			else
       
   627 				{
       
   628 				iView.SetCurrentFocus(GetCurrentItemIndex());
       
   629 				iView.HandleCommandL(EListenCmd);
       
   630 				}
       
   631 			}
       
   632 		break;
       
   633 		case EEventItemClicked:
       
   634 			{
       
   635 			iView.SetCurrentFocus(GetCurrentItemIndex());
       
   636 			iView.SetToolbarItems();
       
   637 			}
       
   638 		break;
       
   639 		default:
       
   640 		break;
       
   641 		}
       
   642 	IRLOG_DEBUG( "CIRStationsViewContainer::HandleListBoxEventL - Exiting" );
       
   643 	}
       
   644 
       
   645 // ---------------------------------------------------------------------------
       
   646 // CIRStationsViewContainer::Draw()
       
   647 // From class CCoeControl.
       
   648 // Draws the control.
       
   649 // ---------------------------------------------------------------------------
       
   650 //
       
   651 void CIRStationsViewContainer::Draw( const TRect& /*aRect*/ ) const
       
   652     {
       
   653 	IRLOG_DEBUG( "CIRStationsViewContainer::Draw - Entering" );
       
   654     CWindowGc& gc = SystemGc();
       
   655 
       
   656     if(iStationsListBox)
       
   657 	    {
       
   658 	   	iStationsListBox->SetGC(gc);
       
   659 	   	iStationsListBox->SetControlFlag(ETrue);
       
   660 	    }
       
   661     gc.SetPenStyle( CGraphicsContext::ENullPen );
       
   662     gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   663 	
       
   664     // draw background skin first. 
       
   665  	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   666   	
       
   667 	TRect clientRect(((CEikAppUi*)(CCoeEnv::Static()->AppUi()))->ClientRect());
       
   668 
       
   669 	AknsDrawUtils::DrawBackground ( skin, iBgContext, this, gc, TPoint(0,0),
       
   670 					 TRect(TPoint(0,0),clientRect.iBr), KAknsDrawParamDefault  );	
       
   671 	
       
   672  	IRLOG_DEBUG( "CIRStationsViewContainer::Draw - Exiting" );
       
   673     }
       
   674 
       
   675 
       
   676 // ---------------------------------------------------------------------------
       
   677 // CIRStationsViewContainer::GetHelpContext()
       
   678 // From class CCoeControl.
       
   679 // Opens help by context.
       
   680 // ---------------------------------------------------------------------------
       
   681 //
       
   682 void CIRStationsViewContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   683     {
       
   684 	IRLOG_DEBUG( "CIRStationsViewContainer::GetHelpContext - Entering" );
       
   685 	if( iView.iUi->iCategoryViewTitleType == CIRCategoryView::EGenreData )
       
   686 		{
       
   687 		aContext = TCoeHelpContext( KIRMCVUid, KIR_HELP_GENRE_STATIONS );
       
   688 		}
       
   689 	else if( iView.iUi->iCategoryViewTitleType == CIRCategoryView::ELanguageData )
       
   690 		{
       
   691 		aContext = TCoeHelpContext( KIRMCVUid, KIR_HELP_LANGUAGE_STATIONS );
       
   692 		}
       
   693 	else if( iView.iUi->iCategoryViewTitleType == CIRCategoryView::ECountryData )
       
   694 		{
       
   695 		aContext = TCoeHelpContext( KIRMCVUid, KIR_HELP_COUNTRY_STATIONS );
       
   696 		}
       
   697 	else 
       
   698 		{
       
   699 		aContext = TCoeHelpContext( KIRMCVUid, KIR_HELP_TOP );
       
   700 		}
       
   701 	IRLOG_DEBUG( "CIRStationsViewContainer::GetHelpContext - Exiting" );
       
   702 
       
   703     }
       
   704     
       
   705 // ---------------------------------------------------------------------------
       
   706 // CIRStationsViewContainer::UpdateSearchResultsViewL()
       
   707 // updates the search results data to the search results list
       
   708 // ---------------------------------------------------------------------------
       
   709 //    
       
   710 
       
   711 void CIRStationsViewContainer::UpdateStationsViewL()
       
   712 	{
       
   713 	IRLOG_DEBUG( "CIRStationsViewContainer::UpdateStationsViewL - Entering" );
       
   714 
       
   715 	//provides logo url in the search results stations
       
   716 	TInt stationsCount = iView.iIsdsWrapper->iStationsData->Count();
       
   717 	for(TInt i = 0; i < stationsCount; i++)
       
   718 		{
       
   719 		//check whether logo url exist for the current channel of the search results
       
   720 		for(TInt m = 0; m < iNoLogosArray.Count(); m++)
       
   721 			{
       
   722 			if(i == iNoLogosArray[m])				
       
   723 				{
       
   724 				//logo should not be displayed in the search results for this particular station
       
   725 				HBufC* itemString = FormatItemStringLC( iView.iIsdsWrapper->iStationsData->
       
   726 														MdcaPoint(i),KIRNoLogo);
       
   727 				iItemArray->AppendL( itemString->Des() );
       
   728 				CleanupStack::PopAndDestroy( itemString );
       
   729 				
       
   730 				break;
       
   731 				}
       
   732 			}
       
   733 			
       
   734 		for(TInt n = 0; n < iLogosArray.Count(); n++)
       
   735 			{
       
   736 			if(i == iLogosArray[n])
       
   737 				{
       
   738 				//logo should be displayed in the search results for this particular station
       
   739 				HBufC* itemString = FormatItemStringLC( iView.iIsdsWrapper->iStationsData->
       
   740 														MdcaPoint(i),i);
       
   741 				iItemArray->AppendL( itemString->Des() );
       
   742 				CleanupStack::PopAndDestroy( itemString );
       
   743 				break;
       
   744 				}
       
   745 			}
       
   746 		}
       
   747 	if(iFilteredFlag)
       
   748 		{
       
   749 		TKeyEvent event;
       
   750 		TEventCode type = EEventKey;
       
   751 		event.iCode = EKeyDownArrow;
       
   752 		TBool needRefresh( EFalse );
       
   753 		AknFind::HandleFindOfferKeyEventL( event, type, this,
       
   754 		iStationsListBox, iStationsSearchBox,EFalse,needRefresh );
       
   755 		TInt filterModelCount = iFilteredModel->NumberOfItems();	
       
   756 		if(filterModelCount ==1 && iView.iUi->iIsdsWrapper->GetBannerUrl())
       
   757 			{
       
   758 			iStationsListBox->SetCurrentItemIndex(0);
       
   759 			}
       
   760 		else
       
   761 			{
       
   762 			if(filterModelCount>1 && iView.iUi->iIsdsWrapper->GetBannerUrl() && !iLogoDownloadError)
       
   763 			iStationsListBox->SetCurrentItemIndex(1);
       
   764 			}
       
   765 		}
       
   766 	else
       
   767 		{
       
   768 		iStationsListBox->HandleItemAdditionL();
       
   769 		}
       
   770 	IRLOG_DEBUG( "CIRStationsViewContainer::UpdateStationsViewL - Exiting" );
       
   771 	}
       
   772 // ---------------------------------------------------------------------------
       
   773 // CIRStationsViewContainer::FormatItemStringLC
       
   774 // Formatter for list item strings.
       
   775 // ---------------------------------------------------------------------------
       
   776 //
       
   777 HBufC* CIRStationsViewContainer::FormatItemStringLC( const TDesC& aFirstRow, 
       
   778 											 TInt aIconId )
       
   779     {
       
   780  	_LIT(KItemFormatStringWithLogo, "%d%S"); 
       
   781 	_LIT(KItemFormatStringWithOutLogo, "%S");   
       
   782 
       
   783     TInt length = KIRListItemBaseLength + aFirstRow.Length() ;
       
   784     HBufC* itemString = HBufC::NewLC( length );
       
   785     
       
   786     TPtrC formatStringWithIcon( KItemFormatStringWithLogo );
       
   787     TPtrC formatStringWithoutIcon( KItemFormatStringWithOutLogo );
       
   788 
       
   789     if( aIconId >= 0 && aIconId <= KRange )
       
   790         {
       
   791         itemString->Des().Format( KItemFormatStringWithLogo, aIconId, &aFirstRow);
       
   792         }
       
   793     else 
       
   794         {
       
   795         itemString->Des().Format( KItemFormatStringWithOutLogo, &aFirstRow);
       
   796         }
       
   797     
       
   798     return itemString;
       
   799     }
       
   800 
       
   801 // ---------------------------------------------------------------------------
       
   802 // CIRStationsViewContainer::GetCurrentItemIndex()
       
   803 // returns the index of the currently selected item
       
   804 // ---------------------------------------------------------------------------
       
   805 //
       
   806 
       
   807 TInt CIRStationsViewContainer::GetCurrentItemIndex() const
       
   808     {
       
   809     IRLOG_DEBUG( "CIRStationsViewContainer::GetCurrentItemIndex" );
       
   810 	return iStationsListBox->CurrentItemIndex();
       
   811     }
       
   812 
       
   813 // ---------------------------------------------------------------------------
       
   814 // CIRStationsViewContainer::GetListBoxTopIndex()
       
   815 // returns the index of the top item
       
   816 // ---------------------------------------------------------------------------
       
   817 //
       
   818 
       
   819 TInt CIRStationsViewContainer::GetListBoxTopIndex() const
       
   820 	{
       
   821 	IRLOG_DEBUG( "CIRStationsViewContainer::GetListBoxTopIndex" );
       
   822 	return iStationsListBox->View()->TopItemIndex () ;
       
   823 	}
       
   824 // ---------------------------------------------------------------------------
       
   825 // CIRStationsViewContainer::GetSearchBoxPointer()
       
   826 // returns the search box pointer.
       
   827 // ---------------------------------------------------------------------------
       
   828 //
       
   829 CAknSearchField* CIRStationsViewContainer::GetSearchBoxPointer()
       
   830 	{
       
   831 	IRLOG_DEBUG( "CIRStationsViewContainer::GetSearchBoxPointer" );
       
   832 	return 	iStationsSearchBox;
       
   833 	}
       
   834 
       
   835 // ---------------------------------------------------------------------------
       
   836 // CIRStationsViewContainer::GetFilterdModelPointer()
       
   837 // returns pointer to filtered model.
       
   838 // ---------------------------------------------------------------------------
       
   839 //
       
   840 CIRFilteredModel* CIRStationsViewContainer::GetFilterdModelPointer()
       
   841 	{
       
   842 	IRLOG_DEBUG( "CIRStationsViewContainer::GetListPointer" );
       
   843 	return iFilteredModel;	
       
   844 	}
       
   845 //----------------------------------------------------------------------------
       
   846 // CIRStationsViewContainer::CountComponentControls() const
       
   847 // returns the number of components in the view.
       
   848 //----------------------------------------------------------------------------
       
   849 //
       
   850 TInt CIRStationsViewContainer::CountComponentControls() const
       
   851 	{
       
   852 	IRLOG_DEBUG( "CIRStationsViewContainer::CountComponentControls - Entering" );
       
   853 	TInt count(KCONTROLSCOUNT);
       
   854 	IRLOG_DEBUG( "CIRStationsViewContainer::CountComponentControls - Exiting" );
       
   855 	if(iStationsListBox)
       
   856 		{
       
   857 		count++;
       
   858 		}
       
   859 	if(iStationsSearchBox)
       
   860 		{
       
   861 		count++;
       
   862 		}
       
   863 	return count;
       
   864 	}
       
   865 //----------------------------------------------------------------------------
       
   866 // CIRStationsViewContainer::ComponentControl() const
       
   867 // returns a pointer to the control under this view depending on the index
       
   868 // passed,to the framework.
       
   869 //----------------------------------------------------------------------------
       
   870 // 
       
   871 CCoeControl* CIRStationsViewContainer::ComponentControl(TInt aIndex) const
       
   872 	{
       
   873 	IRLOG_DEBUG( "CIRStationsViewContainer::ComponentControl - Entering" );
       
   874 	IRLOG_DEBUG( "CIRStationsViewContainer::ComponentControl - Exiting" );
       
   875 	switch(aIndex)
       
   876 		{
       
   877 		case 0:
       
   878 			{
       
   879 			if(iStationsListBox)
       
   880 			return iStationsListBox;
       
   881 			}
       
   882 		case 1:
       
   883 			{
       
   884 			if(iStationsSearchBox)
       
   885 			return iStationsSearchBox;
       
   886 			}
       
   887 		default:
       
   888 			return NULL;
       
   889 		}
       
   890 	}
       
   891 // ---------------------------------------------------------------------------
       
   892 // void CIRStationsViewContainer::SizeChanged(const TRect& aRect)
       
   893 // Responds to changes to the size and position of the contents of this control.
       
   894 // ---------------------------------------------------------------------------
       
   895 //
       
   896 
       
   897 void CIRStationsViewContainer::SizeChanged()
       
   898 	{
       
   899 	IRLOG_DEBUG( "CIRStationsViewContainer::SizeChanged - Entering" );
       
   900 	if(iView.iUi->IsLandscapeOrientation())
       
   901 		{
       
   902 		if(iStationsListBox && iStationsSearchBox && iLandScapeCount ==0)
       
   903 			{
       
   904 	   		AknFind::HandlePopupFindSizeChanged(this,iStationsListBox,iStationsSearchBox);
       
   905 	   		iLandScapeCount ++;
       
   906 			}
       
   907 		}
       
   908 	if(iStationsListBox && iStationsSearchBox)
       
   909 		{
       
   910 	    AknLayoutUtils::LayoutControl(iStationsListBox,  Rect(),
       
   911             AKN_LAYOUT_WINDOW_list_gen_pane(1));
       
   912         AknLayoutUtils::LayoutControl(iStationsSearchBox,  Rect(),
       
   913             AKN_LAYOUT_WINDOW_find_pane);
       
   914 		}
       
   915 	else
       
   916 		{
       
   917 		if(iStationsListBox)
       
   918 			{
       
   919 			AknLayoutUtils::LayoutControl(iStationsListBox, Rect(),
       
   920             	AKN_LAYOUT_WINDOW_list_gen_pane(0));
       
   921 			}
       
   922 		}
       
   923 	TRect clientRect(((CEikAppUi*)(CCoeEnv::Static()->AppUi()))->ClientRect());
       
   924 	TRect parentRectSize(TPoint(0,0),clientRect.iBr);
       
   925 
       
   926 	if ( iBgContext )
       
   927 		{
       
   928 		iBgContext->SetRect(parentRectSize);
       
   929 		}
       
   930 	DrawNow();	
       
   931 	IRLOG_DEBUG( "CIRStationsViewContainer::SizeChanged - Exiting" );
       
   932 	}
       
   933 
       
   934 // ---------------------------------------------------------------------------
       
   935 // void CIRStationsViewContainer::HandleResourceChange(TInt aType)
       
   936 // Handles a change to the control's resources.
       
   937 // ---------------------------------------------------------------------------
       
   938 //
       
   939 void CIRStationsViewContainer::HandleResourceChange(TInt aType)
       
   940 	{
       
   941 	IRLOG_DEBUG( "CIRStationsViewContainer::HandleResourceChange - Entering" );
       
   942     CCoeControl::HandleResourceChange( aType );
       
   943     // application layout change request notification
       
   944     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   945         {
       
   946         // reconstruct controls if needed
       
   947         if(iStationsListBox && iStationsSearchBox )
       
   948 	        {
       
   949 	   		AknFind::HandlePopupFindSizeChanged(this,iStationsListBox,iStationsSearchBox);
       
   950 	        SizeChanged();
       
   951 	        }
       
   952         }
       
   953 	iView.SetToolbarItems();
       
   954 	IRLOG_DEBUG( "CIRStationsViewContainer::HandleResourceChange - Exiting" );
       
   955 	}
       
   956 //----------------------------------------------------------------------------
       
   957 // CIRStationsViewContainer::CreateFindBoxL()
       
   958 // creates the Find box when any character is Pressed
       
   959 //----------------------------------------------------------------------------
       
   960 // 
       
   961 CAknSearchField* CIRStationsViewContainer::CreateFindBoxL(CEikListBox* aListBox,
       
   962 CTextListBoxModel* aModel, CAknSearchField::TSearchFieldStyle aStyle)
       
   963 	{
       
   964 	IRLOG_DEBUG( "CIRStationsViewContainer::CreateFindBoxL - Entering" );
       
   965 	CAknSearchField* findbox = NULL;
       
   966 	if (aListBox && aModel)
       
   967 		{
       
   968 		// Gets pointer of CAknFilteredTextListBoxModel.
       
   969 		// Added For Dynamic Filtering
       
   970 		 iFilteredModel = STATIC_CAST( CIRFilteredModel*, aModel );
       
   971 		// Creates FindBox.
       
   972 		findbox = CAknSearchField::NewL( *this, aStyle, NULL,
       
   973 		KAknExListFindBoxTextLength);
       
   974 		CleanupStack::PushL(findbox);
       
   975 		// Creates CAknListBoxFilterItems class.
       
   976 		iFilteredModel->CreateFilterL( aListBox, findbox );
       
   977 		CleanupStack::Pop(findbox); // findbox
       
   978 		}
       
   979 	IRLOG_DEBUG( "CIRStationsViewContainer::CreateFindBoxL - Exiting" );
       
   980 	return findbox;
       
   981 	}
       
   982 //----------------------------------------------------------------------------
       
   983 // CIRStationsViewContainer::DisableFindBox()
       
   984 // Deletes the findbox
       
   985 //----------------------------------------------------------------------------
       
   986 // 
       
   987 void CIRStationsViewContainer::DisableFindBox()
       
   988 	{
       
   989 	IRLOG_DEBUG( "CIRStationsViewContainer::DisableFindBox - Entering" );
       
   990 	if (iStationsSearchBox)
       
   991 		{
       
   992 		iFilteredModel->RemoveFilter();
       
   993 		// Important to set the find box non-focusing before
       
   994 		// deleting it, otherwise the focus changes triggered
       
   995 		// by the removal of the control from stack will focus
       
   996 		// the find box which is under deletion
       
   997 		iStationsSearchBox->SetNonFocusing();
       
   998 		delete iStationsSearchBox;
       
   999 		iStationsSearchBox = NULL;
       
  1000 		// Inform list box that find is hidden
       
  1001 		static_cast<CAknColumnListBoxView*>(iStationsListBox->View())->SetFindEmptyListState(EFalse);
       
  1002 		SizeChanged();
       
  1003 		}
       
  1004 	IRLOG_DEBUG( "CIRStationsViewContainer::DisableFindBox - Exiting" );
       
  1005 	}
       
  1006 
       
  1007 // ---------------------------------------------------------------------------
       
  1008 // Function : Comparestrings
       
  1009 // Function called to compare the filtered string inthe Itemarray
       
  1010 // ---------------------------------------------------------------------------
       
  1011 //
       
  1012 void  CIRStationsViewContainer::Comparestrings()
       
  1013 	{
       
  1014 	IRLOG_DEBUG( "CIRStationsViewContainer::Comparestrings - Entering" );
       
  1015 	TInt count = iFilteredModel->NumberOfItems();	
       
  1016 	if(count)
       
  1017 		{
       
  1018 		if((count==1) && iAdvPreset && !iLogoDownloadError)
       
  1019 			{
       
  1020 			return;
       
  1021 			}
       
  1022 		else
       
  1023 			{
       
  1024 			TPtrC16 filteredString = iFilteredModel->ItemText (iView.GetFilteredIndex());
       
  1025 			for(TInt i=0;i<iItemArray->Count();i++)
       
  1026 				{
       
  1027 				TPtrC16 matchString=iItemArray->MdcaPoint(i);
       
  1028 				if(filteredString==matchString)
       
  1029 					{
       
  1030 					iView.SetActualFilteredItemIndex(i);
       
  1031 					break;
       
  1032 					}
       
  1033 				}
       
  1034 			}
       
  1035 		}
       
  1036 	IRLOG_DEBUG( "CIRStationsViewContainer::Comparestrings - Exiting" );
       
  1037 	}
       
  1038 
       
  1039 
       
  1040 // ---------------------------------------------------------------------------
       
  1041 // void CIRStationsViewContainer::HandleImageConversionEventL( MIRImageConverterObserver::TIRImageConversionEvent /*aEvent*/, 
       
  1042 // from base class MIRImageConverterObserver
       
  1043 // ---------------------------------------------------------------------------
       
  1044 //
       
  1045 void CIRStationsViewContainer::HandleImageConversionEventL( 
       
  1046 						MIRImageConverterObserver::TIRImageConversionEvent aEvent, 
       
  1047                                                            TInt aId, 
       
  1048                                                            TInt aError )
       
  1049 	{
       
  1050 	IRLOG_DEBUG( "CIRStationsViewContainer::HandleImageConversionEventL - Entering" );
       
  1051 	iError=aError;
       
  1052 	if(aError == KErrNotSupported && iRequestForAdvertisement)
       
  1053 		{
       
  1054 		iLogoDownloadError	= ETrue;
       
  1055 		iFilteredModel->SetAdvFlag(EFalse,*iAdvString);
       
  1056 		iRequestForAdvertisement = EFalse;
       
  1057 		}
       
  1058 	if ( !aError && aEvent == MIRImageConverterObserver::EIRImageConversionCompleted )
       
  1059 		{
       
  1060 		IRLOG_DEBUG( "CIRStationsViewContainer::HandleImageConversionEventL - Entering if" );
       
  1061 		if(iRequestForAdvertisement)
       
  1062 			{
       
  1063 	        CFbsBitmap* bitmap = NULL;
       
  1064 	        CFbsBitmap* mask = NULL;
       
  1065 	        
       
  1066 	        iCurrentItemConverter->TransferBitmapOwnership( bitmap, mask );
       
  1067 	        if ( bitmap && mask )
       
  1068 		        {
       
  1069           	    CleanupStack::PushL( bitmap );
       
  1070             	CleanupStack::PushL( mask );
       
  1071 		      	CGulIcon* icon = CGulIcon::NewLC();
       
  1072                 
       
  1073                 icon->SetBitmap( bitmap );
       
  1074                 icon->SetMask( mask );
       
  1075                 icon->SetBitmapsOwnedExternally( ETrue );
       
  1076                 
       
  1077                 iStationsListBox->SetAdvertisementIconL( icon );
       
  1078                 
       
  1079                 CleanupStack::Pop( icon );
       
  1080                 icon->SetBitmapsOwnedExternally( EFalse );
       
  1081                 CleanupStack::Pop( mask );
       
  1082                 CleanupStack::Pop( bitmap );
       
  1083 		        }
       
  1084 			iRequestForAdvertisement = EFalse;
       
  1085 			iLogoDownloadError	= EFalse;
       
  1086 			}
       
  1087 		else
       
  1088 			{
       
  1089 			if ( iInvalidIconIndices.Count() )
       
  1090 				{
       
  1091 				iIconIndex = iInvalidIconIndices[0];		
       
  1092 				iLogosArray.InsertInOrderL(iInvalidIconIndices[0]);
       
  1093 				if(iNoLogosArray.Count())
       
  1094 					{
       
  1095 					iNoLogosArray.Remove(iNoLogosArray.FindInOrder(iIconIndex));
       
  1096 					}
       
  1097 				CArrayPtr<CGulIcon>* iconArray = iStationsListBox->ItemDrawer()
       
  1098 						->FormattedCellData()->IconArray();
       
  1099 				if(aError == KErrNone)
       
  1100 					{
       
  1101 					if(aId == KErrUnknown)
       
  1102 						{
       
  1103 						if ( iInvalidIconIndices.Count() )
       
  1104 							{
       
  1105 							iInvalidIconIndices.Remove( 0 );
       
  1106 							}					
       
  1107 						}
       
  1108 
       
  1109 					CFbsBitmap* bitmap = NULL;
       
  1110 					CFbsBitmap* mask = NULL;
       
  1111 					aId == KErrUnknown ? iConverter->TransferBitmapOwnership( bitmap, mask ) : 
       
  1112 					iCurrentItemConverter->TransferBitmapOwnership( bitmap, mask );
       
  1113 					if ( bitmap && mask )
       
  1114 						{
       
  1115 			      	    CleanupStack::PushL( bitmap );
       
  1116 			        	CleanupStack::PushL( mask );
       
  1117 						CGulIcon* icon = CGulIcon::NewLC();
       
  1118 						icon->SetBitmap( bitmap );
       
  1119 						icon->SetMask( mask );
       
  1120 						icon->SetBitmapsOwnedExternally( EFalse );
       
  1121 
       
  1122 						iconArray->InsertL( iIconIndex, icon );
       
  1123 						CleanupStack::Pop( icon );
       
  1124 						if(iIconIndex+1 < iconArray->Count())
       
  1125 							{
       
  1126 							icon = iconArray->At( iIconIndex+1 );
       
  1127 							iconArray->Delete( iIconIndex+1 );
       
  1128 							delete icon;
       
  1129 							}
       
  1130 						}
       
  1131 	                CleanupStack::Pop( mask );
       
  1132 	                CleanupStack::Pop( bitmap );
       
  1133 					iStationsListBox->DrawNow();
       
  1134 					}
       
  1135 				}
       
  1136 			iItemArray->Reset();
       
  1137 			if(iAdvString )
       
  1138 				{
       
  1139 				if(!iLogoDownloadError)
       
  1140 				iFilteredModel->SetItemAtZero(ETrue,*iAdvString);
       
  1141 				}
       
  1142 
       
  1143 			UpdateStationsViewL();
       
  1144 			if ( iInvalidIconIndices.Count() && aId == KErrUnknown )
       
  1145 				{
       
  1146 				StartConvertL( *iConverter, iInvalidIconIndices[0], KErrUnknown );
       
  1147 				}
       
  1148 			}
       
  1149 
       
  1150 		}
       
  1151 	else if ( !aError && aEvent == MIRImageConverterObserver::EIRFrameConversionCompleted )
       
  1152 		{
       
  1153 		iRequestForAdvertisement = EFalse;
       
  1154 		iLogoDownloadError	= EFalse;
       
  1155 		CGulIcon* icon = iStationsListBox->AdvertisementIcon(); 
       
  1156 		if ( !icon )
       
  1157 			{
       
  1158 			icon = CGulIcon::NewLC();
       
  1159 			iStationsListBox->SetAdvertisementIconL( icon );
       
  1160 			CleanupStack::Pop( icon );
       
  1161 			}
       
  1162 		icon->SetBitmap( const_cast<CFbsBitmap*>(iCurrentItemConverter->Bitmap()));
       
  1163 		icon->SetMask(const_cast<CFbsBitmap*>(iCurrentItemConverter->Mask() ));
       
  1164 		icon->SetBitmapsOwnedExternally( ETrue );
       
  1165 		DrawDeferred();
       
  1166 		}
       
  1167 	else
       
  1168 		{
       
  1169 
       
  1170 		}
       
  1171 	if(iAdPresent)
       
  1172 		{
       
  1173 		if ( iInvalidIconIndices.Count() )
       
  1174 			{
       
  1175 			iRequestForAdvertisement = EFalse;
       
  1176 			iView.SetCurrentFocus(1);	
       
  1177 			StartConvertL( *iConverter, iInvalidIconIndices[0], KErrUnknown );
       
  1178 			}
       
  1179 
       
  1180 		}
       
  1181 	iAdPresent = EFalse;
       
  1182 	IRLOG_DEBUG( "CIRStationsViewContainer::HandleImageConversionEventL - Exiting" );
       
  1183 	}
       
  1184 
       
  1185 
       
  1186 // ---------------------------------------------------------------------------
       
  1187 // void CIRStationsViewContainer::HandleLogoErrorL()
       
  1188 // called from the iStationsView when the logo is not downloaded
       
  1189 // ---------------------------------------------------------------------------
       
  1190 //
       
  1191 void CIRStationsViewContainer::HandleLogoErrorL()
       
  1192 	{
       
  1193 	IRLOG_DEBUG( "CIRStationsViewContainer::HandleLogoErrorL - Entering" );
       
  1194 	if(iAdRequestStatusFlag)
       
  1195 		{
       
  1196 		iLogoDownloadError	= ETrue;
       
  1197 		iFilteredModel->SetAdvFlag(EFalse,*iAdvString);
       
  1198 		iAdRequestStatusFlag = EFalse;
       
  1199 		iAdPresent = EFalse;
       
  1200 		if ( iInvalidIconIndices.Count() )
       
  1201 			{
       
  1202 			StartConvertL( *iConverter, iInvalidIconIndices[0], KErrUnknown );
       
  1203 			}
       
  1204 		}
       
  1205 	else
       
  1206 		{
       
  1207 		if ( iInvalidIconIndices.Count()  )
       
  1208 			{
       
  1209 			iInvalidIconIndices.Remove( 0 );
       
  1210 			}	
       
  1211 		if ( iInvalidIconIndices.Count() )
       
  1212 			{
       
  1213 			StartConvertL( *iConverter, iInvalidIconIndices[0], KErrUnknown );
       
  1214 			}
       
  1215 		}	
       
  1216 	IRLOG_DEBUG( "CIRStationsViewContainer::HandleLogoErrorL - Exiting" );
       
  1217 	}
       
  1218 
       
  1219 
       
  1220 // ---------------------------------------------------------------------------
       
  1221 // void CIRStationsViewContainer::StartConvertL( CIRImageConverter& aConverter, TInt aIndex, TInt aId )
       
  1222 // used to convert the images depending the index passed
       
  1223 // ---------------------------------------------------------------------------
       
  1224 //
       
  1225 void CIRStationsViewContainer::StartConvertL( CIRImageConverter& aConverter, TInt aIndex, TInt /*aId*/ )
       
  1226 	{
       
  1227 	IRLOG_DEBUG( "CIRStationsViewContainer::StartConvertL - Entering" );
       
  1228 	TInt channelsCount = iView.iIsdsWrapper->iStationsData->Count();
       
  1229 	iResult = 0;
       
  1230 	RBuf url;
       
  1231 	url.Create(iView.iIsdsWrapper->iChannelImgUrl->MdcaPoint(aIndex).Size());
       
  1232 	url.Copy(iView.iIsdsWrapper->iChannelImgUrl->MdcaPoint(aIndex));
       
  1233 
       
  1234 	iView.iUi->iIsdsWrapper->GetISDSInstance()->GetDataProvider()->GetHttpDataProvider()->
       
  1235 			GetLogoDownloadEngine()->GetCacheLogoL(url,iResult);
       
  1236 
       
  1237 	if((iResult == 0) || (iResult == -1))//not available in the cache or cache is stale/not useable
       
  1238 		{
       
  1239 		//code to download the logo
       
  1240 		if(iTempPreset)
       
  1241 			{
       
  1242 			delete iTempPreset;
       
  1243 			iTempPreset = NULL;
       
  1244 			}
       
  1245 		iTempPreset=CIRIsdsPreset::NewL();
       
  1246 		iTempPreset->SetChannelType(1);
       
  1247 		iTempPreset->SetImgUrl(url);		
       
  1248 		iView.LogoRequestL();
       
  1249 		}
       
  1250 	else if(iResult == 1)//cache is useable
       
  1251 		{
       
  1252 		iError=KErrNone;
       
  1253 		aConverter.SetDataL(iView.iUi->iIsdsWrapper->GetISDSInstance()->GetDataProvider()->
       
  1254 					GetHttpDataProvider()->GetLogoDownloadEngine()->SendCacheLogo());
       
  1255 					
       
  1256 		if(iError==KErrNone)
       
  1257 			{
       
  1258 			iConverter->StartL( KBitmapSize, KErrUnknown );	
       
  1259 			}
       
  1260 			else
       
  1261 			{
       
  1262 		if( iError!=KErrNone)
       
  1263 			{
       
  1264 			if ( iInvalidIconIndices.Count() )
       
  1265 				{
       
  1266 				iInvalidIconIndices.Remove( 0 );
       
  1267 				}	
       
  1268 			if ( iInvalidIconIndices.Count() )
       
  1269 				{
       
  1270 				StartConvertL( *iConverter, iInvalidIconIndices[0], KErrUnknown );
       
  1271 				}
       
  1272 			}
       
  1273 			}
       
  1274 		}
       
  1275 	url.Close();
       
  1276 	IRLOG_DEBUG( "CIRStationsViewContainer::StartConvertL - Exiting" );
       
  1277 	}
       
  1278 
       
  1279 
       
  1280 // ---------------------------------------------------------------------------
       
  1281 // CIRStationsViewContainer::PresetLogoDownloadL()
       
  1282 // 
       
  1283 // ---------------------------------------------------------------------------
       
  1284 //
       
  1285 void CIRStationsViewContainer::PresetLogoDownloadL(CIRIsdsPreset* aPreset)
       
  1286 	{
       
  1287 	IRLOG_DEBUG( "CIRStationsViewContainer::PresetLogoDownloadL - Entering" );
       
  1288 	if(iAdPresent && iAdRequestStatusFlag)
       
  1289 		{
       
  1290 		if (iView.iUi->iIsdsWrapper->GetBannerUrl())
       
  1291 			{
       
  1292 			*iAdvPreset = *aPreset;	
       
  1293 			if(iAdvPreset->GetLogoData()!=KNullDesC8 )
       
  1294 				{
       
  1295 				iFilteredModel->SetAdvFlag(ETrue,*iAdvString);
       
  1296 				iError=KErrNone;
       
  1297 				iCurrentItemConverter->SetDataL(aPreset->GetLogoData());
       
  1298 				if(iError==KErrNone)
       
  1299 					{
       
  1300 					iCurrentItemConverter->StartL( IRLayoutUtils::AdvertisementSizeL(), KErrUnknown );//KLogoSize
       
  1301 					}
       
  1302 				iRequestForAdvertisement = ETrue;	
       
  1303 				iAdRequestStatusFlag = EFalse;
       
  1304 				}
       
  1305 			}
       
  1306 		return ;
       
  1307 		}
       
  1308 
       
  1309 	if(aPreset->GetLogoData()!=KNullDesC8)
       
  1310 		{
       
  1311 		iRequestForAdvertisement = EFalse;
       
  1312 		iError=KErrNone;	
       
  1313 		iConverter->SetDataL(aPreset->GetLogoData());
       
  1314 		if(iError==KErrNone)
       
  1315 			{
       
  1316 			iConverter->StartL( KBitmapSize, KErrUnknown );	
       
  1317 			}
       
  1318 		if(iError!=KErrNone)
       
  1319 			{
       
  1320 			if ( iInvalidIconIndices.Count() )
       
  1321 				{
       
  1322 				iInvalidIconIndices.Remove( 0 );
       
  1323 				}	
       
  1324 			if ( iInvalidIconIndices.Count() )
       
  1325 				{
       
  1326 				StartConvertL( *iConverter, iInvalidIconIndices[0], KErrUnknown );
       
  1327 				}
       
  1328 			}
       
  1329 		}
       
  1330 
       
  1331 	IRLOG_DEBUG( "CIRStationsViewContainer::PresetLogoDownloadL - Exiting" );
       
  1332 	}
       
  1333 
       
  1334 // ---------------------------------------------------------------------------
       
  1335 // CIRStationsViewContainer::OpenUrlL( const TDesC& aHttpLink)
       
  1336 // used to connect to the advertisement url.
       
  1337 // ---------------------------------------------------------------------------
       
  1338 //
       
  1339 void CIRStationsViewContainer::OpenUrlL( const TDesC& aHttpLink )
       
  1340 	{
       
  1341 	IRLOG_DEBUG( "CIRStationsViewContainer::OpenUrlL - Entering" );
       
  1342 
       
  1343 	TDataType htmlDataType( KIRHtmlMimeType );
       
  1344 	TUid uid;
       
  1345 
       
  1346 	RApaLsSession ls;
       
  1347 	User::LeaveIfError( ls.Connect() );
       
  1348 	CleanupClosePushL( ls );
       
  1349 
       
  1350 	// Get UID of the browser.
       
  1351 	TInt retVal = ls.AppForDataType( htmlDataType, uid );
       
  1352 
       
  1353 	if ( retVal == KErrNone && uid != KNullUid )
       
  1354 		{
       
  1355 		// We must check if the browser is already open and if it is, 
       
  1356 		// switch its currently opened file to the correct URL.
       
  1357 		TApaTaskList taskList( iEikonEnv->WsSession() );
       
  1358 		TApaTask task = taskList.FindApp( uid );
       
  1359 		if ( task.Exists() )
       
  1360 			{
       
  1361 			HBufC8* url8 = HBufC8::NewLC( aHttpLink.Length() );
       
  1362 			url8->Des().Copy( aHttpLink );
       
  1363 			task.SendMessage( TUid::Uid( 0 ), url8->Des() );
       
  1364 			task.BringToForeground();
       
  1365 			CleanupStack::PopAndDestroy( url8 );
       
  1366 			}
       
  1367 		else
       
  1368 			{
       
  1369 			TThreadId threadId;
       
  1370 			HBufC* newUrl = HBufC::NewLC( aHttpLink.Length() + KBrowserPrefix().Length() );
       
  1371 			newUrl->Des().Append( KBrowserPrefix );
       
  1372 			newUrl->Des().Append( aHttpLink );
       
  1373 			ls.StartDocument( newUrl->Des(), uid, threadId );
       
  1374 			CleanupStack::PopAndDestroy( newUrl );
       
  1375 			}
       
  1376 		}
       
  1377 	CleanupStack::PopAndDestroy( &ls );
       
  1378 
       
  1379 	IRLOG_DEBUG( "CIRStationsViewContainer::OpenUrlL - Exiting" );
       
  1380 
       
  1381 	}
       
  1382 //----------------------------------------------------------------------------
       
  1383 // CIRStationsViewContainer::GetLogoNotSupported() 
       
  1384 // returns whether the advertisement is supported by the sdk r not
       
  1385 //----------------------------------------------------------------------------
       
  1386 // 	
       
  1387 TBool CIRStationsViewContainer::GetLogoNotSupported()
       
  1388 	{
       
  1389 	IRLOG_DEBUG( "CIRStationsViewContainer::GetLogoNotSupported - Entering" );
       
  1390 	IRLOG_DEBUG( "CIRStationsViewContainer::GetLogoNotSupported - Exiting" );
       
  1391 	return iLogoDownloadError;
       
  1392 	}