author | Sebastian Brannstrom <sebastianb@symbian.org> |
Sat, 23 Oct 2010 15:16:10 +0100 | |
branch | symbian1 |
changeset 269 | a89dc59aecbe |
parent 247 | 60621d146c19 |
child 340 | 37610dda6102 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB |
|
3 |
* |
|
4 |
* All rights reserved. |
|
5 |
* This component and the accompanying materials are made available |
|
6 |
* under the terms of the License "Eclipse Public License v1.0" |
|
7 |
* which accompanies this distribution, and is available |
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 |
* |
|
10 |
* Initial Contributors: |
|
11 |
* EmbedDev AB - initial contribution. |
|
12 |
* |
|
13 |
* Contributors: |
|
14 |
* |
|
15 |
* Description: |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
#ifndef FEEDPARSER_H_ |
|
20 |
#define FEEDPARSER_H_ |
|
21 |
||
22 |
#include "FeedParserObserver.h" |
|
23 |
#include "FeedInfo.h" |
|
24 |
#include <xml/parser.h> // for CParser |
|
25 |
#include <xml/contenthandler.h> // for Xml::MContentHandler |
|
26 |
#include <xml/documentparameters.h> |
|
27 |
||
28 |
_LIT(KTagItem, "item"); |
|
29 |
_LIT(KTagTitle, "title"); |
|
30 |
_LIT(KTagImage, "image"); |
|
31 |
_LIT(KTagLink, "link"); |
|
32 |
_LIT(KTagDescription, "description"); |
|
33 |
_LIT(KTagUrl, "url"); |
|
34 |
_LIT(KTagLength, "length"); |
|
35 |
_LIT(KTagChannel, "channel"); |
|
36 |
_LIT(KTagEnclosure, "enclosure"); |
|
37 |
_LIT(KTagPubDate, "pubDate"); |
|
247
60621d146c19
Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
2
diff
changeset
|
38 |
_LIT(KTagGuid, "guid"); |
2 | 39 |
_LIT(KTagLastBuildDate, "lastBuildDate"); |
40 |
_LIT(KTagHref, "href"); |
|
41 |
||
42 |
enum TFeedState { |
|
43 |
EStateRoot, |
|
44 |
EStateChannel, |
|
45 |
EStateChannelTitle, |
|
46 |
EStateChannelLink, |
|
47 |
EStateChannelLastBuildDate, |
|
48 |
EStateChannelDescription, |
|
49 |
EStateChannelImage, |
|
50 |
EStateChannelImageUrl, |
|
51 |
EStateItem, |
|
52 |
EStateItemTitle, |
|
53 |
EStateItemLink, |
|
54 |
EStateItemEnclosure, |
|
55 |
EStateItemDescription, |
|
247
60621d146c19
Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
2
diff
changeset
|
56 |
EStateItemPubDate, |
60621d146c19
Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
2
diff
changeset
|
57 |
EStateItemGuid |
2 | 58 |
}; |
59 |
||
60 |
enum TEncoding { |
|
61 |
EUtf8, |
|
62 |
ELatin1 |
|
63 |
}; |
|
64 |
||
65 |
const int KBufferLength = 1024; |
|
66 |
||
67 |
class CFeedParser : public CBase, public Xml::MContentHandler |
|
68 |
{ |
|
69 |
public: |
|
70 |
CFeedParser(MFeedParserObserver& aCallbacks, RFs& aFs); |
|
71 |
virtual ~CFeedParser(); |
|
72 |
||
73 |
public: |
|
74 |
void ParseFeedL(const TFileName &feedFileName, CFeedInfo *item, TUint aMaxItems); |
|
75 |
||
76 |
public: // from MContentHandler |
|
77 |
void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode); |
|
78 |
void OnEndDocumentL(TInt aErrorCode); |
|
79 |
void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, TInt aErrorCode); |
|
80 |
void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode); |
|
81 |
void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
82 |
void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode); |
|
83 |
void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
84 |
void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
85 |
void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
86 |
void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode); |
|
87 |
void OnError(TInt aErrorCode); |
|
88 |
TAny* GetExtendedInterface(const TInt32 aUid); |
|
89 |
CFeedInfo& ActiveFeed(); |
|
90 |
private: |
|
91 |
MFeedParserObserver& iCallbacks; |
|
92 |
TFeedState iFeedState; |
|
93 |
||
94 |
CShowInfo* iActiveShow; |
|
95 |
CFeedInfo *iActiveFeed; |
|
96 |
||
97 |
TBuf<KBufferLength> iBuffer; |
|
247
60621d146c19
Fix for bug 3420 - we now use GUID if it's provided by the feed
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
2
diff
changeset
|
98 |
TUint iUid; |
2 | 99 |
TUint iMaxItems; |
100 |
TUint iItemsParsed; |
|
101 |
TBool iStoppedParsing; |
|
102 |
TEncoding iEncoding; |
|
103 |
RFs& iRfs; |
|
104 |
}; |
|
105 |
||
106 |
#endif |