Vidalia  0.3.1
TorProcess.h
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If
4 ** you did not receive the LICENSE file with this file, you may obtain it
5 ** from the Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file TorProcess.h
13 ** \brief Starts and stops a Tor process
14 */
15 
16 #ifndef _TORPROCESS_H
17 #define _TORPROCESS_H
18 
19 #include <QProcess>
20 
21 
22 class TorProcess : public QProcess
23 {
24  Q_OBJECT
25 
26 public:
27  /** Default constructor. */
28  TorProcess(QObject *parent = 0);
29 
30  /** Start the Tor process */
31  void start(const QString &app, const QStringList &args);
32  /** Stop the Tor process */
33  bool stop(QString *errmsg = 0);
34 
35  /** Return the Tor process's PID (workaround for some Windows funkiness) */
36  quint64 pid();
37 
38  /** Enable reading log messages from stdout. */
39  void openStdout();
40  /** Disable reading log messages from stdout. */
41  void closeStdout();
42 
43  /** Returns the version reported by the Tor executable specified in
44  * <b>exe</b>, or a default-constructed QString on failure. */
45  static QString version(const QString &exe);
46 
47 signals:
48  /** Emitted when Tor prints a log message to the console */
49  void log(const QString &severity, const QString &message);
50  /** Emitted when Tor fails to start, perhaps because the path to Tor was
51  * bogus. */
52  void startFailed(const QString &errorMessage);
53 
54 private slots:
55  /** Called when there is data to be read from stdout */
56  void onReadyRead();
57  /** Called when an error occurs in the process. */
58  void onError(QProcess::ProcessError error);
59 
60 private:
61  /** Formats the Tor process arguments for logging. */
62  QString formatArguments(const QStringList &args);
63 };
64 
65 #endif
66 
TorProcess
Definition: TorProcess.h:22
TorProcess::closeStdout
void closeStdout()
Definition: TorProcess.cpp:138
TorProcess::startFailed
void startFailed(const QString &errorMessage)
TorProcess::pid
quint64 pid()
Definition: TorProcess.cpp:117
TorProcess::openStdout
void openStdout()
Definition: TorProcess.cpp:129
TorProcess::log
void log(const QString &severity, const QString &message)
TorProcess::version
static QString version(const QString &exe)
Definition: TorProcess.cpp:184
TorProcess::stop
bool stop(QString *errmsg=0)
Definition: TorProcess.cpp:85
TorProcess::onError
void onError(QProcess::ProcessError error)
Definition: TorProcess.cpp:170
TorProcess::start
void start(const QString &app, const QStringList &args)
Definition: TorProcess.cpp:56
TorProcess::onReadyRead
void onReadyRead()
Definition: TorProcess.cpp:148
TorProcess::formatArguments
QString formatArguments(const QStringList &args)
Definition: TorProcess.cpp:42
tc::error
DebugMessage error(const QString &fmt)
Definition: tcglobal.cpp:40
TorProcess::TorProcess
TorProcess(QObject *parent=0)
Definition: TorProcess.cpp:30