X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Foidentdconfiggenerator.cpp;h=91a7f5bde0c6d76be0ff8f755a816b34f737f78f;hp=ecb69b495a878c86abcaa9f559e62d635ee465be;hb=ca06a6758ab9463becafc453d5f6a32cb3b729a0;hpb=b5c64cce8e7813090809a3e4de8f88e148f84392 diff --git a/src/core/oidentdconfiggenerator.cpp b/src/core/oidentdconfiggenerator.cpp index ecb69b49..91a7f5bd 100644 --- a/src/core/oidentdconfiggenerator.cpp +++ b/src/core/oidentdconfiggenerator.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2019 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -19,8 +19,8 @@ ***************************************************************************/ #ifdef HAVE_UMASK -# include -# include +# include +# include #endif /* HAVE_UMASK */ #include @@ -28,15 +28,13 @@ #include "corenetwork.h" #include "oidentdconfiggenerator.h" -OidentdConfigGenerator::OidentdConfigGenerator(QObject *parent) : - QObject(parent), - _initialized(false) +OidentdConfigGenerator::OidentdConfigGenerator(QObject* parent) + : QObject(parent) { if (!_initialized) init(); } - OidentdConfigGenerator::~OidentdConfigGenerator() { _quasselConfig.clear(); @@ -44,10 +42,9 @@ OidentdConfigGenerator::~OidentdConfigGenerator() _configFile->deleteLater(); } - bool OidentdConfigGenerator::init() { - _configDir = QDir::homePath(); + _configDir.setPath(QDir::homePath()); _configFileName = ".oidentd.conf"; if (Quassel::isOptionSet("oidentd-conffile")) @@ -64,7 +61,7 @@ bool OidentdConfigGenerator::init() // 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)); + _quasselStanzaRx = QRegExp(QString(R"(^lport .* \{ .* \} #%1\r?\n)").arg(_configTag)); // initially remove all Quassel stanzas that might be present if (parseConfig(false) && writeConfig()) @@ -73,17 +70,18 @@ bool OidentdConfigGenerator::init() return _initialized; } - -QString OidentdConfigGenerator::sysIdentForIdentity(const CoreIdentity *identity) const { +QString OidentdConfigGenerator::sysIdentForIdentity(const CoreIdentity* identity) const +{ // Make sure the identity's ident complies with strict mode if enabled - const CoreNetwork *network = qobject_cast(sender()); + const CoreNetwork* network = qobject_cast(sender()); return network->coreSession()->strictCompliantIdent(identity); } - -bool OidentdConfigGenerator::addSocket(const CoreIdentity *identity, - const QHostAddress &localAddress, quint16 localPort, - const QHostAddress &peerAddress, quint16 peerPort, +bool OidentdConfigGenerator::addSocket(const CoreIdentity* identity, + const QHostAddress& localAddress, + quint16 localPort, + const QHostAddress& peerAddress, + quint16 peerPort, qint64 socketId) { Q_UNUSED(localAddress) @@ -100,11 +98,12 @@ bool OidentdConfigGenerator::addSocket(const CoreIdentity *identity, return ret; } - //! not yet implemented -bool OidentdConfigGenerator::removeSocket(const CoreIdentity *identity, - const QHostAddress &localAddress, quint16 localPort, - const QHostAddress &peerAddress, quint16 peerPort, +bool OidentdConfigGenerator::removeSocket(const CoreIdentity* identity, + const QHostAddress& localAddress, + quint16 localPort, + const QHostAddress& peerAddress, + quint16 peerPort, qint64 socketId) { Q_UNUSED(identity) @@ -117,7 +116,6 @@ bool OidentdConfigGenerator::removeSocket(const CoreIdentity *identity, return true; } - bool OidentdConfigGenerator::parseConfig(bool readQuasselStanzas) { if (!_configFile->exists()) @@ -143,11 +141,10 @@ bool OidentdConfigGenerator::parseConfig(bool readQuasselStanzas) return true; } - bool OidentdConfigGenerator::writeConfig() { #ifdef HAVE_UMASK - mode_t prev_umask = umask(S_IXUSR | S_IWGRP | S_IXGRP | S_IWOTH | S_IXOTH); // == 0133, rw-r--r-- + mode_t prev_umask = umask(S_IXUSR | S_IWGRP | S_IXGRP | S_IWOTH | S_IXOTH); // == 0133, rw-r--r-- #endif bool not_open = (!_configFile->isOpen() && !_configFile->open(QIODevice::ReadWrite | QIODevice::Text)); #ifdef HAVE_UMASK @@ -169,8 +166,7 @@ bool OidentdConfigGenerator::writeConfig() return true; } - -bool OidentdConfigGenerator::lineByUs(const QByteArray &line) +bool OidentdConfigGenerator::lineByUs(const QByteArray& line) { return _quasselStanzaRx.exactMatch(line); }