Diffstat (limited to 'core/multimedia/opieplayer/rssparser.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/rssparser.h | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/rssparser.h b/core/multimedia/opieplayer/rssparser.h new file mode 100644 index 0000000..669ece5 --- a/dev/null +++ b/core/multimedia/opieplayer/rssparser.h | |||
@@ -0,0 +1,122 @@ | |||
1 | /*************************************************************************** | ||
2 | * Copyright (C) 2004 by ljp * | ||
3 | * lpotter@trolltech.com * | ||
4 | * * | ||
5 | * This program may be distributed under the terms of the Q Public * | ||
6 | * License as defined by Trolltech AS of Norway and appearing in the * | ||
7 | * file LICENSE.QPL included in the packaging of this file. * | ||
8 | * * | ||
9 | * This program is distributed in the hope that it will be useful, * | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * | ||
12 | ***************************************************************************/ | ||
13 | |||
14 | /* RSS required tags: | ||
15 | title,link,description | ||
16 | */ | ||
17 | /* RSS optional tags: | ||
18 | language,copyright,managingEditor,webMaster,pubDate,lastBuildDate,category,generator,docs,cloud,ttl, | ||
19 | image,rating,textInput,skipHours,skipDays | ||
20 | */ | ||
21 | /* | ||
22 | podcast tags | ||
23 | <rss xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd" version="2.0"> | ||
24 | title,link,copyright,pubDate,enclosure,guid,itunes:author,itunes:block,itunes:category,itunes:duration,itunes:explicit,itunes:keywords,itunes:owner,itunes:subtitle,itunes:summary | ||
25 | */ | ||
26 | |||
27 | #ifndef RSSPARSER_H | ||
28 | #define RSSPARSER_H | ||
29 | |||
30 | #include <qxml.h> | ||
31 | #include <qstringlist.h> | ||
32 | #include <qvector.h> | ||
33 | #include <qstringlist.h> | ||
34 | #include <qlist.h> | ||
35 | |||
36 | class QString; | ||
37 | |||
38 | class rssImage { | ||
39 | public: | ||
40 | QString url; | ||
41 | QString title; | ||
42 | int width; | ||
43 | int height; | ||
44 | QString description; | ||
45 | }; | ||
46 | |||
47 | class rssItem { | ||
48 | public: | ||
49 | QString title; | ||
50 | QString description; | ||
51 | QString link; | ||
52 | QString pubdate; | ||
53 | QVector <rssImage> rssImageTags; | ||
54 | QList<QStringList> attributes; //tags with atttributes | ||
55 | }; | ||
56 | |||
57 | class rssChannel { | ||
58 | public: | ||
59 | QString title; | ||
60 | QString description; | ||
61 | QString link; | ||
62 | QString pubdate; | ||
63 | QString copyright; | ||
64 | QString language; | ||
65 | QVector <rssImage> rssImageTags; | ||
66 | QVector <rssItem> rssItems; | ||
67 | QList<QStringList> attributes; //tags with atttributes | ||
68 | }; | ||
69 | |||
70 | class RssParser : public QXmlDefaultHandler | ||
71 | { | ||
72 | public: | ||
73 | RssParser(); | ||
74 | ~RssParser(); | ||
75 | QString errorMessage; | ||
76 | |||
77 | QVector<rssItem> &getItems(); | ||
78 | QStringList getChannelInfo(); | ||
79 | int getSize(); | ||
80 | |||
81 | private: | ||
82 | |||
83 | enum Tag { | ||
84 | NoneTag = 0, | ||
85 | TitleTag = 1, | ||
86 | NewItemTag = 2, | ||
87 | DescriptionTag = 3, | ||
88 | LinkTag = 4, | ||
89 | pubDateTag = 5, | ||
90 | /* | ||
91 | ImageTag = 6, | ||
92 | UrlTag = 7, | ||
93 | WidthTag = 8, | ||
94 | HeightTag = 9, | ||
95 | */ | ||
96 | }; | ||
97 | Tag tag; | ||
98 | |||
99 | // QVector <rssItem> rssItems; | ||
100 | QStringList channelInfo; | ||
101 | rssItem *Item; | ||
102 | rssChannel *channel; | ||
103 | rssImage *image; | ||
104 | |||
105 | bool isItem; | ||
106 | QStringList tokenNames; | ||
107 | QString htmlString; | ||
108 | |||
109 | protected: | ||
110 | |||
111 | bool startElement( const QString&, const QString&, const QString& ,const QXmlAttributes& ); | ||
112 | bool endElement( const QString&, const QString&, const QString& ); | ||
113 | bool characters( const QString &); | ||
114 | |||
115 | bool warning(const QXmlParseException &); | ||
116 | bool error(const QXmlParseException &); | ||
117 | bool fatalError(const QXmlParseException &); | ||
118 | |||
119 | QString itemTitle, itemLink, itemDescription; | ||
120 | }; | ||
121 | |||
122 | #endif | ||