engine/src/FeedParser.cpp
author Sebastian Brannstrom <sebastianb@symbian.org>
Tue, 16 Nov 2010 11:34:24 +0000
branchsymbian1
changeset 365 3317b29a19f1
parent 340 37610dda6102
child 374 f067cee22e48
permissions -rw-r--r--
Bug 3912 - better support for feeds that add shows at the bottom
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>
247
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
    27
#include <e32hashtab.h>
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
#include "debug.h"
60
4d230e702aa3 Moved development branch from MCL to FCL
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;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
340
37610dda6102 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: 336
diff changeset
    58
	TEntry entry;
37610dda6102 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: 336
diff changeset
    59
	User::LeaveIfError(iRfs.Entry(feedFileName, entry));
37610dda6102 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: 336
diff changeset
    60
	iFileSize = entry.iSize;
37610dda6102 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: 336
diff changeset
    61
	
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
	ParseL(*parser, iRfs, feedFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
	CleanupStack::PopAndDestroy(parser);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
	//DP("ParseFeedL END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
	}
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
// from MContentHandler
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
void CFeedParser::OnStartDocumentL(const RDocumentParameters& aDocParam, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
	DP("OnStartDocumentL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
	HBufC* charset = HBufC::NewLC(KMaxParseBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
	charset->Des().Copy(aDocParam.CharacterSetName().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
	iEncoding = EUtf8;
365
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
    76
	iFeedDirection = EFeedUnknown;
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
    77
	iPreviousPubDate = 0;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
	if (charset->CompareF(_L("utf-8")) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
		DP("setting UTF8");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
		iEncoding = EUtf8;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
	} else if (charset->CompareF(_L("ISO-8859-1")) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
		iEncoding = EUtf8; //Latin1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
	} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
		DP1("unknown charset: %S", &charset);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
	CleanupStack::PopAndDestroy(charset);//buffer
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
void CFeedParser::OnEndDocumentL(TInt /*aErrorCode*/)
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
	//DP("OnEndDocumentL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
	iCallbacks.ParsingCompleteL(iActiveFeed);
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
void CFeedParser::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
	if (iStoppedParsing) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
		iActiveShow = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
		return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
	TBuf<KMaxStringBuffer> str;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
	str.Copy(aElement.LocalName().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
	//DP2("OnStartElementL START state=%d, element=%S", iFeedState, &str);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
	iBuffer.Zero();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
	switch (iFeedState) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
	case EStateRoot:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
		// <channel>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
		if (str.CompareF(KTagChannel) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
			iFeedState = EStateChannel;
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
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   113
	case EStateChannel:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   114
		// <channel> <item>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
		if(str.CompareF(KTagItem) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   116
			//DP("New item");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   117
			iFeedState=EStateItem;
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
			iActiveShow = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   120
			iActiveShow = CShowInfo::NewL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
			if (iActiveShow == NULL) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
				DP("Out of memory!");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   123
				iStoppedParsing = ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   124
				return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   125
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   126
			iActiveShow->SetFeedUid(iActiveFeed->Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   127
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   128
		// <channel> <lastBuildDate>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   129
		} else if (str.CompareF(KTagLastBuildDate) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   130
			DP("LastBuildDate BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
			iFeedState=EStateChannelLastBuildDate;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
		// <channel> <link>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   133
		}else if (str.CompareF(KTagTitle) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   134
			iFeedState=EStateChannelTitle;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   135
		// <channel> <link>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   136
		} else if (str.CompareF(KTagLink) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   137
			iFeedState = EStateChannelLink;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   138
		// <channel> <description>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   139
		} else if (str.CompareF(KTagDescription) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   140
			iFeedState=EStateChannelDescription;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   141
		// <channel> <image>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   142
		} else if (str.CompareF(KTagImage) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   143
			for (int i=0;i<aAttributes.Count();i++) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   144
				RAttribute attr = aAttributes[i];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   145
				TBuf<KMaxStringBuffer> attr16;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
				attr16.Copy(attr.Attribute().LocalName().DesC().Left(KMaxStringBuffer));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   147
				HBufC* val16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L(attr.Value().DesC().Left(KMaxParseBuffer));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   148
				CleanupStack::PushL(val16);
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
				// href=...
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   151
				if (attr16.Compare(KTagHref) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
					iActiveFeed->SetImageUrlL(*val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
				CleanupStack::PopAndDestroy(val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   156
					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   157
			iFeedState=EStateChannelImage;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   158
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   159
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   160
	case EStateChannelImage:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   161
		// <channel> <image> <url>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   162
		if (str.CompareF(KTagUrl) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   163
			iFeedState=EStateChannelImageUrl;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   164
		} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   165
			iFeedState=EStateChannelImage;
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
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   168
	case EStateItem:
247
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   169
		iUid = 0;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   170
		// <channel> <item> <title>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   171
		if (str.CompareF(KTagTitle) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   172
			iFeedState=EStateItemTitle;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   173
		// <channel> <item> <link>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   174
		} else if (str.CompareF(KTagLink) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   175
			iFeedState=EStateItemLink;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   176
		// <channel> <item> <enclosure ...>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
		} else if (str.CompareF(KTagEnclosure) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   178
			//DP("Enclosure START");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   179
			for (int i=0;i<aAttributes.Count();i++) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
				RAttribute attr = aAttributes[i];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   181
				TBuf<KMaxStringBuffer> attr16;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   182
				attr16.Copy(attr.Attribute().LocalName().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   183
				// url=...
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   184
				if (attr16.Compare(KTagUrl) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   185
					HBufC* val16 = HBufC::NewLC(KMaxParseBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   186
					val16->Des().Copy(attr.Value().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   187
					iActiveShow->SetUrlL(*val16);
60
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 2
diff changeset
   188
					
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 2
diff changeset
   189
					if (PodcastUtils::IsVideoShow(*val16)) {
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 2
diff changeset
   190
						iActiveShow->SetShowType(EVideoPodcast);
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 2
diff changeset
   191
					}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   192
					CleanupStack::PopAndDestroy(val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   193
				// length=...
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   194
				} else if (attr16.Compare(KTagLength) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   195
					TLex8 lex(attr.Value().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   196
					TUint size = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   197
					lex.Val(size, EDecimal);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   198
					iActiveShow->SetShowSize(size);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   199
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
		// <channel> <item> <description>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
		} else if (str.CompareF(KTagDescription) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
			iFeedState=EStateItemDescription;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
		// <channel> <item> <pubdate>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   205
		} else if (str.CompareF(KTagPubDate) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   206
			//DP("LastBuildDate BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   207
			iFeedState = EStateItemPubDate;
247
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   208
		// <channel> <item> <guid>
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   209
		} else if (str.CompareF(KTagGuid) == 0) {
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   210
			iFeedState = EStateItemGuid;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   212
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   213
	default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   214
		//DP2("Ignoring tag %S when in state %d", &str, iFeedState);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
		break;
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
//	DP1("OnStartElementL END state=%d", iFeedState);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   218
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   219
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   220
void CFeedParser::OnEndElementL(const RTagInfo& aElement, TInt /*aErrorCode*/)
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
	if (iStoppedParsing) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   224
		return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   225
	}
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
	iBuffer.Trim();
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
	TDesC8 lName = aElement.LocalName().DesC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   230
	TBuf<KMaxStringBuffer> str;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   231
	str.Copy(aElement.LocalName().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   232
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   233
	//DP2("OnEndElementL START state=%d, element=%S", iFeedState, &str);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   234
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   235
	switch (iFeedState) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   236
		case EStateChannelTitle:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   237
			if(str.CompareF(KTagTitle) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   238
				if (iActiveFeed->CustomTitle() == EFalse) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   239
					iActiveFeed->SetTitleL(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   240
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   241
				iFeedState = EStateChannel;
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
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   244
		case EStateChannelLink:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   245
			iActiveFeed->SetLinkL(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   246
			iFeedState = EStateChannel;
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
		case EStateChannelDescription:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   249
			iActiveFeed->SetDescriptionL(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   250
			iFeedState = EStateChannel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   251
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   252
		case EStateChannelLastBuildDate:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   253
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   254
			//DP("LastBuildDate END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   255
			TInternetDate internetDate;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   256
			TBuf8<128> temp;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   257
			temp.Copy(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   258
					
340
37610dda6102 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: 336
diff changeset
   259
			DP2("iFileSize=%d, iActiveFeed->FeedFileSize()=%d", iFileSize, iActiveFeed->FeedFileSize());
37610dda6102 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: 336
diff changeset
   260
					
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   261
			TRAPD(parseError, internetDate.SetDateL(temp));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   262
			if(parseError == KErrNone) {				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   263
				if (TTime(internetDate.DateTime()) > iActiveFeed->BuildDate()) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   264
					DP("Successfully parsed build date");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   265
					iActiveFeed->SetBuildDate(TTime(internetDate.DateTime()));
340
37610dda6102 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: 336
diff changeset
   266
				} else if (iFileSize == iActiveFeed->FeedFileSize()){
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   267
					DP("*** Nothing new, aborting parsing");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   268
					iStoppedParsing = ETrue;
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
			} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   271
				DP("Failed to parse last build date");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   272
			}
340
37610dda6102 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: 336
diff changeset
   273
			iActiveFeed->SetFeedFileSize(iFileSize);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   274
			iFeedState = EStateChannel;
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
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   277
		case EStateChannelImageUrl:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   278
			//DP1("Image url: %S", &iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   279
			iActiveFeed->SetImageUrlL(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   280
			iFeedState = EStateChannelImage;
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
		case EStateChannelImage:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   283
			if(str.CompareF(KTagImage) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   284
				iFeedState = EStateChannel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   285
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   286
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   287
		case EStateItem:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   288
			if (str.CompareF(KTagItem) == 0) 
242
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   289
				{
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   290
				// check if we have a valid pubdate
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   291
				if (iActiveShow->PubDate().Int64() == 0)
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   292
					{
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   293
					// set pubDate to present time
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   294
					TTime now;
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   295
					now.UniversalTime();
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   296
					
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   297
					// but we want reverse sorting, so let's do a little trick...
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   298
					TTimeIntervalHours delta;
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   299
					delta = iItemsParsed;
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   300
					
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   301
					// ... remove an hour per show we've parsed so far
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   302
					now -= delta;
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   303
					
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   304
					iActiveShow->SetPubDate(now);
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   305
					}
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   306
				
365
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   307
				if (iFeedDirection == EFeedUnknown)
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   308
					{
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   309
					if (iPreviousPubDate.Int64() != 0) {
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   310
						if (iActiveShow->PubDate() > iPreviousPubDate)
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   311
							{
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   312
							DP("Feed adds at bottom");
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   313
							iFeedDirection = EFeedAddsAtBottom;
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   314
							}
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   315
						else
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   316
							{
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   317
							DP("Feed adds at top");
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   318
							iFeedDirection = EFeedAddsAtTop;
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   319
							}
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   320
					}
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   321
					iPreviousPubDate = iActiveShow->PubDate();
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   322
					}
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   323
				
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   324
				
247
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   325
				if (iUid)
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   326
					{
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   327
					iActiveShow->SetUid(iUid);
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   328
					}
242
64a2995a3e08 Fix for bug 3540 - show sorting when pubDate is not set in feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 88
diff changeset
   329
						
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   330
				iCallbacks.NewShowL(*iActiveShow);
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
				delete iActiveShow;				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   333
				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   334
				// We should now be finished with the show.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   335
				iActiveShow = NULL;
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
				iItemsParsed++;
88
f4b512d870e8 Moved call to DeleteOldShowsByFeedL to when a feed is listed. This prevents a race condition which likely caused
teknolog
parents: 60
diff changeset
   338
				DP2("iItemsParsed: %d, iMaxItems: %d", iItemsParsed, iMaxItems);
365
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   339
				// we stop parsing after iMaxItems, but not if feed builds at bottom
3317b29a19f1 Bug 3912 - better support for feeds that add shows at the bottom
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 340
diff changeset
   340
				if (iItemsParsed >= iMaxItems && iFeedDirection != EFeedAddsAtBottom) 
336
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   341
					{
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   342
					iStoppedParsing = ETrue;
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   343
					DP("*** Too many items, aborting parsing");
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   344
					}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   345
				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   346
				iFeedState=EStateChannel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   347
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   348
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   349
		case EStateItemPubDate:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   350
			DP1("PubDate END: iBuffer='%S'", &iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   351
			if (str.CompareF(KTagPubDate) == 0) {
336
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   352
				DP1("iBuffer.Length()=%d", iBuffer.Length());
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   353
				
336
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   354
				if (iBuffer.Length() > 6)
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   355
					{
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   356
					// hack for feeds that don't always write day as two digits
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   357
					TChar five(iBuffer[5]);
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   358
					TChar six(iBuffer[6]);
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   359
					
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   360
					if (five.IsDigit() && !six.IsDigit()) {
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   361
						TBuf<KMaxStringBuffer> fix;
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   362
						fix.Copy(iBuffer.Left(4));
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   363
						fix.Append(_L(" 0"));
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   364
						fix.Append(iBuffer.Mid(5));
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   365
						iBuffer.Copy(fix);
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   366
					}
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   367
					// end hack
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   368
					}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   369
				
336
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   370
				if (iBuffer.Length() > 11)
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   371
					{
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   372
					// hack for feeds that write out months in full
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   373
					
336
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   374
					if (iBuffer[11] != ' ') {
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   375
						TPtrC midPtr = iBuffer.Mid(8);
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   376
						
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   377
						int spacePos = midPtr.Find(_L(" "));
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   378
						
336
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   379
						if (spacePos != KErrNotFound) {
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   380
							//DP1("Month: %S", &midPtr.Left(spacePos));
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   381
							
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   382
							TBuf16<KBufferLength> newBuffer;
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   383
							newBuffer.Copy(iBuffer.Left(11));
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   384
							newBuffer.Append(_L(" "));
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   385
							newBuffer.Append(iBuffer.Mid(11+spacePos));
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   386
							//DP1("newBuffer: %S", &newBuffer);
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   387
							iBuffer.Copy(newBuffer);
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   388
						}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   389
					}
336
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   390
					
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   391
					// hack for feeds that write days and months as UPPERCASE
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   392
					TChar one(iBuffer[1]);
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   393
					TChar two(iBuffer[2]);
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   394
					TChar nine(iBuffer[9]);
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   395
					TChar ten(iBuffer[10]);
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   396
	
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   397
					one.LowerCase();
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   398
					two.LowerCase();
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   399
					nine.LowerCase();
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   400
					ten.LowerCase();
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   401
					
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   402
					iBuffer[1] = one;
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   403
					iBuffer[2] = two;
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   404
					iBuffer[9] = nine;
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   405
					iBuffer[10] = ten;
3d6c1417e8bd Merged all the later Symbian3 updates into Symbian1 branch; new SIS v. 1.00.32
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 247
diff changeset
   406
					}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   407
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   408
				TBuf8<128> temp;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   409
				temp.Copy(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   410
				TInternetDate internetDate;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   411
				TRAPD(parseError, internetDate.SetDateL(temp));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   412
				if(parseError == KErrNone) {				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   413
					//DP1("PubDate parse success: '%S'", &iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   414
					iActiveShow->SetPubDate(TTime(internetDate.DateTime()));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   415
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   416
					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   417
					DP6("Successfully parsed pubdate %d/%d/%d %d:%d:%d",
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   418
							iActiveShow->PubDate().DateTime().Year(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   419
							iActiveShow->PubDate().DateTime().Month(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   420
							iActiveShow->PubDate().DateTime().Day(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   421
							iActiveShow->PubDate().DateTime().Hour(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   422
							iActiveShow->PubDate().DateTime().Minute(),
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   423
							iActiveShow->PubDate().DateTime().Second());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   424
							
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   425
				} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   426
					DP2("Pubdate parse error: '%S', error=%d", &iBuffer, parseError);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   427
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   428
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   429
			iFeedState=EStateItem;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   430
			break;
247
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   431
		case EStateItemGuid:
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   432
			iUid = DefaultHash::Des16(iBuffer);
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   433
			iFeedState=EStateItem;
60621d146c19 Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 244
diff changeset
   434
			break;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   435
		case EStateItemTitle:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   436
			//DP1("title: %S", &iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   437
			iActiveShow->SetTitleL(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   438
			iFeedState = EStateItem;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   439
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   440
		case EStateItemLink:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   441
			if (iActiveShow->Url().Length() == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   442
				iActiveShow->SetUrlL(iBuffer);
60
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 2
diff changeset
   443
				
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 2
diff changeset
   444
				if (PodcastUtils::IsVideoShow(iBuffer)) {
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 2
diff changeset
   445
					iActiveShow->SetShowType(EVideoPodcast);
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 2
diff changeset
   446
				}
2
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
			iFeedState = EStateItem;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   449
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   450
		case EStateItemDescription:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   451
			iActiveShow->SetDescriptionL(iBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   452
			iFeedState = EStateItem;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   453
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   454
		default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   455
			// fall back to channel level when in doubt
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   456
			iFeedState = EStateChannel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   457
			//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
   458
			break;
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
	//DP1("OnEndElementL END state=%d", iFeedState);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   462
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   463
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   464
void CFeedParser::OnContentL(const TDesC8& aBytes, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   465
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   466
	TBuf<KBufferLength> temp;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   467
	if (iEncoding == EUtf8) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   468
		CnvUtfConverter::ConvertToUnicodeFromUtf8(temp, aBytes);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   469
	} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   470
		temp.Copy(aBytes);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   471
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   472
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   473
	if(temp.Length() + iBuffer.Length() < KBufferLength) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   474
		iBuffer.Append(temp);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   475
	}
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   478
void CFeedParser::OnStartPrefixMappingL(const RString& /*aPrefix*/, const RString& /*aUri*/, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   479
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   480
	DP("OnStartPrefixMappingL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   481
	}
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
void CFeedParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   484
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   485
	DP("OnEndPrefixMappingL()");
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   488
void CFeedParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
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
	DP("OnIgnorableWhiteSpaceL()");
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   493
void CFeedParser::OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   494
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   495
	DP("OnSkippedEntityL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   496
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   497
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   498
void CFeedParser::OnProcessingInstructionL(const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, TInt /*aErrorCode*/)
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
	DP("OnProcessingInstructionL()");
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
void CFeedParser::OnError(TInt aErrorCode)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   504
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   505
	DP1("CFeedParser::OnError %d", aErrorCode);
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
TAny* CFeedParser::GetExtendedInterface(const TInt32 /*aUid*/)
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("GetExtendedInterface()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   511
	return NULL;
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   514
CFeedInfo& CFeedParser::ActiveFeed()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   515
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   516
		return *iActiveFeed;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   517
	}