application/src/PodcastFeedView.cpp
author teknolog
Sun, 28 Feb 2010 21:19:40 +0000
changeset 26 71493655568a
parent 25 ae65906c4347
child 32 26a3f2dfba08
child 35 66c5303f3610
permissions -rw-r--r--
Workaround for long tap on selected item issue
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     1
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     2
* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     3
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     4
* All rights reserved.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     5
* This component and the accompanying materials are made available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     6
* under the terms of the License "Eclipse Public License v1.0"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     7
* which accompanies this distribution, and is available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     8
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     9
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    10
* Initial Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    11
* EmbedDev AB - initial contribution.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    12
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    13
* Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    14
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    15
* Description:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    16
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    17
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    18
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    19
#include "PodcastFeedView.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
#include "PodcastAppUi.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
#include "ShowEngine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
#include "SettingsEngine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
#include "PodcastApp.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
#include "PodcastUtils.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
#include "PodcastFeedViewUpdater.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
#include "Podcast.hrh"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    27
#include <caknfileselectiondialog.h> 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
#include <podcast.rsg>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
#include <podcast.mbg>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
#include <gulicon.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
#include <aknquerydialog.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
#include <caknmemoryselectiondialog.h> 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
#include <caknfilenamepromptdialog.h> 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
#include <BAUTILS.H> 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
#include <pathinfo.h> 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    36
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    37
const TInt KMaxFeedNameLength = 100;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
const TInt KMaxUnplayedFeedsLength =64;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
const TInt KADayInHours = 24;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
const TInt KDefaultGran = 5;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
const TInt KNumberOfFilesMaxLength = 4;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
#define KMaxMessageLength 200
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
#define KMaxTitleLength 100
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
const TInt KMimeBufLength = 100;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
_LIT(KFeedFormat, "%d\t%S\t%S%S");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
enum 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
 EFeedIcon
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
};
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
CPodcastFeedView* CPodcastFeedView::NewL(CPodcastModel& aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
    CPodcastFeedView* self = CPodcastFeedView::NewLC(aPodcastModel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
    CleanupStack::Pop( self );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
    return self;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
CPodcastFeedView* CPodcastFeedView::NewLC(CPodcastModel& aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
    CPodcastFeedView* self = new ( ELeave ) CPodcastFeedView(aPodcastModel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
    CleanupStack::PushL( self );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
    self->ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
    return self;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
CPodcastFeedView::CPodcastFeedView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
	iFirstActivateAfterLaunch = ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
#define KAsterisk iEikonEnv->EikAppUi()->Application()->BitmapStoreName()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
void CPodcastFeedView::ConstructL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
	DP("CPodcastFeedView::ConstructL BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
	//_LIT(KAsterisk, "*");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
	BaseConstructL(R_PODCAST_FEEDVIEW);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
	iNeverUpdated = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_NEVER_UPDATED);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
	iFeedsFormat = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_STATUS_FORMAT);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
	CPodcastListView::ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
	iPodcastModel.FeedEngine().AddObserver(this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
	CArrayPtr< CGulIcon >* icons = new(ELeave) CArrayPtrFlat< CGulIcon >(1);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
	CleanupStack::PushL( icons );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
	CFbsBitmap* bitmap = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
	CFbsBitmap* mask = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
	// Load the bitmap for empty icon	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
	TFileName fname = KAsterisk;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
	TParsePtr parser(fname);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
	SetEmptyTextL(R_PODCAST_NO_FEEDS);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
	// Load svg.-image and mask with a single call
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
		AknIconUtils::CreateIconL(bitmap,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
		                          mask,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
		                          iEikonEnv->EikAppUi()->Application()->BitmapStoreName(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
		                          EMbmPodcastFeed,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
		                          EMbmPodcastFeed_mask);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
	    
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
	/*bitmap = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
	 * */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
	CleanupStack::PushL( bitmap );		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
	// Load the mask for feed icon	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
	//mask = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40m );	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
	CleanupStack::PushL( mask );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
	// Append the feed icon to icon array
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
	icons->AppendL( CGulIcon::NewL( bitmap, mask ) );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
	CleanupStack::Pop(2); // bitmap, mask
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
	iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
	CleanupStack::Pop(icons); // icons
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
	iListContainer->Listbox()->SetListBoxObserver(this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   113
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   114
    iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint(0,0));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
    TResourceReader reader;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   116
    iCoeEnv->CreateResourceReaderLC(reader,R_FEEDVIEW_POPUP_MENU);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   117
    iStylusPopupMenu->ConstructFromResourceL(reader);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   118
    CleanupStack::PopAndDestroy();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   119
    
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   120
    iUpdater = CPodcastFeedViewUpdater::NewL(*this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
	DP("CPodcastFeedView::ConstructL END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   123
    
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   124
CPodcastFeedView::~CPodcastFeedView()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   125
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   126
	iPodcastModel.FeedEngine().RemoveObserver(this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   127
	delete iFeedsFormat;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   128
	delete iNeverUpdated;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   129
	delete iStylusPopupMenu;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   130
	delete iUpdater;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   133
void CPodcastFeedView::UpdateItemL(TInt aIndex)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   134
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   135
	_LIT(KPanicCategory, "CPodcastFeedView::UpdateItemL");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   136
	__ASSERT_DEBUG(iListContainer->IsVisible(), User::Panic(KPanicCategory, 0));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   137
	__ASSERT_ALWAYS(iItemIdArray.Count() > aIndex, User::Panic(KPanicCategory, 1));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   138
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   139
	const RFeedInfoArray& sortedItems = iPodcastModel.FeedEngine().GetSortedFeeds();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   140
	__ASSERT_ALWAYS(sortedItems.Count() > aIndex, User::Panic(KPanicCategory, 2));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   141
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   142
	// Update UID of for the feed at aIndex
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   143
	iItemIdArray[aIndex] = sortedItems[aIndex]->Uid();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   144
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   145
	// Prepare data to update the listbox item with
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
	FormatFeedInfoListBoxItemL(*sortedItems[aIndex], EFalse);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   147
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   148
	// If nothing has changed, we are done here
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   149
	if (iListboxFormatbuffer == iItemArray->MdcaPoint(aIndex))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   150
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   151
		return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
	// Something has changed, update the listbox item
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
	TListItemProperties itemProps;			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   156
	itemProps.SetDimmed(EFalse);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   157
	iItemArray->Delete(aIndex);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   158
	iItemArray->InsertL(aIndex, iListboxFormatbuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   159
	iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(aIndex, itemProps);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   160
	// If item is visible, redraw it
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   161
	if (iListContainer->Listbox()->TopItemIndex() <= aIndex
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   162
			&& iListContainer->Listbox()->BottomItemIndex() >= aIndex)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   163
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   164
		iListContainer->Listbox()->DrawItem(aIndex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   165
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   166
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   167
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   168
TUid CPodcastFeedView::Id() const
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   169
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   170
	return KUidPodcastFeedViewID;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   171
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   172
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   173
void CPodcastFeedView::DoActivateL(const TVwsViewId& aPrevViewId,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   174
	                                  TUid aCustomMessageId,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   175
	                                  const TDesC8& aCustomMessage)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   176
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
11
f6c975c3b702 Work to handle tabs in search view
teknolog
parents: 8
diff changeset
   178
25
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   179
	if (aPrevViewId.iViewUid == KUidPodcastShowsViewID)
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   180
		{
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   181
		// back key from shows view
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   182
		iViewingShows = EFalse;
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   183
		}
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   184
	
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   185
	if (iViewingShows)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   186
		{
25
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   187
		// go to shows view
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   188
		AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID,  TUid::Uid(0), KNullDesC8());
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   189
		} 
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   190
	else 
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   191
		{
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   192
		UpdateToolbar();
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   193
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   194
		if (iFirstActivateAfterLaunch)
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   195
			{
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   196
			iFirstActivateAfterLaunch = EFalse;
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   197
			}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   198
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   199
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
void CPodcastFeedView::DoDeactivate()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
	iUpdater->StopUpdate();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
	CPodcastListView::DoDeactivate();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   205
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   206
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   207
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   208
void CPodcastFeedView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   209
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   210
	DP("CPodcastFeedView::HandleListBoxEventL BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   212
	switch(aEventType)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   213
		{
26
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   214
		case EEventPenDownOnItem:
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   215
			DP("PEN DOWN");
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   216
			break;
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   217
			
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   218
//#ifndef SYMBIAN1_UI
23
cf4b850bbffb Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents: 19
diff changeset
   219
	case EEventItemClicked:
26
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   220
		DP("SINGLE TAP");
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   221
		break;
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   222
//#endif
17
4bcc91e70483 Configuration changes to default podcasts. Changed Download to Get in toolbar
teknolog
parents: 14
diff changeset
   223
	case EEventEnterKeyPressed:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   224
	case EEventItemDoubleClicked:
17
4bcc91e70483 Configuration changes to default podcasts. Changed Download to Get in toolbar
teknolog
parents: 14
diff changeset
   225
	case EEventItemActioned:
26
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   226
		DP("DOUBLE TAP");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   227
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   228
			const RFeedInfoArray* sortedItems = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   229
			TInt index = iListContainer->Listbox()->CurrentItemIndex();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   230
			sortedItems = &iPodcastModel.FeedEngine().GetSortedFeeds();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   231
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   232
			if(index >= 0 && index < sortedItems->Count())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   233
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   234
				iPodcastModel.ActiveShowList().Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   235
				iPodcastModel.SetActiveFeedInfo((*sortedItems)[index]);			
25
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   236
				iViewingShows = ETrue;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   237
				AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID,  TUid::Uid(0), KNullDesC8());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   238
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   239
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   240
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   241
	default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   242
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   243
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   244
	DP("CPodcastFeedView::HandleListBoxEventL END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   245
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   246
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   247
void CPodcastFeedView::FeedUpdateAllCompleteL(TFeedState /*aState*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   248
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   249
	iUpdatingAllRunning = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   250
	UpdateToolbar();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   251
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   252
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   253
void CPodcastFeedView::FeedDownloadStartedL(TFeedState /*aState*/, TUint aFeedUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   254
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   255
	// Update status text
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   256
	UpdateFeedInfoStatusL(aFeedUid, ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   257
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   258
	UpdateToolbar();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   259
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   260
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   261
void CPodcastFeedView::FeedDownloadFinishedL(TFeedState aState,TUint aFeedUid, TInt aError)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   262
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   263
	switch(aError)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   264
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   265
		case KErrCouldNotConnect:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   266
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   267
			if(aState == MFeedEngineObserver::EFeedManualUpdate)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   268
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   269
				TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   270
				iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   271
				ShowErrorMessage(message);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   272
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   273
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   274
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   275
		default: // Do nothing
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   276
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   277
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   278
	UpdateFeedInfoStatusL(aFeedUid, EFalse);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   279
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   280
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   281
void CPodcastFeedView::UpdateFeedInfoStatusL(TUint aFeedUid, TBool aIsUpdating)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   282
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   283
	const RFeedInfoArray& feeds = iPodcastModel.FeedEngine().GetSortedFeeds();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   284
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   285
	// Find the index for the feed i both the feed-array and the listbox 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   286
	TInt feedsIdx = KErrNotFound;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   287
	TInt listboxIdx = KErrNotFound;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   288
	for (TInt i = 0; i < feeds.Count(); i++)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   289
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   290
		if (feeds[i]->Uid() == aFeedUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   291
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   292
			feedsIdx = i;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   293
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   294
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   295
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   296
	for (TInt j = 0; j < iItemIdArray.Count(); j++)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   297
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   298
		if (iItemIdArray[j] == aFeedUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   299
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   300
			listboxIdx = j;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   301
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   302
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   303
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   304
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   305
	if (feedsIdx != KErrNotFound && listboxIdx != KErrNotFound)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   306
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   307
		// TODO In the long run we want to move the sorting resposibility from
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   308
		// CFeedEngine to CPodcastFeedView.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   309
		// Hackish fix to make sure the listbox is sorted.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   310
		if (listboxIdx != feedsIdx)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   311
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   312
			iItemIdArray.Remove(listboxIdx);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   313
			iItemIdArray.InsertL(aFeedUid, feedsIdx);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   314
			iItemArray->Delete(listboxIdx);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   315
			iItemArray->InsertL(feedsIdx, KNullDesC);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   316
			iListContainer->Listbox()->HandleItemAdditionL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   317
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   318
		// Update the listbox info
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   319
		UpdateFeedInfoDataL(feeds[feedsIdx], feedsIdx, aIsUpdating);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   320
		//TODO sort the listbox after update
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   321
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   322
		// Update all visible listbox items that are affected by sorting and update.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   323
		TInt minIdx = Max(Min(feedsIdx, listboxIdx), iListContainer->Listbox()->TopItemIndex());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   324
		TInt maxIdx = Min(Max(feedsIdx, listboxIdx), iListContainer->Listbox()->BottomItemIndex());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   325
		for (TInt k = minIdx; k <= maxIdx; k++)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   326
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   327
			iListContainer->Listbox()->DrawItem(k);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   328
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   329
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   330
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   331
void CPodcastFeedView::FormatFeedInfoListBoxItemL(CFeedInfo& aFeedInfo, TBool aIsUpdating)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   332
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   333
	TBuf<KMaxShortDateFormatSpec*2> updatedDate;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   334
	TBuf<KMaxUnplayedFeedsLength> unplayedShows;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   335
	TUint unplayedCount = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   336
	TUint showCount = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   337
	TInt iconIndex = EFeedIcon;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   338
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   339
	if(aIsUpdating)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   340
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   341
		iEikonEnv->ReadResourceL(updatedDate, R_PODCAST_FEEDS_IS_UPDATING);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   342
		unplayedShows = KNullDesC();			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   343
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   344
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   345
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   346
		iPodcastModel.FeedEngine().GetStatsByFeed(aFeedInfo.Uid(), showCount, unplayedCount);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   347
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   348
		if (unplayedCount) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   349
			unplayedShows.Format(*iFeedsFormat, unplayedCount);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   350
		} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   351
			unplayedShows.Zero();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   352
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   353
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   354
		if (aFeedInfo.LastUpdated().Int64() == 0) 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   355
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   356
			updatedDate.Copy(*iNeverUpdated);					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   357
			unplayedShows.Zero();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   358
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   359
		else 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   360
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   361
			TTime now;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   362
			TTimeIntervalHours interval;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   363
			now.HomeTime();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   364
			now.HoursFrom(aFeedInfo.LastUpdated(), interval);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   365
			if (interval.Int() < KADayInHours) 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   366
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   367
				aFeedInfo.LastUpdated().FormatL(updatedDate, KTimeFormat());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   368
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   369
			else 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   370
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   371
				aFeedInfo.LastUpdated().FormatL(updatedDate, KDateFormatShort());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   372
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   373
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   374
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   375
	CArrayPtr<CGulIcon>* icons = iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->IconArray();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   376
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   377
	if (aFeedInfo.FeedIconIndex() != -1) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   378
		iconIndex = aFeedInfo.FeedIconIndex();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   379
	} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   380
		if(aFeedInfo.FeedIcon() != NULL && 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   381
				aFeedInfo.FeedIcon()->SizeInPixels().iHeight > 0 &&
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   382
				aFeedInfo.FeedIcon()->SizeInPixels().iWidth > 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   383
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   384
			// Hopefully temporary haxx to prevent double delete. I would prefer if
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   385
			// this could be solved with a little better design.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   386
			CFbsBitmap* bmpCopy = new (ELeave) CFbsBitmap;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   387
			CleanupStack::PushL(bmpCopy);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   388
			bmpCopy->Duplicate(aFeedInfo.FeedIcon()->Handle());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   389
			icons->AppendL( CGulIcon::NewL(bmpCopy, NULL));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   390
			CleanupStack::Pop(bmpCopy);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   391
			iconIndex = icons->Count()-1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   392
			aFeedInfo.SetFeedIconIndex(iconIndex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   393
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   394
		else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   395
			if(BaflUtils::FileExists(iPodcastModel.FsSession(), aFeedInfo.ImageFileName()))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   396
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   397
			// If this fails, no reason to worry
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   398
			TRAP_IGNORE(iPodcastModel.ImageHandler().LoadFileAndScaleL(aFeedInfo.FeedIcon(), aFeedInfo.ImageFileName(), TSize(64,56), *this));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   399
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   400
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   401
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   402
	
5
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
   403
	if(aFeedInfo.LastError() != KErrNone)
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
   404
		{
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
   405
		GetFeedErrorText(unplayedShows, aFeedInfo.LastError());
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
   406
		}
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
   407
		
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   408
	if (unplayedShows.Length() > 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   409
		unplayedShows.Insert(0,_L(", "));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   410
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   411
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   412
	iListboxFormatbuffer.Format(KFeedFormat(), iconIndex, &(aFeedInfo.Title()), &updatedDate,  &unplayedShows);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   413
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   414
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   415
void CPodcastFeedView::ImageOperationCompleteL(TInt aError)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   416
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   417
	if (aError == KErrNone) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   418
		UpdateListboxItemsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   419
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   420
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   421
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   422
void CPodcastFeedView::UpdateFeedInfoDataL(CFeedInfo* aFeedInfo, TInt aIndex, TBool aIsUpdating )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   423
	{			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   424
	TListItemProperties itemProps;			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   425
	itemProps.SetDimmed(aIsUpdating);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   426
	FormatFeedInfoListBoxItemL(*aFeedInfo, aIsUpdating);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   427
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   428
	TPtrC compareTo((*iItemArray)[aIndex]);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   429
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   430
	if (iListboxFormatbuffer.Compare(compareTo) != 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   431
		iItemArray->Delete(aIndex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   432
		if(aIndex>= iItemArray->MdcaCount())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   433
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   434
				iItemArray->AppendL(iListboxFormatbuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   435
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   436
			else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   437
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   438
				iItemArray->InsertL(aIndex, iListboxFormatbuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   439
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   440
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   441
	iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(aIndex, itemProps);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   442
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   443
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   444
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   445
void CPodcastFeedView::UpdateListboxItemsL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   446
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   447
	// No reason to do any work if it isn't going to show..
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   448
	if(!iListContainer->IsVisible())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   449
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   450
		return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   451
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   452
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   453
	TInt nbrItems = iPodcastModel.FeedEngine().GetSortedFeeds().Count();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   454
	if (nbrItems > 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   455
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   456
		// Ensure that there are as many elements in iItemIdArray as in FeedEngine
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   457
		while (iItemIdArray.Count() < nbrItems)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   458
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   459
			iItemIdArray.AppendL(0);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   460
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   461
		while (iItemIdArray.Count() > nbrItems)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   462
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   463
			iItemIdArray.Remove(iItemIdArray.Count() - 1);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   464
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   465
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   466
		// Ensure that there are as many elements in iItemArray as in FeedEngine
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   467
		while (iItemArray->Count() < nbrItems)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   468
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   469
			iItemArray->AppendL(KNullDesC);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   470
			TListItemProperties itemProps;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   471
			iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(iItemArray->Count() - 1, itemProps);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   472
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   473
		while (iItemArray->Count() > nbrItems)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   474
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   475
			iItemArray->Delete(iItemArray->Count() - 1);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   476
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   477
		iUpdater->StartUpdate(nbrItems);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   478
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   479
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   480
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   481
		// No feeds at all in the list , add dummy list item
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   482
		TBuf<KMaxFeedNameLength> itemName;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   483
		iEikonEnv->ReadResourceL(itemName, R_PODCAST_FEEDS_NO_FEEDS);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   484
		iItemArray->Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   485
		iItemIdArray.Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   486
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   487
		TListItemProperties itemProps;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   488
		itemProps.SetDimmed(ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   489
		itemProps.SetHiddenSelection(ETrue);								
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   490
		iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   491
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   492
	iListContainer->Listbox()->HandleItemAdditionL();		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   493
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   494
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   495
/** 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   496
 * Command handling function intended for overriding by sub classes. 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   497
 * Default implementation is empty.  
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   498
 * @param aCommand ID of the command to respond to. 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   499
 */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   500
void CPodcastFeedView::HandleCommandL(TInt aCommand)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   501
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   502
	//CloseToolbarExtension();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   503
	switch(aCommand)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   504
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   505
        case EPodcastHide:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   506
			AppUi()->HandleCommandL(EEikCmdExit);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   507
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   508
		case EPodcastAddFeed:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   509
			HandleAddFeedL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   510
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   511
		case EPodcastImportFeeds:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   512
			HandleImportFeedsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   513
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   514
		case EPodcastExportFeeds:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   515
			HandleExportFeedsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   516
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   517
		case EPodcastEditFeed:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   518
			HandleEditFeedL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   519
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   520
		case EPodcastDeleteFeedHardware:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   521
		case EPodcastDeleteFeed:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   522
			HandleRemoveFeedL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   523
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   524
		case EPodcastUpdateAllFeeds:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   525
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   526
			iUpdatingAllRunning = ETrue;			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   527
			iPodcastModel.FeedEngine().UpdateAllFeedsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   528
			UpdateToolbar();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   529
			}break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   530
		case EPodcastUpdateFeed:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   531
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   532
			HandleUpdateFeedL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   533
			}break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   534
		case EPodcastCancelUpdateAllFeeds:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   535
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   536
			if(iUpdatingAllRunning)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   537
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   538
				iUpdatingAllRunning = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   539
				iPodcastModel.FeedEngine().CancelUpdateAllFeeds();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   540
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   541
			}break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   542
		case EAknSoftkeyExit:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   543
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   544
			RShowInfoArray dlQueue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   545
			iPodcastModel.ShowEngine().GetShowsDownloadingL(dlQueue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   546
			TUint queueCount = dlQueue.Count();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   547
			dlQueue.ResetAndDestroy();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   548
			dlQueue.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   549
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   550
			if (queueCount > 0 && !iPodcastModel.SettingsEngine().DownloadSuspended())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   551
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   552
				TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   553
				iEikonEnv->ReadResourceL(message, R_EXIT_SHOWS_DOWNLOADING);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   554
				if(ShowQueryMessage(message))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   555
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   556
					// pass it on to AppUi, which will exit for us
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   557
					CPodcastListView::HandleCommandL(aCommand);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   558
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   559
				} 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   560
			else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   561
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   562
					// nothing in queue, or downloading suspended
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   563
					CPodcastListView::HandleCommandL(aCommand);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   564
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   565
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   566
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   567
		default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   568
			CPodcastListView::HandleCommandL(aCommand);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   569
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   570
		}
26
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   571
	
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   572
	iListContainer->SetLongTapDetected(EFalse); // in case we got here by long tapping
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   573
	UpdateToolbar();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   574
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   575
13
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 12
diff changeset
   576
void CPodcastFeedView::UpdateToolbar(TBool aVisible)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   577
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   578
	CAknToolbar* toolbar = Toolbar();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   579
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   580
	if (toolbar)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   581
		{
14
4e75731546eb Fix so toolbars only change visibility for the visible view
teknolog
parents: 13
diff changeset
   582
		if (iListContainer->IsVisible()) {
4e75731546eb Fix so toolbars only change visibility for the visible view
teknolog
parents: 13
diff changeset
   583
			toolbar->SetToolbarVisibility(aVisible);
4e75731546eb Fix so toolbars only change visibility for the visible view
teknolog
parents: 13
diff changeset
   584
		}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   585
		toolbar->HideItem(EPodcastUpdateAllFeeds, iUpdatingAllRunning, ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   586
		toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !iUpdatingAllRunning, ETrue );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   587
		toolbar->SetItemDimmed(EPodcastAddFeed, iUpdatingAllRunning, ETrue );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   588
		toolbar->SetItemDimmed(EPodcastSettings, iUpdatingAllRunning, ETrue );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   589
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   590
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   591
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   592
void CPodcastFeedView::HandleAddFeedL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   593
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   594
	TBuf<KFeedUrlLength> url;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   595
	url.Copy(_L("http://"));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   596
	CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   597
	dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   598
	HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_ADDFEED_PROMPT);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   599
	dlg->SetPromptL(*prompt);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   600
	CleanupStack::PopAndDestroy(prompt);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   601
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   602
	if(dlg->RunLD())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   603
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   604
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   605
		// if no :// we do a search
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   606
		if (url.Find(_L("://")) == KErrNotFound)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   607
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   608
			HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_SEARCHING);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   609
			ShowWaitDialogL(*waitText);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   610
			CleanupStack::PopAndDestroy(waitText);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   611
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   612
			iOpmlState = EOpmlSearching;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   613
			iPodcastModel.FeedEngine().SearchForFeedL(url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   614
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   615
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   616
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   617
			PodcastUtils::FixProtocolsL(url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   618
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   619
			CFeedInfo* newFeedInfo = CFeedInfo::NewL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   620
			CleanupStack::PushL(newFeedInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   621
			newFeedInfo->SetUrlL(url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   622
			newFeedInfo->SetTitleL(newFeedInfo->Url());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   623
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   624
			TBool added = iPodcastModel.FeedEngine().AddFeedL(*newFeedInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   625
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   626
			if (added)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   627
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   628
				UpdateListboxItemsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   629
				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   630
				// ask if users wants to update it now
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   631
				TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   632
				iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   633
				if(ShowQueryMessage(message))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   634
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   635
					CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   636
					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   637
					iPodcastModel.ActiveShowList().Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   638
					iPodcastModel.SetActiveFeedInfo(info);			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   639
					AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID,  TUid::Uid(0), KNullDesC8());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   640
					iPodcastModel.FeedEngine().UpdateFeedL(newFeedInfo->Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   641
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   642
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   643
			else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   644
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   645
				TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   646
				iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   647
				ShowErrorMessage(message);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   648
				}		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   649
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   650
			CleanupStack::PopAndDestroy(newFeedInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   651
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   652
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   653
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   654
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   655
void CPodcastFeedView::HandleEditFeedL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   656
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   657
	TInt index = iListContainer->Listbox()->CurrentItemIndex();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   658
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   659
	if(index < iItemArray->MdcaCount() && index >= 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   660
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   661
		CFeedInfo *info = iPodcastModel.FeedEngine().GetSortedFeeds()[index];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   662
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   663
		TBuf<KFeedTitleLength> title;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   664
		title.Copy(info->Title());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   665
		TBuf<KFeedUrlLength> url;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   666
		url.Copy(info->Url());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   667
		CAknMultiLineDataQueryDialog  *dlg = CAknMultiLineDataQueryDialog ::NewL(title, url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   668
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   669
		if (dlg->ExecuteLD(R_PODCAST_EDIT_FEED_DLG)) 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   670
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   671
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   672
			if(info->Url().Compare(url) != 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   673
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   674
				TBuf<KMaxMessageLength> dlgMessage;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   675
				iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_REPLACE);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   676
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   677
				// Ask the user if it is OK to remove all shows
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   678
				if ( ShowQueryMessage(dlgMessage))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   679
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   680
					PodcastUtils::FixProtocolsL(url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   681
					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   682
					//----- HACK ---- //
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   683
					CFeedInfo* temp = CFeedInfo::NewLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   684
					temp->SetUrlL(url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   685
					TBool added = iPodcastModel.FeedEngine().AddFeedL(*temp);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   686
					if (added) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   687
						// The Feed URL did not exist
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   688
						// Remove the temp entry so that the correct entry could be changed
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   689
						iPodcastModel.FeedEngine().RemoveFeedL(temp->Uid());	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   690
						
12
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   691
						// we remove the existing feed
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   692
						iPodcastModel.FeedEngine().RemoveFeedL(info->Uid());	
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   693
						
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   694
						CFeedInfo* newFeed = CFeedInfo::NewLC();
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   695
						newFeed->SetUrlL(url);
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   696
						newFeed->SetTitleL(title);
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   697
						
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   698
						iPodcastModel.FeedEngine().AddFeedL(*newFeed);
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   699
						CleanupStack::PopAndDestroy(newFeed);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   700
						UpdateListboxItemsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   701
					} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   702
						// the feed existed. Object deleted in AddFeed.	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   703
						TBuf<KMaxMessageLength> dlgMessage;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   704
						iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_EXISTS);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   705
						ShowErrorMessage(dlgMessage);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   706
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   707
					CleanupStack::PopAndDestroy(temp);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   708
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   709
			} else { // no url change, maybe title?
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   710
				// Update the title
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   711
				if (info->Title().Compare(title) != 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   712
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   713
					info->SetTitleL(title);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   714
					info->SetCustomTitle();	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   715
					iPodcastModel.FeedEngine().UpdateFeed(info);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   716
					UpdateListboxItemsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   717
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   718
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   719
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   720
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   721
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   722
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   723
void CPodcastFeedView::HandleRemoveFeedL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   724
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   725
	if(iListContainer->Listbox() != NULL)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   726
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   727
		TInt index = iListContainer->Listbox()->CurrentItemIndex();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   728
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   729
		if(index < iItemArray->MdcaCount() && index >= 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   730
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   731
			CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(iItemIdArray[index]);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   732
			TBuf<KMaxMessageLength> templ;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   733
			TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   734
			iEikonEnv->ReadResourceL(templ, R_PODCAST_REMOVE_FEED_PROMPT);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   735
			message.Format(templ, &info->Title());					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   736
			if(ShowQueryMessage(message))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   737
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   738
				iPodcastModel.FeedEngine().RemoveFeedL(iItemIdArray[index]);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   739
				iItemArray->Delete(index);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   740
				iItemIdArray.Remove(index);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   741
				iListContainer->Listbox()->HandleItemRemovalL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   742
				iListContainer->Listbox()->DrawNow();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   743
				}					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   744
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   745
		UpdateListboxItemsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   746
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   747
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   748
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   749
void CPodcastFeedView::HandleUpdateFeedL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   750
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   751
	TInt index = iListContainer->Listbox()->CurrentItemIndex();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   752
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   753
	if(index < iItemArray->MdcaCount() && index >= 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   754
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   755
		CFeedInfo *info = iPodcastModel.FeedEngine().GetSortedFeeds()[index];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   756
		iPodcastModel.FeedEngine().UpdateFeedL(info->Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   757
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   758
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   759
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   760
void CPodcastFeedView::HandleImportFeedsL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   761
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   762
	CAknMemorySelectionDialog* memDlg = 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   763
		CAknMemorySelectionDialog::NewL(ECFDDialogTypeNormal, ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   764
	CleanupStack::PushL(memDlg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   765
	CAknMemorySelectionDialog::TMemory memory = 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   766
		CAknMemorySelectionDialog::EPhoneMemory;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   767
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   768
	if (memDlg->ExecuteL(memory))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   769
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   770
		TFileName importName;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   771
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   772
		if (memory==CAknMemorySelectionDialog::EMemoryCard)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   773
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   774
			importName = PathInfo:: MemoryCardRootPath();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   775
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   776
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   777
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   778
			importName = PathInfo:: PhoneMemoryRootPath();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   779
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   780
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   781
		CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeNormal, R_PODCAST_IMPORT_PODCAST);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   782
		CleanupStack::PushL(dlg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   783
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   784
		dlg->SetDefaultFolderL(importName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   785
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   786
		if(dlg->ExecuteL(importName))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   787
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   788
			if(importName.Length()>0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   789
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   790
				HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_IMPORTING);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   791
				iOpmlState = EOpmlImporting;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   792
				ShowWaitDialogL(*waitText);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   793
				CleanupStack::PopAndDestroy(waitText);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   794
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   795
				TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(importName));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   796
									
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   797
				if (err != KErrNone) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   798
					TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   799
					iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   800
					ShowErrorMessage(message);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   801
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   802
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   803
				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   804
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   805
		CleanupStack::PopAndDestroy(dlg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   806
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   807
	CleanupStack::PopAndDestroy(memDlg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   808
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   809
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   810
void CPodcastFeedView::HandleExportFeedsL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   811
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   812
	CAknMemorySelectionDialog* memDlg = 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   813
		CAknMemorySelectionDialog::NewL(ECFDDialogTypeSave, ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   814
	CleanupStack::PushL(memDlg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   815
	CAknMemorySelectionDialog::TMemory memory = 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   816
		CAknMemorySelectionDialog::EPhoneMemory;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   817
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   818
	if (memDlg->ExecuteL(memory))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   819
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   820
		TFileName pathName;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   821
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   822
		if (memory==CAknMemorySelectionDialog::EMemoryCard)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   823
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   824
			pathName = PathInfo::MemoryCardRootPath();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   825
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   826
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   827
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   828
			pathName = PathInfo::PhoneMemoryRootPath();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   829
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   830
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   831
		CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeSave, R_PODCAST_EXPORT_FEEDS);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   832
		CleanupStack::PushL(dlg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   833
								
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   834
		if(dlg->ExecuteL(pathName))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   835
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   836
			CAknFileNamePromptDialog *fileDlg = CAknFileNamePromptDialog::NewL(R_PODCAST_FILENAME_PROMPT_DIALOG);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   837
			CleanupStack::PushL(fileDlg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   838
			fileDlg->SetPathL(pathName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   839
			TFileName fileName;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   840
			if (fileDlg->ExecuteL(fileName) && fileName.Length() > 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   841
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   842
				pathName.Append(fileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   843
				TFileName temp;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   844
				TRAPD(err, iPodcastModel.FeedEngine().ExportFeedsL(temp));						
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   845
				BaflUtils::CopyFile(iEikonEnv->FsSession(), temp, pathName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   846
				BaflUtils::DeleteFile(iEikonEnv->FsSession(),temp);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   847
				if (err == KErrNone) 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   848
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   849
					UpdateListboxItemsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   850
					TInt numFeeds = iPodcastModel.FeedEngine().GetSortedFeeds().Count();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   851
									
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   852
					TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   853
					TBuf<KMaxMessageLength> templ;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   854
					iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   855
					message.Format(templ, numFeeds);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   856
					ShowOkMessage(message);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   857
					} 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   858
				else 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   859
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   860
					TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   861
					iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   862
					ShowErrorMessage(message);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   863
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   864
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   865
			CleanupStack::PopAndDestroy(fileDlg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   866
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   867
		CleanupStack::PopAndDestroy(dlg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   868
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   869
	CleanupStack::PopAndDestroy(memDlg);									
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   870
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   871
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   872
void CPodcastFeedView::CheckResumeDownload()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   873
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   874
	// if there are shows queued for downloading, ask if we should resume now
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   875
	RShowInfoArray showsDownloading;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   876
	iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   877
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   878
	if (showsDownloading.Count() > 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   879
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   880
		TBuf<KMaxMessageLength> msg;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   881
		iEikonEnv->ReadResourceL(msg, R_PODCAST_ENABLE_DOWNLOADS_PROMPT);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   882
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   883
		if (ShowQueryMessage(msg))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   884
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   885
			// need to suspend downloads before ResumeDownloadL will work :)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   886
			iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   887
			// resume downloading if user says yes
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   888
			iPodcastModel.ShowEngine().ResumeDownloadsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   889
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   890
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   891
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   892
			// we disable downloading if user says no
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   893
			iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   894
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   895
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   896
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   897
	// if no shows in queue, we keep whichever state suspend is in
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   898
	showsDownloading.ResetAndDestroy();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   899
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   900
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   901
void CPodcastFeedView::OpmlParsingComplete(TInt aError, TUint aNumFeedsImported)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   902
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   903
	DP("CPodcastFeedView::OpmlParsingComplete BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   904
	
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   905
	switch (aError)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   906
		{
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   907
		case KErrCouldNotConnect:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   908
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   909
			TBuf<KMaxMessageLength> message;
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   910
			iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   911
			ShowErrorMessage(message);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   912
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   913
			break;
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   914
		case KErrNone: 
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   915
		default:			// we don't do more error handling here, just show 0 imported feeds
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   916
		switch (iOpmlState)
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   917
			{
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   918
			case EOpmlIdle:
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   919
				break;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   920
			case EOpmlImporting:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   921
				{
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   922
				UpdateListboxItemsL();
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   923
				delete iWaitDialog;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   924
				iOpmlState = EOpmlIdle;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   925
					
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   926
				TBuf<KMaxMessageLength> message;
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   927
				TBuf<KMaxMessageLength> templ;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   928
				iEikonEnv->ReadResourceL(templ, R_IMPORT_FEED_SUCCESS);
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   929
				message.Format(templ, aNumFeedsImported);
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   930
				
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   931
				if(ShowQueryMessage(message))
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   932
					{
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   933
					HandleCommandL(EPodcastUpdateAllFeeds);
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   934
					}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   935
				}
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   936
				break;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   937
			case EOpmlSearching:
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   938
				delete iWaitDialog;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   939
				if (iPodcastModel.FeedEngine().GetSearchResults().Count() == 0)
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   940
					{
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   941
					TBuf<KMaxMessageLength> message;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   942
					iEikonEnv->ReadResourceL(message, R_SEARCH_NORESULTS);
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   943
					ShowErrorMessage(message);
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   944
					}
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   945
				else
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   946
					{
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   947
					AppUi()->ActivateLocalViewL(KUidPodcastSearchViewID,  TUid::Uid(0), KNullDesC8());
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   948
					}
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   949
				iOpmlState = EOpmlIdle;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   950
				break;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   951
			default:
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   952
				break;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   953
			}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   954
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   955
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   956
	DP("CPodcastFeedView::OpmlParsingComplete END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   957
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   958
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   959
void CPodcastFeedView::DialogDismissedL(TInt /*aButtonId*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   960
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   961
	iPodcastModel.FeedEngine().CancelUpdateAllFeeds();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   962
	}
5
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
   963
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
   964
void CPodcastFeedView::GetFeedErrorText(TDes &aErrorMessage, TInt aErrorCode)
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
   965
	{
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
   966
	iEikonEnv->GetErrorText(aErrorMessage, aErrorCode);
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
   967
	}
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   968
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   969
void CPodcastFeedView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   970
{
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   971
	DP("CPodcastListView::HandleLongTapEventL BEGIN");
26
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   972
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   973
	if (iUpdatingAllRunning) {
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   974
		return; // we don't allow feed manipulation while update is running
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   975
	}
26
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   976
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   977
	iListContainer->SetLongTapDetected(ETrue);
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   978
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   979
	const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   980
	TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems(
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   981
			iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight;
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   982
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   983
    if(iStylusPopupMenu && aPenEventLocation.iY < lbHeight)
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   984
    {
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   985
		iStylusPopupMenu->ShowMenu();
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   986
		iStylusPopupMenu->SetPosition(aPenEventLocation);
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   987
    }
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   988
	DP("CPodcastListView::HandleLongTapEventL END");
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
   989
}