Vidalia
0.2.21
Main Page
Namespaces
Classes
Files
File List
File Members
src
torcontrol
Stream.h
Go to the documentation of this file.
1
/*
2
** This file is part of Vidalia, and is subject to the license terms in the
3
** LICENSE file, found in the top level directory of this distribution. If
4
** you did not receive the LICENSE file with this file, you may obtain it
5
** from the Vidalia source package distributed by the Vidalia Project at
6
** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7
** including this file, may be copied, modified, propagated, or distributed
8
** except according to the terms described in the LICENSE file.
9
*/
10
11
/*
12
** \file Stream.h
13
** \brief Object representing a Tor stream
14
*/
15
16
#ifndef _STREAM_H
17
#define _STREAM_H
18
19
#include "
Circuit.h
"
20
21
#include <QCoreApplication>
22
#include <QString>
23
#include <QObject>
24
#include <QList>
25
#include <QMetaType>
26
27
/** Stream IDs contains 1-16 alphanumeric ASCII characters. */
28
typedef
QString
StreamId
;
29
30
31
class
Stream
32
{
33
Q_DECLARE_TR_FUNCTIONS(
Stream
)
34
35
public
:
36
/** Stream status values */
37
enum
Status
{
38
Unknown
,
/**< Unknown status type given */
39
New
,
/**< New request to connect */
40
NewResolve
,
/**< New request to resolve an address */
41
SentConnect
,
/**< Sent a connect cell */
42
SentResolve
,
/**< Sent a resolve cell */
43
Succeeded
,
/**< Stream established */
44
Failed
,
/**< Stream failed */
45
Closed
,
/**< Stream closed */
46
Detached
,
/**< Detached from circuit */
47
Remap
/**< Address re-mapped to another */
48
};
49
50
/** Default constructor */
51
Stream
();
52
/** Constructor */
53
Stream
(
const
StreamId
&streamId,
Status
status
,
const
CircuitId
&
circuitId
,
54
const
QString &
target
);
55
/** Constructor */
56
Stream
(
const
StreamId
&streamId,
Status
status
,
const
CircuitId
&
circuitId
,
57
const
QString &address, quint16 port);
58
59
/** Parses the given string for a stream, in Tor control protocol format. */
60
static
Stream
fromString
(
const
QString &stream);
61
/** Converts a string description of a stream's status to its enum value */
62
static
Status
toStatus
(
const
QString &strStatus);
63
64
/** Returns true iff the Stream object's fields are all valid. */
65
bool
isValid
()
const
;
66
67
/** Returns the ID for this stream. */
68
StreamId
id
()
const
{
return
_streamId
; }
69
/** Returns the status for this stream. */
70
Status
status
()
const
{
return
_status
; }
71
/** Returns a string representation of this stream's status. */
72
QString
statusString
()
const
;
73
/** Returns the ID of the circuit to which this stream is assigned. */
74
CircuitId
circuitId
()
const
{
return
_circuitId
; }
75
/** Returns the target address and port for this stream. */
76
QString
target
()
const
{
return
(
_address
+
":"
+ QString::number(
_port
)); }
77
/** Returns the target address for this stream. */
78
QString
targetAddress
()
const
{
return
_address
; }
79
/** Returns the target port for this stream. */
80
quint16
targetPort
()
const
{
return
_port
; }
81
82
/** Returns true iff <b>streamId</b> consists of only between 1 and 16
83
* (inclusive) ASCII-encoded letters and numbers. */
84
static
bool
isValidStreamId
(
const
StreamId
&streamId);
85
86
private
:
87
StreamId
_streamId
;
/**< Unique ID associated with this stream. */
88
CircuitId
_circuitId
;
/**< ID of the circuit carrying this stream. */
89
QString
_address
;
/**< Stream target address. */
90
Status
_status
;
/**< Stream status value. */
91
quint16
_port
;
/**< Stream target port. */
92
};
93
94
Q_DECLARE_METATYPE
(
Stream
);
95
96
/** A collection of Stream objects. */
97
typedef
QList<Stream>
StreamList
;
98
99
#endif
100
Generated on Thu Dec 6 2012 04:33:17 for Vidalia by
1.8.2