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