Changeset 78
- Timestamp:
- 01/12/06 20:02:07 (3 years ago)
- Location:
- trunk/src/control
- Files:
-
- 2 modified
-
torcontrol.cpp (modified) (3 diffs)
-
torcontrol.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/control/torcontrol.cpp
r77 r78 138 138 if (_controlConn.send(cmd, reply, errmsg)) { 139 139 ReplyLine line = reply.getLine(); 140 if (line.getStatus() == "250") { 141 return true; 140 if (line.getStatus() != "250") { 141 if (errmsg) { 142 *errmsg = line.getMessage(); 143 } 144 return false; 142 145 } 143 146 } 144 return false;147 return true; 145 148 } 146 149 … … 167 170 foreach (ReplyLine line, reply.getLines()) { 168 171 if (line.getStatus() != "250") { 169 *errmsg = line.getMessage(); 172 if (errmsg) { 173 *errmsg = line.getMessage(); 174 } 170 175 return false; 171 176 } … … 194 199 } 195 200 201 /** Sends a signal to Tor */ 202 bool 203 TorControl::signal(Signal sig, QString *errmsg) 204 { 205 ControlCommand cmd("SIGNAL"); 206 ControlReply reply; 207 QString sigtype; 208 209 /* Convert the signal to the correct string */ 210 switch (sig) { 211 case Reload: sigtype = "RELOAD"; break; 212 case Shutdown: sigtype = "SHUTDOWN"; break; 213 case Dump: sigtype = "DUMP"; break; 214 case Debug: sigtype = "DEBUG"; break; 215 case Halt: sigtype = "HALT"; break; 216 default: return false; break; 217 } 218 219 /* Send and check the response */ 220 if (_controlConn.send(cmd, reply, errmsg)) { 221 ReplyLine line = reply.getLine(); 222 if (line.getStatus() != "250") { 223 if (errmsg) { 224 *errmsg = line.getMessage(); 225 } 226 return false; 227 } 228 } 229 return true; 230 } 231 196 232 /** Ask Tor for its version */ 197 233 QString -
trunk/src/control/torcontrol.h
r77 r78 36 36 37 37 public: 38 /** Signals that can be sent by the controller */ 39 enum Signal { 40 Reload, 41 Shutdown, 42 Dump, 43 Debug, 44 Halt 45 }; 46 38 47 /** Default constructor */ 39 48 TorControl(); … … 69 78 bool getInfo(QString key, QString &val, QString *errmsg = 0); 70 79 80 /** Sends a signal to Tor */ 81 bool signal(Signal sig, QString *errmsg = 0); 82 71 83 /** Ask Tor for its version */ 72 84 QString getTorVersion(QString *errmsg = 0);
