/usr/include/libktorrent/interfaces/piecedownloader.h is in libktorrent-dev 1.3.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | /***************************************************************************
* Copyright (C) 2007 by Joris Guisson and Ivan Vasic *
* joris.guisson@gmail.com *
* ivasic@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef BTPIECEDOWNLOADER_H
#define BTPIECEDOWNLOADER_H
#include <QObject>
#include <ktorrent_export.h>
#include <util/constants.h>
namespace bt
{
class Piece;
class Request;
/**
* Interface for all things which want to download pieces from something.
* @author Joris Guisson
*/
class KTORRENT_EXPORT PieceDownloader : public QObject
{
Q_OBJECT
public:
PieceDownloader();
virtual ~PieceDownloader();
/**
* Grab the Peer, indicates how many ChunkDownload's
* are using this PeerDownloader.
* @return The number of times this PeerDownloader was grabbed
*/
int grab();
/**
* When a ChunkDownload is ready with this PeerDownloader,
* it will release it, so that others can use it.
*/
void release();
/// Get the number of times this PeerDownloader was grabbed.
int getNumGrabbed() const {return grabbed;}
/**
* Send a Request.
* @param req The Request
*/
virtual void download(const bt::Request & req) = 0;
/**
* Cancel a Request.
* @param req The Request
*/
virtual void cancel(const bt::Request & req) = 0;
/**
* Cancel all Requests
*/
virtual void cancelAll() = 0;
/**
* Get the name of the PieceDownloader
* This is something which can be shown in the GUI.
* For a regular PeerDownloader, this should be the client and version.
* For a webseed this should be the URL
*/
virtual QString getName() const = 0;
/**
* Get the current download rate.
* @return The download rate in bytes/sec
*/
virtual bt::Uint32 getDownloadRate() const = 0;
/**
* See if the PieceDownloader is choked, can be overwritten by subclasses.
* @return Whether or not the PieceDownloader is choked
*/
virtual bool isChoked() const {return false;}
/**
* Whether or not we can add another request.
*/
virtual bool canAddRequest() const = 0;
/**
* Whether or not we can download another chunk from this.
*/
virtual bool canDownloadChunk() const = 0;
/// See if this PieceDownloader has nearly finished a chunk
bool isNearlyDone() const {return getNumGrabbed() == 1 && nearly_done;}
/// Set the nearly done status of the PeerDownloader
void setNearlyDone(bool nd) {nearly_done = nd;}
/**
* See if the PieceDownloader has a Chunk.
* By default this returns true, but it can be
* overridden by subclasses.
* @param idx The Chunk's index
*/
virtual bool hasChunk(bt::Uint32 /*idx*/) const {return true;}
/**
* Check if requests have timedout
*/
virtual void checkTimeouts() = 0;
signals:
/**
* Emitted when a request takes longer then 60 seconds to download.
* The sender of the request will have to request it again. This does not apply for
* unsent requests. Their timestamps will be updated when they get transmitted.
* @param r The request
*/
void timedout(const bt::Request & r);
/**
* A request was rejected.
* @param req The Request
*/
void rejected(const bt::Request & req);
private:
int grabbed;
bool nearly_done;
};
}
#endif
|