stream.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 stream.h
00024  * \version $Id: stream.h 1238 2006-09-25 17:50:57Z edmanm $
00025  * \brief Object representing a Tor stream
00026  */
00027 
00028 #ifndef _STREAM_H
00029 #define _STREAM_H
00030 
00031 #include <QCoreApplication>
00032 #include <QString>
00033 #include <QObject>
00034 
00035 class Stream
00036 {
00037   Q_DECLARE_TR_FUNCTIONS(Stream)
00038 
00039 public:
00040   /** Stream status values */
00041   enum Status {
00042     Unknown,      /**< Unknown status type given */
00043     New,          /**< New request to connect */
00044     NewResolve,   /**< New request to resolve an address */
00045     SentConnect,  /**< Sent a connect cell */
00046     SentResolve,  /**< Sent a resolve cell */
00047     Succeeded,    /**< Stream established */
00048     Failed,       /**< Stream failed */
00049     Closed,       /**< Stream closed */
00050     Detached      /**< Detached from circuit */
00051   };
00052     
00053   /** Default constructor */
00054   Stream();
00055   /** Constructor */
00056   Stream(quint64 streamId, Status status, quint64 circuitId, QString target);
00057 
00058   /** Parses the given string for a stream, in Tor control protocol format. */
00059   static Stream fromString(QString stream);
00060   /** Converts a string description of a stream's status to its enum value */
00061   static Status toStatus(QString strStatus);
00062 
00063   /** Returns true if the Stream object's fields are all empty. */
00064   bool isEmpty();
00065   
00066   /** Returns the ID for this stream. */
00067   quint64 id() { return _streamId; }
00068   /** Returns the status for this stream. */
00069   Status status() { return _status; }
00070   /** Returns a string representation of this stream's status. */
00071   QString statusString();
00072   /** Returns the ID of the circuit to which this stream is assigned. */
00073   quint64 circuitId() { return _circuitId; }
00074   /** Returns the target for this stream. */
00075   QString target() { return _target; }
00076   
00077 private:
00078   quint64 _streamId;   /**< Unique ID associated with this stream. */
00079   Status  _status;     /**< Stream status value. */
00080   quint64 _circuitId;  /**< ID of the circuit carrying this stream. */
00081   QString _target;     /**< Stream target address. */
00082 };
00083 
00084 #endif
00085 

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