Vidalia  0.3.1
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 "VidaliaTab.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 VidaliaTab
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  /** Called when the search of a router is triggered by the signal
105  * returnPressed from the search field. */
106  void onRouterSearch();
107 
108 private:
109  /** */
110  void setupGeoIpResolver();
111  /** Retrieves a list of all running routers from Tor and their descriptors,
112  * and adds them to the RouterListWidget. */
113  void loadNetworkStatus();
114  /** Loads a list of address mappings from Tor. */
115  void loadAddressMap();
116  /** Adds a router to our list of servers and retrieves geographic location
117  * information for the server. */
118  void addRouter(const RouterDescriptor &rd);
119 
120  /** TorControl object used to talk to Tor. */
122  /** Timer that fires once an hour to update the router list. */
124  /** GeoIpResolver used to geolocate routers by IP address. */
126  /** Stores a list of address mappings from Tor. */
128 
129  /** Widget that displays the Tor network map. */
130 #if defined(USE_MARBLE)
132 #else
134 #endif
135 
136  /** Qt Designer generated object **/
137  Ui::NetViewer ui;
138 };
139 
140 #endif
141 
NetViewer::addressMapped
void addressMapped(const QString &from, const QString &to, const QDateTime &expires)
Definition: NetViewer.cpp:320
TorMapWidget.h
NetViewer::zoomIn
void zoomIn()
Definition: NetViewer.cpp:469
NetViewer::onDisconnected
void onDisconnected()
Definition: NetViewer.cpp:210
NetViewer::_addressMap
AddressMap _addressMap
Definition: NetViewer.h:127
TorControl
Definition: TorControl.h:49
NetViewer::loadNetworkStatus
void loadNetworkStatus()
Definition: NetViewer.cpp:336
NetViewer::addCircuit
void addCircuit(const Circuit &circuit)
Definition: NetViewer.cpp:291
GeoIpResolver
Definition: GeoIpResolver.h:35
Circuit
Definition: Circuit.h:27
NetViewer::loadConnections
void loadConnections()
Definition: NetViewer.cpp:272
NetViewer::loadAddressMap
void loadAddressMap()
Definition: NetViewer.cpp:263
TorMapImageView
Definition: TorMapImageView.h:31
VidaliaTab
Definition: VidaliaTab.h:23
TorControl.h
NetViewer::addStream
void addStream(const Stream &stream)
Definition: NetViewer.cpp:301
NetViewer::setupGeoIpResolver
void setupGeoIpResolver()
Definition: NetViewer.cpp:179
NetViewer::_refreshTimer
QTimer _refreshTimer
Definition: NetViewer.h:123
NetViewer::retranslateUi
void retranslateUi()
Definition: NetViewer.cpp:152
NetViewer::circuitSelected
void circuitSelected(const Circuit &circuit)
Definition: NetViewer.cpp:389
NetViewer::ui
Ui::NetViewer ui
Definition: NetViewer.h:137
NetViewer::toggleFullScreen
void toggleFullScreen()
Definition: NetViewer.cpp:492
NetViewer::newDescriptors
void newDescriptors(const QStringList &ids)
Definition: NetViewer.cpp:377
Stream
Definition: Stream.h:31
NetViewer::onAuthenticated
void onAuthenticated()
Definition: NetViewer.cpp:201
NetViewer::routerSelected
void routerSelected(const QList< RouterDescriptor > &routers)
Definition: NetViewer.cpp:413
NetViewer::NetViewer
NetViewer(QWidget *parent=0)
Definition: NetViewer.cpp:44
NetViewer::refresh
void refresh()
Definition: NetViewer.cpp:219
RouterDescriptor
Definition: RouterDescriptor.h:26
VidaliaTab.h
GeoIpResolver.h
config.h
NetViewer::addRouter
void addRouter(const RouterDescriptor &rd)
Definition: NetViewer.cpp:354
NetViewer::_geoip
GeoIpResolver _geoip
Definition: NetViewer.h:125
NetViewer::zoomOut
void zoomOut()
Definition: NetViewer.cpp:480
NetViewer
Definition: NetViewer.h:41
TorMapWidget
Definition: TorMapWidget.h:37
NetViewer::onRouterSearch
void onRouterSearch()
Definition: NetViewer.cpp:256
NetViewer::displayRouterInfo
void displayRouterInfo(const QString &id)
Definition: NetViewer.cpp:431
TorMapImageView.h
AddressMap
Definition: AddressMap.h:28
NetViewer::_torControl
TorControl * _torControl
Definition: NetViewer.h:121
NetViewer::_map
TorMapImageView * _map
Definition: NetViewer.h:133
NetViewer::help
void help()
Definition: NetViewer.cpp:328
NetViewer::clear
void clear()
Definition: NetViewer.cpp:240