<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Vidalia: NetViewer.cpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_b47abd1aad201a152869566145babb61.html">src</a> » <a class="el" href="dir_695ba8f8357372e02d38c40b3c6dbe81.html">vidalia</a> » <a class="el" href="dir_3776330d706700e272fa8df738fecea6.html">network</a> </div> </div> <div class="contents"> <h1>NetViewer.cpp</h1><a href="_net_viewer_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment">** This file is part of Vidalia, and is subject to the license terms in the</span> <a name="l00003"></a>00003 <span class="comment">** LICENSE file, found in the top level directory of this distribution. If you</span> <a name="l00004"></a>00004 <span class="comment">** did not receive the LICENSE file with this file, you may obtain it from the</span> <a name="l00005"></a>00005 <span class="comment">** Vidalia source package distributed by the Vidalia Project at</span> <a name="l00006"></a>00006 <span class="comment">** http://www.vidalia-project.net/. No part of Vidalia, including this file,</span> <a name="l00007"></a>00007 <span class="comment">** may be copied, modified, propagated, or distributed except according to the</span> <a name="l00008"></a>00008 <span class="comment">** terms described in the LICENSE file.</span> <a name="l00009"></a>00009 <span class="comment">*/</span> <a name="l00010"></a>00010 <a name="l00011"></a>00011 <span class="comment">/*</span> <a name="l00012"></a>00012 <span class="comment">** \file NetViewer.cpp</span> <a name="l00013"></a>00013 <span class="comment">** \version $Id: NetViewer.cpp 4054 2009-08-17 02:25:08Z edmanm $</span> <a name="l00014"></a>00014 <span class="comment">** \brief Displays a map of the Tor network and the user's circuits</span> <a name="l00015"></a>00015 <span class="comment">*/</span> <a name="l00016"></a>00016 <a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="_net_viewer_8h.html">NetViewer.h</a>"</span> <a name="l00018"></a>00018 <span class="preprocessor">#include "<a class="code" href="_router_info_dialog_8h.html">RouterInfoDialog.h</a>"</span> <a name="l00019"></a>00019 <span class="preprocessor">#include "<a class="code" href="_router_list_item_8h.html">RouterListItem.h</a>"</span> <a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="_vidalia_8h.html">Vidalia.h</a>"</span> <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="_v_message_box_8h.html">VMessageBox.h</a>"</span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="preprocessor">#include <QMessageBox></span> <a name="l00024"></a>00024 <span class="preprocessor">#include <QHeaderView></span> <a name="l00025"></a>00025 <a name="l00026"></a><a class="code" href="_net_viewer_8cpp.html#a0e07860d73d2c712c27808dcd5e25053">00026</a> <span class="preprocessor">#define IMG_MOVE ":/images/22x22/move-map.png"</span> <a name="l00027"></a><a class="code" href="_net_viewer_8cpp.html#a98fc796434a0ad5dee5a1cffff351139">00027</a> <span class="preprocessor"></span><span class="preprocessor">#define IMG_ZOOMIN ":/images/22x22/zoom-in.png"</span> <a name="l00028"></a><a class="code" href="_net_viewer_8cpp.html#ada4021631fdffb58a1df0756019b14be">00028</a> <span class="preprocessor"></span><span class="preprocessor">#define IMG_ZOOMOUT ":/images/22x22/zoom-out.png"</span> <a name="l00029"></a>00029 <span class="preprocessor"></span><span class="comment"></span> <a name="l00030"></a>00030 <span class="comment">/** Number of milliseconds to wait after the arrival of the last descriptor whose</span> <a name="l00031"></a>00031 <span class="comment"> * IP needs to be resolved to geographic information, in case more descriptors</span> <a name="l00032"></a>00032 <span class="comment"> * arrive. Then we can simply lump the IPs into a single request. */</span> <a name="l00033"></a><a class="code" href="_net_viewer_8cpp.html#a5aeafc35346022f9261580d7d2cae234">00033</a> <span class="preprocessor">#define MIN_RESOLVE_QUEUE_DELAY (10*1000)</span> <a name="l00034"></a>00034 <span class="preprocessor"></span><span class="comment">/** Maximum number of milliseconds to wait after the arrival of the first</span> <a name="l00035"></a>00035 <span class="comment"> * IP address into the resolve queue, before we flush the entire queue. */</span> <a name="l00036"></a><a class="code" href="_net_viewer_8cpp.html#a183f55806c36b82335366b6fc2e5edd3">00036</a> <span class="preprocessor">#define MAX_RESOLVE_QUEUE_DELAY (30*1000)</span> <a name="l00037"></a>00037 <span class="preprocessor"></span> <a name="l00038"></a>00038 <span class="comment"></span> <a name="l00039"></a>00039 <span class="comment">/** Constructor. Loads settings from VidaliaSettings.</span> <a name="l00040"></a>00040 <span class="comment"> * \param parent The parent widget of this NetViewer object.\</span> <a name="l00041"></a>00041 <span class="comment"> */</span> <a name="l00042"></a><a class="code" href="class_net_viewer.html#ad1d0ca5abfdb1d1a940e8ec31fef1661">00042</a> <a class="code" href="class_net_viewer.html#ad1d0ca5abfdb1d1a940e8ec31fef1661">NetViewer::NetViewer</a>(QWidget *parent) <a name="l00043"></a>00043 : <a class="code" href="class_vidalia_window.html">VidaliaWindow</a>(<span class="stringliteral">"NetViewer"</span>, parent) <a name="l00044"></a>00044 { <a name="l00045"></a>00045 <span class="comment">/* Invoke Qt Designer generated QObject setup routine */</span> <a name="l00046"></a>00046 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.setupUi(<span class="keyword">this</span>); <a name="l00047"></a>00047 <a name="l00048"></a>00048 <span class="preprocessor">#if defined(Q_WS_MAC)</span> <a name="l00049"></a>00049 <span class="preprocessor"></span> <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionHelp->setShortcut(QString(<span class="stringliteral">"Ctrl+?"</span>)); <a name="l00050"></a>00050 <span class="preprocessor">#endif</span> <a name="l00051"></a>00051 <span class="preprocessor"></span> <a name="l00052"></a>00052 <span class="comment">/* Pressing 'Esc' or 'Ctrl+W' will close the window */</span> <a name="l00053"></a>00053 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionClose->setShortcut(QString(<span class="stringliteral">"Esc"</span>)); <a name="l00054"></a>00054 <a class="code" href="class_vidalia.html#a4f28d73e2f92e6656f7c1c06d41b3569">Vidalia::createShortcut</a>(<span class="stringliteral">"Ctrl+W"</span>, <span class="keyword">this</span>, <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionClose, SLOT(trigger())); <a name="l00055"></a>00055 <a name="l00056"></a>00056 <span class="comment">/* Get the TorControl object */</span> <a name="l00057"></a>00057 <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a> = <a class="code" href="class_vidalia.html#a24c23bc8e35fcf66370d31ef176412d5">Vidalia::torControl</a>(); <a name="l00058"></a>00058 connect(<a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>, SIGNAL(authenticated()), <a name="l00059"></a>00059 <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a7cf1d01c9d9117ae828e57ea596078dd">onAuthenticated</a>())); <a name="l00060"></a>00060 connect(<a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>, SIGNAL(disconnected()), <a name="l00061"></a>00061 <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a2559af44cd76fc4628728d7fc835e85a">onDisconnected</a>())); <a name="l00062"></a>00062 <a name="l00063"></a>00063 <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#ab3dd744e5f82c562ef380a8ca447c3a3">setEvent</a>(<a class="code" href="class_tor_events.html#a08aed30fd27832e89f96114617da72bfaf51a978d8fb4a086d815518b13c6ccc4">TorEvents::CircuitStatus</a>); <a name="l00064"></a>00064 connect(<a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>, SIGNAL(circuitStatusChanged(<a class="code" href="class_circuit.html">Circuit</a>)), <a name="l00065"></a>00065 <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#afc6d6a94e4f463a516ced4267bf31fb8">addCircuit</a>(<a class="code" href="class_circuit.html">Circuit</a>))); <a name="l00066"></a>00066 <a name="l00067"></a>00067 <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#ab3dd744e5f82c562ef380a8ca447c3a3">setEvent</a>(<a class="code" href="class_tor_events.html#a08aed30fd27832e89f96114617da72bfa92d48f0cdb62ea444713b7574ab31d34">TorEvents::StreamStatus</a>); <a name="l00068"></a>00068 connect(<a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>, SIGNAL(streamStatusChanged(<a class="code" href="class_stream.html">Stream</a>)), <a name="l00069"></a>00069 <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a751dcf0bfc08d4665e6e4616e8319117">addStream</a>(<a class="code" href="class_stream.html">Stream</a>))); <a name="l00070"></a>00070 <a name="l00071"></a>00071 <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#ab3dd744e5f82c562ef380a8ca447c3a3">setEvent</a>(<a class="code" href="class_tor_events.html#a08aed30fd27832e89f96114617da72bfa4e71b10927d887d682ded74d160a5a2a">TorEvents::AddressMap</a>); <a name="l00072"></a>00072 connect(<a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>, SIGNAL(<a class="code" href="class_net_viewer.html#a709160288054a93ee1337267c1b40e4a">addressMapped</a>(QString, QString, QDateTime)), <a name="l00073"></a>00073 <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a709160288054a93ee1337267c1b40e4a">addressMapped</a>(QString, QString, QDateTime))); <a name="l00074"></a>00074 <a name="l00075"></a>00075 <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#ab3dd744e5f82c562ef380a8ca447c3a3">setEvent</a>(<a class="code" href="class_tor_events.html#a08aed30fd27832e89f96114617da72bfad4e1c3f57606b56d335885d3f36bf20c">TorEvents::NewDescriptor</a>); <a name="l00076"></a>00076 connect(<a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>, SIGNAL(<a class="code" href="class_net_viewer.html#ab5c243bf39e784335463c07412861208">newDescriptors</a>(QStringList)), <a name="l00077"></a>00077 <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#ab5c243bf39e784335463c07412861208">newDescriptors</a>(QStringList))); <a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="comment">/* Change the column widths of the tree widgets */</span> <a name="l00080"></a>00080 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->header()-> <a name="l00081"></a>00081 resizeSection(<a class="code" href="class_router_list_widget.html#a76aba4b10ccb2e237a1607c8a2857b9faff4fd49c7fb8dc2d43d9e25f92f520dc">RouterListWidget::StatusColumn</a>, 25); <a name="l00082"></a>00082 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->header()-> <a name="l00083"></a>00083 resizeSection(<a class="code" href="class_router_list_widget.html#a76aba4b10ccb2e237a1607c8a2857b9fab3309c35c2eb37d21fd8e3f8e2e2ab8c">RouterListWidget::CountryColumn</a>, 25); <a name="l00084"></a>00084 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList->header()-> <a name="l00085"></a>00085 resizeSection(<a class="code" href="class_circuit_list_widget.html#a0ee7faae3747824d0a26c43fd1e97e75a95ecebcfbcad6e1b8a039570fcbd8e57">CircuitListWidget::ConnectionColumn</a>, 235); <a name="l00086"></a>00086 <a name="l00087"></a>00087 <span class="comment">/* Create the TorMapWidget and add it to the dialog */</span> <a name="l00088"></a>00088 <span class="preprocessor">#if defined(USE_MARBLE)</span> <a name="l00089"></a>00089 <span class="preprocessor"></span> <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a> = <span class="keyword">new</span> <a class="code" href="class_tor_map_widget.html">TorMapWidget</a>(); <a name="l00090"></a>00090 connect(<a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>, SIGNAL(<a class="code" href="class_net_viewer.html#a4d88759346d479e9c8abdeb04f23b52e">displayRouterInfo</a>(QString)), <a name="l00091"></a>00091 <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a4d88759346d479e9c8abdeb04f23b52e">displayRouterInfo</a>(QString))); <a name="l00092"></a>00092 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionZoomFullScreen, SIGNAL(triggered()), <a name="l00093"></a>00093 <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#acc056faebc021de5c67ba5d7684140e3">toggleFullScreen</a>())); <a name="l00094"></a>00094 <a class="code" href="class_vidalia.html#a4f28d73e2f92e6656f7c1c06d41b3569">Vidalia::createShortcut</a>(<span class="stringliteral">"ESC"</span>, <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>, <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#acc056faebc021de5c67ba5d7684140e3">toggleFullScreen</a>())); <a name="l00095"></a>00095 <span class="preprocessor">#else</span> <a name="l00096"></a>00096 <span class="preprocessor"></span> <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a> = <span class="keyword">new</span> <a class="code" href="class_tor_map_image_view.html">TorMapImageView</a>(); <a name="l00097"></a>00097 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionZoomFullScreen->setVisible(<span class="keyword">false</span>); <a name="l00098"></a>00098 <span class="preprocessor">#endif</span> <a name="l00099"></a>00099 <span class="preprocessor"></span> <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.gridLayout->addWidget(<a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>); <a name="l00100"></a>00100 <a name="l00101"></a>00101 <a name="l00102"></a>00102 <span class="comment">/* Connect zoom buttons to TorMapWidget zoom slots */</span> <a name="l00103"></a>00103 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionZoomIn, SIGNAL(triggered()), <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#ae0181ea07d0b7c70f86f671ed73a4689">zoomIn</a>())); <a name="l00104"></a>00104 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionZoomOut, SIGNAL(triggered()), <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a1fed32d4085f58f95536f77d9c758af8">zoomOut</a>())); <a name="l00105"></a>00105 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionZoomToFit, SIGNAL(triggered()), <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>, SLOT(zoomToFit())); <a name="l00106"></a>00106 <a name="l00107"></a>00107 <span class="comment">/* Create the timer that will be used to update the router list once every</span> <a name="l00108"></a>00108 <span class="comment"> * hour. We still receive the NEWDESC event to get new descriptors, but this</span> <a name="l00109"></a>00109 <span class="comment"> * needs to be called to get rid of any descriptors that were removed. */</span> <a name="l00110"></a>00110 <a class="code" href="class_net_viewer.html#a07c4dc0a139c7d4a382ad06b97f220d0">_refreshTimer</a>.setInterval(60*60*1000); <a name="l00111"></a>00111 connect(&<a class="code" href="class_net_viewer.html#a07c4dc0a139c7d4a382ad06b97f220d0">_refreshTimer</a>, SIGNAL(timeout()), <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a8c2d673a8f10e1c422101086c25271ee">refresh</a>())); <a name="l00112"></a>00112 <a name="l00113"></a>00113 <span class="comment">/* Set up the timers used to group together GeoIP requests for new</span> <a name="l00114"></a>00114 <span class="comment"> * descriptors arriving within MIN_RESOLVE_QUEUE_DELAY milliseconds, but no</span> <a name="l00115"></a>00115 <span class="comment"> * more than MAX_RESOLVE_QUEUE_DELAY milliseconds of each other. */</span> <a name="l00116"></a>00116 <a class="code" href="class_net_viewer.html#a67bc5955adb4d0489f6543a79633748b">_minResolveQueueTimer</a>.setSingleShot(<span class="keyword">true</span>); <a name="l00117"></a>00117 connect(&<a class="code" href="class_net_viewer.html#a67bc5955adb4d0489f6543a79633748b">_minResolveQueueTimer</a>, SIGNAL(timeout()), <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a5055d97ac042d2cafd6bb3b36a8d69fd">resolve</a>())); <a name="l00118"></a>00118 <a class="code" href="class_net_viewer.html#aa98ce54d7106f5013d3265f9c5f012dd">_maxResolveQueueTimer</a>.setSingleShot(<span class="keyword">true</span>); <a name="l00119"></a>00119 connect(&<a class="code" href="class_net_viewer.html#aa98ce54d7106f5013d3265f9c5f012dd">_maxResolveQueueTimer</a>, SIGNAL(timeout()), <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a5055d97ac042d2cafd6bb3b36a8d69fd">resolve</a>())); <a name="l00120"></a>00120 <a name="l00121"></a>00121 <span class="comment">/* Connect the necessary slots and signals */</span> <a name="l00122"></a>00122 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionHelp, SIGNAL(triggered()), <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a5deaeec411346de13eaf325c6f49daa1">help</a>())); <a name="l00123"></a>00123 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionRefresh, SIGNAL(triggered()), <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a8c2d673a8f10e1c422101086c25271ee">refresh</a>())); <a name="l00124"></a>00124 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList, SIGNAL(<a class="code" href="class_net_viewer.html#a66c6c7a9b0222dbb0c980d6792bd95bd">routerSelected</a>(QList<RouterDescriptor>)), <a name="l00125"></a>00125 <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a66c6c7a9b0222dbb0c980d6792bd95bd">routerSelected</a>(QList<RouterDescriptor>))); <a name="l00126"></a>00126 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList, SIGNAL(zoomToRouter(QString)), <a name="l00127"></a>00127 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>, SLOT(zoomToRouter(QString))); <a name="l00128"></a>00128 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList, SIGNAL(<a class="code" href="class_net_viewer.html#afc09031d4b84b823f213b78aa102669f">circuitSelected</a>(<a class="code" href="class_circuit.html">Circuit</a>)), <a name="l00129"></a>00129 <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#afc09031d4b84b823f213b78aa102669f">circuitSelected</a>(<a class="code" href="class_circuit.html">Circuit</a>))); <a name="l00130"></a>00130 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList, SIGNAL(circuitRemoved(<a class="code" href="_circuit_8h.html#a8b7b0182a6d1ff0aab7ab31df9c3f83d">CircuitId</a>)), <a name="l00131"></a>00131 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>, SLOT(removeCircuit(<a class="code" href="_circuit_8h.html#a8b7b0182a6d1ff0aab7ab31df9c3f83d">CircuitId</a>))); <a name="l00132"></a>00132 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList, SIGNAL(zoomToCircuit(<a class="code" href="_circuit_8h.html#a8b7b0182a6d1ff0aab7ab31df9c3f83d">CircuitId</a>)), <a name="l00133"></a>00133 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>, SLOT(zoomToCircuit(<a class="code" href="_circuit_8h.html#a8b7b0182a6d1ff0aab7ab31df9c3f83d">CircuitId</a>))); <a name="l00134"></a>00134 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList, SIGNAL(closeCircuit(<a class="code" href="_circuit_8h.html#a8b7b0182a6d1ff0aab7ab31df9c3f83d">CircuitId</a>)), <a name="l00135"></a>00135 <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>, SLOT(closeCircuit(<a class="code" href="_circuit_8h.html#a8b7b0182a6d1ff0aab7ab31df9c3f83d">CircuitId</a>))); <a name="l00136"></a>00136 connect(<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList, SIGNAL(closeStream(<a class="code" href="_stream_8h.html#a90d94d8a7b979b4c7e07f5869a431064">StreamId</a>)), <a name="l00137"></a>00137 <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>, SLOT(closeStream(<a class="code" href="_stream_8h.html#a90d94d8a7b979b4c7e07f5869a431064">StreamId</a>))); <a name="l00138"></a>00138 <a name="l00139"></a>00139 <span class="comment">/* Connect the slot to find out when geoip information has arrived */</span> <a name="l00140"></a>00140 connect(&<a class="code" href="class_net_viewer.html#a288067cdbae084a8490adb059adf8b85">_geoip</a>, SIGNAL(<a class="code" href="class_net_viewer.html#a3cbf9f1953bf0c1abaa6781a7de68476">resolved</a>(<span class="keywordtype">int</span>, QList<GeoIp>)), <a name="l00141"></a>00141 <span class="keyword">this</span>, SLOT(<a class="code" href="class_net_viewer.html#a3cbf9f1953bf0c1abaa6781a7de68476">resolved</a>(<span class="keywordtype">int</span>, QList<GeoIp>))); <a name="l00142"></a>00142 } <a name="l00143"></a>00143 <span class="comment"></span> <a name="l00144"></a>00144 <span class="comment">/** Called when the user changes the UI translation. */</span> <a name="l00145"></a>00145 <span class="keywordtype">void</span> <a name="l00146"></a><a class="code" href="class_net_viewer.html#af4b7d40c730d94bbd21a3243aa7280af">00146</a> <a class="code" href="class_net_viewer.html#af4b7d40c730d94bbd21a3243aa7280af">NetViewer::retranslateUi</a>() <a name="l00147"></a>00147 { <a name="l00148"></a>00148 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.retranslateUi(<span class="keyword">this</span>); <a name="l00149"></a>00149 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->retranslateUi(); <a name="l00150"></a>00150 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList->retranslateUi(); <a name="l00151"></a>00151 <a name="l00152"></a>00152 <span class="keywordflow">if</span> (<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->selectedItems().size()) { <a name="l00153"></a>00153 QList<RouterDescriptor> routers; <a name="l00154"></a>00154 <span class="keywordflow">foreach</span> (QTreeWidgetItem *item, <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->selectedItems()) { <a name="l00155"></a>00155 routers << dynamic_cast<RouterListItem *>(item)->descriptor(); <a name="l00156"></a>00156 } <a name="l00157"></a>00157 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.textRouterInfo->display(routers); <a name="l00158"></a>00158 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList->selectedItems().size()) { <a name="l00159"></a>00159 QList<RouterDescriptor> routers; <a name="l00160"></a>00160 QTreeWidgetItem *item = <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList->selectedItems()[0]; <a name="l00161"></a>00161 <a class="code" href="class_circuit.html">Circuit</a> circuit = <span class="keyword">dynamic_cast<</span><a class="code" href="class_circuit_item.html">CircuitItem</a>*<span class="keyword">></span>(item)->circuit(); <a name="l00162"></a>00162 <span class="keywordflow">foreach</span> (QString <span class="keywordtype">id</span>, circuit.<a class="code" href="class_circuit.html#a42535367967ed99c8b9b312dad11067d">routerIDs</a>()) { <a name="l00163"></a>00163 <a class="code" href="class_router_list_item.html">RouterListItem</a> *item = <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->findRouterById(<span class="keywordtype">id</span>); <a name="l00164"></a>00164 <span class="keywordflow">if</span> (item) <a name="l00165"></a>00165 routers.append(item-><a class="code" href="class_router_list_item.html#a674fe77dae14cbdbc423ea573ce40d4c">descriptor</a>()); <a name="l00166"></a>00166 } <a name="l00167"></a>00167 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.textRouterInfo->display(routers); <a name="l00168"></a>00168 } <a name="l00169"></a>00169 } <a name="l00170"></a>00170 <span class="comment"></span> <a name="l00171"></a>00171 <span class="comment">/** Display the network map window. If there are geoip requests waiting in the</span> <a name="l00172"></a>00172 <span class="comment"> * queue, start the queue timers now. */</span> <a name="l00173"></a>00173 <span class="keywordtype">void</span> <a name="l00174"></a><a class="code" href="class_net_viewer.html#ac8ae13125f5fae65d92b2015f5e12402">00174</a> <a class="code" href="class_net_viewer.html#ac8ae13125f5fae65d92b2015f5e12402">NetViewer::showWindow</a>() <a name="l00175"></a>00175 { <a name="l00176"></a>00176 <span class="keywordflow">if</span> (!<a class="code" href="class_net_viewer.html#a0ceba335e7eb56875c1f3fb59d646334">_resolveQueue</a>.isEmpty()) { <a name="l00177"></a>00177 <a class="code" href="class_net_viewer.html#a67bc5955adb4d0489f6543a79633748b">_minResolveQueueTimer</a>.start(<a class="code" href="_net_viewer_8cpp.html#a5aeafc35346022f9261580d7d2cae234">MIN_RESOLVE_QUEUE_DELAY</a>); <a name="l00178"></a>00178 <a class="code" href="class_net_viewer.html#aa98ce54d7106f5013d3265f9c5f012dd">_maxResolveQueueTimer</a>.start(<a class="code" href="_net_viewer_8cpp.html#a183f55806c36b82335366b6fc2e5edd3">MAX_RESOLVE_QUEUE_DELAY</a>); <a name="l00179"></a>00179 } <a name="l00180"></a>00180 <a class="code" href="class_net_viewer.html#ac8ae13125f5fae65d92b2015f5e12402">VidaliaWindow::showWindow</a>(); <a name="l00181"></a>00181 } <a name="l00182"></a>00182 <span class="comment"></span> <a name="l00183"></a>00183 <span class="comment">/** Loads data into map, lists and starts timer when we get connected*/</span> <a name="l00184"></a>00184 <span class="keywordtype">void</span> <a name="l00185"></a><a class="code" href="class_net_viewer.html#a7cf1d01c9d9117ae828e57ea596078dd">00185</a> <a class="code" href="class_net_viewer.html#a7cf1d01c9d9117ae828e57ea596078dd">NetViewer::onAuthenticated</a>() <a name="l00186"></a>00186 { <a name="l00187"></a>00187 <a class="code" href="class_net_viewer.html#a288067cdbae084a8490adb059adf8b85">_geoip</a>.<a class="code" href="class_geo_ip_resolver.html#abf4521e71431be4189f59148d248ba29">setSocksHost</a>(<a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#a2fb569a54bd8c0e73e81ba76a28f47fc">getSocksAddress</a>(), <a name="l00188"></a>00188 <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#ac58ed8ff6dc3a7fdf7fe16779e444b9a">getSocksPort</a>()); <a name="l00189"></a>00189 <a class="code" href="class_net_viewer.html#a8c2d673a8f10e1c422101086c25271ee">refresh</a>(); <a name="l00190"></a>00190 <a class="code" href="class_net_viewer.html#a07c4dc0a139c7d4a382ad06b97f220d0">_refreshTimer</a>.start(); <a name="l00191"></a>00191 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionRefresh->setEnabled(<span class="keyword">true</span>); <a name="l00192"></a>00192 } <a name="l00193"></a>00193 <span class="comment"></span> <a name="l00194"></a>00194 <span class="comment">/** Clears map, lists and stops timer when we get disconnected */</span> <a name="l00195"></a>00195 <span class="keywordtype">void</span> <a name="l00196"></a><a class="code" href="class_net_viewer.html#a2559af44cd76fc4628728d7fc835e85a">00196</a> <a class="code" href="class_net_viewer.html#a2559af44cd76fc4628728d7fc835e85a">NetViewer::onDisconnected</a>() <a name="l00197"></a>00197 { <a name="l00198"></a>00198 <a class="code" href="class_net_viewer.html#a03991203ec27b231415734522cf3596e">clear</a>(); <a name="l00199"></a>00199 <a class="code" href="class_net_viewer.html#a07c4dc0a139c7d4a382ad06b97f220d0">_refreshTimer</a>.stop(); <a name="l00200"></a>00200 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionRefresh->setEnabled(<span class="keyword">false</span>); <a name="l00201"></a>00201 } <a name="l00202"></a>00202 <span class="comment"></span> <a name="l00203"></a>00203 <span class="comment">/** Reloads the lists of routers, circuits that Tor knows about */</span> <a name="l00204"></a>00204 <span class="keywordtype">void</span> <a name="l00205"></a><a class="code" href="class_net_viewer.html#a8c2d673a8f10e1c422101086c25271ee">00205</a> <a class="code" href="class_net_viewer.html#a8c2d673a8f10e1c422101086c25271ee">NetViewer::refresh</a>() <a name="l00206"></a>00206 { <a name="l00207"></a>00207 <span class="comment">/* Don't let the user refresh while we're refreshing. */</span> <a name="l00208"></a>00208 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionRefresh->setEnabled(<span class="keyword">false</span>); <a name="l00209"></a>00209 <a name="l00210"></a>00210 <span class="comment">/* Clear the data */</span> <a name="l00211"></a>00211 <a class="code" href="class_net_viewer.html#a03991203ec27b231415734522cf3596e">clear</a>(); <a name="l00212"></a>00212 <a name="l00213"></a>00213 <span class="comment">/* Load router information */</span> <a name="l00214"></a>00214 <a class="code" href="class_net_viewer.html#a12a32fc2f915d54865e792335f49d496">loadNetworkStatus</a>(); <a name="l00215"></a>00215 <span class="comment">/* Load existing address mappings */</span> <a name="l00216"></a>00216 <a class="code" href="class_net_viewer.html#ad4bff74ed78c73163abbc2a2d1385484">loadAddressMap</a>(); <a name="l00217"></a>00217 <span class="comment">/* Load Circuits and Streams information */</span> <a name="l00218"></a>00218 <a class="code" href="class_net_viewer.html#a9986ea25487f67c51437e614cd7cd105">loadConnections</a>(); <a name="l00219"></a>00219 <a name="l00220"></a>00220 <span class="comment">/* Ok, they can refresh again. */</span> <a name="l00221"></a>00221 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.actionRefresh->setEnabled(<span class="keyword">true</span>); <a name="l00222"></a>00222 } <a name="l00223"></a>00223 <span class="comment"></span> <a name="l00224"></a>00224 <span class="comment">/** Clears the lists and the map */</span> <a name="l00225"></a>00225 <span class="keywordtype">void</span> <a name="l00226"></a><a class="code" href="class_net_viewer.html#a03991203ec27b231415734522cf3596e">00226</a> <a class="code" href="class_net_viewer.html#a03991203ec27b231415734522cf3596e">NetViewer::clear</a>() <a name="l00227"></a>00227 { <a name="l00228"></a>00228 <span class="comment">/* Clear the resolve queue and map */</span> <a name="l00229"></a>00229 <a class="code" href="class_net_viewer.html#aecff4f08a117d47ccefd2a3c95abdd8d">_resolveMap</a>.clear(); <a name="l00230"></a>00230 <a class="code" href="class_net_viewer.html#a0ceba335e7eb56875c1f3fb59d646334">_resolveQueue</a>.clear(); <a name="l00231"></a>00231 <span class="comment">/* Clear the network map */</span> <a name="l00232"></a>00232 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>-><a class="code" href="class_tor_map_image_view.html#af34ff08ec826e9ee9ed7361b59ff9671">clear</a>(); <a name="l00233"></a>00233 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->update(); <a name="l00234"></a>00234 <span class="comment">/* Clear the address map */</span> <a name="l00235"></a>00235 <a class="code" href="class_net_viewer.html#a47fe551cd0db9aaddab6e8ffbb67f7ea">_addressMap</a>.clear(); <a name="l00236"></a>00236 <span class="comment">/* Clear the lists of routers, circuits, and streams */</span> <a name="l00237"></a>00237 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->clearRouters(); <a name="l00238"></a>00238 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList->clearCircuits(); <a name="l00239"></a>00239 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.textRouterInfo->clear(); <a name="l00240"></a>00240 } <a name="l00241"></a>00241 <span class="comment"></span> <a name="l00242"></a>00242 <span class="comment">/** Loads a list of all current address mappings. */</span> <a name="l00243"></a>00243 <span class="keywordtype">void</span> <a name="l00244"></a><a class="code" href="class_net_viewer.html#ad4bff74ed78c73163abbc2a2d1385484">00244</a> <a class="code" href="class_net_viewer.html#ad4bff74ed78c73163abbc2a2d1385484">NetViewer::loadAddressMap</a>() <a name="l00245"></a>00245 { <a name="l00246"></a>00246 <span class="comment">/* We store the reverse address mappings, so we can go from a numeric value</span> <a name="l00247"></a>00247 <span class="comment"> * back to a likely more meaningful hostname to display for the user. */</span> <a name="l00248"></a>00248 <a class="code" href="class_net_viewer.html#a47fe551cd0db9aaddab6e8ffbb67f7ea">_addressMap</a> = <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#a3fa594dd2b11b0451fdeca36bbd7c18d">getAddressMap</a>().<a class="code" href="class_address_map.html#a9f0b073b8bbb6b5392602bd256f7ac14">reverse</a>(); <a name="l00249"></a>00249 } <a name="l00250"></a>00250 <span class="comment"></span> <a name="l00251"></a>00251 <span class="comment">/** Loads a list of all current circuits and streams. */</span> <a name="l00252"></a>00252 <span class="keywordtype">void</span> <a name="l00253"></a><a class="code" href="class_net_viewer.html#a9986ea25487f67c51437e614cd7cd105">00253</a> <a class="code" href="class_net_viewer.html#a9986ea25487f67c51437e614cd7cd105">NetViewer::loadConnections</a>() <a name="l00254"></a>00254 { <a name="l00255"></a>00255 <span class="comment">/* Load all circuits */</span> <a name="l00256"></a>00256 <a class="code" href="_circuit_8h.html#a5c7c01bcee10c15862fdf844c3d1538c">CircuitList</a> circuits = <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#ab2180f731d4e74f83441618a62c036d6">getCircuits</a>(); <a name="l00257"></a>00257 <span class="keywordflow">foreach</span> (<a class="code" href="class_circuit.html">Circuit</a> circuit, circuits) { <a name="l00258"></a>00258 <a class="code" href="class_net_viewer.html#afc6d6a94e4f463a516ced4267bf31fb8">addCircuit</a>(circuit); <a name="l00259"></a>00259 } <a name="l00260"></a>00260 <span class="comment">/* Now load all streams */</span> <a name="l00261"></a>00261 <a class="code" href="_stream_8h.html#ab96e42e030d3b02d7f4a4d69cf7a98e0">StreamList</a> streams = <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#ada4852a5804eafaebfd26eaaee3859ab">getStreams</a>(); <a name="l00262"></a>00262 <span class="keywordflow">foreach</span> (<a class="code" href="class_stream.html">Stream</a> stream, streams) { <a name="l00263"></a>00263 <a class="code" href="class_net_viewer.html#a751dcf0bfc08d4665e6e4616e8319117">addStream</a>(stream); <a name="l00264"></a>00264 } <a name="l00265"></a>00265 <a name="l00266"></a>00266 <span class="comment">/* Update the map */</span> <a name="l00267"></a>00267 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->update(); <a name="l00268"></a>00268 } <a name="l00269"></a>00269 <span class="comment"></span> <a name="l00270"></a>00270 <span class="comment">/** Adds <b>circuit</b> to the map and the list */</span> <a name="l00271"></a>00271 <span class="keywordtype">void</span> <a name="l00272"></a><a class="code" href="class_net_viewer.html#afc6d6a94e4f463a516ced4267bf31fb8">00272</a> <a class="code" href="class_net_viewer.html#afc6d6a94e4f463a516ced4267bf31fb8">NetViewer::addCircuit</a>(<span class="keyword">const</span> <a class="code" href="class_circuit.html">Circuit</a> &circuit) <a name="l00273"></a>00273 { <a name="l00274"></a>00274 <span class="comment">/* Add the circuit to the list of all current circuits */</span> <a name="l00275"></a>00275 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList->addCircuit(circuit); <a name="l00276"></a>00276 <span class="comment">/* Plot the circuit on the map */</span> <a name="l00277"></a>00277 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>-><a class="code" href="class_tor_map_image_view.html#a36237d226f686d3c5868c2e10b8100ef">addCircuit</a>(circuit.<a class="code" href="class_circuit.html#a3083f9c330227c6f46b3ab32e071f7be">id</a>(), circuit.<a class="code" href="class_circuit.html#a42535367967ed99c8b9b312dad11067d">routerIDs</a>()); <a name="l00278"></a>00278 } <a name="l00279"></a>00279 <span class="comment"></span> <a name="l00280"></a>00280 <span class="comment">/** Adds <b>stream</b> to its associated circuit on the list of all circuits. */</span> <a name="l00281"></a>00281 <span class="keywordtype">void</span> <a name="l00282"></a><a class="code" href="class_net_viewer.html#a751dcf0bfc08d4665e6e4616e8319117">00282</a> <a class="code" href="class_net_viewer.html#a751dcf0bfc08d4665e6e4616e8319117">NetViewer::addStream</a>(<span class="keyword">const</span> <a class="code" href="class_stream.html">Stream</a> &stream) <a name="l00283"></a>00283 { <a name="l00284"></a>00284 QString target = stream.<a class="code" href="class_stream.html#ab774881d5ef13085ff38fa975ec50edf">targetAddress</a>(); <a name="l00285"></a>00285 QHostAddress addr(target); <a name="l00286"></a>00286 <a name="l00287"></a>00287 <span class="comment">/* If the stream's target has an IP address instead of a host name,</span> <a name="l00288"></a>00288 <span class="comment"> * check our cache for an existing reverse address mapping. */</span> <a name="l00289"></a>00289 <span class="keywordflow">if</span> (!addr.isNull() && <a class="code" href="class_net_viewer.html#a47fe551cd0db9aaddab6e8ffbb67f7ea">_addressMap</a>.<a class="code" href="class_address_map.html#aeab78837799234d133513a819a877979">isMapped</a>(target)) { <a name="l00290"></a>00290 <span class="comment">/* Replace the IP address in the stream event with the original </span> <a name="l00291"></a>00291 <span class="comment"> * hostname */</span> <a name="l00292"></a>00292 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList->addStream( <a name="l00293"></a>00293 <a class="code" href="class_stream.html">Stream</a>(stream.<a class="code" href="class_stream.html#ac289e56fcae8e2283e6055d75eb6382d">id</a>(), stream.<a class="code" href="class_stream.html#ae704c6dddc0196b8813de2769426fed6">status</a>(), stream.<a class="code" href="class_stream.html#ab1a8fcb8353bace64d4d56bd5b4d07a2">circuitId</a>(), <a name="l00294"></a>00294 <a class="code" href="class_net_viewer.html#a47fe551cd0db9aaddab6e8ffbb67f7ea">_addressMap</a>.<a class="code" href="class_address_map.html#a86c87e42aeb13954088468390d15dd9e">mappedTo</a>(target), stream.<a class="code" href="class_stream.html#ab3bfd7479953b545bbf1ed3db0502c10">targetPort</a>())); <a name="l00295"></a>00295 } <span class="keywordflow">else</span> { <a name="l00296"></a>00296 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList->addStream(stream); <a name="l00297"></a>00297 } <a name="l00298"></a>00298 } <a name="l00299"></a>00299 <a name="l00300"></a>00300 <span class="keywordtype">void</span> <a name="l00301"></a><a class="code" href="class_net_viewer.html#a709160288054a93ee1337267c1b40e4a">00301</a> <a class="code" href="class_net_viewer.html#a709160288054a93ee1337267c1b40e4a">NetViewer::addressMapped</a>(<span class="keyword">const</span> QString &from, <span class="keyword">const</span> QString &to, <a name="l00302"></a>00302 <span class="keyword">const</span> QDateTime &expires) <a name="l00303"></a>00303 { <a name="l00304"></a>00304 <a class="code" href="class_net_viewer.html#a47fe551cd0db9aaddab6e8ffbb67f7ea">_addressMap</a>.<a class="code" href="class_address_map.html#a1bb12511981bfe02622253b514748698">add</a>(to, from, expires); <a name="l00305"></a>00305 } <a name="l00306"></a>00306 <span class="comment"></span> <a name="l00307"></a>00307 <span class="comment">/** Called when the user selects the "Help" action from the toolbar. */</span> <a name="l00308"></a>00308 <span class="keywordtype">void</span> <a name="l00309"></a><a class="code" href="class_net_viewer.html#a5deaeec411346de13eaf325c6f49daa1">00309</a> <a class="code" href="class_net_viewer.html#a5deaeec411346de13eaf325c6f49daa1">NetViewer::help</a>() <a name="l00310"></a>00310 { <a name="l00311"></a>00311 emit <a class="code" href="class_vidalia_window.html#add0cc6c3beec0d1e18a3dd467a903e6c">helpRequested</a>(<span class="stringliteral">"netview"</span>); <a name="l00312"></a>00312 } <a name="l00313"></a>00313 <span class="comment"></span> <a name="l00314"></a>00314 <span class="comment">/** Retrieves a list of all running routers from Tor and their descriptors,</span> <a name="l00315"></a>00315 <span class="comment"> * and adds them to the RouterListWidget. */</span> <a name="l00316"></a>00316 <span class="keywordtype">void</span> <a name="l00317"></a><a class="code" href="class_net_viewer.html#a12a32fc2f915d54865e792335f49d496">00317</a> <a class="code" href="class_net_viewer.html#a12a32fc2f915d54865e792335f49d496">NetViewer::loadNetworkStatus</a>() <a name="l00318"></a>00318 { <a name="l00319"></a>00319 <a class="code" href="_router_status_8h.html#a0043af5f764cd62f178e35cbd74f494b">NetworkStatus</a> networkStatus = <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#a43e60487d83b03bf401afddb0a17a60a">getNetworkStatus</a>(); <a name="l00320"></a>00320 <span class="keywordflow">foreach</span> (<a class="code" href="class_router_status.html">RouterStatus</a> rs, networkStatus) { <a name="l00321"></a>00321 <span class="keywordflow">if</span> (!rs.<a class="code" href="class_router_status.html#a23881113b6731e90685d15f9b753634a">isRunning</a>()) <a name="l00322"></a>00322 <span class="keywordflow">continue</span>; <a name="l00323"></a>00323 <a name="l00324"></a>00324 <a class="code" href="class_router_descriptor.html">RouterDescriptor</a> rd = <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#ad308e247d95f72400da3dfaf107477e0">getRouterDescriptor</a>(rs.<a class="code" href="class_router_status.html#ad064c0ddddf64b32eb084eb5e90972d3">id</a>()); <a name="l00325"></a>00325 <span class="keywordflow">if</span> (!rd.<a class="code" href="class_router_descriptor.html#af2f3f41df02ac7c60c5184dc80eeb52f">isEmpty</a>()) <a name="l00326"></a>00326 <a class="code" href="class_net_viewer.html#af830ab3a6452a74e4b323492d54a709c">addRouter</a>(rd); <a name="l00327"></a>00327 } <a name="l00328"></a>00328 } <a name="l00329"></a>00329 <span class="comment"></span> <a name="l00330"></a>00330 <span class="comment">/** Adds a router to our list of servers and retrieves geographic location</span> <a name="l00331"></a>00331 <span class="comment"> * information for the server. */</span> <a name="l00332"></a>00332 <span class="keywordtype">void</span> <a name="l00333"></a><a class="code" href="class_net_viewer.html#af830ab3a6452a74e4b323492d54a709c">00333</a> <a class="code" href="class_net_viewer.html#af830ab3a6452a74e4b323492d54a709c">NetViewer::addRouter</a>(<span class="keyword">const</span> <a class="code" href="class_router_descriptor.html">RouterDescriptor</a> &rd) <a name="l00334"></a>00334 { <a name="l00335"></a>00335 <span class="comment">/* Add the descriptor to the list of server */</span> <a name="l00336"></a>00336 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->addRouter(rd); <a name="l00337"></a>00337 <a name="l00338"></a>00338 <span class="comment">/* Add this IP to a list of addresses whose geographic location we'd like to</span> <a name="l00339"></a>00339 <span class="comment"> * find, but not for special purpose descriptors (e.g., bridges). This</span> <a name="l00340"></a>00340 <span class="comment"> * check is only valid for Tor >= 0.2.0.13-alpha. */</span> <a name="l00341"></a>00341 <span class="keywordflow">if</span> (<a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#acd37862e652425dec4329acef6df4f3e">getTorVersion</a>() >= 0x020013) { <a name="l00342"></a>00342 <a class="code" href="_tor_control_8h.html#a53ee5ca0a1f990092916e579bb23103a">DescriptorAnnotations</a> annotations = <a name="l00343"></a>00343 <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#a98b04340a13e19df051c5d533a4419b1">getDescriptorAnnotations</a>(rd.<a class="code" href="class_router_descriptor.html#afd43d25061bd0e5461bb6e27d680498b">id</a>()); <a name="l00344"></a>00344 <span class="keywordflow">if</span> (!annotations.contains(<span class="stringliteral">"purpose"</span>)) <a name="l00345"></a>00345 <a class="code" href="class_net_viewer.html#a965c1c2a4d9baab50253c8a6c9cb6a3e">addToResolveQueue</a>(rd.<a class="code" href="class_router_descriptor.html#a0ff20382ab48433fecdb03758819c8ed">ip</a>(), rd.<a class="code" href="class_router_descriptor.html#afd43d25061bd0e5461bb6e27d680498b">id</a>()); <a name="l00346"></a>00346 } <span class="keywordflow">else</span> { <a name="l00347"></a>00347 <a class="code" href="class_net_viewer.html#a965c1c2a4d9baab50253c8a6c9cb6a3e">addToResolveQueue</a>(rd.<a class="code" href="class_router_descriptor.html#a0ff20382ab48433fecdb03758819c8ed">ip</a>(), rd.<a class="code" href="class_router_descriptor.html#afd43d25061bd0e5461bb6e27d680498b">id</a>()); <a name="l00348"></a>00348 } <a name="l00349"></a>00349 } <a name="l00350"></a>00350 <span class="comment"></span> <a name="l00351"></a>00351 <span class="comment">/** Called when a NEWDESC event arrives. Retrieves new router descriptors</span> <a name="l00352"></a>00352 <span class="comment"> * for the router identities given in <b>ids</b> and updates the router</span> <a name="l00353"></a>00353 <span class="comment"> * list and network map. */</span> <a name="l00354"></a>00354 <span class="keywordtype">void</span> <a name="l00355"></a><a class="code" href="class_net_viewer.html#ab5c243bf39e784335463c07412861208">00355</a> <a class="code" href="class_net_viewer.html#ab5c243bf39e784335463c07412861208">NetViewer::newDescriptors</a>(<span class="keyword">const</span> QStringList &ids) <a name="l00356"></a>00356 { <a name="l00357"></a>00357 <span class="keywordflow">foreach</span> (QString <span class="keywordtype">id</span>, ids) { <a name="l00358"></a>00358 <a class="code" href="class_router_descriptor.html">RouterDescriptor</a> rd = <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#ad308e247d95f72400da3dfaf107477e0">getRouterDescriptor</a>(<span class="keywordtype">id</span>); <a name="l00359"></a>00359 <span class="keywordflow">if</span> (!rd.<a class="code" href="class_router_descriptor.html#af2f3f41df02ac7c60c5184dc80eeb52f">isEmpty</a>()) <a name="l00360"></a>00360 <a class="code" href="class_net_viewer.html#af830ab3a6452a74e4b323492d54a709c">addRouter</a>(rd); <span class="comment">/* Updates the existing entry */</span> <a name="l00361"></a>00361 } <a name="l00362"></a>00362 } <a name="l00363"></a>00363 <span class="comment"></span> <a name="l00364"></a>00364 <span class="comment">/** Adds an IP address to the resolve queue and updates the queue timers. */</span> <a name="l00365"></a>00365 <span class="keywordtype">void</span> <a name="l00366"></a><a class="code" href="class_net_viewer.html#a965c1c2a4d9baab50253c8a6c9cb6a3e">00366</a> <a class="code" href="class_net_viewer.html#a965c1c2a4d9baab50253c8a6c9cb6a3e">NetViewer::addToResolveQueue</a>(<span class="keyword">const</span> QHostAddress &ip, <span class="keyword">const</span> QString &<span class="keywordtype">id</span>) <a name="l00367"></a>00367 { <a name="l00368"></a>00368 QString ipstr = ip.toString(); <a name="l00369"></a>00369 <span class="keywordflow">if</span> (!<a class="code" href="class_net_viewer.html#aecff4f08a117d47ccefd2a3c95abdd8d">_resolveMap</a>.values(ipstr).contains(<span class="keywordtype">id</span>)) { <a name="l00370"></a>00370 <span class="comment">/* Remember which server ids belong to which IP addresses */</span> <a name="l00371"></a>00371 <a class="code" href="class_net_viewer.html#aecff4f08a117d47ccefd2a3c95abdd8d">_resolveMap</a>.insertMulti(ipstr, <span class="keywordtype">id</span>); <a name="l00372"></a>00372 } <a name="l00373"></a>00373 <a name="l00374"></a>00374 <span class="keywordflow">if</span> (!<a class="code" href="class_net_viewer.html#a0ceba335e7eb56875c1f3fb59d646334">_resolveQueue</a>.contains(ip) && !<a class="code" href="class_net_viewer.html#a288067cdbae084a8490adb059adf8b85">_geoip</a>.<a class="code" href="class_geo_ip_resolver.html#a1e76963e27407d363a1fb9664f1ff4d3">resolveFromCache</a>(ip)) { <a name="l00375"></a>00375 <span class="comment">/* Add the IP to the queue of IPs waiting for geographic information */</span> <a name="l00376"></a>00376 <a class="code" href="class_net_viewer.html#a0ceba335e7eb56875c1f3fb59d646334">_resolveQueue</a> << ip; <a name="l00377"></a>00377 <a name="l00378"></a>00378 <span class="comment">/* Wait MIN_RESOLVE_QUEUE_DELAY after the last item inserted into the</span> <a name="l00379"></a>00379 <span class="comment"> * queue, before sending the resolve request. */</span> <a name="l00380"></a>00380 <a class="code" href="class_net_viewer.html#a67bc5955adb4d0489f6543a79633748b">_minResolveQueueTimer</a>.start(<a class="code" href="_net_viewer_8cpp.html#a5aeafc35346022f9261580d7d2cae234">MIN_RESOLVE_QUEUE_DELAY</a>); <a name="l00381"></a>00381 <a name="l00382"></a>00382 <span class="comment">/* Do not wait longer than MAX_RESOLVE_QUEUE_DELAY from the time the first</span> <a name="l00383"></a>00383 <span class="comment"> * item is inserted into the queue, before flushing and resolving the</span> <a name="l00384"></a>00384 <span class="comment"> * queue. */</span> <a name="l00385"></a>00385 <span class="keywordflow">if</span> (<a class="code" href="class_net_viewer.html#a0ceba335e7eb56875c1f3fb59d646334">_resolveQueue</a>.size() == 1) { <a name="l00386"></a>00386 <a class="code" href="class_net_viewer.html#aa98ce54d7106f5013d3265f9c5f012dd">_maxResolveQueueTimer</a>.start(<a class="code" href="_net_viewer_8cpp.html#a183f55806c36b82335366b6fc2e5edd3">MAX_RESOLVE_QUEUE_DELAY</a>); <a name="l00387"></a>00387 } <a name="l00388"></a>00388 } <a name="l00389"></a>00389 } <a name="l00390"></a>00390 <span class="comment"></span> <a name="l00391"></a>00391 <span class="comment">/** Called when the user selects a circuit from the circuit and streams</span> <a name="l00392"></a>00392 <span class="comment"> * list. */</span> <a name="l00393"></a>00393 <span class="keywordtype">void</span> <a name="l00394"></a><a class="code" href="class_net_viewer.html#afc09031d4b84b823f213b78aa102669f">00394</a> <a class="code" href="class_net_viewer.html#afc09031d4b84b823f213b78aa102669f">NetViewer::circuitSelected</a>(<span class="keyword">const</span> <a class="code" href="class_circuit.html">Circuit</a> &circuit) <a name="l00395"></a>00395 { <a name="l00396"></a>00396 <span class="comment">/* Clear any selected items. */</span> <a name="l00397"></a>00397 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->deselectAll(); <a name="l00398"></a>00398 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.textRouterInfo->clear(); <a name="l00399"></a>00399 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>-><a class="code" href="class_tor_map_image_view.html#a541d6537c5579d617bc832f1a4f28bc5">deselectAll</a>(); <a name="l00400"></a>00400 <a name="l00401"></a>00401 <span class="comment">/* Select the items on the map and in the list */</span> <a name="l00402"></a>00402 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>-><a class="code" href="class_tor_map_image_view.html#a0e50ca9ddd6c27a27c106d52f44a814c">selectCircuit</a>(circuit.<a class="code" href="class_circuit.html#a3083f9c330227c6f46b3ab32e071f7be">id</a>()); <a name="l00403"></a>00403 <a name="l00404"></a>00404 QList<RouterDescriptor> routers; <a name="l00405"></a>00405 <a name="l00406"></a>00406 <span class="keywordflow">foreach</span> (QString <span class="keywordtype">id</span>, circuit.<a class="code" href="class_circuit.html#a42535367967ed99c8b9b312dad11067d">routerIDs</a>()) { <a name="l00407"></a>00407 <span class="comment">/* Try to find and select each router in the path */</span> <a name="l00408"></a>00408 <a class="code" href="class_router_list_item.html">RouterListItem</a> *item = <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->findRouterById(<span class="keywordtype">id</span>); <a name="l00409"></a>00409 <span class="keywordflow">if</span> (item) <a name="l00410"></a>00410 routers.append(item-><a class="code" href="class_router_list_item.html#a674fe77dae14cbdbc423ea573ce40d4c">descriptor</a>()); <a name="l00411"></a>00411 } <a name="l00412"></a>00412 <a name="l00413"></a>00413 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.textRouterInfo->display(routers); <a name="l00414"></a>00414 } <a name="l00415"></a>00415 <span class="comment"></span> <a name="l00416"></a>00416 <span class="comment">/** Called when the user selects one or more routers from the router list. */</span> <a name="l00417"></a>00417 <span class="keywordtype">void</span> <a name="l00418"></a><a class="code" href="class_net_viewer.html#a66c6c7a9b0222dbb0c980d6792bd95bd">00418</a> <a class="code" href="class_net_viewer.html#a66c6c7a9b0222dbb0c980d6792bd95bd">NetViewer::routerSelected</a>(<span class="keyword">const</span> QList<RouterDescriptor> &routers) <a name="l00419"></a>00419 { <a name="l00420"></a>00420 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>-><a class="code" href="class_tor_map_image_view.html#a541d6537c5579d617bc832f1a4f28bc5">deselectAll</a>(); <a name="l00421"></a>00421 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.textRouterInfo->clear(); <a name="l00422"></a>00422 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.textRouterInfo->display(routers); <a name="l00423"></a>00423 <a name="l00424"></a>00424 <span class="comment">/* XXX: Ideally we would also be able to select multiple pinpoints on the</span> <a name="l00425"></a>00425 <span class="comment"> * map. But our current map sucks and you can't even tell when one is</span> <a name="l00426"></a>00426 <span class="comment"> * selected anyway. Worry about this when we actually get to Marble.</span> <a name="l00427"></a>00427 <span class="comment"> */</span> <a name="l00428"></a>00428 <span class="keywordflow">if</span> (routers.size() == 1) <a name="l00429"></a>00429 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>-><a class="code" href="class_tor_map_image_view.html#a466796654c6b21473791c7bfa8ffdf0d">selectRouter</a>(routers[0].id()); <a name="l00430"></a>00430 } <a name="l00431"></a>00431 <span class="comment"></span> <a name="l00432"></a>00432 <span class="comment">/** If there are any IPs in the resolve queue, do the request now. */</span> <a name="l00433"></a>00433 <span class="keywordtype">void</span> <a name="l00434"></a><a class="code" href="class_net_viewer.html#a5055d97ac042d2cafd6bb3b36a8d69fd">00434</a> <a class="code" href="class_net_viewer.html#a5055d97ac042d2cafd6bb3b36a8d69fd">NetViewer::resolve</a>() <a name="l00435"></a>00435 { <a name="l00436"></a>00436 <span class="keywordflow">if</span> (!<a class="code" href="class_net_viewer.html#a0ceba335e7eb56875c1f3fb59d646334">_resolveQueue</a>.isEmpty()) { <a name="l00437"></a>00437 <span class="comment">/* Send the request now if either the network map is visible, or the</span> <a name="l00438"></a>00438 <span class="comment"> * request is for more than a quarter of the servers in the list. */</span> <a name="l00439"></a>00439 <span class="keywordflow">if</span> (isVisible() || <a name="l00440"></a>00440 (<a class="code" href="class_net_viewer.html#a0ceba335e7eb56875c1f3fb59d646334">_resolveQueue</a>.size() >= <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->topLevelItemCount()/4)) { <a name="l00441"></a>00441 <a class="code" href="_vidalia_8h.html#a7743cb328f470aa8f382716fbcf61daa">vInfo</a>(<span class="stringliteral">"Sending GeoIP request for %1 IP addresses."</span>) <a name="l00442"></a>00442 .arg(<a class="code" href="class_net_viewer.html#a0ceba335e7eb56875c1f3fb59d646334">_resolveQueue</a>.size()); <a name="l00443"></a>00443 <span class="comment">/* Flush the resolve queue and stop the timers */</span> <a name="l00444"></a>00444 <a class="code" href="class_net_viewer.html#a288067cdbae084a8490adb059adf8b85">_geoip</a>.<a class="code" href="class_geo_ip_resolver.html#add5208876f34e8f938643e7ca57ea06b">resolve</a>(<a class="code" href="class_net_viewer.html#a0ceba335e7eb56875c1f3fb59d646334">_resolveQueue</a>); <a name="l00445"></a>00445 <a class="code" href="class_net_viewer.html#a0ceba335e7eb56875c1f3fb59d646334">_resolveQueue</a>.clear(); <a name="l00446"></a>00446 } <a name="l00447"></a>00447 } <a name="l00448"></a>00448 <span class="comment">/* Stop the queue timers. Only one should be active since the other is what</span> <a name="l00449"></a>00449 <span class="comment"> * called this slot, but calling stop() on a stopped timer does not hurt. */</span> <a name="l00450"></a>00450 <a class="code" href="class_net_viewer.html#a67bc5955adb4d0489f6543a79633748b">_minResolveQueueTimer</a>.stop(); <a name="l00451"></a>00451 <a class="code" href="class_net_viewer.html#aa98ce54d7106f5013d3265f9c5f012dd">_maxResolveQueueTimer</a>.stop(); <a name="l00452"></a>00452 } <a name="l00453"></a>00453 <span class="comment"></span> <a name="l00454"></a>00454 <span class="comment">/** Called when a list of GeoIp information has been resolved. */</span> <a name="l00455"></a>00455 <span class="keywordtype">void</span> <a name="l00456"></a><a class="code" href="class_net_viewer.html#a3cbf9f1953bf0c1abaa6781a7de68476">00456</a> <a class="code" href="class_net_viewer.html#a3cbf9f1953bf0c1abaa6781a7de68476">NetViewer::resolved</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keyword">const</span> QList<GeoIp> &geoips) <a name="l00457"></a>00457 { <a name="l00458"></a>00458 Q_UNUSED(<span class="keywordtype">id</span>); <a name="l00459"></a>00459 <a name="l00460"></a>00460 QString ip; <a name="l00461"></a>00461 <a class="code" href="class_router_list_item.html">RouterListItem</a> *router; <a name="l00462"></a>00462 <a name="l00463"></a>00463 <span class="keywordflow">foreach</span> (<a class="code" href="class_geo_ip.html">GeoIp</a> geoip, geoips) { <a name="l00464"></a>00464 <span class="comment">/* Find all routers that are at this IP address */</span> <a name="l00465"></a>00465 ip = geoip.<a class="code" href="class_geo_ip.html#a054c1b4097bc3cb0bbdd30d4bd8ed6d2">ip</a>().toString(); <a name="l00466"></a>00466 QList<QString> ids = <a class="code" href="class_net_viewer.html#aecff4f08a117d47ccefd2a3c95abdd8d">_resolveMap</a>.values(ip); <a name="l00467"></a>00467 <a class="code" href="class_net_viewer.html#aecff4f08a117d47ccefd2a3c95abdd8d">_resolveMap</a>.remove(ip); <a name="l00468"></a>00468 <a name="l00469"></a>00469 <span class="comment">/* Update their geographic location information with the results of this</span> <a name="l00470"></a>00470 <span class="comment"> * GeoIP query. */</span> <a name="l00471"></a>00471 <span class="keywordflow">foreach</span> (QString <span class="keywordtype">id</span>, ids) { <a name="l00472"></a>00472 router = <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->findRouterById(<span class="keywordtype">id</span>); <a name="l00473"></a>00473 <span class="keywordflow">if</span> (router) { <a name="l00474"></a>00474 <span class="comment">/* Save the location information in the descriptor */</span> <a name="l00475"></a>00475 router-><a class="code" href="class_router_list_item.html#a976336456eb871ddae9a805c3fb8fb47">setLocation</a>(geoip); <a name="l00476"></a>00476 <span class="comment">/* Plot the router on the map */</span> <a name="l00477"></a>00477 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>-><a class="code" href="class_tor_map_image_view.html#af46508fdc7b262995ccc63a890d637ea">addRouter</a>(router-><a class="code" href="class_router_list_item.html#a674fe77dae14cbdbc423ea573ce40d4c">descriptor</a>(), geoip); <a name="l00478"></a>00478 } <a name="l00479"></a>00479 } <a name="l00480"></a>00480 } <a name="l00481"></a>00481 <a name="l00482"></a>00482 <span class="comment">/* Update the circuit lines */</span> <a name="l00483"></a>00483 <span class="keywordflow">foreach</span> (<a class="code" href="class_circuit.html">Circuit</a> circuit, <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeCircuitList->circuits()) { <a name="l00484"></a>00484 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>-><a class="code" href="class_tor_map_image_view.html#a36237d226f686d3c5868c2e10b8100ef">addCircuit</a>(circuit.<a class="code" href="class_circuit.html#a3083f9c330227c6f46b3ab32e071f7be">id</a>(), circuit.<a class="code" href="class_circuit.html#a42535367967ed99c8b9b312dad11067d">routerIDs</a>()); <a name="l00485"></a>00485 } <a name="l00486"></a>00486 <a name="l00487"></a>00487 <span class="comment">/* Repaint the map */</span> <a name="l00488"></a>00488 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->update(); <a name="l00489"></a>00489 } <a name="l00490"></a>00490 <span class="comment"></span> <a name="l00491"></a>00491 <span class="comment">/** Called when the user selects a router on the network map. Displays a </span> <a name="l00492"></a>00492 <span class="comment"> * dialog with detailed information for the router specified by</span> <a name="l00493"></a>00493 <span class="comment"> * <b>id</b>.*/</span> <a name="l00494"></a>00494 <span class="keywordtype">void</span> <a name="l00495"></a><a class="code" href="class_net_viewer.html#a4d88759346d479e9c8abdeb04f23b52e">00495</a> <a class="code" href="class_net_viewer.html#a4d88759346d479e9c8abdeb04f23b52e">NetViewer::displayRouterInfo</a>(<span class="keyword">const</span> QString &<span class="keywordtype">id</span>) <a name="l00496"></a>00496 { <a name="l00497"></a>00497 <a class="code" href="class_router_info_dialog.html">RouterInfoDialog</a> dlg(<a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->isFullScreen() ? <span class="keyword">static_cast<</span>QWidget*<span class="keyword">></span>(<a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>) <a name="l00498"></a>00498 : static_cast<QWidget*>(<span class="keyword">this</span>)); <a name="l00499"></a>00499 <a name="l00500"></a>00500 <span class="comment">/* Fetch the specified router's descriptor */</span> <a name="l00501"></a>00501 QStringList rd = <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#a4e1892fd5e35f076ac199936c3446b53">getRouterDescriptorText</a>(<span class="keywordtype">id</span>); <a name="l00502"></a>00502 <span class="keywordflow">if</span> (rd.isEmpty()) { <a name="l00503"></a>00503 <a class="code" href="class_v_message_box.html#ab13cdbaf47040d9c0312ba5854185b15">VMessageBox::warning</a>(<span class="keyword">this</span>, tr(<span class="stringliteral">"Relay Not Found"</span>), <a name="l00504"></a>00504 tr(<span class="stringliteral">"No details on the selected relay are available."</span>), <a name="l00505"></a>00505 <a class="code" href="class_v_message_box.html#ad9a3aafc6d9076268b6b4b6b1357fe0aafc0d4bb792dca848f92d28e60dec4fe4">VMessageBox::Ok</a>); <a name="l00506"></a>00506 <span class="keywordflow">return</span>; <a name="l00507"></a>00507 } <a name="l00508"></a>00508 <a name="l00509"></a>00509 <span class="comment">/* Fetch the router's network status information */</span> <a name="l00510"></a>00510 <a class="code" href="class_router_status.html">RouterStatus</a> rs = <a class="code" href="class_net_viewer.html#a364fc90e5497271c8e93655f1f54329e">_torControl</a>-><a class="code" href="class_tor_control.html#a25362380480443a5c1cbe37b64efee1c">getRouterStatus</a>(<span class="keywordtype">id</span>); <a name="l00511"></a>00511 <a name="l00512"></a>00512 dlg.setRouterInfo(rd, rs); <a name="l00513"></a>00513 <a name="l00514"></a>00514 <span class="comment">/* Populate the UI with information learned from a previous GeoIP request */</span> <a name="l00515"></a>00515 <a class="code" href="class_router_list_item.html">RouterListItem</a> *item = <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.treeRouterList->findRouterById(<span class="keywordtype">id</span>); <a name="l00516"></a>00516 <span class="keywordflow">if</span> (item) <a name="l00517"></a>00517 dlg.setLocation(item-><a class="code" href="class_router_list_item.html#aea28c51e0e9a581ee8b7504652720ab5">location</a>()); <a name="l00518"></a>00518 <span class="keywordflow">else</span> <a name="l00519"></a>00519 dlg.setLocation(tr(<span class="stringliteral">"Unknown"</span>)); <a name="l00520"></a>00520 <a name="l00521"></a>00521 dlg.exec(); <a name="l00522"></a>00522 } <a name="l00523"></a>00523 <a name="l00524"></a>00524 <span class="comment">/* XXX: The following zoomIn() and zoomOut() slots are a hack. MarbleWidget</span> <a name="l00525"></a>00525 <span class="comment"> * does have zoomIn() and zoomOut() slots to which we could connect the</span> <a name="l00526"></a>00526 <span class="comment"> * buttons, but these slots currently don't force a repaint. So to see</span> <a name="l00527"></a>00527 <span class="comment"> * the zoom effect, the user has to click on the map after clicking one</span> <a name="l00528"></a>00528 <span class="comment"> * of the zoom buttons. Instead, we use the zoomViewBy() method, which</span> <a name="l00529"></a>00529 <span class="comment"> * DOES force a repaint.</span> <a name="l00530"></a>00530 <span class="comment"> */</span><span class="comment"></span> <a name="l00531"></a>00531 <span class="comment">/** Called when the user clicks the "Zoom In" button. */</span> <a name="l00532"></a>00532 <span class="keywordtype">void</span> <a name="l00533"></a><a class="code" href="class_net_viewer.html#ae0181ea07d0b7c70f86f671ed73a4689">00533</a> <a class="code" href="class_net_viewer.html#ae0181ea07d0b7c70f86f671ed73a4689">NetViewer::zoomIn</a>() <a name="l00534"></a>00534 { <a name="l00535"></a>00535 <span class="preprocessor">#if defined(USE_MARBLE)</span> <a name="l00536"></a>00536 <span class="preprocessor"></span> <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->zoomViewBy(40); <a name="l00537"></a>00537 <span class="preprocessor">#else</span> <a name="l00538"></a>00538 <span class="preprocessor"></span> <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>-><a class="code" href="class_z_image_view.html#a68c4dcf1561fa920240db2843525d4f6">zoomIn</a>(); <a name="l00539"></a>00539 <span class="preprocessor">#endif</span> <a name="l00540"></a>00540 <span class="preprocessor"></span>} <a name="l00541"></a>00541 <span class="comment"></span> <a name="l00542"></a>00542 <span class="comment">/** Called when the user clicks the "Zoom Out" button. */</span> <a name="l00543"></a>00543 <span class="keywordtype">void</span> <a name="l00544"></a><a class="code" href="class_net_viewer.html#a1fed32d4085f58f95536f77d9c758af8">00544</a> <a class="code" href="class_net_viewer.html#a1fed32d4085f58f95536f77d9c758af8">NetViewer::zoomOut</a>() <a name="l00545"></a>00545 { <a name="l00546"></a>00546 <span class="preprocessor">#if defined(USE_MARBLE)</span> <a name="l00547"></a>00547 <span class="preprocessor"></span> <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->zoomViewBy(-40); <a name="l00548"></a>00548 <span class="preprocessor">#else</span> <a name="l00549"></a>00549 <span class="preprocessor"></span> <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>-><a class="code" href="class_z_image_view.html#ac75ff5e4efacd591a4d40e0b00ec66ef">zoomOut</a>(); <a name="l00550"></a>00550 <span class="preprocessor">#endif</span> <a name="l00551"></a>00551 <span class="preprocessor"></span>} <a name="l00552"></a>00552 <span class="comment"></span> <a name="l00553"></a>00553 <span class="comment">/** Called when the user clicks "Full Screen" or presses Escape on the map.</span> <a name="l00554"></a>00554 <span class="comment"> * Toggles the map between normal and a full screen viewing modes. */</span> <a name="l00555"></a>00555 <span class="keywordtype">void</span> <a name="l00556"></a><a class="code" href="class_net_viewer.html#acc056faebc021de5c67ba5d7684140e3">00556</a> <a class="code" href="class_net_viewer.html#acc056faebc021de5c67ba5d7684140e3">NetViewer::toggleFullScreen</a>() <a name="l00557"></a>00557 { <a name="l00558"></a>00558 <span class="keywordflow">if</span> (<a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->isFullScreen()) { <a name="l00559"></a>00559 <span class="comment">/* Disabling full screen mode. Put the map back in its container. */</span> <a name="l00560"></a>00560 <a class="code" href="class_net_viewer.html#a78a6382f956c9bb177925c8213a1a9a7">ui</a>.gridLayout->addWidget(<a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>); <a name="l00561"></a>00561 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->setWindowState(<a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->windowState() & ~Qt::WindowFullScreen); <a name="l00562"></a>00562 } <span class="keywordflow">else</span> { <a name="l00563"></a>00563 <span class="comment">/* Enabling full screen mode. Remove the map from the QGridLayout</span> <a name="l00564"></a>00564 <span class="comment"> * container and set its window state to full screen. */</span> <a name="l00565"></a>00565 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->setParent(0); <a name="l00566"></a>00566 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->setWindowState(<a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->windowState() | Qt::WindowFullScreen); <a name="l00567"></a>00567 <a class="code" href="class_net_viewer.html#aca441c0f084c7e3f17756bd0eca2a091">_map</a>->show(); <a name="l00568"></a>00568 } <a name="l00569"></a>00569 } <a name="l00570"></a>00570 </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Mon Aug 30 22:58:54 2010 for Vidalia by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>