Torc  0.1
Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
TorcNetwork Class Reference

Subclass of QNetworkAccessManager for sending network requests and monitoring the network state. More...

#include <torcnetwork.h>

Inheritance diagram for TorcNetwork:
[legend]

Signals

void NewRequest (TorcNetworkRequest *Request)
 
void CancelRequest (TorcNetworkRequest *Request)
 
void PokeRequest (TorcNetworkRequest *Request)
 
void NewAsyncRequest (TorcNetworkRequest *Request, QObject *Parent)
 

Public Member Functions

virtual ~TorcNetwork ()
 

Static Public Member Functions

static bool IsAvailable (void)
 
static bool IsOwnAddress (const QHostAddress &Address)
 
static bool Get (TorcNetworkRequest *Request)
 
static void Cancel (TorcNetworkRequest *Request)
 
static void Poke (TorcNetworkRequest *Request)
 
static bool GetAsynchronous (TorcNetworkRequest *Request, QObject *Parent)
 Queue an asynchronous HTTP request. More...
 
static void AddHostName (const QString &Host)
 Register a known host name for this application. More...
 
static void RemoveHostName (const QString &Host)
 Remove a host name from the known list of host names. More...
 
static QStringList GetHostNames (void)
 Retrieve the list of currently identified host names. More...
 
static QString IPAddressToLiteral (const QHostAddress &Address, int Port, bool UseLocalhost=true)
 Convert an IP address to a string literal. More...
 
static bool IsExternal (const QHostAddress &Address)
 Returns true if the address is accessible from other devices. More...
 
static bool IsLinkLocal (const QHostAddress &Address)
 
static bool IsLocal (const QHostAddress &Address)
 
static bool IsGlobal (const QHostAddress &Address)
 
static QList< QSslError > AllowableSslErrors (const QList< QSslError > &Errors)
 

Protected Slots

void ConfigurationAdded (const QNetworkConfiguration &Config)
 
void ConfigurationChanged (const QNetworkConfiguration &Config)
 
void ConfigurationRemoved (const QNetworkConfiguration &Config)
 
void OnlineStateChanged (bool Online)
 
void UpdateCompleted (void)
 
void ReadyRead (void)
 
void Finished (void)
 
void Error (QNetworkReply::NetworkError Code)
 
void SSLErrors (const QList< QSslError > &Errors)
 
void DownloadProgress (qint64 Received, qint64 Total)
 
void Authenticate (QNetworkReply *Reply, QAuthenticator *Authenticator)
 
void NewHostName (const QHostInfo &Info)
 Receives host name updates from QHostInfo. More...
 

Protected Member Functions

 TorcNetwork ()
 
bool IsOnline (void)
 
bool IsOwnAddressPriv (const QHostAddress &Address)
 
bool CheckHeaders (TorcNetworkRequest *Request, QNetworkReply *Reply)
 
bool Redirected (TorcNetworkRequest *Request, QNetworkReply *Reply)
 
void CloseConnections (void)
 Cancel all current network requests. More...
 
void UpdateConfiguration (bool Creating=false)
 

Static Protected Member Functions

static void Setup (bool Create)
 

Friends

class TorcNetworkObject
 

Detailed Description

Subclass of QNetworkAccessManager for sending network requests and monitoring the network state.

Todo:
Check whether authenticationRequired signal is being emitted.

Definition at line 22 of file torcnetwork.h.

Constructor & Destructor Documentation

TorcNetwork::~TorcNetwork ( )
virtual

Definition at line 344 of file torcnetwork.cpp.

TorcNetwork::TorcNetwork ( )
protected

Definition at line 313 of file torcnetwork.cpp.

Member Function Documentation

void TorcNetwork::AddHostName ( const QString &  Host)
static

Register a known host name for this application.

Host names are currently used to validate cross domain HTTP requests. New host names are added via reverse DNS lookup when an external network connection becomes available and via successful Bonjour services registration events (Bonjour typically uses a different host name).

See also
RemoveHostName
GetHostNames

Definition at line 131 of file torcnetwork.cpp.

QList< QSslError > TorcNetwork::AllowableSslErrors ( const QList< QSslError > &  Errors)
static

Definition at line 645 of file torcnetwork.cpp.

void TorcNetwork::Authenticate ( QNetworkReply *  Reply,
QAuthenticator *  Authenticator 
)
protectedslot

Definition at line 707 of file torcnetwork.cpp.

void TorcNetwork::Cancel ( TorcNetworkRequest Request)
static

Definition at line 73 of file torcnetwork.cpp.

void TorcNetwork::CancelRequest ( TorcNetworkRequest Request)
signal
bool TorcNetwork::CheckHeaders ( TorcNetworkRequest Request,
QNetworkReply *  Reply 
)
protected

Definition at line 480 of file torcnetwork.cpp.

void TorcNetwork::CloseConnections ( void  )
protected

Cancel all current network requests.

This method can be called when the TorcNetwork singleton is being destroyed, when network access has been disallowed or when the network is down. It is reasonable to expect outstanding requests in the latter 2 cases but well behaved clients should have cancelled any requests in the first case. Hence we warn in this instance.

Note
Command line applications currently do not run an admin thread and call QCoreApplication::quit to close the application. In this specific case, the main event loop is no longer running when clients call TorcNetwork::Cancel, the CancelRequest signal is never sent/received and requests may still be outstanding.

Definition at line 735 of file torcnetwork.cpp.

void TorcNetwork::ConfigurationAdded ( const QNetworkConfiguration &  Config)
protectedslot

Definition at line 451 of file torcnetwork.cpp.

void TorcNetwork::ConfigurationChanged ( const QNetworkConfiguration &  Config)
protectedslot

Definition at line 457 of file torcnetwork.cpp.

void TorcNetwork::ConfigurationRemoved ( const QNetworkConfiguration &  Config)
protectedslot

Definition at line 463 of file torcnetwork.cpp.

void TorcNetwork::DownloadProgress ( qint64  Received,
qint64  Total 
)
protectedslot

Definition at line 698 of file torcnetwork.cpp.

void TorcNetwork::Error ( QNetworkReply::NetworkError  Code)
protectedslot

Definition at line 633 of file torcnetwork.cpp.

void TorcNetwork::Finished ( void  )
protectedslot

Definition at line 601 of file torcnetwork.cpp.

bool TorcNetwork::Get ( TorcNetworkRequest Request)
static

Definition at line 60 of file torcnetwork.cpp.

bool TorcNetwork::GetAsynchronous ( TorcNetworkRequest Request,
QObject *  Parent 
)
static

Queue an asynchronous HTTP request.

This is a method for Parent objects that are QObject subclasses residing in a full QThread. The parent must implement a RequestReady(TorcNetworkRequest*) public slot, which will be invoked once the download is complete. There is no need to cancel the request unless it is no longer required.

Definition at line 94 of file torcnetwork.cpp.

QStringList TorcNetwork::GetHostNames ( void  )
static

Retrieve the list of currently identified host names.

See also
AddHostName
RemoveHostName

Definition at line 183 of file torcnetwork.cpp.

QString TorcNetwork::IPAddressToLiteral ( const QHostAddress &  Address,
int  Port,
bool  UseLocalhost = true 
)
static

Convert an IP address to a string literal.

For an IPv4 address, this is a no-op. For IPv6 addresses, we need to remove the scope Id if present and wrap the remainder in braces.

Definition at line 196 of file torcnetwork.cpp.

bool TorcNetwork::IsAvailable ( void  )
static

Definition at line 46 of file torcnetwork.cpp.

bool TorcNetwork::IsExternal ( const QHostAddress &  Address)
static

Returns true if the address is accessible from other devices.

Definition at line 222 of file torcnetwork.cpp.

bool TorcNetwork::IsGlobal ( const QHostAddress &  Address)
static

Definition at line 258 of file torcnetwork.cpp.

bool TorcNetwork::IsLinkLocal ( const QHostAddress &  Address)
static

Definition at line 229 of file torcnetwork.cpp.

bool TorcNetwork::IsLocal ( const QHostAddress &  Address)
static

Definition at line 238 of file torcnetwork.cpp.

bool TorcNetwork::IsOnline ( void  )
protected

Definition at line 352 of file torcnetwork.cpp.

bool TorcNetwork::IsOwnAddress ( const QHostAddress &  Address)
static

Definition at line 53 of file torcnetwork.cpp.

bool TorcNetwork::IsOwnAddressPriv ( const QHostAddress &  Address)
protected

Definition at line 357 of file torcnetwork.cpp.

void TorcNetwork::NewAsyncRequest ( TorcNetworkRequest Request,
QObject *  Parent 
)
signal
void TorcNetwork::NewHostName ( const QHostInfo &  Info)
protectedslot

Receives host name updates from QHostInfo.

Definition at line 715 of file torcnetwork.cpp.

void TorcNetwork::NewRequest ( TorcNetworkRequest Request)
signal
void TorcNetwork::OnlineStateChanged ( bool  Online)
protectedslot

Definition at line 469 of file torcnetwork.cpp.

void TorcNetwork::Poke ( TorcNetworkRequest Request)
static

Definition at line 80 of file torcnetwork.cpp.

void TorcNetwork::PokeRequest ( TorcNetworkRequest Request)
signal
void TorcNetwork::ReadyRead ( void  )
protectedslot

Definition at line 572 of file torcnetwork.cpp.

bool TorcNetwork::Redirected ( TorcNetworkRequest Request,
QNetworkReply *  Reply 
)
protected

Definition at line 536 of file torcnetwork.cpp.

void TorcNetwork::RemoveHostName ( const QString &  Host)
static

Remove a host name from the known list of host names.

See also
AddHostName
GetHostNames

Definition at line 159 of file torcnetwork.cpp.

void TorcNetwork::Setup ( bool  Create)
staticprotected

Definition at line 271 of file torcnetwork.cpp.

void TorcNetwork::SSLErrors ( const QList< QSslError > &  Errors)
protectedslot

Definition at line 687 of file torcnetwork.cpp.

void TorcNetwork::UpdateCompleted ( void  )
protectedslot

Definition at line 475 of file torcnetwork.cpp.

void TorcNetwork::UpdateConfiguration ( bool  Creating = false)
protected

Definition at line 748 of file torcnetwork.cpp.

Friends And Related Function Documentation

friend class TorcNetworkObject
friend

Definition at line 24 of file torcnetwork.h.


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