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

[tor-commits] [vidalia/alpha] Merge branch 'master' into alpha



commit 70680a3325b820abf41bffc0eea1c7a7523ffaad
Merge: 5193835 d569712
Author: Tomas Touceda <chiiph@xxxxxxxxxx>
Date:   Thu May 5 17:09:54 2011 -0300

    Merge branch 'master' into alpha
    
    Conflicts:
    	src/vidalia/MainWindow.cpp
    	src/vidalia/help/content/po/templates/links.pot

 src/vidalia/MainWindow.cpp                      |    8 ++--
 src/vidalia/help/content/po/templates/links.pot |   46 +++++++++-------------
 2 files changed, 23 insertions(+), 31 deletions(-)

diff --cc src/vidalia/MainWindow.cpp
index d1fd2a4,860eae4..c373d01
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@@ -1038,116 -858,435 +1038,116 @@@ MainWindow::bootstrapStatusChanged(cons
    setStartupProgress(percentComplete, description);
  }
  
 -/** Updates the UI to reflect Tor's current <b>status</b>. Returns the
 - * previously set TorStatus value.*/
 -MainWindow::TorStatus
 -MainWindow::updateTorStatus(TorStatus status)
 -{
 -  QString statusText, actionText;
 -  QString trayIconFile, statusIconFile;
 -  TorStatus prevStatus = _status;
 - 
 -  vNotice("Tor status changed from '%1' to '%2'.")
 -    .arg(toString(prevStatus)).arg(toString(status));
 -  _status = status;
 -
 -  if (status == Stopped) {
 -      statusText = tr("Tor is not running");
 -      actionText = tr("Start Tor");
 -      trayIconFile = IMG_TOR_STOPPED;
 -      statusIconFile = IMG_TOR_STOPPED_48;
 -      _actionStartStopTor->setEnabled(true);
 -      _actionStartStopTor->setText(actionText);
 -      _actionStartStopTor->setIcon(QIcon(IMG_START_TOR_16));
 -      ui.lblStartStopTor->setEnabled(true);
 -      ui.lblStartStopTor->setText(actionText);
 -      ui.lblStartStopTor->setPixmap(QPixmap(IMG_START_TOR_48));
 -      ui.lblStartStopTor->setStatusTip(actionText);
 -
 -      /* XXX: This might need to be smarter if we ever start connecting other
 -       * slots to these triggered() and clicked() signals. */
 -      QObject::disconnect(_actionStartStopTor, SIGNAL(triggered()), this, 0);
 -      QObject::disconnect(ui.lblStartStopTor, SIGNAL(clicked()), this, 0);
 -      connect(_actionStartStopTor, SIGNAL(triggered()), this, SLOT(start()));
 -      connect(ui.lblStartStopTor, SIGNAL(clicked()), this, SLOT(start()));
 -      setStartupProgressVisible(false);
 -  } else if (status == Stopping) {
 -      if (_delayedShutdownStarted) {
 -        statusText = tr("Your relay is shutting down.\n" 
 -                        "Click 'Stop' again to stop your relay now.");
 -      } else {
 -        statusText = tr("Tor is shutting down");
 -      }
 -      trayIconFile = IMG_TOR_STOPPING;
 -      statusIconFile = IMG_TOR_STOPPING_48;
 -      
 -      ui.lblStartStopTor->setStatusTip(tr("Stop Tor Now"));
 -  } else if (status == Started) {
 -      actionText = tr("Stop Tor");
 -      _actionStartStopTor->setEnabled(true);
 -      _actionStartStopTor->setText(actionText);
 -      _actionStartStopTor->setIcon(QIcon(IMG_STOP_TOR_16));
 -      ui.lblStartStopTor->setEnabled(true);
 -      ui.lblStartStopTor->setText(actionText);
 -      ui.lblStartStopTor->setPixmap(QPixmap(IMG_STOP_TOR_48));
 -      ui.lblStartStopTor->setStatusTip(actionText);
 -            
 -      /* XXX: This might need to be smarter if we ever start connecting other
 -       * slots to these triggered() and clicked() signals. */
 -      QObject::disconnect(_actionStartStopTor, SIGNAL(triggered()), this, 0);
 -      QObject::disconnect(ui.lblStartStopTor, SIGNAL(clicked()), this, 0);
 -      connect(_actionStartStopTor, SIGNAL(triggered()), this, SLOT(stop()));
 -      connect(ui.lblStartStopTor, SIGNAL(clicked()), this, SLOT(stop()));
 -  } else if (status == Starting)  {
 -      statusText = tr("Starting the Tor software");
 -      trayIconFile = IMG_TOR_STARTING;
 -      statusIconFile = IMG_TOR_STARTING_48;
 -      _actionStartStopTor->setEnabled(false);
 -      ui.lblStartStopTor->setText(tr("Starting Tor"));
 -      ui.lblStartStopTor->setEnabled(false);
 -      ui.lblStartStopTor->setStatusTip(statusText);
 -      setStartupProgressVisible(true);
 -      setStartupProgress(STARTUP_PROGRESS_STARTING, statusText);
 -  } else if (status == CircuitEstablished) {
 -      statusText = tr("Connected to the Tor network!");
 -      trayIconFile = IMG_TOR_RUNNING;
 -      statusIconFile = IMG_TOR_RUNNING_48;
 -      setStartupProgressVisible(false);
 -  }
 -
 -  /* Update the tray icon */
 -  if (!trayIconFile.isEmpty()) {
 -    setTrayIcon(trayIconFile);
 -  }
 -  /* Update the status banner on the control panel */
 -  if (!statusIconFile.isEmpty())
 -    ui.lblTorStatusImg->setPixmap(QPixmap(statusIconFile));
 -  if (!statusText.isEmpty()) {
 -    _trayIcon.setToolTip(statusText);
 -    ui.lblTorStatus->setText(statusText);
 -  }
 -  return prevStatus;
 -}
 -
 -/** Called when the "show on startup" checkbox is toggled. */
 +/** Called when Tor has successfully established a circuit. */
  void
 -MainWindow::toggleShowOnStartup(bool checked)
 +MainWindow::circuitEstablished()
  {
 -  VidaliaSettings settings;
 -  settings.setShowMainWindowAtStart(checked);
 -}
 +  updateTorStatus(CircuitEstablished);
 +  // TODO: fix hardcoded total length
 +  setStartupProgress(130,
 +                     tr("Connected to the Tor network!"));
 +  startSubprocesses();
  
 -/** Sets the visibility of the startup status description and progress bar to
 - * <b>visible</b>. */
 -void
 -MainWindow::setStartupProgressVisible(bool visible)
 -{
 -  /* XXX: We force a repaint() to make sure the progress bar and onion status
 -   * icon don't overlap briefly. This is pretty hacktastic. */
 -  if (visible) {
 -    ui.lblTorStatus->setVisible(false);
 -    ui.lblTorStatusImg->setVisible(false);
 -    repaint(ui.grpStatus->rect());
 -    ui.lblStartupProgress->setVisible(true);
 -    ui.progressBar->setVisible(true);
 -  } else {
 -    ui.lblStartupProgress->setVisible(false);
 -    ui.progressBar->setVisible(false);
 -    repaint(ui.grpStatus->rect());
 -    ui.lblTorStatus->setVisible(true);
 -    ui.lblTorStatusImg->setVisible(true);
 +#if defined(USE_AUTOUPDATE)
 +  VidaliaSettings settings;
 +  if (settings.isAutoUpdateEnabled()) {
 +    QDateTime lastCheckedAt = settings.lastCheckedForUpdates();
 +    if (UpdateProcess::shouldCheckForUpdates(lastCheckedAt)) {
 +      /* Initiate a background check for updates now */
 +      _updateTimer.stop();
 +      checkForUpdates();
 +    }
    }
 +#endif
  }
  
 -/** Sets the progress bar completion value to <b>progressValue</b> and sets
 - * the status text to <b>description</b>. */
 +/** Called when Tor thinks the user has tried to connect to a port that
 + * typically is used for unencrypted applications. Warns the user and allows
 + * them to ignore future warnings on <b>port</b>. It is possible that Tor
 + * will produce multiple asynchronous status events warning of dangerous ports
 + * while the message box is displayed (for example, while the user is away
 + * from the keyboard), so subsequent messages will be discarded until the
 + * first message box is dismissed. */
  void
 -MainWindow::setStartupProgress(int progressValue,
 -                               const QString &description)
 -{
 -  ui.progressBar->setValue(progressValue);
 -  ui.lblStartupProgress->setText(description);
 -  _trayIcon.setToolTip(description);
 -}
 -
 -/** Attempts to start Tor. If Tor fails to start, then startFailed() will be
 - * called with an error message containing the reason. */
 -void 
 -MainWindow::start()
 +MainWindow::warnDangerousPort(quint16 port, bool rejected)
  {
 -  TorSettings settings;
 -  QStringList args;
 -
 -  updateTorStatus(Starting);
 -
 -  /* Check if Tor is already running separately */
 -  if(settings.getControlMethod() == ControlMethod::Port) {
 -    if (net_test_connect(settings.getControlAddress(),
 -                        settings.getControlPort())) {
 -      started();
 -      return;
 -    }
 -  } else {
 -    if (socket_test_connect(settings.getSocketPath())) {
 -      started();
 -      return;
 -    }
 -  }
 -
 -  QString torrc = settings.getTorrc();
 +  static QMessageBox *dlg = 0;
  
 -  if(settings.bootstrap()) {
 -    QString boottorrc = settings.bootstrapFrom();
 -    vNotice(tr("Bootstrapping torrc from %1 to %2")
 -        .arg(boottorrc).arg(torrc));
 -    if(QFileInfo(boottorrc).exists()) {
 -      if(QFile::copy(boottorrc, torrc)) {
 -        settings.setBootstrap(false);
 -      }
 -    }
 -  }
 +  /* Don't display another message box until the first one is dismissed */
 +  if (dlg)
 +    return;
  
 -  /* Make sure the torrc we want to use really exists. */
 -  if (!torrc.isEmpty()) {
 -    if (!QFileInfo(torrc).exists())
 -      touch_file(torrc, true);
 -    args << "-f" << torrc;
 -  }
 +  QString application;
 +  switch (port) {
 +    case  23:
-      application = tr(", probably Telnet, ");
++     application = tr("(probably Telnet)");
 +     break;
  
 -  /* Specify Tor's data directory, if different from the default */
 -  QString dataDirectory = settings.getDataDirectory();
 -  if (!dataDirectory.isEmpty())
 -    args << "DataDirectory" << expand_filename(dataDirectory);
 -  
 -  if(settings.getControlMethod() == ControlMethod::Port) {
 -    /* Add the intended control port value */
 -    quint16 controlPort = settings.getControlPort();
 -    if (controlPort)
 -      args << "ControlPort" << QString::number(controlPort);
 -  } else {
 -    QString path = settings.getSocketPath();
 -    args << "ControlSocket" << path;
 -  }
 -  
 -  /* Add the control port authentication arguments */
 -  switch (settings.getAuthenticationMethod()) {
 -    case TorSettings::PasswordAuth:
 -      if (! vApp->readPasswordFromStdin()) {
 -        if (settings.useRandomPassword()) {
 -          _controlPassword = TorSettings::randomPassword();
 -          _useSavedPassword = false;
 -        } else {
 -          _controlPassword = settings.getControlPassword();
 -          _useSavedPassword = true;
 -        }
 -      }
 -      args << "HashedControlPassword"
 -           << TorSettings::hashPassword(_controlPassword);
 -      break;
 -    case TorSettings::CookieAuth:
 -      args << "CookieAuthentication"  << "1";
 +    case 109:
 +    case 110:
 +    case 143:
-       application = tr(", probably an email client, "); 
++      application = tr("(probably an email client)"); 
        break;
 -    default:
 -      args << "CookieAuthentication"  << "0";
 -  }
 -
 -  /* This doesn't get set to false until Tor is actually up and running, so we
 -   * don't yell at users twice if their Tor doesn't even start, due to the fact
 -   * that QProcess::stopped() is emitted even if the process didn't even
 -   * start. */
 -  _isIntentionalExit = true;
 -  /* Kick off the Tor process */
 -  _torControl->start(settings.getExecutable(), args);
 -}
  
 -/** Called when the user changes a setting that needs Tor restarting */
 -void
 -MainWindow::restart()
 -{
 -  if(_torControl->stop()) {
 -    start();
 +    default:
-       application = " ";
++      application = "";
    }
 -}
  
-   QString text = tr("One of your applications%1appears to be making a "
 -/** Called when the Tor process fails to start, for example, because the path
 - * specified to the Tor executable didn't lead to an executable. */
 -void
 -MainWindow::startFailed(QString errmsg)
 -{
 -  /* We don't display the error message for now, because the error message
 -   * that Qt gives us in this instance is almost always "Unknown Error". That
 -   * will make users sad. */
 -  Q_UNUSED(errmsg);
 - 
 -  updateTorStatus(Stopped);
 -
 -  /* Display an error message and see if the user wants some help */
 -  int response = VMessageBox::warning(this, tr("Error Starting Tor"),
 -                   tr("Vidalia was unable to start Tor. Check your settings "
 -                        "to ensure the correct name and location of your Tor "
 -                        "executable is specified."),
 -                   VMessageBox::ShowSettings|VMessageBox::Default,
 -                   VMessageBox::Cancel|VMessageBox::Escape,
 -                   VMessageBox::Help);
++  QString text = tr("One of your applications %1 appears to be making a "
 +                    "potentially unencrypted and unsafe connection to port %2.")
 +                    .arg(application).arg(port);
  
 -  if (response == VMessageBox::ShowSettings) {
 -    /* Show the settings dialog so the user can make sure they're pointing to
 -     * the correct Tor. */
 -     showConfigDialog();
 -  } else if (response == VMessageBox::Help) {
 -    /* Show troubleshooting information about starting Tor */
 -    showHelpDialog("troubleshooting.start");
 +  QString extraText = p(tr("Anything sent over this connection could be "
 +                           "monitored. Please check your application's "
 +                           "configuration and use only encrypted protocols, "
 +                           "such as SSL, if possible."));
 +  if (rejected) {
 +    extraText.append(p(tr("Tor has automatically closed your connection in "
 +                          "order to protect your anonymity.")));
    }
 -}
 -
 -/** Slot: Called when the Tor process is started. It will connect the control
 - * socket and set the icons and tooltips accordingly. */
 -void 
 -MainWindow::started()
 -{
 -  TorSettings settings;
 -
 -  updateTorStatus(Started);
 -
 -  /* Now that Tor is running, we want to know if it dies when we didn't want
 -   * it to. */
 -  _isIntentionalExit = false;
 -  /* We haven't started a delayed shutdown yet. */
 -  _delayedShutdownStarted = false;
 -  /* Remember whether we started Tor or not */
 -  _isVidaliaRunningTor = _torControl->isVidaliaRunningTor();
 -  /* Try to connect to Tor's control port */
 -  if(settings.getControlMethod() == ControlMethod::Port)
 -    _torControl->connect(settings.getControlAddress(),
 -                        settings.getControlPort());
 -  else
 -    _torControl->connect(settings.getSocketPath());
 -  setStartupProgress(STARTUP_PROGRESS_CONNECTING, tr("Connecting to Tor"));
 -}
 -
 -/** Called when the connection to the control socket fails. The reason will be
 - * given in the errmsg parameter. */
 -void
 -MainWindow::connectFailed(QString errmsg)
 -{
 -  /* Ok, ok. It really isn't going to connect. I give up. */
 -  int response = VMessageBox::warning(this, 
 -                   tr("Connection Error"), p(errmsg),
 -                   VMessageBox::Ok|VMessageBox::Default|VMessageBox::Escape, 
 -                   VMessageBox::Retry, VMessageBox::Help);
  
 +  dlg = new QMessageBox(QMessageBox::Warning,
 +                        tr("Potentially Unsafe Connection"), text,
 +                        QMessageBox::Ok | QMessageBox::Ignore);
 +  dlg->setInformativeText(extraText);
 +  dlg->setDefaultButton(QMessageBox::Ok);
 +  dlg->setEscapeButton(QMessageBox::Ok);
  
 -  if (response == VMessageBox::Retry) {
 -    /* Let's give it another try. */
 +  int ret = dlg->exec();
 +  if (ret == QMessageBox::Ignore) {
 +    TorControl *tc = Vidalia::torControl();
      TorSettings settings;
 -    _torControl->connect(settings.getControlAddress(),
 -                         settings.getControlPort());
 -  } else {
 -    /* Show the help browser (if requested) */
 -    if (response == VMessageBox::Help)
 -      showHelpDialog("troubleshooting.connect");
 -    /* Since Vidalia can't connect, we can't really do much, so stop Tor. */
 -    _torControl->stop();
 -  }
 -}
 -
 -/** Disconnects the control socket and stops the Tor process. */
 -bool
 -MainWindow::stop()
 -{
 -  ServerSettings server(_torControl);
 -  QString errmsg;
 -  TorStatus prevStatus;
 -  bool rc;
 -
 -  /* If we're running a server, give users the option of terminating
 -   * gracefully so clients have time to find new servers. */
 -  if (server.isServerEnabled() && !_delayedShutdownStarted) {
 -    /* Ask the user if they want to shutdown nicely. */
 -    int response = VMessageBox::question(this, tr("Relaying is Enabled"),
 -                     tr("You are currently running a relay. "
 -                        "Terminating your relay will interrupt any "
 -                        "open connections from clients.\n\n"
 -                        "Would you like to shutdown gracefully and "
 -                        "give clients time to find a new relay?"),
 -                        VMessageBox::Yes|VMessageBox::Default, 
 -                        VMessageBox::No, 
 -                        VMessageBox::Cancel|VMessageBox::Escape);
 -    if (response == VMessageBox::Yes)
 -      _delayedShutdownStarted = true;
 -    else if (response == VMessageBox::Cancel)
 -      return false;
 -  }
 -  
 -  prevStatus = updateTorStatus(Stopping);  
 -  if (_delayedShutdownStarted) {
 -    /* Start a delayed shutdown */
 -    rc = _torControl->signal(TorSignal::Shutdown, &errmsg);
 -  } else {
 -    /* We want Tor to stop now, regardless of whether we're a server. */
 -    _isIntentionalExit = true;
 -    rc = _torControl->stop(&errmsg);
 -  }
 -  
 -  if (!rc) {
 -    /* We couldn't tell Tor to stop, for some reason. */
 -    int response = VMessageBox::warning(this, tr("Error Shutting Down"),
 -                     p(tr("Vidalia was unable to stop the Tor software.")) 
 -                       + p(errmsg),
 -                     VMessageBox::Ok|VMessageBox::Default|VMessageBox::Escape, 
 -                     VMessageBox::Help);
 -      
 -    if (response == VMessageBox::Help) {
 -      /* Show some troubleshooting help */
 -      showHelpDialog("troubleshooting.stop");
 -    }
 -    /* Tor is still running since stopping failed */
 -    _isIntentionalExit = false;
 -    _delayedShutdownStarted = false;
 -    updateTorStatus(prevStatus);
 -  }
 -  return rc;
 -}
 +    QStringList portList;
 +    QList<quint16> ports;
 +    int idx;
  
 -/** Slot: Called when the Tor process has exited. It will adjust the tray
 - * icons and tooltips accordingly. */
 -void 
 -MainWindow::stopped(int exitCode, QProcess::ExitStatus exitStatus)
 -{
 -  updateTorStatus(Stopped);
 +    ports = settings.getWarnPlaintextPorts();
 +    idx   = ports.indexOf(port);
 +    if (idx >= 0) {
 +      ports.removeAt(idx);
 +      settings.setWarnPlaintextPorts(ports);
  
 -  /* If we didn't intentionally close Tor, then check to see if it crashed or
 -   * if it closed itself and returned an error code. */
 -  if (!_isIntentionalExit) {
 -    /* A quick overview of Tor's code tells me that if it catches a SIGTERM or
 -     * SIGINT, Tor will exit(0). We might need to change this warning message
 -     * if this turns out to not be the case. */
 -    if (exitStatus == QProcess::CrashExit || exitCode != 0) {
 -      int ret = VMessageBox::warning(this, tr("Unexpected Error"),
 -                  tr("Vidalia detected that the Tor software exited "
 -                     "unexpectedly.\n\n"
 -                     "Please check the message log for recent "
 -                     "warning or error messages."),
 -                  VMessageBox::Ok|VMessageBox::Escape, 
 -                  VMessageBox::ShowLog|VMessageBox::Default,
 -                  VMessageBox::Help);
 -      if (ret == VMessageBox::ShowLog)
 -        _messageLog->showWindow();  
 -      else if (ret == VMessageBox::Help)
 -        showHelpDialog("troubleshooting.torexited");
 +      foreach (quint16 port, ports) {
 +        portList << QString::number(port);
 +      }
 +      tc->setConf("WarnPlaintextPorts", portList.join(","));
 +      portList.clear();
      }
 -  }
 -}
 -
 -/** Called when the control socket has successfully connected to Tor. */
 -void
 -MainWindow::connected()
 -{
 -  authenticate();
 -}
  
 -/** Called when Vidalia wants to disconnect from a Tor it did not start. */
 -void
 -MainWindow::disconnect()
 -{
 -  _torControl->disconnect();
 -}
 +    ports = settings.getRejectPlaintextPorts();
 +    idx   = ports.indexOf(port);
 +    if (idx >= 0) {
 +      ports.removeAt(idx);
 +      settings.setRejectPlaintextPorts(ports);
  
 -/** Called when the control socket has been disconnected. */
 -void
 -MainWindow::disconnected()
 -{
 -  if (!_isVidaliaRunningTor) {
 -    /* If we didn't start our own Tor process, interpret losing the control
 -     * connection as "Tor is stopped". */
 -    updateTorStatus(Stopped);
 +      foreach (quint16 port, ports) {
 +        portList << QString::number(port);
 +      }
 +      tc->setConf("RejectPlaintextPorts", portList.join(","));
 +    }
    }
 -  
 -  /*XXX We should warn here if we get disconnected when we didn't intend to */
 -  _actionNewIdentity->setEnabled(false);
 -  ui.lblNewIdentity->setEnabled(false);
 -  _isVidaliaRunningTor = false;
 +  delete dlg;
 +  dlg = 0;
  }
  
  /** Attempts to authenticate to Tor's control port, depending on the

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