Vidalia 0.2.10
|
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 TorMapWidget.h 00013 ** \version $Id: TorMapWidget.h 4378 2010-08-05 20:28:54Z edmanm $ 00014 ** \brief Displays Tor servers and circuits on a map of the world 00015 */ 00016 00017 #ifndef _TORMAPWIDGET_H 00018 #define _TORMAPWIDGET_H 00019 00020 #include "RouterDescriptor.h" 00021 #include "GeoIpRecord.h" 00022 00023 #include "Circuit.h" 00024 #include "Stream.h" 00025 00026 #include <MarbleWidget.h> 00027 #include <GeoPainter.h> 00028 #include <GeoDataCoordinates.h> 00029 #include <GeoDataLineString.h> 00030 00031 #include <QHash> 00032 #include <QPair> 00033 #include <QPainterPath> 00034 00035 typedef QPair<Marble::GeoDataLineString, bool> CircuitGeoPath; 00036 00037 00038 class TorMapWidget : public Marble::MarbleWidget 00039 { 00040 Q_OBJECT 00041 00042 public: 00043 /** Default constructor. */ 00044 TorMapWidget(QWidget *parent = 0); 00045 /** Destructor. */ 00046 ~TorMapWidget(); 00047 00048 /** Plots the given router on the map using the given coordinates. */ 00049 void addRouter(const RouterDescriptor &desc, const GeoIpRecord &geoip); 00050 /** Plots the given circuit on the map. */ 00051 void addCircuit(const CircuitId &circid, const QStringList &path); 00052 /** Selects and hightlights a router on the map. */ 00053 void selectRouter(const QString &id); 00054 /** Selects and highlights a circuit on the map. */ 00055 void selectCircuit(const CircuitId &circid); 00056 00057 public slots: 00058 /** Removes a circuit from the map. */ 00059 void removeCircuit(const CircuitId &circid); 00060 /** Deselects all the highlighted circuits and routers */ 00061 void deselectAll(); 00062 /** Clears the known routers and removes all the data from the map */ 00063 void clear(); 00064 /** Zooms the map to fit entirely within the constraints of the current 00065 * viewport size. */ 00066 void zoomToFit(); 00067 /** Zoom to a particular router on the map. */ 00068 void zoomToRouter(const QString &id); 00069 /** Zoom to the circuit on the map with the given <b>circid</b>. */ 00070 void zoomToCircuit(const CircuitId &circid); 00071 00072 signals: 00073 /** Emitted when the user selects a router placemark on the map. <b>id</b> 00074 * contain's the selected router's fingerprint. */ 00075 void displayRouterInfo(const QString &id); 00076 00077 protected: 00078 /** Paints the current circuits and streams on the image. */ 00079 virtual void customPaint(Marble::GeoPainter *painter); 00080 00081 private: 00082 /** Stores placemark IDs for Tor routers. */ 00083 QHash<QString, Marble::GeoDataCoordinates> _routers; 00084 /** Stores circuit information */ 00085 QHash<CircuitId, CircuitGeoPath*> _circuits; 00086 }; 00087 00088 #endif 00089