1 /***************************************************************************
2 * Copyright (C) 2012 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "oidentdconfiggenerator.h"
23 OidentdConfigGenerator::OidentdConfigGenerator(QObject *parent) :
27 qDebug() << "OidentdConfigGenerator() checking for being initialized";
32 bool OidentdConfigGenerator::init() {
33 configDir = QDir::homePath();
34 configFileName = ".oidentd.conf";
35 configTag = " stanza created by Quassel";
37 _configFile = new QFile(configDir.absoluteFilePath(configFileName));
38 qDebug() << "1: _configFile" << _configFile->fileName();
40 quasselStanza = QRegExp(QString("^lport .* { .* } #%1$").arg(configTag));
45 qDebug() << "konichi wa °-°";
50 bool OidentdConfigGenerator::update() {
52 qDebug() << "oidentd config parsed successfully";
54 qDebug() << QString("parsing oidentd config failed (%1 [%2])").arg(_configFile->errorString()).arg(_configFile->error());
59 bool OidentdConfigGenerator::parseConfig() {
60 qDebug() << "_configFile name" << _configFile->fileName();
61 qDebug() << "open?" << _configFile->isOpen();
62 if (!_configFile->isOpen() && !_configFile->open(QIODevice::ReadWrite))
65 QByteArray parsedConfig;
66 while (!_configFile->atEnd()) {
67 QByteArray line = _configFile->readLine();
70 parsedConfig.append(line);
73 _config = parsedConfig;
78 bool OidentdConfigGenerator::writeConfig() {
82 bool OidentdConfigGenerator::checkLine(const QByteArray &line) {
83 return !quasselStanza.exactMatch(line);