Vidalia 0.2.15
Public Types | Public Member Functions | Private Attributes
GeoIpDatabase Class Reference

#include <GeoIpDatabase.h>

List of all members.

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

Detailed Description

Definition at line 29 of file GeoIpDatabase.h.


Member Enumeration Documentation

Enumerator:
UnknownDatabase 
CountryDatabase 
CityDatabase 
RegionDatabase 
OrganizationDatabase 
IspDatabase 
ProxyDatabase 
AsnDatabase 
NetSpeedDatabase 
DomainDatabase 

Definition at line 34 of file GeoIpDatabase.h.


Constructor & Destructor Documentation

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


Member Function Documentation

void GeoIpDatabase::close ( )

Closes an open dataase, or does nothing if no database file is currently open.

See also:
open()
isOpen()

Definition at line 51 of file GeoIpDatabase.cpp.

References _db, and isOpen().

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.

References _db, and isOpen().

bool GeoIpDatabase::isOpen ( ) const

Return true if this object has a currently open GeoIP database.

See also:
open()

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.

See also:
close()
isOpen()

Definition at line 36 of file GeoIpDatabase.cpp.

References _db, close(), isOpen(), and vError.

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.


Member Data Documentation

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


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