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