qBittorrent
rss_parser.h
Go to the documentation of this file.
1 /*
2  * Bittorrent Client using Qt and libtorrent.
3  * Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
4  * Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * In addition, as a special exception, the copyright holders give permission to
21  * link this program with the OpenSSL project's "OpenSSL" library (or with
22  * modified versions of it that use the same license as the "OpenSSL" library),
23  * and distribute the linked executables. You must obey the GNU General Public
24  * License in all respects for all of the code used other than "OpenSSL". If you
25  * modify file(s), you may extend this exception to your version of the file(s),
26  * but you are not obligated to do so. If you do not wish to do so, delete this
27  * exception statement from your version.
28  */
29 
30 #pragma once
31 
32 #include <QList>
33 #include <QObject>
34 #include <QSet>
35 #include <QString>
36 #include <QVariantHash>
37 
38 class QXmlStreamReader;
39 
40 namespace RSS
41 {
42  namespace Private
43  {
45  {
46  QString error;
47  QString lastBuildDate;
48  QString title;
49  QList<QVariantHash> articles;
50  };
51 
52  class Parser : public QObject
53  {
54  Q_OBJECT
55 
56  public:
57  explicit Parser(QString lastBuildDate);
58  void parse(const QByteArray &feedData);
59 
60  signals:
62 
63  private:
64  Q_INVOKABLE void parse_impl(const QByteArray &feedData);
65  void parseRssArticle(QXmlStreamReader &xml);
66  void parseRSSChannel(QXmlStreamReader &xml);
67  void parseAtomArticle(QXmlStreamReader &xml);
68  void parseAtomChannel(QXmlStreamReader &xml);
69  void addArticle(QVariantHash article);
70 
71  QString m_baseUrl;
73  QSet<QString> m_articleIDs;
74  };
75  }
76 }
77 
78 Q_DECLARE_METATYPE(RSS::Private::ParsingResult)
ParsingResult m_result
Definition: rss_parser.h:72
void parse(const QByteArray &feedData)
Definition: rss_parser.cpp:550
Q_INVOKABLE void parse_impl(const QByteArray &feedData)
Definition: rss_parser.cpp:557
void addArticle(QVariantHash article)
Definition: rss_parser.cpp:822
Parser(QString lastBuildDate)
Definition: rss_parser.cpp:545
void parseRSSChannel(QXmlStreamReader &xml)
Definition: rss_parser.cpp:673
void parseAtomChannel(QXmlStreamReader &xml)
Definition: rss_parser.cpp:787
void parseRssArticle(QXmlStreamReader &xml)
Definition: rss_parser.cpp:610
void finished(const RSS::Private::ParsingResult &result)
void parseAtomArticle(QXmlStreamReader &xml)
Definition: rss_parser.cpp:706
QSet< QString > m_articleIDs
Definition: rss_parser.h:73
QList< QVariantHash > articles
Definition: rss_parser.h:49