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 1238 2006-09-25 17:50:57Z 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 00051 /** Returns the request's identifier. */ 00052 int id() { return _id; } 00053 /** Formats the request as an HTTP POST request */ 00054 QByteArray request(); 00055 00056 private: 00057 /** Creates an HTTP header for this request. */ 00058 QHttpRequestHeader createHeader(); 00059 00060 int _id; /**< Request identifier */ 00061 QString _host; /**< Host: field value. */ 00062 QString _page; /**< Page giving us the geo ip information. */ 00063 QString _request; /**< Formatted Geo IP request string. */ 00064 }; 00065 00066 #endif 00067