[Kde-pim] [PATCH 2/2] Fix filtering of notifications for explcitly monitored collections.

Stephen Kelly steveire at gmail.com
Fri Feb 25 23:05:22 GMT 2011


---
 akonadi/monitor_p.cpp |   14 +++++++-------
 akonadi/monitor_p.h   |   18 +++++++++++++++---
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/akonadi/monitor_p.cpp b/akonadi/monitor_p.cpp
index f4121d9..56b69da 100644
--- a/akonadi/monitor_p.cpp
+++ b/akonadi/monitor_p.cpp
@@ -181,8 +181,8 @@ bool MonitorPrivate::acceptNotification( const NotificationMessage & msg )
 
       // we explicitly monitor that item or the collections it's in
       return items.contains( msg.uid() )
-          || isCollectionMonitored( msg.parentCollection() )
-          || isCollectionMonitored( msg.parentDestCollection() );
+          || isCollectionMonitored( msg.parentCollection(), true )
+          || isCollectionMonitored( msg.parentDestCollection(), true );
 
     case NotificationMessage::Collection:
       // we have a resource filter
@@ -197,8 +197,8 @@ bool MonitorPrivate::acceptNotification( const NotificationMessage & msg )
 
       // we explicitly monitor that colleciton, or all of them
       return isCollectionMonitored( msg.uid() )
-          || isCollectionMonitored( msg.parentCollection() )
-          || isCollectionMonitored( msg.parentDestCollection() );
+          || isCollectionMonitored( msg.parentCollection(), true )
+          || isCollectionMonitored( msg.parentDestCollection(), true );
   }
   Q_ASSERT( false );
   return false;
@@ -329,9 +329,9 @@ void MonitorPrivate::appendAndCompress( const NotificationMessage &msg  )
       destWatched = isMoveDestinationResourceMonitored( msg );
     }
     if ( !sourceWatched )
-      sourceWatched = isCollectionMonitored( msg.parentCollection() );
+      sourceWatched = isCollectionMonitored( msg.parentCollection(), true );
     if ( !destWatched )
-      destWatched = isCollectionMonitored( msg.parentDestCollection() );
+      destWatched = isCollectionMonitored( msg.parentDestCollection(), true );
   }
 
   if ( sourceWatched && destWatched )
@@ -693,7 +693,7 @@ Collection::Id MonitorPrivate::PurgeBuffer::buffer( Collection::Id id )
 }
 
 void MonitorPrivate::notifyCollectionStatisticsWatchers(Entity::Id collection, const QByteArray& resource) {
-  if ( collection > 0 && (monitorAll || isCollectionMonitored( collection ) || resources.contains( resource ) ) ) {
+  if ( collection > 0 && (monitorAll || isCollectionMonitored( collection, true ) || resources.contains( resource ) ) ) {
     recentlyChangedCollections.insert( collection );
     if ( !statisticsCompressionTimer.isActive() )
       statisticsCompressionTimer.start();
diff --git a/akonadi/monitor_p.h b/akonadi/monitor_p.h
index cde1e97..54dc751 100644
--- a/akonadi/monitor_p.h
+++ b/akonadi/monitor_p.h
@@ -192,12 +192,24 @@ class AKONADI_TESTS_EXPORT MonitorPrivate
     */
     bool isLazilyIgnored( const NotificationMessage & msg ) const;
 
-    bool isCollectionMonitored( Collection::Id collection ) const
+    bool isCollectionMonitored( Collection::Id collection, bool recurs = false ) const
     {
-      if ( collections.contains( Collection( collection ) ) )
-        return true;
       if ( collections.contains( Collection::root() ) )
         return true;
+      if ( collections.contains( Collection( collection ) ) )
+        return true;
+      if ( recurs && needPrefetch() ) {
+        Collection col = collectionCache.retrieve( collection );
+        col = col.parentCollection();
+        while ( col.isValid() && col != Collection::root() ) {
+          if ( collections.contains( col ) )
+            return true;
+          col = col.parentCollection();
+        }
+        if ( !col.isValid() ) {
+          qWarning() << "Invalid collection in prefetch";
+        }
+      }
       return false;
     }
 
-- 
1.7.4.rc1.8.gca2fb

_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list