Vidalia 0.2.15
|
#include <TorService.h>
Signals | |
void | started () |
void | finished (int exitCode, QProcess::ExitStatus) |
void | startFailed (QString error) |
Public Member Functions | |
TorService (QObject *parent=0) | |
~TorService () | |
bool | isInstalled () |
bool | isRunning () |
void | start () |
bool | stop () |
int | exitCode () |
QProcess::ExitStatus | exitStatus () |
bool | install (const QString &torPath, const QString &torrc, quint16 controlPort) |
bool | remove () |
Static Public Member Functions | |
static bool | isSupported () |
static bool | loadServiceFunctions () |
Private Member Functions | |
SC_HANDLE | openService () |
DWORD | status () |
Static Private Member Functions | |
static SC_HANDLE | openSCM () |
static void | closeHandle (SC_HANDLE handle) |
Private Attributes | |
SC_HANDLE | _scm |
Static Private Attributes | |
static ServiceFunctions | _service_fns |
Definition at line 93 of file TorService.h.
TorService::TorService | ( | QObject * | parent = 0 | ) |
TorService::~TorService | ( | ) |
void TorService::closeHandle | ( | SC_HANDLE | handle | ) | [static, private] |
Closes the service handle.
Definition at line 110 of file TorService.cpp.
References _service_fns, ServiceFunctions::CloseServiceHandle, and loadServiceFunctions().
Referenced by exitCode(), install(), isInstalled(), remove(), start(), status(), stop(), and ~TorService().
int TorService::exitCode | ( | ) |
Returns the exit code of the last Tor service that finished.
Definition at line 203 of file TorService.cpp.
References _service_fns, closeHandle(), openService(), ServiceFunctions::QueryServiceStatus, and UNKNOWN_EXIT_CODE.
Referenced by stop().
QProcess::ExitStatus TorService::exitStatus | ( | ) |
Returns the exit status of the last Tor service that finished.
Definition at line 225 of file TorService.cpp.
Referenced by stop().
void TorService::finished | ( | int | exitCode, |
QProcess::ExitStatus | |||
) | [signal] |
Called when the service gets stopped.
Referenced by stop().
bool TorService::install | ( | const QString & | torPath, |
const QString & | torrc, | ||
quint16 | controlPort | ||
) |
Installs the Tor service.
Installs the Tor service. Returns true if the service was successfully installed or already exists.
Definition at line 239 of file TorService.cpp.
References _scm, _service_fns, ServiceFunctions::ChangeServiceConfig2A, closeHandle(), ServiceFunctions::CreateServiceA, tc::debug(), tc::error(), openService(), TOR_SERVICE_ACCESS, TOR_SERVICE_DESC, TOR_SERVICE_DISP, and TOR_SERVICE_NAME.
bool TorService::isInstalled | ( | ) |
Returns true if the Tor service is installed.
Definition at line 119 of file TorService.cpp.
References closeHandle(), and openService().
Referenced by AdvancedPage::load().
bool TorService::isRunning | ( | ) |
Returns true if the Tor service is running.
Definition at line 130 of file TorService.cpp.
References status().
bool TorService::isSupported | ( | ) | [static] |
Returns if services are supported.
Returns true if services are supported.
Definition at line 48 of file TorService.cpp.
Referenced by AdvancedPage::AdvancedPage(), loadServiceFunctions(), and TorControl::start().
bool TorService::loadServiceFunctions | ( | ) | [static] |
Dynamically loads NT service related functions from advapi32.dll.
Dyanmically loads NT service related functions from advapi32.dll. This function is adapted from Tor's nt_service_load_library() function. See LICENSE for details on Tor's license.
Definition at line 57 of file TorService.cpp.
References _service_fns, isSupported(), LOAD_SERVICE_FN, and ServiceFunctions::loaded.
Referenced by closeHandle(), openSCM(), and openService().
SC_HANDLE TorService::openSCM | ( | ) | [static, private] |
Opens a handle to the service control manager. Returns NULL on error.
Definition at line 101 of file TorService.cpp.
References _service_fns, loadServiceFunctions(), and ServiceFunctions::OpenSCManagerA.
Referenced by TorService().
SC_HANDLE TorService::openService | ( | ) | [private] |
Opens a handle to the Tor service. Returns NULL on error.
Definition at line 88 of file TorService.cpp.
References _scm, _service_fns, loadServiceFunctions(), ServiceFunctions::OpenServiceA, TOR_SERVICE_ACCESS, and TOR_SERVICE_NAME.
Referenced by exitCode(), install(), isInstalled(), remove(), start(), status(), and stop().
bool TorService::remove | ( | ) |
Removes the Tor service.
Removes the Tor service. Returns true if the service was removed successfully or does not exist.
Definition at line 280 of file TorService.cpp.
References _service_fns, closeHandle(), tc::debug(), ServiceFunctions::DeleteService, tc::error(), openService(), and stop().
void TorService::start | ( | ) |
Starts the Tor service. Emits started on success.
Starts Tor service.
Definition at line 137 of file TorService.cpp.
References _service_fns, closeHandle(), tc::debug(), tc::error(), openService(), started(), startFailed(), ServiceFunctions::StartServiceA, and status().
void TorService::started | ( | ) | [signal] |
Called when the service gets started.
Referenced by start().
void TorService::startFailed | ( | QString | error | ) | [signal] |
Called when there is an error in starting the service.
Referenced by start().
DWORD TorService::status | ( | ) | [private] |
Gets the status of the Tor service.
Definition at line 300 of file TorService.cpp.
References _service_fns, closeHandle(), openService(), ServiceFunctions::QueryServiceStatus, and SERVICE_ERROR.
Referenced by isRunning(), start(), and stop().
bool TorService::stop | ( | ) |
Stops the Tor service. Emits finished on success.
Stops Tor service.
Definition at line 168 of file TorService.cpp.
References _service_fns, closeHandle(), ServiceFunctions::ControlService, tc::debug(), tc::error(), exitCode(), exitStatus(), finished(), openService(), and status().
Referenced by remove().
SC_HANDLE TorService::_scm [private] |
Handle to the service control manager.
Definition at line 145 of file TorService.h.
Referenced by install(), openService(), TorService(), and ~TorService().
ServiceFunctions TorService::_service_fns [static, private] |
{ false,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL
}
List of dynamically loaded NT service functions.
Definition at line 147 of file TorService.h.
Referenced by closeHandle(), exitCode(), install(), loadServiceFunctions(), openSCM(), openService(), remove(), start(), status(), and stop().