Vidalia 0.2.10

NetViewer.h

Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file NetViewer.h
00013 ** \version $Id: NetViewer.h 4378 2010-08-05 20:28:54Z edmanm $
00014 ** \brief Displays a map of the Tor network and the user's circuits
00015 */
00016 
00017 #ifndef _NETVIEWER_H
00018 #define _NETVIEWER_H
00019 
00020 #include "config.h"
00021 #include "ui_NetViewer.h"
00022 #include "VidaliaWindow.h"
00023 #include "GeoIpResolver.h"
00024 
00025 #if defined(USE_MARBLE)
00026 #include "TorMapWidget.h"
00027 #else
00028 #include "TorMapImageView.h"
00029 #endif
00030 
00031 #include "TorControl.h"
00032 
00033 #include <QMainWindow>
00034 #include <QStringList>
00035 #include <QEvent>
00036 #include <QTimer>
00037 #include <QHash>
00038 
00039 class QDateTime;
00040 
00041 
00042 class NetViewer : public VidaliaWindow
00043 {
00044   Q_OBJECT
00045 
00046 public:
00047   /** Default constructor */
00048   NetViewer(QWidget* parent = 0);
00049 
00050 public slots:
00051   /** Displays the network map window. */
00052 //  void showWindow();
00053   /** Loads a list of current circuits and streams. */
00054   void loadConnections();
00055   /** Adds <b>circuit</b> to the list and the map */
00056   void addCircuit(const Circuit &circuit);
00057   /** Adds <b>stream</b> to the list of circuits, under the appropriate
00058    * circuit. */
00059   void addStream(const Stream &stream);
00060 
00061   /** Called when a NEWDESC event arrives. Retrieves new router descriptors
00062    * for the router identities given in <b>ids</b> and updates the router list
00063    * and network map.
00064    */
00065   void newDescriptors(const QStringList &ids);
00066 
00067   /** Called when Tor has mapped the address <b>from</b> to the address
00068    * <b>to</b>. <b>expires</b> indicates the time at which when the address
00069    * mapping will no longer be considered valid.
00070    */
00071   void addressMapped(const QString &from, const QString &to,
00072                      const QDateTime &expires);
00073 
00074   /** Clears all known information */
00075   void clear();
00076 
00077 protected:
00078   /** Called when the user changes the UI translation. */
00079   void retranslateUi();
00080 
00081 private slots:
00082   /** Called when the user selects the "Help" action on the toolbar. */
00083   void help();
00084   /** Called when the user selects the "Refresh" action on the toolbar */
00085   void refresh();
00086   /** Called when the user selects a circuit on the circuit list */
00087   void circuitSelected(const Circuit &circuit);
00088   /** Called when the user selects one or more routers in the list. */
00089   void routerSelected(const QList<RouterDescriptor> &routers);
00090   /** Handles when we get connected to Tor network */
00091   void onAuthenticated();
00092   /** Handles when we get disconnected from Tor network */
00093   void onDisconnected();
00094   /** Called when the user selects a router on the network map. Displays a 
00095    * dialog with detailed information for the router specified by
00096    * <b>id</b>.*/
00097   void displayRouterInfo(const QString &id);
00098   /** Called when the user clicks the "Zoom In" button. */
00099   void zoomIn();
00100   /** Called when the user clicks the "Zoom Out" button. */
00101   void zoomOut();
00102   /** Called when the user clicks "Full Screen" or presses Escape on the map.
00103    * Toggles the map between normal and a full screen viewing modes. */
00104   void toggleFullScreen();
00105 
00106 private:
00107   /** */
00108   void setupGeoIpResolver();
00109   /** Retrieves a list of all running routers from Tor and their descriptors,
00110    * and adds them to the RouterListWidget. */
00111   void loadNetworkStatus();
00112   /** Loads a list of address mappings from Tor. */
00113   void loadAddressMap();
00114   /** Adds a router to our list of servers and retrieves geographic location
00115    * information for the server. */
00116   void addRouter(const RouterDescriptor &rd);
00117 
00118   /** TorControl object used to talk to Tor. */
00119   TorControl* _torControl;
00120   /** Timer that fires once an hour to update the router list. */
00121   QTimer _refreshTimer;
00122   /** GeoIpResolver used to geolocate routers by IP address. */
00123   GeoIpResolver _geoip;
00124   /** Stores a list of address mappings from Tor. */
00125   AddressMap _addressMap;
00126  
00127   /** Widget that displays the Tor network map. */
00128 #if defined(USE_MARBLE)
00129   TorMapWidget* _map;
00130 #else
00131   TorMapImageView* _map;
00132 #endif
00133 
00134   /** Qt Designer generated object **/
00135   Ui::NetViewer ui;
00136 };
00137 
00138 #endif
00139