Changeset 84
- Timestamp:
- 01/13/06 23:32:35 (3 years ago)
- Location:
- trunk/src/control
- Files:
-
- 4 modified
-
controlconnection.cpp (modified) (3 diffs)
-
test/control_test.cpp (modified) (4 diffs)
-
torcontrol.cpp (modified) (4 diffs)
-
torcontrol.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/control/controlconnection.cpp
r61 r84 57 57 { 58 58 disconnectFromHost(); 59 if (!waitForDisconnected(-1)) { 60 if (errmsg) { 61 *errmsg = 62 QString("Error disconnecting socket. [%1]").arg(errorString()); 59 if (state() != QAbstractSocket::UnconnectedState) { 60 if (!waitForDisconnected(-1)) { 61 if (errmsg) { 62 *errmsg = 63 QString("Error disconnecting socket. [%1]").arg(errorString()); 64 } 65 return false; 63 66 } 64 return false;65 67 } 66 68 return true; … … 77 79 ControlConnection::sendCommand(ControlCommand cmd, QString *errmsg) 78 80 { 81 if (!isValid()) { 82 return false; 83 } 84 79 85 /* Format the control command */ 80 86 QString strCmd = cmd.toString(); … … 109 115 QChar c; 110 116 QString line; 117 118 if (!isValid()) { 119 return false; 120 } 111 121 112 122 /* The implementation below is based on the Java control library from Tor */ -
trunk/src/control/test/control_test.cpp
r72 r84 38 38 39 39 /* Start Tor */ 40 if (!control.start Tor(&errmsg)) {40 if (!control.start(&errmsg)) { 41 41 qDebug() << "Could not start Tor:" << errmsg; 42 42 return -1; … … 48 48 if (!control.connect(&errmsg)) { 49 49 qDebug() << "Could not connect to Tor:" << errmsg; 50 control.stop Tor();50 control.stop(); 51 51 return -1; 52 52 } else { … … 55 55 56 56 /* Authenticate */ 57 if (control.authenticate( QByteArray(),&errmsg)) {57 if (control.authenticate(&errmsg)) { 58 58 qDebug() << "Authentication Successful..."; 59 59 … … 71 71 /* Disconnect the control socket and stop Tor */ 72 72 control.disconnect(); 73 control.stop Tor();73 control.stop(); 74 74 75 75 return 0; -
trunk/src/control/torcontrol.cpp
r83 r84 122 122 TorControl::isConnected() 123 123 { 124 return (_controlConn.state() == QAbstractSocket::ConnectedState);124 return _controlConn.isValid(); 125 125 } 126 126 … … 131 131 */ 132 132 bool 133 TorControl::authenticate(QByteArray token, QString *errmsg) 134 { 135 ControlCommand cmd("AUTHENTICATE", QString(token)); 133 TorControl::authenticate(QString *errmsg) 134 { 135 VidaliaSettings settings; 136 ControlCommand cmd("AUTHENTICATE", QString(settings.getAuthToken())); 136 137 ControlReply reply; 137 138 … … 182 183 } 183 184 } 185 } else { 186 /* Sending the control command failed */ 187 return false; 184 188 } 185 189 return true; … … 195 199 if (getInfo(map, errmsg)) { 196 200 val = map.value(key); 201 return true; 197 202 } 198 203 return false; -
trunk/src/control/torcontrol.h
r83 r84 70 70 71 71 /** Sends an authentication token to Tor */ 72 bool authenticate(Q ByteArray token, QString *errmsg = 0);72 bool authenticate(QString *errmsg = 0); 73 73 74 74 /** Sends a GETINFO message to Tor based on the given keys */
