[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r1796: Add methods for getting just the address or port from the st (trunk/src/control)
Author: edmanm
Date: 2007-07-02 21:28:52 -0400 (Mon, 02 Jul 2007)
New Revision: 1796
Modified:
trunk/src/control/stream.cpp
trunk/src/control/stream.h
Log:
Add methods for getting just the address or port from the stream target.
Modified: trunk/src/control/stream.cpp
===================================================================
--- trunk/src/control/stream.cpp 2007-06-22 23:02:06 UTC (rev 1795)
+++ trunk/src/control/stream.cpp 2007-07-03 01:28:52 UTC (rev 1796)
@@ -36,16 +36,33 @@
_streamId = 0;
_status = Unknown;
_circuitId = 0;
- _target = QString();
+ _port = 0;
}
/** Constructor */
+Stream::Stream(quint64 streamId, Status status, quint64 circuitId,
+ QString address, quint16 port)
+{
+ _streamId = streamId;
+ _status = status;
+ _circuitId = circuitId;
+ _address = address;
+ _port = port;
+}
+
+/** Constructor */
Stream::Stream(quint64 streamId, Status status, quint64 circuitId, QString target)
{
_streamId = streamId;
_status = status;
_circuitId = circuitId;
- _target = target;
+ _port = 0;
+
+ int i = target.indexOf(":");
+ if (i >= 0)
+ _address = target.mid(0, i);
+ if (i + 1 < target.length())
+ _port = target.mid(i+1).toUInt();
}
/** Parses the given string for stream information, given in Tor control
@@ -125,6 +142,6 @@
Stream::isEmpty()
{
return (!_streamId && !_circuitId &&
- (_status == Unknown) && _target.isEmpty());
+ (_status == Unknown) && _address.isEmpty() && !_port);
}
Modified: trunk/src/control/stream.h
===================================================================
--- trunk/src/control/stream.h 2007-06-22 23:02:06 UTC (rev 1795)
+++ trunk/src/control/stream.h 2007-07-03 01:28:52 UTC (rev 1796)
@@ -54,6 +54,9 @@
Stream();
/** Constructor */
Stream(quint64 streamId, Status status, quint64 circuitId, QString target);
+ /** Constructor */
+ Stream(quint64 streamId, Status status, quint64 circuitId,
+ QString address, quint16 port);
/** Parses the given string for a stream, in Tor control protocol format. */
static Stream fromString(QString stream);
@@ -71,14 +74,19 @@
QString statusString();
/** Returns the ID of the circuit to which this stream is assigned. */
quint64 circuitId() { return _circuitId; }
- /** Returns the target for this stream. */
- QString target() { return _target; }
-
+ /** Returns the target address and port for this stream. */
+ QString target() { return (_address + ":" + QString::number(_port)); }
+ /** Returns the target address for this stream. */
+ QString targetAddress() { return _address; }
+ /** Returns the target port for this stream. */
+ quint16 targetPort() { return _port; }
+
private:
quint64 _streamId; /**< Unique ID associated with this stream. */
Status _status; /**< Stream status value. */
quint64 _circuitId; /**< ID of the circuit carrying this stream. */
- QString _target; /**< Stream target address. */
+ QString _address; /**< Stream target address. */
+ quint16 _port; /**< Stream target port. */
};
#endif