[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [vidalia/alpha] Implement wizard for first run



commit baa7e2d3a6b66e8e766c1099ccea29ee0ab877c9
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date:   Thu Mar 29 17:57:04 2012 -0300

    Implement wizard for first run
---
 changes/bug2905                          |    6 +++++
 src/vidalia/CMakeLists.txt               |    2 +
 src/vidalia/MainWindow.cpp               |   33 ++++++++++++++++++++++++-----
 src/vidalia/MainWindow.h                 |    7 ++++++
 src/vidalia/config/AdvancedPage.cpp      |   20 ++++++++++++++++++
 src/vidalia/config/AdvancedPage.h        |   10 +++++++++
 src/vidalia/config/AdvancedPage.ui       |    2 +-
 src/vidalia/config/NetworkSettings.cpp   |    4 +++
 src/vidalia/config/TorSettings.cpp       |   25 ++++++++++++++++++++++
 src/vidalia/config/TorSettings.h         |    6 +++++
 src/vidalia/config/torrc/TorrcParser.cpp |    1 +
 11 files changed, 109 insertions(+), 7 deletions(-)

diff --git a/changes/bug2905 b/changes/bug2905
new file mode 100644
index 0000000..3eae285
--- /dev/null
+++ b/changes/bug2905
@@ -0,0 +1,6 @@
+  New Features:
+  o Add a wizard for the special cases where the user starts Vidalia
+    while tor has DisableNetwork=1 or the Panic feature enabled. This
+    wizard is meant to warn the user about either the Panic feature or
+    that she might need to configure a proxy or a bridge before tor
+    connects to the outside world. Fixes ticket 2905.
\ No newline at end of file
diff --git a/src/vidalia/CMakeLists.txt b/src/vidalia/CMakeLists.txt
index 86f755a..30e2a9f 100644
--- a/src/vidalia/CMakeLists.txt
+++ b/src/vidalia/CMakeLists.txt
@@ -182,6 +182,7 @@ set(vidalia_SRCS ${vidalia_SRCS}
   VidaliaTab.cpp
   StatusTab.cpp
   HelperProcess.cpp
+  FirstRunWizard.cpp
 )
 qt4_wrap_cpp(vidalia_SRCS
   Vidalia.h
@@ -194,6 +195,7 @@ qt4_wrap_cpp(vidalia_SRCS
   VidaliaTab.h
   StatusTab.h
   HelperProcess.h
+  FirstRunWizard.h
 )
 
 if (USE_MINIUPNPC)
diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index b203b84..741f55e 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -23,6 +23,7 @@
 #include "VMessageBox.h"
 #include "TorSettings.h"
 #include "ServerSettings.h"
+#include "NetworkSettings.h"
 #include "AboutDialog.h"
 #include "HelpBrowser.h"
 #include "VAttachButton.h"
@@ -41,6 +42,8 @@
 #include "PluginWrapper.h"
 #include "DebugDialog.h"
 
+#include "FirstRunWizard.h"
+
 #include <QtGui>
 
 #ifdef Q_WS_MAC
@@ -138,13 +141,17 @@ MainWindow::MainWindow()
   VidaliaWindow::setVisible(settings.showMainWindowAtStart());
 #endif
 
+  TorSettings tor_settings(_torControl);
+
   if(settings.firstRun()) {
-    if(settings.allowPanic())
-      VMessageBox::warning(this, tr("Panic is enabled"),
-                           tr("<b>WARNING:</b> The Panic button is enabled. Use "
-                              "it carefully because it will remove Tor completely."),
-                           VMessageBox::Ok|VMessageBox::Default);
-    settings.setFirstRun(false);
+    if(tor_settings.getDisableNetwork() or settings.allowPanic()) {
+      _wizard = new FirstRunWizard(this, settings.allowPanic(), tor_settings.getDisableNetwork());
+      _wizard->show();
+      connect(_wizard, SIGNAL(accepted()),
+              this, SLOT(enableNetwork()));
+
+      settings.setFirstRun(false);
+    }
   }
 }
 
@@ -154,6 +161,20 @@ MainWindow::~MainWindow()
   delete _engine;
 }
 
+/** Called when the user has finished the first run wizard */
+void
+MainWindow::enableNetwork()
+{
+  TorSettings tor_settings(_torControl);
+  tor_settings.setDisableNetwork(false);
+  QString errmsg;
+  if(not tor_settings.apply(&errmsg))
+    VMessageBox::warning(this, tr("Error finishing apply of first run settings"),
+                         tr("Error: %1").arg(errmsg),
+                         VMessageBox::Ok|VMessageBox::Default);
+}
+
+
 /** Calls the different methods that will handle the GUI "creation".
  * It's called once at the MainWindow creation. */
 void
diff --git a/src/vidalia/MainWindow.h b/src/vidalia/MainWindow.h
index 5acd2ee..4a34ee3 100644
--- a/src/vidalia/MainWindow.h
+++ b/src/vidalia/MainWindow.h
@@ -42,6 +42,8 @@
 #include <QTimer>
 #include <QSystemTrayIcon>
 
+class FirstRunWizard;
+
 class MainWindow : public VidaliaWindow
 {
   Q_OBJECT
@@ -198,6 +200,9 @@ private slots:
   void upnpError(UPNPControl::UPNPError error);
 #endif
 
+  /** Called when the user has finished the first run wizard */
+  void enableNetwork();
+
 private:
   enum TorStatus {
     Unset,      /**< Tor's status has not yet been set. */
@@ -319,6 +324,8 @@ private:
   QString _previousSocksPort; /**< Holds the previous socksport used */
 
   bool _pressedStop; /**< True if the user has pressed the Stop Tor button */
+
+  FirstRunWizard *_wizard; /**< Wizard displayed when running Vidalia for the first time */
 };
 
 #endif
diff --git a/src/vidalia/config/AdvancedPage.cpp b/src/vidalia/config/AdvancedPage.cpp
index 084d17c..8e617fd 100644
--- a/src/vidalia/config/AdvancedPage.cpp
+++ b/src/vidalia/config/AdvancedPage.cpp
@@ -478,3 +478,23 @@ AdvancedPage::browsePanicPath()
   if (!panicPath.isEmpty())
     ui.linePanicPath->setText(panicPath);
 }
+
+/** Hides the specified group */
+void
+AdvancedPage::hideGroup(ConfigGroup group)
+{
+  switch(group) {
+  case Control:
+    ui.grpControlPort->hide();
+    break;
+  case ConfigurationFile:
+    ui.grpTorConfigFile->hide();
+    break;
+  case DataDirectory:
+    ui.grpTorDataDirectory->hide();
+    break;
+  case Panic:
+    ui.grpPanic->hide();
+    break;
+  }
+}
diff --git a/src/vidalia/config/AdvancedPage.h b/src/vidalia/config/AdvancedPage.h
index ab91d0e..11cd6b6 100644
--- a/src/vidalia/config/AdvancedPage.h
+++ b/src/vidalia/config/AdvancedPage.h
@@ -28,6 +28,13 @@ class AdvancedPage : public ConfigPage
   Q_OBJECT
 
 public:
+  enum ConfigGroup {
+    Control,
+    ConfigurationFile,
+    DataDirectory,
+    Panic
+  };
+
   /** Default Constructor */
   AdvancedPage(QWidget *parent = 0);
   /** Default Destructor */
@@ -50,6 +57,9 @@ public:
   /** Called when the user changes the UI translation. */
   virtual void retranslateUi();
 
+  /** Hides the specified group */
+  void hideGroup(ConfigGroup group);
+
 signals:
   /** Emitted when the user changes torrc file to restart Tor */
   void restartTor();
diff --git a/src/vidalia/config/AdvancedPage.ui b/src/vidalia/config/AdvancedPage.ui
index a9c97fa..58631cd 100644
--- a/src/vidalia/config/AdvancedPage.ui
+++ b/src/vidalia/config/AdvancedPage.ui
@@ -415,7 +415,7 @@
     </widget>
    </item>
    <item>
-    <widget class="QGroupBox" name="groupBox">
+    <widget class="QGroupBox" name="grpPanic">
      <property name="title">
       <string>Panic</string>
      </property>
diff --git a/src/vidalia/config/NetworkSettings.cpp b/src/vidalia/config/NetworkSettings.cpp
index bb4e7ba..21c41c7 100644
--- a/src/vidalia/config/NetworkSettings.cpp
+++ b/src/vidalia/config/NetworkSettings.cpp
@@ -65,6 +65,10 @@ bool
 NetworkSettings::apply(QString *errmsg)
 {
   quint32 torVersion = torControl()->getTorVersion();
+  // If there is no tor version, asume the greatest
+  if(not torVersion)
+    torVersion = 0xffffff;
+
   Torrc *torrc = Vidalia::torrc();
   QStringList clearKeys;
 
diff --git a/src/vidalia/config/TorSettings.cpp b/src/vidalia/config/TorSettings.cpp
index fe7e4c1..b7da39a 100644
--- a/src/vidalia/config/TorSettings.cpp
+++ b/src/vidalia/config/TorSettings.cpp
@@ -47,6 +47,7 @@
 #define SETTING_BOOTSTRAP            "Bootstrap"
 #define SETTING_BOOTSTRAP_FROM       "BootstrapFrom"
 #define SETTING_AUTOCONTROL          "AutoControl"
+#define SETTING_DISABLE_NETWORK      "DisableNetwork"
 
 /** Default to using hashed password authentication */
 #define DEFAULT_AUTH_METHOD     PasswordAuth
@@ -97,6 +98,7 @@ TorSettings::TorSettings(TorControl *torControl)
   setDefault(SETTING_BOOTSTRAP, false);
   setDefault(SETTING_BOOTSTRAP_FROM, "");
   setDefault(SETTING_AUTOCONTROL, false);
+  setDefault(SETTING_DISABLE_NETWORK, false);
 }
 
 /** Applies any changes to Tor's control port or authentication settings. */
@@ -156,6 +158,9 @@ TorSettings::apply(QString *errmsg)
       torrc->setValue(TOR_ARG_HASHED_PASSWORD, "");
   }
 
+  torrc->setValue(SETTING_DISABLE_NETWORK,
+                  volatileValue(SETTING_DISABLE_NETWORK).toBool() ? "1" : "0");
+
   return torrc->apply(Vidalia::torControl(), errmsg);
 }
 
@@ -446,6 +451,26 @@ TorSettings::setRejectPlaintextPorts(const QList<quint16> &ports)
   setValue(SETTING_REJECT_PLAINTEXT_PORTS, rejectList.join(","));
 }
 
+/** Returns the value for the DisableNetwork option */
+bool
+TorSettings::getDisableNetwork() const
+{
+  bool val = false;
+  with_torrc_value(SETTING_DISABLE_NETWORK) {
+    val = (bool)ret.at(0).toUInt();
+  }
+
+  return val;
+}
+
+/** Sets the DisableNetwork property for tor. When enabled, tor
+ * won't try to reach any node. */
+void
+TorSettings::setDisableNetwork(bool val)
+{
+  setVolatileValue(SETTING_DISABLE_NETWORK, val);
+}
+
 /** Returns the string description of the authentication method specified by
  * <b>method</b>. The authentication method string is stored in Vidalia's
  * configuration file. */
diff --git a/src/vidalia/config/TorSettings.h b/src/vidalia/config/TorSettings.h
index 1352518..6feabe7 100644
--- a/src/vidalia/config/TorSettings.h
+++ b/src/vidalia/config/TorSettings.h
@@ -127,6 +127,12 @@ public:
    * when the user tries to connect to one of them. */
   void setRejectPlaintextPorts(const QList<quint16> &ports);
 
+  /** Returns the value for the DisableNetwork option */
+  bool getDisableNetwork() const;
+  /** Sets the DisableNetwork property for tor. When enabled, tor
+   * won't try to reach any node. */
+  void setDisableNetwork(bool val);
+
   /** Generates a random control password consisting of PASSWORD_LEN
    * characters. */
   static QString randomPassword();
diff --git a/src/vidalia/config/torrc/TorrcParser.cpp b/src/vidalia/config/torrc/TorrcParser.cpp
index 2c5c679..bdcd618 100644
--- a/src/vidalia/config/torrc/TorrcParser.cpp
+++ b/src/vidalia/config/torrc/TorrcParser.cpp
@@ -87,6 +87,7 @@ TorrcParser::TorrcParser()
   _torOpts << TorOpt("DirServer", TorOpt::LineList, "");
   _torOpts << TorOpt("DisableAllSwap", TorOpt::Boolean, "0");
   _torOpts << TorOpt("DisableIOCP", TorOpt::Boolean, "1");
+  _torOpts << TorOpt("DisableNetwork", TorOpt::Boolean, "0");
   _torOpts << TorOpt("DNSPort", TorOpt::LineList, "");
   _torOpts << TorOpt("DNSListenAddress", TorOpt::LineList, "");
   _torOpts << TorOpt("DownloadExtraInfo", TorOpt::Boolean, "0");



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits