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 2362 2008-02-29 04:30:11Z 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 <QByteArray> 00023 #include <QHostAddress> 00024 #include <QHttpRequestHeader> 00025 00026 00027 class GeoIpRequest 00028 { 00029 public: 00030 /** Constructor */ 00031 GeoIpRequest(int id) : _id(id) {} 00032 00033 /** Sets the Host: field in this request's header. */ 00034 void setHost(const QString &host) { _host = host; } 00035 /** Sets the page path in this request's header. */ 00036 void setPage(const QString &page) { _page = page; } 00037 /** Sets the list of IPs whose geo information we want to request. */ 00038 void setRequest(const QList<QHostAddress> &ips); 00039 /** Returns true if this request contains <b>ip</b>. */ 00040 bool contains(const QHostAddress &ip) const; 00041 00042 /** Returns the request's identifier. */ 00043 int id() const { return _id; } 00044 /** Returns the number of IP addresses contained in this request. */ 00045 int size() const { return _ips.size(); } 00046 /** Formats the request as an HTTP POST request */ 00047 QByteArray request() const; 00048 00049 private: 00050 /** Creates an HTTP header for this request. */ 00051 QHttpRequestHeader createHeader() const; 00052 00053 int _id; /**< Request identifier */ 00054 QString _host; /**< Host: field value. */ 00055 QString _page; /**< Page giving us the geo ip information. */ 00056 QString _request; /**< Formatted Geo IP request string. */ 00057 QList<QHostAddress> _ips; /**< List of IP addresses in this request. */ 00058 }; 00059 00060 #endif 00061