Changeset 90 for trunk/src/control/torcontrol.h
- Timestamp:
- 01/15/06 17:36:23 (3 years ago)
- Files:
-
- 1 modified
-
trunk/src/control/torcontrol.h (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/control/torcontrol.h
r84 r90 30 30 #include "controlconnection.h" 31 31 #include "torprocess.h" 32 #include "messagepump.h" 33 #include "torevents.h" 34 32 35 33 36 class TorControl : public QObject … … 38 41 /** Signals that can be sent by the controller */ 39 42 enum Signal { 40 Reload, 41 Shutdown, 42 Dump, 43 Debug, 44 Halt 43 SignalReload, SignalShutdown, SignalDump, SignalDebug, SignalHalt 45 44 }; 46 45 46 47 47 /** Default constructor */ 48 48 TorControl(); 49 50 49 /** Default destructor */ 51 50 ~TorControl(); … … 53 52 /** Start the Tor process */ 54 53 bool start(QString *errmsg = 0); 55 56 54 /** Stop the Tor process */ 57 55 bool stop(QString *errmsg = 0); 58 59 56 /** Detect if the Tor process is running */ 60 57 bool isRunning(); … … 62 59 /** Connect to Tor's control socket */ 63 60 bool connect(QString *errmsg = 0); 64 65 61 /** Disconnect from Tor's control socket */ 66 62 void disconnect(); 67 68 63 /** Check if we're connected to Tor's control socket */ 69 64 bool isConnected(); … … 74 69 /** Sends a GETINFO message to Tor based on the given keys */ 75 70 bool getInfo(QHash<QString,QString> &map, QString *errmsg = 0); 76 77 71 /** Sends a GETINFO message for a single info value to Tor */ 78 72 bool getInfo(QString key, QString &val, QString *errmsg = 0); … … 84 78 QString getTorVersion(QString *errmsg = 0); 85 79 80 /** Register another event of interest with Tor */ 81 bool addEvent(TorEvents::Event e, QString *errmsg = 0); 82 /** Remove a previously registered event */ 83 bool removeEvent(TorEvents::Event e, QString *errmsg = 0); 84 86 85 87 86 signals: 88 87 /** Emitted when the Tor process has started */ 89 88 void started(); 90 91 89 /** Emitted when the Tor process has stopped */ 92 90 void stopped(int exitCode, QProcess::ExitStatus exitStatus); 93 94 91 /** Emitted when the controller has connected to Tor */ 95 92 void connected(); 96 97 93 /** Emitted when the controller has disconnected from Tor */ 98 94 void disconnected(); 95 /** Emitted when a bandwidth update is received from Tor */ 96 void bandwidth(quint64 bytesIn, quint64 bytesOut); 97 /** Emitted when a log message is received from Tor */ 98 void log(TorEvents::LogSeverity severity, QString msg); 99 /** Emitted when a circuit status event is received from Tor */ 100 void circuit(quint64 circId, TorEvents::CircuitStatus status, QString path); 101 /** Emitted when a stream status event is received from Tor */ 102 void stream(quint64 streamId, TorEvents::StreamStatus status, 103 quint64 circId, QString target); 99 104 100 105 101 106 private: 102 107 /** Instantiates a socket used to connect to Tor's control port */ … … 104 109 /** Manages and monitors the Tor process */ 105 110 TorProcess _torProcess; 111 /** Handles sending and receiving messages from Tor over the control 112 * connection */ 113 MessagePump *_messages; 114 /** Dispatches asynchronous events sent by Tor */ 115 TorEvents _events; 116 /** Keep track of which events we're interested in */ 117 QStringList _eventList; 106 118 119 /** Register events of interest with Tor */ 120 bool registerEvents(QString *errmsg); 121 /** Sends a message to Tor and discards the response */ 122 bool send(ControlCommand cmd, QString *errmsg = 0); 123 /** Send a message to Tor and read the response */ 124 bool send(ControlCommand cmd, ControlReply &reply, QString *errmsg = 0); 125 126 107 127 /* The slots below simply relay signals from the appropriate member objects */ 108 128 private slots: … … 111 131 void onConnected(); 112 132 void onDisconnected(); 133 void onBandwidthUpdate(quint64 bytesIn, quint64 bytesOut); 134 void onLogMessage(TorEvents::LogSeverity severity, QString msg); 135 void onCircuitStatus(quint64 circId, 136 TorEvents::CircuitStatus status, QString path); 137 void onStreamStatus(quint64 streamId, TorEvents::StreamStatus status, 138 quint64 circId, QString target); 113 139 }; 114 140
