From: Manuel Nickschas Date: Fri, 16 Jan 2009 20:15:27 +0000 (+0100) Subject: Formatting, make strings translateable, naming convention++ X-Git-Tag: 0.4.0~200 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=94899dd5e482868ca01a3de3857e47a46d996553;ds=sidebyside Formatting, make strings translateable, naming convention++ --- diff --git a/src/core/sslserver.cpp b/src/core/sslserver.cpp index bfcdbf26..f256923b 100644 --- a/src/core/sslserver.cpp +++ b/src/core/sslserver.cpp @@ -25,25 +25,24 @@ #endif #include -#include #include "logger.h" #include "util.h" #ifdef HAVE_SSL -static bool SslServer_longMessShown=false; - SslServer::SslServer(QObject *parent) - : QTcpServer(parent) + : QTcpServer(parent), + _isCertValid(false) { - if (! setCertificate(quasselDir().absolutePath() + "/quasselCert.pem")) { - if (! SslServer_longMessShown) { - qWarning() + static bool sslWarningShown = false; + if(!setCertificate(quasselDir().absolutePath() + "/quasselCert.pem")) { + if(!sslWarningShown) { + quWarning() << "SslServer: Unable to set certificate file\n" << " Quassel Core will still work, but cannot provide SSL for client connections.\n" << " Please see http://quassel-irc.org/faq/cert to learn how to enable SSL support."; - SslServer_longMessShown=true; + sslWarningShown=true; } } } @@ -58,7 +57,7 @@ QTcpSocket *SslServer::nextPendingConnection() { void SslServer::incomingConnection(int socketDescriptor) { QSslSocket *serverSocket = new QSslSocket(this); if(serverSocket->setSocketDescriptor(socketDescriptor)) { - if(certIsValid()) { + if(isCertValid()) { serverSocket->setLocalCertificate(_cert); serverSocket->setPrivateKey(_key); } @@ -70,50 +69,49 @@ void SslServer::incomingConnection(int socketDescriptor) { } bool SslServer::setCertificate(const QString &path) { - _certIsValid = false; + _isCertValid = false; - if (path.isNull()) { + if(path.isEmpty()) return false; - } QFile certFile(path); - if (! certFile.exists()) { - qWarning() << "SslServer: Certificate file" << qPrintable(path) << "does not exist"; + if(!certFile.exists()) { + quWarning() << "SslServer: Certificate file" << qPrintable(path) << "does not exist"; return false; } - if (! certFile.open(QIODevice::ReadOnly)) { - qWarning() + if(!certFile.open(QIODevice::ReadOnly)) { + quWarning() << "SslServer: Failed to open certificate file" << qPrintable(path) << "error:" << certFile.error(); return false; } _cert = QSslCertificate(&certFile); - if (! certFile.reset()) { - qWarning() << "SslServer: IO error reading certificate file"; + if(!certFile.reset()) { + quWarning() << "SslServer: IO error reading certificate file"; return false; } _key = QSslKey(&certFile, QSsl::Rsa); certFile.close(); - if (_cert.isNull()) { - qWarning() << "SslServer:" << qPrintable(path) << "contains no certificate data"; + if(_cert.isNull()) { + quWarning() << "SslServer:" << qPrintable(path) << "contains no certificate data"; return false; } - if (! _cert.isValid()) { - qWarning() << "SslServer: Invalid certificate"; + if(!_cert.isValid()) { + quWarning() << "SslServer: Invalid certificate"; return false; } - if (_key.isNull()) { - qWarning() << "SslServer:" << qPrintable(path) << "contains no key data"; + if(_key.isNull()) { + quWarning() << "SslServer:" << qPrintable(path) << "contains no key data"; return false; } - _certIsValid = true; + _isCertValid = true; - return _certIsValid; + return _isCertValid; } #endif // HAVE_SSL diff --git a/src/core/sslserver.h b/src/core/sslserver.h index 6b5e5c8f..306bd8ef 100644 --- a/src/core/sslserver.h +++ b/src/core/sslserver.h @@ -39,7 +39,7 @@ public: virtual inline const QSslCertificate &certificate() const { return _cert; } virtual inline const QSslKey &key() const { return _key; } - virtual inline bool certIsValid() const { return _certIsValid; } + virtual inline bool isCertValid() const { return _isCertValid; } protected: virtual void incomingConnection(int socketDescriptor); @@ -49,7 +49,7 @@ private: QLinkedList _pendingConnections; QSslCertificate _cert; QSslKey _key; - bool _certIsValid; + bool _isCertValid; }; #endif //HAVE_SSL