Vidalia
0.2.15
|
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.torproject.org/projects/vidalia.html. No part of Vidalia, 00007 ** including this file, may be copied, modified, propagated, or distributed 00008 ** except according to the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file ReplyLine.h 00013 ** \brief Reply from a previous control command sent to Tor 00014 */ 00015 00016 #ifndef _REPLYLINE_H 00017 #define _REPLYLINE_H 00018 00019 #include <QStringList> 00020 00021 00022 class ReplyLine 00023 { 00024 public: 00025 ReplyLine(); 00026 ReplyLine(const QString &status, const QString &message); 00027 ReplyLine(const QString &status, const QString &message, const QString &data); 00028 00029 /** Set the status code to <b>status</b>. */ 00030 void setStatus(const QString &status); 00031 /** Returns the status code for this reply line. */ 00032 QString getStatus() const; 00033 00034 /** Sets the ReplyText message this reply line to <b>msg</b>. */ 00035 void setMessage(const QString &msg); 00036 /** Returns the ReplyText portion of this reply line. */ 00037 QString getMessage() const; 00038 00039 /** Appends <b>data</b> to this reply line. */ 00040 void appendData(const QString &data); 00041 /** Returns a QStringList of all data lines for this reply line. */ 00042 QStringList getData() const; 00043 /** Returns true if this reply contained a data portion. */ 00044 bool hasData() const { return _data.size() > 0; } 00045 00046 /** Returns the entire contents of this reply line, including the status, 00047 * message, and any extra data. */ 00048 QString toString() const; 00049 00050 private: 00051 /** Unescapes special characters in <b>str</b> and returns the unescaped 00052 * result. */ 00053 static QString unescape(const QString &escaped); 00054 00055 QString _status; /**< Response status code. */ 00056 QString _message; /**< ReplyText portion of this reply line. */ 00057 QStringList _data; /**< Contents of any DataReplyLines in this line. */ 00058 }; 00059 00060 #endif 00061