/* This file is part of Akregator. Copyright (C) 2008 Didier Hoarau This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include "opml.h" #include #include #include #include namespace feedsync { Opml::Opml(const KConfigGroup& configgroup, QObject* parent) : Aggregator( parent ), _xmlDoc( 0 ), _xmlFile( configgroup.readEntry("Filename") ), _loaded( false ) { kDebug(); } Opml::~Opml() { kDebug(); delete _xmlDoc; } SubscriptionList Opml::getSubscriptionList() const { kDebug(); return _subscriptionList; } void Opml::load() { kDebug(); // If not already done load the file if ( !_loaded ) { } // Read the XML delete _xmlDoc; _xmlDoc = new QDomDocument("opml"); if (!_xmlFile.open(QIODevice::ReadOnly)) { kDebug() << "File Error"; delete _xmlDoc; _xmlDoc = 0; return; } if (!_xmlDoc->setContent(&_xmlFile)) { kDebug() << "File Error"; _xmlFile.close(); delete _xmlDoc; _xmlDoc = 0; return; } _xmlFile.close(); QDomNodeList nodeList = _xmlDoc->elementsByTagName("outline"); bool firstCat = true; QString cat; for (int i=0;idocumentElement().firstChild().nextSibling(); QString m_rss; for (int i=0;icreateElement("outline"); m_element.setAttribute(QString("title"),list.getName(i)); m_element.setAttribute(QString("type"),QString("rss")); m_element.setAttribute(QString("text"),list.getName(i)); m_element.setAttribute(QString("xmlUrl"),m_rss); // append nodeList.appendChild(m_element); } // TODO Test save QFile file; QTextStream out; file.setFileName("~/out.xml"); if (!file.open(QIODevice::WriteOnly)) return; out.setDevice(&file); _xmlDoc->save(out,2); file.close(); // Send signal emit addDone(); } void Opml::update(const SubscriptionList & list) { Q_UNUSED(list) kDebug(); // Send signal emit updateDone(); } void Opml::remove(const SubscriptionList & list) { Q_UNUSED(list) kDebug(); // Send signal emit removeDone(); } }