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