[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2977: Create CircuitId and StreamId typedefs with QString as their (in vidalia/trunk/src: torcontrol vidalia/network)
Author: edmanm
Date: 2008-08-16 21:28:25 -0400 (Sat, 16 Aug 2008)
New Revision: 2977
Modified:
vidalia/trunk/src/torcontrol/circuit.cpp
vidalia/trunk/src/torcontrol/circuit.h
vidalia/trunk/src/torcontrol/circuitevent.h
vidalia/trunk/src/torcontrol/stream.cpp
vidalia/trunk/src/torcontrol/stream.h
vidalia/trunk/src/torcontrol/streamevent.h
vidalia/trunk/src/torcontrol/torcontrol.cpp
vidalia/trunk/src/torcontrol/torcontrol.h
vidalia/trunk/src/vidalia/network/circuititem.cpp
vidalia/trunk/src/vidalia/network/circuititem.h
vidalia/trunk/src/vidalia/network/circuitlistwidget.cpp
vidalia/trunk/src/vidalia/network/circuitlistwidget.h
vidalia/trunk/src/vidalia/network/netviewer.cpp
vidalia/trunk/src/vidalia/network/netviewer.h
vidalia/trunk/src/vidalia/network/streamitem.h
vidalia/trunk/src/vidalia/network/tormapwidget.cpp
vidalia/trunk/src/vidalia/network/tormapwidget.h
Log:
Create CircuitId and StreamId typedefs with QString as their underlying type,
and switch all circuit and stream function calls to use these new types. Fixes
ticket #400.
Modified: vidalia/trunk/src/torcontrol/circuit.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/circuit.cpp 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/torcontrol/circuit.cpp 2008-08-17 01:28:25 UTC (rev 2977)
@@ -17,13 +17,13 @@
#include <QStringList>
#include <QRegExp>
+#include "tcglobal.h"
#include "circuit.h"
/** Default constructor. */
Circuit::Circuit()
{
- _circId = 0;
_status = Unknown;
_isValid = false;
}
@@ -38,12 +38,13 @@
*/
Circuit::Circuit(const QString &circuit)
{
- _isValid = false;
-
- QStringList parts = circuit.split(" ");
+ QStringList parts = circuit.split(" ", QString::SkipEmptyParts);
if (parts.size() >= 2) {
/* Get the circuit ID */
- _circId = (quint64)parts.at(0).toULongLong();
+ _circId = parts.at(0);
+ if (! isValidCircuitId(_circId))
+ goto err;
+
/* Get the circuit status value */
_status = Circuit::toStatus(parts.at(1));
@@ -52,7 +53,7 @@
foreach (QString hop, parts.at(2).split(",")) {
QStringList parts = hop.split(QRegExp("[=~]"));
if (parts.size() != 2)
- return;
+ goto err;
_ids << parts.at(0).mid(1);
_names << parts.at(1);
@@ -61,8 +62,30 @@
_isValid = true;
}
+ return;
+
+err:
+ tc::warn("Improperly formatted circuit: '%1'").arg(circuit);
+ _isValid = false;
}
+/** Returns true iff <b>circId</b> consists of only between 1 and 16
+ * (inclusive) ASCII-encoded letters and numbers. */
+bool
+Circuit::isValidCircuitId(const CircuitId &circId)
+{
+ int length = circId.length();
+ if (length < 1 || length > 16)
+ return false;
+
+ for (int i = 0; i < length; i++) {
+ char c = circId[i].toAscii();
+ if (c < '0' && c > '9' && c < 'A' && c > 'Z' && c < 'a' && c > 'z')
+ return false;
+ }
+ return true;
+}
+
/** Converts the circuit status string to its proper enum value */
Circuit::Status
Circuit::toStatus(const QString &status)
Modified: vidalia/trunk/src/torcontrol/circuit.h
===================================================================
--- vidalia/trunk/src/torcontrol/circuit.h 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/torcontrol/circuit.h 2008-08-17 01:28:25 UTC (rev 2977)
@@ -20,7 +20,10 @@
#include <QCoreApplication>
#include <QStringList>
+/** Circuit IDs contains 1-16 alphanumeric ASCII characters. */
+typedef QString CircuitId;
+
class Circuit
{
Q_DECLARE_TR_FUNCTIONS(Circuit)
@@ -39,13 +42,13 @@
/** Default constructor. */
Circuit();
/** Constructor. */
- Circuit(const QString &circuit);
+ Circuit(const CircuitId &circuit);
/** Returns true if this circuit is valid. */
bool isValid() const { return _isValid; }
/** Returns the ID for this circuit */
- quint64 id() const { return _circId; }
+ CircuitId id() const { return _circId; }
/** Returns the status of this circuit */
Status status() const { return _status; }
/** Returns a string representation of the status of this circuit. */
@@ -60,8 +63,12 @@
/** Converts a string description of a circuit's status to an enum value */
static Status toStatus(const QString &strStatus);
+ /** Returns true iff <b>circId</b> consists of only between 1 and 16
+ * (inclusive) ASCII-encoded letters and numbers. */
+ static bool isValidCircuitId(const CircuitId &circId);
+
private:
- quint64 _circId; /**< Circuit ID. */
+ CircuitId _circId; /**< Circuit ID. */
Status _status; /**< Circuit status. */
QStringList _names; /**< Nicknames of the routers in the circuit. */
QStringList _ids; /**< IDs of the routers in the circuit. */
Modified: vidalia/trunk/src/torcontrol/circuitevent.h
===================================================================
--- vidalia/trunk/src/torcontrol/circuitevent.h 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/torcontrol/circuitevent.h 2008-08-17 01:28:25 UTC (rev 2977)
@@ -18,6 +18,7 @@
#define _CIRCUITEVENT_H
#include <QEvent>
+#include <QString>
#include "eventtype.h"
#include "circuit.h"
@@ -34,7 +35,7 @@
/** Returns the Circuit object for this event. */
Circuit circuit() const { return _circuit; }
/** Returns the ID for this circuit event. */
- quint64 id() const { return _circuit.id(); }
+ CircuitId id() const { return _circuit.id(); }
/** Returns the status of this circuit event. */
Circuit::Status status() const { return _circuit.status(); }
/** Returns the names of the routers in the path for this circuit event. */
Modified: vidalia/trunk/src/torcontrol/stream.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/stream.cpp 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/torcontrol/stream.cpp 2008-08-17 01:28:25 UTC (rev 2977)
@@ -15,22 +15,22 @@
*/
#include <QStringList>
-
+
+#include "circuit.h"
#include "stream.h"
/** Default constructor. */
Stream::Stream()
{
- _streamId = 0;
_status = Unknown;
- _circuitId = 0;
_port = 0;
}
/** Constructor */
-Stream::Stream(quint64 streamId, Status status, quint64 circuitId,
- QString address, quint16 port)
+Stream::Stream(const StreamId &streamId, Status status,
+ const CircuitId &circuitId, const QString &address,
+ quint16 port)
{
_streamId = streamId;
_status = status;
@@ -40,7 +40,8 @@
}
/** Constructor */
-Stream::Stream(quint64 streamId, Status status, quint64 circuitId, QString target)
+Stream::Stream(const StreamId &streamId, Status status,
+ const CircuitId &circuitId, const QString &target)
{
_streamId = streamId;
_status = status;
@@ -60,16 +61,16 @@
* StreamID SP StreamStatus SP CircID SP Target
*/
Stream
-Stream::fromString(QString stream)
+Stream::fromString(const QString &stream)
{
- QStringList parts = stream.split(" ");
+ QStringList parts = stream.split(" ", QString::SkipEmptyParts);
if (parts.size() >= 4) {
/* Get the stream ID */
- quint64 streamId = (quint64)parts.at(0).toULongLong();
+ StreamId streamId = parts.at(0);
/* Get the stream status value */
Stream::Status status = Stream::toStatus(parts.at(1));
/* Get the ID of the circuit on which this stream travels */
- quint64 circId = (quint64)parts.at(2).toULongLong();
+ CircuitId circId = parts.at(2);
/* Get the target address for this stream */
QString target = parts.at(3);
@@ -78,34 +79,46 @@
return Stream();
}
+/** Returns true iff <b>streamId</b> consists of only between 1 and 16
+ * (inclusive) ASCII-encoded letters and numbers. */
+bool
+Stream::isValidStreamId(const StreamId &streamId)
+{
+ int length = streamId.length();
+ if (length < 1 || length > 16)
+ return false;
+
+ for (int i = 0; i < length; i++) {
+ char c = streamId[i].toAscii();
+ if (c < '0' && c > '9' && c < 'A' && c > 'Z' && c < 'a' && c > 'z')
+ return false;
+ }
+ return true;
+}
+
/** Converts a string description of a stream's status to its enum value */
Stream::Status
-Stream::toStatus(QString strStatus)
+Stream::toStatus(const QString &strStatus)
{
- Status status;
- strStatus = strStatus.toUpper();
- if (strStatus == "NEW") {
- status = New;
- } else if (strStatus == "NEWRESOLVE") {
- status = NewResolve;
- } else if (strStatus == "SENTCONNECT") {
- status = SentConnect;
- } else if (strStatus == "SENTRESOLVE") {
- status = SentResolve;
- } else if (strStatus == "SUCCEEDED") {
- status = Succeeded;
- } else if (strStatus == "FAILED") {
- status = Failed;
- } else if (strStatus == "CLOSED") {
- status = Closed;
- } else if (strStatus == "DETACHED") {
- status = Detached;
- } else if (strStatus == "REMAP") {
- status = Remap;
- } else {
- status = Unknown;
- }
- return status;
+ if (!strStatus.compare("NEW", Qt::CaseInsensitive))
+ return New;
+ if (!strStatus.compare("NEWRESOLVE", Qt::CaseInsensitive))
+ return NewResolve;
+ if (!strStatus.compare("SENTCONNECT", Qt::CaseInsensitive))
+ return SentConnect;
+ if (!strStatus.compare("SENTRESOLVE", Qt::CaseInsensitive))
+ return SentResolve;
+ if (!strStatus.compare("SUCCEEDED", Qt::CaseInsensitive))
+ return Succeeded;
+ if (!strStatus.compare("FAILED", Qt::CaseInsensitive))
+ return Failed;
+ if (!strStatus.compare("CLOSED", Qt::CaseInsensitive))
+ return Closed;
+ if (!strStatus.compare("DETACHED", Qt::CaseInsensitive))
+ return Detached;
+ if (!strStatus.compare("REMAP", Qt::CaseInsensitive))
+ return Remap;
+ return Unknown;
}
/** Returns a human-understandable string representation of this
@@ -129,11 +142,13 @@
return status;
}
-/** Returns true if all fields in this Stream object are empty. */
+/** Returns true if all fields in this Stream object are valid. */
bool
-Stream::isEmpty() const
+Stream::isValid() const
{
- return (!_streamId && !_circuitId &&
- (_status == Unknown) && _address.isEmpty() && !_port);
+ return (isValidStreamId(_streamId)
+ && Circuit::isValidCircuitId(_circuitId)
+ && (_status != Unknown)
+ && !_address.isEmpty());
}
Modified: vidalia/trunk/src/torcontrol/stream.h
===================================================================
--- vidalia/trunk/src/torcontrol/stream.h 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/torcontrol/stream.h 2008-08-17 01:28:25 UTC (rev 2977)
@@ -22,7 +22,12 @@
#include <QObject>
#include <QList>
+#include "circuit.h"
+/** Stream IDs contains 1-16 alphanumeric ASCII characters. */
+typedef QString StreamId;
+
+
class Stream
{
Q_DECLARE_TR_FUNCTIONS(Stream)
@@ -45,27 +50,28 @@
/** Default constructor */
Stream();
/** Constructor */
- Stream(quint64 streamId, Status status, quint64 circuitId, QString target);
+ Stream(const StreamId &streamId, Status status, const CircuitId &circuitId,
+ const QString &target);
/** Constructor */
- Stream(quint64 streamId, Status status, quint64 circuitId,
- QString address, quint16 port);
+ Stream(const StreamId &streamId, Status status, const CircuitId &circuitId,
+ const QString &address, quint16 port);
/** Parses the given string for a stream, in Tor control protocol format. */
- static Stream fromString(QString stream);
+ static Stream fromString(const QString &stream);
/** Converts a string description of a stream's status to its enum value */
- static Status toStatus(QString strStatus);
+ static Status toStatus(const QString &strStatus);
- /** Returns true if the Stream object's fields are all empty. */
- bool isEmpty() const;
+ /** Returns true iff the Stream object's fields are all valid. */
+ bool isValid() const;
/** Returns the ID for this stream. */
- quint64 id() const { return _streamId; }
+ StreamId id() const { return _streamId; }
/** Returns the status for this stream. */
Status status() const { return _status; }
/** Returns a string representation of this stream's status. */
QString statusString() const;
/** Returns the ID of the circuit to which this stream is assigned. */
- quint64 circuitId() const { return _circuitId; }
+ CircuitId circuitId() const { return _circuitId; }
/** Returns the target address and port for this stream. */
QString target() const { return (_address + ":" + QString::number(_port)); }
/** Returns the target address for this stream. */
@@ -73,11 +79,15 @@
/** Returns the target port for this stream. */
quint16 targetPort() const { return _port; }
+ /** Returns true iff <b>streamId</b> consists of only between 1 and 16
+ * (inclusive) ASCII-encoded letters and numbers. */
+ static bool isValidStreamId(const StreamId &streamId);
+
private:
- quint64 _streamId; /**< Unique ID associated with this stream. */
+ StreamId _streamId; /**< Unique ID associated with this stream. */
+ CircuitId _circuitId; /**< ID of the circuit carrying this stream. */
+ QString _address; /**< Stream target address. */
Status _status; /**< Stream status value. */
- quint64 _circuitId; /**< ID of the circuit carrying this stream. */
- QString _address; /**< Stream target address. */
quint16 _port; /**< Stream target port. */
};
Modified: vidalia/trunk/src/torcontrol/streamevent.h
===================================================================
--- vidalia/trunk/src/torcontrol/streamevent.h 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/torcontrol/streamevent.h 2008-08-17 01:28:25 UTC (rev 2977)
@@ -34,11 +34,11 @@
/** Returns the Stream object for this stream event. */
Stream stream() const { return _stream; }
/** Returns the ID for this stream event. */
- quint64 id() const { return _stream.id(); }
+ StreamId id() const { return _stream.id(); }
/** Returns the status for this stream event. */
Stream::Status status() const { return _stream.status(); }
/** Returns the ID of the circuit to which this stream is assigned */
- quint64 circuitId() const { return _stream.circuitId(); }
+ CircuitId circuitId() const { return _stream.circuitId(); }
/** Returns the target for this stream event. */
QString target() const { return _stream.target(); }
Modified: vidalia/trunk/src/torcontrol/torcontrol.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/torcontrol.cpp 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/torcontrol/torcontrol.cpp 2008-08-17 01:28:25 UTC (rev 2977)
@@ -974,12 +974,12 @@
return circuits;
}
-/** Closes the circuit specified by <b>circid</b>. If <b>ifUnused</b> is
+/** Closes the circuit specified by <b>circId</b>. If <b>ifUnused</b> is
* true, then the circuit will not be closed unless it is unused. */
bool
-TorControl::closeCircuit(quint64 circid, bool ifUnused, QString *errmsg)
+TorControl::closeCircuit(const CircuitId &circId, bool ifUnused, QString *errmsg)
{
- ControlCommand cmd("CLOSECIRCUIT", QString::number(circid));
+ ControlCommand cmd("CLOSECIRCUIT", circId);
if (ifUnused) {
cmd.addArgument("IfUnused");
}
@@ -999,26 +999,24 @@
/* Sometimes there is a stream on the first message line */
QString msg = reply.getMessage();
s = Stream::fromString(msg.mid(msg.indexOf("=")+1));
- if (!s.isEmpty()) {
+ if (s.isValid())
streams << s;
- }
- /* The rest of the streams jsut come as data, one per line */
+ /* The rest of the streams just come as data, one per line */
foreach (QString line, reply.getData()) {
s = Stream::fromString(line);
- if (!s.isEmpty()) {
+ if (s.isValid())
streams << s;
- }
}
}
return streams;
}
-/** Closes the stream specified by <b>streamid</b>. */
+/** Closes the stream specified by <b>streamId</b>. */
bool
-TorControl::closeStream(quint64 streamid, QString *errmsg)
+TorControl::closeStream(const StreamId &streamId, QString *errmsg)
{
- ControlCommand cmd("CLOSESTREAM", QString::number(streamid));
+ ControlCommand cmd("CLOSESTREAM", streamId);
cmd.addArgument("1"); /* 1 == REASON_MISC (tor-spec.txt) */
return send(cmd, errmsg);
}
Modified: vidalia/trunk/src/torcontrol/torcontrol.h
===================================================================
--- vidalia/trunk/src/torcontrol/torcontrol.h 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/torcontrol/torcontrol.h 2008-08-17 01:28:25 UTC (rev 2977)
@@ -196,11 +196,12 @@
QString *errmsg = 0);
public slots:
- /** Closes the circuit specified by <b>circid</b>. If <b>ifUnused</b> is
+ /** Closes the circuit specified by <b>circId</b>. If <b>ifUnused</b> is
* true, then the circuit will not be closed unless it is unused. */
- bool closeCircuit(quint64 circid, bool ifUnused = false, QString *errmsg = 0);
- /** Closes the stream specified by <b>streamid</b>. */
- bool closeStream(quint64 streamid, QString *errmsg = 0);
+ bool closeCircuit(const CircuitId &circId, bool ifUnused = false,
+ QString *errmsg = 0);
+ /** Closes the stream specified by <b>streamId</b>. */
+ bool closeStream(const StreamId &streamId, QString *errmsg = 0);
signals:
/** Emitted when the Tor process has started */
Modified: vidalia/trunk/src/vidalia/network/circuititem.cpp
===================================================================
--- vidalia/trunk/src/vidalia/network/circuititem.cpp 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/vidalia/network/circuititem.cpp 2008-08-17 01:28:25 UTC (rev 2977)
@@ -64,7 +64,7 @@
/** Returns a list of all stream items on this circuit. */
QList<StreamItem *>
-CircuitItem::streams()
+CircuitItem::streams() const
{
QList<StreamItem *> streams;
int n = childCount();
Modified: vidalia/trunk/src/vidalia/network/circuititem.h
===================================================================
--- vidalia/trunk/src/vidalia/network/circuititem.h 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/vidalia/network/circuititem.h 2008-08-17 01:28:25 UTC (rev 2977)
@@ -40,11 +40,11 @@
/** Updates the status of this circuit item using the given circuit. */
void update(const Circuit &circuit);
/** Returns the ID for this circuit. */
- quint64 id() { return _circuit.id(); }
+ CircuitId id() const { return _circuit.id(); }
/** Returns the Circuit object for this item. */
- Circuit circuit() { return _circuit; }
+ Circuit circuit() const { return _circuit; }
/** Returns a list of all stream items on this circuit. */
- QList<StreamItem *> streams();
+ QList<StreamItem *> streams() const;
private:
Circuit _circuit; /**< Circuit associated with this item. */
Modified: vidalia/trunk/src/vidalia/network/circuitlistwidget.cpp
===================================================================
--- vidalia/trunk/src/vidalia/network/circuitlistwidget.cpp 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/vidalia/network/circuitlistwidget.cpp 2008-08-17 01:28:25 UTC (rev 2977)
@@ -271,7 +271,7 @@
/** Finds the circuit with the given ID and returns a pointer to that
* circuit's item in the list. */
CircuitItem*
-CircuitListWidget::findCircuitItem(quint64 circid)
+CircuitListWidget::findCircuitItem(const CircuitId &circid)
{
int numCircs = topLevelItemCount();
for (int i = 0; i < numCircs; i++) {
@@ -286,7 +286,7 @@
/** Finds the stream with the given ID and returns a pointer to that stream's
* item in the list. */
StreamItem*
-CircuitListWidget::findStreamItem(quint64 streamid)
+CircuitListWidget::findStreamItem(const StreamId &streamid)
{
int numCircs = topLevelItemCount();
int numStreams;
Modified: vidalia/trunk/src/vidalia/network/circuitlistwidget.h
===================================================================
--- vidalia/trunk/src/vidalia/network/circuitlistwidget.h 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/vidalia/network/circuitlistwidget.h 2008-08-17 01:28:25 UTC (rev 2977)
@@ -54,13 +54,13 @@
/** Emitted when a circuit item is selected. */
void circuitSelected(Circuit circuit);
/** Emitted when a circuit is removed from the list. */
- void circuitRemoved(quint64 circid);
+ void circuitRemoved(CircuitId circid);
/** Emitted when the user selects a circuit to be closed. */
- void closeCircuit(quint64 circid);
+ void closeCircuit(CircuitId circid);
/** Emitted when the user selects a stream to be closed. */
- void closeStream(quint64 streamid);
+ void closeStream(StreamId streamid);
/** Emitted when the user selects a circuit to zoom to. */
- void zoomToCircuit(quint64 circid);
+ void zoomToCircuit(CircuitId circid);
public slots:
/** Clears all circuits and streams from the list. */
@@ -86,9 +86,9 @@
/** Removes the given stream item. */
void removeStream(StreamItem *stream);
/** Finds the circuit with the given ID. */
- CircuitItem* findCircuitItem(quint64 circid);
+ CircuitItem* findCircuitItem(const CircuitId &circid);
/** Finds the stream with the given ID. */
- StreamItem* findStreamItem(quint64 streamid);
+ StreamItem* findStreamItem(const StreamId &streamid);
/** Schedules the given circuit item to be removed after the given timeout. */
void scheduleCircuitRemoval(CircuitItem *circuit, int delay);
/** Schedules a stream to be removed after the given timeout. */
Modified: vidalia/trunk/src/vidalia/network/netviewer.cpp
===================================================================
--- vidalia/trunk/src/vidalia/network/netviewer.cpp 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/vidalia/network/netviewer.cpp 2008-08-17 01:28:25 UTC (rev 2977)
@@ -95,14 +95,14 @@
_map, SLOT(zoomToRouter(QString)));
connect(ui.treeCircuitList, SIGNAL(circuitSelected(Circuit)),
this, SLOT(circuitSelected(Circuit)));
- connect(ui.treeCircuitList, SIGNAL(circuitRemoved(quint64)),
- _map, SLOT(removeCircuit(quint64)));
- connect(ui.treeCircuitList, SIGNAL(zoomToCircuit(quint64)),
- _map, SLOT(zoomToCircuit(quint64)));
- connect(ui.treeCircuitList, SIGNAL(closeCircuit(quint64)),
- _torControl, SLOT(closeCircuit(quint64)));
- connect(ui.treeCircuitList, SIGNAL(closeStream(quint64)),
- _torControl, SLOT(closeStream(quint64)));
+ connect(ui.treeCircuitList, SIGNAL(circuitRemoved(CircuitId)),
+ _map, SLOT(removeCircuit(CircuitId)));
+ connect(ui.treeCircuitList, SIGNAL(zoomToCircuit(CircuitId)),
+ _map, SLOT(zoomToCircuit(CircuitId)));
+ connect(ui.treeCircuitList, SIGNAL(closeCircuit(CircuitId)),
+ _torControl, SLOT(closeCircuit(CircuitId)));
+ connect(ui.treeCircuitList, SIGNAL(closeStream(StreamId)),
+ _torControl, SLOT(closeStream(StreamId)));
/* Respond to changes in the status of the control connection */
connect(_torControl, SIGNAL(authenticated()), this, SLOT(onAuthenticated()));
@@ -330,7 +330,7 @@
/** Adds an IP address to the resolve queue and updates the queue timers. */
void
-NetViewer::addToResolveQueue(QHostAddress ip, QString id)
+NetViewer::addToResolveQueue(const QHostAddress &ip, const QString &id)
{
QString ipstr = ip.toString();
if (!_resolveMap.values(ipstr).contains(id)) {
@@ -358,7 +358,7 @@
/** Called when the user selects a circuit from the circuit and streams
* list. */
void
-NetViewer::circuitSelected(Circuit circuit)
+NetViewer::circuitSelected(const Circuit &circuit)
{
/* Clear any selected items. */
ui.treeRouterList->deselectAll();
@@ -382,7 +382,7 @@
/** Called when the user selects a router from the router list. */
void
-NetViewer::routerSelected(RouterDescriptor router)
+NetViewer::routerSelected(const RouterDescriptor &router)
{
_map->deselectAll();
ui.textRouterInfo->clear();
@@ -414,7 +414,7 @@
/** Called when a list of GeoIp information has been resolved. */
void
-NetViewer::resolved(int id, QList<GeoIp> geoips)
+NetViewer::resolved(int id, const QList<GeoIp> &geoips)
{
Q_UNUSED(id);
QString ip;
Modified: vidalia/trunk/src/vidalia/network/netviewer.h
===================================================================
--- vidalia/trunk/src/vidalia/network/netviewer.h 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/vidalia/network/netviewer.h 2008-08-17 01:28:25 UTC (rev 2977)
@@ -61,11 +61,11 @@
/** Called when the user selects the "Refresh" action on the toolbar */
void refresh();
/** Called when the user selects a circuit on the circuit list */
- void circuitSelected(Circuit circuit);
+ void circuitSelected(const Circuit &circuit);
/** Called when an IP has been resolved to geographic information. */
- void resolved(int id, QList<GeoIp> geoips);
+ void resolved(int id, const QList<GeoIp> &geoips);
/** Called when the user selects a router in the list. */
- void routerSelected(RouterDescriptor router);
+ void routerSelected(const RouterDescriptor &router);
/** Handles when we get connected to Tor network */
void onAuthenticated();
/** Handles when we get disconnected from Tor network */
@@ -75,7 +75,7 @@
private:
/** Adds an IP address to the resolve queue and updates the queue timers. */
- void addToResolveQueue(QHostAddress ip, QString id);
+ void addToResolveQueue(const QHostAddress &ip, const QString &id);
/** Retrieves a list of all running routers from Tor and their descriptors,
* and adds them to the RouterListWidget. */
void loadNetworkStatus();
Modified: vidalia/trunk/src/vidalia/network/streamitem.h
===================================================================
--- vidalia/trunk/src/vidalia/network/streamitem.h 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/vidalia/network/streamitem.h 2008-08-17 01:28:25 UTC (rev 2977)
@@ -30,10 +30,10 @@
/** Updates the status of this stream item. */
void update(const Stream &stream);
/** Returns the ID of the stream associated with this tree item. */
- quint64 id() const { return _id; }
+ StreamId id() const { return _id; }
private:
- quint64 _id; /**< ID for this stream. */
+ StreamId _id; /**< ID for this stream. */
};
#endif
Modified: vidalia/trunk/src/vidalia/network/tormapwidget.cpp
===================================================================
--- vidalia/trunk/src/vidalia/network/tormapwidget.cpp 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/vidalia/network/tormapwidget.cpp 2008-08-17 01:28:25 UTC (rev 2977)
@@ -78,7 +78,7 @@
/** Adds a router to the map. */
void
-TorMapWidget::addRouter(QString id, float latitude, float longitude)
+TorMapWidget::addRouter(const QString &id, float latitude, float longitude)
{
QPointF routerCoord = toMapSpace(latitude, longitude);
@@ -91,7 +91,7 @@
/** Adds a circuit to the map using the given ordered list of router IDs. */
void
-TorMapWidget::addCircuit(quint64 circid, QStringList path)
+TorMapWidget::addCircuit(const CircuitId &circid, const QStringList &path)
{
QPainterPath *circPainterPath = new QPainterPath;
@@ -128,7 +128,7 @@
/** Removes a circuit from the map. */
void
-TorMapWidget::removeCircuit(quint64 circid)
+TorMapWidget::removeCircuit(const CircuitId &circid)
{
QPair<QPainterPath*,bool> *circ = _circuits.take(circid);
QPainterPath *circpath = circ->first;
@@ -140,7 +140,7 @@
/** Selects and highlights the router on the map. */
void
-TorMapWidget::selectRouter(QString id)
+TorMapWidget::selectRouter(const QString &id)
{
if (_routers.contains(id)) {
QPair<QPointF, bool> *routerPair = _routers.value(id);
@@ -152,7 +152,7 @@
/** Selects and highlights the circuit with the id <b>circid</b>
* on the map. */
void
-TorMapWidget::selectCircuit(quint64 circid)
+TorMapWidget::selectCircuit(const CircuitId &circid)
{
if (_circuits.contains(circid)) {
QPair<QPainterPath*, bool> *circuitPair = _circuits.value(circid);
@@ -171,7 +171,7 @@
routerPair->second = false;
}
/* Deselect all circuit paths */
- foreach (quint64 circid, _circuits.keys()) {
+ foreach (CircuitId circid, _circuits.keys()) {
QPair<QPainterPath*,bool> *circuitPair = _circuits.value(circid);
circuitPair->second = false;
}
@@ -186,7 +186,7 @@
delete _routers.take(router);
}
/* Clear out all the circuit paths and free their memory */
- foreach (quint64 circid, _circuits.keys()) {
+ foreach (CircuitId circid, _circuits.keys()) {
QPair<QPainterPath*,bool> *circuitPair = _circuits.take(circid);
delete circuitPair->first;
delete circuitPair;
@@ -206,7 +206,7 @@
painter->drawPoint(routerPair->first);
}
/* Draw the circuit paths */
- foreach(quint64 circid, _circuits.keys()) {
+ foreach(CircuitId circid, _circuits.keys()) {
QPair<QPainterPath*,bool> *circuitPair = _circuits.value(circid);
painter->setPen((circuitPair->second ? PEN_SELECTED : PEN_CIRCUIT));
painter->drawPath(*(circuitPair->first));
@@ -279,7 +279,7 @@
/** Zoom to the circuit on the map with the given <b>circid</b>. */
void
-TorMapWidget::zoomToCircuit(quint64 circid)
+TorMapWidget::zoomToCircuit(const CircuitId &circid)
{
if (_circuits.contains(circid)) {
QPair<QPainterPath*,bool> *pair = _circuits.value(circid);
@@ -295,7 +295,7 @@
/** Zooms in on the router with the given <b>id</b>. */
void
-TorMapWidget::zoomToRouter(QString id)
+TorMapWidget::zoomToRouter(const QString &id)
{
QPair<QPointF,bool> *routerPair;
@@ -315,7 +315,7 @@
QRectF rect;
/* Compute the union of bounding rectangles for all circuit paths */
- foreach (quint64 circid, _circuits.keys()) {
+ foreach (CircuitId circid, _circuits.keys()) {
QPair<QPainterPath*,bool> *pair = _circuits.value(circid);
QPainterPath *circuit = pair->first;
rect = rect.unite(circuit->boundingRect());
Modified: vidalia/trunk/src/vidalia/network/tormapwidget.h
===================================================================
--- vidalia/trunk/src/vidalia/network/tormapwidget.h 2008-08-16 20:42:03 UTC (rev 2976)
+++ vidalia/trunk/src/vidalia/network/tormapwidget.h 2008-08-17 01:28:25 UTC (rev 2977)
@@ -21,6 +21,8 @@
#include <QPair>
#include <QPainter>
#include <QPainterPath>
+#include <circuit.h>
+#include <stream.h>
#include "zimageview.h"
@@ -36,19 +38,19 @@
~TorMapWidget();
/** Plots the given router on the map using the given coordinates. */
- void addRouter(QString id, float latitude, float longitude);
+ void addRouter(const QString &id, float latitude, float longitude);
/** Plots the given circuit on the map. */
- void addCircuit(quint64 circid, QStringList path);
+ void addCircuit(const CircuitId &circid, const QStringList &path);
/** Selects and hightlights a router on the map. */
- void selectRouter(QString id);
+ void selectRouter(const QString &id);
/** Selects and highlights a circuit on the map. */
- void selectCircuit(quint64 circid);
+ void selectCircuit(const CircuitId &circid);
/** Returns the minimum size of the widget */
QSize minimumSizeHint() const;
public slots:
/** Removes a circuit from the map. */
- void removeCircuit(quint64 circid);
+ void removeCircuit(const CircuitId &circid);
/** Deselects all the highlighted circuits and routers */
void deselectAll();
/** Clears the known routers and removes all the data from the map */
@@ -56,9 +58,9 @@
/** Zooms to fit all currently displayed circuits on the map. */
void zoomToFit();
/** Zoom to a particular router on the map. */
- void zoomToRouter(QString id);
+ void zoomToRouter(const QString &id);
/** Zoom to the circuit on the map with the given <b>circid</b>. */
- void zoomToCircuit(quint64 circid);
+ void zoomToCircuit(const CircuitId &circid);
protected:
/** Paints the current circuits and streams on the image. */
@@ -76,7 +78,7 @@
/** Stores map locations for tor routers */
QHash<QString, QPair<QPointF,bool>* > _routers;
/** Stores circuit information */
- QHash<quint64, QPair<QPainterPath *,bool>* > _circuits;
+ QHash<CircuitId, QPair<QPainterPath *,bool>* > _circuits;
};
#endif