source: trunk/src/network/ssl/qsslcipher.cpp@ 807

Last change on this file since 807 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 5.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtNetwork module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42
43/*!
44 \class QSslCipher
45 \brief The QSslCipher class represents an SSL cryptographic cipher.
46 \since 4.3
47
48 \reentrant
49 \ingroup network
50 \ingroup ssl
51 \inmodule QtNetwork
52
53 QSslCipher stores information about one cryptographic cipher. It
54 is most commonly used with QSslSocket, either for configuring
55 which ciphers the socket can use, or for displaying the socket's
56 ciphers to the user.
57
58 \sa QSslSocket, QSslKey
59*/
60
61#include "qsslcipher.h"
62#include "qsslcipher_p.h"
63#include "qsslsocket.h"
64
65#ifndef QT_NO_DEBUG_STREAM
66#include <QtCore/qdebug.h>
67#endif
68
69QT_BEGIN_NAMESPACE
70
71/*!
72 Constructs an empty QSslCipher object.
73*/
74QSslCipher::QSslCipher()
75 : d(new QSslCipherPrivate)
76{
77}
78
79/*!
80 Constructs a QSslCipher object for the cipher determined by \a
81 name and \a protocol. The constructor accepts only supported
82 ciphers (i.e., the \a name and \a protocol must identify a cipher
83 in the list of ciphers returned by
84 QSslSocket::supportedCiphers()).
85
86 You can call isNull() after construction to check if \a name and
87 \a protocol correctly identified a supported cipher.
88*/
89QSslCipher::QSslCipher(const QString &name, QSsl::SslProtocol protocol)
90 : d(new QSslCipherPrivate)
91{
92 foreach (const QSslCipher &cipher, QSslSocket::supportedCiphers()) {
93 if (cipher.name() == name && cipher.protocol() == protocol) {
94 *this = cipher;
95 return;
96 }
97 }
98}
99
100/*!
101 Constructs an identical copy of the \a other cipher.
102*/
103QSslCipher::QSslCipher(const QSslCipher &other)
104 : d(new QSslCipherPrivate)
105{
106 *d.data() = *other.d.data();
107}
108
109/*!
110 Destroys the QSslCipher object.
111*/
112QSslCipher::~QSslCipher()
113{
114}
115
116/*!
117 Copies the contents of \a other into this cipher, making the two
118 ciphers identical.
119*/
120QSslCipher &QSslCipher::operator=(const QSslCipher &other)
121{
122 *d.data() = *other.d.data();
123 return *this;
124}
125
126/*!
127 Returns true if this cipher is the same as \a other; otherwise,
128 false is returned.
129*/
130bool QSslCipher::operator==(const QSslCipher &other) const
131{
132 return d->name == other.d->name && d->protocol == other.d->protocol;
133}
134
135/*!
136 \fn bool QSslCipher::operator!=(const QSslCipher &other) const
137
138 Returns true if this cipher is not the same as \a other;
139 otherwise, false is returned.
140*/
141
142/*!
143 Returns true if this is a null cipher; otherwise returns false.
144*/
145bool QSslCipher::isNull() const
146{
147 return d->isNull;
148}
149
150/*!
151 Returns the name of the cipher, or an empty QString if this is a null