libktorrent
2.1.1
src
torrent
torrentcreator.h
1
/***************************************************************************
2
* Copyright (C) 2005 by Joris Guisson *
3
* joris.guisson@gmail.com *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
* *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
14
* *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
20
#ifndef BTTORRENTCREATOR_H
21
#define BTTORRENTCREATOR_H
22
23
#include <QThread>
24
#include <QStringList>
25
#include <util/sha1hash.h>
26
#include <ktorrent_export.h>
27
#include "torrent.h"
28
29
namespace
bt
30
{
31
class
BEncoder;
32
class
TorrentControl;
33
42
class
KTORRENT_EXPORT TorrentCreator :
public
QThread
43
{
44
Q_OBJECT
45
46
// input values
47
QString target;
48
QStringList trackers;
49
QList<QUrl> webseeds;
50
int
chunk_size;
51
QString name,comments;
52
// calculated values
53
Uint32 num_chunks;
54
Uint64 last_size;
55
QList<TorrentFile> files;
56
QList<SHA1Hash> hashes;
57
//
58
Uint32 cur_chunk;
59
bool
priv;
60
Uint64 tot_size;
61
bool
decentralized;
62
bool
stopped;
63
public
:
74
TorrentCreator
(
const
QString & target,
const
QStringList & trackers,
const
QList<QUrl> & webseeds,
75
Uint32 chunk_size,
const
QString & name,
76
const
QString & comments,
bool
priv,
bool
decentralized);
77
~
TorrentCreator
()
override
;
78
80
Uint32 getNumChunks()
const
{
return
num_chunks;}
81
82
Uint32 getCurrentChunk()
const
{
return
cur_chunk;}
83
89
void
saveTorrent(
const
QString & url);
90
101
TorrentControl* makeTC(
const
QString & data_dir);
102
104
void
stop() {stopped =
true
;}
105
106
private
:
107
void
saveInfo(
BEncoder
& enc);
108
void
saveFile(
BEncoder
& enc,
const
TorrentFile
& file);
109
void
savePieces(
BEncoder
& enc);
110
void
buildFileList(
const
QString & dir);
111
bool
calcHashSingle();
112
bool
calcHashMulti();
113
void
run()
override
;
114
bool
calculateHash();
115
};
116
117
}
118
119
#endif
bt::BEncoder
Helper class to b-encode stuff.
Definition:
bencoder.h:92
bt::TorrentCreator
Class to generate torrent files.
Definition:
torrentcreator.h:61
bt::TorrentFile
Definition:
torrentfile.h:61
Generated by
1.8.18