[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r1373: Only build the service stuff in on Win32. It seems silly to (trunk/src/control)
Author: edmanm
Date: 2006-10-22 23:26:51 -0400 (Sun, 22 Oct 2006)
New Revision: 1373
Modified:
trunk/src/control/control.pri
trunk/src/control/torcontrol.cpp
trunk/src/control/torcontrol.h
trunk/src/control/torservice.cpp
trunk/src/control/torservice.h
Log:
Only build the service stuff in on Win32. It seems silly to compile a couple
files that I'll never use, when I'm building on my Mac.
Modified: trunk/src/control/control.pri
===================================================================
--- trunk/src/control/control.pri 2006-10-22 23:56:51 UTC (rev 1372)
+++ trunk/src/control/control.pri 2006-10-23 03:26:51 UTC (rev 1373)
@@ -39,8 +39,7 @@
$$PWD/newdescriptorevent.h \
$$PWD/routerdescriptor.h \
$$PWD/circuit.h \
- $$PWD/stream.h \
- $$PWD/torservice.h
+ $$PWD/stream.h
SOURCES += $$PWD/torcontrol.cpp \
$$PWD/torprocess.cpp \
@@ -55,6 +54,10 @@
$$PWD/torsignal.cpp \
$$PWD/routerdescriptor.cpp \
$$PWD/circuit.cpp \
- $$PWD/stream.cpp \
- $$PWD/torservice.cpp
+ $$PWD/stream.cpp
+win32 {
+ HEADERS += $$PWD/torservice.h
+ SOURCES += $$PWD/torservice.cpp
+}
+
Modified: trunk/src/control/torcontrol.cpp
===================================================================
--- trunk/src/control/torcontrol.cpp 2006-10-22 23:56:51 UTC (rev 1372)
+++ trunk/src/control/torcontrol.cpp 2006-10-23 03:26:51 UTC (rev 1373)
@@ -54,6 +54,7 @@
QObject::connect(_controlConn, SIGNAL(disconnected()),
this, SLOT(onDisconnected()));
+#if defined(Q_OS_WIN32)
_torService = new TorService(this);
QObject::connect(_torService, SIGNAL(started()),
this, SLOT(onStarted()), Qt::QueuedConnection);
@@ -62,6 +63,7 @@
QObject::connect(_torService, SIGNAL(startFailed(QString)),
this, SLOT(onStartFailed(QString)),
Qt::QueuedConnection);
+#endif
}
/** Default destructor */
@@ -91,11 +93,13 @@
/* Make sure our torrc and the full path to it exists. If it doesn't,
* then touch it. */
touch_file(settings.getTorrc(), true);
-
+
+#if defined(Q_OS_WIN32)
if (TorService::isSupported() && _torService->isInstalled()) {
_torService->start();
} else {
+#endif
_torProcess = new TorProcess;
/* Plumb the process signals */
@@ -111,7 +115,9 @@
/* Kick off the Tor process. */
_torProcess->start(settings.getExecutable(),
settings.getArguments());
+#if defined(Q_OS_WIN32)
}
+#endif
}
}
Modified: trunk/src/control/torcontrol.h
===================================================================
--- trunk/src/control/torcontrol.h 2006-10-22 23:56:51 UTC (rev 1372)
+++ trunk/src/control/torcontrol.h 2006-10-23 03:26:51 UTC (rev 1373)
@@ -35,12 +35,15 @@
#include "controlconnection.h"
#include "torprocess.h"
-#include "torservice.h"
#include "torevents.h"
#include "torsignal.h"
#include "routerdescriptor.h"
+#if defined(Q_OS_WIN32)
+#include "torservice.h"
+#endif
+
class TorControl : public QObject
{
Q_OBJECT
@@ -173,13 +176,15 @@
ControlConnection* _controlConn;
/** Manages and monitors the Tor process */
TorProcess* _torProcess;
- /** Manages the Tor service, if supported and enabled */
- TorService* _torService;
/** Keep track of which events we're interested in */
TorEvents _torEvents;
/** The version of Tor we're currently talking to. */
QString _torVersion;
-
+#if defined(Q_OS_WIN32)
+ /** Manages the Tor service, if supported and enabled */
+ TorService* _torService;
+#endif
+
/** Send a message to Tor and read the response */
bool send(ControlCommand cmd, ControlReply &reply, QString *errmsg = 0);
/** Send a message to Tor and discard the response */
Modified: trunk/src/control/torservice.cpp
===================================================================
--- trunk/src/control/torservice.cpp 2006-10-22 23:56:51 UTC (rev 1372)
+++ trunk/src/control/torservice.cpp 2006-10-23 03:26:51 UTC (rev 1373)
@@ -36,11 +36,7 @@
bool
TorService::isSupported()
{
- bool supported = false;
-#if defined(Q_OS_WIN32)
- supported = (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based);
-#endif
- return supported;
+ return (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based);
}
/** Default ctor. */
@@ -62,7 +58,6 @@
void
TorService::close()
{
-#if defined(Q_OS_WIN32)
if (_service) {
CloseServiceHandle(_service);
_service = NULL;
@@ -71,7 +66,6 @@
CloseServiceHandle(_manager);
_manager = NULL;
}
-#endif
}
/** Initializes the service and service manager. */
@@ -79,7 +73,6 @@
TorService::initialize()
{
/* If services are supported, initialize the manager and service */
-#if defined(Q_OS_WIN32)
if (isSupported()) {
/* Open service manager */
if (_manager == NULL) {
@@ -90,7 +83,6 @@
_service = OpenServiceA(_manager, TOR_SERVICE_NAME, TOR_SERVICE_ACCESS);
}
}
-#endif
}
/** Returns true if the Tor service is installed. */
@@ -105,12 +97,8 @@
bool
TorService::isRunning()
{
-#if defined(Q_OS_WIN32)
initialize();
return (status() == SERVICE_RUNNING);
-#else
- return false;
-#endif
}
/** Starts Tor service. */
@@ -126,7 +114,6 @@
return;
}
-#if defined(Q_OS_WIN32)
/* Make sure we're initialized */
initialize();
@@ -146,14 +133,12 @@
} else {
emit startFailed(tr("Unable to start Tor service."));
}
-#endif
}
/** Stops Tor service. */
void
TorService::stop()
{
-#if defined(Q_OS_WIN32)
if (isRunning()) {
SERVICE_STATUS stat;
stat.dwCurrentState = SERVICE_RUNNING;
@@ -172,7 +157,6 @@
/* Emit the signal that we stopped and the service's exit code and status. */
emit finished(exitCode(), exitStatus());
}
-#endif
}
/** Returns the exit code of the last Tor service that finished. */
@@ -180,7 +164,7 @@
TorService::exitCode()
{
int exitCode = UNKNOWN_EXIT_CODE;
-#if defined(Q_OS_WIN32)
+
if (isSupported() && _manager && _service) {
SERVICE_STATUS s;
@@ -192,7 +176,6 @@
: s.dwWin32ExitCode);
}
}
-#endif
return exitCode;
}
@@ -214,7 +197,6 @@
TorService::install(const QString &torPath, const QString &torrc,
quint16 controlPort)
{
-#if defined(Q_OS_WIN32)
if (!isSupported()) return false;
if (!isInstalled()) {
@@ -235,16 +217,12 @@
}
}
return isInstalled();
-#else
- return false;
-#endif
}
/** Removes the Tor service. */
bool
TorService::remove()
{
-#if defined(Q_OS_WIN32)
if (!isSupported()) return false;
if (isInstalled()) {
/* Stop the service */
@@ -257,9 +235,6 @@
close();
}
return !isInstalled();
-#else
- return false;
-#endif
}
@@ -267,7 +242,6 @@
DWORD
TorService::status()
{
-#if defined(Q_OS_WIN32)
if (!(isSupported() && _manager && _service)) return DWORD(-1);
SERVICE_STATUS s;
@@ -277,8 +251,5 @@
stat = s.dwCurrentState;
}
return stat;
-#else
- return 0;
-#endif
}
Modified: trunk/src/control/torservice.h
===================================================================
--- trunk/src/control/torservice.h 2006-10-22 23:56:51 UTC (rev 1372)
+++ trunk/src/control/torservice.h 2006-10-23 03:26:51 UTC (rev 1373)
@@ -31,18 +31,13 @@
#include <QObject>
#include <QProcess>
-#if defined(Q_OS_WIN32)
- #include <windows.h>
- #define TOR_SERVICE_NAME "tor"
- #define TOR_SERVICE_DISP "Tor Win32 Service"
- #define TOR_SERVICE_DESC \
- TEXT("Provides an anonymous Internet communication system.")
- #define TOR_SERVICE_ACCESS SERVICE_ALL_ACCESS
- #define SERVICE_ERROR 8
-#else
- typedef void* SC_HANDLE; /** Make SC_HANDLE a void* on non-Windows. */
- typedef quint64 DWORD; /** DWORD only exists on Windows, so redefine it. */
-#endif
+#include <windows.h>
+#define TOR_SERVICE_NAME "tor"
+#define TOR_SERVICE_DISP "Tor Win32 Service"
+#define TOR_SERVICE_DESC \
+ TEXT("Provides an anonymous Internet communication system.")
+#define TOR_SERVICE_ACCESS SERVICE_ALL_ACCESS
+#define SERVICE_ERROR 8
class TorService : public QObject