From 9c15e81b15a20e861c707e240c2cfee56bdf4bc9 Mon Sep 17 00:00:00 2001 From: Daniel Albers Date: Sun, 12 Feb 2012 22:39:39 +0100 Subject: [PATCH] oidentd code cleanup --- src/core/coreapplication.cpp | 1 - src/core/corenetwork.h | 13 ++++++------- src/core/oidentdconfiggenerator.cpp | 21 +++++++++++---------- src/core/oidentdconfiggenerator.h | 14 +++++++------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/core/coreapplication.cpp b/src/core/coreapplication.cpp index f881d9ec..f7f36c54 100644 --- a/src/core/coreapplication.cpp +++ b/src/core/coreapplication.cpp @@ -22,7 +22,6 @@ #include "core.h" #include "logger.h" -#include CoreApplicationInternal::CoreApplicationInternal() : _coreCreated(false) diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index 005b309e..8093bb61 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -26,7 +26,6 @@ #include "coreircuser.h" #include -#include #ifdef HAVE_SSL # include @@ -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); diff --git a/src/core/oidentdconfiggenerator.cpp b/src/core/oidentdconfiggenerator.cpp index 0f653497..fac6dcd9 100644 --- a/src/core/oidentdconfiggenerator.cpp +++ b/src/core/oidentdconfiggenerator.cpp @@ -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); } diff --git a/src/core/oidentdconfiggenerator.h b/src/core/oidentdconfiggenerator.h index edc59001..55c06caf 100644 --- a/src/core/oidentdconfiggenerator.h +++ b/src/core/oidentdconfiggenerator.h @@ -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 -- 2.20.1