GeoIpCache Class Reference

#include <geoipcache.h>

List of all members.

Public Member Functions

 GeoIpCache ()
bool saveToDisk (QString *errmsg=0)
bool loadFromDisk (QString *errmsg=0)
QString cacheFilename ()
void cache (GeoIp geoip)
GeoIp geoip (QHostAddress ip)
bool contains (QHostAddress ip)

Private Attributes

QHash< quint32, GeoIpCacheItem_cache

Detailed Description

Definition at line 27 of file geoipcache.h.


Constructor & Destructor Documentation

GeoIpCache::GeoIpCache (  ) 

Default constructor.

Constructor.

Definition at line 32 of file geoipcache.cpp.

References loadFromDisk().


Member Function Documentation

void GeoIpCache::cache ( GeoIp  geoip  ) 

Caches the given IP and geographic information to disk.

Caches the given IP and geographic information to disk. Call saveToDisk() when you want to write the cache to disk.

Definition at line 115 of file geoipcache.cpp.

References _cache, and GeoIp::ip().

Referenced by GeoIpResolver::disconnected(), loadFromDisk(), and saveToDisk().

QString GeoIpCache::cacheFilename (  ) 

Returns the location currently used for the cache file.

Definition at line 39 of file geoipcache.cpp.

References CACHE_FILENAME.

bool GeoIpCache::contains ( QHostAddress  ip  ) 

Returns true if the given IP address is cached.

Returns true if the given IP address is cached and the cached information is not stale.

Definition at line 135 of file geoipcache.cpp.

References _cache, and GeoIpCacheItem::isExpired().

Referenced by GeoIpResolver::disconnected(), geoip(), and GeoIpResolver::resolveFromCache().

GeoIp GeoIpCache::geoip ( QHostAddress  ip  ) 

Returns a GeoIp object for the given IP from cache.

Definition at line 124 of file geoipcache.cpp.

References _cache, and contains().

Referenced by GeoIpResolver::resolveFromCache().

bool GeoIpCache::loadFromDisk ( QString *  errmsg = 0  ) 

Reads the cache in from disk.

Reads the cache contents in from disk. This function returns true if no cache file exists, since it's possible nothing has been cached yet.

Definition at line 86 of file geoipcache.cpp.

References _cache, cache(), CACHE_FILENAME, err(), GeoIpCacheItem::fromString(), GeoIpCacheItem::ip(), GeoIpCacheItem::isEmpty(), and GeoIpCacheItem::isExpired().

Referenced by GeoIpCache().

bool GeoIpCache::saveToDisk ( QString *  errmsg = 0  ) 

Writes the current cache to disk.

Definition at line 46 of file geoipcache.cpp.

References _cache, cache(), CACHE_FILENAME, create_path(), Vidalia::dataDirectory(), err(), GeoIpCacheItem::isExpired(), and GeoIpCacheItem::toString().

Referenced by GeoIpResolver::disconnected().


Member Data Documentation

QHash<quint32, GeoIpCacheItem> GeoIpCache::_cache [private]

List of cached GeoIp objects.

Definition at line 48 of file geoipcache.h.

Referenced by cache(), contains(), geoip(), loadFromDisk(), and saveToDisk().


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

Generated on 28 Dec 2009 for Vidalia by  doxygen 1.6.1