circuit.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 circuit.h
00013 ** \version $Id: circuit.h 2511 2008-04-12 22:02:27Z edmanm $
00014 ** \brief Object representing a Tor circuit
00015 */
00016 
00017 #ifndef _CIRCUIT_H
00018 #define _CIRCUIT_H
00019 
00020 #include <QCoreApplication>
00021 #include <QStringList>
00022 
00023 
00024 class Circuit
00025 {
00026   Q_DECLARE_TR_FUNCTIONS(Circuit)
00027 
00028 public:
00029   /** Circuit status events */
00030   enum Status {
00031     Unknown,   /**< Unknown circuit status */
00032     Launched,  /**< Circuit ID assigned to new circuit */
00033     Built,     /**< All hops finished */
00034     Extended,  /**< Circuit extended by one hop */
00035     Failed,    /**< Circuit closed (was not built) */
00036     Closed     /**< Circuit closed (was built) */
00037   };
00038 
00039   /** Default constructor. */
00040   Circuit();
00041   /** Constructor. */  
00042   Circuit(const QString &circuit);
00043   
00044   /** Returns true if this circuit is valid. */
00045   bool isValid() const { return _isValid; }
00046   
00047   /** Returns the ID for this circuit */
00048   quint64 id() const { return _circId; }
00049   /** Returns the status of this circuit */
00050   Status status() const { return _status; }
00051   /** Returns a string representation of the status of this circuit. */
00052   QString statusString() const;
00053   /** Returns the length of the circuit's path. */
00054   uint length() const { return _ids.size(); }
00055   /** Returns the circuit's path as an ordered list of router nicknames. */
00056   QStringList routerNames() const { return _names; }
00057   /** Returns the circuit's path as an ordered list of router fingerprints. */
00058   QStringList routerIDs() const { return _ids; }
00059 
00060   /** Converts a string description of a circuit's status to an enum value */
00061   static Status toStatus(const QString &strStatus);
00062 
00063 private:
00064   quint64 _circId; /**< Circuit ID. */
00065   Status _status;  /**< Circuit status. */
00066   QStringList _names;  /**< Nicknames of the routers in the circuit. */
00067   QStringList _ids;    /**< IDs of the routers in the circuit. */
00068   bool _isValid;
00069 };
00070 
00071 /** A collection of circuits. */
00072 typedef QList<Circuit> CircuitList;
00073 
00074 #endif
00075 

Generated on Sat Aug 16 17:31:48 2008 for Vidalia by  doxygen 1.5.6