00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file geoipcacheitem.h 00024 * \version $Id: geoipcacheitem.h 1238 2006-09-25 17:50:57Z edmanm $ 00025 * \brief Cached result of a single IP-to-geolocation result 00026 */ 00027 00028 #ifndef _GEOIPCACHEITEM_H 00029 #define _GEOIPCACHEITEM_H 00030 00031 #include <QDateTime> 00032 00033 #include "geoip.h" 00034 00035 00036 class GeoIpCacheItem 00037 { 00038 public: 00039 /** Default constructor */ 00040 GeoIpCacheItem() {}; 00041 /** Constructor. */ 00042 GeoIpCacheItem(GeoIp geoip, QDateTime timestamp); 00043 00044 /** Returns the IP of this cache item. */ 00045 QHostAddress ip() const { return _geoip.ip(); } 00046 /** Returns the cached GeoIp object. */ 00047 GeoIp geoip() const { return _geoip; } 00048 /** Returns true if this cache item is expired. */ 00049 bool isExpired() const; 00050 00051 /** Returns a string representing the contents of this cache item, suitable 00052 * for writing to disk. */ 00053 QString toString() const; 00054 /** Returns a GeoIpCacheItem from a string as read from the cache that was 00055 * written to disk. */ 00056 static GeoIpCacheItem fromString(QString cacheString); 00057 00058 private: 00059 GeoIp _geoip; /**< Cached GeoIp item. */ 00060 QDateTime _timestamp; /**< Time this item was cached. */ 00061 }; 00062 00063 #endif 00064