[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-08-14 17:57:30
Message-ID: 1218736650.226965.26282.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 847085 by divanov:

Monitor changes in collections and items. That
code was lost during a recent cleanup


 M  +55 -0     rssresource.cpp  
 M  +8 -1      rssresource.h  


--- trunk/playground/pim/krss/resource/rssresource.cpp #847084:847085
@@ -30,6 +30,7 @@
 #include <akonadi/collectionmodifyjob.h>
 #include <akonadi/collectiondeletejob.h>
 #include <akonadi/attributefactory.h>
+#include <akonadi/changerecorder.h>
 
 #include <KDebug>
 #include <KFileDialog>
@@ -49,6 +50,8 @@
     AttributeFactory::registerAttribute<SubscriptionLabelsCollectionAttribute>();
     AttributeFactory::registerAttribute<FeedPropertiesCollectionAttribute>();
 
+    changeRecorder()->fetchCollection( true );
+
     new KrssAdaptor( this );
     if ( !QDBusConnection::sessionBus().registerObject( QLatin1String( "/KRss" ), \
this, QDBusConnection::ExportAdaptors ) ) {  kWarning() << "Couldn't register a D-Bus \
service org.kde.krss"; @@ -61,6 +64,58 @@
     connect( job, SIGNAL( result( KJob* ) ), this, SLOT( slotListingDone( KJob* ) ) \
);  }
 
+void RssResource::collectionAdded( const Akonadi::Collection &collection, const \
Akonadi::Collection &parent ) +{
+    Q_ASSERT( parent.id() == m_rootCollection.id() );
+
+    kDebug() << "Collection id:" << collection.id() << " , name:" << \
collection.name(); +    kDebug() << "Adding new feeds outside the RSS resource is not \
supported!"; +    changeCommitted( collection );
+}
+
+void RssResource::collectionChanged( const Akonadi::Collection &collection )
+{
+    Q_ASSERT( m_feeds.contains( collection.id() ) );
+
+    kDebug() << "Collection id:" << collection.id() << " , name:" << \
collection.name(); +    m_feeds[ collection.id() ] = collection;
+    changeCommitted( collection );
+}
+
+void RssResource::collectionRemoved( const Akonadi::Collection &collection )
+{
+    Q_ASSERT( m_feeds.contains( collection.id() ) );
+    // also check if the feed is being processed atm
+
+    kDebug() << "Collection id:" << collection.id() << " , name:" << \
collection.name(); +    abortFetch( collection.id() );
+    m_feeds.remove( collection.id() );
+    changeCommitted( collection );
+}
+
+void RssResource::itemAdded( const Akonadi::Item &item, const Akonadi::Collection \
&collection ) +{
+    Q_UNUSED( collection )
+
+    kDebug() << "Item id:" << item.id();
+    kDebug() << "Adding new RSS items is not supported!";
+    changeCommitted( item );
+}
+
+void RssResource::itemChanged( const Akonadi::Item &item, const QSet<QByteArray> \
&partIdentifiers ) +{
+    Q_UNUSED( partIdentifiers )
+
+    kDebug() << "Item id:" << item.id();
+    changeCommitted( item );
+}
+
+void RssResource::itemRemoved( const Akonadi::Item &item )
+{
+    kDebug() << "Item id:" << item.id();
+    changeCommitted( item );
+}
+
 qlonglong RssResource::addFeed( const QString &xmlUrl, const QString \
&subscriptionLabel )  {
     FeedCollection feed;
--- trunk/playground/pim/krss/resource/rssresource.h #847084:847085
@@ -28,7 +28,7 @@
 class KJob;
 class FetchFeedJob;
 
-class RssResource : public Akonadi::ResourceBase
+class RssResource : public Akonadi::ResourceBase, public \
Akonadi::AgentBase::Observer  {
     Q_OBJECT
     Q_CLASSINFO("D-Bus Interface","org.kde.krss")
@@ -37,6 +37,13 @@
 
     RssResource( const QString &id );
 
+    void collectionAdded( const Akonadi::Collection &collection, const \
Akonadi::Collection &parent ); +    void collectionChanged( const Akonadi::Collection \
&collection ); +    void collectionRemoved( const Akonadi::Collection &collection );
+    void itemAdded( const Akonadi::Item &item, const Akonadi::Collection &collection \
); +    void itemChanged( const Akonadi::Item &item, const QSet<QByteArray> \
&partIdentifiers ); +    void itemRemoved( const Akonadi::Item &item );
+
 public Q_SLOTS:
 
     void configure( WId windowId );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic