controlsocket.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 controlsocket.h
00024  * \version $Id: controlsocket.h 1817 2007-08-02 04:03:02Z edmanm $
00025  * \brief Socket used to connect to Tor's control interface
00026  */
00027 
00028 #ifndef _CONTROLSOCKET_H
00029 #define _CONTROLSOCKET_H
00030 
00031 #include <QTcpSocket>
00032 #include <QHostAddress>
00033 
00034 #include "controlcommand.h"
00035 #include "controlreply.h"
00036 
00037 
00038 class ControlSocket : public QTcpSocket
00039 {
00040   Q_OBJECT
00041 
00042 public:
00043   /** Default constructor and destructor */
00044   ControlSocket();
00045 
00046   /** Connect to Tor on the specified host and port */
00047   bool connect(QHostAddress addr, quint16 port, QString *errmsg = 0);
00048   /** Disconnect from Tor */
00049   bool disconnect(QString *errmsg = 0);
00050   
00051   /** Send a command to Tor */
00052   bool sendCommand(ControlCommand cmd, QString *errmsg = 0);
00053   /** Read a response from Tor */
00054   bool readReply(ControlReply &reply, QString *errmsg = 0);
00055 
00056   /** Returns true if the control socket is connected and ready to send or
00057    * receive. */
00058   bool isConnected();
00059 
00060 protected:
00061   /** Reads line data off the socket in chunks. */
00062   bool readLineData(QString &line, QString *errmsg = 0);
00063   /** Reads a line of data from the socket (blocking) */
00064   bool readLine(QString &line, QString *errmsg = 0);
00065 };
00066 
00067 #endif
00068 

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