/usr/include/libktorrent/torrent/torrentcreator.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 | /***************************************************************************
* Copyright (C) 2005 by Joris Guisson *
* joris.guisson@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 BTTORRENTCREATOR_H
#define BTTORRENTCREATOR_H
#include <QThread>
#include <QStringList>
#include <util/sha1hash.h>
#include <ktorrent_export.h>
#include "torrent.h"
namespace bt
{
class BEncoder;
class TorrentControl;
/**
* @author Joris Guisson
* @brief Class to generate torrent files
*
* This class generates torrent files.
* It also allows to create a TorrentControl object, so
* that we immediately can start to share the torrent.
*/
class KTORRENT_EXPORT TorrentCreator : public QThread
{
Q_OBJECT
// input values
QString target;
QStringList trackers;
KUrl::List webseeds;
int chunk_size;
QString name,comments;
// calculated values
Uint32 num_chunks;
Uint64 last_size;
QList<TorrentFile> files;
QList<SHA1Hash> hashes;
//
Uint32 cur_chunk;
bool priv;
Uint64 tot_size;
bool decentralized;
bool stopped;
public:
/**
* Constructor.
* @param target The file or directory to make a torrent of
* @param trackers A list of tracker urls
* @param webseeds A list of webseed urls
* @param chunk_size The size of each chunk
* @param name The name suggestion
* @param comments The comments field of the torrent
* @param priv Private torrent or not
*/
TorrentCreator(const QString & target,const QStringList & trackers,const KUrl::List & webseeds,
Uint32 chunk_size,const QString & name,
const QString & comments,bool priv,bool decentralized);
virtual ~TorrentCreator();
/// Get the number of chunks
Uint32 getNumChunks() const {return num_chunks;}
Uint32 getCurrentChunk() const {return cur_chunk;}
/**
* Save the torrent file.
* @param url Filename
* @throw Error if something goes wrong
*/
void saveTorrent(const QString & url);
/**
* Make a TorrentControl object for this torrent.
* This will also create the files :
* data_dir/index
* data_dir/torrent
* data_dir/cache (symlink to target)
* @param data_dir The data directory
* @throw Error if something goes wrong
* @return The newly created object
*/
TorrentControl* makeTC(const QString & data_dir);
/// Stop the thread
void stop() {stopped = true;}
private:
void saveInfo(BEncoder & enc);
void saveFile(BEncoder & enc,const TorrentFile & file);
void savePieces(BEncoder & enc);
void buildFileList(const QString & dir);
bool calcHashSingle();
bool calcHashMulti();
virtual void run();
bool calculateHash();
};
}
#endif
|