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

kget

Public Types | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TransferDataSource Class Referenceabstract

#include <transferdatasource.h>

Inheritance diagram for TransferDataSource:
Inheritance graph
[legend]

Public Types

enum  Error { Unknown, WrongDownloadSize, NotResumeable }
 

Signals

void broken (TransferDataSource *source, TransferDataSource::Error error)
 
void brokenSegments (TransferDataSource *source, QPair< int, int > segmentRange)
 
void capabilitiesChanged ()
 
void data (KIO::fileoffset_t offset, const QByteArray &data, bool &worked)
 
void data (const QList< KUrl > &data)
 
void data (const QString type, const QString checksum)
 
void finished ()
 
void finishedDownload (TransferDataSource *source, KIO::filesize_t fileSize)
 
void finishedSegment (TransferDataSource *source, int segmentNumber, bool connectionFinished=true)
 
void foundFileSize (TransferDataSource *source, KIO::filesize_t fileSize, const QPair< int, int > &segmentRange)
 
void freeSegments (TransferDataSource *source, QPair< int, int > segmentRange)
 
void log (const QString &message, Transfer::LogLevel logLevel)
 
void speed (ulong speed)
 
void urlChanged (const KUrl &old, const KUrl &newUrl)
 

Public Member Functions

 TransferDataSource (const KUrl &srcUrl, QObject *parent)
 
virtual ~TransferDataSource ()
 
virtual void addSegments (const QPair< KIO::fileoffset_t, KIO::fileoffset_t > &segmentSize, const QPair< int, int > &segmentRange)=0
 
virtual QList< QPair< int, int > > assignedSegments () const
 
Transfer::Capabilities capabilities () const
 
virtual int changeNeeded () const
 
virtual int countUnfinishedSegments () const
 
virtual int currentSegments () const
 
ulong currentSpeed () const
 
virtual void findFileSize (KIO::fileoffset_t segmentSize)
 
virtual int paralellSegments () const
 
virtual QPair< int, int > removeConnection ()
 
virtual void setParalellSegments (int paralellSegments)
 
virtual void setSupposedSize (KIO::filesize_t supposedSize)
 
KUrl sourceUrl () const
 
virtual QPair< int, int > split ()
 
virtual void start ()=0
 
virtual void stop ()=0
 

Protected Member Functions

void setCapabilities (Transfer::Capabilities capabilities)
 

Protected Attributes

int m_currentSegments
 
int m_paralellSegments
 
KUrl m_sourceUrl
 
ulong m_speed
 
KIO::filesize_t m_supposedSize
 

Detailed Description

This Class is an interface for inter-plugins data change.

allowing to use already implemented features from others plugins

Definition at line 26 of file transferdatasource.h.

Member Enumeration Documentation

enum TransferDataSource::Error
Enumerator
Unknown 
WrongDownloadSize 
NotResumeable 

Definition at line 33 of file transferdatasource.h.

Constructor & Destructor Documentation

TransferDataSource::TransferDataSource ( const KUrl &  srcUrl,
QObject *  parent 
)

Definition at line 15 of file transferdatasource.cpp.

TransferDataSource::~TransferDataSource ( )
virtual

Definition at line 27 of file transferdatasource.cpp.

Member Function Documentation

virtual void TransferDataSource::addSegments ( const QPair< KIO::fileoffset_t, KIO::fileoffset_t > &  segmentSize,
const QPair< int, int > &  segmentRange 
)
pure virtual

Adds multiple continuous segments that should be downloaded by this TransferDataSource.

Parameters
segmentSizefirst is always the general segmentSize, second the segmentSize of the last segment in the range. If just one (the last) segment was assigned, then first would not equal second, this is to ensure that first can be used to calculate the offset TransferDataSources have to handle all that internally.
segmentRangefirst the beginning, second the end

Implemented in ChecksumSearchTransferDataSource, BTDataSource, MultiSegKioDataSource, and MirrorSearchTransferDataSource.

QList< QPair< int, int > > TransferDataSource::assignedSegments ( ) const
virtual

Returns the assignedSegments to this TransferDataSource Each connection is represented by a QPair, where the first int is the beginning segment and the last the ending segment.

Note
an empty list is returned by default, the elements can also be (-1, -1)

Reimplemented in MultiSegKioDataSource.

Definition at line 53 of file transferdatasource.cpp.

void TransferDataSource::broken ( TransferDataSource *  source,
TransferDataSource::Error  error 
)
signal

Alert that datasource is no able to send any data.

Parameters
sourcethe datasource, sending the signal
void TransferDataSource::brokenSegments ( TransferDataSource *  source,
QPair< int, int >  segmentRange 
)
signal

emitted when an assigned segment is broken

Parameters
sourcethe source that emmited this signal
segmentRangethe range of the segments e.g. (1,1,) or (0, 10)
Transfer::Capabilities TransferDataSource::capabilities ( ) const

Returns the capabilities this TransferDataSource supports.

Definition at line 32 of file transferdatasource.cpp.

void TransferDataSource::capabilitiesChanged ( )
signal

Emitted when the capabilities of the TransferDataSource change.

int TransferDataSource::changeNeeded ( ) const
virtual

Returns the missmatch of paralellSegments() and currentSegments()

Returns
the number of segments to add/remove e.g. -1 means one segment to remove

Definition at line 83 of file transferdatasource.cpp.

int TransferDataSource::countUnfinishedSegments ( ) const
virtual

Returns the number of unfinished Segments of the connection with the most unfinished segments Each TransferDataSource can have multiple connections and each connection can have multiple segments assigned.

Note
default implemention returns 0

Reimplemented in MultiSegKioDataSource.

Definition at line 58 of file transferdatasource.cpp.

int TransferDataSource::currentSegments ( ) const
virtual
Returns
the number of paralell segments this DataSources currently uses

Reimplemented in MultiSegKioDataSource.

Definition at line 78 of file transferdatasource.cpp.

ulong TransferDataSource::currentSpeed ( ) const
inline

returns the current speed of this data source

Returns
the speed

Definition at line 82 of file transferdatasource.h.

void TransferDataSource::data ( KIO::fileoffset_t  offset,
const QByteArray &  data,
bool &  worked 
)
signal

Returns data in the forms of chucks.

Note
if the receiver set worked to wrong the TransferDataSource should cache the data
Parameters
offsetthe offset in the file
datathe downloaded data
workedif the receiver could handle the data, if not, the sender should cache the data
void TransferDataSource::data ( const QList< KUrl > &  data)
signal

Returns data in the forms of URL List.

Parameters
datain form of KUrl list
void TransferDataSource::data ( const QString  type,
const QString  checksum 
)
signal

Returns found checksums with their type.

Parameters
typethe type of the checksum
checksumthe checksum
void TransferDataSource::findFileSize ( KIO::fileoffset_t  segmentSize)
virtual

Tries to find the filesize if this capability is supported, if successfull it emits foundFileSize(TransferDataSource*,KIO::filesize_t,QPair<int,int>) and assigns all segements to itself if not succesfull it will try to download the file nevertheless.

Note
if stop is called and no size is found yet then this is aborted, i.e. needs to be called again if start is later called
Parameters
segmentSizethe segments should have

Reimplemented in MultiSegKioDataSource.

Definition at line 43 of file transferdatasource.cpp.

void TransferDataSource::finished ( )
signal

emitted when there is no more data

Parameters
sourcethe datasource, sending the signal
void TransferDataSource::finishedDownload ( TransferDataSource *  source,
KIO::filesize_t  fileSize 
)
signal

Emitted when the TransferDataSource finished the download on its own, e.g.

when findFileSize is being called but no fileSize is found and instead the download finishes

Parameters
sourcethe source that emmited this signal
fileSizethe fileSize of the finished file (calculated by the downloaded bytes)
void TransferDataSource::finishedSegment ( TransferDataSource *  source,
int  segmentNumber,
bool  connectionFinished = true 
)
signal

emitted when an assigned segment finishes

Parameters
sourcethe source that emmited this signal
segmentNumberthe number of the segment, to identify it
connectionFinishedtrue if all segments of this connection have been finished, if one segement (instead of a group of segments) has been asigned this is always true
void TransferDataSource::foundFileSize ( TransferDataSource *  source,
KIO::filesize_t  fileSize,
const QPair< int, int > &  segmentRange 
)
signal

Emitted after findFileSize is called successfully.

Parameters
sourcethat foudn the filesize
fileSizethat was found
segmentRangethat was calculated based on the segmentSize and that was assigned to source automatically
void TransferDataSource::freeSegments ( TransferDataSource *  source,
QPair< int, int >  segmentRange 
)
signal

Emitted when a Datasource itself decides to not download a specific segmentRange, e.g.

when there are too many connections for this TransferDataSource

void TransferDataSource::log ( const QString &  message,
Transfer::LogLevel  logLevel 
)
signal
int TransferDataSource::paralellSegments ( ) const
virtual
Returns
the number of paralell segments this DataSource is allowed to use, default is 1

Definition at line 68 of file transferdatasource.cpp.

QPair< int, int > TransferDataSource::removeConnection ( )
virtual

Removes one connection, useful when setMaximumParalellDownloads was called with a lower number.

Returns
the segments that are removed (unassigned) now

Reimplemented in MultiSegKioDataSource.

Definition at line 48 of file transferdatasource.cpp.

void TransferDataSource::setCapabilities ( Transfer::Capabilities  capabilities)
protected

Sets the capabilities and automatically emits capabilitiesChanged.

Definition at line 37 of file transferdatasource.cpp.

void TransferDataSource::setParalellSegments ( int  paralellSegments)
virtual

Sets the number of paralell segments this DataSource is allowed to use.

Definition at line 73 of file transferdatasource.cpp.

virtual void TransferDataSource::setSupposedSize ( KIO::filesize_t  supposedSize)
inlinevirtual

Set the size the server used for downloading should report.

Parameters
supposedSizethe size the file should have

Reimplemented in MultiSegKioDataSource.

Definition at line 88 of file transferdatasource.h.

KUrl TransferDataSource::sourceUrl ( ) const
inline

Definition at line 76 of file transferdatasource.h.

void TransferDataSource::speed ( ulong  speed)
signal

The speed of the download.

Parameters
speedspeed of the download
QPair< int, int > TransferDataSource::split ( )
virtual

If a connection of this TransferDataSource is assigned multiple (continuous) segments, then this method will split them (the unfinished ones) in half, it returns the beginning and the end of the now unassigned segments; (-1, -1) if there are none.

Note
if only one segment is assigned to a connection split will also return (-1, -1)

Reimplemented in MultiSegKioDataSource.

Definition at line 63 of file transferdatasource.cpp.

virtual void TransferDataSource::start ( )
pure virtual

Implemented in ChecksumSearchTransferDataSource, BTDataSource, MultiSegKioDataSource, and MirrorSearchTransferDataSource.

virtual void TransferDataSource::stop ( )
pure virtual

Implemented in ChecksumSearchTransferDataSource, BTDataSource, MultiSegKioDataSource, and MirrorSearchTransferDataSource.

void TransferDataSource::urlChanged ( const KUrl &  old,
const KUrl &  newUrl 
)
signal

Emitted when the filename of a url changes, e.g.

when a link redirects

Member Data Documentation

int TransferDataSource::m_currentSegments
protected

Definition at line 246 of file transferdatasource.h.

int TransferDataSource::m_paralellSegments
protected

Definition at line 245 of file transferdatasource.h.

KUrl TransferDataSource::m_sourceUrl
protected

Definition at line 242 of file transferdatasource.h.

ulong TransferDataSource::m_speed
protected

Definition at line 243 of file transferdatasource.h.

KIO::filesize_t TransferDataSource::m_supposedSize
protected

Definition at line 244 of file transferdatasource.h.


The documentation for this class was generated from the following files:
  • transferdatasource.h
  • transferdatasource.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:18 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