Vidalia 0.2.10
|
#include <ControlSocket.h>
Public Member Functions | |
ControlSocket () | |
bool | sendCommand (ControlCommand cmd, QString *errmsg=0) |
bool | readReply (ControlReply &reply, QString *errmsg=0) |
bool | isConnected () |
Static Public Member Functions | |
static QString | toString (const QAbstractSocket::SocketError error) |
Protected Member Functions | |
void | customEvent (QEvent *event) |
bool | readLineData (QString &line, QString *errmsg=0) |
bool | readLine (QString &line, QString *errmsg=0) |
Definition at line 26 of file ControlSocket.h.
ControlSocket::ControlSocket | ( | ) |
Default constructor.
Definition at line 29 of file ControlSocket.cpp.
void ControlSocket::customEvent | ( | QEvent * | event | ) | [protected] |
Processes custom events sent to this object (e.g. SendCommandEvents) from other threads.
Definition at line 44 of file ControlSocket.cpp.
References SendCommandEvent::command(), sendCommand(), and SendCommandEvent::waiter().
bool ControlSocket::isConnected | ( | ) |
Returns true if the control socket is connected and ready to send or receive.
Definition at line 36 of file ControlSocket.cpp.
Referenced by readLine(), readReply(), ControlConnection::send(), and sendCommand().
bool ControlSocket::readLine | ( | QString & | line, |
QString * | errmsg = 0 |
||
) | [protected] |
Reads a line of data from the socket (blocking)
Reads a line of data from the socket and returns true if successful or false if an error occurred while waiting for a line of data to become available.
Definition at line 110 of file ControlSocket.cpp.
References err(), isConnected(), READ_TIMEOUT, and readLineData().
Referenced by readLineData(), and readReply().
bool ControlSocket::readLineData | ( | QString & | line, |
QString * | errmsg = 0 |
||
) | [protected] |
Reads line data off the socket in chunks.
Reads line data, one chunk at a time, until a newline character is encountered.
Definition at line 89 of file ControlSocket.cpp.
References err(), and readLine().
Referenced by readLine().
bool ControlSocket::readReply | ( | ControlReply & | reply, |
QString * | errmsg = 0 |
||
) |
Read a response from Tor
Read a complete reply from the control socket. Replies take the following form, based on Tor's Control Protocol v1:
Reply = *(MidReplyLine / DataReplyLine) EndReplyLine
MidReplyLine = "-" ReplyLine DataReplyLine = "+" ReplyLine Data EndReplyLine = SP ReplyLine ReplyLine = StatusCode [ SP ReplyText ] CRLF ReplyText = XXXX StatusCode = XXiX
Definition at line 138 of file ControlSocket.cpp.
References ReplyLine::appendData(), ControlReply::appendLine(), err(), isConnected(), and readLine().
Referenced by ControlConnection::onReadyRead().
bool ControlSocket::sendCommand | ( | ControlCommand | cmd, |
QString * | errmsg = 0 |
||
) |
Send a command to Tor
Send a control command to Tor on the control socket, conforming to Tor's Control Protocol V1:
Command = Keyword Arguments CRLF / "+" Keyword Arguments CRLF Data Keyword = 1*ALPHA Arguments = *(SP / VCHAR)
Definition at line 67 of file ControlSocket.cpp.
References tc::debug(), err(), isConnected(), and ControlCommand::toString().
Referenced by customEvent().
QString ControlSocket::toString | ( | const QAbstractSocket::SocketError | error | ) | [static] |
Returns the string description of error.
Definition at line 187 of file ControlSocket.cpp.
Referenced by ControlConnection::onError().