00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file netviewer.h 00024 * \version $Id: netviewer.h 699 2006-04-15 03:12:22Z hipplej $ 00025 * \brief Displays a map of the Tor network and the user's circuits 00026 */ 00027 00028 #ifndef _NETVIEWER_H 00029 #define _NETVIEWER_H 00030 00031 #include <QMainWindow> 00032 #include <QStringList> 00033 #include <QEvent> 00034 #include <QTimer> 00035 #include <QHash> 00036 #include <control/torcontrol.h> 00037 #include <util/geoip/geoipresolver.h> 00038 #include <gui/common/vidaliawindow.h> 00039 00040 #include "tormapwidget.h" 00041 #include "ui_netviewer.h" 00042 00043 00044 class NetViewer : public VidaliaWindow 00045 { 00046 Q_OBJECT 00047 00048 public: 00049 /** Default constructor */ 00050 NetViewer(QWidget* parent = 0); 00051 00052 public slots: 00053 /** Loads a list of current circuits and streams. */ 00054 void loadConnections(); 00055 /** Adds a circuit to the list and the map */ 00056 void addCircuit(Circuit circuit); 00057 /** Clears all known information */ 00058 void clear(); 00059 00060 protected: 00061 /** Called to deliver a NEWDESC event from Tor. */ 00062 void customEvent(QEvent *event); 00063 00064 private slots: 00065 /** Called when the user selects the "Help" action on the toolbar. */ 00066 void help(); 00067 /** Called when the user selects the "Refresh" action on the toolbar */ 00068 void refresh(); 00069 /** Called when the user selects a circuit on the circuit list */ 00070 void circuitSelected(Circuit circuit); 00071 /** Called when an IP has been resolved to geographic information. */ 00072 void resolved(int id, QList<GeoIp> geoips); 00073 /** Called when the user selects a router in the list. */ 00074 void routerSelected(RouterDescriptor router); 00075 /** Handles when we get connected to Tor network */ 00076 void gotConnected(); 00077 /** Handles when we get disconnected from Tor network */ 00078 void gotDisconnected(); 00079 /** Resolves IP addresses in the resolve queue to geographic information. */ 00080 void resolve(); 00081 00082 private: 00083 /** Loads a list of router descriptors from the list of IDs. */ 00084 void loadDescriptors(QStringList ids); 00085 /** Adds a router to our list of servers and retrieves geographic location 00086 * information for the server. */ 00087 void addRouter(RouterDescriptor rd); 00088 /** Convert all hops in <b>circ</b>'s path to server identities. 00089 * <b>circ</b>'s status and circuit ID will be preserved. */ 00090 Circuit circuitPathIDs(Circuit circ); 00091 /** Convert all hops in <b>circ</b>'s path to server names. <b>circ</b>'s 00092 * status and circuit ID will be preserved. */ 00093 Circuit circuitPathNames(Circuit circ); 00094 00095 /** TorControl object used to talk to Tor. */ 00096 TorControl* _torControl; 00097 /** Timer that fires once an hour to update the router list. */ 00098 QTimer _refreshTimer; 00099 /** TorMapWidget that displays the map. */ 00100 TorMapWidget* _map; 00101 /** GeoIpResolver used to geolocate routers by IP address. */ 00102 GeoIpResolver _geoip; 00103 /** Queue for IPs pending resolution to geographic information. */ 00104 QList<QHostAddress> _resolveQueue; 00105 /** Maps pending GeoIP requests to server IDs. */ 00106 QHash<QString, QString> _resolveMap; 00107 /** Timer used to delay GeoIP requests until we've received "a chunk" of them. */ 00108 QTimer _resolveQueueTimer; 00109 00110 /** Qt Designer generated object **/ 00111 Ui::NetViewer ui; 00112 }; 00113 00114 #endif 00115