#include <GeoIpCache.h>
Public Member Functions | |
GeoIpCache (QObject *parent=0) | |
bool | saveToDisk (QString *errmsg=0) |
bool | loadFromDisk (QString *errmsg=0) |
QString | cacheFileName () const |
void | addToCache (const GeoIp &geoip) |
void | addToCache (const QHostAddress &from, const QHostAddress &to, const GeoIp &geoip) |
GeoIp | geoIpForAddress (const QHostAddress &ip) |
bool | contains (const QHostAddress &ip) |
Private Member Functions | |
void | addToCache (const GeoIpCacheItem &ci) |
Private Attributes | |
GeoIpCacheMap | _cache |
Definition at line 32 of file GeoIpCache.h.
GeoIpCache::GeoIpCache | ( | QObject * | parent = 0 |
) |
void GeoIpCache::addToCache | ( | const GeoIpCacheItem & | ci | ) | [private] |
Adds the GeoIpCacheItem ci to the cache. List of cached GeoIp objects.
Definition at line 131 of file GeoIpCache.cpp.
References _cache, GeoIpCacheItem::ipRangeEnd(), GeoIpCacheItem::isExpired(), and GeoIpCacheItem::isValid().
void GeoIpCache::addToCache | ( | const QHostAddress & | from, | |
const QHostAddress & | to, | |||
const GeoIp & | geoip | |||
) |
Caches the geographic information in geoip associated with a range of IP addresses, from from to to (inclusive).
Definition at line 120 of file GeoIpCache.cpp.
References addToCache().
void GeoIpCache::addToCache | ( | const GeoIp & | geoip | ) |
Caches the geographic information in geoip associated with a single IP address.
Definition at line 112 of file GeoIpCache.cpp.
References contains(), and GeoIp::ip().
Referenced by addToCache(), loadFromDisk(), and GeoIpResolver::parseGeoIpResponse().
QString GeoIpCache::cacheFileName | ( | ) | const |
Returns the location currently used for the cache file.
Definition at line 40 of file GeoIpCache.cpp.
References Vidalia::dataDirectory().
Referenced by loadFromDisk(), and saveToDisk().
bool GeoIpCache::contains | ( | const QHostAddress & | ip | ) |
Returns true if the cache contains geographic location information for ip. Otherwise, returns false.
Definition at line 154 of file GeoIpCache.cpp.
Referenced by addToCache(), GeoIpResolver::parseGeoIpResponse(), and GeoIpResolver::resolveFromCache().
GeoIp GeoIpCache::geoIpForAddress | ( | const QHostAddress & | ip | ) |
Returns a GeoIp object for the given ip from cache. If no cached information is known for ip, an empty GeoIp object is returned.
Definition at line 145 of file GeoIpCache.cpp.
Referenced by GeoIpResolver::resolveFromCache().
bool GeoIpCache::loadFromDisk | ( | QString * | errmsg = 0 |
) |
Reads the cache in from disk. Returns true if the cache file was successfully read. Otherwise, returns false and sets errmsg to a string describing the error encountered, if errmsg is not null.
Definition at line 84 of file GeoIpCache.cpp.
References _cache, addToCache(), cacheFileName(), err(), GeoIpCacheItem::fromCacheString(), GeoIpCacheItem::isExpired(), GeoIpCacheItem::isValid(), and vInfo.
Referenced by GeoIpCache().
bool GeoIpCache::saveToDisk | ( | QString * | errmsg = 0 |
) |
Writes the current cache to disk. Returns true if the cache file was successfully saved to disk. Otherwise, returns false and sets errmsg to a string describing the error encountered, if errmsg is not null.
Definition at line 46 of file GeoIpCache.cpp.
References _cache, cacheFileName(), create_path(), Vidalia::dataDirectory(), err(), GeoIpCacheItem::isExpired(), and GeoIpCacheItem::toCacheString().
Referenced by GeoIpResolver::parseGeoIpResponse().
GeoIpCacheMap GeoIpCache::_cache [private] |
Definition at line 83 of file GeoIpCache.h.
Referenced by addToCache(), contains(), geoIpForAddress(), loadFromDisk(), and saveToDisk().