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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
DownloadQueueSet.h
Go to the documentation of this file.
1 // Copyright 2009 Jens-Michael Hoffmann <jmho@c-xx.com>
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library. If not, see <http://www.gnu.org/licenses/>.
15 
16 #ifndef MARBLE_DOWNLOADQUEUESET_H
17 #define MARBLE_DOWNLOADQUEUESET_H
18 
19 #include <QList>
20 #include <QQueue>
21 #include <QObject>
22 #include <QSet>
23 #include <QStack>
24 #include <QUrl>
25 
26 #include "DownloadPolicy.h"
27 
28 namespace Marble
29 {
30 
31 class HttpJob;
32 
72 class DownloadQueueSet: public QObject
73 {
74  Q_OBJECT
75 
76  public:
77  explicit DownloadQueueSet( QObject * const parent = 0 );
78  explicit DownloadQueueSet( const DownloadPolicy& policy, QObject * const parent = 0 );
79  ~DownloadQueueSet();
80 
81  DownloadPolicy downloadPolicy() const;
82  void setDownloadPolicy( const DownloadPolicy& );
83 
84  bool canAcceptJob( const QUrl& sourceUrl,
85  const QString& destinationFileName ) const;
86  void addJob( HttpJob * const job );
87 
88  void activateJobs();
89  void retryJobs();
90  void purgeJobs();
91 
92  Q_SIGNALS:
93  void jobAdded();
94  void jobRemoved();
95  void jobRetry();
96  void jobFinished( const QByteArray& data, const QString& destinationFileName,
97  const QString& id );
98  void jobRedirected( const QUrl& newSourceUrl, const QString& destinationFileName,
99  const QString& id, DownloadUsage );
100  void progressChanged( int active, int queued );
101 
102  private Q_SLOTS:
103  void finishJob( HttpJob * job, const QByteArray& data );
104  void redirectJob( HttpJob * job, const QUrl& newSourceUrl );
105  void retryOrBlacklistJob( HttpJob * job, const int errorCode );
106 
107  private:
108  void activateJob( HttpJob * const job );
109  void deactivateJob( HttpJob * const job );
110  bool jobIsActive( const QString& destinationFileName ) const;
111  bool jobIsQueued( const QString& destinationFileName ) const;
112  bool jobIsWaitingForRetry( const QString& destinationFileName ) const;
113  bool jobIsBlackListed( const QUrl& sourceUrl ) const;
114 
115  DownloadPolicy m_downloadPolicy;
116 
120  class JobStack
121  {
122  public:
123  bool contains( const QString& destinationFileName ) const;
124  int count() const;
125  bool isEmpty() const;
126  HttpJob * pop();
127  void push( HttpJob * const );
128  private:
129  QStack<HttpJob*> m_jobs;
130  QSet<QString> m_jobsContent;
131  };
132  JobStack m_jobs;
133 
135  QList<HttpJob*> m_activeJobs;
136 
140  QQueue<HttpJob*> m_retryQueue;
141 
143  QSet<QString> m_jobBlackList;
144 };
145 
146 }
147 
148 #endif
Marble::DownloadQueueSet::jobRetry
void jobRetry()
Marble::DownloadPolicy
Definition: DownloadPolicy.h:55
Marble::DownloadQueueSet::jobAdded
void jobAdded()
Marble::DownloadQueueSet::jobFinished
void jobFinished(const QByteArray &data, const QString &destinationFileName, const QString &id)
QQueue
Marble::DownloadUsage
DownloadUsage
This enum is used to describe the type of download.
Definition: MarbleGlobal.h:164
QByteArray
Marble::DownloadQueueSet::activateJobs
void activateJobs()
Definition: DownloadQueueSet.cpp:85
Marble::DownloadQueueSet::addJob
void addJob(HttpJob *const job)
Definition: DownloadQueueSet.cpp:76
Marble::DownloadQueueSet
Life of a HttpJob
Definition: DownloadQueueSet.h:72
Marble::DownloadQueueSet::setDownloadPolicy
void setDownloadPolicy(const DownloadPolicy &)
Definition: DownloadQueueSet.cpp:46
Marble::DownloadQueueSet::jobRemoved
void jobRemoved()
Marble::DownloadQueueSet::jobRedirected
void jobRedirected(const QUrl &newSourceUrl, const QString &destinationFileName, const QString &id, DownloadUsage)
DownloadPolicy.h
QObject
Marble::DownloadQueueSet::canAcceptJob
bool canAcceptJob(const QUrl &sourceUrl, const QString &destinationFileName) const
Definition: DownloadQueueSet.cpp:51
Marble::DownloadQueueSet::progressChanged
void progressChanged(int active, int queued)
QSet< QString >
QString
QList
QUrl
Marble::DownloadQueueSet::~DownloadQueueSet
~DownloadQueueSet()
Definition: DownloadQueueSet.cpp:36
QObject::parent
QObject * parent() const
Marble::DownloadQueueSet::purgeJobs
void purgeJobs()
Definition: DownloadQueueSet.cpp:105
Marble::DownloadQueueSet::DownloadQueueSet
DownloadQueueSet(QObject *const parent=0)
Definition: DownloadQueueSet.cpp:25
Marble::HttpJob
Definition: HttpJob.h:33
Marble::DownloadQueueSet::retryJobs
void retryJobs()
Definition: DownloadQueueSet.cpp:95
Marble::DownloadQueueSet::downloadPolicy
DownloadPolicy downloadPolicy() const
Definition: DownloadQueueSet.cpp:41
QStack
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

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