MainWindow Class Reference

#include <mainwindow.h>

Inheritance diagram for MainWindow:

VidaliaWindow

List of all members.

Public Member Functions

 MainWindow ()
 ~MainWindow ()

Protected Member Functions

virtual void customEvent (QEvent *event)

Private Types

enum  TorStatus {
  Unset, Stopping, Stopped, Starting,
  Started, Authenticating, Authenticated, CircuitEstablished
}

Private Slots

void showHelpDialog ()
void showHelpDialog (const QString &topic)
void start ()
void startFailed (QString errmsg)
void started ()
bool stop ()
void stopped (int errorCode, QProcess::ExitStatus exitStatus)
void connected ()
void connectFailed (QString errmsg)
void disconnect ()
void disconnected ()
void authenticated ()
void authenticationFailed (QString errmsg)
void enableNewIdentity ()
void newIdentity ()
void close ()
void running ()
void shutdown ()
void showAboutDialog ()
void showConfigDialog (ConfigDialog::Page page=ConfigDialog::General)
void showServerConfigDialog ()
void toggleShowOnStartup (bool checked)
void onSubprocessFinished (int exitCode, QProcess::ExitStatus exitStatus)
void onBrowserFailed (QString errmsg)
void onIMFailed (QString errmsg)
void onProxyFailed (QString errmsg)

Private Member Functions

void createActions ()
void createTrayIcon ()
QMenu * createTrayMenu ()
void createMenuBar ()
TorStatus updateTorStatus (TorStatus status)
void startSubprocesses ()
void startProxy ()
QString toString (TorStatus status)
bool authenticate ()
QByteArray loadControlCookie (QString cookiePath=QString())
void circuitEstablished ()
void checkTorVersion ()
void dangerousTorVersion ()
void bootstrapStatusChanged (const BootstrapStatus &bs)
void setStartupProgressVisible (bool visible)
void setStartupProgress (int percentComplete, const QString &description)

Private Attributes

TorStatus _status
bool _isIntentionalExit
bool _delayedShutdownStarted
bool _isVidaliaRunningTor
MessageLog_messageLog
BandwidthGraph_bandwidthGraph
NetViewer_netViewer
ConfigDialog_configDialog
TorControl_torControl
HelperProcess_browserProcess
HelperProcess_imProcess
HelperProcess_proxyProcess
QString _controlPassword
bool _useSavedPassword
TrayIcon _trayIcon
QAction * _controlPanelAct
QAction * _startStopAct
QAction * _configAct
QAction * _aboutAct
QAction * _exitAct
QAction * _bandwidthAct
QAction * _messageAct
QAction * _helpAct
QAction * _networkAct
QAction * _newIdentityAct
Ui::MainWindow ui


Detailed Description

Definition at line 40 of file mainwindow.h.


Member Enumeration Documentation

enum MainWindow::TorStatus [private]

Enumerator:
Unset  Tor's status has not yet been set.
Stopping  Tor is in the process of shutting down.
Stopped  Tor is not running.
Starting  Tor is in the process of starting.
Started  Tor is currently running.
Authenticating  Vidalia is authenticating to Tor.
Authenticated  Vidalia has authenticated to Tor.
CircuitEstablished  Tor has built a circuit.

Definition at line 120 of file mainwindow.h.


Constructor & Destructor Documentation

MainWindow::MainWindow (  ) 

MainWindow::~MainWindow (  ) 

Destructor.

Definition at line 188 of file mainwindow.cpp.

References _bandwidthGraph, _configDialog, _messageLog, _netViewer, _trayIcon, and TrayIcon::hide().


Member Function Documentation

void MainWindow::customEvent ( QEvent *  event  )  [protected, virtual]

void MainWindow::showHelpDialog (  )  [private, slot]

Displays the help browser and displays the most recently viewed help topic.

Displays the help browser and displays the most recently viewed help topic. Shows the help browser and displays the given help topic.

Definition at line 1336 of file mainwindow.cpp.

Referenced by authenticationFailed(), connectFailed(), createActions(), MainWindow(), startFailed(), stop(), and stopped().

void MainWindow::showHelpDialog ( const QString &  topic  )  [private, slot]

Called when a child window requests the given help topic.

Definition at line 1343 of file mainwindow.cpp.

References HelpBrowser::showWindow().

void MainWindow::start (  )  [private, slot]

void MainWindow::startFailed ( QString  errmsg  )  [private, slot]

Called when the Tor process fails to start.

Called when the Tor process fails to start, for example, because the path specified to the Tor executable didn't lead to an executable.

Definition at line 833 of file mainwindow.cpp.

References VMessageBox::Cancel, VMessageBox::Help, showConfigDialog(), showHelpDialog(), VMessageBox::ShowSettings, Stopped, updateTorStatus(), and VMessageBox::warning().

Referenced by MainWindow().

void MainWindow::started (  )  [private, slot]

Called when the Tor process has successfully started.

Slot: Called when the Tor process is started. It will connect the control socket and set the icons and tooltips accordingly.

Definition at line 864 of file mainwindow.cpp.

References _delayedShutdownStarted, _isIntentionalExit, _isVidaliaRunningTor, _torControl, TorControl::connect(), TorSettings::getControlAddress(), TorSettings::getControlPort(), TorControl::isVidaliaRunningTor(), setStartupProgress(), Started, STARTUP_PROGRESS_CONNECTING, and updateTorStatus().

Referenced by MainWindow(), running(), and start().

bool MainWindow::stop (  )  [private, slot]

void MainWindow::stopped ( int  exitCode,
QProcess::ExitStatus  exitStatus 
) [private, slot]

Called when the Tor process has exited, either expectedly or not.

Slot: Called when the Tor process has exited. It will adjust the tray icons and tooltips accordingly.

Definition at line 970 of file mainwindow.cpp.

References _isIntentionalExit, _messageLog, VMessageBox::Help, VMessageBox::Ok, showHelpDialog(), VMessageBox::ShowLog, VidaliaWindow::showWindow(), Stopped, updateTorStatus(), and VMessageBox::warning().

Referenced by close(), and MainWindow().

void MainWindow::connected (  )  [private, slot]

Called when the control socket has connected to Tor.

Called when the control socket has successfully connected to Tor.

Definition at line 999 of file mainwindow.cpp.

References authenticate().

Referenced by MainWindow().

void MainWindow::connectFailed ( QString  errmsg  )  [private, slot]

Called when the control connection fails.

Called when the connection to the control socket fails. The reason will be given in the errmsg parameter.

Definition at line 886 of file mainwindow.cpp.

References _torControl, TorControl::connect(), TorSettings::getControlAddress(), TorSettings::getControlPort(), VMessageBox::Help, VMessageBox::Ok, p(), VMessageBox::Retry, showHelpDialog(), TorControl::stop(), and VMessageBox::warning().

Referenced by MainWindow().

void MainWindow::disconnect (  )  [private, slot]

Called when Vidalia wants to disconnect from a Tor it did not start.

Definition at line 1006 of file mainwindow.cpp.

References _torControl, and TorControl::disconnect().

Referenced by authenticate(), and authenticationFailed().

void MainWindow::disconnected (  )  [private, slot]

Called when the control socket has been disconnected.

Definition at line 1013 of file mainwindow.cpp.

References _isVidaliaRunningTor, _newIdentityAct, Stopped, ui, and updateTorStatus().

Referenced by MainWindow().

void MainWindow::authenticated (  )  [private, slot]

void MainWindow::authenticationFailed ( QString  errmsg  )  [private, slot]

void MainWindow::enableNewIdentity (  )  [private, slot]

Re-enables the 'New Identity' button after a delay from the previous time 'New Identity' was used.

Definition at line 1402 of file mainwindow.cpp.

References _newIdentityAct, _torControl, TorControl::isConnected(), and ui.

Referenced by newIdentity().

void MainWindow::newIdentity (  )  [private, slot]

void MainWindow::close (  )  [private, slot]

Called when the user exits Vidalia.

Called when the application is closing, by selecting "Exit" from the tray menu. If we're running a Tor server, then ask if we want to kill Tor now, or do a delayed shutdown.

Definition at line 284 of file mainwindow.cpp.

References _torControl, TorControl::isConnected(), ServerSettings::isServerEnabled(), TorControl::isVidaliaRunningTor(), shutdown(), stop(), and stopped().

Referenced by createActions().

void MainWindow::running (  )  [private, slot]

Called when the application has started and the main event loop is running.

Definition at line 234 of file mainwindow.cpp.

References _torControl, TorControl::isRunning(), VidaliaSettings::runProxyAtStart(), VidaliaSettings::runTorAtStart(), start(), started(), Starting, startProxy(), and updateTorStatus().

Referenced by MainWindow().

void MainWindow::shutdown (  )  [private, slot]

Terminate the Tor process if it is being run under Vidalia, disconnect all TorControl signals, and exit Vidalia.

Terminate the Tor process if it is being run under Vidalia, disconnect all TorControl signals, and exit Vidalia.

Definition at line 256 of file mainwindow.cpp.

References _proxyProcess, _torControl, ServerSettings::cleanupPortForwarding(), TorControl::isVidaliaRunningTor(), and TorControl::stop().

Referenced by close(), MainWindow(), and onSubprocessFinished().

void MainWindow::showAboutDialog (  )  [private, slot]

Creates and displays Vidalia's About dialog.

Definition at line 1325 of file mainwindow.cpp.

References AboutDialog::showWindow().

Referenced by createActions().

void MainWindow::showConfigDialog ( ConfigDialog::Page  page = ConfigDialog::General  )  [private, slot]

Creates and displays the Configuration dialog with the current page set to page.

Creates and displays the Configuration dialog with the current page set to page.

Definition at line 1354 of file mainwindow.cpp.

References _configDialog, and ConfigDialog::showWindow().

Referenced by authenticationFailed(), createActions(), showServerConfigDialog(), and startFailed().

void MainWindow::showServerConfigDialog (  )  [private, slot]

Displays the Configuration dialog, set to the Server page.

Definition at line 1361 of file mainwindow.cpp.

References ConfigDialog::Server, and showConfigDialog().

void MainWindow::toggleShowOnStartup ( bool  checked  )  [private, slot]

Called when the "show on startup" checkbox is toggled.

Definition at line 716 of file mainwindow.cpp.

References VidaliaSettings::setShowMainWindowAtStart().

void MainWindow::onSubprocessFinished ( int  exitCode,
QProcess::ExitStatus  exitStatus 
) [private, slot]

Called when the web browser or IM client have stopped

Called when browser or IM client have exited

Definition at line 473 of file mainwindow.cpp.

References _browserProcess, _imProcess, VidaliaSettings::getBrowserExecutable(), VidaliaSettings::getIMExecutable(), HelperProcess::isDone(), and shutdown().

Referenced by MainWindow().

void MainWindow::onBrowserFailed ( QString  errmsg  )  [private, slot]

Called web the web browser failed to start

Called when the web browser failed to start, for example, because the path specified to the web browser executable didn't lead to an executable.

Definition at line 495 of file mainwindow.cpp.

References VMessageBox::Ok, and VMessageBox::warning().

Referenced by MainWindow().

void MainWindow::onIMFailed ( QString  errmsg  )  [private, slot]

Called web the IM client failed to start

Called when the IM client failed to start, for example, because the path specified to the IM client executable didn't lead to an executable.

Definition at line 508 of file mainwindow.cpp.

References VMessageBox::Ok, and VMessageBox::warning().

Referenced by MainWindow().

void MainWindow::onProxyFailed ( QString  errmsg  )  [private, slot]

Called when the proxy server fails to start

Called when the proxy server fails to start, for example, because the path specified didn't lead to an executable.

Definition at line 530 of file mainwindow.cpp.

References VMessageBox::Ok, and VMessageBox::warning().

Referenced by MainWindow().

void MainWindow::createActions (  )  [private]

void MainWindow::createTrayIcon (  )  [private]

Creates a tray icon with a context menu and adds it to the system notification area. On Mac, we also set up an application menubar.

Definition at line 368 of file mainwindow.cpp.

References _trayIcon, createMenuBar(), createTrayMenu(), and TrayIcon::setContextMenu().

Referenced by MainWindow().

QMenu * MainWindow::createTrayMenu (  )  [private]

Create the tray popup menu and it's submenus

Creates a QMenu object that contains QActions which compose the system tray menu.

Definition at line 380 of file mainwindow.cpp.

References _aboutAct, _bandwidthAct, _configAct, _controlPanelAct, _exitAct, _helpAct, _messageAct, _networkAct, _newIdentityAct, and _startStopAct.

Referenced by createTrayIcon().

void MainWindow::createMenuBar (  )  [private]

Creates a default menubar on Mac

Creates a new menubar with no parent, so Qt will use this as the "default menubar" on Mac. This adds on to the existing actions from the createMens() method.

Definition at line 408 of file mainwindow.cpp.

References _aboutAct, _bandwidthAct, _configAct, _controlPanelAct, _exitAct, _helpAct, _messageAct, _networkAct, _newIdentityAct, and _startStopAct.

Referenced by createTrayIcon().

MainWindow::TorStatus MainWindow::updateTorStatus ( TorStatus  status  )  [private]

void MainWindow::startSubprocesses (  )  [private]

Starts the web browser, if appropriately configured

Starts the web browser and IM client, if appropriately configured

Definition at line 456 of file mainwindow.cpp.

References _browserProcess, _imProcess, VidaliaSettings::getBrowserExecutable(), VidaliaSettings::getIMExecutable(), and HelperProcess::start().

Referenced by circuitEstablished().

void MainWindow::startProxy (  )  [private]

Starts the proxy server, if appropriately configured

Definition at line 520 of file mainwindow.cpp.

References _proxyProcess, VidaliaSettings::getProxyExecutable(), VidaliaSettings::getProxyExecutableArguments(), and HelperProcess::start().

Referenced by running().

QString MainWindow::toString ( TorStatus  status  )  [private]

Converts a TorStatus enum value to a string for debug logging purposes.

Definition at line 1412 of file mainwindow.cpp.

References Authenticated, Authenticating, CircuitEstablished, Started, Starting, Stopped, Stopping, and Unset.

Referenced by updateTorStatus().

bool MainWindow::authenticate (  )  [private]

QByteArray MainWindow::loadControlCookie ( QString  cookiePath = QString()  )  [private]

Searches for and attempts to load the control authentication cookie. This assumes the cookie is named 'control_auth_cookie'. If cookiePath is empty, this method will search some default locations depending on the current platform. cookiePath can point to either a cookie file or a directory containing the cookie file.

Searches for and attempts to load the control authentication cookie. This assumes the cookie is named 'control_auth_cookie'. If cookiePath is empty, this method will search some default locations depending on the current platform. cookiePath can point to either a cookie file or a directory containing the cookie file.

Definition at line 1233 of file mainwindow.cpp.

References expand_filename(), TorSettings::getDataDirectory(), vDebug, vInfo, and vWarn.

Referenced by authenticate().

void MainWindow::circuitEstablished (  )  [private]

Called when Tor has successfully established a circuit.

Definition at line 1277 of file mainwindow.cpp.

References CircuitEstablished, setStartupProgress(), startSubprocesses(), ui, and updateTorStatus().

Referenced by authenticated(), and customEvent().

void MainWindow::checkTorVersion (  )  [private]

Checks the status of the current version of Tor to see if it's old, unrecommended, or obsolete.

Definition at line 1288 of file mainwindow.cpp.

References _torControl, dangerousTorVersion(), and TorControl::getInfo().

Referenced by authenticated().

void MainWindow::dangerousTorVersion (  )  [private]

Called when Tor thinks its version is old or unrecommended, and displays a message notifying the user.

Called when Tor thinks its version is old or unrecommended, and displays a message notifying the user.

Definition at line 1303 of file mainwindow.cpp.

References VMessageBox::information(), VMessageBox::Ok, and p().

Referenced by checkTorVersion(), and customEvent().

void MainWindow::bootstrapStatusChanged ( const BootstrapStatus bs  )  [private]

void MainWindow::setStartupProgressVisible ( bool  visible  )  [private]

Sets the visibility of the startup status description and progress bar to visible.

Sets the visibility of the startup status description and progress bar to visible.

Definition at line 725 of file mainwindow.cpp.

References ui.

Referenced by updateTorStatus().

void MainWindow::setStartupProgress ( int  progressValue,
const QString &  description 
) [private]

Sets the progress bar completion value to progressValue and sets the status text to description.

Definition at line 747 of file mainwindow.cpp.

References _trayIcon, TrayIcon::setToolTip(), and ui.

Referenced by authenticate(), authenticated(), bootstrapStatusChanged(), circuitEstablished(), started(), and updateTorStatus().


Member Data Documentation

The current status of Tor.

Definition at line 175 of file mainwindow.h.

Referenced by MainWindow(), and updateTorStatus().

Used to determine if the Tor process exiting was intentional or not

Definition at line 177 of file mainwindow.h.

Referenced by start(), started(), stop(), and stopped().

Tracks whether we started a delayed server shutdown.

Definition at line 179 of file mainwindow.h.

Referenced by started(), stop(), and updateTorStatus().

Set to true if Vidalia started its own Tor process.

Definition at line 181 of file mainwindow.h.

Referenced by authenticate(), authenticationFailed(), disconnected(), and started().

A MessageLog object which handles logging Tor messages

Definition at line 183 of file mainwindow.h.

Referenced by createActions(), MainWindow(), stopped(), and ~MainWindow().

A BandwidthGraph object which handles monitoring Tor bandwidth usage

Definition at line 185 of file mainwindow.h.

Referenced by createActions(), MainWindow(), and ~MainWindow().

A NetViewer object which displays the Tor network graphically

Definition at line 187 of file mainwindow.h.

Referenced by createActions(), MainWindow(), and ~MainWindow().

A ConfigDialog object which lets the user configure Tor and Vidalia

Definition at line 189 of file mainwindow.h.

Referenced by MainWindow(), showConfigDialog(), and ~MainWindow().

A HelperProcess object that manages the web browser

Definition at line 193 of file mainwindow.h.

Referenced by MainWindow(), onSubprocessFinished(), and startSubprocesses().

A HelperProcess object that manages the IM client

Definition at line 195 of file mainwindow.h.

Referenced by MainWindow(), onSubprocessFinished(), and startSubprocesses().

A HelperProcess object that manages the proxy server

Definition at line 197 of file mainwindow.h.

Referenced by MainWindow(), shutdown(), and startProxy().

QString MainWindow::_controlPassword [private]

Remembers the control password between when we start Tor with a hash of the password and when we need to provide the password itself.

Definition at line 200 of file mainwindow.h.

Referenced by authenticate(), authenticationFailed(), and start().

Set to true if we should use the control password saved in TorSettings when authenticating to Tor.

Definition at line 203 of file mainwindow.h.

Referenced by authenticate(), authenticationFailed(), and start().

The Vidalia icon that sits in the tray.

Definition at line 205 of file mainwindow.h.

Referenced by createTrayIcon(), MainWindow(), newIdentity(), setStartupProgress(), updateTorStatus(), and ~MainWindow().

QAction* MainWindow::_controlPanelAct [private]

Defines the actions for the tray menu

Definition at line 208 of file mainwindow.h.

Referenced by createActions(), createMenuBar(), and createTrayMenu().

QAction* MainWindow::_startStopAct [private]

Definition at line 209 of file mainwindow.h.

Referenced by createActions(), createMenuBar(), createTrayMenu(), and updateTorStatus().

QAction* MainWindow::_configAct [private]

Definition at line 210 of file mainwindow.h.

Referenced by createActions(), createMenuBar(), and createTrayMenu().

QAction* MainWindow::_aboutAct [private]

Definition at line 211 of file mainwindow.h.

Referenced by createActions(), createMenuBar(), and createTrayMenu().

QAction* MainWindow::_exitAct [private]

Definition at line 212 of file mainwindow.h.

Referenced by createActions(), createMenuBar(), and createTrayMenu().

QAction* MainWindow::_bandwidthAct [private]

Definition at line 213 of file mainwindow.h.

Referenced by createActions(), createMenuBar(), and createTrayMenu().

QAction* MainWindow::_messageAct [private]

Definition at line 214 of file mainwindow.h.

Referenced by createActions(), createMenuBar(), and createTrayMenu().

QAction* MainWindow::_helpAct [private]

Definition at line 215 of file mainwindow.h.

Referenced by createActions(), createMenuBar(), and createTrayMenu().

QAction* MainWindow::_networkAct [private]

Definition at line 216 of file mainwindow.h.

Referenced by createActions(), createMenuBar(), and createTrayMenu().

QAction* MainWindow::_newIdentityAct [private]

Ui::MainWindow MainWindow::ui [private]


The documentation for this class was generated from the following files:

Generated on Wed Nov 26 21:02:39 2008 for Vidalia by  doxygen 1.5.6