Vidalia
0.3.1
Main Page
Namespaces
Classes
Files
File List
File Members
src
vidalia
MainWindow.h
Go to the documentation of this file.
1
/*
2
** This file is part of Vidalia, and is subject to the license terms in the
3
** LICENSE file, found in the top level directory of this distribution. If you
4
** did not receive the LICENSE file with this file, you may obtain it from the
5
** Vidalia source package distributed by the Vidalia Project at
6
** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7
** including this file, may be copied, modified, propagated, or distributed
8
** except according to the terms described in the LICENSE file.
9
*/
10
11
/*
12
** \file MainWindow.h
13
** \brief Main window. Creates tray menu and child windows
14
*/
15
16
#ifndef _MAINWINDOW_H
17
#define _MAINWINDOW_H
18
19
#include "
config.h
"
20
#include "ui_MainWindow.h"
21
22
#include "
VidaliaWindow.h
"
23
#include "
StatusTab.h
"
24
#include "
ConfigDialog.h
"
25
#include "
MessageLog.h
"
26
#include "
NetViewer.h
"
27
#include "
BandwidthGraph.h
"
28
#include "
HelperProcess.h
"
29
#if defined(USE_AUTOUPDATE)
30
#include "
UpdateProcess.h
"
31
#include "
UpdateProgressDialog.h
"
32
#endif
33
#if defined(USE_MINIUPNPC)
34
#include "
UPNPControl.h
"
35
#endif
36
37
#include "
TorControl.h
"
38
39
#include "
PluginEngine.h
"
40
41
#include <QMainWindow>
42
#include <QTimer>
43
#include <QSystemTrayIcon>
44
45
class
MainWindow
:
public
VidaliaWindow
46
{
47
Q_OBJECT
48
49
public
:
50
/** Default constructor */
51
MainWindow
();
52
/** Destructor. */
53
~MainWindow
();
54
55
public
slots:
56
/** Shows or hides this window. **/
57
virtual
void
setVisible
(
bool
visible);
58
59
protected
:
60
/** Called when the user changes the UI translation. */
61
virtual
void
retranslateUi
();
62
63
private
slots:
64
/** Respond to a double-click on the tray icon by opening the Control Panel
65
* window. */
66
void
trayIconActivated
(QSystemTrayIcon::ActivationReason reason);
67
/** Called when the user selects "Start" from the menu. */
68
void
start
();
69
/** Called when the user changes a setting that needs Tor restarting */
70
void
restart
();
71
/** Called when the user wants to reload Tor's config */
72
void
sighup
();
73
/** Called when the Tor process fails to start. */
74
void
startFailed
(QString errmsg);
75
/** Called when the Tor process has successfully started. */
76
void
started
();
77
/** Called when the user selects "Stop" form the menu. */
78
bool
stop
();
79
/** Called when the Tor process has exited, either expectedly or not. */
80
void
stopped
(
int
errorCode, QProcess::ExitStatus exitStatus);
81
/** Called when the control socket has connected to Tor. */
82
void
connected
();
83
/** Called when the control connection fails. */
84
void
connectFailed
(QString errmsg);
85
/** Called when Vidalia wants to disconnect from a Tor it did not start. */
86
void
disconnect
();
87
/** Called when the control socket has been disconnected. */
88
void
disconnected
();
89
/** Called when Vidalia has successfully authenticated to Tor. */
90
void
authenticated
();
91
/** Called when authenticated() detects that you can do auth with a cookie */
92
bool
tryCookie
(
const
ProtocolInfo
&pi);
93
/** Called when cookie auth fails or when it's the only method configured */
94
bool
tryHashed
();
95
/** Called when Vidalia fails to authenticate to Tor. The failure reason is
96
* specified in <b>errmsg</b>. */
97
void
authenticationFailed
(QString errmsg);
98
/** Re-enables the 'New Identity' button after a delay from the previous time
99
* 'New Identity' was used. */
100
void
enableNewIdentity
();
101
/** Called when the user selects the "New Identity" action from the menu. */
102
void
newIdentity
();
103
/** Called when the user exits Vidalia. */
104
void
close
();
105
/** Called when the application has started and the main event loop is
106
* running. */
107
void
running
();
108
/** Terminate the Tor process if it is being run under Vidalia, disconnect
109
* all TorControl signals, and exit Vidalia. */
110
void
aboutToQuit
();
111
112
/** Called when Tor has successfully established a circuit. */
113
void
circuitEstablished
();
114
/** Called when Tor thinks the user has tried to connect to a port that
115
* typically is used for unencrypted applications. Warns the user and allows
116
* them to ignore future warnings on <b>port</b>. */
117
void
warnDangerousPort
(quint16 port,
bool
rejected);
118
/** Called when Tor's bootstrapping status changes. <b>bse</b> represents
119
* Tor's current estimate of its bootstrapping progress. */
120
void
bootstrapStatusChanged
(
const
BootstrapStatus
&bs);
121
/** Called when Tor thinks its version is old or unrecommended, and displays
122
* a message notifying the user. */
123
void
dangerousTorVersion
(
tc::TorVersionStatus
reason,
124
const
QString &version,
125
const
QStringList &recommended);
126
void
handleCloseTab
(
int
index);
127
/** Creates and displays the Configuration dialog with the current page set
128
* to <b>page</b>. */
129
void
showConfigDialog
(
ConfigDialog::Page
page =
ConfigDialog::General
);
130
/** Displays the Message Log tab */
131
void
showMessageLogTab
();
132
/** Displays the General Tor Status tab */
133
void
showStatusTab
();
134
/** Displays the Bandwidth graph tab */
135
void
showBandwidthTab
();
136
/** Displays the Network map tab */
137
void
showNetViewerTab
();
138
/** Creates and displays Vidalia's About dialog. */
139
void
showAboutDialog
();
140
/** Displays the help browser and displays the most recently viewed help
141
* topic. */
142
void
showHelpDialog
();
143
/** Called when a child window requests the given help <b>topic</b>. */
144
void
showHelpDialog
(
const
QString &topic);
145
146
/** Displays the debug output dialog for plugins */
147
void
showDebugDialog
();
148
149
/** Adds a new tab to the MainWindow */
150
void
addTab
(
VidaliaTab
*tab);
151
/** Deletes the tab at index if it exists and it isn't the Status tab */
152
void
delTab
(
int
index = -1);
153
154
/** Attaches a tab to the tabwidget */
155
void
attachTab
();
156
/** Detaches a tab from the tabwidget */
157
void
detachTab
();
158
159
/** Called when trying to close a tab that has been detached */
160
void
handleAttachedClose
();
161
162
/** Called when tor detects a problem with the system clock */
163
void
clockSkewed
(
int
skew,
const
QString &source);
164
165
#if defined(USE_AUTOUPDATE)
166
/** Called when the user clicks the 'Check Now' button in the General
167
* settings page. */
168
void
checkForUpdatesWithUi();
169
/** Called when the update interval timer expires, notifying Vidalia that
170
* we should check for updates again. */
171
void
checkForUpdates(
bool
showProgress =
false
);
172
/** Called when the check for software updates fails. */
173
void
checkForUpdatesFailed(
const
QString &errmsg);
174
/** Called when there is an update available for installation. */
175
void
updatesAvailable(
UpdateProcess::BundleInfo
bi,
176
const
PackageList
&packageList);
177
/** Stops Tor (if necessary), installs any available for <b>bi</b>, and
178
* restarts Tor (if necessary). */
179
void
installUpdates(
UpdateProcess::BundleInfo
bi);
180
/** Called when all <b>numUpdates</b> software updates have been installed
181
* successfully. */
182
void
updatesInstalled(
int
numUpdates);
183
/** Called when an update fails to install. <b>errmsg</b> contains details
184
* about the failure. */
185
void
installUpdatesFailed(
const
QString &errmsg);
186
#endif
187
188
189
#if defined(USE_MINIUPNPC)
190
/** Called when a UPnP error occurs. */
191
void
upnpError(
UPNPControl::UPNPError
error
);
192
#endif
193
194
private
:
195
enum
TorStatus
{
196
Unset
,
/**< Tor's status has not yet been set. */
197
Stopping
,
/**< Tor is in the process of shutting down. */
198
Stopped
,
/**< Tor is not running. */
199
Starting
,
/**< Tor is in the process of starting. */
200
Started
,
/**< Tor is currently running. */
201
Authenticating
,
/**< Vidalia is authenticating to Tor. */
202
Authenticated
,
/**< Vidalia has authenticated to Tor. */
203
CircuitEstablished
/**< Tor has built a circuit. */
204
};
205
206
void
createGUI
();
207
void
createConnections
();
208
/** Create the actions on the tray menu or menubar */
209
void
createActions
();
210
/** Creates a tray icon with a context menu and adds it to the system
211
* notification area. On Mac, we also set up an application menubar. */
212
void
createTrayIcon
();
213
/** Create the tray popup menu and it's submenus */
214
QMenu*
createTrayMenu
();
215
/** Creates a menubar */
216
void
createMenuBar
();
217
/** Creates a toolbar */
218
void
createToolBar
();
219
/** Sets the current tray or dock icon image to <b>iconFile</b>. */
220
void
setTrayIcon
(
const
QString &iconFile);
221
/** Updates the UI to reflect Tor's current <b>status</b>. Returns the
222
* previously set TorStatus value. */
223
TorStatus
updateTorStatus
(
TorStatus
status);
224
/** Converts a TorStatus enum value to a string for debug logging purposes. */
225
QString
toString
(
TorStatus
status);
226
/** Authenticates Vidalia to Tor's control port. */
227
bool
authenticate
();
228
/** Searches for and attempts to load the control authentication cookie.
229
* This assumes the cookie is named 'control_auth_cookie'. If
230
* <b>cookiePath</b> is empty, this method will search some default locations
231
* depending on the current platform. <b>cookiePath</b> can point to either
232
* a cookie file or a directory containing the cookie file. */
233
QByteArray
loadControlCookie
(QString cookiePath = QString());
234
/** Checks the status of the current version of Tor to see if it's old,
235
* unrecommended, or obsolete. */
236
void
checkTorVersion
();
237
/** Alerts the user that their current Tor version is either obsolete or
238
* no longer recommended. If Vidalia was built with auto-update support,
239
* they will be given the option to check for available updates. */
240
void
displayTorVersionWarning
();
241
/** Sets the visibility of the startup status description and progress bar
242
* to <b>visible</b>. */
243
void
setStartupProgressVisible
(
bool
visible);
244
/** Sets the progress bar completion value to <b>progressValue</b> and sets
245
* the status text to <b>description</b>. */
246
void
setStartupProgress
(
int
percentComplete,
const
QString &description);
247
248
/** The current status of Tor. */
249
TorStatus
_status
;
250
/** Used to determine if the Tor process exiting was intentional or not */
251
bool
_isIntentionalExit
;
252
/** Tracks whether we started a delayed server shutdown. */
253
bool
_delayedShutdownStarted
;
254
/** Set to true if Vidalia started its own Tor process. */
255
bool
_isVidaliaRunningTor
;
256
/** A TorControl object that handles communication with Tor */
257
TorControl
*
_torControl
;
258
/** Remembers the control password between when we start Tor with a hash of
259
* the password and when we need to provide the password itself. */
260
QString
_controlPassword
;
261
/** Set to true if we should use the control password saved in TorSettings
262
* when authenticating to Tor. */
263
bool
_useSavedPassword
;
264
/** The Vidalia icon that sits in the tray. */
265
QSystemTrayIcon
_trayIcon
;
266
267
#if defined(USE_AUTOUPDATE)
268
/** Timer used to remind us to check for software updates. */
269
QTimer _updateTimer;
270
/** The auto-update process used to check for and download updates. */
271
UpdateProcess
_updateProcess;
272
/** Dialog instance that is be used to show the progress of the auto-update
273
* executable. */
274
UpdateProgressDialog
_updateProgressDialog;
275
/** Set to true if Vidalia should restart Tor after a software upgrade. */
276
bool
_restartTorAfterUpgrade;
277
#endif
278
279
/** Defines the actions for the tray menu */
280
QAction *
_actionShowControlPanel
;
281
QAction *
_actionStartStopTor
;
282
QAction *
_actionRestartTor
;
283
QAction *
_actionReloadConfig
;
284
QAction *
_actionNewIdentity
;
285
QAction *
_actionStatus
;
286
QAction *
_actionNetworkMap
;
287
QAction *
_actionMessageLog
;
288
QAction *
_actionBandwidthGraph
;
289
QAction *
_actionConfigure
;
290
QAction *
_actionVidaliaHelp
;
291
QAction *
_actionAbout
;
292
QAction *
_actionExit
;
293
QAction *
_actionDebugDialog
;
294
295
QMenu
_reattachMenu
;
/**< Menu used to handle tab re-attaching */
296
QAction *
_dummy
;
/**< Dummy action to display when there are no more tabs */
297
298
Ui::MainWindow
ui
;
/**< Qt Designer generated object. */
299
300
StatusTab
_statusTab
;
/**< Status tab that displays the load progress and a short log */
301
MessageLog
*
_messageLog
;
/**< Message log that displays a more detailed log from Tor */
302
NetViewer
_netViewer
;
/**< Network map that draws circuits */
303
BandwidthGraph
*
_graph
;
/**< Graph that draws bandwidth usage */
304
305
PluginEngine
*
_engine
;
306
QStringList
_tabMap
;
/**< Map to handle opened tabs */
307
QStringList
_detachedTabMap
;
/**< Map to handle detached tabs */
308
309
bool
_startedWithPrevious
;
/**< True if Vidalia tried to start Tor with the previous ports */
310
QString
_previousControlPort
;
/**< Holds the previous controlport used */
311
QString
_previousSocksPort
;
/**< Holds the previous socksport used */
312
};
313
314
#endif
315
Generated on Mon Jan 14 2013 08:44:27 for Vidalia by
1.8.3