engine/inc/FeedParser.h
author Sebastian Brannstrom <sebastianb@symbian.org>
Sat, 13 Nov 2010 13:54:36 +0000
branch3rded
changeset 343 9c56bf585696
parent 2 29cda98b007e
child 390 d7abecc9d189
permissions -rw-r--r--
Catching up with 5th edition
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
#ifndef FEEDPARSER_H_
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
#define FEEDPARSER_H_
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
#include "FeedParserObserver.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
#include "FeedInfo.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
#include <xml/parser.h> // for CParser
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
#include <xml/contenthandler.h>	// for Xml::MContentHandler
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
#include <xml/documentparameters.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
_LIT(KTagItem, "item");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
_LIT(KTagTitle, "title");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
_LIT(KTagImage, "image");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
_LIT(KTagLink, "link");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
_LIT(KTagDescription, "description");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
_LIT(KTagUrl, "url");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
_LIT(KTagLength, "length");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
_LIT(KTagChannel, "channel");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    36
_LIT(KTagEnclosure, "enclosure");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    37
_LIT(KTagPubDate, "pubDate");
343
9c56bf585696 Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 2
diff changeset
    38
_LIT(KTagGuid, "guid");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
_LIT(KTagLastBuildDate, "lastBuildDate");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
_LIT(KTagHref, "href");
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
enum TFeedState {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
	EStateRoot,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
	EStateChannel,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
	EStateChannelTitle,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
	EStateChannelLink,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
	EStateChannelLastBuildDate,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
	EStateChannelDescription,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
	EStateChannelImage,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
	EStateChannelImageUrl,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
	EStateItem,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
	EStateItemTitle,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
	EStateItemLink,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
	EStateItemEnclosure,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
	EStateItemDescription,
343
9c56bf585696 Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 2
diff changeset
    56
	EStateItemPubDate,
9c56bf585696 Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 2
diff changeset
    57
	EStateItemGuid
2
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
enum TEncoding {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
	EUtf8,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
	ELatin1
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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
const int KBufferLength = 1024;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
class CFeedParser : public CBase, public Xml::MContentHandler 
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
public:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
	CFeedParser(MFeedParserObserver& aCallbacks, RFs& aFs);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
	virtual ~CFeedParser();
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
public:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
	void ParseFeedL(const TFileName &feedFileName, CFeedInfo *item, TUint aMaxItems);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
public: // from MContentHandler
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
	void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
	void OnEndDocumentL(TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
	void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
	void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
	void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
	void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
	void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
	void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
	void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
	void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
	void OnError(TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
	TAny* GetExtendedInterface(const TInt32 aUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
	CFeedInfo& ActiveFeed();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
private:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
	MFeedParserObserver& iCallbacks;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
	TFeedState iFeedState;
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
	CShowInfo* iActiveShow;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
	CFeedInfo *iActiveFeed;
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
	TBuf<KBufferLength> iBuffer;
343
9c56bf585696 Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 2
diff changeset
    98
	TUint iUid;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
	TUint iMaxItems;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
	TUint iItemsParsed;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
	TBool iStoppedParsing;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
	TEncoding iEncoding;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
	RFs& iRfs;
343
9c56bf585696 Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 2
diff changeset
   104
	TInt iFileSize;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
};
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
#endif