engine/inc/FeedParser.h
author Sebastian Brannstrom <sebastianb@symbian.org>
Thu, 21 Oct 2010 21:36:03 +0100
branch3rded
changeset 262 81bb9210fd4c
parent 2 29cda98b007e
child 171 cc1be3797632
child 247 60621d146c19
child 343 9c56bf585696
permissions -rw-r--r--
Bug 3836 - added Exit to all menus
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");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
_LIT(KTagLastBuildDate, "lastBuildDate");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
_LIT(KTagHref, "href");
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
enum TFeedState {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
	EStateRoot,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
	EStateChannel,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
	EStateChannelTitle,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
	EStateChannelLink,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
	EStateChannelLastBuildDate,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
	EStateChannelDescription,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
	EStateChannelImage,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
	EStateChannelImageUrl,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
	EStateItem,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
	EStateItemTitle,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
	EStateItemLink,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
	EStateItemEnclosure,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
	EStateItemDescription,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
	EStateItemPubDate
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
};
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
enum TEncoding {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
	EUtf8,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
	ELatin1
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
};
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
const int KBufferLength = 1024;
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
class CFeedParser : public CBase, public Xml::MContentHandler 
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
public:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
	CFeedParser(MFeedParserObserver& aCallbacks, RFs& aFs);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
	virtual ~CFeedParser();
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
public:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
	void ParseFeedL(const TFileName &feedFileName, CFeedInfo *item, TUint aMaxItems);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
public: // from MContentHandler
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
	void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
	void OnEndDocumentL(TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
	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
    78
	void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
	void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
	void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
	void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
	void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
	void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
	void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
	void OnError(TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
	TAny* GetExtendedInterface(const TInt32 aUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
	CFeedInfo& ActiveFeed();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
private:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
	MFeedParserObserver& iCallbacks;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
	TFeedState iFeedState;
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
	CShowInfo* iActiveShow;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
	CFeedInfo *iActiveFeed;
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
	TBuf<KBufferLength> iBuffer;
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
	TUint iMaxItems;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
	TUint iItemsParsed;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
	TBool iStoppedParsing;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
	TEncoding iEncoding;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
	RFs& iRfs;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
};
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
#endif