GeoIpResolver Class Reference

#include <GeoIpResolver.h>

List of all members.

Signals

void resolved (int id, const QList< GeoIp > &geoips)
void resolveFailed (int id, const QString &errorString)

Public Member Functions

 GeoIpResolver (QObject *parent=0)
void setSocksHost (const QHostAddress &addr, quint16 port)
int resolve (const QHostAddress &ip)
int resolve (const QList< QHostAddress > &ips)
bool resolveFromCache (const QHostAddress &ip)
QList< QHostAddress > resolveFromCache (const QList< QHostAddress > &ips)

Private Slots

void connected ()
void disconnected ()
void socketError (const QString &errorString)

Private Member Functions

GeoIpRequestcreateRequest (const QList< QHostAddress > &ips)
void parseGeoIpResponse (const QByteArray &response, GeoIpRequest *request)

Private Attributes

GeoIpCache_cache
QHash< QAbstractSocket
*, GeoIpRequest * > 
_requestList
QHostAddress _socksAddr
quint16 _socksPort

Detailed Description

Definition at line 34 of file GeoIpResolver.h.


Constructor & Destructor Documentation

GeoIpResolver::GeoIpResolver ( QObject *  parent = 0  ) 

Default constructor.

Definition at line 35 of file GeoIpResolver.cpp.

References _cache, _socksAddr, and _socksPort.


Member Function Documentation

void GeoIpResolver::connected (  )  [private, slot]

Called when the socket has connected to the Geo IP host.

Definition at line 95 of file GeoIpResolver.cpp.

References _requestList, GeoIpRequest::id(), GeoIpRequest::request(), GeoIpRequest::size(), and vInfo.

Referenced by resolve().

GeoIpRequest * GeoIpResolver::createRequest ( const QList< QHostAddress > &  ips  )  [private]

Creates an HTTP request for Geo IP information.

Definition at line 244 of file GeoIpResolver.cpp.

References GEOIP_HOST, GEOIP_PAGE, GeoIpRequest::setHost(), GeoIpRequest::setPage(), and GeoIpRequest::setRequest().

Referenced by resolve().

void GeoIpResolver::disconnected (  )  [private, slot]

Called when the socket has disconnected from the Geo IP host.

Definition at line 113 of file GeoIpResolver.cpp.

References _requestList, GeoIpResponse::content(), GeoIpRequest::id(), parseGeoIpResponse(), resolveFailed(), GeoIpResponse::statusCode(), GeoIpResponse::statusMessage(), and vWarn.

Referenced by resolve().

void GeoIpResolver::parseGeoIpResponse ( const QByteArray &  response,
GeoIpRequest request 
) [private]
int GeoIpResolver::resolve ( const QList< QHostAddress > &  ips  ) 
int GeoIpResolver::resolve ( const QHostAddress &  ip  ) 

Resolves a single IP to a geographic location.

Definition at line 88 of file GeoIpResolver.cpp.

Referenced by NetViewer::resolve().

void GeoIpResolver::resolved ( int  id,
const QList< GeoIp > &  geoips 
) [signal]

Emitted when a list of IPs have been resolved to lat/long.

Referenced by parseGeoIpResponse(), and resolveFromCache().

void GeoIpResolver::resolveFailed ( int  id,
const QString &  errorString 
) [signal]

Emitted when a resolve has failed.

Referenced by disconnected(), and socketError().

QList< QHostAddress > GeoIpResolver::resolveFromCache ( const QList< QHostAddress > &  ips  ) 

Resolves a list of IPs to a geographic location, but only those which are cached. Returns a list of which IPs were not cached.

Resolves a list of IPs to a geographic location, but only those which are cached. Returns a list of IPs that were not in the cache.

Definition at line 68 of file GeoIpResolver.cpp.

References _cache, GeoIpCache::contains(), GeoIpCache::geoIpForAddress(), resolved(), and vInfo.

bool GeoIpResolver::resolveFromCache ( const QHostAddress &  ip  ) 

Resolves ip to geographic information only if it is cached.

Resolves ip to geographic information if it is cached. A resolved() signal will be emitted and true returned if we have cached geographic information for ip. Otherwise, this returns false.

Definition at line 56 of file GeoIpResolver.cpp.

References _cache, GeoIpCache::contains(), GeoIpCache::geoIpForAddress(), and resolved().

Referenced by NetViewer::addToResolveQueue(), and resolve().

void GeoIpResolver::setSocksHost ( const QHostAddress &  addr,
quint16  port 
)

Sets the address and port of Tor, through which GeoIP requests will be made.

Definition at line 46 of file GeoIpResolver.cpp.

References _socksAddr, and _socksPort.

Referenced by NetViewer::onAuthenticated().

void GeoIpResolver::socketError ( const QString &  errorString  )  [private, slot]

Called when an error has occurred getting the Geo IP information.

Called when an error has occurred requesting Geo IP information.

Definition at line 220 of file GeoIpResolver.cpp.

References _requestList, GeoIpRequest::id(), resolveFailed(), and vWarn.

Referenced by resolve().


Member Data Documentation

List of sockets used for requests.

Definition at line 77 of file GeoIpResolver.h.

Referenced by GeoIpResolver(), parseGeoIpResponse(), and resolveFromCache().

QHash<QAbstractSocket *,GeoIpRequest*> GeoIpResolver::_requestList [private]

Definition at line 78 of file GeoIpResolver.h.

Referenced by connected(), disconnected(), resolve(), and socketError().

QHostAddress GeoIpResolver::_socksAddr [private]

Tor's SocksListenAddress.

Definition at line 80 of file GeoIpResolver.h.

Referenced by GeoIpResolver(), resolve(), and setSocksHost().

quint16 GeoIpResolver::_socksPort [private]

Tor's SocksPort.

Definition at line 82 of file GeoIpResolver.h.

Referenced by GeoIpResolver(), resolve(), and setSocksHost().


The documentation for this class was generated from the following files:
Generated on Mon Aug 30 23:09:54 2010 for Vidalia by  doxygen 1.6.3