[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-28 18:22:05
Message-ID: 1214677325.386341.22388.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 825580 by divanov:
Revert the last commit: there is no need to store RSS items on disk
M +1 -3 CMakeLists.txt
D maildir.h
D maildir_export.h
D maildirstorage.cpp
D maildirstorage.h
M +19 -39 rssresource.cpp
M +0 -5 rssresource.h
--- trunk/playground/pim/krss/resource/CMakeLists.txt #825579:825580
@@ -6,15 +6,13 @@
../libkrss/tagscollectionattribute.cpp
../libkrss/subscriptionlabelscollectionattribute.cpp
../libkrss/feedpropertiescollectionattribute.cpp
- maildirstorage.cpp
)
qt4_add_dbus_adaptor(rssresource_SRCS ../libkrss/org.kde.krss.xml rssresource.h \
RssResource )
kde4_add_executable(akonadi_rss_resource RUN_UNINSTALLED ${rssresource_SRCS})
-target_link_libraries(akonadi_rss_resource ${KDE4_AKONADI_LIBS} ${QT_QTDBUS_LIBRARY} \
${KDE4_KIO_LIBRARY} ${KDE4_SYNDICATION_LIBS} kfeed
- maildir)
+target_link_libraries(akonadi_rss_resource ${KDE4_AKONADI_LIBS} ${QT_QTDBUS_LIBRARY} \
${KDE4_KIO_LIBRARY} ${KDE4_SYNDICATION_LIBS} kfeed)
install(TARGETS akonadi_rss_resource ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES rssresource.desktop DESTINATION \
"${CMAKE_INSTALL_PREFIX}/share/akonadi/agents")
--- trunk/playground/pim/krss/resource/rssresource.cpp #825579:825580
@@ -24,7 +24,6 @@
#include <kfeed/person.h>
#include <kfeed/enclosure.h>
#include <kfeed/category.h>
-#include <kfeed/itemserializer.h>
#include <akonadi/collectionfetchjob.h>
#include <akonadi/collectioncreatejob.h>
#include <akonadi/collectionmodifyjob.h>
@@ -36,7 +35,7 @@
#include <KFileDialog>
#include <KDateTime>
#include <KLocale>
-#include <KStandardDirs>
+#include <KRandom>
#include <QDBusConnection>
@@ -130,7 +129,7 @@
// member functions
RssResource::RssResource( const QString &id )
- :ResourceBase( id ), m_fetchTries( 0 ), m_storage( 0 )
+ :ResourceBase( id ), m_fetchTries( 0 )
{
AttributeFactory::registerAttribute<TagsCollectionAttribute>();
AttributeFactory::registerAttribute<SubscriptionLabelsCollectionAttribute>();
@@ -142,8 +141,6 @@
kWarning() << QDBusConnection::sessionBus().lastError().message();
}
- m_storage = new MaildirStorage( KGlobal::dirs()->saveLocation( "appdata", \
"storage/" ) );
-
changeRecorder()->fetchCollection( true );
listCollections();
}
@@ -153,7 +150,7 @@
Akonadi::Collection col;
col.setParent( m_rootCollection );
col.setContentMimeTypes( QStringList( "application/rss+xml" ) );
- col.setRemoteId( m_storage->addFeed() );
+ col.setRemoteId( KRandom::randomString( 10 ) );
col.setName( xmlUrl + '_' + col.remoteId() );
col.attribute<FeedPropertiesCollectionAttribute>( \
Akonadi::Collection::AddIfMissing )->setXmlUrl( xmlUrl );
col.attribute<SubscriptionLabelsCollectionAttribute>( \
Akonadi::Collection::AddIfMissing )->addSubscriptionLabel( subscriptionLabel ); @@ \
-374,7 +371,8 @@ }
else {
kDebug() << "Collection doesn't have \'FeedProperties\' attribute \
set";
- itemsRetrievedIncremental( Akonadi::Item::List(), \
Akonadi::Item::List() ); + Item::List itemList;
+ itemsRetrieved( itemList );
}
}
@@ -407,23 +405,10 @@
kDebug() << "Collections:";
QHashIterator<QString, Akonadi::Collection> it(m_collections);
- KFeed::ItemSerializer *ser = new KFeed::XmlItemSerializerImpl();
while ( it.hasNext() ) {
it.next();
kDebug() << "Remote id:" << it.key() << ", name:" << \
it.value().name() << ", id:" << it.value().id();
- if ( it.value().parent() == Akonadi::Collection::root().id() ) {
- kDebug() << "Skipping";
- continue;
- }
- QStringList articleEntries = m_storage->articles( it.key() );
- Q_FOREACH( const QString &articleEntry, articleEntries ) {
- KFeed::Item article;
- ser->deserialize( article, m_storage->readArticle( it.key(), \
articleEntry ) );
- kDebug() << "Article id:" << article.id();
- m_items[ it.key() ][ article.id() ] = articleEntry;
- }
}
- delete ser;
}
void RssResource::slotRootCollectionCreated( KJob *job )
@@ -603,30 +588,25 @@
{
Q_UNUSED( loader )
+ kDebug() << "Status:" << status;
+
+ Item::List itemList;
if ( status != Syndication::Success ) {
kDebug() << "Failed to load feed from"
- << \
currentCollection().attribute<FeedPropertiesCollectionAttribute>()->xmlUrl()
- << ", status:" << status;;
- itemsRetrievedIncremental( Akonadi::Item::List(), \
Akonadi::Item::List() ); + << \
currentCollection().attribute<FeedPropertiesCollectionAttribute>()->xmlUrl(); + \
itemsRetrieved( itemList ); return;
}
- Akonadi::Item::List newItems;
Q_FOREACH( const Syndication::ItemPtr &it, feed->items() ) {
- if ( !m_items.value( currentCollection().remoteId() ).contains( \
it->id() ) ) {
- kDebug() << "New article:" << it->id();
- Item item;
- item.setRemoteId( it->id() );
- item.setMimeType( "application/rss+xml" );
- item.setPayload<KFeed::Item>( convertToKFeedItem( it ) );
- newItems.append( item );
-
- QString articleEntry = m_storage->addArticle( \
currentCollection().remoteId(), item.payloadData() );
- m_items[ currentCollection().remoteId() ][ it->id() ] = \
articleEntry;
- }
+ Item item;
+ item.setRemoteId( it->id() );
+ item.setMimeType( "application/rss+xml" );
+ item.setPayload<KFeed::Item>( convertToKFeedItem( it ) );
+ itemList.append( item );
}
- itemsRetrievedIncremental( newItems, Akonadi::Item::List() );
+ itemsRetrieved( itemList );
}
void RssResource::importOpml( const QString &path, const QString &defaultTag )
@@ -638,8 +618,8 @@
// start with creating the root collection
Collection root;
root.setParent( Collection::root() );
- root.setRemoteId( identifier() + "_storage" );
- root.setName( "feeds_" + root.remoteId() );
+ root.setRemoteId( KRandom::randomString( 10 ) );
+ root.setName( "RSS subscriptions_" + root.remoteId() );
root.setContentMimeTypes( QStringList( Collection::mimeType() ) );
Akonadi::CollectionCreateJob *job = new \
Akonadi::CollectionCreateJob( root ); @@ -774,7 +754,7 @@
kDebug() << "Feed:" << xmlUrl;
isFolder = false;
Collection col;
- col.setRemoteId( m_storage->addFeed() );
+ col.setRemoteId( KRandom::randomString( 10 ) );
col.setName( xmlUrl + '_' + col.remoteId() );
col.setParent( m_rootCollection );
col.setContentMimeTypes( QStringList( "application/rss+xml" ) );
--- trunk/playground/pim/krss/resource/rssresource.h #825579:825580
@@ -18,8 +18,6 @@
#ifndef KRSS_RSSRESOURCE
#define KRSS_RSSRESOURCE
-#include "maildirstorage.h"
-
#include <kfeed/item.h>
#include <syndication/syndication.h>
#include <akonadi/resourcebase.h>
@@ -104,9 +102,6 @@
QXmlStreamWriter m_writer;
QDBusMessage m_replyMessage;
-
- MaildirStorage *m_storage;
- QHash<QString, QHash<QString,QString> > m_items;
};
#endif /* KRSS_RSSRESOURCE */
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic