[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2706: Update the progress bar, status text, and tooltip based on T (in vidalia: . trunk/src/vidalia)
Author: edmanm
Date: 2008-06-13 01:39:27 -0400 (Fri, 13 Jun 2008)
New Revision: 2706
Modified:
vidalia/
vidalia/trunk/src/vidalia/mainwindow.cpp
vidalia/trunk/src/vidalia/mainwindow.h
Log:
r534@thebe: edmanm | 2008-06-13 01:40:03 -0400
Update the progress bar, status text, and tooltip based on Tor's bootstrapping
events.
Property changes on: vidalia
___________________________________________________________________
svk:merge ticket from /local/vidalia [r534] on 45a62a8a-8088-484c-baad-c7b3e776dd32
Modified: vidalia/trunk/src/vidalia/mainwindow.cpp
===================================================================
--- vidalia/trunk/src/vidalia/mainwindow.cpp 2008-06-13 05:39:25 UTC (rev 2705)
+++ vidalia/trunk/src/vidalia/mainwindow.cpp 2008-06-13 05:39:27 UTC (rev 2706)
@@ -77,6 +77,12 @@
/** Only allow 'New Identity' to be clicked once every 10 seconds. */
#define MIN_NEWIDENTITY_INTERVAL (10*1000)
+/* Startup progress milestones */
+#define STARTUP_PROGRESS_STARTING 0
+#define STARTUP_PROGRESS_CONNECTING 10
+#define STARTUP_PROGRESS_AUTHENTICATING 20
+#define STARTUP_PROGRESS_BOOTSTRAPPING 30
+#define STARTUP_PROGRESS_MAXIMUM (STARTUP_PROGRESS_BOOTSTRAPPING+100)
/** Default constructor. It installs an icon in the system tray area and
* creates the popup menu associated with that icon. */
@@ -516,7 +522,44 @@
void
MainWindow::bootstrapStatusChanged(const BootstrapStatusEvent *bse)
{
- Q_UNUSED(bse);
+ int percentComplete = STARTUP_PROGRESS_BOOTSTRAPPING + bse->percentComplete();
+
+ QString description;
+ switch (bse->status()) {
+ case BootstrapStatusEvent::ConnectingToDirMirror:
+ case BootstrapStatusEvent::HandshakingWithDirMirror:
+ description = tr("Connecting to a directory mirror");
+ break;
+ case BootstrapStatusEvent::CreatingOneHopCircuit:
+ description = tr("Establishing an encrypted directory connection");
+ break;
+ case BootstrapStatusEvent::RequestingNetworkStatus:
+ description = tr("Retrieving network status");
+ break;
+ case BootstrapStatusEvent::LoadingNetworkStatus:
+ description = tr("Loading network status");
+ break;
+ case BootstrapStatusEvent::LoadingAuthorityCertificates:
+ description = tr("Loading authority certificates");
+ break;
+ case BootstrapStatusEvent::RequestingDescriptors:
+ description = tr("Requesting relay information");
+ break;
+ case BootstrapStatusEvent::LoadingDescriptors:
+ description = tr("Loading relay information");
+ break;
+ case BootstrapStatusEvent::ConnectingToEntryGuard:
+ case BootstrapStatusEvent::HandshakingWithEntryGuard:
+ case BootstrapStatusEvent::EstablishingCircuit:
+ description = tr("Connecting to the Tor network");
+ break;
+ case BootstrapStatusEvent::BootstrappingDone:
+ description = tr("Connected to the Tor network!");
+ break;
+ default:
+ description = tr("Unrecognized startup status");
+ }
+ setStartupProgress(percentComplete, description);
}
/** Updates the UI to reflect Tor's current <b>status</b>. Returns the
@@ -571,7 +614,7 @@
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(_startStopAct, SIGNAL(triggered()), this, 0);
@@ -579,18 +622,21 @@
connect(_startStopAct, SIGNAL(triggered()), this, SLOT(stop()));
connect(ui.lblStartStopTor, SIGNAL(clicked()), this, SLOT(stop()));
} else if (status == Starting) {
- statusText = tr("Tor is starting up...");
+ statusText = tr("Starting the Tor software");
trayIconFile = IMG_TOR_STARTING;
statusIconFile = IMG_TOR_STARTING_48;
_startStopAct->setEnabled(false);
ui.lblStartStopTor->setText(tr("Starting Tor"));
ui.lblStartStopTor->setEnabled(false);
ui.lblStartStopTor->setStatusTip(statusText);
+ setStartupProgressVisible(true);
+ setStartupProgress(STARTUP_PROGRESS_STARTING, statusText);
//ui.lblStartStopTor->setAnimation(QPixmap(ANIM_PROCESS_WORKING));
} else if (status == CircuitEstablished) {
statusText = tr("Tor is Running");
trayIconFile = IMG_TOR_RUNNING;
statusIconFile = IMG_TOR_RUNNING_48;
+ QTimer::singleShot(3000, this, SLOT(hideStartupProgress()));
}
/* Update the tray icon */
@@ -615,6 +661,42 @@
settings.setShowMainWindowAtStart(checked);
}
+/** Sets the visibility of the startup status description and progress bar to
+ * <b>visible</b>. */
+void
+MainWindow::setStartupProgressVisible(bool visible)
+{
+ if (visible) {
+ ui.lblTorStatus->setVisible(false);
+ ui.lblTorStatusImg->setVisible(false);
+ ui.lblStartupProgress->setVisible(true);
+ ui.progressBar->setVisible(true);
+ } else {
+ ui.lblStartupProgress->setVisible(false);
+ ui.progressBar->setVisible(false);
+ ui.lblTorStatus->setVisible(true);
+ ui.lblTorStatusImg->setVisible(true);
+ }
+}
+
+/** Hides the startup status text and progress bar. */
+void
+MainWindow::hideStartupProgress()
+{
+ setStartupProgressVisible(false);
+}
+
+/** Sets the progress bar completion value to <b>progressValue</b> and sets
+ * the status text to <b>description</b>. */
+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
@@ -624,7 +706,7 @@
QStringList args;
updateTorStatus(Starting);
-
+
/* Check if Tor is already running separately */
if (net_test_connect(settings.getControlAddress(),
settings.getControlPort())) {
@@ -738,6 +820,7 @@
/* Try to connect to Tor's control port */
_torControl->connect(settings.getControlAddress(),
settings.getControlPort());
+ setStartupProgress(STARTUP_PROGRESS_CONNECTING, tr("Connecting to Tor"));
}
/** Called when the connection to the control socket fails. The reason will be
@@ -895,7 +978,9 @@
ProtocolInfo pi;
updateTorStatus(Authenticating);
-
+ setStartupProgress(STARTUP_PROGRESS_AUTHENTICATING,
+ tr("Authenticating to Tor"));
+
authMethod = settings.getAuthenticationMethod();
pi = _torControl->protocolInfo();
if (!pi.isEmpty()) {
Modified: vidalia/trunk/src/vidalia/mainwindow.h
===================================================================
--- vidalia/trunk/src/vidalia/mainwindow.h 2008-06-13 05:39:25 UTC (rev 2705)
+++ vidalia/trunk/src/vidalia/mainwindow.h 2008-06-13 05:39:27 UTC (rev 2706)
@@ -110,6 +110,8 @@
void onIMFailed(QString errmsg);
/** Called when the proxy server fails to start */
void onProxyFailed(QString errmsg);
+ /** Hides the startup status text and progress bar. */
+ void hideStartupProgress();
#if defined(USE_MINIUPNPC)
/** Called when a UPnP error occurs. */
@@ -164,7 +166,13 @@
/** Called when Tor's bootstrapping status changes. <b>bse</b> represents
* Tor's current estimate of its bootstrapping progress. */
void bootstrapStatusChanged(const BootstrapStatusEvent *bse);
-
+ /** Sets the visibility of the startup status description and progress bar
+ * to <b>visible</b>. */
+ void setStartupProgressVisible(bool visible);
+ /** Sets the progress bar completion value to <b>progressValue</b> and sets
+ * the status text to <b>description</b>. */
+ void setStartupProgress(int percentComplete, const QString &description);
+
/** The current status of Tor. */
TorStatus _status;
/** Used to determine if the Tor process exiting was intentional or not */