Vidalia  0.2.21
NetViewer.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 NetViewer.h
13 ** \brief Displays a map of the Tor network and the user's circuits
14 */
15 
16 #ifndef _NETVIEWER_H
17 #define _NETVIEWER_H
18 
19 #include "config.h"
20 #include "ui_NetViewer.h"
21 #include "VidaliaWindow.h"
22 #include "GeoIpResolver.h"
23 
24 #if defined(USE_MARBLE)
25 #include "TorMapWidget.h"
26 #else
27 #include "TorMapImageView.h"
28 #endif
29 
30 #include "TorControl.h"
31 
32 #include <QMainWindow>
33 #include <QStringList>
34 #include <QEvent>
35 #include <QTimer>
36 #include <QHash>
37 
38 class QDateTime;
39 
40 
41 class NetViewer : public VidaliaWindow
42 {
43  Q_OBJECT
44 
45 public:
46  /** Default constructor */
47  NetViewer(QWidget* parent = 0);
48 
49 public slots:
50  /** Displays the network map window. */
51 // void showWindow();
52  /** Loads a list of current circuits and streams. */
53  void loadConnections();
54  /** Adds <b>circuit</b> to the list and the map */
55  void addCircuit(const Circuit &circuit);
56  /** Adds <b>stream</b> to the list of circuits, under the appropriate
57  * circuit. */
58  void addStream(const Stream &stream);
59 
60  /** Called when a NEWDESC event arrives. Retrieves new router descriptors
61  * for the router identities given in <b>ids</b> and updates the router list
62  * and network map.
63  */
64  void newDescriptors(const QStringList &ids);
65 
66  /** Called when Tor has mapped the address <b>from</b> to the address
67  * <b>to</b>. <b>expires</b> indicates the time at which when the address
68  * mapping will no longer be considered valid.
69  */
70  void addressMapped(const QString &from, const QString &to,
71  const QDateTime &expires);
72 
73  /** Clears all known information */
74  void clear();
75 
76 protected:
77  /** Called when the user changes the UI translation. */
78  void retranslateUi();
79 
80 private slots:
81  /** Called when the user selects the "Help" action on the toolbar. */
82  void help();
83  /** Called when the user selects the "Refresh" action on the toolbar */
84  void refresh();
85  /** Called when the user selects a circuit on the circuit list */
86  void circuitSelected(const Circuit &circuit);
87  /** Called when the user selects one or more routers in the list. */
88  void routerSelected(const QList<RouterDescriptor> &routers);
89  /** Handles when we get connected to Tor network */
90  void onAuthenticated();
91  /** Handles when we get disconnected from Tor network */
92  void onDisconnected();
93  /** Called when the user selects a router on the network map. Displays a
94  * dialog with detailed information for the router specified by
95  * <b>id</b>.*/
96  void displayRouterInfo(const QString &id);
97  /** Called when the user clicks the "Zoom In" button. */
98  void zoomIn();
99  /** Called when the user clicks the "Zoom Out" button. */
100  void zoomOut();
101  /** Called when the user clicks "Full Screen" or presses Escape on the map.
102  * Toggles the map between normal and a full screen viewing modes. */
103  void toggleFullScreen();
104 
105 private:
106  /** */
107  void setupGeoIpResolver();
108  /** Retrieves a list of all running routers from Tor and their descriptors,
109  * and adds them to the RouterListWidget. */
110  void loadNetworkStatus();
111  /** Loads a list of address mappings from Tor. */
112  void loadAddressMap();
113  /** Adds a router to our list of servers and retrieves geographic location
114  * information for the server. */
115  void addRouter(const RouterDescriptor &rd);
116 
117  /** TorControl object used to talk to Tor. */
119  /** Timer that fires once an hour to update the router list. */
121  /** GeoIpResolver used to geolocate routers by IP address. */
123  /** Stores a list of address mappings from Tor. */
125 
126  /** Widget that displays the Tor network map. */
127 #if defined(USE_MARBLE)
129 #else
131 #endif
132 
133  /** Qt Designer generated object **/
134  Ui::NetViewer ui;
135 };
136 
137 #endif
138