~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/dataengines/rss/rss.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright (C) 2007 Aaron Seigo <aseigo@kde.org>
 
3
 *   Copyright (C) 2007 Petri Damsten <damu@iki.fi>
 
4
 *   Copyright (C) 2008 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
 
5
 *
 
6
 *   This program is free software; you can redistribute it and/or modify
 
7
 *   it under the terms of the GNU Library General Public License version 2 as
 
8
 *   published by the Free Software Foundation
 
9
 *
 
10
 *   This program is distributed in the hope that it will be useful,
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *   GNU General Public License for more details
 
14
 *
 
15
 *   You should have received a copy of the GNU Library General Public
 
16
 *   License along with this program; if not, write to the
 
17
 *   Free Software Foundation, Inc.,
 
18
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
 */
 
20
 
 
21
#ifndef RSS_DATAENGINE_H
 
22
#define RSS_DATAENGINE_H
 
23
 
 
24
#include <syndication/item.h>
 
25
#include <syndication/loader.h>
 
26
#include <syndication/feed.h>
 
27
#include <Solid/Networking>
 
28
#include <Plasma/DataEngine>
 
29
#include <QSet>
 
30
 
 
31
class QDBusInterface;
 
32
class QSignalMapper;
 
33
 
 
34
/**
 
35
 * This class can be used to fetch one or more rss feeds. By
 
36
 * requesting a datasource with the url's of one or more rss
 
37
 * feeds separated by " ", you will receive a merged list
 
38
 * containing the items of all feeds requested. This list is
 
39
 * sorted by timestamp.
 
40
 * This class also fetches the favicons from all requested
 
41
 * feeds.
 
42
 */
 
43
class RssEngine : public Plasma::DataEngine
 
44
{
 
45
    Q_OBJECT
 
46
 
 
47
    public:
 
48
        RssEngine(QObject* parent, const QVariantList& args);
 
49
        virtual ~RssEngine();
 
50
 
 
51
    protected:
 
52
        bool sourceRequestEvent(const QString &name);
 
53
        bool updateSourceEvent(const QString& name);
 
54
 
 
55
    protected slots:
 
56
        void processRss(Syndication::Loader* loader,
 
57
                        Syndication::FeedPtr feed,
 
58
                        Syndication::ErrorCode error);
 
59
        void slotIconChanged(bool isHost, const QString& hostOrURL,
 
60
                                          const QString& iconName);
 
61
        void timeout(const QString & source);
 
62
        void networkStatusChanged(Solid::Networking::Status status);
 
63
 
 
64
    private:
 
65
        QVariantList mergeFeeds(QString source) const;
 
66
        void updateFeeds(const QString & source,
 
67
                         const QString & title);
 
68
        bool cachesUpToDate(const QString & source) const;
 
69
        QString iconLocation(const KUrl & url) const;
 
70
 
 
71
        QHash<Syndication::Loader*, QString> m_feedMap;
 
72
        QHash<Syndication::Loader*, QString> m_sourceMap;
 
73
        QHash<QString, QTimer*>              m_timerMap;
 
74
        QHash<QString, QVariantList>         m_feedItems;
 
75
        QHash<QString, QString>              m_feedIcons;
 
76
        QHash<QString, QString>              m_feedTitles;
 
77
        QHash<QString, QDateTime>            m_feedTimes;
 
78
        bool                                 m_forceUpdate;
 
79
 
 
80
        QVariantList                         m_rssSources;
 
81
        QSet<QString>                        m_rssSourceNames;
 
82
 
 
83
        QDBusInterface *                     m_favIconsModule;
 
84
        QSignalMapper *                      m_signalMapper;
 
85
};
 
86
 
 
87
K_EXPORT_PLASMA_DATAENGINE(rss, RssEngine)
 
88
 
 
89
#endif
 
90