Vidalia  0.2.15
Public Slots | Public Member Functions | Protected Member Functions | Private Types | Private Slots | Private Member Functions | Private Attributes
MainWindow Class Reference

#include <MainWindow.h>

Inheritance diagram for MainWindow:
VidaliaWindow

List of all members.

Public Slots

virtual void setVisible (bool visible)

Public Member Functions

 MainWindow ()
 ~MainWindow ()

Protected Member Functions

virtual void retranslateUi ()

Private Types

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

Private Slots

void trayIconActivated (QSystemTrayIcon::ActivationReason reason)
void showHelpDialog ()
void showHelpDialog (const QString &topic)
void start ()
void restart ()
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 aboutToQuit ()
void showAboutDialog ()
void showConfigDialog (ConfigDialog::Page page=ConfigDialog::General)
void showServerConfigDialog ()
void toggleShowOnStartup (bool checked)
void onSubprocessFinished (int exitCode, QProcess::ExitStatus exitStatus)
void onCheckForBrowser ()
void onBrowserFailed (QString errmsg)
void onIMFailed (QString errmsg)
void onProxyFailed (QString errmsg)
void circuitEstablished ()
void warnDangerousPort (quint16 port, bool rejected)
void bootstrapStatusChanged (const BootstrapStatus &bs)
void dangerousTorVersion (tc::TorVersionStatus reason, const QString &version, const QStringList &recommended)

Private Member Functions

void createActions ()
void createTrayIcon ()
QMenu * createTrayMenu ()
void createMenuBar ()
void setTrayIcon (const QString &iconFile)
TorStatus updateTorStatus (TorStatus status)
void launchBrowserFromDirectory ()
void startSubprocesses ()
void startProxy ()
QString toString (TorStatus status)
bool authenticate ()
QByteArray loadControlCookie (QString cookiePath=QString())
void checkTorVersion ()
void displayTorVersionWarning ()
void setStartupProgressVisible (bool visible)
void setStartupProgress (int percentComplete, const QString &description)
QStringList updateBrowserEnv ()

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
QSystemTrayIcon _trayIcon
QMenuBar * _menuBar
QAction * _actionShowControlPanel
QAction * _actionStartStopTor
QAction * _actionShowConfig
QAction * _actionShowAbout
QAction * _actionExit
QAction * _actionShowBandwidth
QAction * _actionShowMessageLog
QAction * _actionShowHelp
QAction * _actionShowNetworkMap
QAction * _actionNewIdentity
quint16 _autoControlPort
Ui::MainWindow ui

Detailed Description

Definition at line 45 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 175 of file MainWindow.h.


Constructor & Destructor Documentation

MainWindow::MainWindow ( )
MainWindow::~MainWindow ( )

Destructor.

Definition at line 235 of file MainWindow.cpp.

References _bandwidthGraph, _configDialog, _messageLog, _netViewer, and _trayIcon.


Member Function Documentation

void MainWindow::aboutToQuit ( ) [private, slot]
bool MainWindow::authenticate ( ) [private]
void MainWindow::authenticated ( ) [private, slot]
void MainWindow::authenticationFailed ( QString  errmsg) [private, slot]
void MainWindow::bootstrapStatusChanged ( const BootstrapStatus bs) [private, slot]
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 1649 of file MainWindow.cpp.

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

Referenced by authenticated().

void MainWindow::circuitEstablished ( ) [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 403 of file MainWindow.cpp.

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

Referenced by createActions().

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 1344 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 1231 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(), and started().

void MainWindow::createActions ( ) [private]
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 533 of file MainWindow.cpp.

References _actionExit, _actionNewIdentity, _actionShowAbout, _actionShowBandwidth, _actionShowConfig, _actionShowControlPanel, _actionShowHelp, _actionShowMessageLog, _actionShowNetworkMap, _actionStartStopTor, and _menuBar.

Referenced by createTrayIcon(), and retranslateUi().

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 486 of file MainWindow.cpp.

References _trayIcon, createMenuBar(), createTrayMenu(), and trayIconActivated().

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 505 of file MainWindow.cpp.

References _actionExit, _actionNewIdentity, _actionShowAbout, _actionShowBandwidth, _actionShowConfig, _actionShowControlPanel, _actionShowHelp, _actionShowMessageLog, _actionShowNetworkMap, and _actionStartStopTor.

Referenced by createTrayIcon().

void MainWindow::dangerousTorVersion ( tc::TorVersionStatus  reason,
const QString &  current,
const QStringList &  recommended 
) [private, slot]

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

Definition at line 1664 of file MainWindow.cpp.

References displayTorVersionWarning(), tc::ObsoleteTorVersion, and tc::UnrecommendedTorVersion.

Referenced by MainWindow().

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

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

Definition at line 1351 of file MainWindow.cpp.

References _torControl, and TorControl::disconnect().

Referenced by aboutToQuit(), authenticate(), authenticationFailed(), close(), and updateTorStatus().

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

Called when the control socket has been disconnected.

Definition at line 1358 of file MainWindow.cpp.

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

Referenced by MainWindow().

void MainWindow::displayTorVersionWarning ( ) [private]

Alerts the user that their current Tor version is either obsolete or no longer recommended. If Vidalia was built with auto-update support, they will be given the option to check for available updates.

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

Definition at line 1679 of file MainWindow.cpp.

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

Referenced by checkTorVersion(), and dangerousTorVersion().

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 1878 of file MainWindow.cpp.

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

Referenced by newIdentity().

void MainWindow::launchBrowserFromDirectory ( ) [private]

Start a web browser when given the directory containing the executable and profile

Definition at line 611 of file MainWindow.cpp.

References _browserProcess, copy_dir(), VidaliaSettings::getBrowserDirectory(), VidaliaSettings::getBrowserExecutable(), HelperProcess::start(), HelperProcess::toForeground(), and updateBrowserEnv().

Referenced by startSubprocesses().

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.

Definition at line 1582 of file MainWindow.cpp.

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

Referenced by authenticate().

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

Called when the user selects the "New Identity" action from the menu.

Definition at line 1844 of file MainWindow.cpp.

References _actionNewIdentity, _torControl, _trayIcon, enableNewIdentity(), VMessageBox::information(), MIN_NEWIDENTITY_INTERVAL, TorSignal::NewNym, VMessageBox::Ok, TorControl::signal(), ui, and VMessageBox::warning().

Referenced by createActions().

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 750 of file MainWindow.cpp.

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

Referenced by MainWindow().

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

Called periodically to check if the browser is running. If it is not, exit Vidalia cleanly

Definition at line 715 of file MainWindow.cpp.

References VidaliaSettings::getBrowserExecutable(), i(), vApp, and win32_process_list().

Referenced by onSubprocessFinished().

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 763 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 785 of file MainWindow.cpp.

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

Referenced by MainWindow().

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 681 of file MainWindow.cpp.

References _browserProcess, _imProcess, VidaliaSettings::getBrowserDirectory(), VidaliaSettings::getBrowserExecutable(), VidaliaSettings::getIMExecutable(), HelperProcess::isDone(), onCheckForBrowser(), and vApp.

Referenced by MainWindow().

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

Called when the user changes a setting that needs Tor restarting

Definition at line 1117 of file MainWindow.cpp.

References _torControl, start(), and TorControl::stop().

Referenced by MainWindow().

void MainWindow::retranslateUi ( ) [protected, virtual]
void MainWindow::running ( ) [private, slot]
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 1002 of file MainWindow.cpp.

References _trayIcon, and ui.

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

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

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

Definition at line 980 of file MainWindow.cpp.

References ui.

Referenced by updateTorStatus().

void MainWindow::setTrayIcon ( const QString &  iconFile) [private]

Sets the current tray or dock icon image to iconFile.

Definition at line 586 of file MainWindow.cpp.

References _trayIcon, VidaliaSettings::Dock, and VidaliaSettings::getIconPref().

Referenced by updateTorStatus().

void MainWindow::setVisible ( bool  visible) [virtual, slot]

Shows or hides this window.

Reimplemented from VidaliaWindow.

Definition at line 245 of file MainWindow.cpp.

References ui.

Referenced by MainWindow(), and trayIconActivated().

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

Creates and displays Vidalia's About dialog.

Definition at line 1803 of file MainWindow.cpp.

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.

Definition at line 1830 of file MainWindow.cpp.

References _configDialog, and ConfigDialog::showWindow().

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

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 1812 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 1819 of file MainWindow.cpp.

References HelpBrowser::showWindow().

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

Displays the Configuration dialog, set to the Server page.

Definition at line 1837 of file MainWindow.cpp.

References ConfigDialog::Server, and showConfigDialog().

void MainWindow::start ( ) [private, slot]
void MainWindow::started ( ) [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 1127 of file MainWindow.cpp.

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

Referenced by MainWindow().

void MainWindow::startProxy ( ) [private]

Starts the proxy server, if appropriately configured

Definition at line 775 of file MainWindow.cpp.

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

Referenced by running().

void MainWindow::startSubprocesses ( ) [private]

Starts the web browser, if appropriately configured

Starts the web browser and IM client, if appropriately configured

Definition at line 656 of file MainWindow.cpp.

References _browserProcess, _imProcess, VidaliaSettings::getBrowserDirectory(), VidaliaSettings::getBrowserExecutable(), VidaliaSettings::getIMExecutable(), launchBrowserFromDirectory(), HelperProcess::start(), HelperProcess::toForeground(), and updateBrowserEnv().

Referenced by circuitEstablished().

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 1315 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::toggleShowOnStartup ( bool  checked) [private, slot]

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

Definition at line 971 of file MainWindow.cpp.

References VidaliaSettings::setShowMainWindowAtStart().

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

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

Definition at line 1888 of file MainWindow.cpp.

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

Referenced by updateTorStatus().

void MainWindow::trayIconActivated ( QSystemTrayIcon::ActivationReason  reason) [private, slot]

Respond to a double-click on the tray icon by opening the Control Panel window.

Definition at line 603 of file MainWindow.cpp.

References setVisible().

Referenced by createTrayIcon().

QStringList MainWindow::updateBrowserEnv ( ) [private]
MainWindow::TorStatus MainWindow::updateTorStatus ( TorStatus  status) [private]
void MainWindow::warnDangerousPort ( quint16  port,
bool  rejected 
) [private, slot]

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 port.

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 port. 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.

Definition at line 1720 of file MainWindow.cpp.

References TorSettings::getRejectPlaintextPorts(), TorSettings::getWarnPlaintextPorts(), p(), TorControl::setConf(), TorSettings::setRejectPlaintextPorts(), TorSettings::setWarnPlaintextPorts(), and Vidalia::torControl().

Referenced by MainWindow().


Member Data Documentation

QAction* MainWindow::_actionExit [private]

Definition at line 284 of file MainWindow.h.

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

QAction* MainWindow::_actionNewIdentity [private]
QAction* MainWindow::_actionShowAbout [private]

Definition at line 283 of file MainWindow.h.

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

Definition at line 285 of file MainWindow.h.

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

QAction* MainWindow::_actionShowConfig [private]

Definition at line 282 of file MainWindow.h.

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

Defines the actions for the tray menu

Definition at line 280 of file MainWindow.h.

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

QAction* MainWindow::_actionShowHelp [private]

Definition at line 287 of file MainWindow.h.

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

Definition at line 286 of file MainWindow.h.

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

Definition at line 288 of file MainWindow.h.

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

QAction* MainWindow::_actionStartStopTor [private]
quint16 MainWindow::_autoControlPort [private]

Definition at line 291 of file MainWindow.h.

Referenced by started(), and updateBrowserEnv().

A BandwidthGraph object which handles monitoring Tor bandwidth usage

Definition at line 243 of file MainWindow.h.

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

A HelperProcess object that manages the web browser

Definition at line 251 of file MainWindow.h.

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

A ConfigDialog object which lets the user configure Tor and Vidalia

Definition at line 247 of file MainWindow.h.

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

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 258 of file MainWindow.h.

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

Tracks whether we started a delayed server shutdown.

Definition at line 237 of file MainWindow.h.

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

A HelperProcess object that manages the IM client

Definition at line 253 of file MainWindow.h.

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

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

Definition at line 235 of file MainWindow.h.

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

Set to true if Vidalia started its own Tor process.

Definition at line 239 of file MainWindow.h.

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

QMenuBar* MainWindow::_menuBar [private]

The menubar (Mac OS X only).

Definition at line 277 of file MainWindow.h.

Referenced by createMenuBar(), and MainWindow().

A MessageLog object which handles logging Tor messages

Definition at line 241 of file MainWindow.h.

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

A NetViewer object which displays the Tor network graphically

Definition at line 245 of file MainWindow.h.

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

A HelperProcess object that manages the proxy server

Definition at line 255 of file MainWindow.h.

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

The current status of Tor.

Definition at line 233 of file MainWindow.h.

Referenced by MainWindow(), retranslateUi(), and updateTorStatus().

QSystemTrayIcon MainWindow::_trayIcon [private]

The Vidalia icon that sits in the tray.

Definition at line 263 of file MainWindow.h.

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

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

Definition at line 261 of file MainWindow.h.

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

Ui::MainWindow MainWindow::ui [private]

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