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 OPMLPARSER_H_
|
|
20 |
#define OPMLPARSER_H_
|
|
21 |
|
|
22 |
#include <xml/parser.h> // for CParser
|
|
23 |
#include <xml/contenthandler.h> // for Xml::MContentHandler
|
|
24 |
#include <xml/documentparameters.h>
|
|
25 |
#include "FeedEngine.h"
|
|
26 |
|
|
27 |
_LIT(KTagOpml, "opml");
|
|
28 |
_LIT(KTagBody, "body");
|
|
29 |
_LIT(KTagOutline, "outline");
|
|
30 |
_LIT(KTagXmlUrl, "xmlUrl");
|
|
31 |
_LIT(KTagText, "text");
|
|
32 |
_LIT(KTagHtmlUrl, "htmlUrl");
|
|
33 |
|
|
34 |
enum TOpmlState {
|
|
35 |
EStateOpmlRoot,
|
|
36 |
EStateOpmlBody,
|
|
37 |
EStateOpmlOutline,
|
|
38 |
EStateOpmlOutlineOutline
|
|
39 |
};
|
|
40 |
|
|
41 |
class COpmlParser : public CBase, public Xml::MContentHandler
|
|
42 |
{
|
|
43 |
public:
|
|
44 |
COpmlParser(CFeedEngine& aFeedEngine, RFs& aFs);
|
|
45 |
virtual ~COpmlParser();
|
|
46 |
|
|
47 |
public:
|
|
48 |
void ParseOpmlL(const TFileName &feedFileName, TBool aSearching);
|
|
49 |
|
|
50 |
public: // from MContentHandler
|
|
51 |
void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode);
|
|
52 |
void OnEndDocumentL(TInt aErrorCode);
|
|
53 |
void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, TInt aErrorCode);
|
|
54 |
void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode);
|
|
55 |
void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
|
|
56 |
void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
|
|
57 |
void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
|
|
58 |
void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
|
|
59 |
void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
|
|
60 |
void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
|
|
61 |
void OnError(TInt aErrorCode);
|
|
62 |
TAny* GetExtendedInterface(const TInt32 aUid);
|
|
63 |
private:
|
|
64 |
CFeedEngine& iFeedEngine;
|
|
65 |
TOpmlState iOpmlState;
|
|
66 |
|
|
67 |
TBuf<KBufferLength> iBuffer;
|
|
68 |
TEncoding iEncoding;
|
|
69 |
RFs& iFs;
|
|
70 |
TBool iSearching;
|
|
71 |
TUint iNumFeedsAdded;
|
|
72 |
};
|
|
73 |
|
|
74 |
#endif
|