Vidalia 0.2.12
|
#include <GeoIpDatabase.h>
Public Types | |
enum | DatabaseType { UnknownDatabase = 0, CountryDatabase, CityDatabase, RegionDatabase, OrganizationDatabase, IspDatabase, ProxyDatabase, AsnDatabase, NetSpeedDatabase, DomainDatabase } |
Public Member Functions | |
GeoIpDatabase (QObject *parent=0) | |
virtual | ~GeoIpDatabase () |
bool | open (const QString &fname) |
void | close () |
bool | isOpen () const |
GeoIpDatabase::DatabaseType | type () const |
QString | countryCodeByAddr (const QHostAddress &ip) |
GeoIpRecord | recordByAddr (const QHostAddress &ip) |
Private Attributes | |
GeoIP * | _db |
Definition at line 29 of file GeoIpDatabase.h.
UnknownDatabase | |
CountryDatabase | |
CityDatabase | |
RegionDatabase | |
OrganizationDatabase | |
IspDatabase | |
ProxyDatabase | |
AsnDatabase | |
NetSpeedDatabase | |
DomainDatabase |
Definition at line 34 of file GeoIpDatabase.h.
GeoIpDatabase::GeoIpDatabase | ( | QObject * | parent = 0 | ) |
Default constructor.
Definition at line 25 of file GeoIpDatabase.cpp.
GeoIpDatabase::~GeoIpDatabase | ( | ) | [virtual] |
Virtual destructor. Closes the database if it is currently open.
Definition at line 30 of file GeoIpDatabase.cpp.
References close().
void GeoIpDatabase::close | ( | ) |
Closes an open dataase, or does nothing if no database file is currently open.
Definition at line 51 of file GeoIpDatabase.cpp.
Referenced by open(), and ~GeoIpDatabase().
QString GeoIpDatabase::countryCodeByAddr | ( | const QHostAddress & | ip | ) |
Resolves the IP address ip to its two-letter ISO-3166 country code and returns the result on success. On failure, this returns a default-constructed QString.
Definition at line 108 of file GeoIpDatabase.cpp.
bool GeoIpDatabase::isOpen | ( | ) | const |
Return true if this object has a currently open GeoIP database.
Definition at line 60 of file GeoIpDatabase.cpp.
References _db.
Referenced by close(), countryCodeByAddr(), open(), recordByAddr(), and type().
bool GeoIpDatabase::open | ( | const QString & | fname | ) |
Open the GeoIP database file fname and return true if successful. Otherwise, return false. If a different database file is already open, the open database will be closed before the new one is opened.
Definition at line 36 of file GeoIpDatabase.cpp.
GeoIpRecord GeoIpDatabase::recordByAddr | ( | const QHostAddress & | ip | ) |
Resolves the IP address ip to an approximate geographic location and returns the result on success. On failure, this returns a default-constructed QString.
Definition at line 120 of file GeoIpDatabase.cpp.
References _db, isOpen(), and GeoIpRecord::toString().
GeoIpDatabase::DatabaseType GeoIpDatabase::type | ( | ) | const |
Returns the DatabaseType enum value corresponding to the current database type. If no database is open, this will simply return UnknownDatabase.
Definition at line 66 of file GeoIpDatabase.cpp.
References _db, AsnDatabase, CityDatabase, CountryDatabase, DomainDatabase, isOpen(), IspDatabase, NetSpeedDatabase, OrganizationDatabase, ProxyDatabase, RegionDatabase, and UnknownDatabase.
GeoIP* GeoIpDatabase::_db [private] |
Pointer to the local GeoIP database object.
Definition at line 95 of file GeoIpDatabase.h.
Referenced by close(), countryCodeByAddr(), isOpen(), open(), recordByAddr(), and type().