From c896cc340d7e6e0878b3249c5792e6d88a12cf42 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 30 Apr 2010 11:23:37 +0200 Subject: A coding style round --- src/websslinfo.cpp | 161 +++++++++++++++++++++++++++-------------------------- 1 file changed, 82 insertions(+), 79 deletions(-) (limited to 'src/websslinfo.cpp') diff --git a/src/websslinfo.cpp b/src/websslinfo.cpp index ffc4918f..35112504 100644 --- a/src/websslinfo.cpp +++ b/src/websslinfo.cpp @@ -28,184 +28,187 @@ class WebSslInfo::WebSslInfoPrivate { public: - WebSslInfoPrivate() - : usedCipherBits(0), supportedCipherBits(0) {} - - QUrl url; - QString ciphers; - QString protocol; - QString certErrors; - QHostAddress peerAddress; - QHostAddress parentAddress; - QList certificateChain; - - int usedCipherBits; - int supportedCipherBits; + WebSslInfoPrivate() + : usedCipherBits(0), supportedCipherBits(0) {} + + QUrl url; + QString ciphers; + QString protocol; + QString certErrors; + QHostAddress peerAddress; + QHostAddress parentAddress; + QList certificateChain; + + int usedCipherBits; + int supportedCipherBits; }; WebSslInfo::WebSslInfo() - :d(new WebSslInfo::WebSslInfoPrivate) + : d(new WebSslInfo::WebSslInfoPrivate) { } WebSslInfo::WebSslInfo(const WebSslInfo& other) - :d(new WebSslInfo::WebSslInfoPrivate) + : d(new WebSslInfo::WebSslInfoPrivate) { - *this = other; + *this = other; } WebSslInfo::~WebSslInfo() { - delete d; - d = 0; + delete d; + d = 0; } bool WebSslInfo::isValid() const { - return !d->peerAddress.isNull(); + return !d->peerAddress.isNull(); } QUrl WebSslInfo::url() const { - return d->url; + return d->url; } QHostAddress WebSslInfo::parentAddress() const { - return d->parentAddress; + return d->parentAddress; } QHostAddress WebSslInfo::peerAddress() const { - return d->peerAddress; + return d->peerAddress; } QString WebSslInfo::protocol() const { - return d->protocol; + return d->protocol; } QString WebSslInfo::ciphers() const { - return d->ciphers; + return d->ciphers; } QString WebSslInfo::certificateErrors() const { - return d->certErrors; + return d->certErrors; } -int WebSslInfo::supportedChiperBits () const +int WebSslInfo::supportedChiperBits() const { - return d->supportedCipherBits; + return d->supportedCipherBits; } -int WebSslInfo::usedChiperBits () const +int WebSslInfo::usedChiperBits() const { - return d->usedCipherBits; + return d->usedCipherBits; } QList WebSslInfo::certificateChain() const { - return d->certificateChain; + return d->certificateChain; } -WebSslInfo& WebSslInfo::operator=(const WebSslInfo& other) +WebSslInfo& WebSslInfo::operator=(const WebSslInfo & other) { - d->ciphers = other.d->ciphers; - d->protocol = other.d->protocol; - d->certErrors = other.d->certErrors; - d->peerAddress = other.d->peerAddress; - d->parentAddress = other.d->parentAddress; - d->certificateChain = other.d->certificateChain; + d->ciphers = other.d->ciphers; + d->protocol = other.d->protocol; + d->certErrors = other.d->certErrors; + d->peerAddress = other.d->peerAddress; + d->parentAddress = other.d->parentAddress; + d->certificateChain = other.d->certificateChain; - d->usedCipherBits = other.d->usedCipherBits; - d->supportedCipherBits = other.d->supportedCipherBits; - d->url = other.d->url; + d->usedCipherBits = other.d->usedCipherBits; + d->supportedCipherBits = other.d->supportedCipherBits; + d->url = other.d->url; - return *this; + return *this; } QVariant WebSslInfo::toMetaData() const { - if (isValid()) { - QMap data; - data.insert("ssl_in_use", true); - data.insert("ssl_peer_ip", d->peerAddress.toString()); - data.insert("ssl_parent_ip", d->parentAddress.toString()); - data.insert("ssl_protocol_version", d->protocol); - data.insert("ssl_cipher", d->ciphers); - data.insert("ssl_cert_errors", d->certErrors); - data.insert("ssl_cipher_used_bits", d->usedCipherBits); - data.insert("ssl_cipher_bits", d->supportedCipherBits); - QByteArray certChain; - Q_FOREACH(const QSslCertificate& cert, d->certificateChain) + if (isValid()) + { + QMap data; + data.insert("ssl_in_use", true); + data.insert("ssl_peer_ip", d->peerAddress.toString()); + data.insert("ssl_parent_ip", d->parentAddress.toString()); + data.insert("ssl_protocol_version", d->protocol); + data.insert("ssl_cipher", d->ciphers); + data.insert("ssl_cert_errors", d->certErrors); + data.insert("ssl_cipher_used_bits", d->usedCipherBits); + data.insert("ssl_cipher_bits", d->supportedCipherBits); + QByteArray certChain; + Q_FOREACH(const QSslCertificate& cert, d->certificateChain) certChain += cert.toPem(); - data.insert("ssl_peer_chain", certChain); - return data; - } + data.insert("ssl_peer_chain", certChain); + return data; + } - return QVariant(); + return QVariant(); } void WebSslInfo::fromMetaData(const QVariant& value) { - if (value.isValid() && value.type() == QVariant::Map) { - QMap metaData = value.toMap(); - if (metaData.value("ssl_in_use", false).toBool()) { - setCertificateChain(metaData.value("ssl_peer_chain").toByteArray()); - setPeerAddress(metaData.value("ssl_peer_ip").toString()); - setParentAddress(metaData.value("ssl_parent_ip").toString()); - setProtocol(metaData.value("ssl_protocol_version").toString()); - setCiphers(metaData.value("ssl_cipher").toString()); - setCertificateErrors(metaData.value("ssl_cert_errors").toString()); - setUsedCipherBits(metaData.value("ssl_cipher_used_bits").toString()); - setSupportedCipherBits(metaData.value("ssl_cipher_bits").toString()); + if (value.isValid() && value.type() == QVariant::Map) + { + QMap metaData = value.toMap(); + if (metaData.value("ssl_in_use", false).toBool()) + { + setCertificateChain(metaData.value("ssl_peer_chain").toByteArray()); + setPeerAddress(metaData.value("ssl_peer_ip").toString()); + setParentAddress(metaData.value("ssl_parent_ip").toString()); + setProtocol(metaData.value("ssl_protocol_version").toString()); + setCiphers(metaData.value("ssl_cipher").toString()); + setCertificateErrors(metaData.value("ssl_cert_errors").toString()); + setUsedCipherBits(metaData.value("ssl_cipher_used_bits").toString()); + setSupportedCipherBits(metaData.value("ssl_cipher_bits").toString()); + } } - } } -void WebSslInfo::setUrl (const QUrl &url) +void WebSslInfo::setUrl(const QUrl &url) { - d->url = url; + d->url = url; } void WebSslInfo::setPeerAddress(const QString& address) { - d->peerAddress = address; + d->peerAddress = address; } void WebSslInfo::setParentAddress(const QString& address) { - d->parentAddress = address; + d->parentAddress = address; } void WebSslInfo::setProtocol(const QString& protocol) { - d->protocol = protocol; + d->protocol = protocol; } void WebSslInfo::setCertificateChain(const QByteArray& chain) { - d->certificateChain = QSslCertificate::fromData(chain); + d->certificateChain = QSslCertificate::fromData(chain); } void WebSslInfo::setCiphers(const QString& ciphers) { - d->ciphers = ciphers; + d->ciphers = ciphers; } void WebSslInfo::setUsedCipherBits(const QString& bits) { - d->usedCipherBits = bits.toInt(); + d->usedCipherBits = bits.toInt(); } void WebSslInfo::setSupportedCipherBits(const QString& bits) { - d->supportedCipherBits = bits.toInt(); + d->supportedCipherBits = bits.toInt(); } void WebSslInfo::setCertificateErrors(const QString& certErrors) { - d->certErrors = certErrors; + d->certErrors = certErrors; } -- cgit v1.2.1