application/src/PodcastQueueView.cpp
changeset 2 29cda98b007e
child 4 be243543a361
equal deleted inserted replaced
1:5f8e5adbbed9 2:29cda98b007e
       
     1 /*
       
     2 * Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB
       
     3 *
       
     4 * All rights reserved.
       
     5 * This component and the accompanying materials are made available
       
     6 * under the terms of the License "Eclipse Public License v1.0"
       
     7 * which accompanies this distribution, and is available
       
     8 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     9 *
       
    10 * Initial Contributors:
       
    11 * EmbedDev AB - initial contribution.
       
    12 *
       
    13 * Contributors:
       
    14 *
       
    15 * Description:
       
    16 *
       
    17 */
       
    18 
       
    19 #include "PodcastQueueView.h"
       
    20 #include "PodcastAppUi.h"
       
    21 #include "ShowEngine.h"
       
    22 #include "SettingsEngine.h"
       
    23 #include "PodcastApp.h"
       
    24 #include "Constants.h"
       
    25 #include "imagehandler.h"
       
    26 #include "PodcastShowsView.h"
       
    27 
       
    28 #include <akntitle.h>
       
    29 #include <podcast.rsg>
       
    30 #include <podcast.mbg>
       
    31 #include <gulicon.h>
       
    32 #include <barsread.h>
       
    33 #include <aknnotedialog.h>
       
    34 #include <aknmessagequerydialog.h>
       
    35 #include "Podcast.hrh"
       
    36 
       
    37 #define KMaxMessageLength 200
       
    38 
       
    39 #define KPodcastImageWidth 160
       
    40 #define KPodcastImageHeight 120
       
    41 #define KPodcastDialogOffset 2
       
    42 
       
    43 #define KOneHundredPercent 100
       
    44 
       
    45 const TInt KSizeBufLen = 64;
       
    46 const TInt KDefaultGran = 5;
       
    47 _LIT(KSizeDownloadingOf, "%.1f/%.1f MB");
       
    48 _LIT(KShowsSizeFormatS60, "%.1f MB");
       
    49 
       
    50 _LIT(KShowFormat, "%d\t%S\t%S %S\t");
       
    51 _LIT(KShowErrorFormat, "%d\t%S\t%S\t");
       
    52 _LIT(KShowQueueFormat, "%d\t%S\t%S%S\t");
       
    53 
       
    54 
       
    55 // these must correspond with TShowsIconIndex
       
    56 
       
    57 const TUint KShowIconArrayIds[] =
       
    58 	{
       
    59 			EMbmPodcastAudio,
       
    60 			EMbmPodcastAudio_mask,
       
    61 			EMbmPodcastAudio_new,
       
    62 			EMbmPodcastAudio_new_mask,
       
    63 			EMbmPodcastAudio_queued,
       
    64 			EMbmPodcastAudio_queued_mask,
       
    65 			EMbmPodcastAudio_downloading,
       
    66 			EMbmPodcastAudio_downloading_mask,
       
    67 			EMbmPodcastAudio_downloaded,
       
    68 			EMbmPodcastAudio_downloaded_mask,
       
    69 			EMbmPodcastAudio_downloaded_new,
       
    70 			EMbmPodcastAudio_downloaded_new_mask,
       
    71 			EMbmPodcastAudio_failed,
       
    72 			EMbmPodcastAudio_failed_mask,
       
    73 			EMbmPodcastAudio_suspended,
       
    74 			EMbmPodcastAudio_suspended_mask,
       
    75 			0,
       
    76 			0
       
    77 	};
       
    78 
       
    79 CPodcastQueueView* CPodcastQueueView::NewL(CPodcastModel& aPodcastModel)
       
    80 	{
       
    81 	CPodcastQueueView* self = CPodcastQueueView::NewLC(aPodcastModel);
       
    82 	CleanupStack::Pop(self);
       
    83 	return self;
       
    84 	}
       
    85 
       
    86 CPodcastQueueView* CPodcastQueueView::NewLC(CPodcastModel& aPodcastModel)
       
    87 	{
       
    88 	CPodcastQueueView* self = new ( ELeave ) CPodcastQueueView(aPodcastModel);
       
    89 	CleanupStack::PushL(self);
       
    90 	self->ConstructL();
       
    91 	return self;
       
    92 	}
       
    93 
       
    94 CPodcastQueueView::CPodcastQueueView(CPodcastModel& aPodcastModel) :
       
    95 	iPodcastModel(aPodcastModel)
       
    96 	{
       
    97 	}
       
    98 
       
    99 void CPodcastQueueView::ConstructL()
       
   100 	{
       
   101 	BaseConstructL(R_PODCAST_QUEUEVIEW);
       
   102 	CPodcastListView::ConstructL();
       
   103 	CArrayPtr< CGulIcon>* icons = new(ELeave) CArrayPtrFlat< CGulIcon>(1);
       
   104 	CleanupStack::PushL(icons);
       
   105 	TInt pos = 0;
       
   106 	while (KShowIconArrayIds[pos] > 0)
       
   107 		{
       
   108 		// Load the bitmap for play icon	
       
   109 		CFbsBitmap* bitmap= NULL;//iEikonEnv->CreateBitmapL( _L("*"), KIconArrayIds[pos]);
       
   110 		CFbsBitmap* mask=  NULL;////iEikonEnv->CreateBitmapL( _L("*"), KIconArrayIds[pos+1] );
       
   111 		AknIconUtils::CreateIconL(bitmap,
       
   112 					                          mask,
       
   113 					                          iEikonEnv->EikAppUi()->Application()->BitmapStoreName(),
       
   114 					                          KShowIconArrayIds[pos],
       
   115 					                          KShowIconArrayIds[pos+1]);	
       
   116 		CleanupStack::PushL(bitmap);
       
   117 		// Load the mask for play icon			
       
   118 		CleanupStack::PushL(mask);
       
   119 		// Append the play icon to icon array
       
   120 		icons->AppendL(CGulIcon::NewL(bitmap, mask) );
       
   121 		CleanupStack::Pop(2); // bitmap, mask
       
   122 		pos+=2;
       
   123 		}
       
   124 	iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
       
   125 	CleanupStack::Pop(icons); // icons
       
   126 	iListContainer->Listbox()->SetListBoxObserver(this);
       
   127 	
       
   128 	iPodcastModel.FeedEngine().AddObserver(this);
       
   129 	iPodcastModel.ShowEngine().AddObserver(this);
       
   130 	
       
   131 	iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint(0,0));
       
   132 	TResourceReader reader;
       
   133 	iCoeEnv->CreateResourceReaderLC(reader,R_QUEUEVIEW_POPUP_MENU);
       
   134 	iStylusPopupMenu->ConstructFromResourceL(reader);
       
   135 	CleanupStack::PopAndDestroy();
       
   136 	SetEmptyTextL(R_PODCAST_EMPTY_QUEUE);
       
   137 	}
       
   138 
       
   139 TKeyResponse CPodcastQueueView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   140 	{
       
   141 	if (aType == EEventKey)
       
   142 		{
       
   143 		CShowInfo *activeShow = NULL;
       
   144 
       
   145 		TInt index = iListContainer->Listbox()->CurrentItemIndex();
       
   146 		if(index >= 0 && index < iPodcastModel.ActiveShowList().Count())
       
   147 		{
       
   148 			activeShow = iPodcastModel.ActiveShowList()[index];
       
   149 		}
       
   150 		
       
   151 		if (activeShow != NULL) {
       
   152 			DP1("aKeyEvent.iCode=%d", aKeyEvent.iCode);
       
   153 			switch (aKeyEvent.iCode) {
       
   154 			case 117: 
       
   155 			case '*':
       
   156 			case EKeySpace:
       
   157 				if (activeShow->PlayState() == EPlayed) {
       
   158 					HandleCommandL(EPodcastMarkAsUnplayed);
       
   159 				} else {
       
   160 					HandleCommandL(EPodcastMarkAsPlayed);
       
   161 				}
       
   162 				break;
       
   163 			case 106:
       
   164 			case '#':
       
   165 				if (activeShow->DownloadState() == ENotDownloaded) {
       
   166 					HandleCommandL(EPodcastDownloadShow);
       
   167 				}
       
   168 				break;
       
   169 			case EKeyBackspace:
       
   170 			case EKeyDelete:
       
   171 				HandleCommandL(EPodcastRemoveDownload);
       
   172 				break;
       
   173 			default:
       
   174 				break;
       
   175 			}
       
   176 			UpdateToolbar();
       
   177 		}
       
   178 	}
       
   179 		return CPodcastListView::OfferKeyEventL(aKeyEvent, aType);
       
   180 	}
       
   181 
       
   182 CPodcastQueueView::~CPodcastQueueView()
       
   183 	{
       
   184 	iPodcastModel.ShowEngine().RemoveObserver(this);
       
   185 	iPodcastModel.FeedEngine().RemoveObserver(this);
       
   186 	
       
   187     if(iStylusPopupMenu)
       
   188         delete iStylusPopupMenu, iStylusPopupMenu = NULL;
       
   189 	}
       
   190 
       
   191 
       
   192 TUid CPodcastQueueView::Id() const
       
   193 	{
       
   194 	return KUidPodcastQueueViewID;
       
   195 	}
       
   196 
       
   197 void CPodcastQueueView::DoActivateL(const TVwsViewId& aPrevViewId,
       
   198 		TUid aCustomMessageId, const TDesC8& aCustomMessage)
       
   199 	{
       
   200 	DP("CPodcastQueueView::DoActivateL BEGIN");
       
   201 	
       
   202 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
       
   203 	iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID);
       
   204 	
       
   205 	UpdateFeedUpdateStateL();
       
   206 	UpdateToolbar();
       
   207 	DP("CPodcastQueueView::DoActivateL END");
       
   208 	}
       
   209 
       
   210 void CPodcastQueueView::DoDeactivate()
       
   211 	{
       
   212 	CPodcastListView::DoDeactivate();
       
   213 	}
       
   214 
       
   215 // Engine callback when new shows are available
       
   216 void CPodcastQueueView::ShowListUpdatedL()
       
   217 	{
       
   218 	UpdateListboxItemsL();
       
   219 	}
       
   220 
       
   221 void CPodcastQueueView::ShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt /*aBytesTotal*/)
       
   222 	{
       
   223 	if (!iListContainer->IsVisible())
       
   224 		{
       
   225 		return;
       
   226 		}
       
   227 		
       
   228 	CShowInfo *info = iPodcastModel.ShowEngine().ShowDownloading();
       
   229 	if (info) 
       
   230 		{
       
   231 		UpdateShowItemL(info->Uid(), aBytesOfCurrentDownload);
       
   232 		}
       
   233 	}
       
   234 
       
   235 void CPodcastQueueView::ShowDownloadFinishedL(TUint /*aShowUid*/, TInt aError)
       
   236 	{
       
   237 	iProgressAdded = EFalse;
       
   238 
       
   239 	iPodcastModel.GetShowsDownloading();
       
   240 	UpdateListboxItemsL();
       
   241 	UpdateToolbar();
       
   242 	
       
   243 	switch(aError)
       
   244 		{
       
   245 		case KErrCouldNotConnect:
       
   246 			{
       
   247 			TBuf<KMaxMessageLength> message;
       
   248 			iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
       
   249 			ShowErrorMessage(message);
       
   250 			}
       
   251 			break;
       
   252 		default: // Do nothing
       
   253 			break;
       
   254 		}
       
   255 	}
       
   256 
       
   257 
       
   258 void CPodcastQueueView::FeedDownloadStartedL(TFeedState /*aState*/, TUint aFeedUid)
       
   259 	{
       
   260 	// TODO make use of the fact that we know that the feed download is
       
   261 	// started instead of checking feed engine states in UpdateFeedUpdateStateL.
       
   262 	if (iPodcastModel.ActiveFeedInfo() != NULL
       
   263 			&& iPodcastModel.ActiveFeedInfo()->Uid() == aFeedUid)
       
   264 		{
       
   265 		TRAP_IGNORE(UpdateFeedUpdateStateL());
       
   266 		UpdateToolbar();
       
   267 		}	
       
   268 	}
       
   269 
       
   270 void CPodcastQueueView::FeedDownloadFinishedL(TFeedState /*aState*/, TUint aFeedUid, TInt /*aError*/)
       
   271 	{
       
   272 	DP("CPodcastQueueView::FeedDownloadFinishedL BEGIN");
       
   273 	// TODO make use of the fact that we know that the feed download is
       
   274 	// finished instead of checking feed engine states in UpdateFeedUpdateStateL.
       
   275 	if (iPodcastModel.ActiveFeedInfo() != NULL
       
   276 			&& iPodcastModel.ActiveFeedInfo()->Uid() == aFeedUid)
       
   277 		{
       
   278 		TRAP_IGNORE(UpdateFeedUpdateStateL());
       
   279 		}
       
   280 	DP("CPodcastQueueView::FeedDownloadFinishedL END");
       
   281 	}
       
   282 
       
   283 void CPodcastQueueView::HandleListBoxEventL(CEikListBox* /*aListBox*/,
       
   284 		TListBoxEvent aEventType)
       
   285 	{
       
   286 	switch (aEventType)
       
   287 		{
       
   288 		case EEventEnterKeyPressed:		
       
   289 		case EEventItemActioned:
       
   290 		case EEventItemDoubleClicked:
       
   291 			break;
       
   292 		default:
       
   293 			break;
       
   294 		}
       
   295 		UpdateToolbar();
       
   296 	}
       
   297 
       
   298 void CPodcastQueueView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex)
       
   299 	{
       
   300 	TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended();
       
   301 	TUint showDownloadingUid = iPodcastModel.ShowEngine().ShowDownloading() ? iPodcastModel.ShowEngine().ShowDownloading()->Uid() : 0;
       
   302 	
       
   303 	if (showDownloadingUid == aShowInfo->Uid())
       
   304 		{
       
   305 		aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon;		
       
   306 		}
       
   307 	else
       
   308 		{
       
   309 		switch (aShowInfo->DownloadState())
       
   310 			{
       
   311 			case EQueued:
       
   312 				aIconIndex = dlStop ? ESuspendedShowIcon : EQuedShowIcon;
       
   313 				break;
       
   314 			case EDownloading:
       
   315 				aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon;		
       
   316 				break;
       
   317 			case EFailedDownload:
       
   318 				aIconIndex = EFailedShowIcon;
       
   319 				break;
       
   320 			default:
       
   321 				DP("Wrong download state for queue view!");
       
   322 				break;
       
   323 			}
       
   324 		}
       
   325 	}
       
   326 
       
   327 void CPodcastQueueView::UpdateFeedUpdateStateL()
       
   328 	{
       
   329 	TBool listboxDimmed = EFalse;
       
   330 
       
   331 	if (iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.ActiveFeedInfo()
       
   332 			!= NULL && iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid())
       
   333 		{
       
   334 		listboxDimmed = ETrue;
       
   335 		}
       
   336 
       
   337 	if ((iListContainer->Listbox()->IsDimmed() && !listboxDimmed) || (!iListContainer->Listbox()->IsDimmed() && listboxDimmed))
       
   338 		{
       
   339 		iListContainer->Listbox()->SetDimmed(listboxDimmed);
       
   340 		}
       
   341 	UpdateListboxItemsL();
       
   342 	UpdateToolbar();
       
   343 	}
       
   344 
       
   345 void CPodcastQueueView::FormatShowInfoListBoxItemL(CShowInfo& aShowInfo, TInt aSizeDownloaded)
       
   346 	{
       
   347 	TBuf<32> infoSize;
       
   348 	TInt iconIndex = 0;	
       
   349 	TBuf<KMaxShortDateFormatSpec*2> showDate;
       
   350 	GetShowIcons(&aShowInfo, iconIndex);	
       
   351 	
       
   352 	if(aSizeDownloaded > 0)
       
   353 		{
       
   354 		if (aShowInfo.ShowSize() > 0)
       
   355 			{
       
   356 				infoSize.Format(KSizeDownloadingOf(), ((float) aSizeDownloaded / (float) KSizeMb),
       
   357 						((float)aShowInfo.ShowSize() / (float)KSizeMb));
       
   358 			}
       
   359 		else
       
   360 			{
       
   361 			infoSize.Format(KShowsSizeFormatS60(), (float)aSizeDownloaded / (float)KSizeMb);
       
   362 			}
       
   363 		}
       
   364 	else if (aShowInfo.ShowSize() > 0)
       
   365 		{
       
   366 		infoSize.Format(KShowsSizeFormatS60(), (float)aShowInfo.ShowSize() / (float)KSizeMb);
       
   367 		} 
       
   368 	else {
       
   369 		infoSize = KNullDesC();	
       
   370 	}
       
   371 
       
   372 	if (aShowInfo.PubDate().Int64() == 0)
       
   373 		{
       
   374 		showDate = KNullDesC();
       
   375 		}
       
   376 	else
       
   377 		{
       
   378 		aShowInfo.PubDate().FormatL(showDate, KDateFormatShort());
       
   379 		}
       
   380 
       
   381 	if(aShowInfo.LastError() != KErrNone)
       
   382 		{
       
   383 		TBuf<KSizeBufLen> errorBuffer;
       
   384 		iEikonEnv->GetErrorText(errorBuffer, aShowInfo.LastError());
       
   385 		iListboxFormatbuffer.Format(KShowErrorFormat(), iconIndex, &aShowInfo.Title(), &errorBuffer);
       
   386 		}
       
   387 	else	
       
   388 		{
       
   389 		if (infoSize.Length() > 0) {
       
   390 			infoSize.Insert(0,_L(", "));
       
   391 		}
       
   392 		
       
   393 		iListboxFormatbuffer.Format(KShowQueueFormat(), iconIndex, &aShowInfo.Title(), &showDate, &infoSize);
       
   394 		}
       
   395 	}
       
   396 
       
   397 void CPodcastQueueView::UpdateShowItemDataL(CShowInfo* aShowInfo,TInt aIndex, TInt aSizeDownloaded)
       
   398 {
       
   399 	FormatShowInfoListBoxItemL(*aShowInfo, aSizeDownloaded);
       
   400 	iItemArray->Delete(aIndex);
       
   401 	if(aIndex>= iItemArray->MdcaCount())
       
   402 		{
       
   403 		iItemArray->AppendL(iListboxFormatbuffer);
       
   404 		}
       
   405 	else
       
   406 		{
       
   407 		iItemArray->InsertL(aIndex, iListboxFormatbuffer);
       
   408 		}
       
   409 }
       
   410 
       
   411 void CPodcastQueueView::UpdateShowItemL(TUint aUid, TInt aSizeDownloaded)
       
   412 {
       
   413 	RShowInfoArray& array = iPodcastModel.ActiveShowList();
       
   414 	
       
   415 	for (int i=0;i<array.Count();i++) {
       
   416 		if (array[i]->Uid() == aUid) {
       
   417 			UpdateShowItemDataL(array[i], i, aSizeDownloaded);
       
   418 			if (iListContainer->Listbox()->TopItemIndex() <= i &&
       
   419 				iListContainer->Listbox()->BottomItemIndex() >= i) {
       
   420 					iListContainer->Listbox()->DrawItem(i);
       
   421 			}
       
   422 		}
       
   423 	}
       
   424 }
       
   425 
       
   426 void CPodcastQueueView::UpdateListboxItemsL()
       
   427 	{
       
   428 	if (iListContainer->IsVisible())
       
   429 		{
       
   430 		TListItemProperties itemProps;
       
   431 		TInt len = 0;
       
   432 
       
   433 		iPodcastModel.GetShowsDownloading();
       
   434 	
       
   435 		RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
       
   436 		len = fItems.Count();
       
   437 
       
   438 		if (iListContainer->Listbox() != NULL)
       
   439 			{
       
   440 			TBool allUidsMatch = EFalse;
       
   441 
       
   442 			if (len == iListContainer->Listbox()->Model()->NumberOfItems())
       
   443 				{
       
   444 				allUidsMatch = ETrue;
       
   445 				TUint itemId = 0;
       
   446 				for (TInt loop = 0; loop< len; loop++)
       
   447 					{
       
   448 					itemId = iItemIdArray[loop];
       
   449 					if (fItems[loop]->Uid() != itemId)
       
   450 						{
       
   451 						allUidsMatch = EFalse;
       
   452 						break;
       
   453 						}
       
   454 					}
       
   455 				}
       
   456 
       
   457 			if (allUidsMatch && len > 0)
       
   458 				{
       
   459 				for (TInt loop = 0; loop< len; loop++)
       
   460 					{					
       
   461 					UpdateShowItemDataL(fItems[loop], loop);	
       
   462 					iListContainer->Listbox()->DrawItem(loop);
       
   463 					}
       
   464 				}
       
   465 			else
       
   466 				{
       
   467 				iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL();
       
   468 				iListContainer->Listbox()->Reset();
       
   469 				iItemIdArray.Reset();
       
   470 				iItemArray->Reset();
       
   471 
       
   472 				if (len > 0)
       
   473 					{
       
   474 					for (TInt i=0; i<len; i++)
       
   475 						{
       
   476 						CShowInfo *si = fItems[i];
       
   477 						FormatShowInfoListBoxItemL(*si);
       
   478 						iItemIdArray.Append(si->Uid());						
       
   479 						iItemArray->AppendL(iListboxFormatbuffer);
       
   480 						}
       
   481 					}
       
   482 				else
       
   483 					{
       
   484 					iItemArray->Reset();
       
   485 					iItemIdArray.Reset();
       
   486 					
       
   487 					itemProps.SetDimmed(ETrue);
       
   488 					itemProps.SetHiddenSelection(ETrue);
       
   489 					}
       
   490 				iListContainer->Listbox()->HandleItemAdditionL();
       
   491 				}				
       
   492 			}
       
   493 		}
       
   494 	}
       
   495 
       
   496 /** 
       
   497  * Command handling function intended for overriding by sub classes. 
       
   498  * Default implementation is empty.  
       
   499  * @param aCommand ID of the command to respond to. 
       
   500  */
       
   501 void CPodcastQueueView::HandleCommandL(TInt aCommand)
       
   502 	{
       
   503 	switch (aCommand)
       
   504 		{
       
   505 		case EPodcastRemoveAllDownloads:
       
   506 			{
       
   507 			TBuf<KMaxMessageLength> msg;
       
   508 			iEikonEnv->ReadResourceL(msg, R_CLEAR_QUERY);
       
   509 												
       
   510 			if(ShowQueryMessage(msg))
       
   511 				{
       
   512 				iPodcastModel.ShowEngine().RemoveAllDownloads();
       
   513 				UpdateListboxItemsL();
       
   514 				}
       
   515 			}
       
   516 			break;
       
   517 		case EPodcastRemoveDownload:
       
   518 			{
       
   519 			TInt index = iListContainer->Listbox()->CurrentItemIndex();
       
   520 			if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
       
   521 				{
       
   522 				if (iPodcastModel.ShowEngine().RemoveDownloadL(iPodcastModel.ActiveShowList()[index]->Uid()))
       
   523 					{
       
   524 						iItemArray->Delete(index);
       
   525 						iItemIdArray.Remove(index);						
       
   526 						iListContainer->Listbox()->HandleItemRemovalL();
       
   527 						iListContainer->Listbox()->SetCurrentItemIndex(index - 1 > 0 ? index - 1 : 0);
       
   528 						iListContainer->Listbox()->DrawNow();
       
   529 						
       
   530 						delete iPodcastModel.ActiveShowList()[index];
       
   531 						iPodcastModel.ActiveShowList().Remove(index);
       
   532 					}
       
   533 				}
       
   534 			}
       
   535 			break;
       
   536 		case EPodcastSuspendDownloads:
       
   537 			{
       
   538 			iPodcastModel.ShowEngine().SuspendDownloads();
       
   539 			UpdateListboxItemsL();
       
   540 			}
       
   541 			break;
       
   542 		case EPodcastResumeDownloads:
       
   543 			{
       
   544 			iPodcastModel.ShowEngine().ResumeDownloadsL();
       
   545 			UpdateListboxItemsL();
       
   546 			}
       
   547 			break;
       
   548 		default:
       
   549 			CPodcastListView::HandleCommandL(aCommand);
       
   550 			break;
       
   551 		}
       
   552 	UpdateToolbar();
       
   553 	}
       
   554 	
       
   555 void CPodcastQueueView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
   556 {
       
   557 	if(aResourceId == R_PODCAST_SHOWSVIEW_MENU)
       
   558 		{
       
   559 		aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, ETrue);
       
   560 		}
       
   561 }
       
   562 
       
   563 void CPodcastQueueView::UpdateToolbar()
       
   564 {
       
   565 	CAknToolbar* toolbar = Toolbar();
       
   566 	
       
   567 	RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
       
   568 	TInt itemCnt = fItems.Count();
       
   569 	
       
   570 	toolbar->HideItem(EPodcastRemoveDownload, EFalse, ETrue);
       
   571 	toolbar->HideItem(EPodcastRemoveAllDownloads, EFalse, ETrue);
       
   572 	toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue);
       
   573 	toolbar->SetItemDimmed(EPodcastRemoveAllDownloads, itemCnt == 0, ETrue);
       
   574 	toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);
       
   575 	toolbar->HideItem(EPodcastResumeDownloads,!iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);	
       
   576 }
       
   577 
       
   578 void CPodcastQueueView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
       
   579 {
       
   580 	DP("CPodcastQueueView::HandleLongTapEventL BEGIN");
       
   581 	
       
   582     if(iStylusPopupMenu)
       
   583     {
       
   584 		iStylusPopupMenu->ShowMenu();
       
   585 		iStylusPopupMenu->SetPosition(aPenEventLocation);
       
   586     }
       
   587 	DP("CPodcastQueueView::HandleLongTapEventL END");
       
   588 }
       
   589 
       
   590 void CPodcastQueueView::DownloadQueueUpdatedL(TInt /*aDownloadingShows*/, TInt /*aQueuedShows*/)
       
   591 	{
       
   592 	}
       
   593 
       
   594 void CPodcastQueueView::FeedUpdateAllCompleteL(TFeedState /*aState*/)
       
   595 	{
       
   596 	UpdateListboxItemsL();
       
   597 	UpdateToolbar();
       
   598 	}