Vidalia 0.2.12

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