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 geoipresponse.h 00013 ** \version $Id: geoipresponse.h 2362 2008-02-29 04:30:11Z edmanm $ 00014 ** \brief Parses a response to a previous GeoIP request 00015 */ 00016 00017 #ifndef _GEOIPRESPONSE_H 00018 #define _GEOIPRESPONSE_H 00019 00020 #include <QList> 00021 #include <QByteArray> 00022 #include <QHttpResponseHeader> 00023 00024 #include "geoip.h" 00025 00026 00027 class GeoIpResponse 00028 { 00029 public: 00030 /** Constructor. Parses the response data for an HTTP header and Geo IP 00031 * information. */ 00032 GeoIpResponse(QByteArray response); 00033 00034 /** Returns the HTTP status code for this response. */ 00035 int statusCode() { return _header.statusCode(); } 00036 /** Returns the HTTP status message for this response. */ 00037 QString statusMessage() { return _header.reasonPhrase(); } 00038 /** Returns the Geo IP information contained in this response. */ 00039 QList<GeoIp> geoIps() { return _geoips; } 00040 00041 private: 00042 /** Decodes a <b>chunked</b> transfer encoding. Returns the unchunked 00043 * result on success, or an empty QByteArray if decoding fails. */ 00044 QByteArray decodeChunked(QByteArray chunked); 00045 00046 QHttpResponseHeader _header; /**< HTTP response header. */ 00047 QList<GeoIp> _geoips; /**< Geo IP information in this response. */ 00048 }; 00049 00050 #endif 00051