application/src/PodcastFeedView.cpp
branch3rded
changeset 390 d7abecc9d189
parent 343 9c56bf585696
equal deleted inserted replaced
345:702ba9ffe210 390:d7abecc9d189
   111 	DP("CPodcastFeedView::ConstructL END");
   111 	DP("CPodcastFeedView::ConstructL END");
   112 	}
   112 	}
   113     
   113     
   114 CPodcastFeedView::~CPodcastFeedView()
   114 CPodcastFeedView::~CPodcastFeedView()
   115     {
   115     {
       
   116 	DP("CPodcastFeedView::~CPodcastFeedView BEGIN");
   116 	iPodcastModel.FeedEngine().RemoveObserver(this);
   117 	iPodcastModel.FeedEngine().RemoveObserver(this);
   117 	delete iFeedsFormat;
   118 	delete iFeedsFormat;
   118 	delete iNeverUpdated;
   119 	delete iNeverUpdated;
   119 	delete iUpdater;
   120 	delete iUpdater;
   120 	iFeedIdForIconArray.Close();
   121 	iFeedIdForIconArray.Close();
       
   122 	DP("CPodcastFeedView::~CPodcastFeedView END");
   121     }
   123     }
   122 
   124 
   123 void CPodcastFeedView::UpdateItemL(TInt aIndex)
   125 void CPodcastFeedView::UpdateItemL(TInt aIndex)
   124 	{
   126 	{
   125 	__ASSERT_DEBUG(iListContainer->IsVisible(), Panic(EPodcatcherPanicFeedView));
   127 	__ASSERT_DEBUG(iListContainer->IsVisible(), Panic(EPodcatcherPanicFeedView));
   130 
   132 
   131 	// Update UID of for the feed at aIndex
   133 	// Update UID of for the feed at aIndex
   132 	iItemIdArray[aIndex] = sortedItems[aIndex]->Uid();
   134 	iItemIdArray[aIndex] = sortedItems[aIndex]->Uid();
   133 	
   135 	
   134 	// Prepare data to update the listbox item with
   136 	// Prepare data to update the listbox item with
   135 	FormatFeedInfoListBoxItemL(*sortedItems[aIndex], EFalse);
   137 	FormatFeedInfoListBoxItemL(*sortedItems[aIndex], sortedItems[aIndex]->Uid() == iFeedUpdating);
   136 	
   138 	
   137 	// If nothing has changed, we are done here
   139 	// If nothing has changed, we are done here
   138 	if (iListboxFormatbuffer == iItemArray->MdcaPoint(aIndex))
   140 	if (iListboxFormatbuffer == iItemArray->MdcaPoint(aIndex))
   139 		{
   141 		{
   140 		return;
   142 		return;
   168 	                                  const TDesC8& aCustomMessage)
   170 	                                  const TDesC8& aCustomMessage)
   169 	{
   171 	{
   170 	DP("CPodcastFeedView::DoActivateL BEGIN");
   172 	DP("CPodcastFeedView::DoActivateL BEGIN");
   171 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
   173 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
   172 	
   174 	
       
   175 	iPodcastModel.ShowEngine().ExpireOldShows();
   173 	if (aPrevViewId.iViewUid == KUidPodcastShowsViewID)
   176 	if (aPrevViewId.iViewUid == KUidPodcastShowsViewID)
   174 		{
   177 		{
   175 		// back key from shows view
   178 		// back key from shows view
   176 		iViewingShows = EFalse;
   179 		iViewingShows = EFalse;
   177 		}
   180 		}
   320 		DP("CPodcastFeedView::UpdateFeedInfoStatusL END");
   323 		DP("CPodcastFeedView::UpdateFeedInfoStatusL END");
   321 	}
   324 	}
   322 
   325 
   323 void CPodcastFeedView::FormatFeedInfoListBoxItemL(CFeedInfo& aFeedInfo, TBool aIsUpdating)
   326 void CPodcastFeedView::FormatFeedInfoListBoxItemL(CFeedInfo& aFeedInfo, TBool aIsUpdating)
   324 	{
   327 	{
   325 	DP("CPodcastFeedView::FormatFeedInfoListBoxItemL BEGIN");
   328 //	DP("CPodcastFeedView::FormatFeedInfoListBoxItemL BEGIN");
   326 	TBuf<KMaxShortDateFormatSpec*2> updatedDate;
   329 	TBuf<KMaxShortDateFormatSpec*2> updatedDate;
   327 	TBuf<KMaxUnplayedFeedsLength> unplayedShows;
   330 	TBuf<KMaxUnplayedFeedsLength> unplayedShows;
   328 	TUint unplayedCount = 0;
   331 	TUint unplayedCount = 0;
   329 	TUint showCount = 0;
   332 	TUint showCount = 0;
   330 	TInt iconIndex = EFeedIcon;
   333 	TInt iconIndex = EFeedIcon;
   372 			updatedDate.Zero();
   375 			updatedDate.Zero();
   373 			}
   376 			}
   374 		}
   377 		}
   375 	
   378 	
   376 	iconIndex = iFeedIdForIconArray.Find(aFeedInfo.Uid());
   379 	iconIndex = iFeedIdForIconArray.Find(aFeedInfo.Uid());
   377 	DP1("    iconIndex = %d", iconIndex);
   380 //	DP1("    iconIndex = %d", iconIndex);
   378 	if(iconIndex == KErrNotFound && aFeedInfo.FeedIcon() != NULL && aFeedInfo.ImageFileName().Length() > 0 && 
   381 	if(iconIndex == KErrNotFound && aFeedInfo.FeedIcon() != NULL && aFeedInfo.ImageFileName().Length() > 0 && 
   379 			aFeedInfo.FeedIcon()->SizeInPixels().iHeight > 0 &&
   382 			aFeedInfo.FeedIcon()->SizeInPixels().iHeight > 0 &&
   380 			aFeedInfo.FeedIcon()->SizeInPixels().iWidth > 0)
   383 			aFeedInfo.FeedIcon()->SizeInPixels().iWidth > 0)
   381 		{
   384 		{
   382 		// Hopefully temporary haxx to prevent double delete. I would prefer if
   385 		// Hopefully temporary haxx to prevent double delete. I would prefer if
   400 	if (unplayedShows.Length() > 0 && updatedDate.Length() > 0) {
   403 	if (unplayedShows.Length() > 0 && updatedDate.Length() > 0) {
   401 		unplayedShows.Insert(0,_L(", "));
   404 		unplayedShows.Insert(0,_L(", "));
   402 	}
   405 	}
   403 		
   406 		
   404 	iListboxFormatbuffer.Format(KFeedFormat(), iconIndex, &(aFeedInfo.Title()), &updatedDate,  &unplayedShows);
   407 	iListboxFormatbuffer.Format(KFeedFormat(), iconIndex, &(aFeedInfo.Title()), &updatedDate,  &unplayedShows);
   405 	DP("CPodcastFeedView::FormatFeedInfoListBoxItemL END");
   408 //	DP("CPodcastFeedView::FormatFeedInfoListBoxItemL END");
   406 	}
   409 	}
   407 
   410 
   408 void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle, CPodcastModel& /*aPodcastModel*/)
   411 void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle, CPodcastModel& /*aPodcastModel*/)
   409 	{
   412 	{
   410 	if (aError == KErrNone) {
   413 	if (aError == KErrNone) {
   510 			HandleExportFeedsL();
   513 			HandleExportFeedsL();
   511 			break;
   514 			break;
   512 		case EPodcastEditFeed:
   515 		case EPodcastEditFeed:
   513 			HandleEditFeedL();
   516 			HandleEditFeedL();
   514 			break;
   517 			break;
       
   518 		case EPodcastShowInfo:
       
   519 			DisplayFeedInfoDialogL();
       
   520 			break;
   515 		case EPodcastDeleteFeedHardware:
   521 		case EPodcastDeleteFeedHardware:
   516 		case EPodcastDeleteFeed:
   522 		case EPodcastDeleteFeed:
   517 			HandleRemoveFeedL();
   523 			HandleRemoveFeedL();
   518 			break;
   524 			break;
   519 		case EPodcastUpdateAllFeeds:
   525 		case EPodcastUpdateAllFeeds:
   529 			if(iFeedUpdating)
   535 			if(iFeedUpdating)
   530 				{
   536 				{
   531 				iPodcastModel.FeedEngine().CancelUpdateAllFeeds();
   537 				iPodcastModel.FeedEngine().CancelUpdateAllFeeds();
   532 				}
   538 				}
   533 			}break;
   539 			}break;
   534 		case EPodcastShowInfo:
       
   535 			DisplayFeedInfoDialogL();
       
   536 			break;
       
   537 		default:
   540 		default:
   538 			CPodcastListView::HandleCommandL(aCommand);
   541 			CPodcastListView::HandleCommandL(aCommand);
   539 			break;
   542 			break;
   540 		}
   543 		}
   541 	
   544 	
   591 	}
   594 	}
   592 
   595 
   593 void CPodcastFeedView::ShowItem(TUint aUid)
   596 void CPodcastFeedView::ShowItem(TUint aUid)
   594 	{
   597 	{
   595 	TInt listIndex = -1;
   598 	TInt listIndex = -1;
   596 	for (TUint i=0;i<iItemIdArray.Count();i++)
   599 	for (TInt i=0;i<iItemIdArray.Count();i++)
   597 		{
   600 		{
   598 		if (iItemIdArray[i] == aUid)
   601 		if (iItemIdArray[i] == aUid)
   599 			{
   602 			{
   600 			listIndex = i;
   603 			listIndex = i;
   601 			}
   604 			}
   901 	
   904 	
   902 	// if no shows in queue, we keep whichever state suspend is in
   905 	// if no shows in queue, we keep whichever state suspend is in
   903 	showsDownloading.ResetAndDestroy();
   906 	showsDownloading.ResetAndDestroy();
   904 	}
   907 	}
   905 
   908 
       
   909 void CPodcastFeedView::CheckConfirmExit()
       
   910 	{
       
   911 	DP("CPodcastFeedView::CheckConfirmExit");
       
   912 	RShowInfoArray showsDownloading;
       
   913 	iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading);
       
   914 	TUint count = showsDownloading.Count();
       
   915 	showsDownloading.ResetAndDestroy();
       
   916 	showsDownloading.Close();
       
   917 
       
   918 	if (count > 0 && !iPodcastModel.SettingsEngine().DownloadSuspended())
       
   919 		{
       
   920 		TBuf<256> msg;
       
   921 		iEikonEnv->ReadResourceL(msg, R_EXIT_SHOWS_DOWNLOADING);
       
   922 		
       
   923 		if (!ShowQueryMessageL(msg))
       
   924 			{
       
   925 			return;
       
   926 			}
       
   927 		}
       
   928 	
       
   929 	AppUi()->Exit();
       
   930 	}
       
   931 
   906 void CPodcastFeedView::OpmlParsingComplete(TInt aError, TUint aNumFeedsImported)
   932 void CPodcastFeedView::OpmlParsingComplete(TInt aError, TUint aNumFeedsImported)
   907 	{
   933 	{
   908 	TRAP_IGNORE(OpmlParsingCompleteL(aError, aNumFeedsImported));
   934 	TRAP_IGNORE(OpmlParsingCompleteL(aError, aNumFeedsImported));
   909 	}
   935 	}
   910 
   936 
   994 		aMenuPane->SetItemDimmed(EPodcastFeedFeedMenu, iFeedUpdating);
  1020 		aMenuPane->SetItemDimmed(EPodcastFeedFeedMenu, iFeedUpdating);
   995 //		aMenuPane->SetItemDimmed(EPodcastImportExportFeeds, iUpdatingRunning);
  1021 //		aMenuPane->SetItemDimmed(EPodcastImportExportFeeds, iUpdatingRunning);
   996 		}
  1022 		}
   997 	}
  1023 	}
   998 
  1024 
   999 void CPodcastFeedView::CheckConfirmExit()
       
  1000 	{
       
  1001 	DP("CPodcastFeedView::CheckConfirmExit");
       
  1002 	RShowInfoArray showsDownloading;
       
  1003 	iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading);
       
  1004 	TUint count = showsDownloading.Count();
       
  1005 	showsDownloading.ResetAndDestroy();
       
  1006 	showsDownloading.Close();
       
  1007 
       
  1008 	if (count > 0 && !iPodcastModel.SettingsEngine().DownloadSuspended())
       
  1009 		{
       
  1010 		TBuf<256> msg;
       
  1011 		iEikonEnv->ReadResourceL(msg, R_EXIT_SHOWS_DOWNLOADING);
       
  1012 		
       
  1013 		if (!ShowQueryMessageL(msg))
       
  1014 			{
       
  1015 			return;
       
  1016 			}
       
  1017 		}
       
  1018 	
       
  1019 	AppUi()->Exit();
       
  1020 	}
       
  1021 
       
  1022 TKeyResponse CPodcastFeedView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
  1025 TKeyResponse CPodcastFeedView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
  1023 	{
  1026 	{
  1024 	if (aType == EEventKey)
  1027 	if (aType == EEventKey)
  1025 		{
  1028 		{
  1026 			switch (aKeyEvent.iCode) {
  1029 			switch (aKeyEvent.iCode) {
  1027 			case EKeyBackspace:
  1030 			case EKeyBackspace:
  1028 			case EKeyDelete:
  1031 			case EKeyDelete:
  1029 				HandleCommandL(EPodcastDeleteFeedHardware);
  1032 				HandleCommandL(EPodcastDeleteFeedHardware);
  1030 				break;
  1033 				break;
       
  1034 			case 106:
       
  1035 			case '#':
       
  1036 				HandleCommandL(EPodcastShowInfo);
       
  1037 				break;
  1031 			default:
  1038 			default:
  1032 				break;
  1039 				break;
  1033 			}
  1040 			}
  1034 		}
  1041 		}
  1035 		return CPodcastListView::OfferKeyEventL(aKeyEvent, aType);
  1042 		return CPodcastListView::OfferKeyEventL(aKeyEvent, aType);