Vidalia  0.2.15
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Private Slots | Private Member Functions | Private Attributes
BridgeDownloader Class Reference

#include <BridgeDownloader.h>

List of all members.

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

Detailed Description

Definition at line 21 of file BridgeDownloader.h.


Member Enumeration Documentation

Available bridge download methods.

Enumerator:
DownloadMethodHttps 

Definition at line 27 of file BridgeDownloader.h.


Constructor & Destructor Documentation

BridgeDownloader::BridgeDownloader ( QObject *  parent = 0)

Default constructor.

Definition at line 22 of file BridgeDownloader.cpp.

References _https, httpsRequestFinished(), and sslErrors().


Member Function Documentation

void BridgeDownloader::bridgeRequestFailed ( const QString &  error) [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().

void BridgeDownloader::bridgeRequestFinished ( const QStringList &  bridges) [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().

void BridgeDownloader::cancelBridgeRequest ( ) [slot]

Cancels any pending bridge download requests.

Definition at line 84 of file BridgeDownloader.cpp.

References _reply.

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().

void BridgeDownloader::downloadProgress ( qint64  done,
qint64  total 
) [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().

void BridgeDownloader::httpsRequestFinished ( QNetworkReply *  reply) [private, slot]

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(), vInfo, and vWarn.

Referenced by BridgeDownloader().

void BridgeDownloader::httpsStateChanged ( int  state) [private, slot]

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().

bool BridgeDownloader::isMethodSupported ( BridgeDownloadMethod  method) [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().

void BridgeDownloader::sslErrors ( QNetworkReply *  reply,
const QList< QSslError > &  sslErrors 
) [private, slot]

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 vWarn.

Referenced by BridgeDownloader().

void BridgeDownloader::startHttpsDownload ( ) [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, downloadProgress(), statusChanged(), and vInfo.

Referenced by downloadBridges().

void BridgeDownloader::statusChanged ( const QString &  status) [signal]

Emitted when the status of the bridge request changes. status describes the new current state of the request.

Referenced by httpsStateChanged(), and startHttpsDownload().


Member Data Documentation

QNetworkAccessManager* BridgeDownloader::_https [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().

QNetworkReply* BridgeDownloader::_reply [private]

Identifier of the current bridge request

Definition at line 118 of file BridgeDownloader.h.

Referenced by cancelBridgeRequest(), httpsRequestFinished(), and startHttpsDownload().


The documentation for this class was generated from the following files: