00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file controlcommand.h 00024 * \version $Id: controlcommand.h 1838 2007-08-21 04:33:02Z edmanm $ 00025 * \brief A command sent to Tor's control interface 00026 */ 00027 00028 #ifndef _CONTROLCOMMAND_H 00029 #define _CONTROLCOMMAND_H 00030 00031 #include <QStringList> 00032 00033 00034 class ControlCommand 00035 { 00036 public: 00037 ControlCommand(); 00038 ControlCommand(QString keyword); 00039 ControlCommand(QString keyword, QString arg); 00040 ControlCommand(QString keyword, QStringList args); 00041 00042 /** Returns the keyword for this control command. */ 00043 QString keyword() const { return _keyword; } 00044 00045 /** Set the keyword for this control command */ 00046 void setKeyword(QString keyword); 00047 00048 /** Add an argument to this control command */ 00049 void addArgument(QString arg); 00050 00051 /** Append a data line for this control command */ 00052 void appendData(QString data); 00053 00054 /** Format this control command into a format conforming to Tor's v1 00055 * protocol specification. */ 00056 QString toString(); 00057 00058 private: 00059 /** Escape special characters in the supplied string */ 00060 QString escape(QString str); 00061 00062 QString _keyword; 00063 QStringList _arguments; 00064 QStringList _data; 00065 }; 00066 00067 #endif 00068