[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim-runtime/akregator_port] krsslocal: interval fetching (doesn't compile yet)
From: Alessandro Cosentino <cosenal () gmail ! com>
Date: 2012-03-31 15:16:46
Message-ID: 20120331151646.52DCEA60ED () git ! kde ! org
[Download RAW message or body]
Git commit 2d69de1891ff17bbf7a7a36365a90057496a1750 by Alessandro Cosentino.
Committed on 15/08/2011 at 04:21.
Pushed by osterfeld into branch 'akregator_port'.
interval fetching (doesn't compile yet)
M +56 -5 krsslocal/krsslocalresource.cpp
M +9 -0 krsslocal/krsslocalresource.h
http://commits.kde.org/kdepim-runtime/2d69de1891ff17bbf7a7a36365a90057496a1750
diff --git a/krsslocal/krsslocalresource.cpp b/krsslocal/krsslocalresource.cpp
index 191c1da..10f4f11 100644
--- a/krsslocal/krsslocalresource.cpp
+++ b/krsslocal/krsslocalresource.cpp
@@ -12,6 +12,9 @@
#include <QtXml/QXmlStreamReader>
#include <QMessageBox>
#include <akonadi/entitydisplayattribute.h>
+#include <Syndication/Loader>
+
+#define FETCH_INTERVAL 1800000 // (30 mins)
using namespace Akonadi;
using namespace KRssResource;
@@ -23,12 +26,17 @@ KRssLocalResource::KRssLocalResource( const QString &id )
new SettingsAdaptor( Settings::self() );
QDBusConnection::sessionBus().registerObject( QLatin1String( "/Settings" ),
Settings::self(), QDBusConnection::ExportAdaptors );
-
- // TODO: you can put any resource specific initialization code here.
+
+ timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), this, SLOT(intervalFetch()));
+ timer->setInterval(FETCH_INTERVAL);
+ timer->start();
+
}
KRssLocalResource::~KRssLocalResource()
{
+ timer->stop();
}
void KRssLocalResource::retrieveCollections()
@@ -119,7 +127,7 @@ Collection::List KRssLocalResource::buildCollectionTree( \
QList<shared_ptr<const void KRssLocalResource::retrieveItems( const \
Akonadi::Collection &collection ) {
- Q_UNUSED(collection);
+ //Q_UNUSED(collection);
// TODO: this method is called when Akonadi wants to know about all the
// items in the given collection. You can but don't have to provide all the
@@ -127,9 +135,14 @@ void KRssLocalResource::retrieveItems( const Akonadi::Collection \
&collection ) // Depending on how your resource accesses the data, there are several
// different ways to tell Akonadi when you are done.
+ QString xmlUrl = collection.remoteId();
- Item::List itemlist;
- itemsRetrieved(itemlist);
+ Item::List items;
+ Item prova;
+ prova.setId(12);
+ prova.setRemoteId(xmlUrl + "1");
+ items << prova;
+ itemsRetrieved(items);
}
@@ -211,6 +224,44 @@ void KRssLocalResource::itemRemoved( const Akonadi::Item &item )
// of this template code to keep it simple
}
+void KRssLocalResource::intervalFetch()
+{
+
+
+
+}
+
+void KRssLocalResource::fetchFeed(const Akonadi::Collection &feed)
+{
+
+ Syndication::Loader * const loader = Syndication::Loader::create();
+ connect( loader, SIGNAL( loadingComplete( Syndication::Loader*, \
Syndication::FeedPtr, Syndication::ErrorCode ) ), + this, SLOT( \
slotFeedFetched( Syndication::Loader*, Syndication::FeedPtr, Syndication::ErrorCode ) \
) ); + KUrl xmlUrl( feed.remoteId() );
+ loader->loadFrom( xmlUrl );
+
+}
+
+void KRssLocalResource::slotLoadingComplete(Syndication::Loader* loader, \
Syndication::FeedPtr feed, + Syndication::ErrorCode status)
+{
+ if (status != Syndication::Success)
+ return;
+
+ QString title = feed->title();
+ const QList<Syndication::ItemPtr> syndItems = feed->items();
+ Q_FOREACH( const Syndication::ItemPtr& syndItem, syndItems ) {
+ Akonadi::Item item;
+ item.setRemoteId( syndItem->id() );
+ /*
+ item.setMimeType( KRss::Item::mimeType() );
+ item.setPayload<KRss::RssItem>( KRssResource::fromSyndicationItem( \
syndItem ) ); + item.setFlag( KRss::RssItem::flagNew() );
+ m_items.append( item );
+ */
+ }
+}
+
AKONADI_RESOURCE_MAIN( KRssLocalResource )
#include "krsslocalresource.moc"
diff --git a/krsslocal/krsslocalresource.h b/krsslocal/krsslocalresource.h
index b29ff2a..7e6106e 100644
--- a/krsslocal/krsslocalresource.h
+++ b/krsslocal/krsslocalresource.h
@@ -4,6 +4,7 @@
#include <akonadi/resourcebase.h>
#include <boost/shared_ptr.hpp>
#include <krssresource/opmlparser.h>
+#include <qtimer.h>
class KRssLocalResource : public Akonadi::ResourceBase,
public Akonadi::AgentBase::Observer
@@ -24,12 +25,20 @@ class KRssLocalResource : public Akonadi::ResourceBase,
void retrieveItems( const Akonadi::Collection &col );
bool retrieveItem( const Akonadi::Item &item, const QSet<QByteArray> &parts );
+ private Q_SLOTS:
+ void intervalFetch();
+
protected:
virtual void aboutToQuit();
virtual void itemAdded( const Akonadi::Item &item, const Akonadi::Collection \
&collection );
virtual void itemChanged( const Akonadi::Item &item, const QSet<QByteArray> \
&parts ); virtual void itemRemoved( const Akonadi::Item &item );
+
+ void fetchFeed( const Akonadi::Collection &feed );
+
+ private:
+ QTimer timer;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic