Vidalia
0.3.1
Main Page
Namespaces
Classes
Files
File List
File Members
src
vidalia
config
BridgeDownloader.h
Go to the documentation of this file.
1
/*
2
** This file is part of Vidalia, and is subject to the license terms in the
3
** LICENSE file, found in the top level directory of this distribution. If you
4
** did not receive the LICENSE file with this file, you may obtain it from the
5
** Vidalia source package distributed by the Vidalia Project at
6
** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7
** including this file, may be copied, modified, propagated, or distributed
8
** except according to the terms described in the LICENSE file.
9
*/
10
11
/*
12
** \file BridgeDownloader.h
13
** \brief Downloads a list of new bridge addresses via HTTPS
14
*/
15
16
#ifndef _BRIDGEDOWNLOADER_H
17
#define _BRIDGEDOWNLOADER_H
18
19
#include <QtNetwork>
20
21
class
BridgeDownloader
:
public
QObject
22
{
23
Q_OBJECT
24
25
public
:
26
/** Available bridge download methods. */
27
enum
BridgeDownloadMethod
{
28
DownloadMethodHttps
,
/** Download via an HTTPS connection. */
29
};
30
31
/** Default constructor.
32
*/
33
BridgeDownloader
(QObject *parent = 0);
34
35
/** Initiates a request for a set of bridges using the specified
36
* download <b>method</b>. Returns true if the request was initiated
37
* successfully, or false on error.
38
*/
39
bool
downloadBridges
(
BridgeDownloadMethod
method);
40
41
/** Enables HTTPS proxy support, using the proxy server <b>host</b> on
42
* port <b>port</b>. A <b>username</b> and <b>password</b> can also
43
* optionally be supplied, if required by the proxy.
44
*/
45
void
setProxy
(
const
QString &host,
int
port,
46
const
QString &username = QString(),
47
const
QString &password = QString());
48
49
/** Returns true if <b>method</b> is supported by the currently
50
* available Qt libraries.
51
*/
52
static
bool
isMethodSupported
(
BridgeDownloadMethod
method);
53
54
public
slots:
55
/** Cancels any pending bridge download requests.
56
*/
57
void
cancelBridgeRequest
();
58
59
signals:
60
/** Emitted when the underlying QHttp object reads data from an HTTPS
61
* response. <b>done</b> indicates how many bytes out of <b>total</b>
62
* have been read so far. Note that <b>total</b> may be 0 if the expected
63
* total size of the response is not known.
64
*/
65
void
downloadProgress
(qint64 done, qint64 total);
66
67
/** Emitted when the status of the bridge request changes. <b>status</b>
68
* describes the new current state of the request.
69
*/
70
void
statusChanged
(
const
QString &status);
71
72
/** Emitted when the previous request for bridge addresses completes
73
* successfully. The QStringList <b>bridges</b> contains a (possibly empty)
74
* list of bridge addresses parsed from the received response.
75
*/
76
void
bridgeRequestFinished
(
const
QStringList &bridges);
77
78
/** Emitted when the previous request for bridge addresses fails. The
79
* QString <b>error</b> is a human-readable string describing the error
80
* encountered.
81
*/
82
void
bridgeRequestFailed
(
const
QString &
error
);
83
84
private
slots:
85
/** Called when the state of the underlying QHttp object changes. A
86
* statusChanged() signal is emitted with the appropriate text
87
* describing the new state of the request.
88
*/
89
void
httpsStateChanged
(
int
state);
90
91
/** Called when the underlying QHttp object used to make the bridge
92
* request completes. <b>error</b> is set to false if the request was
93
* successful, or true if the request failed. If <b>id</b> does not
94
* match the request ID previously returned by QHttp::get(), then the
95
* signal is ignored since it is the result of a close() or abort()
96
* request.
97
*/
98
void
httpsRequestFinished
(QNetworkReply *reply);
99
100
/** Called when the HTTPS connection encounters one or more
101
* <b>sslErrors</b>. Currently the errors are just logged and
102
* bridgeRequestFailed() is <i>not</i> emitted, since QHttp will also
103
* emit
104
*/
105
void
sslErrors
(QNetworkReply *,
const
QList<QSslError> &
sslErrors
);
106
107
private
:
108
/** Initiates an HTTPS connection to bridges.torproject.org to start
109
* downloading a set of bridges.
110
*/
111
void
startHttpsDownload
();
112
113
/** Used to connect to the bridge database, send an HTTPS request for
114
* new bridge addresses and then read the response. */
115
QNetworkAccessManager*
_https
;
116
117
/** Identifier of the current bridge request */
118
QNetworkReply *
_reply
;
119
};
120
121
#endif
122
Generated on Mon Jan 14 2013 08:44:27 for Vidalia by
1.8.3