controlsocket.h

Go to the documentation of this file.
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 
00004 **  you did not receive the LICENSE file with this file, you may obtain it
00005 **  from the 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
00008 **  the terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file controlsocket.h
00013 ** \version $Id: controlsocket.h 2838 2008-07-06 22:43:48Z edmanm $
00014 ** \brief Socket used to connect to Tor's control interface
00015 */
00016 
00017 #ifndef _CONTROLSOCKET_H
00018 #define _CONTROLSOCKET_H
00019 
00020 #include <QTcpSocket>
00021 
00022 #include "controlcommand.h"
00023 #include "controlreply.h"
00024 
00025 
00026 class ControlSocket : public QTcpSocket
00027 {
00028   Q_OBJECT
00029 
00030 public:
00031   /** Default constructor. */
00032   ControlSocket();
00033 
00034   /** Send a command to Tor */
00035   bool sendCommand(ControlCommand cmd, QString *errmsg = 0);
00036   /** Read a response from Tor */
00037   bool readReply(ControlReply &reply, QString *errmsg = 0);
00038 
00039   /** Returns true if the control socket is connected and ready to send or
00040    * receive. */
00041   bool isConnected();
00042   
00043   /** Returns the string description of <b>error</b>. */
00044   static QString toString(const QAbstractSocket::SocketError error);
00045   
00046 protected:
00047   /** Processes custom events sent to this object (e.g. SendCommandEvents)
00048    * from other threads. */
00049   void customEvent(QEvent *event);
00050   /** Reads line data off the socket in chunks. */
00051   bool readLineData(QString &line, QString *errmsg = 0);
00052   /** Reads a line of data from the socket (blocking) */
00053   bool readLine(QString &line, QString *errmsg = 0);
00054 };
00055 
00056 #endif
00057 

Generated on 22 Feb 2010 for Vidalia by  doxygen 1.6.1