Vidalia 0.3.1
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
19namespace tc {
20
21/* Creates a new message using <b>fmt</b> and a severity level of
22 * QtDebugMsg. */
24debug(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. */
31DebugMessage
32warn(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. */
39DebugMessage
40error(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. */
47DebugMessage
48fatal(const QString &fmt)
49{
50 return DebugMessage(QtFatalMsg, fmt);
51}
52
53/* Converts <b>str</b> to a ConnectionStatusReason enum value. */
56{
57 if (str.isEmpty())
58 return UnrecognizedReason;
59 if (!str.compare("MISC", Qt::CaseInsensitive))
61 if (!str.compare("IDENTITY", Qt::CaseInsensitive))
62 return IdentityMismatch;
63 if (!str.compare("RESOURCELIMIT", Qt::CaseInsensitive))
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. */
82severityFromString(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;
95}
96
97}
98
Definition: tcglobal.cpp:19
DebugMessage warn(const QString &fmt)
Definition: tcglobal.cpp:32
DebugMessage fatal(const QString &fmt)
Definition: tcglobal.cpp:48
DebugMessage error(const QString &fmt)
Definition: tcglobal.cpp:40
ConnectionStatusReason
Definition: tcglobal.h:56
@ NoRouteToHost
Definition: tcglobal.h:65
@ UnrecognizedReason
Definition: tcglobal.h:57
@ ResourceLimitReached
Definition: tcglobal.h:66
@ ConnectionTimeout
Definition: tcglobal.h:63
@ ConnectionRefused
Definition: tcglobal.h:61
@ MiscellaneousReason
Definition: tcglobal.h:58
@ ConnectionIoError
Definition: tcglobal.h:64
@ IdentityMismatch
Definition: tcglobal.h:59
@ ConnectionDone
Definition: tcglobal.h:60
Severity severityFromString(const QString &str)
Definition: tcglobal.cpp:82
Severity
Definition: tcglobal.h:69
@ UnrecognizedSeverity
Definition: tcglobal.h:70
@ DebugSeverity
Definition: tcglobal.h:71
@ NoticeSeverity
Definition: tcglobal.h:73
@ ErrorSeverity
Definition: tcglobal.h:75
@ WarnSeverity
Definition: tcglobal.h:74
@ InfoSeverity
Definition: tcglobal.h:72
ConnectionStatusReason connectionStatusReasonFromString(const QString &str)
Definition: tcglobal.cpp:55
DebugMessage debug(const QString &fmt)
Definition: tcglobal.cpp:24