Formatting, make strings translateable, naming convention++
authorManuel Nickschas <sputnick@quassel-irc.org>
Fri, 16 Jan 2009 20:15:27 +0000 (21:15 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Fri, 16 Jan 2009 20:15:27 +0000 (21:15 +0100)
src/core/sslserver.cpp
src/core/sslserver.h

index bfcdbf2..f256923 100644 (file)
 #endif
 
 #include <QFile>
 #endif
 
 #include <QFile>
-#include <QDebug>
 
 #include "logger.h"
 #include "util.h"
 
 #ifdef HAVE_SSL
 
 
 #include "logger.h"
 #include "util.h"
 
 #ifdef HAVE_SSL
 
-static bool SslServer_longMessShown=false;
-
 SslServer::SslServer(QObject *parent)
 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: 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)) {
 void SslServer::incomingConnection(int socketDescriptor) {
   QSslSocket *serverSocket = new QSslSocket(this);
   if(serverSocket->setSocketDescriptor(socketDescriptor)) {
-    if(certIsValid()) {
+    if(isCertValid()) {
       serverSocket->setLocalCertificate(_cert);
       serverSocket->setPrivateKey(_key);
     }
       serverSocket->setLocalCertificate(_cert);
       serverSocket->setPrivateKey(_key);
     }
@@ -70,50 +69,49 @@ void SslServer::incomingConnection(int socketDescriptor) {
 }
 
 bool SslServer::setCertificate(const QString &path) {
 }
 
 bool SslServer::setCertificate(const QString &path) {
-  _certIsValid = false;
+  _isCertValid = false;
 
 
-  if (path.isNull()) {
+  if(path.isEmpty())
     return false;
     return false;
-  }
 
   QFile certFile(path);
 
   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;
   }
 
     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);
 
       << "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();
 
     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;
   }
     return false;
   }
-  if (! _cert.isValid()) {
-    qWarning() << "SslServer: Invalid certificate";
+  if(!_cert.isValid()) {
+    quWarning() << "SslServer: Invalid certificate";
     return false;
   }
     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;
   }
 
     return false;
   }
 
-  _certIsValid = true;
+  _isCertValid = true;
 
 
-  return _certIsValid;
+  return _isCertValid;
 }
 
 #endif // HAVE_SSL
 }
 
 #endif // HAVE_SSL
index 6b5e5c8..306bd8e 100644 (file)
@@ -39,7 +39,7 @@ public:
 
   virtual inline const QSslCertificate &certificate() const { return _cert; }
   virtual inline const QSslKey &key() const { return _key; }
 
   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);
 
 protected:
   virtual void incomingConnection(int socketDescriptor);
@@ -49,7 +49,7 @@ private:
   QLinkedList<QTcpSocket *> _pendingConnections;
   QSslCertificate _cert;
   QSslKey _key;
   QLinkedList<QTcpSocket *> _pendingConnections;
   QSslCertificate _cert;
   QSslKey _key;
-  bool _certIsValid;
+  bool _isCertValid;
 };
 
 #endif //HAVE_SSL
 };
 
 #endif //HAVE_SSL