akregator/src

feed.h

00001 /*
00002     This file is part of Akregator.
00003 
00004     Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
00005                   2005 Frank Osterfeld <frank.osterfeld at kdemail.net>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021     As a special exception, permission is given to link this program
00022     with any edition of Qt, and distribute the resulting executable,
00023     without including the source code for Qt in the source distribution.
00024 */
00025 
00026 #ifndef AKREGATORFEED_H
00027 #define AKREGATORFEED_H
00028 
00029 #include "treenode.h"
00030 #include "librss/librss.h"
00031 
00032 class QDomElement;
00033 class QPixmap;
00034 class QString;
00035 class QStringList;
00036 class KURL;
00037 
00038 
00039 namespace KPIM {
00040     class ProgressItem;
00041 }
00042 
00043 // needed for slot fetchCompleted()
00044 using RSS::Document;
00045 using RSS::Loader;
00046 using RSS::Status;
00047 
00048 namespace Akregator
00049 {
00050     class Article;
00051     class FetchQueue;
00052     class Folder;
00053     class TreeNodeVisitor;
00054 
00055     namespace Backend
00056     {
00057         class FeedStorage;
00058     }
00062     class Feed : public TreeNode
00063     {
00064         friend class Article;
00065         
00066         Q_OBJECT
00067         public:
00075             enum ArchiveMode { globalDefault, keepAllArticles, disableArchiving, limitArticleNumber, limitArticleAge };
00076 
00077             // class methods
00081             static ArchiveMode stringToArchiveMode(const QString& str);
00082 
00084             static QString archiveModeToString(ArchiveMode mode);
00085 
00087             static Feed* fromOPML(QDomElement e);
00088 
00090             Feed();
00091 
00092             virtual ~Feed();
00093 
00094             virtual bool accept(TreeNodeVisitor* visitor);
00095 
00097             virtual QDomElement toOPML( QDomElement parent, QDomDocument document ) const;
00098 
00103             bool useCustomFetchInterval() const;
00104 
00109             void setCustomFetchIntervalEnabled(bool enabled);
00110 
00111             // FIXME is it -1 or 0 to disable interval fetching?
00114             int fetchInterval() const;
00115 
00118             void setFetchInterval(int interval);
00119 
00121             ArchiveMode archiveMode() const;
00122 
00124             void setArchiveMode(ArchiveMode archiveMode);
00125 
00128             int maxArticleAge() const;
00129 
00132             void setMaxArticleAge(int maxArticleAge);
00133             
00134 
00136             int maxArticleNumber() const;
00137 
00139             void setMaxArticleNumber(int maxArticleNumber);
00140 
00142             bool markImmediatelyAsRead() const;
00143 
00144             void setMarkImmediatelyAsRead(bool enabled);
00145 
00146             void setUseNotification(bool enabled);
00147 
00148             bool useNotification() const;
00149 
00151             void setLoadLinkedWebsite(bool enabled);
00152 
00153             bool loadLinkedWebsite() const;
00154             
00156             const QPixmap& favicon() const;
00157 
00159             void setFavicon(const QPixmap& p);
00160 
00162             const QPixmap& image() const;
00163 
00165             const QString& xmlUrl() const;
00167             void setXmlUrl(const QString& s);
00168 
00170             const QString& htmlUrl() const;
00172             void setHtmlUrl(const QString& s);
00173 
00175             const QString& description() const;
00176 
00178             void setDescription(const QString& s);
00179 
00180             virtual QValueList<Article> articles(const QString& tag=QString::null);
00181 
00183             virtual Article findArticle(const QString& guid) const;
00184             
00185             virtual QStringList tags() const;
00186             
00188             bool fetchErrorOccurred();
00189 
00191             virtual int unread() const;
00192 
00196             virtual int totalCount() const;
00197 
00199             bool isArticlesLoaded() const;
00200 
00202             virtual bool isGroup() const { return false; }
00203 
00207             virtual TreeNode* next();
00208 
00210             void loadFavicon();
00211             
00213             void loadImage();
00214             
00215         public slots:
00217             void fetch(bool followDiscovery=false);
00218 
00219             void slotAbortFetch();
00220 
00222             virtual void slotDeleteExpiredArticles();
00223 
00225             virtual void slotMarkAllArticlesAsRead();
00226 
00228             virtual void slotAddToFetchQueue(FetchQueue* queue, bool intervalFetchOnly=false);
00229 
00230         signals:
00232             void fetchStarted(Feed*);
00234             void fetched(Feed *);
00236             void fetchError(Feed *);
00238             void fetchDiscovery(Feed *);
00240             void fetchAborted(Feed *);
00241            
00242         protected:
00244             void loadArticles();
00245 
00246             void recalcUnreadCount();
00247 
00248             virtual void doArticleNotification();
00249 
00251             void setUnread(int unread);
00252 
00253             
00254         private slots:
00255 
00256             void fetchCompleted(Loader *loader, Document doc, Status status);
00257             void slotImageFetched(const QPixmap& image);
00258 
00259         private:
00260             
00264             void setArticleDeleted(Article& a);
00265 
00270             void setArticleChanged(Article& a, int oldStatus=-1);
00271             
00272             void enforceLimitArticleNumber();
00273 
00274             void appendArticles(const RSS::Document &d);
00276             void appendArticle(const Article& a);
00277 
00279             bool isExpired(const Article& a) const;
00280 
00282             bool usesExpiryByAge() const;
00283 
00285             void tryFetch();
00286 
00287             class FeedPrivate;
00288             FeedPrivate* d;
00289     };
00290 }
00291 
00292 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys