libktorrent
2.2.0
src
magnet
magnetlink.h
1
/***************************************************************************
2
* Copyright (C) 2009 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
21
22
#ifndef BT_MAGNETLINK_H
23
#define BT_MAGNETLINK_H
24
25
#include <ktorrent_export.h>
26
#include <util/sha1hash.h>
27
#include <QUrl>
28
29
namespace
bt
30
{
40
class
KTORRENT_EXPORT
MagnetLink
41
{
42
friend
class
MagnetDownloader
;
43
public
:
44
MagnetLink
();
45
MagnetLink
(
const
MagnetLink
& mlink);
46
MagnetLink
(
const
QUrl& mlink);
47
MagnetLink
(
const
QString & mlink);
48
~
MagnetLink
();
49
51
MagnetLink
& operator = (
const
MagnetLink
& mlink);
52
54
bool
operator == (
const
MagnetLink
& mlink)
const
;
55
57
bool
isValid
()
const
{
return
!magnet_string.isEmpty();}
58
60
QString
toString
()
const
{
return
magnet_string;}
61
63
QString
displayName
()
const
{
return
name;}
64
66
QString
subPath
()
const
{
return
path;}
67
69
QString
torrent
()
const
{
return
torrent_url;}
70
72
QList<QUrl>
trackers
()
const
{
return
tracker_urls;}
73
75
const
SHA1Hash
&
infoHash
()
const
{
return
info_hash;}
76
77
private
:
78
void
parse(
const
QUrl& mlink);
79
Uint8 charToHex(
const
QChar & ch);
80
QString base32ToHexString(
const
QString &s);
81
82
private
:
83
QString magnet_string;
84
SHA1Hash
info_hash;
85
QString torrent_url;
86
QList<QUrl> tracker_urls;
87
QString path;
88
QString name;
89
};
90
91
}
92
93
#endif // BT_MAGNETLINK_H
bt::MagnetLink::torrent
QString torrent() const
Get the torrent URL (can be empty)
Definition:
magnetlink.h:69
bt::MagnetDownloader
Definition:
magnetdownloader.h:47
bt::MagnetLink::isValid
bool isValid() const
Is this a valid magnet link.
Definition:
magnetlink.h:57
bt::MagnetLink::infoHash
const SHA1Hash & infoHash() const
Get the info hash.
Definition:
magnetlink.h:75
bt::MagnetLink::trackers
QList< QUrl > trackers() const
Get all possible trackers (can be empty)
Definition:
magnetlink.h:72
bt::SHA1Hash
Stores a SHA1 hash.
Definition:
sha1hash.h:41
bt::MagnetLink
Definition:
magnetlink.h:41
bt::MagnetLink::toString
QString toString() const
Convert it to a string.
Definition:
magnetlink.h:60
bt::MagnetLink::subPath
QString subPath() const
Get the path of addressed file(s) inside the torrent.
Definition:
magnetlink.h:66
bt::MagnetLink::displayName
QString displayName() const
Get the display name (can be empty)
Definition:
magnetlink.h:63
Generated by
1.8.20