application/src/PodcastFeedView.cpp
author Sebastian Brannstrom <sebastianb@symbian.org>
Sun, 31 Oct 2010 14:40:31 +0000
branchRCL_3
changeset 323 0bd524909716
parent 320 e3ec8e436951
child 328 75a70f4a4f6d
permissions -rw-r--r--
Proper fix for bug 3875
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 <BAUTILS.H> 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
#include <pathinfo.h> 
107
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
    34
#include <akncommondialogsdynmem.h> 
114
27f6f5827e5d Cleaned up panic handling
teknolog
parents: 113
diff changeset
    35
#include "Podcatcher.pan"
2
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
#define KMaxMessageLength 200
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
#define KMaxTitleLength 100
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
313
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    43
_LIT(KFeedFormatPortrait, "%d\t%S\t%S%S");
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    44
//_LIT(KFeedFormatPortrait, "%d\t%S");
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    45
_LIT(KFeedFormatLandscape, "%d\t%S");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
enum 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
 EFeedIcon
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
};
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
CPodcastFeedView* CPodcastFeedView::NewL(CPodcastModel& aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
    CPodcastFeedView* self = CPodcastFeedView::NewLC(aPodcastModel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
    CleanupStack::Pop( self );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
    return self;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
    }
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
CPodcastFeedView* CPodcastFeedView::NewLC(CPodcastModel& aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
    CPodcastFeedView* self = new ( ELeave ) CPodcastFeedView(aPodcastModel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
    CleanupStack::PushL( self );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
    self->ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
    return self;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
314
e7776f6a2198 Dual listbox solution now mostly works
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 313
diff changeset
    66
void CPodcastFeedView::LoadIcons()
e7776f6a2198 Dual listbox solution now mostly works
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 313
diff changeset
    67
	{
313
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    68
	iFeedIdForIconArray.Reset();
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
    69
313
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    70
	CFbsBitmap* bitmap = NULL;
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    71
	CFbsBitmap* mask = NULL;
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    72
	_LIT(KAsterisk, "*");
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    73
	// Load the bitmap for empty icon	
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    74
	TFileName fname;
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    75
	fname.Copy(KAsterisk);
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    76
	TParsePtr parser(fname);
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
    77
	CArrayPtrFlat< CGulIcon > *iconArray= new(ELeave) CArrayPtrFlat< CGulIcon >(1);
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
    78
	CleanupStack::PushL( iconArray );
313
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    79
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    80
	// Load svg.-image and mask with a single call
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    81
		AknIconUtils::CreateIconL(bitmap,
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    82
		                          mask,
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    83
		                          iEikonEnv->EikAppUi()->Application()->BitmapStoreName(),
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    84
		                          EMbmPodcastFeed,
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    85
		                          EMbmPodcastFeed_mask);
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    86
	    
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    87
	/*bitmap = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40);
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    88
	 * */
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    89
	CleanupStack::PushL( bitmap );		
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    90
	// Load the mask for feed icon	
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    91
	//mask = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40m );	
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    92
	CleanupStack::PushL( mask );
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    93
	// Append the feed icon to icon array
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
    94
	iconArray->AppendL( CGulIcon::NewL( bitmap, mask ) );
313
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    95
	CleanupStack::Pop(2); // bitmap, mask
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
    96
	iListContainer->SetListboxIcons(iconArray);
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
    97
	CleanupStack::Pop(iconArray); // icons
313
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    98
	}
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    99
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
CPodcastFeedView::CPodcastFeedView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
	iFirstActivateAfterLaunch = ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
#define KAsterisk iEikonEnv->EikAppUi()->Application()->BitmapStoreName()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
void CPodcastFeedView::ConstructL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
	DP("CPodcastFeedView::ConstructL BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
	//_LIT(KAsterisk, "*");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
	BaseConstructL(R_PODCAST_FEEDVIEW);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
	iNeverUpdated = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_NEVER_UPDATED);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
	iFeedsFormat = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_STATUS_FORMAT);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
	CPodcastListView::ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   113
	iPodcastModel.FeedEngine().AddObserver(this);
313
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
   114
	SetEmptyTextL(R_PODCAST_NO_FEEDS);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
314
e7776f6a2198 Dual listbox solution now mostly works
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 313
diff changeset
   116
	LoadIcons();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   117
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   118
    iUpdater = CPodcastFeedViewUpdater::NewL(*this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   119
	DP("CPodcastFeedView::ConstructL END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   120
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
    
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
CPodcastFeedView::~CPodcastFeedView()
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
	iPodcastModel.FeedEngine().RemoveObserver(this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   125
	delete iFeedsFormat;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   126
	delete iNeverUpdated;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   127
	delete iUpdater;
94
8d36b7608232 Further updates to podcatchers handling of cached icons. Now cache the uid of icon in feedview and reuse if already cloned. Only one icon loaded anyway.
Lars Persson <lars.persson@embeddev.se>
parents: 93
diff changeset
   128
	iFeedIdForIconArray.Close();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   129
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   130
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
void CPodcastFeedView::UpdateItemL(TInt aIndex)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
	{
114
27f6f5827e5d Cleaned up panic handling
teknolog
parents: 113
diff changeset
   133
	__ASSERT_DEBUG(iListContainer->IsVisible(), Panic(EPodcatcherPanicFeedView));
27f6f5827e5d Cleaned up panic handling
teknolog
parents: 113
diff changeset
   134
	__ASSERT_ALWAYS(iItemIdArray.Count() > aIndex, Panic(EPodcatcherPanicFeedView));
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   135
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   136
	const RFeedInfoArray& sortedItems = iPodcastModel.FeedEngine().GetSortedFeeds();
114
27f6f5827e5d Cleaned up panic handling
teknolog
parents: 113
diff changeset
   137
	__ASSERT_ALWAYS(sortedItems.Count() > aIndex, Panic(EPodcatcherPanicFeedView));
2
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
	// Update UID of for the feed at aIndex
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   140
	iItemIdArray[aIndex] = sortedItems[aIndex]->Uid();
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
	// Prepare data to update the listbox item with
306
a36dc474cae2 Fix so "Updating..." text remains for a feed when list is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 302
diff changeset
   143
	FormatFeedInfoListBoxItemL(*sortedItems[aIndex], sortedItems[aIndex]->Uid() == iFeedUpdating);
2
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
	// If nothing has changed, we are done here
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
	if (iListboxFormatbuffer == iItemArray->MdcaPoint(aIndex))
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
		return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   149
		}
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
	// Something has changed, update the listbox item
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
	TListItemProperties itemProps;			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
	itemProps.SetDimmed(EFalse);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
	iItemArray->Delete(aIndex);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
	iItemArray->InsertL(aIndex, iListboxFormatbuffer);
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   156
	iItemArrayShort->Delete(aIndex);	
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   157
	iItemArrayShort->InsertL(aIndex, iListboxFormatbufferShort);
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   158
317
5afc95a6ad83 Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 316
diff changeset
   159
	//iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(aIndex, itemProps);
2
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
323
0bd524909716 Proper fix for bug 3875
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 320
diff changeset
   162
			&& iListContainer->Listbox()->BottomItemIndex() > aIndex)
2
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
323
0bd524909716 Proper fix for bug 3875
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 320
diff changeset
   168
void CPodcastFeedView::UpdateItemsComplete()
0bd524909716 Proper fix for bug 3875
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 320
diff changeset
   169
	{
0bd524909716 Proper fix for bug 3875
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 320
diff changeset
   170
	}
0bd524909716 Proper fix for bug 3875
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 320
diff changeset
   171
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   172
TUid CPodcastFeedView::Id() const
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   173
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   174
	return KUidPodcastFeedViewID;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   175
	}
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
void CPodcastFeedView::DoActivateL(const TVwsViewId& aPrevViewId,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   178
	                                  TUid aCustomMessageId,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   179
	                                  const TDesC8& aCustomMessage)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
	{
311
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   181
	DP("CPodcastFeedView::DoActivateL BEGIN");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   182
	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
49
43e204e6ae2e Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents: 33
diff changeset
   183
	
312
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   184
	
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   185
	UpdateListboxItemsL();		
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   186
	UpdateToolbar();
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   187
	
25
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   188
	if (aPrevViewId.iViewUid == KUidPodcastShowsViewID)
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
		// back key from shows view
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   191
		iViewingShows = EFalse;
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   192
		}
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   193
312
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   194
	// when we receive a UID argument, this comes from search view after
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   195
	// a new feed has been added
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   196
	if (aCustomMessageId.iUid != 0)
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   197
		{
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   198
		TUint feedUid = aCustomMessageId.iUid;
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   199
		ShowItem(feedUid);
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   200
		TBuf<KMaxMessageLength> message;
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   201
		iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS);
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   202
		if(ShowQueryMessageL(message))
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   203
			{
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   204
			iPodcastModel.FeedEngine().UpdateFeedL(feedUid);
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   205
			}
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   206
		}
2faae209e72b More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 311
diff changeset
   207
		
50
e7b10d6d7ba3 Merge with symbian1 branch
teknolog
parents: 49 45
diff changeset
   208
	if (iFirstActivateAfterLaunch)
e7b10d6d7ba3 Merge with symbian1 branch
teknolog
parents: 49 45
diff changeset
   209
		{
e7b10d6d7ba3 Merge with symbian1 branch
teknolog
parents: 49 45
diff changeset
   210
		iFirstActivateAfterLaunch = EFalse;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
		}
311
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   212
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   213
	DP("CPodcastFeedView::DoActivateL END");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   214
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   216
void CPodcastFeedView::DoDeactivate()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   217
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   218
	iUpdater->StopUpdate();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   219
	CPodcastListView::DoDeactivate();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   220
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   221
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   222
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   223
void CPodcastFeedView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   224
	{
315
091fa3bf3295 Cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 314
diff changeset
   225
//	DP("CPodcastFeedView::HandleListBoxEventL BEGIN");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   226
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   227
	switch(aEventType)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   228
		{
137
eefed4bda2e2 Minor fixes to comply with single tap technical solution description. By this I consider bug 2056 closed.
teknolog
parents: 126
diff changeset
   229
	case EEventItemSingleClicked:
17
4bcc91e70483 Configuration changes to default podcasts. Changed Download to Get in toolbar
teknolog
parents: 14
diff changeset
   230
	case EEventEnterKeyPressed:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   231
	case EEventItemDoubleClicked:
17
4bcc91e70483 Configuration changes to default podcasts. Changed Download to Get in toolbar
teknolog
parents: 14
diff changeset
   232
	case EEventItemActioned:
2
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
			const RFeedInfoArray* sortedItems = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   235
			TInt index = iListContainer->Listbox()->CurrentItemIndex();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   236
			sortedItems = &iPodcastModel.FeedEngine().GetSortedFeeds();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   237
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   238
			if(index >= 0 && index < sortedItems->Count())
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
				iPodcastModel.SetActiveFeedInfo((*sortedItems)[index]);			
25
ae65906c4347 Added feature to show showsview on return from queue if previously showed showsview
teknolog
parents: 24
diff changeset
   241
				iViewingShows = ETrue;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   242
				AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID,  TUid::Uid(0), KNullDesC8());
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
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   245
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   246
	default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   247
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   248
		}
315
091fa3bf3295 Cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 314
diff changeset
   249
//	DP("CPodcastFeedView::HandleListBoxEventL END");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   250
	}
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
void CPodcastFeedView::FeedUpdateAllCompleteL(TFeedState /*aState*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   253
	{
306
a36dc474cae2 Fix so "Updating..." text remains for a feed when list is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 302
diff changeset
   254
	DP("FeedUpdateAllCompleteL");
a36dc474cae2 Fix so "Updating..." text remains for a feed when list is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 302
diff changeset
   255
	iFeedUpdating = 0;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   256
	UpdateToolbar();
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   259
void CPodcastFeedView::FeedDownloadStartedL(TFeedState /*aState*/, TUint aFeedUid)
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
	// Update status text
306
a36dc474cae2 Fix so "Updating..." text remains for a feed when list is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 302
diff changeset
   262
	iFeedUpdating = aFeedUid;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   263
	UpdateFeedInfoStatusL(aFeedUid, ETrue);
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
	UpdateToolbar();
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   268
void CPodcastFeedView::FeedDownloadFinishedL(TFeedState aState,TUint aFeedUid, TInt aError)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   269
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   270
	switch(aError)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   271
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   272
		case KErrCouldNotConnect:
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
			if(aState == MFeedEngineObserver::EFeedManualUpdate)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   275
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   276
				TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   277
				iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 26
diff changeset
   278
				ShowErrorMessageL(message);
2
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
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   282
		default: // Do nothing
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   283
			break;
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
	UpdateFeedInfoStatusL(aFeedUid, EFalse);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   286
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   287
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   288
void CPodcastFeedView::UpdateFeedInfoStatusL(TUint aFeedUid, TBool aIsUpdating)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   289
	{
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   290
	DP("CPodcastFeedView::UpdateFeedInfoStatusL BEGIN");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   291
	const RFeedInfoArray& feeds = iPodcastModel.FeedEngine().GetSortedFeeds();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   292
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   293
	// 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
   294
	TInt feedsIdx = KErrNotFound;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   295
	TInt listboxIdx = KErrNotFound;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   296
	for (TInt i = 0; i < feeds.Count(); i++)
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 (feeds[i]->Uid() == 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
			feedsIdx = i;
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
	for (TInt j = 0; j < iItemIdArray.Count(); j++)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   305
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   306
		if (iItemIdArray[j] == aFeedUid)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   307
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   308
			listboxIdx = j;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   309
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   310
			}
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
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   313
	if (feedsIdx != KErrNotFound && listboxIdx != KErrNotFound)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   314
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   315
		// 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
   316
		// CFeedEngine to CPodcastFeedView.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   317
		// Hackish fix to make sure the listbox is sorted.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   318
		if (listboxIdx != feedsIdx)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   319
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   320
			iItemIdArray.Remove(listboxIdx);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   321
			iItemIdArray.InsertL(aFeedUid, feedsIdx);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   322
			iItemArray->Delete(listboxIdx);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   323
			iItemArray->InsertL(feedsIdx, KNullDesC);
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   324
			iItemArrayShort->Delete(listboxIdx);
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   325
			iItemArrayShort->InsertL(feedsIdx, KNullDesC);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   326
			iListContainer->Listbox()->HandleItemAdditionL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   327
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   328
		// Update the listbox info
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   329
		UpdateFeedInfoDataL(feeds[feedsIdx], feedsIdx, aIsUpdating);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   330
		//TODO sort the listbox after update
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   331
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   332
		// 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
   333
		TInt minIdx = Max(Min(feedsIdx, listboxIdx), iListContainer->Listbox()->TopItemIndex());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   334
		TInt maxIdx = Min(Max(feedsIdx, listboxIdx), iListContainer->Listbox()->BottomItemIndex());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   335
		for (TInt k = minIdx; k <= maxIdx; k++)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   336
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   337
			iListContainer->Listbox()->DrawItem(k);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   338
			}
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   339
		DP("CPodcastFeedView::UpdateFeedInfoStatusL END");
2
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   342
void CPodcastFeedView::FormatFeedInfoListBoxItemL(CFeedInfo& aFeedInfo, TBool aIsUpdating)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   343
	{
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   344
	DP("CPodcastFeedView::FormatFeedInfoListBoxItemL BEGIN");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   345
	TBuf<KMaxShortDateFormatSpec*2> updatedDate;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   346
	TBuf<KMaxUnplayedFeedsLength> unplayedShows;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   347
	TUint unplayedCount = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   348
	TUint showCount = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   349
	TInt iconIndex = EFeedIcon;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   350
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   351
	if(aIsUpdating)
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
		iEikonEnv->ReadResourceL(updatedDate, R_PODCAST_FEEDS_IS_UPDATING);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   354
		unplayedShows = KNullDesC();			
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
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   357
		{
109
223f270fa7ff Significantly improved database robustness
teknolog
parents: 107
diff changeset
   358
		// we will get a leave if there are no shows for this feed, for instance, which is fine
223f270fa7ff Significantly improved database robustness
teknolog
parents: 107
diff changeset
   359
		TRAP_IGNORE(iPodcastModel.FeedEngine().GetStatsByFeedL(aFeedInfo.Uid(), showCount, unplayedCount));	
2
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
		if (unplayedCount) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   362
			unplayedShows.Format(*iFeedsFormat, unplayedCount);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   363
		} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   364
			unplayedShows.Zero();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   365
		}
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
		if (aFeedInfo.LastUpdated().Int64() == 0) 
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
			updatedDate.Copy(*iNeverUpdated);					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   370
			unplayedShows.Zero();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   371
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   372
		else 
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
			TTime now;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   375
			TTimeIntervalHours interval;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   376
			now.HomeTime();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   377
			now.HoursFrom(aFeedInfo.LastUpdated(), interval);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   378
			if (interval.Int() < KADayInHours) 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   379
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   380
				aFeedInfo.LastUpdated().FormatL(updatedDate, KTimeFormat());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   381
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   382
			else 
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
				aFeedInfo.LastUpdated().FormatL(updatedDate, KDateFormatShort());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   385
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   386
			}
32
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 26
diff changeset
   387
		
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 26
diff changeset
   388
		if(aFeedInfo.LastError() != KErrNone)
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 26
diff changeset
   389
			{
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 26
diff changeset
   390
			GetFeedErrorText(unplayedShows, aFeedInfo.LastError());
112
0bd6b9a3f027 Don't show feed/show date when an error occured
teknolog
parents: 109
diff changeset
   391
			updatedDate.Zero();
32
26a3f2dfba08 Fix for bug where we always load the feed icon a large number of times
teknolog
parents: 26
diff changeset
   392
			}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   393
		}
313
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
   394
	
94
8d36b7608232 Further updates to podcatchers handling of cached icons. Now cache the uid of icon in feedview and reuse if already cloned. Only one icon loaded anyway.
Lars Persson <lars.persson@embeddev.se>
parents: 93
diff changeset
   395
	iconIndex = iFeedIdForIconArray.Find(aFeedInfo.Uid());
109
223f270fa7ff Significantly improved database robustness
teknolog
parents: 107
diff changeset
   396
	if(iconIndex == KErrNotFound && aFeedInfo.FeedIcon() != NULL && aFeedInfo.ImageFileName().Length() > 0 && 
93
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   397
			aFeedInfo.FeedIcon()->SizeInPixels().iHeight > 0 &&
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   398
			aFeedInfo.FeedIcon()->SizeInPixels().iWidth > 0)
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   399
		{
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   400
		// Hopefully temporary haxx to prevent double delete. I would prefer if
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   401
		// this could be solved with a little better design.
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   402
		CFbsBitmap* bmpCopy = new (ELeave) CFbsBitmap;
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   403
		CleanupStack::PushL(bmpCopy);
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   404
		bmpCopy->Duplicate(aFeedInfo.FeedIcon()->Handle());
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   405
		CArrayPtr<CGulIcon>* icons = iListContainer->ListboxIcons();
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   406
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   407
		icons->AppendL( CGulIcon::NewL(AknIconUtils::CreateIconL(bmpCopy), NULL));
311
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   408
		
94
8d36b7608232 Further updates to podcatchers handling of cached icons. Now cache the uid of icon in feedview and reuse if already cloned. Only one icon loaded anyway.
Lars Persson <lars.persson@embeddev.se>
parents: 93
diff changeset
   409
		iFeedIdForIconArray.Append(aFeedInfo.Uid());
93
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   410
		CleanupStack::Pop(bmpCopy);			
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   411
		iconIndex = icons->Count()-1;
94
8d36b7608232 Further updates to podcatchers handling of cached icons. Now cache the uid of icon in feedview and reuse if already cloned. Only one icon loaded anyway.
Lars Persson <lars.persson@embeddev.se>
parents: 93
diff changeset
   412
		}	
93
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   413
	else 
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   414
		{
94
8d36b7608232 Further updates to podcatchers handling of cached icons. Now cache the uid of icon in feedview and reuse if already cloned. Only one icon loaded anyway.
Lars Persson <lars.persson@embeddev.se>
parents: 93
diff changeset
   415
		iconIndex++;
8d36b7608232 Further updates to podcatchers handling of cached icons. Now cache the uid of icon in feedview and reuse if already cloned. Only one icon loaded anyway.
Lars Persson <lars.persson@embeddev.se>
parents: 93
diff changeset
   416
		}	
93
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   417
112
0bd6b9a3f027 Don't show feed/show date when an error occured
teknolog
parents: 109
diff changeset
   418
	if (unplayedShows.Length() > 0 && updatedDate.Length() > 0) {
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   419
		unplayedShows.Insert(0,_L(", "));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   420
	}
313
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
   421
		
314
e7776f6a2198 Dual listbox solution now mostly works
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 313
diff changeset
   422
	iListboxFormatbuffer.Format(KFeedFormatPortrait(), iconIndex, &(aFeedInfo.Title()), &updatedDate,  &unplayedShows);
317
5afc95a6ad83 Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 316
diff changeset
   423
	iListboxFormatbufferShort.Format(KFeedFormatLandscape(), iconIndex, &(aFeedInfo.Title()));
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   424
	DP("CPodcastFeedView::FormatFeedInfoListBoxItemL END");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   425
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   426
93
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   427
void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle, CPodcastModel& /*aPodcastModel*/)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   428
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   429
	if (aError == KErrNone) {
93
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   430
		UpdateFeedInfoStatusL(aHandle, EFalse);
bbf5c5204844 We always build the static version of sqlite for now. Further improvements for signaling when icons has been generated so these can be used in the feedview
Lars Persson <lars.persson@embeddev.se>
parents: 91
diff changeset
   431
		}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   432
	}
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
void CPodcastFeedView::UpdateFeedInfoDataL(CFeedInfo* aFeedInfo, TInt aIndex, TBool aIsUpdating )
317
5afc95a6ad83 Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 316
diff changeset
   435
	{
5afc95a6ad83 Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 316
diff changeset
   436
	DP("CPodcastFeedView::UpdateFeedInfoDataL BEGIN");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   437
	TListItemProperties itemProps;			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   438
	itemProps.SetDimmed(aIsUpdating);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   439
	FormatFeedInfoListBoxItemL(*aFeedInfo, aIsUpdating);
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
	TPtrC compareTo((*iItemArray)[aIndex]);
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
	if (iListboxFormatbuffer.Compare(compareTo) != 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   444
		iItemArray->Delete(aIndex);
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   445
		iItemArrayShort->Delete(aIndex);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   446
		if(aIndex>= iItemArray->MdcaCount())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   447
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   448
				iItemArray->AppendL(iListboxFormatbuffer);
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   449
				iItemArrayShort->AppendL(iListboxFormatbufferShort);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   450
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   451
			else
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
				iItemArray->InsertL(aIndex, iListboxFormatbuffer);
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   454
				iItemArrayShort->InsertL(aIndex, iListboxFormatbufferShort);
2
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
	}
317
5afc95a6ad83 Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 316
diff changeset
   457
	//iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(aIndex, itemProps);
5afc95a6ad83 Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 316
diff changeset
   458
	DP("CPodcastFeedView::UpdateFeedInfoDataL END");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   459
	}
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   462
void CPodcastFeedView::UpdateListboxItemsL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   463
	{
153
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   464
	DP("CPodcastFeedView::UpdateListboxItemsL BEGIN");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   465
	// 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
   466
	if(!iListContainer->IsVisible())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   467
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   468
		return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   469
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   470
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   471
	TInt nbrItems = iPodcastModel.FeedEngine().GetSortedFeeds().Count();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   472
	if (nbrItems > 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   473
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   474
		// 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
   475
		while (iItemIdArray.Count() < nbrItems)
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
			iItemIdArray.AppendL(0);
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
		while (iItemIdArray.Count() > nbrItems)
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
			iItemIdArray.Remove(iItemIdArray.Count() - 1);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   482
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   483
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   484
		// 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
   485
		while (iItemArray->Count() < nbrItems)
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
			iItemArray->AppendL(KNullDesC);
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   488
			iItemArrayShort->AppendL(KNullDesC);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   489
			TListItemProperties itemProps;
317
5afc95a6ad83 Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 316
diff changeset
   490
			//iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(iItemArray->Count() - 1, itemProps);
2
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
		while (iItemArray->Count() > nbrItems)
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
			iItemArray->Delete(iItemArray->Count() - 1);
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   495
			iItemArrayShort->Delete(iItemArray->Count() - 1);		
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   496
			}
313
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
   497
		//iListContainer->Listbox()->
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   498
		iUpdater->StartUpdate(nbrItems);
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
	else
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
		// No feeds at all in the list , add dummy list item
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   503
		TBuf<KMaxFeedNameLength> itemName;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   504
		iEikonEnv->ReadResourceL(itemName, R_PODCAST_FEEDS_NO_FEEDS);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   505
		iItemArray->Reset();
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   506
		iItemArrayShort->Reset();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   507
		iItemIdArray.Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   508
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   509
		TListItemProperties itemProps;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   510
		itemProps.SetDimmed(ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   511
		itemProps.SetHiddenSelection(ETrue);								
317
5afc95a6ad83 Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 316
diff changeset
   512
		//iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   513
		}
153
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   514
	iListContainer->Listbox()->HandleItemAdditionL();
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   515
	DP("CPodcastFeedView::UpdateListboxItemsL END");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   516
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   517
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   518
/** 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   519
 * Command handling function intended for overriding by sub classes. 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   520
 * Default implementation is empty.  
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   521
 * @param aCommand ID of the command to respond to. 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   522
 */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   523
void CPodcastFeedView::HandleCommandL(TInt aCommand)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   524
	{
153
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   525
	DP("CPodcastFeedView::HandleCommandL BEGIN");
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   526
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   527
	switch(aCommand)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   528
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   529
		case EPodcastAddFeed:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   530
			HandleAddFeedL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   531
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   532
		case EPodcastImportFeeds:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   533
			HandleImportFeedsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   534
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   535
		case EPodcastExportFeeds:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   536
			HandleExportFeedsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   537
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   538
		case EPodcastEditFeed:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   539
			HandleEditFeedL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   540
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   541
		case EPodcastDeleteFeedHardware:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   542
		case EPodcastDeleteFeed:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   543
			HandleRemoveFeedL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   544
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   545
		case EPodcastUpdateAllFeeds:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   546
			{
315
091fa3bf3295 Cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 314
diff changeset
   547
			iPodcastModel.FeedEngine().UpdateAllFeedsL();
091fa3bf3295 Cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 314
diff changeset
   548
			UpdateToolbar();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   549
			}break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   550
		case EPodcastUpdateFeed:
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
			HandleUpdateFeedL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   553
			}break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   554
		case EPodcastCancelUpdateAllFeeds:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   555
			{
306
a36dc474cae2 Fix so "Updating..." text remains for a feed when list is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 302
diff changeset
   556
			if(iFeedUpdating)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   557
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   558
				iPodcastModel.FeedEngine().CancelUpdateAllFeeds();
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
			}break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   561
		default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   562
			CPodcastListView::HandleCommandL(aCommand);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   563
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   564
		}
26
71493655568a Workaround for long tap on selected item issue
teknolog
parents: 25
diff changeset
   565
	
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   566
	UpdateToolbar();
153
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   567
	DP("CPodcastFeedView::HandleCommandL END");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   568
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   569
13
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 12
diff changeset
   570
void CPodcastFeedView::UpdateToolbar(TBool aVisible)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   571
{
153
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   572
	DP("CPodcastFeedView::UpdateToolbar BEGIN");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   573
	CAknToolbar* toolbar = Toolbar();
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
	if (toolbar)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   576
		{
14
4e75731546eb Fix so toolbars only change visibility for the visible view
teknolog
parents: 13
diff changeset
   577
		if (iListContainer->IsVisible()) {
4e75731546eb Fix so toolbars only change visibility for the visible view
teknolog
parents: 13
diff changeset
   578
			toolbar->SetToolbarVisibility(aVisible);
4e75731546eb Fix so toolbars only change visibility for the visible view
teknolog
parents: 13
diff changeset
   579
		}
306
a36dc474cae2 Fix so "Updating..." text remains for a feed when list is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 302
diff changeset
   580
		toolbar->HideItem(EPodcastUpdateAllFeeds, iFeedUpdating, ETrue);
a36dc474cae2 Fix so "Updating..." text remains for a feed when list is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 302
diff changeset
   581
		toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !iFeedUpdating, ETrue );
a36dc474cae2 Fix so "Updating..." text remains for a feed when list is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 302
diff changeset
   582
		toolbar->SetItemDimmed(EPodcastAddFeed, iFeedUpdating, ETrue );
a36dc474cae2 Fix so "Updating..." text remains for a feed when list is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 302
diff changeset
   583
		toolbar->SetItemDimmed(EPodcastSettings, iFeedUpdating, ETrue );
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   584
		}
153
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   585
	DP("CPodcastFeedView::UpdateToolbar END");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   586
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   587
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   588
void CPodcastFeedView::HandleAddFeedL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   589
	{
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   590
	TInt selection;
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   591
	CDesCArrayFlat* array = iCoeEnv->ReadDesC16ArrayResourceL(R_FEEDVIEW_ADD_URL_OR_SEARCH_ARRAY );
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   592
	CleanupStack::PushL( array );
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   593
	
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   594
	CAknListQueryDialog* dialog = new ( ELeave ) CAknListQueryDialog( &selection );
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   595
	CleanupStack::PushL( dialog );
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   596
	dialog->PrepareLC( R_FEEDVIEW_ADD_URL_OR_SEARCH );
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   597
	CleanupStack::Pop( dialog );
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   598
	
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   599
	dialog->SetItemTextArray( array );
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   600
	dialog->SetOwnershipType( ELbmDoesNotOwnItemArray );
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   601
	
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   602
	if ( dialog->RunLD() )
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   603
		{
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   604
		if (selection == 0)
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   605
			{
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   606
			// Enter URL selected
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   607
			HandleAddFeedUrlL();
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   608
			} 
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   609
		else
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   610
			{
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   611
			// Search selected
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   612
			HandleAddFeedSearchL();
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   613
			}	
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   614
		}
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   615
	CleanupStack::PopAndDestroy( array );		
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   616
	}
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   617
311
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   618
void CPodcastFeedView::ShowItem(TUint aUid)
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   619
	{
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   620
	TInt listIndex = -1;
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   621
	for (TUint i=0;i<iItemIdArray.Count();i++)
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   622
		{
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   623
		if (iItemIdArray[i] == aUid)
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   624
			{
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   625
			listIndex = i;
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   626
			}
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   627
		}
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   628
		
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   629
	if (listIndex != -1)
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   630
		iListContainer->Listbox()->ScrollToMakeItemVisible(listIndex);
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   631
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   632
	}
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   633
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   634
void CPodcastFeedView::HandleAddFeedUrlL()
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   635
	{
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   636
	TBuf<KFeedUrlLength> url;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   637
	url.Copy(_L("http://"));
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   638
	
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   639
	CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   640
	dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG);
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   641
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   642
	HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_ADDFEED_PROMPT);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   643
	dlg->SetPromptL(*prompt);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   644
	CleanupStack::PopAndDestroy(prompt);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   645
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   646
	if(dlg->RunLD())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   647
		{
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   648
		PodcastUtils::FixProtocolsL(url);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   649
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   650
		CFeedInfo* newFeedInfo = CFeedInfo::NewL();
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   651
		CleanupStack::PushL(newFeedInfo);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   652
		newFeedInfo->SetUrlL(url);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   653
		newFeedInfo->SetTitleL(newFeedInfo->Url());
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   654
		
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   655
		TBool added = iPodcastModel.FeedEngine().AddFeedL(*newFeedInfo);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   656
		
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   657
		if (added)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   658
			{
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   659
			UpdateListboxItemsL();
153
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   660
			
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   661
			// ask if users wants to update it now
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   662
			TBuf<KMaxMessageLength> message;
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   663
			iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   664
			if(ShowQueryMessageL(message))
153
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   665
				{
311
606f4f6babf6 Fix so feed icons are scaled nicely when rotating view
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 306
diff changeset
   666
				ShowItem(newFeedInfo->Uid());
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   667
				iPodcastModel.FeedEngine().UpdateFeedL(newFeedInfo->Uid());
153
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   668
				}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   669
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   670
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   671
			{
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   672
			TBuf<KMaxMessageLength> message;
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   673
			iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   674
			ShowErrorMessageL(message);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   675
			}		
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   676
		
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   677
		CleanupStack::PopAndDestroy(newFeedInfo);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   678
		}
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   679
	}
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   680
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   681
void CPodcastFeedView::HandleAddFeedSearchL()
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   682
	{
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   683
	TBuf<KFeedUrlLength> url;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   684
	
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   685
	CAknTextQueryDialog * dlg =CAknTextQueryDialog::NewL(url);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   686
	dlg->PrepareLC(R_PODCAST_ADD_FEED_DLG);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   687
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   688
	HBufC* prompt = iEikonEnv->AllocReadResourceLC(R_PODCAST_SEARCHFEED_PROMPT);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   689
	dlg->SetPromptL(*prompt);
272
e6d095ba6756 Icons in tabs
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 243
diff changeset
   690
	dlg->SetPredictiveTextInputPermitted(ETrue);
207
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   691
	CleanupStack::PopAndDestroy(prompt);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   692
	
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   693
	if(dlg->RunLD())
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   694
		{		
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   695
		HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_SEARCHING);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   696
		ShowWaitDialogL(*waitText);
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   697
		CleanupStack::PopAndDestroy(waitText);	
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   698
	
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   699
		iOpmlState = EOpmlSearching;
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   700
		TRAPD(err, iPodcastModel.FeedEngine().SearchForFeedL(url));
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   701
		
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   702
		if (err != KErrNone)
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   703
			{
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   704
			delete iWaitDialog;
9fef0425017e Bug 2865 - added option to search or enter URL for feed adding
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   705
			iOpmlState = EOpmlIdle;
2
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
		}
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   710
void CPodcastFeedView::HandleEditFeedL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   711
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   712
	TInt index = iListContainer->Listbox()->CurrentItemIndex();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   713
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   714
	if(index < iItemArray->MdcaCount() && index >= 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   715
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   716
		CFeedInfo *info = iPodcastModel.FeedEngine().GetSortedFeeds()[index];
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
		TBuf<KFeedTitleLength> title;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   719
		title.Copy(info->Title());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   720
		TBuf<KFeedUrlLength> url;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   721
		url.Copy(info->Url());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   722
		CAknMultiLineDataQueryDialog  *dlg = CAknMultiLineDataQueryDialog ::NewL(title, url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   723
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   724
		if (dlg->ExecuteLD(R_PODCAST_EDIT_FEED_DLG)) 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   725
			{
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
			if(info->Url().Compare(url) != 0)
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
				TBuf<KMaxMessageLength> dlgMessage;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   730
				iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_REPLACE);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   731
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   732
				// Ask the user if it is OK to remove all shows
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 26
diff changeset
   733
				if ( ShowQueryMessageL(dlgMessage))
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   734
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   735
					PodcastUtils::FixProtocolsL(url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   736
					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   737
					//----- HACK ---- //
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   738
					CFeedInfo* temp = CFeedInfo::NewLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   739
					temp->SetUrlL(url);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   740
					TBool added = iPodcastModel.FeedEngine().AddFeedL(*temp);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   741
					if (added) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   742
						// The Feed URL did not exist
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   743
						// 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
   744
						iPodcastModel.FeedEngine().RemoveFeedL(temp->Uid());	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   745
						
12
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   746
						// we remove the existing feed
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   747
						iPodcastModel.FeedEngine().RemoveFeedL(info->Uid());	
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   748
						
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   749
						CFeedInfo* newFeed = CFeedInfo::NewLC();
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   750
						newFeed->SetUrlL(url);
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   751
						newFeed->SetTitleL(title);
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   752
						
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   753
						iPodcastModel.FeedEngine().AddFeedL(*newFeed);
47c8595ffc70 Fix for bug when editing feed URL
teknolog
parents: 11
diff changeset
   754
						CleanupStack::PopAndDestroy(newFeed);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   755
						UpdateListboxItemsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   756
					} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   757
						// the feed existed. Object deleted in AddFeed.	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   758
						TBuf<KMaxMessageLength> dlgMessage;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   759
						iEikonEnv->ReadResourceL(dlgMessage, R_ADD_FEED_EXISTS);
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 26
diff changeset
   760
						ShowErrorMessageL(dlgMessage);
2
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
					CleanupStack::PopAndDestroy(temp);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   763
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   764
			} else { // no url change, maybe title?
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   765
				// Update the title
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   766
				if (info->Title().Compare(title) != 0)
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
					info->SetTitleL(title);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   769
					info->SetCustomTitle();	
102
04c6ccce8e7e Fix for bug 2408. Improved feed engine robustness.
teknolog
parents: 96
diff changeset
   770
					iPodcastModel.FeedEngine().UpdateFeedInfoL(info);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   771
					UpdateListboxItemsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   772
				}
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
		}
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
	}
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
void CPodcastFeedView::HandleRemoveFeedL()
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
	if(iListContainer->Listbox() != NULL)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   781
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   782
		TInt index = iListContainer->Listbox()->CurrentItemIndex();
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
		if(index < iItemArray->MdcaCount() && index >= 0)
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
			CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(iItemIdArray[index]);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   787
			TBuf<KMaxMessageLength> templ;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   788
			TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   789
			iEikonEnv->ReadResourceL(templ, R_PODCAST_REMOVE_FEED_PROMPT);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   790
			message.Format(templ, &info->Title());					
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 26
diff changeset
   791
			if(ShowQueryMessageL(message))
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   792
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   793
				iPodcastModel.FeedEngine().RemoveFeedL(iItemIdArray[index]);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   794
				iItemArray->Delete(index);
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 315
diff changeset
   795
				iItemArrayShort->Delete(index);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   796
				iItemIdArray.Remove(index);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   797
				iListContainer->Listbox()->HandleItemRemovalL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   798
				iListContainer->Listbox()->DrawNow();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   799
				}					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   800
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   801
		UpdateListboxItemsL();
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
void CPodcastFeedView::HandleUpdateFeedL()
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
	TInt index = iListContainer->Listbox()->CurrentItemIndex();
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
	if(index < iItemArray->MdcaCount() && index >= 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   810
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   811
		CFeedInfo *info = iPodcastModel.FeedEngine().GetSortedFeeds()[index];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   812
		iPodcastModel.FeedEngine().UpdateFeedL(info->Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   813
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   814
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   815
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   816
void CPodcastFeedView::HandleImportFeedsL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   817
	{
107
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   818
	TFileName fileName;
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   819
	fileName.Zero();
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   820
	TFileName startFolder;
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   821
	startFolder.Zero();
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   822
	TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   823
	
107
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   824
	HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_OPML);
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   825
	if (AknCommonDialogsDynMem::RunSelectDlgLD (types, fileName,
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   826
			startFolder, NULL, NULL, *title))
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   827
		{
107
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   828
		
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   829
		if(fileName.Length()>0)
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   830
			{
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   831
			HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_IMPORTING);
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   832
			iOpmlState = EOpmlImporting;
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   833
			ShowWaitDialogL(*waitText);
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   834
			CleanupStack::PopAndDestroy(waitText);	
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   835
107
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   836
			TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(fileName));
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   837
								
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   838
			if (err != KErrNone) {
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   839
				TBuf<KMaxMessageLength> message;
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   840
				iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE);
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   841
				ShowErrorMessageL(message);
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   842
				}
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   843
			}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   844
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   845
		}
107
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   846
	CleanupStack::PopAndDestroy(title);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   847
	}
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
void CPodcastFeedView::HandleExportFeedsL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   850
	{
107
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   851
	TFileName fileName;
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   852
	fileName.Copy(_L("feeds.opml"));
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   853
	TFileName startFolder;
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   854
	startFolder.Zero();
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   855
	TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   856
	
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   857
	HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_FOLDER);
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   858
	if (AknCommonDialogsDynMem::RunSaveDlgLD (types, fileName,
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   859
			startFolder, NULL, NULL, *title))
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   860
		{
107
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   861
			TFileName temp;
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   862
			TRAPD(err, iPodcastModel.FeedEngine().ExportFeedsL(temp));						
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   863
			BaflUtils::CopyFile(iEikonEnv->FsSession(), temp, fileName);
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   864
			BaflUtils::DeleteFile(iEikonEnv->FsSession(),temp);	
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   865
			if (err == KErrNone) 
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   866
				{
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   867
				UpdateListboxItemsL();
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   868
				TInt numFeeds = iPodcastModel.FeedEngine().GetSortedFeeds().Count();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   869
								
107
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   870
				TBuf<KMaxMessageLength> message;
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   871
				TBuf<KMaxMessageLength> templ;
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   872
				iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS);
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   873
				message.Format(templ, numFeeds);
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   874
				ShowOkMessageL(message);
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   875
				} 
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   876
			else 
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   877
				{
107
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   878
				TBuf<KMaxMessageLength> message;
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   879
				iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE);
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   880
				ShowErrorMessageL(message);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   881
				}
107
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   882
		}
af6475fdf8d6 Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
teknolog
parents: 102
diff changeset
   883
	CleanupStack::PopAndDestroy(title);
2
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
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 26
diff changeset
   886
void CPodcastFeedView::CheckResumeDownloadL()
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   887
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   888
	// 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
   889
	RShowInfoArray showsDownloading;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   890
	iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading);
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
	if (showsDownloading.Count() > 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   893
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   894
		TBuf<KMaxMessageLength> msg;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   895
		iEikonEnv->ReadResourceL(msg, R_PODCAST_ENABLE_DOWNLOADS_PROMPT);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   896
	
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 26
diff changeset
   897
		if (ShowQueryMessageL(msg))
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   898
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   899
			// need to suspend downloads before ResumeDownloadL will work :)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   900
			iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   901
			// resume downloading if user says yes
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   902
			iPodcastModel.ShowEngine().ResumeDownloadsL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   903
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   904
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   905
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   906
			// we disable downloading if user says no
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   907
			iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
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
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   910
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   911
	// 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
   912
	showsDownloading.ResetAndDestroy();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   913
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   914
292
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   915
void CPodcastFeedView::CheckConfirmExit()
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   916
	{
302
cf14797d0023 Fix for broken check for active downloads when exiting
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 297
diff changeset
   917
	DP("CPodcastFeedView::CheckConfirmExit");
292
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   918
	RShowInfoArray showsDownloading;
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   919
	iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading);
302
cf14797d0023 Fix for broken check for active downloads when exiting
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 297
diff changeset
   920
	TUint count = showsDownloading.Count();
cf14797d0023 Fix for broken check for active downloads when exiting
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 297
diff changeset
   921
	showsDownloading.ResetAndDestroy();
cf14797d0023 Fix for broken check for active downloads when exiting
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 297
diff changeset
   922
	showsDownloading.Close();
292
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   923
302
cf14797d0023 Fix for broken check for active downloads when exiting
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 297
diff changeset
   924
	if (count > 0 && !iPodcastModel.SettingsEngine().DownloadSuspended())
292
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   925
		{
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   926
		TBuf<256> msg;
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   927
		iEikonEnv->ReadResourceL(msg, R_EXIT_SHOWS_DOWNLOADING);
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   928
		
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   929
		if (!ShowQueryMessageL(msg))
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   930
			{
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   931
			return;
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   932
			}
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   933
		}
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   934
	
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   935
	AppUi()->Exit();
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   936
	}
655dbce90b70 Added check and query when downloading is active while trying to exit
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 272
diff changeset
   937
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   938
void CPodcastFeedView::OpmlParsingComplete(TInt aError, TUint aNumFeedsImported)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   939
	{
117
3b59b88b089e Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents: 115
diff changeset
   940
	TRAP_IGNORE(OpmlParsingCompleteL(aError, aNumFeedsImported));
3b59b88b089e Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents: 115
diff changeset
   941
	}
3b59b88b089e Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents: 115
diff changeset
   942
3b59b88b089e Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents: 115
diff changeset
   943
void CPodcastFeedView::OpmlParsingCompleteL(TInt aError, TUint aNumFeedsImported)
3b59b88b089e Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents: 115
diff changeset
   944
	{
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   945
	DP("CPodcastFeedView::OpmlParsingComplete BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   946
	
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   947
	switch (aError)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   948
		{
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   949
		case KErrCouldNotConnect:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   950
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   951
			TBuf<KMaxMessageLength> message;
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   952
			iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
153
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   953
			delete iWaitDialog;
1d3315159ef5 Fix for bug 3051 - search wait dialog doesn't close if search fails; some extra debugging output added
teknolog
parents: 137
diff changeset
   954
			iOpmlState = EOpmlIdle;
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 26
diff changeset
   955
			ShowErrorMessageL(message);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   956
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   957
			break;
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   958
		case KErrNone: 
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   959
		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
   960
		switch (iOpmlState)
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   961
			{
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   962
			case EOpmlIdle:
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   963
				break;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   964
			case EOpmlImporting:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   965
				{
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   966
				UpdateListboxItemsL();
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   967
				delete iWaitDialog;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   968
				iOpmlState = EOpmlIdle;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   969
					
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   970
				TBuf<KMaxMessageLength> message;
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   971
				TBuf<KMaxMessageLength> templ;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   972
				iEikonEnv->ReadResourceL(templ, R_IMPORT_FEED_SUCCESS);
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   973
				message.Format(templ, aNumFeedsImported);
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   974
				
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 26
diff changeset
   975
				if(ShowQueryMessageL(message))
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   976
					{
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   977
					HandleCommandL(EPodcastUpdateAllFeeds);
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   978
					}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   979
				}
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   980
				break;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   981
			case EOpmlSearching:
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   982
				delete iWaitDialog;
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 26
diff changeset
   983
				iWaitDialog = NULL;
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   984
				if (iPodcastModel.FeedEngine().GetSearchResults().Count() == 0)
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   985
					{
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   986
					TBuf<KMaxMessageLength> message;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   987
					iEikonEnv->ReadResourceL(message, R_SEARCH_NORESULTS);
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 26
diff changeset
   988
					ShowErrorMessageL(message);
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   989
					}
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   990
				else
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   991
					{
302
cf14797d0023 Fix for broken check for active downloads when exiting
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 297
diff changeset
   992
					iToolbar->SetToolbarVisibility(EFalse);
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   993
					AppUi()->ActivateLocalViewL(KUidPodcastSearchViewID,  TUid::Uid(0), KNullDesC8());
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   994
					}
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   995
				iOpmlState = EOpmlIdle;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   996
				break;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   997
			default:
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   998
				break;
a7a43293ae56 Added error handling for searching
teknolog
parents: 5
diff changeset
   999
			}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1000
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1001
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1002
	DP("CPodcastFeedView::OpmlParsingComplete END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1003
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1004
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1005
void CPodcastFeedView::DialogDismissedL(TInt /*aButtonId*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1006
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1007
	iPodcastModel.FeedEngine().CancelUpdateAllFeeds();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
  1008
	}
5
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
  1009
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
  1010
void CPodcastFeedView::GetFeedErrorText(TDes &aErrorMessage, TInt aErrorCode)
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
  1011
	{
117
3b59b88b089e Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents: 115
diff changeset
  1012
	TRAP_IGNORE(((CPodcastAppUi*)AppUi())->GetErrorTextL(aErrorMessage,aErrorCode));
5
ba42cd6670b8 Cleanup of command handling code
teknolog
parents: 2
diff changeset
  1013
	}
8
aab3aa4acdd6 Checked all TRAP_IGNORE
teknolog
parents: 7
diff changeset
  1014
45
56d4e0784e5d Nicer way to handle back from queue view to feed/show view
teknolog
parents: 36
diff changeset
  1015
TBool CPodcastFeedView::ViewingShows()
56d4e0784e5d Nicer way to handle back from queue view to feed/show view
teknolog
parents: 36
diff changeset
  1016
	{
56d4e0784e5d Nicer way to handle back from queue view to feed/show view
teknolog
parents: 36
diff changeset
  1017
	return iViewingShows;
56d4e0784e5d Nicer way to handle back from queue view to feed/show view
teknolog
parents: 36
diff changeset
  1018
	}