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
22class TorProcess : public QProcess
23{
24 Q_OBJECT
25
26public:
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
47signals:
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
54private 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
60private:
61 /** Formats the Tor process arguments for logging. */
62 QString formatArguments(const QStringList &args);
63};
64
65#endif
66
void onReadyRead()
Definition: TorProcess.cpp:148
void start(const QString &app, const QStringList &args)
Definition: TorProcess.cpp:56
void log(const QString &severity, const QString &message)
TorProcess(QObject *parent=0)
Definition: TorProcess.cpp:30
void openStdout()
Definition: TorProcess.cpp:129
void onError(QProcess::ProcessError error)
Definition: TorProcess.cpp:170
QString formatArguments(const QStringList &args)
Definition: TorProcess.cpp:42
quint64 pid()
Definition: TorProcess.cpp:117
bool stop(QString *errmsg=0)
Definition: TorProcess.cpp:85
static QString version(const QString &exe)
Definition: TorProcess.cpp:184
void closeStdout()
Definition: TorProcess.cpp:138
void startFailed(const QString &errorMessage)
DebugMessage error(const QString &fmt)
Definition: tcglobal.cpp:40