torsocket.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 torsocket.h
00024  * \version $Id: torsocket.h 1238 2006-09-25 17:50:57Z edmanm $
00025  * \brief A QTcpSocket that makes requests over Tor
00026  */
00027 
00028 #ifndef _TORSOCKET_H
00029 #define _TORSOCKET_H
00030 
00031 #include <QTcpSocket>
00032 #include <QHostAddress>
00033 
00034 
00035 class TorSocket : public QTcpSocket
00036 {
00037   Q_OBJECT
00038   
00039 public:
00040   /** Constructor. */
00041   TorSocket(QHostAddress socksAddr, quint16 socksPort, QObject *parent = 0);
00042 
00043   /** Connects to the specified hostname and port via Tor. */
00044   void connectToHost(const QString &remoteHost, quint16 remotePort);
00045 
00046 signals:
00047   /** Emitted when a connection has been established to Tor. */
00048   void connectedToTor();
00049   /** Emitted when a connection has been established through Tor to the remote
00050    * host specified in a prior call to connectToHost(). */
00051   void connectedToHost();
00052   /** Emmitted when a connection error has occurred. */
00053   void socketError(QString errmsg);
00054   
00055 private slots:
00056   /** Handles the server's response part of a Socks4a handshake. */
00057   void onHandshakeResponse();
00058   /** Called when a connection error has occurred. */
00059   void onError(QAbstractSocket::SocketError error);
00060 
00061 private:
00062   /** Sends the client part of a Socks4a handshake with a proxy server. */
00063   void sendSocksHandshake(const QString &remoteHost, quint16 remotePort);
00064   
00065   QHostAddress _socksAddr; /**< Address of Tor's SOCKS listener. */
00066   quint16 _socksPort;      /**< Port of Tor's SOCKS listener. */
00067 };
00068 
00069 #endif
00070 

Generated on Mon Oct 23 20:08:16 2006 for Vidalia by  doxygen 1.5.0