Vidalia 0.3.1
|
#include <BridgeDownloader.h>
Public Types | |
enum | BridgeDownloadMethod { DownloadMethodHttps } |
Public Slots | |
void | cancelBridgeRequest () |
Signals | |
void | downloadProgress (qint64 done, qint64 total) |
void | statusChanged (const QString &status) |
void | bridgeRequestFinished (const QStringList &bridges) |
void | bridgeRequestFailed (const QString &error) |
Public Member Functions | |
BridgeDownloader (QObject *parent=0) | |
bool | downloadBridges (BridgeDownloadMethod method) |
void | setProxy (const QString &host, int port, const QString &username=QString(), const QString &password=QString()) |
Static Public Member Functions | |
static bool | isMethodSupported (BridgeDownloadMethod method) |
Private Slots | |
void | httpsStateChanged (int state) |
void | httpsRequestFinished (QNetworkReply *reply) |
void | sslErrors (QNetworkReply *, const QList< QSslError > &sslErrors) |
Private Member Functions | |
void | startHttpsDownload () |
Private Attributes | |
QNetworkAccessManager * | _https |
QNetworkReply * | _reply |
Definition at line 21 of file BridgeDownloader.h.
Available bridge download methods.
Enumerator | |
---|---|
DownloadMethodHttps |
Definition at line 27 of file BridgeDownloader.h.
BridgeDownloader::BridgeDownloader | ( | QObject * | parent = 0 | ) |
Default constructor.
Definition at line 22 of file BridgeDownloader.cpp.
References _https, connect(), httpsRequestFinished(), and sslErrors().
|
signal |
Emitted when the previous request for bridge addresses fails. The QString error is a human-readable string describing the error encountered.
Referenced by httpsRequestFinished().
|
signal |
Emitted when the previous request for bridge addresses completes successfully. The QStringList bridges contains a (possibly empty) list of bridge addresses parsed from the received response.
Referenced by httpsRequestFinished().
|
slot |
Cancels any pending bridge download requests.
Definition at line 84 of file BridgeDownloader.cpp.
References _reply, and disconnect().
Referenced by NetworkPage::findBridges().
bool BridgeDownloader::downloadBridges | ( | BridgeDownloadMethod | method | ) |
Initiates a request for a set of bridges using the specified download method. Returns true if the request was initiated successfully, or false on error.
Definition at line 41 of file BridgeDownloader.cpp.
References DownloadMethodHttps, isMethodSupported(), and startHttpsDownload().
Referenced by NetworkPage::startBridgeRequest().
|
signal |
Emitted when the underlying QHttp object reads data from an HTTPS response. done indicates how many bytes out of total have been read so far. Note that total may be 0 if the expected total size of the response is not known.
Referenced by startHttpsDownload().
|
privateslot |
Called when the underlying QHttp object used to make the bridge request completes. error is set to false if the request was successful, or true if the request failed. If id does not match the request ID previously returned by QHttp::get(), then the signal is ignored since it is the result of a close() or abort() request.
Definition at line 113 of file BridgeDownloader.cpp.
References _reply, bridgeRequestFailed(), bridgeRequestFinished(), disconnect(), vInfo, and vWarn.
Referenced by BridgeDownloader().
|
privateslot |
Called when the state of the underlying QHttp object changes. A statusChanged() signal is emitted with the appropriate text describing the new state of the request.
Definition at line 91 of file BridgeDownloader.cpp.
References BRIDGEDB_HOST, BRIDGEDB_PORT, and statusChanged().
|
static |
Returns true if method is supported by the currently available Qt libraries.
Definition at line 58 of file BridgeDownloader.cpp.
References DownloadMethodHttps.
Referenced by downloadBridges(), and NetworkPage::NetworkPage().
void BridgeDownloader::setProxy | ( | const QString & | host, |
int | port, | ||
const QString & | username = QString() , |
||
const QString & | password = QString() |
||
) |
Enables HTTPS proxy support, using the proxy server host on port port. A username and password can also optionally be supplied, if required by the proxy.
Definition at line 34 of file BridgeDownloader.cpp.
References _https.
Referenced by NetworkPage::startBridgeRequest().
|
privateslot |
Called when the HTTPS connection encounters one or more sslErrors. Currently the errors are just logged and bridgeRequestFailed() is not emitted, since QHttp will also emit
Definition at line 137 of file BridgeDownloader.cpp.
References sslErrors(), and vWarn.
Referenced by BridgeDownloader(), and sslErrors().
|
private |
Initiates an HTTPS connection to bridges.torproject.org to start downloading a set of bridges.
Definition at line 71 of file BridgeDownloader.cpp.
References _https, _reply, BRIDGEDB_HOST, BRIDGEDB_PORT, connect(), downloadProgress(), statusChanged(), and vInfo.
Referenced by downloadBridges().
|
signal |
Emitted when the status of the bridge request changes. status describes the new current state of the request.
Referenced by httpsStateChanged(), and startHttpsDownload().
|
private |
Used to connect to the bridge database, send an HTTPS request for new bridge addresses and then read the response.
Definition at line 115 of file BridgeDownloader.h.
Referenced by BridgeDownloader(), setProxy(), and startHttpsDownload().
|
private |
Identifier of the current bridge request
Definition at line 118 of file BridgeDownloader.h.
Referenced by cancelBridgeRequest(), httpsRequestFinished(), and startHttpsDownload().