Vidalia
0.2.21
Main Page
Namespaces
Classes
Files
File List
File Members
src
vidalia
config
NicknameValidator.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 NicknameValidator.cpp
13
** \brief Validates that a server nickname contains only valid characters
14
*/
15
16
#include "
NicknameValidator.h
"
17
#include "
stringutil.h
"
18
19
/** Set of characters that are valid in a server's nickname. */
20
#define VALID_NICKNAME_CHARS \
21
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
22
23
24
/** Constructor. */
25
NicknameValidator::NicknameValidator
(QObject *parent)
26
: QValidator(parent)
27
{
28
}
29
30
/** Validates the given input contains only valid nickname characters starting
31
* at the specified position. */
32
QValidator::State
33
NicknameValidator::validate
(QString &input,
int
&pos)
const
34
{
35
Q_UNUSED(pos);
36
37
/* Make sure the input only contains valid characters. If any characters
38
* were removed, then we know the input contained invalid characters. */
39
QString validString =
ensure_valid_chars
(input,
VALID_NICKNAME_CHARS
);
40
return
(validString.length() == input.length() ? QValidator::Acceptable
41
: QValidator::Invalid);
42
}
43
Generated on Thu Dec 6 2012 04:33:17 for Vidalia by
1.8.2