• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

akregator

  • sources
  • kde-4.14
  • kdepim
  • akregator
  • src
fetchqueue.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Akregator.
3 
4  Copyright (C) 2004 Sashmit Bhaduri <smt@vfemail.net>
5  2005 Frank Osterfeld <osterfeld@kde.org>
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 Qt, and distribute the resulting executable,
23  without including the source code for Qt in the source distribution.
24 */
25 
26 #include "fetchqueue.h"
27 #include "akregatorconfig.h"
28 #include "feed.h"
29 #include "treenode.h"
30 
31 #include <QList>
32 
33 using namespace Akregator;
34 
35 class FetchQueue::FetchQueuePrivate
36 {
37  public:
38 
39  QList<Feed*> queuedFeeds;
40  QList<Feed*> fetchingFeeds;
41 };
42 
43 
44 FetchQueue::FetchQueue(QObject* parent): QObject(parent), d(new FetchQueuePrivate) {
45 }
46 
47 
48 FetchQueue::~FetchQueue()
49 {
50  slotAbort();
51  delete d;
52  d = 0;
53 }
54 
55 void FetchQueue::slotAbort()
56 {
57  foreach( Feed* const i, d->fetchingFeeds )
58  {
59  disconnectFromFeed( i );
60  i->slotAbortFetch();
61  }
62  d->fetchingFeeds.clear();
63 
64  foreach ( Feed* const i, d->queuedFeeds )
65  disconnectFromFeed( i );
66  d->queuedFeeds.clear();
67 
68  emit signalStopped();
69 }
70 
71 void FetchQueue::addFeed(Feed *f)
72 {
73  if (!d->queuedFeeds.contains(f) && !d->fetchingFeeds.contains(f))
74  {
75  connectToFeed(f);
76  d->queuedFeeds.append(f);
77  fetchNextFeed();
78  }
79 }
80 
81 void FetchQueue::fetchNextFeed()
82 {
83  if (!d->queuedFeeds.isEmpty() && d->fetchingFeeds.count() < Settings::concurrentFetches())
84  {
85  if (d->fetchingFeeds.isEmpty() && d->queuedFeeds.count() == 1)
86  emit signalStarted();
87  Feed* f = *(d->queuedFeeds.begin());
88  d->queuedFeeds.pop_front();
89  d->fetchingFeeds.append(f);
90  f->fetch(false);
91 
92  }
93 }
94 
95 void FetchQueue::slotFeedFetched(Feed *f)
96 {
97  emit fetched(f);
98  feedDone(f);
99 }
100 
101 void FetchQueue::slotFetchError(Feed *f)
102 {
103  emit fetchError(f);
104  feedDone(f);
105 }
106 
107 void FetchQueue::slotFetchAborted(Feed *f)
108 {
109  emit fetched(f); // FIXME: better use a signal like signalAborted(Feed*)
110  feedDone(f);
111 }
112 
113 bool FetchQueue::isEmpty() const
114 {
115  return d->queuedFeeds.isEmpty() && d->fetchingFeeds.isEmpty();
116 }
117 
118 void FetchQueue::feedDone(Feed *f)
119 {
120  disconnectFromFeed(f);
121  d->fetchingFeeds.removeAll(f);
122  if (isEmpty())
123  emit signalStopped();
124  else
125  fetchNextFeed();
126 }
127 
128 void FetchQueue::connectToFeed(Feed* feed)
129 {
130  connect (feed, SIGNAL(fetched(Akregator::Feed*)), this, SLOT(slotFeedFetched(Akregator::Feed*)));
131  connect (feed, SIGNAL(fetchError(Akregator::Feed*)), this, SLOT(slotFetchError(Akregator::Feed*)));
132  connect (feed, SIGNAL(fetchAborted(Akregator::Feed*)), this, SLOT(slotFetchAborted(Akregator::Feed*)));
133  connect (feed, SIGNAL(signalDestroyed(Akregator::TreeNode*)), this, SLOT(slotNodeDestroyed(Akregator::TreeNode*)));
134 }
135 
136 void FetchQueue::disconnectFromFeed(Feed* feed)
137 {
138  feed->disconnect( this );
139 }
140 
141 
142 void FetchQueue::slotNodeDestroyed(TreeNode* node)
143 {
144  Feed* const feed = qobject_cast<Feed*>( node );
145  assert( feed );
146 
147  d->fetchingFeeds.removeAll(feed);
148  d->queuedFeeds.removeAll(feed);
149 }
150 
treenode.h
Akregator::FetchQueue::feedDone
void feedDone(Feed *f)
Definition: fetchqueue.cpp:118
Akregator::FetchQueue::slotAbort
void slotAbort()
aborts currently fetching feeds and empties the queue
Definition: fetchqueue.cpp:55
Akregator::FetchQueue::slotFeedFetched
void slotFeedFetched(Akregator::Feed *)
Definition: fetchqueue.cpp:95
Akregator::FetchQueue::fetchNextFeed
void fetchNextFeed()
fetches the next feed in the queue, unless the maximum of concurrent fetches is reached ...
Definition: fetchqueue.cpp:81
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
Akregator::FetchQueue::addFeed
void addFeed(Feed *f)
adds a feed to the queue
Definition: fetchqueue.cpp:71
feed.h
Akregator::FetchQueue::fetchError
void fetchError(Akregator::Feed *)
QObject
Akregator::FetchQueue::signalStarted
void signalStarted()
Akregator::FetchQueue::signalStopped
void signalStopped()
Akregator::FetchQueue::connectToFeed
void connectToFeed(Feed *feed)
Definition: fetchqueue.cpp:128
Akregator::Feed::fetch
void fetch(bool followDiscovery=false)
starts fetching
Definition: feed.cpp:572
fetchqueue.h
Akregator::Feed::slotAbortFetch
void slotAbortFetch()
Definition: feed.cpp:594
Akregator::FetchQueue::isEmpty
bool isEmpty() const
returns true when no feeds are neither fetching nor queued
Definition: fetchqueue.cpp:113
QList
Definition: article.h:41
Akregator::FetchQueue::~FetchQueue
~FetchQueue()
Definition: fetchqueue.cpp:48
Akregator::FetchQueue::slotFetchAborted
void slotFetchAborted(Akregator::Feed *)
Definition: fetchqueue.cpp:107
Akregator::Feed
represents a feed
Definition: feed.h:53
Akregator::FetchQueue::slotFetchError
void slotFetchError(Akregator::Feed *)
Definition: fetchqueue.cpp:101
Akregator::FetchQueue::slotNodeDestroyed
void slotNodeDestroyed(Akregator::TreeNode *node)
Definition: fetchqueue.cpp:142
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Akregator::FetchQueue::FetchQueue
FetchQueue(QObject *parent=0)
Definition: fetchqueue.cpp:44
Akregator::TreeNode
Abstract base class for all kind of elements in the feed tree, like feeds and feed groups (and search...
Definition: treenode.h:58
Akregator::FetchQueue::fetched
void fetched(Akregator::Feed *)
Akregator::FetchQueue::disconnectFromFeed
void disconnectFromFeed(Feed *feed)
Definition: fetchqueue.cpp:136
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akregator

Skip menu "akregator"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal