akregator/src

feed.h
1/*
2 This file is part of Akregator.
3
4 Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
5 2005 Frank Osterfeld <frank.osterfeld at kdemail.net>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21 As a special exception, permission is given to link this program
22 with any edition of TQt, and distribute the resulting executable,
23 without including the source code for TQt in the source distribution.
24*/
25
26#ifndef AKREGATORFEED_H
27#define AKREGATORFEED_H
28
29#include "treenode.h"
30#include "librss/librss.h"
31
32class TQDomElement;
33class TQPixmap;
34class TQString;
35class TQStringList;
36class KURL;
37
38
39namespace KPIM {
40 class ProgressItem;
41}
42
43// needed for slot fetchCompleted()
44using RSS::Document;
45using RSS::Loader;
46using RSS::Status;
47
48namespace Akregator
49{
50 class Article;
51 class FetchQueue;
52 class Folder;
53 class TreeNodeVisitor;
54
55 namespace Backend
56 {
57 class FeedStorage;
58 }
62 class Feed : public TreeNode
63 {
64 friend class Article;
65
66 TQ_OBJECT
67
68 public:
76 enum ArchiveMode { globalDefault, keepAllArticles, disableArchiving, limitArticleNumber, limitArticleAge };
77
78 // class methods
82 static ArchiveMode stringToArchiveMode(const TQString& str);
83
85 static TQString archiveModeToString(ArchiveMode mode);
86
88 static Feed* fromOPML(TQDomElement e);
89
91 Feed();
92
93 virtual ~Feed();
94
95 virtual bool accept(TreeNodeVisitor* visitor);
96
98 virtual TQDomElement toOPML( TQDomElement parent, TQDomDocument document ) const;
99
104 bool useCustomFetchInterval() const;
105
110 void setCustomFetchIntervalEnabled(bool enabled);
111
112 // FIXME is it -1 or 0 to disable interval fetching?
115 int fetchInterval() const;
116
119 void setFetchInterval(int interval);
120
122 ArchiveMode archiveMode() const;
123
126
129 int maxArticleAge() const;
130
134
135
137 int maxArticleNumber() const;
138
141
143 bool markImmediatelyAsRead() const;
144
145 void setMarkImmediatelyAsRead(bool enabled);
146
147 void setUseNotification(bool enabled);
148
149 bool useNotification() const;
150
152 void setLoadLinkedWebsite(bool enabled);
153
154 bool loadLinkedWebsite() const;
155
157 const TQPixmap& favicon() const;
158
160 void setFavicon(const TQPixmap& p);
161
163 const TQPixmap& image() const;
164
166 const TQString& xmlUrl() const;
168 void setXmlUrl(const TQString& s);
169
171 const TQString& htmlUrl() const;
173 void setHtmlUrl(const TQString& s);
174
176 const TQString& description() const;
177
179 void setDescription(const TQString& s);
180
181 virtual TQValueList<Article> articles(const TQString& tag=TQString());
182
184 virtual Article findArticle(const TQString& guid) const;
185
186 virtual TQStringList tags() const;
187
189 bool fetchErrorOccurred();
190
192 virtual int unread() const;
193
197 virtual int totalCount() const;
198
200 bool isArticlesLoaded() const;
201
203 virtual bool isGroup() const { return false; }
204
208 virtual TreeNode* next();
209
211 void loadFavicon();
212
214 void loadImage();
215
216 public slots:
218 void fetch(bool followDiscovery=false);
219
220 void slotAbortFetch();
221
223 virtual void slotDeleteExpiredArticles();
224
226 virtual void slotMarkAllArticlesAsRead();
227
229 virtual void slotAddToFetchQueue(FetchQueue* queue, bool intervalFetchOnly=false);
230
231 signals:
235 void fetched(Feed *);
242
243 protected:
245 void loadArticles();
246
247 void recalcUnreadCount();
248
249 virtual void doArticleNotification();
250
252 void setUnread(int unread);
253
254
255 private slots:
256
257 void fetchCompleted(Loader *loader, Document doc, Status status);
258 void slotImageFetched(const TQPixmap& image);
259
260 private:
261
265 void setArticleDeleted(Article& a);
266
271 void setArticleChanged(Article& a, int oldStatus=-1);
272
273 void enforceLimitArticleNumber();
274
275 void appendArticles(const RSS::Document &d);
277 void appendArticle(const Article& a);
278
280 bool isExpired(const Article& a) const;
281
283 bool usesExpiryByAge() const;
284
286 void tryFetch();
287
288 class FeedPrivate;
289 FeedPrivate* d;
290 };
291}
292
293#endif
A proxy class for RSS::Article with some additional methods to assist sorting.
Definition: article.h:58
represents a feed
Definition: feed.h:63
virtual int unread() const
returns the unread count for this feed
Definition: feed.cpp:712
void loadImage()
load the image from the cache if it is in there
Definition: feed.cpp:209
void setArchiveMode(ArchiveMode archiveMode)
sets the archiving mode for this feed
Definition: feed.cpp:707
virtual TQValueList< Article > articles(const TQString &tag=TQString())
Returns a sequence of the articles this node contains.
Definition: feed.cpp:192
void fetchError(Feed *)
emitted when a fetch error occurred
ArchiveMode
the archiving modes:
Definition: feed.h:76
bool markImmediatelyAsRead() const
if true, new articles are marked immediately as read instead of new/unread.
Definition: feed.cpp:318
void setDescription(const TQString &s)
sets the description of this feed
Definition: feed.cpp:361
bool fetchErrorOccurred()
returns whether a fetch error has occurred
Definition: feed.cpp:363
virtual TreeNode * next()
returns the next node in the tree.
Definition: feed.cpp:757
void loadFavicon()
downloads the favicon
Definition: feed.cpp:654
const TQPixmap & favicon() const
returns the favicon
Definition: feed.cpp:347
void loadArticles()
loads articles from archive
Definition: feed.cpp:217
int fetchInterval() const
Returns custom auto fetch interval of this feed.
Definition: feed.cpp:306
virtual int totalCount() const
returns the number of total articles in this feed
Definition: feed.cpp:752
void setLoadLinkedWebsite(bool enabled)
if true, the linked URL is loaded directly in the article viewer instead of showing the description
Definition: feed.cpp:337
void fetchStarted(Feed *)
emitted when fetching started
void fetchDiscovery(Feed *)
emitted when a feed URL was found by auto discovery
void setMaxArticleAge(int maxArticleAge)
sets the maximum age of articles used for expiration by age (used in limitArticleAge archive mode)
Definition: feed.cpp:312
const TQString & description() const
returns the description of this feed
Definition: feed.cpp:359
virtual void doArticleNotification()
reimplement this in subclasses to do the actual notification called by articlesModified
Definition: feed.cpp:773
virtual void slotAddToFetchQueue(FetchQueue *queue, bool intervalFetchOnly=false)
add this feed to the fetch queue queue
Definition: feed.cpp:409
void setMaxArticleNumber(int maxArticleNumber)
sets the article count limit used in limitArticleNumber archive mode
Definition: feed.cpp:316
static TQString archiveModeToString(ArchiveMode mode)
converts ArchiveMode values to corresponding strings
Definition: feed.cpp:104
int maxArticleAge() const
returns the maximum age of articles used for expiration by age (used in limitArticleAge archive mode)
Definition: feed.cpp:310
const TQPixmap & image() const
returns the feed image
Definition: feed.cpp:349
bool isArticlesLoaded() const
returns if the article archive of this feed is loaded
Definition: feed.cpp:365
Feed()
default constructor
Definition: feed.cpp:276
static Feed * fromOPML(TQDomElement e)
creates a Feed object from a description in OPML format
Definition: feed.cpp:125
const TQString & xmlUrl() const
returns the url of the actual feed source (rss/rdf/atom file)
Definition: feed.cpp:351
void setXmlUrl(const TQString &s)
sets the url of the actual feed source (rss/rdf/atom file)
Definition: feed.cpp:353
void setUnread(int unread)
sets the unread count for this feed
Definition: feed.cpp:717
bool useCustomFetchInterval() const
returns whether this feed uses its own fetch interval or the global setting
Definition: feed.cpp:302
virtual TQDomElement toOPML(TQDomElement parent, TQDomDocument document) const
exports the feed settings to OPML
Definition: feed.cpp:368
int maxArticleNumber() const
returns the article count limit used in limitArticleNumber archive mode
Definition: feed.cpp:314
virtual TQStringList tags() const
returns a list of all tags occurring in this node (sub tree for folders)
Definition: feed.cpp:182
void setFetchInterval(int interval)
Sets custom auto fetch interval.
Definition: feed.cpp:308
void fetchAborted(Feed *)
emitted when a fetch is aborted
virtual bool isGroup() const
returns if this node is a feed group (false here)
Definition: feed.h:203
void fetched(Feed *)
emitted when feed finished fetching
ArchiveMode archiveMode() const
returns the archiving mode which is used for this feed
Definition: feed.cpp:702
virtual void slotDeleteExpiredArticles()
deletes expired articles
Definition: feed.cpp:659
void fetch(bool followDiscovery=false)
starts fetching
Definition: feed.cpp:548
virtual void slotMarkAllArticlesAsRead()
mark all articles in this feed as read
Definition: feed.cpp:395
static ArchiveMode stringToArchiveMode(const TQString &str)
converts strings to ArchiveMode value if parsing fails, it returns ArchiveMode::globalDefault
Definition: feed.cpp:260
const TQString & htmlUrl() const
returns the URL of the HTML page of this feed
Definition: feed.cpp:355
void setFavicon(const TQPixmap &p)
sets the favicon (used in the tree view)
Definition: feed.cpp:696
void setHtmlUrl(const TQString &s)
sets the URL of the HTML page of this feed
Definition: feed.cpp:357
virtual Article findArticle(const TQString &guid) const
returns the article with the given guid, or a null article if it not exists
Definition: feed.cpp:187
void setCustomFetchIntervalEnabled(bool enabled)
set if the feed has its custom fetch interval or uses the global setting
Definition: feed.cpp:304
Abstract base class for all kind of elements in the feed tree, like feeds and feed groups (and search...
Definition: treenode.h:52
virtual Folder * parent() const
Returns the parent node.
Definition: treenode.cpp:115