geoipcacheitem.h

Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file geoipcacheitem.h
00013 ** \version $Id: geoipcacheitem.h 2362 2008-02-29 04:30:11Z edmanm $
00014 ** \brief Cached result of a single IP-to-geolocation result
00015 */
00016 
00017 #ifndef _GEOIPCACHEITEM_H
00018 #define _GEOIPCACHEITEM_H
00019 
00020 #include <QDateTime>
00021 
00022 #include "geoip.h"
00023 
00024 
00025 class GeoIpCacheItem
00026 {
00027 public:
00028   /** Default constructor */
00029   GeoIpCacheItem() {};
00030   /** Constructor. */
00031   GeoIpCacheItem(GeoIp geoip, QDateTime timestamp);
00032 
00033   /** Returns the IP of this cache item. */
00034   QHostAddress ip() const { return _geoip.ip(); }
00035   /** Returns the cached GeoIp object. */
00036   GeoIp geoip() const { return _geoip; }
00037   /** Returns true if this cache item is expired. */
00038   bool isExpired() const;
00039   /** Returns true if this cache item is empty and invalid. */
00040   bool isEmpty() const;
00041 
00042   /** Returns a string representing the contents of this cache item, suitable
00043    * for writing to disk. */
00044   QString toString() const;
00045   /** Returns a GeoIpCacheItem from a string as read from the cache that was
00046    * written to disk. */
00047   static GeoIpCacheItem fromString(QString cacheString);
00048 
00049 private:
00050   GeoIp     _geoip;      /**< Cached GeoIp item. */
00051   QDateTime _timestamp;  /**< Time this item was cached. */
00052 };
00053 
00054 #endif
00055 

Generated on Sat Aug 16 17:31:48 2008 for Vidalia by  doxygen 1.5.6