internetradio2.0/uisrc/irisdswrapper.cpp
changeset 3 ee64f059b8e1
parent 2 2e1adbfc62af
child 4 3f2d53f144fe
child 5 0930554dc389
equal deleted inserted replaced
2:2e1adbfc62af 3:ee64f059b8e1
     1 /*
       
     2 * Copyright (c) 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:  Wrapper class for Isds functions
       
    15 *
       
    16 */
       
    17 
       
    18 #include "irisdswrapper.h"
       
    19 #include "isdsclientdll.h"
       
    20 #include "irdebug.h"
       
    21 #include "irsettings.h"
       
    22 #include "misdsresponseobserver.h"
       
    23 #include "mviewsresponseanderrorobserver.h"
       
    24 #include "irbrowsecatagoryitems.h"
       
    25 #include "irbrowsechannelitems.h"
       
    26 #include "irisdspreset.h"
       
    27 #include "irfavoritesdb.h"
       
    28 #include "irdialoglauncher.h"
       
    29 #include <internetradio.rsg>
       
    30 #include <stringloader.h>
       
    31 #include "irdataproviderconstants.h"
       
    32 #include "ir.hrh"
       
    33 #include "msyncpresetobserver.h"
       
    34 #include <aknwaitdialog.h>
       
    35 
       
    36 
       
    37 _LIT(KFalse,"false");
       
    38 const TInt KStationsDataMaxLength = 5;
       
    39 const TInt KCategoryDataMaxLength = 5;
       
    40 const TInt KBufSize = 100;
       
    41 const TInt KSize = 10;
       
    42 
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CIRIsdsWrapper* CIRIsdsWrapper::NewL()
       
    46 // function to return an instance of CIRIsdsWrapper 
       
    47 // Two phase constructor
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CIRIsdsWrapper* CIRIsdsWrapper::NewL(CIRSettings& aIRSettings,CIRFavoritesDb& aFavPresets)
       
    51 	{
       
    52 	IRLOG_DEBUG( "CIRIsdsWrapper::NewL - Entering" );
       
    53 	CIRIsdsWrapper* self = CIRIsdsWrapper::NewLC(aIRSettings,aFavPresets);
       
    54 	CleanupStack::Pop(self);
       
    55 	IRLOG_DEBUG( "CIRIsdsWrapper::NewL - Exiting" );
       
    56 	return self;
       
    57 	}
       
    58         
       
    59 // ---------------------------------------------------------------------------
       
    60 // CIRIsdsWrapper* CIRIsdsWrapper::NewLC()
       
    61 // Two-phased constructor.
       
    62 // Create a CIRIsdsWrapper object, which will draw itself
       
    63 // to aRect.
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CIRIsdsWrapper* CIRIsdsWrapper::NewLC(CIRSettings& aIRSettings,CIRFavoritesDb& aFavPresets)
       
    67 	{
       
    68 	IRLOG_DEBUG( "CIRIsdsWrapper::NewLC - Entering" );
       
    69 	CIRIsdsWrapper* self = new (ELeave) CIRIsdsWrapper(aIRSettings,aFavPresets);
       
    70 	CleanupStack::PushL(self);
       
    71 	self->ConstructL();
       
    72 	IRLOG_DEBUG( "CIRIsdsWrapper::NewLC - Exiting." );
       
    73 	return self;
       
    74 	}
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // CIRIsdsWrapper:: ~CIRIsdsWrapper()
       
    78 // Destructor..
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 CIRIsdsWrapper:: ~CIRIsdsWrapper()
       
    82 	{
       
    83 	IRLOG_DEBUG( "CIRIsdsWrapper::~CIRIsdsWrapper - Entering" );
       
    84 	if( iISDSClient )
       
    85 	{
       
    86 	delete iISDSClient;
       
    87 	}
       
    88 	delete iStationsData;
       
    89 	delete iDiaologLauncher;
       
    90 	delete iCategoryData;
       
    91 	delete iChannelImgUrl;
       
    92 
       
    93 	iChannelIdArray.Close();
       
    94 	if(iBannerUrl) 
       
    95 		{
       
    96 		delete iBannerUrl;
       
    97 		}
       
    98 	iBannerUrl = NULL;
       
    99 
       
   100 
       
   101     if (iClickThroughUrl)
       
   102 		{
       
   103 		delete iClickThroughUrl;
       
   104 		}
       
   105     iClickThroughUrl = NULL;
       
   106     
       
   107     if(iCatBannerUrl) 
       
   108 		{
       
   109 		delete iCatBannerUrl;
       
   110 		}
       
   111 	iCatBannerUrl = NULL;
       
   112 
       
   113 
       
   114     if (iCatClickThroughUrl)
       
   115 		{
       
   116 		delete iCatClickThroughUrl;
       
   117 		}
       
   118     iCatClickThroughUrl = NULL;
       
   119 	if(iIsdsWaitDialog)
       
   120     	{
       
   121     	delete iIsdsWaitDialog;
       
   122     	iIsdsWaitDialog= NULL;
       
   123     	}
       
   124 	IRLOG_DEBUG( "CIRIsdsWrapper::~CIRIsdsWrapper - Exiting" );
       
   125 	}
       
   126 // ---------------------------------------------------------------------------
       
   127 // void CIRIsdsWrapper::ConstructL()
       
   128 // Constructs the IsdsClient object
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131  
       
   132 void CIRIsdsWrapper::ConstructL()
       
   133 	{
       
   134 	IRLOG_DEBUG( "CIRIsdsWrapper::ConstructL - Entering" );
       
   135 
       
   136 	// ISDS INTERFACE 
       
   137 	_LIT(KServerAddress, "http://idirectory.xgns.net/isds");
       
   138 	//iISDSClient = CIRIsdsClient::NewL(*this , iIRSettings.GetISDSBaseUrlL());
       
   139 	iISDSClient = CIRIsdsClient::NewL(*this , KServerAddress);
       
   140 	iCategoryData = new (ELeave) CDesCArrayFlat(KStationsDataMaxLength);
       
   141 
       
   142 	iStationsData = new (ELeave) CDesCArrayFlat(KStationsDataMaxLength);
       
   143 	iChannelImgUrl = new (ELeave) CDesCArrayFlat(KStationsDataMaxLength);
       
   144 	//Dialog Launcher instance
       
   145 	iDiaologLauncher = CIRDialogLauncher::NewL();
       
   146 	iReqAddToFav = EFalse;
       
   147 	iError = EFalse;
       
   148 	iConnTimeOut = EFalse;
       
   149 	iBannerUrl = NULL;
       
   150 	iClickThroughUrl = NULL;
       
   151 	iCatBannerUrl = NULL;
       
   152 	iCatClickThroughUrl = NULL;
       
   153 	iIsdsWaitDialog = NULL;
       
   154 	iViewObserver = NULL;
       
   155 	IRLOG_DEBUG( "CIRIsdsWrapper::ConstructL - Exiting" );
       
   156 	}
       
   157 		
       
   158 // ---------------------------------------------------------------------------
       
   159 // void CIRIsdsWrapper::CIRIsdsWrapper()
       
   160 // Default Constructor
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 CIRIsdsWrapper::CIRIsdsWrapper(CIRSettings& aIRSettings,CIRFavoritesDb& aFavPresets):
       
   164 				iIRSettings(aIRSettings),iFavPresets(aFavPresets)
       
   165 	{
       
   166    	IRLOG_DEBUG( "CIRIsdsWrapper::CIRIsdsWrapper" );
       
   167 	//No implementation
       
   168    }
       
   169 // ---------------------------------------------------------------------------
       
   170 // CIRIsdsClient* CIRIsdsWrapper::GetISDSInstance()
       
   171 // Returns the ISDS Instance
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 CIRIsdsClient* CIRIsdsWrapper::GetISDSInstance()
       
   175    {
       
   176    IRLOG_DEBUG( "CIRIsdsWrapper::GetISDSInstance" );
       
   177    return iISDSClient;
       
   178    }
       
   179 // ---------------------------------------------------------------------------
       
   180 // CIRIsdsClient* CIRIsdsWrapper::GetISDSInstance()
       
   181 // Returns the ISDS Instance
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 CIRDialogLauncher* CIRIsdsWrapper::GetDialogLauncherInstance()
       
   185    {
       
   186    IRLOG_DEBUG( "CIRIsdsWrapper::GetDialogLauncherInstance" );
       
   187    return iDiaologLauncher;
       
   188    }
       
   189 // ---------------------------------------------------------------------------
       
   190 // void CIRIsdsWrapper::IsdsSearchRequestL()
       
   191 // Issues a search request to the Isds Client
       
   192 // ---------------------------------------------------------------------------
       
   193 //
       
   194 void CIRIsdsWrapper::IsdsSearchRequestL(MViewsResponseAndErrorObserver* aViewObserver,
       
   195 										const TDesC& aIsdsSearchString)
       
   196 	{
       
   197 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsSearchRequestL started." );
       
   198 	iViewObserver = aViewObserver;	
       
   199 	iSSearchRequest = ETrue;
       
   200 	iListenRequest=EFalse;
       
   201 	iWaitDialogWhileSearch=ETrue;
       
   202 	CreateWaitDialogL();
       
   203 	iISDSClient->IRISDSSearchL(aIsdsSearchString);
       
   204 	iWaitDialogWhileSearch=EFalse;
       
   205 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsSearchRequestL exiting" );
       
   206 	}
       
   207 // ---------------------------------------------------------------------------
       
   208 // void CIRIsdsWrapper::IsdsCategoryRequestL()
       
   209 // Issues a Category request to the Isds Client
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 void CIRIsdsWrapper::IsdsCategoryRequestL(MViewsResponseAndErrorObserver* aViewObserver,
       
   213 										  CIRIsdsClient::TIRIsdsclientInterfaceIDs aIDType)
       
   214 	{
       
   215 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsCategoryRequestL started." );
       
   216 	iViewObserver = aViewObserver;	
       
   217 	iListenRequest=EFalse;
       
   218 	CreateWaitDialogL();
       
   219 	iISDSClient->IRIsdsClientIntefaceL(aIDType);
       
   220 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsCategoryRequestL exiting" );
       
   221 	}
       
   222 // ---------------------------------------------------------------------------
       
   223 // void CIRIsdsWrapper::IsdsChannelRequestL()
       
   224 // Issues a Channel request to the Isds Client
       
   225 // ---------------------------------------------------------------------------
       
   226 //
       
   227 void CIRIsdsWrapper::IsdsChannelRequestL(MViewsResponseAndErrorObserver* aViewObserver,TInt aIndex)
       
   228 	{
       
   229 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsChannelRequestL started." );
       
   230 	iViewObserver = aViewObserver;	
       
   231 	iListenRequest=EFalse;
       
   232 	CreateWaitDialogL();
       
   233 	iISDSClient->IRIsdsClientIntefaceL(aIndex,CIRIsdsClient::ECatagory);
       
   234 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsChannelRequestL exiting" );
       
   235 	}
       
   236 
       
   237 // ---------------------------------------------------------------------------
       
   238 // void CIRIsdsWrapper::IsdsListenRequestL()
       
   239 // Issues a Listen request to the Isds Client
       
   240 // ---------------------------------------------------------------------------
       
   241 //
       
   242 void CIRIsdsWrapper::IsdsListenRequestL(MViewsResponseAndErrorObserver* aViewObserver,
       
   243 										TInt aCurrentIndex,TBool aHistoryBool)
       
   244 	{
       
   245 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsListenRequestL started." );
       
   246 	iViewObserver = aViewObserver;
       
   247 	iListenRequest=ETrue;
       
   248 	iHistoryBool = aHistoryBool ;
       
   249 	if(aHistoryBool)
       
   250 		{
       
   251 		iISDSClient->IRIsdsClientIntefaceL(aCurrentIndex,CIRIsdsClient::EChannels,ETrue);
       
   252 		}
       
   253 	else
       
   254 		{
       
   255 		iCurrentPlayingIndex = aCurrentIndex;
       
   256 		iISDSClient->IRIsdsClientIntefaceL(aCurrentIndex,CIRIsdsClient::EChannels);
       
   257 		}
       
   258 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsListenRequestL exiting" );
       
   259 	}
       
   260 
       
   261 
       
   262 
       
   263 // ---------------------------------------------------------------------------
       
   264 // MIsdsResponseObserver::IsdsErrorL()
       
   265 // Used to Indiacte error in retrieving data from Isds
       
   266 // @param aErrCode- contains error code
       
   267 // ---------------------------------------------------------------------------
       
   268 //
       
   269 void CIRIsdsWrapper::IsdsErrorL(TInt aErrorCode)
       
   270     {
       
   271     IRLOG_DEBUG( "CIRIsdsWrapper::IsdsErrorL started." );
       
   272     IRRDEBUG2("CIRISDSWRAPPER::ISDSERRORL",KNullDesC);
       
   273     DestroyWaitDialogL();
       
   274     
       
   275     
       
   276     iReqAddToFav = EFalse;
       
   277 
       
   278     
       
   279 	if( aErrorCode == KNotFound)
       
   280 		{
       
   281 		IRRDEBUG2("CIRISDSWRAPPER::ISDSERRORL--NOTFOUND",KNullDesC);
       
   282 		if(iViewObserver)
       
   283 			{
       
   284 			if(iSSearchRequest)	
       
   285 				{
       
   286 				iError = ETrue;
       
   287 				iViewObserver->ErrorL();
       
   288 				iSSearchRequest = EFalse;		
       
   289 				}
       
   290 			else 
       
   291 				{
       
   292 				if(iHistoryBool)
       
   293 					{
       
   294 					iKNotFound = ETrue ;
       
   295 					iViewObserver->ErrorL();
       
   296 					iHistoryBool = EFalse ;
       
   297 					iKNotFound = EFalse ;
       
   298 					}
       
   299 				else if(iSyncReqFromMainView)
       
   300 					{
       
   301 					iSyncReqFromMainView = EFalse;
       
   302 					iViewObserver->ErrorL();						
       
   303 					}
       
   304 				else
       
   305 					{
       
   306 					iViewObserver->ErrorL();
       
   307 					iDiaologLauncher->ShowErrorNoteL(R_IRAPP_ERROR_NOTINISDS,ETrue);	
       
   308 					}
       
   309 				}
       
   310 			}
       
   311 		}
       
   312 		
       
   313 	else if( aErrorCode == KNotModified )
       
   314 		{
       
   315 		IRRDEBUG2("CIRISDSWRAPPER::ISDSERRORL--NOTMODIFIED",KNullDesC);
       
   316 		iViewObserver->ErrorL();
       
   317 		//iDiaologLauncher->ShowErrorNoteL(R_IRAPP_ERROR_NOTINISDS,ETrue)
       
   318 		}
       
   319 	else if	( aErrorCode == KErrCouldNotConnect )
       
   320         {
       
   321         //VerifyNetworkConnectivityL()
       
   322         //iDiaologLauncher->ShowErrorNoteL(R_IRAPP_NW_NOCONN_ERROR,ETrue)
       
   323         }
       
   324 	else if	( aErrorCode == KDndTimedOut  )
       
   325         {
       
   326   		IRRDEBUG2("IsdsErrorL :DndTimedOut ",KNullDesC);
       
   327   		if(iViewObserver)
       
   328 			{
       
   329 			iViewObserver->ErrorL();
       
   330        		iDiaologLauncher->ShowErrorNoteL(R_IRAPP_NW_NOCONN_ERROR,ETrue);
       
   331 			}
       
   332         }
       
   333     else if ( aErrorCode == KServiceUnavailable )
       
   334 	    {
       
   335 		if(iSyncReqFromMainView)
       
   336 			{
       
   337 			iSyncReqFromMainView = EFalse;
       
   338 			}
       
   339 		if( iViewObserver )
       
   340 			{
       
   341 			iViewObserver->ErrorL();
       
   342 			iDiaologLauncher->ShowErrorNoteL(R_IRAPP_ERROR_ISDS_UNAVAILABLE,ETrue);	
       
   343 			}
       
   344 	    }
       
   345     else if ( aErrorCode == KErrCorrupt )
       
   346         {
       
   347         IRRDEBUG2("CIRISDSWRAPPER::ISDSERRORL--KERRCORRUPT",KNullDesC);
       
   348         iDiaologLauncher->ShowErrorNoteL( R_IRAPP_ERROR_ADDRESS,ETrue );
       
   349         }
       
   350     else if (aErrorCode == KDataProviderTimeout)
       
   351 		{
       
   352 		IRRDEBUG2("CIRISDSWRAPPER::ISDSERRORL--KDATAPROVIDERTIMEOUT",KNullDesC);
       
   353 		if(iViewObserver)
       
   354 			{
       
   355 			iConnTimeOut= ETrue;
       
   356 			iViewObserver->ErrorL();	
       
   357 
       
   358 			iDiaologLauncher->ShowErrorNoteL(R_IRAPP_ERROR_CONNECTION,ETrue);
       
   359 			}
       
   360 		}
       
   361 		
       
   362 	else
       
   363 		{
       
   364 		IRRDEBUG2("CIRISDSWRAPPER::ISDSERRORL--LASTELSE aErrorCode =%d",aErrorCode);
       
   365 		if(iViewObserver)
       
   366 			{
       
   367 			iViewObserver->ErrorL();
       
   368 			iDiaologLauncher->ShowErrorNoteL(R_IRAPP_ERROR_OPERATION,ETrue);
       
   369 			}
       
   370 		}
       
   371 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsErrorL exiting" );
       
   372     }
       
   373     
       
   374 // ---------------------------------------------------------------------------
       
   375 // MIsdsResponseObserver::IsdsCatogoryDataReceivedL()
       
   376 // Called when catogory information is recieved from ISDS
       
   377 // @param aParsedStructure - contains catogory info
       
   378 // ---------------------------------------------------------------------------
       
   379 //
       
   380 
       
   381 void CIRIsdsWrapper::IsdsCatogoryDataReceivedL(CArrayPtrFlat<CIRBrowseCatagoryItems> 
       
   382 											   & aParsedStructure) 
       
   383 	{
       
   384 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsCatogoryDataReceivedL started." );
       
   385 	iError = EFalse;
       
   386 	iConnTimeOut = EFalse;
       
   387 	iCatBannerTag = EFalse;
       
   388 	DestroyWaitDialogL();
       
   389 
       
   390 	if (iCategoryData)
       
   391 		{
       
   392 		iCategoryData->Reset();
       
   393 		delete iCategoryData;
       
   394 		iCategoryData = NULL;
       
   395 		}
       
   396 	if(iCatBannerUrl) 
       
   397 		delete iCatBannerUrl;
       
   398 	
       
   399 	iCatBannerUrl = NULL;
       
   400 	
       
   401 	if (iCatClickThroughUrl)
       
   402 		delete iCatClickThroughUrl;
       
   403 	
       
   404 	iCatClickThroughUrl = NULL;
       
   405 	//Set the catogory array with categoryname and description
       
   406 	iCategoryData = new (ELeave) CDesCArrayFlat(KCategoryDataMaxLength);
       
   407 	for(TInt i=0;i<aParsedStructure.Count();i++)
       
   408 		{
       
   409 		_LIT(KTabSpace,"\t");
       
   410 			if(aParsedStructure[i]->iCatBannerUrl )		
       
   411 				{
       
   412 				iCatBannerTag = ETrue;
       
   413 				if(aParsedStructure[i]->iCatBannerUrl->Length() !=0)
       
   414 					{
       
   415 					iCatBannerUrl = HBufC::NewL(aParsedStructure[i]->
       
   416 					             iCatBannerUrl->Des().Length());
       
   417 					iCatBannerUrl->Des().Append(aParsedStructure[i]->
       
   418 					                        iCatBannerUrl->Des()); 
       
   419 					}
       
   420 				        
       
   421 				if(aParsedStructure[i]->iCatClickThroughUrl)        
       
   422 					{
       
   423 					if(aParsedStructure[i]->iCatClickThroughUrl->Length() != 0)	
       
   424 						{
       
   425 						iCatClickThroughUrl = HBufC::NewL(aParsedStructure[i]->
       
   426 						                   iCatClickThroughUrl->Des().Length());
       
   427 						iCatClickThroughUrl->Des().Append(aParsedStructure[i]->
       
   428 												iCatClickThroughUrl->Des());
       
   429 						}
       
   430 					}
       
   431 							
       
   432 				} 
       
   433 			if(aParsedStructure[i]->iCatName)
       
   434 				{
       
   435 				HBufC* textResource = HBufC::NewLC(aParsedStructure[i]->iCatName->Des().Length() + KBufSize);
       
   436 				textResource->Des().Append(KTabSpace);
       
   437 				textResource->Des().Append(aParsedStructure[i]->iCatName->Des());
       
   438 				textResource->Des().Append(KTabSpace);
       
   439 
       
   440 				HBufC* expandedText = StringLoader::LoadLC(R_IRAPP_GENRE_STATLIST_TITLE_EXPAND,
       
   441 														   aParsedStructure[i]->iSize);
       
   442 				textResource->Des().Append(*expandedText);												
       
   443 				iCategoryData->AppendL(*textResource);
       
   444 				CleanupStack::PopAndDestroy(expandedText);
       
   445 				CleanupStack::PopAndDestroy(textResource);
       
   446 				}
       
   447 		}
       
   448 		
       
   449 	
       
   450 	iViewObserver->ResponseL();
       
   451 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsCatogoryDataReceivedL exiting" );			
       
   452 	}
       
   453 // ---------------------------------------------------------------------------
       
   454 // MIsdsResponseObserver::IsdsChannelDataReceivedL()
       
   455 // Called when channel information is recieved from ISDS
       
   456 // @param aParsedStructure - contains Channel info
       
   457 // ---------------------------------------------------------------------------
       
   458 //
       
   459 
       
   460 void CIRIsdsWrapper::IsdsChannelDataReceivedL(CArrayPtrFlat<CIRBrowseChannelItems> 
       
   461 											  & aParsedStructure)
       
   462 	{
       
   463 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsChannelDataReceivedL started." );
       
   464 	iError = EFalse;
       
   465 	iConnTimeOut = EFalse;
       
   466 	iChannelBannerTag = EFalse;
       
   467 	iStationsData->Reset();
       
   468 	iChannelImgUrl->Reset();
       
   469     DestroyWaitDialogL();
       
   470 	iChannelIdArray.Reset();
       
   471 
       
   472 	if(iBannerUrl) 
       
   473 	delete iBannerUrl;
       
   474 	iBannerUrl = NULL;
       
   475 
       
   476 	if (iClickThroughUrl)
       
   477 	delete iClickThroughUrl;
       
   478 	iClickThroughUrl = NULL;
       
   479 	
       
   480 	for(TInt i=0;i<aParsedStructure.Count();i++)
       
   481 		{
       
   482 		_LIT(KTabSpace,"\t");
       
   483 		if(aParsedStructure[i]->iBannerUrl )		
       
   484 			{
       
   485 			iChannelBannerTag = ETrue;
       
   486 			if(aParsedStructure[i]->iBannerUrl->Length() != 0)
       
   487 				{
       
   488 				iBannerUrl = HBufC::NewL(aParsedStructure[i]->
       
   489 									iBannerUrl->Des().Length());
       
   490 				iBannerUrl->Des().Append(aParsedStructure[i]->
       
   491 											iBannerUrl->Des()); 
       
   492 				}
       
   493 
       
   494 			if(aParsedStructure[i]->iClickThroughUrl)
       
   495 				{
       
   496 				if(aParsedStructure[i]->iClickThroughUrl->Length() != 0)
       
   497 					{
       
   498 					iClickThroughUrl = HBufC::NewL(aParsedStructure[i]->
       
   499 					iClickThroughUrl->Des().Length());
       
   500 					iClickThroughUrl->Des().Append(aParsedStructure[i]->
       
   501 					iClickThroughUrl->Des());
       
   502 					}
       
   503 				}
       
   504 			} 
       
   505 		
       
   506 		if(aParsedStructure[i]->iChannelName)
       
   507 			{
       
   508 			TInt len = aParsedStructure[i]->iChannelName->Des().Length();
       
   509 			if(aParsedStructure[i]->iShortDescription)
       
   510 				{
       
   511 				len = len + aParsedStructure[i]->iShortDescription->Des().Length();
       
   512 				}
       
   513 			HBufC* textResource = HBufC::NewLC(len + KSize);
       
   514 			textResource->Des().Append(KTabSpace);
       
   515 			textResource->Des().Append(aParsedStructure[i]->iChannelName->Des());
       
   516 			textResource->Des().Append(KTabSpace);
       
   517 			if(aParsedStructure[i]->iShortDescription)
       
   518 			textResource->Des().Append(aParsedStructure[i]->iShortDescription->Des());
       
   519 			iStationsData->AppendL(*textResource);
       
   520 			CleanupStack::PopAndDestroy(textResource);
       
   521 
       
   522 			if(aParsedStructure[i]->iImgUrl.Length())
       
   523 				{
       
   524 				iChannelImgUrl->AppendL(aParsedStructure[i]->iImgUrl);
       
   525 				}
       
   526 			else
       
   527 				{
       
   528 				RBuf urlStatus;
       
   529 				urlStatus.Create(KSize);
       
   530 				urlStatus.Copy(KFalse);
       
   531 				iChannelImgUrl->AppendL(urlStatus);
       
   532 				urlStatus.Close();
       
   533 				}
       
   534 
       
   535 			//the current channel list that is being displayed
       
   536 			//in the stations view
       
   537 			//this array contains all that channel ids 
       
   538 			iChannelIdArray.Append(aParsedStructure[i]->iChannelID);
       
   539 			}
       
   540 
       
   541 		}
       
   542 	iViewObserver->ResponseL();	
       
   543 	
       
   544 	if(iSSearchRequest)	
       
   545 		{
       
   546 		iSSearchRequest = EFalse;
       
   547 		}			
       
   548 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsChannelDataReceivedL exiting" );
       
   549 	}
       
   550 // ---------------------------------------------------------------------------
       
   551 // MIsdsResponseObserver::IsdsPresetDataReceivedL()
       
   552 // Called when preset information is recieved from ISDS
       
   553 // @param aParsedStructure - contains Preset info
       
   554 // ---------------------------------------------------------------------------
       
   555 //
       
   556 void CIRIsdsWrapper::IsdsPresetDataReceivedL(CArrayPtrFlat<CIRIsdsPreset> & aParsedStructure)
       
   557 	{
       
   558 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsPresetDataReceivedL started." );
       
   559 	iError = EFalse;
       
   560 	iConnTimeOut = EFalse;
       
   561 	iListenRequest=EFalse;
       
   562 	CIRIsdsPreset* data = aParsedStructure[0];
       
   563 	data->SetChannelType(1);
       
   564 	DestroyWaitDialogL();
       
   565 	if(iReqAddToFav)
       
   566 		{
       
   567 		TInt err;
       
   568 						
       
   569 		iFavPresets.AddPresetL(*data,err,iReqForLogo);
       
   570 		
       
   571 		iViewObserver->ResponseL(data);
       
   572 		iReqAddToFav=EFalse;
       
   573 		
       
   574 		
       
   575 		//If favourites is full then display an error message
       
   576 		if(err==KErrNoMemory)
       
   577 			{
       
   578 			iDiaologLauncher->ShowErrorNoteL(R_IRAPP_ADDFAVOURITES_ERROR,ETrue);
       
   579 			return;			
       
   580 			}
       
   581 			
       
   582 		else
       
   583 			{
       
   584 			if((err==KErrAlreadyExists )&&
       
   585 			 ( iFavPresets.iFavPresetList.Count() == KPresetsArrayMaxLength) )
       
   586 				{
       
   587 				iDiaologLauncher->ShowErrorNoteL(R_IRAPP_ADDFAVOURITES_ERROR,ETrue);
       
   588 				return;			
       
   589 				}
       
   590 			else
       
   591 				{
       
   592 				RBuf channel;
       
   593 				HBufC* textResource = StringLoader::LoadLC( R_IRAPP_STATIONS_POPUP_SAVED,data->GetName() );//CurrentItemIndex()-1
       
   594 				channel.Create(*textResource);
       
   595 				iDiaologLauncher->ShowConfirmationNoteL( channel,ETrue );
       
   596 				CleanupStack::PopAndDestroy(textResource);
       
   597 				channel.Close();
       
   598 				iIRSettings.SetFlagIfAnyFavL();
       
   599 				return;
       
   600 				}
       
   601 			}
       
   602 		}
       
   603 		
       
   604 	iViewObserver->PresetResponseL(data);
       
   605 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsPresetDataReceivedL exiting" );
       
   606 	}
       
   607 // ---------------------------------------------------------------------------
       
   608 // MIsdsResponseObserver::IsdsIRIDRecieved()
       
   609 // Called to provide IRID
       
   610 // @param aIRID  - contains IRID recived from Isds
       
   611 // ---------------------------------------------------------------------------
       
   612 //
       
   613 void CIRIsdsWrapper::IsdsIRIDRecieved(const TDesC& aIRID)
       
   614 	{
       
   615 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsIRIDRecieved" );
       
   616 	TRAP_IGNORE( iIRSettings.SetIRIDL(aIRID) )
       
   617 	}
       
   618 // ---------------------------------------------------------------------------
       
   619 // MIsdsResponseObserver::IsdsOtaInfoRecieved()
       
   620 // called back when OTA info is recieved and Ui needs to be intimated
       
   621 // @param CIROTAUpdate&,the ota information 
       
   622 // ---------------------------------------------------------------------------
       
   623 //
       
   624 void CIRIsdsWrapper::IsdsOtaInfoRecieved( CIROTAUpdate &/*aOtaData*/)
       
   625 	{
       
   626 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsOtaInfoRecieved" );	
       
   627 	}
       
   628 
       
   629 // ---------------------------------------------------------------------------
       
   630 // MIsdsResponseObserver::IsdsPresetRemovedL()
       
   631 // called back when the preset that is synced was removed from isds
       
   632 // @param TInt,the preset id
       
   633 // ---------------------------------------------------------------------------
       
   634 //
       
   635 void CIRIsdsWrapper::IsdsPresetRemovedL(TInt aId)
       
   636 	{
       
   637 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsPresetRemovedL - Entering" );
       
   638 	iFavPresets.MakePresetUserDefinedL(aId,0);
       
   639 	iSyncPresetObserver->SyncPresetRemovedL(aId);
       
   640 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsPresetRemovedL - Exiting" );
       
   641 	}
       
   642 
       
   643 // ---------------------------------------------------------------------------
       
   644 // MIsdsResponseObserver::IsdsPresetChangedL()
       
   645 // called back when the preset that is synced has been changed in the isds
       
   646 // @param CIRIsdsPreset&,the new preset data
       
   647 // ---------------------------------------------------------------------------
       
   648 //
       
   649 void CIRIsdsWrapper::IsdsPresetChangedL(CIRIsdsPreset& aPreset)
       
   650 	{
       
   651 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsPresetChangedL - Entering" );
       
   652 	iFavPresets.ReplacePresetL(aPreset);
       
   653 	iSyncPresetObserver->SyncPresetChangedL(aPreset);
       
   654 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsPresetChangedL - Exiting" );		
       
   655 	}
       
   656 	
       
   657 // ---------------------------------------------------------------------------
       
   658 // MIsdsResponseObserver::IsdsPresetNoChangeL()
       
   659 // called back when the preset that is synced has not been changed
       
   660 // ---------------------------------------------------------------------------
       
   661 //
       
   662 void CIRIsdsWrapper::IsdsPresetNoChangeL()
       
   663 	{
       
   664 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsPresetNoChangeL - Entering" );
       
   665 	iSyncPresetObserver->SyncPresetNoChangeL();
       
   666 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsPresetNoChangeL - Exiting" );
       
   667 	}
       
   668 	  
       
   669 	  
       
   670 // ---------------------------------------------------------------------------
       
   671 // IsdsPresetRequestL()
       
   672 // called by all the views to get preset data
       
   673 // ---------------------------------------------------------------------------
       
   674 //
       
   675 void CIRIsdsWrapper::IsdsPresetRequestL(MViewsResponseAndErrorObserver* aViewObserver,TInt aIndex,
       
   676 										TInt aCommand,TInt aReqForLogo,TInt aHistoryBool)
       
   677 {
       
   678 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsPresetRequestL started." );
       
   679 	iViewObserver = aViewObserver;	
       
   680 	iListenRequest=EFalse;
       
   681 	CreateWaitDialogL();
       
   682 
       
   683 	if(EAddtoFavouritesCmd == aCommand )
       
   684 	iReqAddToFav=ETrue;
       
   685 	iHistoryBool = aHistoryBool ;
       
   686 	iReqForLogo = aReqForLogo;
       
   687 	if(aHistoryBool)
       
   688 		{
       
   689 		iISDSClient->IRIsdsClientIntefaceL(aIndex,CIRIsdsClient::EChannels,ETrue);
       
   690 		}
       
   691 	else
       
   692 		{
       
   693 		iISDSClient->IRIsdsClientIntefaceL(aIndex,CIRIsdsClient::EChannels);
       
   694 		}
       
   695 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsPresetRequestL exiting" );
       
   696 }
       
   697 
       
   698 // ---------------------------------------------------------------------------
       
   699 // IsdsCancelRequest()
       
   700 // called by all the views to cancel the UI request
       
   701 // ---------------------------------------------------------------------------
       
   702 //
       
   703 
       
   704 void CIRIsdsWrapper::IsdsCancelRequest()
       
   705 {	
       
   706 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsCancelRequest started." );
       
   707 	iISDSClient->IRISDSCancelRequest();
       
   708     IRLOG_DEBUG( "CIRIsdsWrapper::IsdsCancelRequest exiting." );
       
   709 }
       
   710 
       
   711 
       
   712 // ---------------------------------------------------------------------------
       
   713 // IsdsCancelRequest()
       
   714 // called by all the views to cancel the UI request
       
   715 // ---------------------------------------------------------------------------
       
   716 //
       
   717 
       
   718 CDesCArrayFlat* CIRIsdsWrapper::GetStationsData()
       
   719 	{
       
   720 	IRLOG_DEBUG( "CIRIsdsWrapper::GetStationsData" );
       
   721 	return iStationsData;
       
   722 	}
       
   723 
       
   724 // ---------------------------------------------------------------------------
       
   725 // IsdsCancelRequest()
       
   726 // called by all the views to cancel the UI request
       
   727 // ---------------------------------------------------------------------------
       
   728 //
       
   729 
       
   730 void CIRIsdsWrapper::CreateWaitDialogL()
       
   731 	{
       
   732 	IRLOG_DEBUG( "CIRIsdsWrapper::CreateWaitDialogL - Entering" );
       
   733 	iDialogDismissed=EFalse;
       
   734 	RBuf title;
       
   735 	HBufC* titleText;
       
   736 	if(iWaitDialogWhileSearch)
       
   737 		{
       
   738 	 	titleText = StringLoader::LoadLC(R_IRAPP_SEARCHING_PROGRESS);
       
   739 		}
       
   740  	else if(iListenRequest)
       
   741 		{
       
   742 		titleText = StringLoader::LoadLC(R_IRAPP_LOADING_BUFFERING);
       
   743 		}
       
   744 	else 
       
   745 		{
       
   746 	 	titleText = StringLoader::LoadLC(R_IRAPP_LOADING_LOADING);
       
   747 		}
       
   748 	title.CreateL(*titleText );
       
   749 	CleanupStack::PopAndDestroy( titleText );
       
   750 	
       
   751 	if(!iIsdsWaitDialog)	
       
   752 		{
       
   753 		iIsdsWaitDialog =  new ( ELeave ) CAknWaitDialog( NULL,ETrue);
       
   754 		iIsdsWaitDialog->SetCallback(this);
       
   755 		iIsdsWaitDialog->SetTextL(title);
       
   756 		iIsdsWaitDialog->ExecuteLD(R_IRAPP_PROGRESS_DIALOG);
       
   757 		}
       
   758 	title.Close();
       
   759 	IRLOG_DEBUG( "CIRIsdsWrapper::IsdsCancelRequest - exiting." );
       
   760 	}
       
   761 // -----------------------------------------------------------------------------
       
   762 // CIRIsdsWrapper::DialogDismissedL()
       
   763 // Called by CAknwaitdialog 
       
   764 // -----------------------------------------------------------------------------
       
   765 // 
       
   766 void CIRIsdsWrapper::DialogDismissedL( TInt aButtonId )
       
   767 	{
       
   768 	IRLOG_DEBUG( "CIRIsdsWrapper::DialogDismissedL - Entering" );
       
   769 	if(aButtonId == EIRCancel)
       
   770 		{
       
   771 		iIsdsWaitDialog= NULL;
       
   772 		iDialogDismissed=ETrue;
       
   773 		iReqAddToFav=EFalse;
       
   774 		iViewObserver->ErrorL();
       
   775 		iDialogDismissed=EFalse;
       
   776 		IsdsCancelRequest();
       
   777 		}
       
   778 	IRLOG_DEBUG( "CIRIsdsWrapper::DialogDismissedL - Exiting" );
       
   779 	}    
       
   780 // -----------------------------------------------------------------------------
       
   781 // CIRIsdsWrapper::GetBannerUrl()
       
   782 // Returns the BannerUrl
       
   783 // -----------------------------------------------------------------------------
       
   784 // 
       
   785 HBufC* CIRIsdsWrapper::GetBannerUrl()
       
   786 {	
       
   787 IRLOG_DEBUG( "CIRIsdsWrapper::GetBannerUrl - Entering" );
       
   788 IRLOG_DEBUG( "CIRIsdsWrapper::GetBannerUrl - Exiting" );
       
   789 	if(iBannerUrl)
       
   790 	{
       
   791 		return iBannerUrl;
       
   792 	}
       
   793 	else
       
   794 	{
       
   795 		return NULL;
       
   796 	}
       
   797 }
       
   798 
       
   799 // ---------------------------------------------------------------------------
       
   800 // DestroyWaitDialogL()
       
   801 // Destroys The WaitDialog
       
   802 // ---------------------------------------------------------------------------
       
   803 //
       
   804 
       
   805 void CIRIsdsWrapper::DestroyWaitDialogL()
       
   806 	{
       
   807 	
       
   808 	IRLOG_DEBUG( "CIRIsdsWrapper::DestroyWaitDialogL - Entering" );
       
   809 
       
   810 		if(iIsdsWaitDialog)
       
   811 		{
       
   812 		iIsdsWaitDialog->ProcessFinishedL();
       
   813 		iIsdsWaitDialog=NULL;
       
   814 		}
       
   815 	
       
   816 	IRLOG_DEBUG( "CIRIsdsWrapper::DestroyWaitDialogL - exiting." );
       
   817 	}
       
   818 	
       
   819 // ---------------------------------------------------------------------------
       
   820 // SetCurrentPlayingIndex()
       
   821 // Sets the Current Playing Index
       
   822 // ---------------------------------------------------------------------------
       
   823 //
       
   824 
       
   825 void CIRIsdsWrapper::SetCurrentPlayingIndex(TBool aCurrentPlayingIndex  )
       
   826 	{
       
   827 	
       
   828 	IRLOG_DEBUG( "CIRIsdsWrapper::SetCurrentPlayingIndex - Entering" );
       
   829 	iCurrentPlayingIndex=aCurrentPlayingIndex;
       
   830 	IRLOG_DEBUG( "CIRIsdsWrapper::SetCurrentPlayingIndex - exiting" );
       
   831 	}
       
   832 // ---------------------------------------------------------------------------
       
   833 // GetCurrentPlayingIndex()
       
   834 // Returns The current Playing Index
       
   835 // ---------------------------------------------------------------------------
       
   836 //
       
   837 
       
   838 TBool CIRIsdsWrapper::GetCurrentPlayingIndex( )
       
   839 	{
       
   840 	
       
   841 	IRLOG_DEBUG( "CIRIsdsWrapper::GetCurrentPlayingIndex - Entering" );
       
   842 	IRLOG_DEBUG( "CIRIsdsWrapper::GetCurrentPlayingIndex - exiting" );
       
   843 	return iCurrentPlayingIndex;
       
   844 	}
       
   845 
       
   846 
       
   847 // ---------------------------------------------------------------------------
       
   848 // SetListenRequest()
       
   849 // Sets The ListenRequest if Listen is Done
       
   850 // ---------------------------------------------------------------------------
       
   851 //
       
   852 
       
   853 void CIRIsdsWrapper::SetListenRequest(TBool aListenRequest)
       
   854 	{
       
   855 	
       
   856 	IRLOG_DEBUG( "CIRIsdsWrapper::SetListenRequest - Entering" );
       
   857 	iListenRequest=aListenRequest;
       
   858 	IRLOG_DEBUG( "CIRIsdsWrapper::SetListenRequest - exiting" );
       
   859 	}
       
   860 
       
   861 // ---------------------------------------------------------------------------
       
   862 // GetListenRequest()
       
   863 // Returns the Listen Request Value
       
   864 // ---------------------------------------------------------------------------
       
   865 //
       
   866 
       
   867 TBool CIRIsdsWrapper::GetListenRequest( )
       
   868 	{
       
   869 	
       
   870 	IRLOG_DEBUG( "CIRIsdsWrapper::GetListenRequest - Entering" );
       
   871 	IRLOG_DEBUG( "CIRIsdsWrapper::GetListenRequest - exiting" );
       
   872 	return iListenRequest;
       
   873 	}
       
   874 // ---------------------------------------------------------------------------
       
   875 // ActiveWaitDialog( )
       
   876 // Returns Whether the Isds WaitDialog is Active or Not
       
   877 // ---------------------------------------------------------------------------
       
   878 //
       
   879 
       
   880 TBool CIRIsdsWrapper::ActiveWaitDialog( )
       
   881 	{
       
   882 	
       
   883 	IRLOG_DEBUG( "CIRIsdsWrapper::ActiveWaitDialog- Entering" );
       
   884 	IRLOG_DEBUG( "CIRIsdsWrapper::ActiveWaitDialog- exiting" );
       
   885 	if(iIsdsWaitDialog)
       
   886 		{
       
   887 		return ETrue;
       
   888 		}
       
   889 	else
       
   890 		{
       
   891 		return EFalse;
       
   892 		}
       
   893 	}
       
   894 
       
   895 // ---------------------------------------------------------------------------
       
   896 // CIRIsdsWrapper::SetSyncPresetObserver()
       
   897 // Notifies the sync preset call back to the observer
       
   898 // @param MSyncPresetObserver, observer for the preset synchronization
       
   899 // ---------------------------------------------------------------------------
       
   900 //
       
   901 void CIRIsdsWrapper::SetSyncPresetObserver(MSyncPresetObserver* aSyncPresetObserver)
       
   902 	{
       
   903 	IRLOG_DEBUG("CIRIsdsWrapper::SetSyncPresetObserver - Entering");
       
   904 	iSyncPresetObserver = aSyncPresetObserver;
       
   905 	IRLOG_DEBUG("CIRIsdsWrapper::SetSyncPresetObserver -- Exiting");
       
   906 	}
       
   907 	
       
   908 
       
   909 void CIRIsdsWrapper::SetSyncPresetObserver(MSyncPresetObserver* aSyncPresetObserver,
       
   910 									MViewsResponseAndErrorObserver* aViewObserver)
       
   911 	{
       
   912 	IRLOG_DEBUG("CIRIsdsWrapper::SetSyncPresetObserver 2 - Entering");
       
   913 	iViewObserver = aViewObserver;
       
   914 	SetSyncPresetObserver(aSyncPresetObserver);
       
   915 	IRLOG_DEBUG("CIRIsdsWrapper::SetSyncPresetObserver 2 - Exiting");
       
   916 	}
       
   917 	
       
   918 
       
   919 // ---------------------------------------------------------------------------
       
   920 // CIRIsdsWrapper::GetErrorCode()
       
   921 // Getting the errorcode
       
   922 // ---------------------------------------------------------------------------
       
   923 //
       
   924 TInt CIRIsdsWrapper::GetErrorCode()
       
   925 	{
       
   926 	return iKNotFound ;	
       
   927 	}
       
   928 	
       
   929 // ------------------------------------------------------------------------------
       
   930 // CIRIsdsWrapper::SetSyncReqFromMainview()
       
   931 // called before the syncrequest is made form MAINVIEW
       
   932 // once the reponse receives saying "preset removed",
       
   933 // error note "item no longer available" should not be displayed
       
   934 // @param aValue, to know whether the syncrequest is made form mainview or not
       
   935 // ------------------------------------------------------------------------------
       
   936 void CIRIsdsWrapper::SetSyncReqFromMainView(TBool aValue)
       
   937 	{
       
   938 	iSyncReqFromMainView = aValue;		
       
   939 	}
       
   940 
       
   941 
       
   942