Changeset 2324

Show
Ignore:
Timestamp:
01/24/08 20:53:24 (12 months ago)
Author:
edmanm
Message:

r81@lysithea: edmanm | 2008-01-24 20:53:06 -0500
Add a 'ProxyExecutable?' configuration option to launch a proxy application
when Vidalia starts, and close it when Vidalia exits.
Patch from Steven J. Murdoch <http://www.cl.cam.ac.uk/users/sjm217/>.

Location:
vidalia/trunk
Files:
2 added
2 removed
6 modified

Legend:

Unmodified
Added
Removed
  • vidalia/trunk/CHANGELOG

    r2318 r2324  
    3535  o Add a 'BrowserExecutable' configuration option to launch a Web browser 
    3636    when Tor has built a circuit, and exit Vidalia when the browser is closed. 
     37    Patch from Steven J. Murdoch <http://www.cl.cam.ac.uk/users/sjm217/>. 
     38  o Add a 'ProxyExecutable' configuration option to launch a proxy application 
     39    when Vidalia starts, and close it when Vidalia exits. 
    3740    Patch from Steven J. Murdoch <http://www.cl.cam.ac.uk/users/sjm217/>. 
    3841  o Respond to the Delete key in the network map by closing whatever circuits 
  • vidalia/trunk/src/vidalia/CMakeLists.txt

    r2319 r2324  
    183183  vidaliawindow.cpp 
    184184  vmessagebox.cpp 
    185   browserprocess.cpp 
     185  helperprocess.cpp 
    186186) 
    187187qt4_wrap_cpp(vidalia_SRCS 
     
    192192  vidaliawindow.h 
    193193  vmessagebox.h 
    194   browserprocess.h 
     194  helperprocess.h 
    195195) 
    196196 
     
    289289endif(NOT WIN32 AND NOT APPLE) 
    290290 
     291 
  • vidalia/trunk/src/vidalia/config/vidaliasettings.cpp

    r2206 r2324  
    4444#define SETTING_SHOW_MAINWINDOW_AT_START  "ShowMainWindowAtStart" 
    4545#define SETTING_BROWSER_EXECUTABLE  "BrowserExecutable" 
     46#define SETTING_PROXY_EXECUTABLE  "ProxyExecutable" 
    4647 
    4748#if defined(Q_OS_WIN32) 
     
    7576  setDefault(SETTING_SHOW_MAINWINDOW_AT_START, true); 
    7677  setDefault(SETTING_BROWSER_EXECUTABLE, ""); 
     78  setDefault(SETTING_PROXY_EXECUTABLE, ""); 
    7779} 
    7880 
     
    187189} 
    188190 
     191/** Returns a fully-qualified path to the proxy server, including the 
     192 * executable name. */ 
     193QString 
     194VidaliaSettings::getProxyExecutable() const 
     195{ 
     196  return QDir::convertSeparators(value(SETTING_PROXY_EXECUTABLE).toString()); 
     197} 
     198 
     199/** Sets the location and name of the proxy server executable to the given string. 
     200 * If set to the empty string, the proxy will not be started. */ 
     201void 
     202VidaliaSettings::setProxyExecutable(const QString &proxyExecutable) 
     203{ 
     204  setValue(SETTING_PROXY_EXECUTABLE, proxyExecutable); 
     205} 
  • vidalia/trunk/src/vidalia/config/vidaliasettings.h

    r2206 r2324  
    7979   * If set to the empty string, the browser will not be started. */ 
    8080  void setBrowserExecutable(const QString &browserExecutable); 
     81 
     82  /** Returns a fully-qualified path to the proxy server, including the 
     83   * executable name. */ 
     84  QString getProxyExecutable() const; 
     85 
     86  /** Sets the location and name of the proxy server executable to the given string. 
     87   * If set to the empty string, the proxy will not be started. */ 
     88  void setProxyExecutable(const QString &proxyExecutable); 
    8189}; 
    8290 
  • vidalia/trunk/src/vidalia/mainwindow.cpp

    r2320 r2324  
    148148  _torControl->setEvent(TorEvents::GeneralStatus, this, true); 
    149149 
    150   /* Create a new BrowserProcess object, used to start the web browser */ 
    151   _browserProcess = new BrowserProcess(this); 
     150  /* Create a new HelperProcess object, used to start the web browser */ 
     151  _browserProcess = new HelperProcess(this); 
    152152  connect(_browserProcess, SIGNAL(finished(int, QProcess::ExitStatus)), 
    153153           this, SLOT(onBrowserFinished(int, QProcess::ExitStatus))); 
    154154  connect(_browserProcess, SIGNAL(startFailed(QString)), 
    155155           this, SLOT(onBrowserFailed(QString))); 
     156 
     157  /* Create a new HelperProcess object, used to start the proxy server */ 
     158  _proxyProcess = new HelperProcess(this); 
     159  connect(_proxyProcess, SIGNAL(startFailed(QString)), 
     160           this, SLOT(onProxyFailed(QString))); 
    156161 
    157162  /* Catch signals when the application is running or shutting down */ 
     
    227232    start(); 
    228233  } 
     234 
     235  /* Start the proxy server, if configured */ 
     236  startProxy(); 
    229237} 
    230238 
     
    237245    /* Kill our Tor process now */  
    238246    _torControl->stop(); 
     247  } 
     248 
     249  if (_proxyProcess->state() != QProcess::NotRunning) { 
     250    /* Close the proxy server (Polipo ignores the WM_CLOSE event sent by 
     251     * terminate() so we have to kill() it) */ 
     252    _proxyProcess->kill(); 
    239253  } 
    240254 
     
    436450  VMessageBox::warning(this, tr("Error starting web browser"), 
    437451              tr("Vidalia was unable to start the configured web browser"), 
     452              VMessageBox::Ok|VMessageBox::Default|VMessageBox::Escape); 
     453} 
     454 
     455/** Starts the proxy server, if appropriately configured */ 
     456void MainWindow::startProxy() 
     457{ 
     458  VidaliaSettings settings; 
     459  QString executable = settings.getProxyExecutable(); 
     460   
     461  if (!executable.isEmpty()) 
     462    _proxyProcess->start(executable, QStringList()); 
     463} 
     464 
     465/** Called when the proxy server fails to start, for example, because 
     466 * the path specified didn't lead to an executable. */ 
     467void 
     468MainWindow::onProxyFailed(QString errmsg) 
     469{ 
     470  Q_UNUSED(errmsg); 
     471  
     472  /* Display an error message and see if the user wants some help */ 
     473  VMessageBox::warning(this, tr("Error starting proxy server"), 
     474              tr("Vidalia was unable to start the configured proxy server"), 
    438475              VMessageBox::Ok|VMessageBox::Default|VMessageBox::Escape); 
    439476} 
     
    11521189} 
    11531190 
     1191 
  • vidalia/trunk/src/vidalia/mainwindow.h

    r2217 r2324  
    4141#include "network/netviewer.h" 
    4242#include "ui_mainwindow.h" 
    43 #include "browserprocess.h" 
     43#include "helperprocess.h" 
    4444 
    4545 
     
    113113  /** Called web the web browser failed to start */ 
    114114  void onBrowserFailed(QString errmsg); 
     115  /** Called when the proxy server fails to start */ 
     116  void onProxyFailed(QString errmsg); 
    115117   
    116118private: 
     
    139141  /** Starts the web browser, if appropriately configured */ 
    140142  void startBrowser(); 
     143  /** Starts the proxy server, if appropriately configured */ 
     144  void startProxy(); 
    141145  /** Converts a TorStatus enum value to a string for debug logging purposes. */ 
    142146  QString toString(TorStatus status); 
     
    176180  /** A TorControl object that handles communication with Tor */ 
    177181  TorControl* _torControl; 
    178   /** A BrowserProcess object that manages the web browser */ 
    179   BrowserProcess* _browserProcess; 
     182  /** A HelperProcess object that manages the web browser */ 
     183  HelperProcess* _browserProcess; 
     184  /** A HelperProcess object that manages the proxy server */ 
     185  HelperProcess* _proxyProcess; 
    180186  /** Remembers the control password between when we start Tor with a hash of 
    181187   * the password and when we need to provide the password itself. */ 
     
    201207#endif 
    202208 
     209