#include <geoipcache.h>
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 |
Definition at line 38 of file geoipcache.h.
GeoIpCache::GeoIpCache | ( | ) |
Default constructor.
Constructor.
Definition at line 43 of file geoipcache.cpp.
References loadFromDisk().
bool GeoIpCache::saveToDisk | ( | QString * | errmsg = 0 |
) |
Writes the current cache to disk.
Definition at line 57 of file geoipcache.cpp.
References _cache, cache(), CACHE_FILENAME, create_path(), Vidalia::dataDirectory(), err(), GeoIpCacheItem::isExpired(), and GeoIpCacheItem::toString().
Referenced by GeoIpResolver::disconnected().
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 97 of file geoipcache.cpp.
References _cache, cache(), CACHE_FILENAME, err(), GeoIpCacheItem::fromString(), GeoIpCacheItem::ip(), GeoIpCacheItem::isEmpty(), and GeoIpCacheItem::isExpired().
Referenced by GeoIpCache().
QString GeoIpCache::cacheFilename | ( | ) |
Returns the location currently used for the cache file.
Definition at line 50 of file geoipcache.cpp.
References CACHE_FILENAME.
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 126 of file geoipcache.cpp.
References _cache, and GeoIp::ip().
Referenced by GeoIpResolver::disconnected(), loadFromDisk(), and saveToDisk().
GeoIp GeoIpCache::geoip | ( | QHostAddress | ip | ) |
Returns a GeoIp object for the given IP from cache.
Definition at line 135 of file geoipcache.cpp.
References _cache.
Referenced by GeoIpResolver::resolveFromCache().
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 146 of file geoipcache.cpp.
References _cache, and GeoIpCacheItem::isExpired().
Referenced by GeoIpResolver::disconnected(), and GeoIpResolver::resolveFromCache().
QHash<quint32, GeoIpCacheItem> GeoIpCache::_cache [private] |
List of cached GeoIp objects.
Definition at line 59 of file geoipcache.h.
Referenced by cache(), contains(), geoip(), loadFromDisk(), and saveToDisk().