oidentd code cleanup
authorDaniel Albers <daniel@lbe.rs>
Sun, 12 Feb 2012 21:39:39 +0000 (22:39 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 13 Feb 2012 19:35:39 +0000 (20:35 +0100)
src/core/coreapplication.cpp
src/core/corenetwork.h
src/core/oidentdconfiggenerator.cpp
src/core/oidentdconfiggenerator.h

index f881d9e..f7f36c5 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "core.h"
 #include "logger.h"
-#include <QDebug>
 
 CoreApplicationInternal::CoreApplicationInternal()
   : _coreCreated(false)
index 005b309..8093bb6 100644 (file)
@@ -26,7 +26,6 @@
 #include "coreircuser.h"
 
 #include <QTimer>
-#include <QDebug>
 
 #ifdef HAVE_SSL
 # include <QSslSocket>
@@ -87,12 +86,12 @@ public:
 
   inline UserId userId() const { return _coreSession->user(); }
 
-  inline QAbstractSocket::SocketState socketState() { return socket.state(); }
-  inline bool socketConnected() { return socket.state() == QAbstractSocket::ConnectedState; }
-  inline QHostAddress localAddress() { return socket.localAddress(); }
-  inline QHostAddress peerAddress() { return socket.peerAddress(); }
-  inline quint16 localPort() { return socket.localPort(); }
-  inline quint16 peerPort() { return socket.peerPort(); }
+  inline QAbstractSocket::SocketState socketState() const { return socket.state(); }
+  inline bool socketConnected() const { return socket.state() == QAbstractSocket::ConnectedState; }
+  inline QHostAddress localAddress() const { return socket.localAddress(); }
+  inline QHostAddress peerAddress() const { return socket.peerAddress(); }
+  inline quint16 localPort() const { return socket.localPort(); }
+  inline quint16 peerPort() const { return socket.peerPort(); }
 
 public slots:
   virtual void setMyNick(const QString &mynick);
index 0f65349..fac6dcd 100644 (file)
@@ -31,27 +31,28 @@ OidentdConfigGenerator::OidentdConfigGenerator(QObject *parent) :
 OidentdConfigGenerator::~OidentdConfigGenerator() {
   _quasselConfig.clear();
   writeConfig();
+  _configFile->deleteLater();
 }
 
 bool OidentdConfigGenerator::init() {
-  configDir = QDir::homePath();
-  configFileName = ".oidentd.conf";
+  _configDir = QDir::homePath();
+  _configFileName = ".oidentd.conf";
 
   if(Quassel::isOptionSet("oidentd-conffile"))
-    configPath = Quassel::optionValue("oidentd-conffile");
+    _configPath = Quassel::optionValue("oidentd-conffile");
   else
-    configPath = configDir.absoluteFilePath(configFileName);
+    _configPath = _configDir.absoluteFilePath(_configFileName);
 
-  configTag = " stanza created by Quassel";
+  _configTag = " stanza created by Quassel";
 
-  _configFile = new QFile(configPath);
+  _configFile = new QFile(_configPath);
 
   // Rx has to match Template in order for cleanup to work.
   // Template should be enhanced with the "from" parameter as soon as Quassel gains
   // the ability to bind to an IP on client sockets.
 
-  quasselStanzaTemplate = QString("lport %1 { reply \"%2\" } #%3\n");
-  quasselStanzaRx = QRegExp(QString("^lport .* \\{ .* \\} #%1\\r?\\n").arg(configTag));
+  _quasselStanzaTemplate = QString("lport %1 { reply \"%2\" } #%3\n");
+  _quasselStanzaRx = QRegExp(QString("^lport .* \\{ .* \\} #%1\\r?\\n").arg(_configTag));
 
   // initially remove all Quassel stanzas that might be present
   if (parseConfig(false) && writeConfig())
@@ -64,7 +65,7 @@ bool OidentdConfigGenerator::addSocket(const CoreIdentity *identity, const QHost
   Q_UNUSED(localAddress) Q_UNUSED(peerAddress) Q_UNUSED(peerPort)
   QString ident = identity->ident();
 
-  _quasselConfig.append(quasselStanzaTemplate.arg(localPort).arg(ident).arg(configTag));
+  _quasselConfig.append(_quasselStanzaTemplate.arg(localPort).arg(ident).arg(_configTag).toAscii());
 
   bool ret = writeConfig();
 
@@ -122,5 +123,5 @@ bool OidentdConfigGenerator::writeConfig() {
 }
 
 bool OidentdConfigGenerator::lineByUs(const QByteArray &line) {
-  return quasselStanzaRx.exactMatch(line);
+  return _quasselStanzaRx.exactMatch(line);
 }
index edc5900..55c06ca 100644 (file)
@@ -56,7 +56,7 @@
 
 class OidentdConfigGenerator : public QObject
 {
-    Q_OBJECT
+  Q_OBJECT
 public:
   explicit OidentdConfigGenerator(QObject *parent = 0);
   ~OidentdConfigGenerator();
@@ -79,12 +79,12 @@ private:
   // Mutex isn't strictly necessary at the moment, since with the current invocation in Core only one instance at a time exists
   QMutex _mutex;
 
-  QDir configDir;
-  QString configFileName;
-  QString configPath;
-  QString configTag;
-  QRegExp quasselStanzaRx;
-  QString quasselStanzaTemplate;
+  QDir _configDir;
+  QString _configFileName;
+  QString _configPath;
+  QString _configTag;
+  QRegExp _quasselStanzaRx;
+  QString _quasselStanzaTemplate;
 };
 
 #endif // OIDENTDCONFIGGENERATOR_H