[tor-commits] [vidalia/alpha] Add a way to sighup Tor on platforms other than Windows

chiiph at torproject.org chiiph at torproject.org
Tue May 3 14:21:33 UTC 2011


commit 4a82329fc123b00c2b75686e5091b127659964ff
Author: Tomas Touceda <chiiph at gentoo.org>
Date:   Sun May 1 07:13:54 2011 -0300

    Add a way to sighup Tor on platforms other than Windows
---
 src/vidalia/MainWindow.cpp |   22 ++++++++++++++++++++++
 src/vidalia/MainWindow.h   |    3 +++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index db28916..97f9877 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -135,6 +135,7 @@ MainWindow::createActions()
   _actionStartTor = new QAction(QIcon(IMG_START_TOR_16), tr("Start"), this);
   _actionStopTor = new QAction(QIcon(IMG_STOP_TOR_16), tr("Stop"), this);
   _actionRestartTor = new QAction(tr("Restart"), this);
+  _actionReloadConfig = new QAction(tr("Reload Tor's config"), this);
   _actionNewIdentity = new QAction(QIcon(IMG_IDENTITY), tr("New Identity"), this);
   _actionStatus = new QAction(QIcon(IMG_CONTROL_PANEL), tr("Status"), this);
   _actionNetworkMap = new QAction(QIcon(IMG_NETWORK), tr("Network Map"), this);
@@ -158,6 +159,9 @@ MainWindow::createMenuBar()
   torMenu->addAction(_actionStartTor);
   torMenu->addAction(_actionStopTor);
   torMenu->addAction(_actionRestartTor);
+#if !defined(Q_WS_WIN)
+  torMenu->addAction(_actionReloadConfig);
+#endif
 
   QMenu *actionsMenu = menu->addMenu(tr("Actions"));
   actionsMenu->addAction(_actionNewIdentity);
@@ -277,6 +281,7 @@ MainWindow::retranslateUi()
   _actionStartTor->setText(tr("Start"));
   _actionStopTor->setText(tr("Stop"));
   _actionRestartTor->setText(tr("Restart"));
+  _actionReloadConfig->setText(tr("Reload Tor's config"));
   _actionConfigure->setText(tr("Settings"));
 
   if (_status == Stopped) {
@@ -310,6 +315,7 @@ MainWindow::createConnections()
   connect(_actionExit, SIGNAL(triggered()), this, SLOT(close()));
   connect(_actionStartTor, SIGNAL(triggered()), this, SLOT(start()));
   connect(_actionRestartTor, SIGNAL(triggered()), this, SLOT(restart()));
+  connect(_actionReloadConfig, SIGNAL(triggered()), this, SLOT(sighup()));
   connect(_actionStopTor, SIGNAL(triggered()), this, SLOT(stop()));
   connect(_actionShowControlPanel, SIGNAL(triggered()), this, SLOT(show()));
   connect(_actionNewIdentity, SIGNAL(triggered()), this, SLOT(newIdentity()));
@@ -1390,6 +1396,22 @@ MainWindow::restart()
   }
 }
 
+/** Sends a sighup signal to Tor on platforms other than Windows */
+void
+MainWindow::sighup()
+{
+  bool rc;
+  QString errmsg;
+  rc = _torControl->signal(TorSignal::Reload, &errmsg);
+
+  if (!rc) {
+    int response = VMessageBox::warning(this, tr("Error reloading configuration"),
+                     p(tr("Vidalia was unable to reload Tor's configuration.")) 
+                       + p(errmsg),
+                     VMessageBox::Ok);
+  }
+}
+
 /** Sets the visibility of the startup status description and progress bar to
  * <b>visible</b>. */
 void
diff --git a/src/vidalia/MainWindow.h b/src/vidalia/MainWindow.h
index 51722cb..a11dffc 100644
--- a/src/vidalia/MainWindow.h
+++ b/src/vidalia/MainWindow.h
@@ -65,6 +65,8 @@ private slots:
   void start();
   /** Called when the user changes a setting that needs Tor restarting */
   void restart();
+  /** Called when the user wants to reload Tor's config */
+  void sighup();
   /** Called when the Tor process fails to start. */
   void startFailed(QString errmsg);
   /** Called when the Tor process has successfully started. */
@@ -285,6 +287,7 @@ private:
   QAction *_actionStartTor;
   QAction *_actionStopTor;
   QAction *_actionRestartTor;
+  QAction *_actionReloadConfig;
   QAction *_actionNewIdentity;
   QAction *_actionStatus;
   QAction *_actionNetworkMap;





More information about the tor-commits mailing list