MainWindow Class Reference

#include <mainwindow.h>

Inheritance diagram for MainWindow:

VidaliaWindow

List of all members.

Public Member Functions

 MainWindow ()
 ~MainWindow ()

Private Types

enum  TorStatus {
  Unset, Stopping, Stopped, Starting,
  Started, Connecting, Connected, Disconnecting,
  Disconnected, Authenticating, Authenticated
}

Private Slots

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 shutdown ()
void showAboutDialog ()
void showConfigDialog (ConfigDialog::Page page=ConfigDialog::General)
void showServerConfigDialog ()
void toggleShowOnStartup (bool checked)

Private Member Functions

void createActions ()
void createTrayIcon ()
QMenu * createTrayMenu ()
void createMenuBar ()
bool isTrayIconSupported ()
TorStatus updateTorStatus (TorStatus status)
QString toString (TorStatus status)
bool authenticate ()
QByteArray loadControlCookie (QString cookiePath=QString())

Private Attributes

TorStatus _status
bool _isIntentionalExit
bool _delayedShutdownStarted
bool _isVidaliaRunningTor
MessageLog_messageLog
BandwidthGraph_bandwidthGraph
NetViewer_netViewer
TorControl_torControl
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 55 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.
Connecting  Vidalia is connecting to Tor.
Connected  Vidalia is connected to Tor.
Disconnecting  Vidalia is disconnecting from Tor.
Disconnected  Vidalia is disconnected from Tor.
Authenticating  Vidalia is authenticating to Tor.
Authenticated  Vidalia has authenticated to Tor.

Definition at line 115 of file mainwindow.h.


Constructor & Destructor Documentation

MainWindow::MainWindow (  ) 

Default constructor

Default constructor. It installs an icon in the system tray area and creates the popup menu associated with that icon.

Definition at line 109 of file mainwindow.cpp.

References _bandwidthGraph, _messageLog, _netViewer, _status, _torControl, _trayIcon, authenticated(), authenticationFailed(), connected(), connectFailed(), createActions(), createTrayIcon(), disconnected(), TorControl::isRunning(), isTrayIconSupported(), VidaliaSettings::runTorAtStart(), TrayIcon::show(), VidaliaSettings::showMainWindowAtStart(), shutdown(), start(), started(), startFailed(), Starting, stopped(), Stopped, Vidalia::torControl(), ui, Unset, updateTorStatus(), and vApp.

MainWindow::~MainWindow (  ) 

Destructor.

Definition at line 177 of file mainwindow.cpp.

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


Member Function Documentation

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

Called when the user selects "Start" from the menu.

Attempts to start Tor. If Tor fails to start, then startFailed() will be called with an error message containing the reason.

Definition at line 499 of file mainwindow.cpp.

References _isIntentionalExit, _torControl, TorControl::start(), Starting, and updateTorStatus().

Referenced by authenticationFailed(), createActions(), MainWindow(), and updateTorStatus().

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 514 of file mainwindow.cpp.

References VMessageBox::Cancel, Vidalia::help(), VMessageBox::Help, showConfigDialog(), 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 545 of file mainwindow.cpp.

References _delayedShutdownStarted, _isIntentionalExit, _isVidaliaRunningTor, _torControl, TorControl::connect(), TorControl::isVidaliaRunningTor(), Started, and updateTorStatus().

Referenced by MainWindow().

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

Called when the user selects "Stop" form the menu.

Disconnects the control socket and stops the Tor process.

Definition at line 588 of file mainwindow.cpp.

References _delayedShutdownStarted, _isIntentionalExit, _torControl, VMessageBox::Cancel, Vidalia::help(), VMessageBox::Help, ServerSettings::isServerEnabled(), VMessageBox::No, VMessageBox::Ok, p(), VMessageBox::question(), TorSignal::Shutdown, TorControl::signal(), TorControl::stop(), Stopping, updateTorStatus(), VMessageBox::warning(), and VMessageBox::Yes.

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

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 646 of file mainwindow.cpp.

References _isIntentionalExit, _messageLog, Vidalia::help(), VMessageBox::Help, VMessageBox::Ok, 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 674 of file mainwindow.cpp.

References authenticate(), Connected, and updateTorStatus().

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 563 of file mainwindow.cpp.

References _torControl, TorControl::connect(), Disconnected, Vidalia::help(), VMessageBox::Help, VMessageBox::Ok, p(), VMessageBox::Retry, TorControl::stop(), updateTorStatus(), 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 682 of file mainwindow.cpp.

References _torControl, TorControl::disconnect(), Disconnecting, and updateTorStatus().

Referenced by authenticate(), and authenticationFailed().

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

Called when the control socket has been disconnected.

Definition at line 690 of file mainwindow.cpp.

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

Referenced by MainWindow().

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

Called when Vidalia has successfully authenticated to Tor.

Definition at line 778 of file mainwindow.cpp.

References _messageLog, _newIdentityAct, _torControl, ServerSettings::apply(), Authenticated, ServerSettings::changedSinceLastApply(), VMessageBox::Ok, p(), ConfigDialog::Server, TorControl::setEvents(), showConfigDialog(), VMessageBox::ShowLog, VMessageBox::ShowSettings, VidaliaWindow::showWindow(), ui, updateTorStatus(), and VMessageBox::warning().

Referenced by MainWindow().

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

Called when Vidalia fails to authenticate to Tor. The failure reason is specified in errmsg.

Definition at line 823 of file mainwindow.cpp.

References _isVidaliaRunningTor, _torControl, ConfigDialog::Advanced, VMessageBox::Cancel, disconnect(), TorControl::isConnected(), TorControl::isRunning(), p(), TorSettings::PasswordAuth, TorSettings::setAuthenticationMethod(), TorSettings::setControlPassword(), showConfigDialog(), VMessageBox::ShowSettings, start(), stop(), vWarn, and VMessageBox::warning().

Referenced by MainWindow().

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 990 of file mainwindow.cpp.

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

Referenced by newIdentity().

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

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

Definition at line 943 of file mainwindow.cpp.

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

Referenced by createActions().

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 223 of file mainwindow.cpp.

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

Referenced by createActions().

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 205 of file mainwindow.cpp.

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

Referenced by close(), and MainWindow().

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

Creates and displays Vidalia's About dialog.

Definition at line 915 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 926 of file mainwindow.cpp.

References ConfigDialog::showWindow().

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

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

Displays the Configuration dialog, set to the Server page.

Definition at line 936 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 490 of file mainwindow.cpp.

References VidaliaSettings::setShowMainWindowAtStart().

void MainWindow::createActions (  )  [private]

Create the actions on the tray menu or menubar

Create and bind actions to events. Setup for initial tray menu configuration.

Definition at line 244 of file mainwindow.cpp.

References _aboutAct, _bandwidthAct, _bandwidthGraph, _configAct, _controlPanelAct, _exitAct, _helpAct, _messageAct, _messageLog, _netViewer, _networkAct, _newIdentityAct, _startStopAct, close(), IMG_ABOUT, IMG_BWGRAPH, IMG_CONFIG, IMG_CONTROL_PANEL, IMG_EXIT, IMG_HELP, IMG_IDENTITY, IMG_MESSAGELOG, IMG_NETWORK, IMG_START_TOR_16, newIdentity(), showAboutDialog(), showConfigDialog(), VidaliaWindow::showWindow(), start(), ui, and vApp.

Referenced by MainWindow().

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 292 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 310 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 338 of file mainwindow.cpp.

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

Referenced by createTrayIcon().

bool MainWindow::isTrayIconSupported (  )  [private]

Returns true if we're running on a platform with tray icon support.

Definition at line 187 of file mainwindow.cpp.

Referenced by MainWindow().

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

Updates the UI to reflect Tor's current status. Returns the previously set TorStatus value.

Updates the UI to reflect Tor's current status. Returns the previously set TorStatus value.

Definition at line 389 of file mainwindow.cpp.

References _delayedShutdownStarted, _startStopAct, _status, _trayIcon, ANIM_PROCESS_WORKING, Authenticated, IMG_START_TOR_16, IMG_START_TOR_48, IMG_STOP_TOR_16, IMG_STOP_TOR_48, IMG_TOR_RUNNING_48, IMG_TOR_STARTING_48, IMG_TOR_STOPPED_48, IMG_TOR_STOPPING_48, TrayIcon::setIcon(), TrayIcon::setToolTip(), start(), Started, Starting, stop(), Stopped, Stopping, toString(), ui, and vNotice.

Referenced by authenticate(), authenticated(), connected(), connectFailed(), disconnect(), disconnected(), MainWindow(), start(), started(), startFailed(), stop(), and stopped().

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

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

Definition at line 1000 of file mainwindow.cpp.

References Authenticated, Authenticating, Connected, Connecting, Disconnected, Disconnecting, Started, Starting, Stopped, Stopping, and Unset.

Referenced by updateTorStatus().

bool MainWindow::authenticate (  )  [private]

Authenticates Vidalia to Tor's control port.

Attempts to authenticate to Tor's control port, depending on the authentication method specified in TorSettings::getAuthenticationMethod().

Definition at line 709 of file mainwindow.cpp.

References _isVidaliaRunningTor, _torControl, TorControl::authenticate(), Authenticating, ProtocolInfo::authMethods(), VMessageBox::Browse, VMessageBox::Cancel, TorSettings::CookieAuth, ProtocolInfo::cookieAuthFile(), disconnect(), TorSettings::getAuthenticationMethod(), TorSettings::getControlPassword(), TorSettings::getDataDirectory(), ProtocolInfo::isEmpty(), loadControlCookie(), TorSettings::NullAuth, p(), TorSettings::PasswordAuth, TorControl::protocolInfo(), VMessageBox::question(), stop(), updateTorStatus(), vNotice, and vWarn.

Referenced by connected().

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 871 of file mainwindow.cpp.

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

Referenced by authenticate().


Member Data Documentation

TorStatus MainWindow::_status [private]

The current status of Tor.

Definition at line 154 of file mainwindow.h.

Referenced by MainWindow(), and updateTorStatus().

bool MainWindow::_isIntentionalExit [private]

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

Definition at line 156 of file mainwindow.h.

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

bool MainWindow::_delayedShutdownStarted [private]

Tracks whether we started a delayed server shutdown.

Definition at line 158 of file mainwindow.h.

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

bool MainWindow::_isVidaliaRunningTor [private]

Set to true if Vidalia started its own Tor process.

Definition at line 160 of file mainwindow.h.

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

MessageLog* MainWindow::_messageLog [private]

A MessageLog object which handles logging Tor messages

Definition at line 162 of file mainwindow.h.

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

BandwidthGraph* MainWindow::_bandwidthGraph [private]

A BandwidthGraph object which handles monitoring Tor bandwidth usage

Definition at line 164 of file mainwindow.h.

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

NetViewer* MainWindow::_netViewer [private]

A NetViewer object which displays the Tor network graphically

Definition at line 166 of file mainwindow.h.

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

TorControl* MainWindow::_torControl [private]

A TorControl object that handles communication with Tor

Definition at line 168 of file mainwindow.h.

Referenced by authenticate(), authenticated(), authenticationFailed(), close(), connectFailed(), disconnect(), enableNewIdentity(), MainWindow(), newIdentity(), shutdown(), start(), started(), and stop().

TrayIcon MainWindow::_trayIcon [private]

The Vidalia icon that sits in the tray. (pre-Qt 4.2)

Definition at line 174 of file mainwindow.h.

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

QAction* MainWindow::_controlPanelAct [private]

Defines the actions for the tray menu

Definition at line 178 of file mainwindow.h.

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

QAction* MainWindow::_startStopAct [private]

Definition at line 179 of file mainwindow.h.

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

QAction* MainWindow::_configAct [private]

Definition at line 180 of file mainwindow.h.

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

QAction* MainWindow::_aboutAct [private]

Definition at line 181 of file mainwindow.h.

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

QAction* MainWindow::_exitAct [private]

Definition at line 182 of file mainwindow.h.

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

QAction* MainWindow::_bandwidthAct [private]

Definition at line 183 of file mainwindow.h.

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

QAction* MainWindow::_messageAct [private]

Definition at line 184 of file mainwindow.h.

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

QAction* MainWindow::_helpAct [private]

Definition at line 185 of file mainwindow.h.

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

QAction* MainWindow::_networkAct [private]

Definition at line 186 of file mainwindow.h.

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

QAction* MainWindow::_newIdentityAct [private]

Definition at line 187 of file mainwindow.h.

Referenced by authenticated(), createActions(), createMenuBar(), createTrayMenu(), disconnected(), enableNewIdentity(), and newIdentity().

Ui::MainWindow MainWindow::ui [private]

Qt Designer generated object.

Definition at line 189 of file mainwindow.h.

Referenced by authenticated(), createActions(), disconnected(), enableNewIdentity(), MainWindow(), newIdentity(), and updateTorStatus().


The documentation for this class was generated from the following files:
Generated on Wed Sep 5 15:49:29 2007 for Vidalia by  doxygen 1.5.3