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 GeoIpRequest.h 00013 ** \version $Id: GeoIpRequest.h 3768 2009-05-13 19:07:26Z edmanm $ 00014 ** \brief A formatted request for GeoIP information for one or more IPs 00015 */ 00016 00017 #ifndef _GEOIPREQUEST_H 00018 #define _GEOIPREQUEST_H 00019 00020 #include <QList> 00021 #include <QString> 00022 #include <QHttpRequestHeader> 00023 00024 class QHostAddress; 00025 class QByteArray; 00026 00027 00028 class GeoIpRequest 00029 { 00030 public: 00031 /** Constructor */ 00032 GeoIpRequest(int id) : _id(id) {} 00033 00034 /** Sets the Host: field in this request's header. */ 00035 void setHost(const QString &host) { _host = host; } 00036 /** Sets the page path in this request's header. */ 00037 void setPage(const QString &page) { _page = page; } 00038 /** Sets the list of IPs whose geo information we want to request. */ 00039 void setRequest(const QList<QHostAddress> &ips); 00040 /** Returns true if this request contains <b>ip</b>. */ 00041 bool contains(const QHostAddress &ip) const; 00042 00043 /** Returns the request's identifier. */ 00044 int id() const { return _id; } 00045 /** Returns the number of IP addresses contained in this request. */ 00046 int size() const { return _ips.size(); } 00047 /** Formats the request as an HTTP POST request */ 00048 QByteArray request() const; 00049 00050 private: 00051 /** Creates an HTTP header for this request. */ 00052 QHttpRequestHeader createHeader() const; 00053 00054 int _id; /**< Request identifier */ 00055 QString _host; /**< Host: field value. */ 00056 QString _page; /**< Page giving us the geo ip information. */ 00057 QString _request; /**< Formatted Geo IP request string. */ 00058 QList<QHostAddress> _ips; /**< List of IP addresses in this request. */ 00059 }; 00060 00061 #endif 00062