engine/inc/FeedParser.h
author Sebastian Brannstrom <sebastianb@symbian.org>
Mon, 22 Nov 2010 15:41:41 +0000
branch3rded
changeset 390 d7abecc9d189
parent 343 9c56bf585696
permissions -rw-r--r--
Catch up with 5th ed; New SIS version 1.10 (1)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     1
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     2
* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     3
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     4
* All rights reserved.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     5
* This component and the accompanying materials are made available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     6
* under the terms of the License "Eclipse Public License v1.0"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     7
* which accompanies this distribution, and is available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     8
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     9
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    10
* Initial Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    11
* EmbedDev AB - initial contribution.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    12
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    13
* Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    14
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    15
* Description:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    16
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    17
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    18
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    19
#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
390
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
    65
enum TFeedDirection
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
    66
	{
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
    67
	EFeedUnknown,
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
    68
	EFeedAddsAtTop,
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
    69
	EFeedAddsAtBottom
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
    70
	};
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
    71
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
const int KBufferLength = 1024;
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
class CFeedParser : public CBase, public Xml::MContentHandler 
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:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
	CFeedParser(MFeedParserObserver& aCallbacks, RFs& aFs);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
	virtual ~CFeedParser();
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
public:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
	void ParseFeedL(const TFileName &feedFileName, CFeedInfo *item, TUint aMaxItems);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
public: // from MContentHandler
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
	void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
	void OnEndDocumentL(TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
	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
    87
	void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
	void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
	void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
	void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
	void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
	void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
	void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
	void OnError(TInt aErrorCode);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
	TAny* GetExtendedInterface(const TInt32 aUid);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
	CFeedInfo& ActiveFeed();
390
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
    97
	
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
private:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
	MFeedParserObserver& iCallbacks;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
	TFeedState iFeedState;
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
	CShowInfo* iActiveShow;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
	CFeedInfo *iActiveFeed;
390
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
   104
	CShowInfo *iNewestShow;
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
   105
	
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
	TBuf<KBufferLength> iBuffer;
343
9c56bf585696 Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 2
diff changeset
   107
	TUint iUid;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
	TUint iMaxItems;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
	TUint iItemsParsed;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
	TBool iStoppedParsing;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
	TEncoding iEncoding;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
	RFs& iRfs;
343
9c56bf585696 Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 2
diff changeset
   113
	TInt iFileSize;
390
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
   114
	TFeedDirection iFeedDirection;
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
   115
	TTime iPreviousPubDate;
d7abecc9d189 Catch up with 5th ed; New SIS version 1.10 (1)
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 343
diff changeset
   116
	TBool iNewFeed;
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   117
};
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   118
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   119
#endif