[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/krss/resource
From: Dmitry Ivanov <vonami () gmail ! com>
Date: 2008-06-22 14:32:07
Message-ID: 1214145127.618791.5802.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 823073 by divanov:
Support for export in OPML v2 (not enabled yet)
M +52 -0 rssresource.cpp
M +6 -0 rssresource.h
--- trunk/playground/pim/krss/resource/rssresource.cpp #823072:823073
@@ -782,6 +782,58 @@
tags.removeLast();
}
+bool RssResource::exportOpml( const QString &path )
+{
+ QFile file( path );
+ if ( !file.open( QFile::WriteOnly | QFile::Text ) ) {
+ kWarning() << "Couldn't create an OPML document";
+ return false;
+ }
+
+ m_writer.setDevice( &file );
+
+ m_writer.writeStartDocument();
+ m_writer.writeStartElement( "opml" );
+ m_writer.writeAttribute( "version", "2.0" );
+ m_writer.writeEmptyElement( "head" );
+ m_writer.writeStartElement( "body" );
+ Q_FOREACH( const Akonadi::Collection &col, m_collections ) {
+ if ( col.id() != m_rootCollection.id() ) {
+ writeOutline( col );
+ }
+ }
+ m_writer.writeEndElement(); // body
+ m_writer.writeEndElement(); // opml
+ m_writer.writeEndDocument();
+
+ file.close();
+ return true;
+}
+
+void RssResource::writeOutline( const Akonadi::Collection &col )
+{
+ Q_ASSERT( col.hasAttribute( "FeedProperties" ) );
+
+ FeedPropertiesCollectionAttribute *props = col.attribute<FeedPropertiesCollectionAttribute>();
+ m_writer.writeEmptyElement( "outline" );
+ m_writer.writeAttribute( "id", col.remoteId() );
+ m_writer.writeAttribute( "text", props->name() );
+ m_writer.writeAttribute( "title", props->name() );
+ m_writer.writeAttribute( "description", props->description() );
+ m_writer.writeAttribute( "htmlUrl", props->htmlUrl() );
+ m_writer.writeAttribute( "xmlUrl", props->xmlUrl() );
+
+ if ( col.hasAttribute( "Tags" ) ) {
+ QStringList tags = col.attribute<TagsCollectionAttribute>()->tags();
+ QString category;
+ Q_FOREACH( const QString &tag, tags ) {
+ category += tag + ',';
+ }
+ category.remove( category.length() - 1, 1 );
+ m_writer.writeAttribute( "category", category );
+ }
+}
+
AKONADI_RESOURCE_MAIN(RssResource)
#include "rssresource.moc"
--- trunk/playground/pim/krss/resource/rssresource.h #823072:823073
@@ -25,6 +25,7 @@
#include <QStack>
#include <QHash>
#include <QXmlStreamReader>
+#include <QXmlStreamWriter>
class RssResource : public Akonadi::ResourceBase, public Akonadi::AgentBase::Observer
{
@@ -85,6 +86,9 @@
void readBody();
void readOutline( QStringList &tags );
+ bool exportOpml( const QString &path );
+ void writeOutline( const Akonadi::Collection &col );
+
private:
int m_fetchTries;
@@ -93,7 +97,9 @@
QHash<QString, Akonadi::Collection> m_collections;
QStack<Akonadi::Collection> m_pendingCollections;
Akonadi::Collection m_currentCollection;
+
QXmlStreamReader m_reader;
+ QXmlStreamWriter m_writer;
QDBusMessage m_replyMessage;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic