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 controlcommand.h 00013 ** \version $Id: controlcommand.h 2362 2008-02-29 04:30:11Z edmanm $ 00014 ** \brief A command sent to Tor's control interface 00015 */ 00016 00017 #ifndef _CONTROLCOMMAND_H 00018 #define _CONTROLCOMMAND_H 00019 00020 #include <QStringList> 00021 00022 00023 class ControlCommand 00024 { 00025 public: 00026 ControlCommand(); 00027 ControlCommand(const QString &keyword); 00028 ControlCommand(const QString &keyword, const QString &arg); 00029 ControlCommand(const QString &keyword, const QStringList &args); 00030 00031 /** Returns the keyword for this control command. */ 00032 QString keyword() const { return _keyword; } 00033 00034 /** Set the keyword for this control command */ 00035 void setKeyword(const QString &keyword); 00036 00037 /** Add an argument to this control command */ 00038 void addArgument(const QString &arg); 00039 /** Adds all arguments in <b>args</b> to this control command. */ 00040 void addArguments(const QStringList &args); 00041 00042 /** Append a data line for this control command */ 00043 void appendData(const QString &data); 00044 00045 /** Format this control command into a format conforming to Tor's v1 00046 * protocol specification. */ 00047 QString toString() const; 00048 00049 private: 00050 /** Escape special characters in the supplied string */ 00051 QString escape(const QString &str) const; 00052 00053 QString _keyword; 00054 QStringList _arguments; 00055 QStringList _data; 00056 }; 00057 00058 #endif 00059