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

kget

  • sources
  • kde-4.12
  • kdenetwork
  • kget
  • core
transferdatasource.h
Go to the documentation of this file.
1 /* This file is part of the KDE project
2 
3  Copyright (C) 2008 Manolo Valdes <nolis71cu@gmail.com>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 */
10 
11 
12 #ifndef TRANSFERDATASOURCE_H
13 #define TRANSFERDATASOURCE_H
14 
15 #include "kget_export.h"
16 #include "transfer.h"
17 
18 #include <QObject>
19 
20 #include <kio/job.h>
21 
26 class KGET_EXPORT TransferDataSource : public QObject
27 {
28  Q_OBJECT
29  public:
30  TransferDataSource(const KUrl &srcUrl, QObject *parent);
31  virtual ~TransferDataSource();
32 
33  enum Error
34  {
35  Unknown,
36  WrongDownloadSize,
37  NotResumeable
38  };
39 
43  Transfer::Capabilities capabilities() const;
44 
45  virtual void start() = 0;
46  virtual void stop() = 0;
47 
57  virtual void findFileSize(KIO::fileoffset_t segmentSize);
58 
67  virtual void addSegments(const QPair<KIO::fileoffset_t, KIO::fileoffset_t> &segmentSize, const QPair<int, int> &segmentRange) = 0;
68 
74  virtual QPair<int, int> removeConnection();
75 
76  KUrl sourceUrl() const {return m_sourceUrl;}//TODO
77 
82  ulong currentSpeed() const {return m_speed;}
83 
88  virtual void setSupposedSize(KIO::filesize_t supposedSize) {m_supposedSize = supposedSize;}
89 
96  virtual QList<QPair<int, int> > assignedSegments() const;
97 
105  virtual int countUnfinishedSegments() const;
106 
113  virtual QPair<int, int> split();//TODO should split also take the current running segment into account?
114 
115 
116  //the following methods are used for managing the number of paralell connections
117  //subclasses have to keep track of the currentSegments
122  virtual int paralellSegments() const;
123 
127  virtual void setParalellSegments(int paralellSegments);
128 
132  virtual int currentSegments() const;
133 
138  virtual int changeNeeded() const;
139 
140  signals:
148  void foundFileSize(TransferDataSource *source, KIO::filesize_t fileSize, const QPair<int, int> &segmentRange);
149 
153  void capabilitiesChanged();
154 
161  void finishedDownload(TransferDataSource *source, KIO::filesize_t fileSize);
162 
170  void data(KIO::fileoffset_t offset, const QByteArray &data, bool &worked);
171 
176  void data(const QList<KUrl> &data);
177 
183  void data(const QString type, const QString checksum);
184 
189  void finished();
190 
198  void finishedSegment(TransferDataSource *source, int segmentNumber, bool connectionFinished = true);
199 
204  void broken(TransferDataSource *source, TransferDataSource::Error error);
205 
211  void brokenSegments(TransferDataSource *source, QPair<int, int> segmentRange);
212 
217  void speed(ulong speed);
218 
223  void freeSegments(TransferDataSource *source, QPair<int, int> segmentRange);
224 
225  void log(const QString &message, Transfer::LogLevel logLevel);
226 
230  void urlChanged(const KUrl &old, const KUrl &newUrl);
231 
232  protected:
236  void setCapabilities(Transfer::Capabilities capabilities);
237 
238  private Q_SLOTS:
239  virtual void slotSpeed(ulong speed) {Q_UNUSED(speed)}
240 
241  protected:
242  KUrl m_sourceUrl;
243  ulong m_speed;
244  KIO::filesize_t m_supposedSize;
245  int m_paralellSegments;
246  int m_currentSegments;
247 
248  private:
249  Transfer::Capabilities m_capabilities;
250 };
251 #endif
TransferDataSource::m_sourceUrl
KUrl m_sourceUrl
Definition: transferdatasource.h:242
TransferDataSource::Error
Error
Definition: transferdatasource.h:33
TransferDataSource::m_supposedSize
KIO::filesize_t m_supposedSize
Definition: transferdatasource.h:244
Transfer::LogLevel
LogLevel
Definition: transfer.h:81
TransferDataSource::Unknown
Definition: transferdatasource.h:35
TransferDataSource::currentSpeed
ulong currentSpeed() const
returns the current speed of this data source
Definition: transferdatasource.h:82
TransferDataSource::m_speed
ulong m_speed
Definition: transferdatasource.h:243
TransferDataSource
This Class is an interface for inter-plugins data change.
Definition: transferdatasource.h:26
QObject
kget_export.h
TransferDataSource::sourceUrl
KUrl sourceUrl() const
Definition: transferdatasource.h:76
TransferDataSource::m_currentSegments
int m_currentSegments
Definition: transferdatasource.h:246
TransferDataSource::m_paralellSegments
int m_paralellSegments
Definition: transferdatasource.h:245
transfer.h
KGET_EXPORT
#define KGET_EXPORT
Definition: kget_export.h:24
TransferDataSource::WrongDownloadSize
Definition: transferdatasource.h:36
TransferDataSource::setSupposedSize
virtual void setSupposedSize(KIO::filesize_t supposedSize)
Set the size the server used for downloading should report.
Definition: transferdatasource.h:88
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

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

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

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