engine/src/FeedParser.cpp
author Sebastian Brannstrom <sebastianb@symbian.org>
Fri, 19 Nov 2010 01:47:31 +0000
branchRCL_3
changeset 376 31968c23152c
parent 369 c683165bec63
permissions -rw-r--r--
Merging fixes from Symbian 1
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 "FeedParser.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
#include <f32file.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
#include <bautils.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
#include <s32file.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
#include <charconv.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
#include <xml/stringdictionarycollection.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
#include <utf.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
#include <tinternetdate.h>
258
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
    27
#include <e32hashtab.h>
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
#include "debug.h"
123
50edf2be6f0d Crude video file detection implemented
teknolog
parents: 2
diff changeset
    29
#include "podcastutils.h"
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
using namespace Xml;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
const TInt KMaxParseBuffer = 1024;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
const TInt KMaxStringBuffer = 100;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
CFeedParser::CFeedParser(MFeedParserObserver& aCallbacks, RFs& aFs) : 	iCallbacks(aCallbacks), iRfs(aFs)
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
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
CFeedParser::~CFeedParser()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
{	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
void CFeedParser::ParseFeedL(const TFileName &feedFileName, CFeedInfo *info, TUint aMaxItems)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
	//DP1("ParseFeedL BEGIN: %S", &feedFileName);		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
	_LIT8(KXmlMimeType, "text/xml");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
	// Contruct the parser object
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
	CParser* parser = CParser::NewLC(KXmlMimeType, *this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
	iActiveFeed = info;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
	iFeedState = EStateRoot;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
	iActiveShow = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
	iItemsParsed = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
	iMaxItems = aMaxItems;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
	iStoppedParsing = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
	iEncoding = ELatin1;
376
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
    57
	if (iNewestShow)
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
    58
		delete iNewestShow;
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
    59
	iNewestShow = 0;
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
    60
	
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
    61
	iNewFeed = (iActiveFeed->LastUpdated() == 0) ? ETrue : EFalse;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
342
9441fb8fd60d Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 330
diff changeset
    63
	TEntry entry;
9441fb8fd60d Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 330
diff changeset
    64
	User::LeaveIfError(iRfs.Entry(feedFileName, entry));
9441fb8fd60d Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 330
diff changeset
    65
	iFileSize = entry.iSize;
9441fb8fd60d Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 330
diff changeset
    66
	
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
	ParseL(*parser, iRfs, feedFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
	CleanupStack::PopAndDestroy(parser);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
	//DP("ParseFeedL END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
// from MContentHandler
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
void CFeedParser::OnStartDocumentL(const RDocumentParameters& aDocParam, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
	DP("OnStartDocumentL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
	HBufC* charset = HBufC::NewLC(KMaxParseBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
	charset->Des().Copy(aDocParam.CharacterSetName().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
	iEncoding = EUtf8;
369
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
    81
	iFeedDirection = EFeedUnknown;
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
    82
	iPreviousPubDate = 0;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
	if (charset->CompareF(_L("utf-8")) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
		DP("setting UTF8");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
		iEncoding = EUtf8;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
	} else if (charset->CompareF(_L("ISO-8859-1")) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
		iEncoding = EUtf8; //Latin1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
	} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
		DP1("unknown charset: %S", &charset);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
	CleanupStack::PopAndDestroy(charset);//buffer
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
void CFeedParser::OnEndDocumentL(TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
	//DP("OnEndDocumentL()");
376
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
    97
	if (iNewFeed)
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
    98
		{
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
    99
		// if the feed adds at bottom, this 
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   100
		if (iNewestShow)
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   101
			{
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   102
			iNewestShow->SetPlayState(ENeverPlayed);
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   103
			iCallbacks.ParserShowUpdatedL(*iNewestShow);
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   104
			delete iNewestShow;
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   105
			iNewestShow = 0;
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   106
			}
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   107
		}
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   108
	
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
	iCallbacks.ParsingCompleteL(iActiveFeed);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
void CFeedParser::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   113
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   114
	if (iStoppedParsing) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
		iActiveShow = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   116
		return;
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
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   119
	TBuf<KMaxStringBuffer> str;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   120
	str.Copy(aElement.LocalName().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
	//DP2("OnStartElementL START state=%d, element=%S", iFeedState, &str);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
	iBuffer.Zero();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   123
	switch (iFeedState) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   124
	case EStateRoot:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   125
		// <channel>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   126
		if (str.CompareF(KTagChannel) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   127
			iFeedState = EStateChannel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   128
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   129
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   130
	case EStateChannel:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
		// <channel> <item>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
		if(str.CompareF(KTagItem) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   133
			//DP("New item");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   134
			iFeedState=EStateItem;
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
			iActiveShow = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   137
			iActiveShow = CShowInfo::NewL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   138
			if (iActiveShow == NULL) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   139
				DP("Out of memory!");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   140
				iStoppedParsing = ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   141
				return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   142
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   143
			iActiveShow->SetFeedUid(iActiveFeed->Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   144
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   145
		// <channel> <lastBuildDate>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
		} else if (str.CompareF(KTagLastBuildDate) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   147
			DP("LastBuildDate BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   148
			iFeedState=EStateChannelLastBuildDate;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   149
		// <channel> <link>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   150
		}else if (str.CompareF(KTagTitle) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   151
			iFeedState=EStateChannelTitle;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
		// <channel> <link>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
		} else if (str.CompareF(KTagLink) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
			iFeedState = EStateChannelLink;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
		// <channel> <description>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   156
		} else if (str.CompareF(KTagDescription) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   157
			iFeedState=EStateChannelDescription;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   158
		// <channel> <image>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   159
		} else if (str.CompareF(KTagImage) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   160
			for (int i=0;i<aAttributes.Count();i++) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   161
				RAttribute attr = aAttributes[i];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   162
				TBuf<KMaxStringBuffer> attr16;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   163
				attr16.Copy(attr.Attribute().LocalName().DesC().Left(KMaxStringBuffer));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   164
				HBufC* val16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L(attr.Value().DesC().Left(KMaxParseBuffer));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   165
				CleanupStack::PushL(val16);
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
				// href=...
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   168
				if (attr16.Compare(KTagHref) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   169
					iActiveFeed->SetImageUrlL(*val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   170
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   171
				CleanupStack::PopAndDestroy(val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   172
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   173
					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   174
			iFeedState=EStateChannelImage;
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
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
	case EStateChannelImage:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   178
		// <channel> <image> <url>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   179
		if (str.CompareF(KTagUrl) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
			iFeedState=EStateChannelImageUrl;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   181
		} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   182
			iFeedState=EStateChannelImage;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   183
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   184
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   185
	case EStateItem:
258
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   186
		iUid = 0;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   187
		// <channel> <item> <title>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   188
		if (str.CompareF(KTagTitle) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   189
			iFeedState=EStateItemTitle;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   190
		// <channel> <item> <link>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   191
		} else if (str.CompareF(KTagLink) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   192
			iFeedState=EStateItemLink;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   193
		// <channel> <item> <enclosure ...>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   194
		} else if (str.CompareF(KTagEnclosure) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   195
			//DP("Enclosure START");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   196
			for (int i=0;i<aAttributes.Count();i++) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   197
				RAttribute attr = aAttributes[i];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   198
				TBuf<KMaxStringBuffer> attr16;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   199
				attr16.Copy(attr.Attribute().LocalName().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
				// url=...
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
				if (attr16.Compare(KTagUrl) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
					HBufC* val16 = HBufC::NewLC(KMaxParseBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
					val16->Des().Copy(attr.Value().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
					iActiveShow->SetUrlL(*val16);
123
50edf2be6f0d Crude video file detection implemented
teknolog
parents: 2
diff changeset
   205
					
50edf2be6f0d Crude video file detection implemented
teknolog
parents: 2
diff changeset
   206
					if (PodcastUtils::IsVideoShow(*val16)) {
50edf2be6f0d Crude video file detection implemented
teknolog
parents: 2
diff changeset
   207
						iActiveShow->SetShowType(EVideoPodcast);
50edf2be6f0d Crude video file detection implemented
teknolog
parents: 2
diff changeset
   208
					}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   209
					CleanupStack::PopAndDestroy(val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   210
				// length=...
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
				} else if (attr16.Compare(KTagLength) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   212
					TLex8 lex(attr.Value().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   213
					TUint size = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   214
					lex.Val(size, EDecimal);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
					iActiveShow->SetShowSize(size);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   216
				}
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
		// <channel> <item> <description>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   219
		} else if (str.CompareF(KTagDescription) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   220
			iFeedState=EStateItemDescription;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   221
		// <channel> <item> <pubdate>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   222
		} else if (str.CompareF(KTagPubDate) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   223
			//DP("LastBuildDate BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   224
			iFeedState = EStateItemPubDate;
258
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   225
		// <channel> <item> <guid>
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   226
		} else if (str.CompareF(KTagGuid) == 0) {
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   227
			iFeedState = EStateItemGuid;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   228
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   229
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   230
	default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   231
		//DP2("Ignoring tag %S when in state %d", &str, iFeedState);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   232
		break;
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
//	DP1("OnStartElementL END state=%d", iFeedState);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   235
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   236
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   237
void CFeedParser::OnEndElementL(const RTagInfo& aElement, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   238
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   239
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   240
	if (iStoppedParsing) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   241
		return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   242
	}
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
	iBuffer.Trim();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   245
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   246
	TDesC8 lName = aElement.LocalName().DesC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   247
	TBuf<KMaxStringBuffer> str;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   248
	str.Copy(aElement.LocalName().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   249
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   250
	//DP2("OnEndElementL START state=%d, element=%S", iFeedState, &str);
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
	switch (iFeedState) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   253
		case EStateChannelTitle:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   254
			if(str.CompareF(KTagTitle) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   255
				if (iActiveFeed->CustomTitle() == EFalse) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   256
					iActiveFeed->SetTitleL(iBuffer);
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
				iFeedState = EStateChannel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   259
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   260
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   261
		case EStateChannelLink:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   262
			iActiveFeed->SetLinkL(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   263
			iFeedState = EStateChannel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   264
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   265
		case EStateChannelDescription:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   266
			iActiveFeed->SetDescriptionL(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   267
			iFeedState = EStateChannel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   268
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   269
		case EStateChannelLastBuildDate:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   270
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   271
			//DP("LastBuildDate END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   272
			TInternetDate internetDate;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   273
			TBuf8<128> temp;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   274
			temp.Copy(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   275
					
342
9441fb8fd60d Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 330
diff changeset
   276
			DP2("iFileSize=%d, iActiveFeed->FeedFileSize()=%d", iFileSize, iActiveFeed->FeedFileSize());
9441fb8fd60d Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 330
diff changeset
   277
					
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   278
			TRAPD(parseError, internetDate.SetDateL(temp));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   279
			if(parseError == KErrNone) {				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   280
				if (TTime(internetDate.DateTime()) > iActiveFeed->BuildDate()) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   281
					DP("Successfully parsed build date");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   282
					iActiveFeed->SetBuildDate(TTime(internetDate.DateTime()));
342
9441fb8fd60d Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 330
diff changeset
   283
				} else if (iFileSize == iActiveFeed->FeedFileSize()){
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   284
					DP("*** Nothing new, aborting parsing");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   285
					iStoppedParsing = ETrue;
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
			} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   288
				DP("Failed to parse last build date");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   289
			}
342
9441fb8fd60d Fix for bug 2780 - we now compare file sizes as well as lastPubDate to tell if a feed is updated
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 330
diff changeset
   290
			iActiveFeed->SetFeedFileSize(iFileSize);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   291
			iFeedState = EStateChannel;
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
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   294
		case EStateChannelImageUrl:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   295
			//DP1("Image url: %S", &iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   296
			iActiveFeed->SetImageUrlL(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   297
			iFeedState = EStateChannelImage;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   298
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   299
		case EStateChannelImage:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   300
			if(str.CompareF(KTagImage) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   301
				iFeedState = EStateChannel;
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
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   304
		case EStateItem:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   305
			if (str.CompareF(KTagItem) == 0) 
254
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   306
				{
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   307
				// check if we have a valid pubdate
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   308
				if (iActiveShow->PubDate().Int64() == 0)
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   309
					{
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   310
					// set pubDate to present time
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   311
					TTime now;
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   312
					now.UniversalTime();
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   313
					
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   314
					// but we want reverse sorting, so let's do a little trick...
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   315
					TTimeIntervalHours delta;
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   316
					delta = iItemsParsed;
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   317
					
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   318
					// ... remove an hour per show we've parsed so far
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   319
					now -= delta;
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   320
					
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   321
					iActiveShow->SetPubDate(now);
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   322
					}
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   323
				
369
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   324
				if (iFeedDirection == EFeedUnknown)
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   325
					{
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   326
					if (iPreviousPubDate.Int64() != 0) {
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   327
						if (iActiveShow->PubDate() > iPreviousPubDate)
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   328
							{
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   329
							DP("Feed adds at bottom");
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   330
							iFeedDirection = EFeedAddsAtBottom;
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   331
							}
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   332
						else
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   333
							{
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   334
							DP("Feed adds at top");
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   335
							iFeedDirection = EFeedAddsAtTop;
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   336
							}
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   337
					}
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   338
					iPreviousPubDate = iActiveShow->PubDate();
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   339
					}
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   340
				
258
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   341
				if (iUid)
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   342
					{
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   343
					iActiveShow->SetUid(iUid);
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   344
					}
376
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   345
				
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   346
				if (iNewFeed)
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   347
					{
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   348
					// set all played, except for the newest one
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   349
					iActiveShow->SetPlayState(EPlayed);
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   350
					
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   351
					if (!iNewestShow || iActiveShow->PubDate() > iNewestShow->PubDate())
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   352
						{
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   353
						if (iNewestShow)
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   354
							delete iNewestShow;
254
042bb9038b32 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 126
diff changeset
   355
						
376
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   356
						iNewestShow = new CShowInfo(iActiveShow);
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   357
						}
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   358
					}
31968c23152c Merging fixes from Symbian 1
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 369
diff changeset
   359
					
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   360
				iCallbacks.NewShowL(*iActiveShow);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   361
				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   362
				delete iActiveShow;				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   363
				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   364
				// We should now be finished with the show.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   365
				iActiveShow = NULL;
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
				iItemsParsed++;
126
c2f1ea38ec70 Import from FCL default branch
teknolog
parents: 123
diff changeset
   368
				DP2("iItemsParsed: %d, iMaxItems: %d", iItemsParsed, iMaxItems);
369
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   369
				// we stop parsing after iMaxItems, but not if feed builds at bottom
c683165bec63 More catchup with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 342
diff changeset
   370
				if (iItemsParsed >= iMaxItems && iFeedDirection != EFeedAddsAtBottom) 
321
7a0fb290f9c6 Re-enabled max items parsed, because disabling this causes shows to turn up as new multiple times. This again breaks feeds that add new shows at the bottom, so we need to solve this properly.
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 258
diff changeset
   371
					{
7a0fb290f9c6 Re-enabled max items parsed, because disabling this causes shows to turn up as new multiple times. This again breaks feeds that add new shows at the bottom, so we need to solve this properly.
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 258
diff changeset
   372
					iStoppedParsing = ETrue;
7a0fb290f9c6 Re-enabled max items parsed, because disabling this causes shows to turn up as new multiple times. This again breaks feeds that add new shows at the bottom, so we need to solve this properly.
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 258
diff changeset
   373
					DP("*** Too many items, aborting parsing");
7a0fb290f9c6 Re-enabled max items parsed, because disabling this causes shows to turn up as new multiple times. This again breaks feeds that add new shows at the bottom, so we need to solve this properly.
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 258
diff changeset
   374
					}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   375
				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   376
				iFeedState=EStateChannel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   377
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   378
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   379
		case EStateItemPubDate:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   380
			DP1("PubDate END: iBuffer='%S'", &iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   381
			if (str.CompareF(KTagPubDate) == 0) {
330
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   382
				DP1("iBuffer.Length()=%d", iBuffer.Length());
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   383
				
330
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   384
				if (iBuffer.Length() > 6)
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   385
					{
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   386
					// hack for feeds that don't always write day as two digits
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   387
					TChar five(iBuffer[5]);
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   388
					TChar six(iBuffer[6]);
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   389
					
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   390
					if (five.IsDigit() && !six.IsDigit()) {
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   391
						TBuf<KMaxStringBuffer> fix;
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   392
						fix.Copy(iBuffer.Left(4));
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   393
						fix.Append(_L(" 0"));
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   394
						fix.Append(iBuffer.Mid(5));
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   395
						iBuffer.Copy(fix);
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   396
					}
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   397
					// end hack
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   398
					}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   399
				
330
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   400
				if (iBuffer.Length() > 11)
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   401
					{
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   402
					// hack for feeds that write out months in full
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   403
					
330
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   404
					if (iBuffer[11] != ' ') {
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   405
						TPtrC midPtr = iBuffer.Mid(8);
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   406
						
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   407
						int spacePos = midPtr.Find(_L(" "));
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   408
						
330
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   409
						if (spacePos != KErrNotFound) {
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   410
							//DP1("Month: %S", &midPtr.Left(spacePos));
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   411
							
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   412
							TBuf16<KBufferLength> newBuffer;
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   413
							newBuffer.Copy(iBuffer.Left(11));
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   414
							newBuffer.Append(_L(" "));
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   415
							newBuffer.Append(iBuffer.Mid(11+spacePos));
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   416
							//DP1("newBuffer: %S", &newBuffer);
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   417
							iBuffer.Copy(newBuffer);
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   418
						}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   419
					}
330
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   420
					
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   421
					// hack for feeds that write days and months as UPPERCASE
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   422
					TChar one(iBuffer[1]);
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   423
					TChar two(iBuffer[2]);
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   424
					TChar nine(iBuffer[9]);
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   425
					TChar ten(iBuffer[10]);
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   426
	
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   427
					one.LowerCase();
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   428
					two.LowerCase();
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   429
					nine.LowerCase();
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   430
					ten.LowerCase();
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   431
					
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   432
					iBuffer[1] = one;
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   433
					iBuffer[2] = two;
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   434
					iBuffer[9] = nine;
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   435
					iBuffer[10] = ten;
4cf89a7d3476 Fix for bug 3911 - Podcatcher still crashes when trying to update some feeds
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 321
diff changeset
   436
					}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   437
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   438
				TBuf8<128> temp;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   439
				temp.Copy(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   440
				TInternetDate internetDate;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   441
				TRAPD(parseError, internetDate.SetDateL(temp));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   442
				if(parseError == KErrNone) {				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   443
					//DP1("PubDate parse success: '%S'", &iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   444
					iActiveShow->SetPubDate(TTime(internetDate.DateTime()));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   445
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   446
					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   447
					DP6("Successfully parsed pubdate %d/%d/%d %d:%d:%d",
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   448
							iActiveShow->PubDate().DateTime().Year(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   449
							iActiveShow->PubDate().DateTime().Month(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   450
							iActiveShow->PubDate().DateTime().Day(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   451
							iActiveShow->PubDate().DateTime().Hour(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   452
							iActiveShow->PubDate().DateTime().Minute(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   453
							iActiveShow->PubDate().DateTime().Second());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   454
							
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   455
				} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   456
					DP2("Pubdate parse error: '%S', error=%d", &iBuffer, parseError);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   457
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   458
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   459
			iFeedState=EStateItem;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   460
			break;
258
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   461
		case EStateItemGuid:
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   462
			iUid = DefaultHash::Des16(iBuffer);
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   463
			iFeedState=EStateItem;
f02d87cb8d1f Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 255
diff changeset
   464
			break;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   465
		case EStateItemTitle:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   466
			//DP1("title: %S", &iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   467
			iActiveShow->SetTitleL(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   468
			iFeedState = EStateItem;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   469
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   470
		case EStateItemLink:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   471
			if (iActiveShow->Url().Length() == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   472
				iActiveShow->SetUrlL(iBuffer);
123
50edf2be6f0d Crude video file detection implemented
teknolog
parents: 2
diff changeset
   473
				
50edf2be6f0d Crude video file detection implemented
teknolog
parents: 2
diff changeset
   474
				if (PodcastUtils::IsVideoShow(iBuffer)) {
50edf2be6f0d Crude video file detection implemented
teknolog
parents: 2
diff changeset
   475
					iActiveShow->SetShowType(EVideoPodcast);
50edf2be6f0d Crude video file detection implemented
teknolog
parents: 2
diff changeset
   476
				}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   477
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   478
			iFeedState = EStateItem;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   479
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   480
		case EStateItemDescription:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   481
			iActiveShow->SetDescriptionL(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   482
			iFeedState = EStateItem;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   483
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   484
		default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   485
			// fall back to channel level when in doubt
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   486
			iFeedState = EStateChannel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   487
			//DP2("Don't know how to handle end tag %S when in state %d", &str, iFeedState);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   488
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   489
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   490
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   491
	//DP1("OnEndElementL END state=%d", iFeedState);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   492
	}
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
void CFeedParser::OnContentL(const TDesC8& aBytes, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   495
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   496
	TBuf<KBufferLength> temp;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   497
	if (iEncoding == EUtf8) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   498
		CnvUtfConverter::ConvertToUnicodeFromUtf8(temp, aBytes);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   499
	} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   500
		temp.Copy(aBytes);
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
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   503
	if(temp.Length() + iBuffer.Length() < KBufferLength) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   504
		iBuffer.Append(temp);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   505
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   506
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   507
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   508
void CFeedParser::OnStartPrefixMappingL(const RString& /*aPrefix*/, const RString& /*aUri*/, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   509
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   510
	DP("OnStartPrefixMappingL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   511
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   512
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   513
void CFeedParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   514
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   515
	DP("OnEndPrefixMappingL()");
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
void CFeedParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   519
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   520
	DP("OnIgnorableWhiteSpaceL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   521
	}
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 CFeedParser::OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   524
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   525
	DP("OnSkippedEntityL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   526
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   527
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   528
void CFeedParser::OnProcessingInstructionL(const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   529
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   530
	DP("OnProcessingInstructionL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   531
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   532
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   533
void CFeedParser::OnError(TInt aErrorCode)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   534
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   535
	DP1("CFeedParser::OnError %d", aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   536
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   537
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   538
TAny* CFeedParser::GetExtendedInterface(const TInt32 /*aUid*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   539
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   540
	DP("GetExtendedInterface()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   541
	return NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   542
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   543
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   544
CFeedInfo& CFeedParser::ActiveFeed()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   545
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   546
		return *iActiveFeed;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   547
	}