engine/src/OpmlParser.cpp
author teknolog
Tue, 27 Apr 2010 19:26:48 +0100
changeset 60 4d230e702aa3
parent 20 c92d8384952c
child 65 bcd88ba95046
permissions -rw-r--r--
Moved development branch from MCL to FCL
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 "OpmlParser.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
#include "debug.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
#include <f32file.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
#include <bautils.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
#include <s32file.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
#include <charconv.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
#include <xml/stringdictionarycollection.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
#include <utf.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    27
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
using namespace Xml;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
const TInt KMaxParseBuffer = 2048;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
const TInt KMaxStringBuffer = 1024;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
COpmlParser::COpmlParser(CFeedEngine& aFeedEngine, RFs& aFs) : iFeedEngine(aFeedEngine),iFs(aFs)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
{	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
}
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
COpmlParser::~COpmlParser()
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
void COpmlParser::ParseOpmlL(const TFileName &feedFileName, TBool aSearching)
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
	DP1("ParseOpmlL BEGIN: %S", &feedFileName);
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
	iSearching = aSearching;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
	_LIT8(KXmlMimeType, "text/xml");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
	// Contruct the parser object
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
	CParser* parser = CParser::NewLC(KXmlMimeType, *this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
	iOpmlState = EStateOpmlRoot;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
	iEncoding = EUtf8;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
	iNumFeedsAdded = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
	ParseL(*parser, iFs, feedFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
	CleanupStack::PopAndDestroy(parser);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
	//DP("ParseFeedL END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
// from MContentHandler
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
void COpmlParser::OnStartDocumentL(const RDocumentParameters& aDocParam, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
	DP("OnStartDocumentL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
	HBufC* charset = HBufC::NewLC(KMaxParseBuffer);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
	charset->Des().Copy(aDocParam.CharacterSetName().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
	iEncoding = EUtf8;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
	if (charset->CompareF(_L("utf-8")) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
		DP("setting UTF8");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
		iEncoding = EUtf8;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
	} else if (charset->CompareF(_L("ISO-8859-1")) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
		iEncoding = EUtf8; //Latin1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
	} else {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
		DP1("unknown charset: %S", &charset);
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
	CleanupStack::PopAndDestroy(charset);
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
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 2
diff changeset
    74
void COpmlParser::OnEndDocumentL(TInt aErrorCode)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
	{
60
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
    76
	iFeedEngine.OpmlParsingCompleteL(aErrorCode, iNumFeedsAdded);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
	//DP("OnEndDocumentL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
void COpmlParser::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
	TBuf<KMaxStringBuffer> str;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
	str.Copy(aElement.LocalName().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
	DP2("OnStartElementL START state=%d, element=%S", iOpmlState, &str);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
	iBuffer.Zero();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
	switch (iOpmlState) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
	case EStateOpmlRoot:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
		// <body>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
		if (str.CompareF(KTagBody) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
			iOpmlState = EStateOpmlBody;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
	case EStateOpmlBody:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
		// <body> <outline>
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
		if(str.CompareF(KTagOutline) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
			iOpmlState = EStateOpmlOutline;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
		}
60
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
    99
		
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   100
		// there are two variations on OPML, where the <outline> tags sit either
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   101
		// directly below <body>, or inside a collective <body> <outline>
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   102
		// by checking if the <body> <outline> has arguments, we can support both
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   103
		// by falling through to the nextstate
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   104
		if (aAttributes.Count() == 0)
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   105
			{
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   106
			break;
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   107
			}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
	case EStateOpmlOutline:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
		// <body> <outline> <outline...
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
		if(str.CompareF(KTagOutline) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
			iOpmlState=EStateOpmlOutlineOutline;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
			CFeedInfo* newFeed = CFeedInfo::NewLC();
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
			TBool hasTitle = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
			TBool hasUrl = EFalse;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   116
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   117
			for (int i=0;i<aAttributes.Count();i++) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   118
				RAttribute attr = aAttributes[i];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   119
				TBuf<KMaxStringBuffer> attr16;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   120
				attr16.Copy(attr.Attribute().LocalName().DesC().Left(KMaxStringBuffer));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
				HBufC* val16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
						attr.Value().DesC().Left(KMaxParseBuffer));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   123
				CleanupStack::PushL(val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   124
				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   125
				// xmlUrl=...
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   126
				if (attr16.Compare(KTagXmlUrl) == 0 || attr16.Compare(KTagUrl) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   127
					newFeed->SetUrlL(*val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   128
					hasUrl = ETrue;			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   129
				// htmlUrl
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   130
				} else if (attr16.Compare(KTagHtmlUrl) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
					newFeed->SetLinkL(*val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
					hasUrl = ETrue;
60
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   133
				// title=...
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   134
				} else if (attr16.Compare(KTagTitle) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   135
					newFeed->SetTitleL(*val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   136
					hasTitle = ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   137
				// description=
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   138
				} else if (attr16.Compare(KTagDescription) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   139
					newFeed->SetDescriptionL(*val16);
60
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   140
				// text=
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   141
				} else if (attr16.Compare(KTagText) == 0) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   142
					if (!hasTitle) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   143
						newFeed->SetTitleL(*val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   144
						hasTitle = ETrue;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   145
					}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
				} 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   147
				CleanupStack::PopAndDestroy(val16);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   148
			}
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
			if (!hasUrl) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   151
				break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
			if (!hasTitle) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
				newFeed->SetTitleL(newFeed->Url());
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
			
60
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   158
			// if the title is the same as the URL, it is hardly a custom
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   159
			// title, so let's replace it on update
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   160
			if (newFeed->Title().Length() &&
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   161
					newFeed->Url().Length() &&
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   162
					newFeed->Title().Compare(newFeed->Url()) != 0) {
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   163
				newFeed->SetCustomTitle();
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   164
			}
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   165
			
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   166
			if (iSearching) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   167
				iFeedEngine.AddSearchResultL(newFeed);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   168
				CleanupStack::Pop(newFeed);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   169
			} else {
60
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   170
				TRAPD(err, iFeedEngine.AddFeedL(*newFeed))
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   171
				if (err == KErrNone)
20
c92d8384952c Fix so only actually added feeds are counted during import
teknolog
parents: 7
diff changeset
   172
					{
c92d8384952c Fix so only actually added feeds are counted during import
teknolog
parents: 7
diff changeset
   173
					iNumFeedsAdded++;
c92d8384952c Fix so only actually added feeds are counted during import
teknolog
parents: 7
diff changeset
   174
					}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   175
				CleanupStack::PopAndDestroy(newFeed);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   176
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   178
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   179
	default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
		DP2("Ignoring tag %S when in state %d", &str, iOpmlState);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   181
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   182
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   183
	DP1("OnStartElementL END state=%d", iOpmlState);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   184
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   185
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   186
void COpmlParser::OnEndElementL(const RTagInfo& aElement, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   187
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   188
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   189
	TDesC8 lName = aElement.LocalName().DesC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   190
	TBuf<KMaxStringBuffer> str;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   191
	str.Copy(aElement.LocalName().DesC());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   192
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   193
	DP2("OnEndElementL START state=%d, element=%S", iOpmlState, &str);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   194
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   195
	switch (iOpmlState) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   196
		case EStateOpmlOutlineOutline:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   197
			iOpmlState=EStateOpmlOutline;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   198
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   199
		case EStateOpmlOutline:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
			iOpmlState=EStateOpmlBody;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
		case EStateOpmlBody:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
			iOpmlState = EStateOpmlRoot;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   205
		default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   206
			// fall back to body level when in doubt
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   207
			iOpmlState = EStateOpmlBody;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   208
			//DP("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
   209
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   210
	}
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
	DP1("OnEndElementL END state=%d", iOpmlState);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   213
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   214
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
void COpmlParser::OnContentL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
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
	//DP("OnContentL()");
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 COpmlParser::OnStartPrefixMappingL(const RString& /*aPrefix*/, const RString& /*aUri*/, 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
	//DP("OnStartPrefixMappingL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   223
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   224
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   225
void COpmlParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt /*aErrorCode*/)
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
	//DP("OnEndPrefixMappingL()");
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   230
void COpmlParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   231
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   232
	//DP("OnIgnorableWhiteSpaceL()");
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   235
void COpmlParser::OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/)
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
	//DP("OnSkippedEntityL()");
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
void COpmlParser::OnProcessingInstructionL(const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, TInt /*aErrorCode*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   241
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   242
	//DP("OnProcessingInstructionL()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   243
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   244
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   245
void COpmlParser::OnError(TInt aErrorCode)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   246
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   247
	DP1("COpmlParser::OnError %d", aErrorCode);
60
4d230e702aa3 Moved development branch from MCL to FCL
teknolog
parents: 20
diff changeset
   248
	TRAP_IGNORE(iFeedEngine.OpmlParsingCompleteL(aErrorCode, iNumFeedsAdded));
2
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   251
TAny* COpmlParser::GetExtendedInterface(const TInt32 /*aUid*/)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   252
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   253
	//DP("GetExtendedInterface()");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   254
	return NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   255
	}