[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-07-05 20:05:44
Message-ID: 1215288344.132410.20917.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 828432 by divanov:

KJob wrappers for addTag()/removeTag()/subscribe()/unsubscribe()/removeFeed()


 M  +2 -0      CMakeLists.txt  
 A             deletefeedjob.cpp   [License: GPL (v2+)]
 A             deletefeedjob.h   [License: GPL (v2+)]
 A             modifyfeedjob.cpp   [License: GPL (v2+)]
 A             modifyfeedjob.h   [License: GPL (v2+)]
 M  +54 -58    rssresource.cpp  
 M  +2 -6      rssresource.h  


--- trunk/playground/pim/krss/resource/CMakeLists.txt #828431:828432
@@ -10,6 +10,8 @@
     ../libkrss/flagsmodifyjob.cpp
     syncfeedjob.cpp
     addfeedjob.cpp
+    modifyfeedjob.cpp
+    deletefeedjob.cpp
 )
 
 qt4_add_dbus_adaptor(rssresource_SRCS ../libkrss/org.kde.krss.xml rssresource.h \
                RssResource )
--- trunk/playground/pim/krss/resource/rssresource.cpp #828431:828432
@@ -22,6 +22,8 @@
 #include "../libkrss/feedpropertiescollectionattribute.h"
 #include "syncfeedjob.h"
 #include "addfeedjob.h"
+#include "modifyfeedjob.h"
+#include "deletefeedjob.h"
 
 #include <akonadi/collectionfetchjob.h>
 #include <akonadi/collectioncreatejob.h>
@@ -113,14 +115,15 @@
                 return false;
         }
 
-        Akonadi::CollectionDeleteJob *job = new Akonadi::CollectionDeleteJob( \
                m_collections[ remoteId ] );
-        connect( job, SIGNAL( result( KJob* ) ),
-                 this, SLOT( slotCollectionDeleted( KJob* ) ) );
+        DeleteFeedJob *job = new DeleteFeedJob( m_collections[ remoteId ] );
+        connect( job, SIGNAL( result( KJob* ) ), this, SLOT( feedDeletionDone( KJob* \
) ) );  
         // send the reply later
         setDelayedReply( true );
-        m_replyMessage = QDBusContext::message().createReply();
+        job->setReplyMessage( QDBusContext::message().createReply() );
 
+        job->start();
+
         return false;
 }
 
@@ -131,17 +134,18 @@
                 return false;
         }
 
-        m_currentCollection = m_collections[ remoteId ];
-        m_currentCollection.attribute<SubscriptionLabelsCollectionAttribute>( \
                Akonadi::Collection::AddIfMissing )->
-                                     addSubscriptionLabel( subscriptionLabel );
-        Akonadi::CollectionModifyJob *job = new Akonadi::CollectionModifyJob( \
                m_currentCollection );
-        connect( job, SIGNAL( result( KJob* ) ),
-                 this, SLOT( slotSubscriptionDone( KJob* ) ) );
+        Akonadi::Collection col = m_collections[ remoteId ];
+        col.attribute<SubscriptionLabelsCollectionAttribute>( \
Akonadi::Collection::AddIfMissing )-> +                                               \
addSubscriptionLabel( subscriptionLabel ); +        ModifyFeedJob *job = new \
ModifyFeedJob( col ); +        connect( job, SIGNAL( result( KJob* ) ), this, SLOT( \
feedModificationDone( KJob* ) ) );  
         // send the reply later
         setDelayedReply( true );
-        m_replyMessage = QDBusContext::message().createReply();
+        job->setReplyMessage( QDBusContext::message().createReply() );
 
+        job->start();
+
         return false;
 }
 
@@ -152,17 +156,18 @@
                 return false;
         }
 
-        m_currentCollection = m_collections[ remoteId ];
-        m_currentCollection.attribute<SubscriptionLabelsCollectionAttribute>( \
                Akonadi::Collection::AddIfMissing )->
-                                     removeSubscriptionLabel( subscriptionLabel );
-        Akonadi::CollectionModifyJob *job = new Akonadi::CollectionModifyJob( \
                m_currentCollection );
-        connect( job, SIGNAL( result( KJob* ) ),
-                 this, SLOT( slotSubscriptionDone( KJob* ) ) );
+        Akonadi::Collection col = m_collections[ remoteId ];
+        col.attribute<SubscriptionLabelsCollectionAttribute>( \
Akonadi::Collection::AddIfMissing )-> +                                               \
removeSubscriptionLabel( subscriptionLabel ); +        ModifyFeedJob *job = new \
ModifyFeedJob( col ); +        connect( job, SIGNAL( result( KJob* ) ), this, SLOT( \
feedModificationDone( KJob* ) ) );  
         // send the reply later
         setDelayedReply( true );
-        m_replyMessage = QDBusContext::message().createReply();
+        job->setReplyMessage( QDBusContext::message().createReply() );
 
+        job->start();
+
         return false;
 }
 
@@ -187,16 +192,17 @@
                 return false;
         }
 
-        m_currentCollection = m_collections[ remoteId ];
-        m_currentCollection.attribute<TagsCollectionAttribute>( \
                Akonadi::Collection::AddIfMissing )->addTag( tag );
-        Akonadi::CollectionModifyJob *job = new Akonadi::CollectionModifyJob( \
                m_currentCollection );
-        connect( job, SIGNAL( result( KJob* ) ),
-                 this, SLOT( slotTaggingDone( KJob* ) ) );
+        Akonadi::Collection col = m_collections[ remoteId ];
+        col.attribute<TagsCollectionAttribute>( Akonadi::Collection::AddIfMissing \
)->addTag( tag ); +        ModifyFeedJob *job = new ModifyFeedJob( col );
+        connect( job, SIGNAL( result( KJob* ) ), this, SLOT( feedModificationDone( \
KJob* ) ) );  
         // send the reply later
         setDelayedReply( true );
-        m_replyMessage = QDBusContext::message().createReply();
+        job->setReplyMessage( QDBusContext::message().createReply() );
 
+        job->start();
+
         return false;
 }
 
@@ -207,16 +213,17 @@
                 return false;
         }
 
-        m_currentCollection = m_collections[ remoteId ];
-        m_currentCollection.attribute<TagsCollectionAttribute>( \
                Akonadi::Collection::AddIfMissing )->removeTag( tag );
-        Akonadi::CollectionModifyJob *job = new Akonadi::CollectionModifyJob( \
                m_currentCollection );
-        connect( job, SIGNAL( result( KJob* ) ),
-                 this, SLOT( slotTaggingDone( KJob* ) ) );
+        Akonadi::Collection col = m_collections[ remoteId ];
+        col.attribute<TagsCollectionAttribute>( Akonadi::Collection::AddIfMissing \
)->removeTag( tag ); +        ModifyFeedJob *job = new ModifyFeedJob( col );
+        connect( job, SIGNAL( result( KJob* ) ), this, SLOT( feedModificationDone( \
KJob* ) ) );  
         // send the reply later
         setDelayedReply( true );
-        m_replyMessage = QDBusContext::message().createReply();
+        job->setReplyMessage( QDBusContext::message().createReply() );
 
+        job->start();
+
         return false;
 }
 
@@ -427,54 +434,43 @@
         QDBusConnection::sessionBus().send( replyMessage );
 }
 
-void RssResource::slotCollectionDeleted( KJob *job )
+void RssResource::feedDeletionDone( KJob *job )
 {
-        kDebug() << "CollectionDeleteJob done";
-        if ( job->error() ) {
-                kWarning() << "Failed to delete the collection";
-                kWarning() << job->errorString();
-                m_replyMessage << false;
-        }
-        else {
-                m_replyMessage << true;
-        }
+        kDebug() << "Feed deletion done";
 
-        // return the result to the caller
-        QDBusConnection::sessionBus().send( m_replyMessage );
-}
-
-void RssResource::slotSubscriptionDone( KJob *job )
-{
-        kDebug() << "CollectionModifyJob done";
+        QDBusMessage replyMessage = static_cast<DeleteFeedJob*>( job \
)->replyMessage();  if ( job->error() ) {
-                kWarning() << "Failed to modify the collection";
+                kWarning() << "Failed to delete the feed";
                 kWarning() << job->errorString();
-                m_replyMessage << false;
+                replyMessage << false;
         }
         else {
-                m_collections[ m_currentCollection.remoteId() ] = \
                m_currentCollection;
-                m_replyMessage << true;
+                m_collections.remove( static_cast<DeleteFeedJob*>( job \
)->collection().remoteId() ); +                replyMessage << true;
         }
 
         // return the result to the caller
-        QDBusConnection::sessionBus().send( m_replyMessage );
+        QDBusConnection::sessionBus().send( replyMessage );
 }
 
-void RssResource::slotTaggingDone( KJob *job )
+void RssResource::feedModificationDone( KJob *job )
 {
-        kDebug() << "CollectionModifyJob done";
+        kDebug() << "Collection modification done";
+
+        QDBusMessage replyMessage = static_cast<ModifyFeedJob*>( job \
)->replyMessage();  if ( job->error() ) {
                 kWarning() << "Failed to modify the collection";
                 kWarning() << job->errorString();
-                m_replyMessage << false;
+                replyMessage << false;
         }
         else {
-                m_collections[ m_currentCollection.remoteId() ] = \
                m_currentCollection;
-                m_replyMessage << true;
+                Akonadi::Collection col = static_cast<ModifyFeedJob*>( job \
)->collection(); +                m_collections[ col.remoteId() ] = col;
+                replyMessage << true;
         }
 
         // return the result to the caller
-        QDBusConnection::sessionBus().send( m_replyMessage );
+        QDBusConnection::sessionBus().send( replyMessage );
 }
 
 void RssResource::importOpml( const QString &path, const QString &defaultTag )
--- trunk/playground/pim/krss/resource/rssresource.h #828431:828432
@@ -66,9 +66,8 @@
         void slotListingDone( KJob *job );
         void slotRootCollectionCreated( KJob *job );
         void slotCollectionImported( KJob *job );
-        void slotCollectionDeleted( KJob *job );
-        void slotSubscriptionDone( KJob *job );
-        void slotTaggingDone( KJob *job );
+        void feedDeletionDone( KJob *job );
+        void feedModificationDone( KJob *job );
         void feedCreationDone( KJob *job );
         void blockedFeedSyncDone( KJob *job );
         void parallelFeedSyncDone( KJob *job );
@@ -90,12 +89,9 @@
         Akonadi::Collection m_rootCollection;
         QHash<QString, Akonadi::Collection> m_collections;
         QStack<Akonadi::Collection> m_pendingCollections;
-        Akonadi::Collection m_currentCollection;
 
         QXmlStreamReader m_reader;
         QXmlStreamWriter m_writer;
-
-        QDBusMessage m_replyMessage;
 };
 
 #endif /* KRSS_RSSRESOURCE */


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

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