Vidalia
0.3.1
src
torcontrol
tcglobal.cpp
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 you
4
** did not receive the LICENSE file with this file, you may obtain it from the
5
** 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 tcglobal.cpp
13
** \brief Provides common methods and constants used by the torcontrol library
14
*/
15
16
#include "
tcglobal.h
"
17
18
19
namespace
tc
{
20
21
/* Creates a new message using <b>fmt</b> and a severity level of
22
* QtDebugMsg. */
23
DebugMessage
24
debug
(
const
QString &fmt)
25
{
26
return
DebugMessage
(QtDebugMsg, fmt);
27
}
28
29
/* Creates a new message using <b>fmt</b> and a severity level of
30
* QtWarningMsg. */
31
DebugMessage
32
warn
(
const
QString &fmt)
33
{
34
return
DebugMessage
(QtWarningMsg, fmt);
35
}
36
37
/* Creates a new message using <b>fmt</b> and a severity level of
38
* QtCriticalMsg. */
39
DebugMessage
40
error
(
const
QString &fmt)
41
{
42
return
DebugMessage
(QtCriticalMsg, fmt);
43
}
44
45
/* Creates a new message using <b>fmt</b> and a severity level of
46
* QtFatalMsg. */
47
DebugMessage
48
fatal
(
const
QString &fmt)
49
{
50
return
DebugMessage
(QtFatalMsg, fmt);
51
}
52
53
/* Converts <b>str</b> to a ConnectionStatusReason enum value. */
54
ConnectionStatusReason
55
connectionStatusReasonFromString
(
const
QString &str)
56
{
57
if
(str.isEmpty())
58
return
UnrecognizedReason
;
59
if
(!str.compare(
"MISC"
, Qt::CaseInsensitive))
60
return
MiscellaneousReason
;
61
if
(!str.compare(
"IDENTITY"
, Qt::CaseInsensitive))
62
return
IdentityMismatch
;
63
if
(!str.compare(
"RESOURCELIMIT"
, Qt::CaseInsensitive))
64
return
ResourceLimitReached
;
65
if
(!str.compare(
"DONE"
, Qt::CaseInsensitive))
66
return
ConnectionDone
;
67
if
(!str.compare(
"CONNECTREFUSED"
))
68
return
ConnectionRefused
;
69
if
(!str.compare(
"CONNECTRESET"
, Qt::CaseInsensitive))
70
return
ConnectionRefused
;
71
if
(!str.compare(
"TIMEOUT"
, Qt::CaseInsensitive))
72
return
ConnectionTimeout
;
73
if
(!str.compare(
"NOROUTE"
, Qt::CaseInsensitive))
74
return
NoRouteToHost
;
75
if
(!str.compare(
"IOERROR"
, Qt::CaseInsensitive))
76
return
ConnectionIoError
;
77
return
UnrecognizedReason
;
78
}
79
80
/* Converts <b>str</b> to a Severity enum value. */
81
Severity
82
severityFromString
(
const
QString &str)
83
{
84
if
(!str.compare(
"DEBUG"
, Qt::CaseInsensitive))
85
return
DebugSeverity
;
86
if
(!str.compare(
"INFO"
, Qt::CaseInsensitive))
87
return
InfoSeverity
;
88
if
(!str.compare(
"NOTICE"
, Qt::CaseInsensitive))
89
return
NoticeSeverity
;
90
if
(!str.compare(
"WARN"
, Qt::CaseInsensitive))
91
return
WarnSeverity
;
92
if
(!str.compare(
"ERR"
, Qt::CaseInsensitive))
93
return
ErrorSeverity
;
94
return
UnrecognizedSeverity
;
95
}
96
97
}
98
tc::WarnSeverity
@ WarnSeverity
Definition:
tcglobal.h:74
tc::ResourceLimitReached
@ ResourceLimitReached
Definition:
tcglobal.h:66
tc::UnrecognizedReason
@ UnrecognizedReason
Definition:
tcglobal.h:57
tcglobal.h
tc::ConnectionStatusReason
ConnectionStatusReason
Definition:
tcglobal.h:56
tc::InfoSeverity
@ InfoSeverity
Definition:
tcglobal.h:72
tc::NoticeSeverity
@ NoticeSeverity
Definition:
tcglobal.h:73
tc::Severity
Severity
Definition:
tcglobal.h:69
tc::ConnectionDone
@ ConnectionDone
Definition:
tcglobal.h:60
tc::warn
DebugMessage warn(const QString &fmt)
Definition:
tcglobal.cpp:32
tc::IdentityMismatch
@ IdentityMismatch
Definition:
tcglobal.h:59
tc::debug
DebugMessage debug(const QString &fmt)
Definition:
tcglobal.cpp:24
tc
Definition:
tcglobal.cpp:19
tc::MiscellaneousReason
@ MiscellaneousReason
Definition:
tcglobal.h:58
tc::ConnectionRefused
@ ConnectionRefused
Definition:
tcglobal.h:61
tc::severityFromString
Severity severityFromString(const QString &str)
Definition:
tcglobal.cpp:82
tc::ErrorSeverity
@ ErrorSeverity
Definition:
tcglobal.h:75
tc::UnrecognizedSeverity
@ UnrecognizedSeverity
Definition:
tcglobal.h:70
tc::ConnectionTimeout
@ ConnectionTimeout
Definition:
tcglobal.h:63
tc::connectionStatusReasonFromString
ConnectionStatusReason connectionStatusReasonFromString(const QString &str)
Definition:
tcglobal.cpp:55
tc::NoRouteToHost
@ NoRouteToHost
Definition:
tcglobal.h:65
tc::DebugSeverity
@ DebugSeverity
Definition:
tcglobal.h:71
tc::fatal
DebugMessage fatal(const QString &fmt)
Definition:
tcglobal.cpp:48
tc::DebugMessage
Definition:
tcglobal.h:24
tc::error
DebugMessage error(const QString &fmt)
Definition:
tcglobal.cpp:40
tc::ConnectionIoError
@ ConnectionIoError
Definition:
tcglobal.h:64
Generated by
1.8.17