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 ControlReply.cpp 00013 ** \version $Id: ControlReply.cpp 3735 2009-04-28 20:28:01Z edmanm $ 00014 ** \brief A response from Tor's control interface 00015 */ 00016 00017 #include "ControlReply.h" 00018 00019 00020 /** Default constructor */ 00021 ControlReply::ControlReply() 00022 { 00023 } 00024 00025 /** Add a line associated with this reply */ 00026 void 00027 ControlReply::appendLine(ReplyLine line) 00028 { 00029 _lines << line; 00030 } 00031 00032 /** Returns the requested line from this reply */ 00033 ReplyLine 00034 ControlReply::getLine(int idx) const 00035 { 00036 return _lines.at(idx); 00037 } 00038 00039 /** Returns all lines for this reply */ 00040 QList<ReplyLine> 00041 ControlReply::getLines() const 00042 { 00043 return _lines; 00044 } 00045 00046 /** Returns the status of the first line in the reply */ 00047 QString 00048 ControlReply::getStatus() const 00049 { 00050 return getLine().getStatus(); 00051 } 00052 00053 /** Returns the message of the first line in the reply */ 00054 QString 00055 ControlReply::getMessage() const 00056 { 00057 return getLine().getMessage(); 00058 } 00059 00060 /** Returns the data for the first line in the reply. */ 00061 QStringList 00062 ControlReply::getData() const 00063 { 00064 return getLine().getData(); 00065 } 00066 00067 /** Returns the entire contents of the control reply. */ 00068 QString 00069 ControlReply::toString() const 00070 { 00071 QString str; 00072 foreach (ReplyLine line, _lines) { 00073 str.append(line.toString()); 00074 str.append("\n"); 00075 } 00076 return str.trimmed(); 00077 } 00078