geoipresponse.h

Go to the documentation of this file.
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 geoipresponse.h
00024  * \version $Id: geoipresponse.h 1593 2007-01-16 03:52:47Z edmanm $
00025  * \brief Parses a response to a previous GeoIP request
00026  */
00027 
00028 #ifndef _GEOIPRESPONSE_H
00029 #define _GEOIPRESPONSE_H
00030 
00031 #include <QList>
00032 #include <QByteArray>
00033 #include <QHttpResponseHeader>
00034 
00035 #include "geoip.h"
00036 
00037 
00038 class GeoIpResponse
00039 {
00040 public:
00041   /** Constructor. Parses the response data for an HTTP header and Geo IP
00042    * information.  */
00043   GeoIpResponse(QByteArray response);
00044 
00045   /** Returns the HTTP status code for this response. */
00046   int statusCode() { return _header.statusCode(); }
00047   /** Returns the HTTP status message for this response. */
00048   QString statusMessage() { return _header.reasonPhrase(); }
00049   /** Returns the Geo IP information contained in this response. */
00050   QList<GeoIp> geoIps() { return _geoips; }
00051   
00052 private:
00053   /** Decodes a <b>chunked</b> transfer encoding. Returns the unchunked 
00054    * result on success, or an empty QByteArray if decoding fails. */
00055   QByteArray decodeChunked(QByteArray chunked);
00056   
00057   QHttpResponseHeader _header; /**< HTTP response header. */
00058   QList<GeoIp> _geoips;        /**< Geo IP information in this response. */
00059 };
00060 
00061 #endif
00062 

Generated on Wed Sep 5 15:49:27 2007 for Vidalia by  doxygen 1.5.3