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

List:       kde-commits
Subject:    kdesupport/akonadi/server/src
From:       Volker Krause <vkrause () kde ! org>
Date:       2009-02-28 23:14:46
Message-ID: 1235862886.265773.2241.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 933455 by vkrause:

Move the collection sync triggering code to ItemRetrievalManager as
well, to share the resource interface cache and benefit from the
thread-safety fixes there.


 M  +1 -1      handler/fetch.cpp  
 M  +2 -1      intervalcheck.cpp  
 M  +0 -29     storage/datastore.cpp  
 M  +0 -20     storage/datastore.h  
 M  +16 -0     storage/itemretrievalmanager.cpp  
 M  +5 -0      storage/itemretrievalmanager.h  


--- trunk/kdesupport/akonadi/server/src/handler/fetch.cpp #933454:933455
@@ -304,7 +304,7 @@
   store->activeCachePolicy( col );
   if ( !col.cachePolicySyncOnDemand() )
     return;
-  store->triggerCollectionSync( col );
+  ItemRetrievalManager::instance()->requestCollectionSync( col );
 }
 
 QueryBuilder Fetch::buildPartQuery( const QStringList &partList, bool allPayload, \
                bool allAttrs )
--- trunk/kdesupport/akonadi/server/src/intervalcheck.cpp #933454:933455
@@ -19,6 +19,7 @@
 
 #include "intervalcheck.h"
 #include "storage/datastore.h"
+#include "storage/itemretrievalmanager.h"
 
 #include <QDebug>
 #include <QTimer>
@@ -61,7 +62,7 @@
 
     mLastChecks[ collection.id() ] = QDateTime::currentDateTime();
     qDebug() << "interval checking  collection " << collection.id() << "(" << \
                collection.name() << ")";
-    DataStore::self()->triggerCollectionSync( collection );
+    ItemRetrievalManager::instance()->requestCollectionSync( collection );
   }
 
   QTimer::singleShot( 60 * 1000, this, SLOT(doIntervalCheck()) );
--- trunk/kdesupport/akonadi/server/src/storage/datastore.cpp #933454:933455
@@ -21,7 +21,6 @@
 #include "datastore.h"
 
 #include "agentmanagerinterface.h"
-#include "resourceinterface.h"
 #include "dbconfig.h"
 #include "dbinitializer.h"
 #include "dbupdater.h"
@@ -551,13 +550,6 @@
   return ok;
 }
 
-void DataStore::triggerCollectionSync( const Collection &collection )
-{
-  org::freedesktop::Akonadi::Resource *interface = resourceInterface( \
                collection.resource().name() );
-  if ( interface )
-    interface->synchronizeCollection( collection.id() );
-}
-
 QList<PimItem> DataStore::listPimItems( const Collection & collection, const Flag \
&flag )  {
   if ( !m_dbOpened )
@@ -770,25 +762,4 @@
   return m_transactionLevel > 0;
 }
 
-org::freedesktop::Akonadi::Resource * Akonadi::DataStore::resourceInterface( const \
                QString &res )
-{
-  org::freedesktop::Akonadi::Resource* iface = 0;
-  if ( mResourceInterfaceCache.contains( res ) )
-    iface = mResourceInterfaceCache.value( res );
-  if ( iface && iface->isValid() )
-    return iface;
-
-  delete iface;
-  iface = new org::freedesktop::Akonadi::Resource( \
                QLatin1String("org.freedesktop.Akonadi.Resource.") + res,
-                                                   QLatin1String("/"), \
                QDBusConnection::sessionBus(), this );
-  if ( !iface || !iface->isValid() ) {
-    qDebug() << QString::fromLatin1( "Cannot connect to agent instance with \
                identifier '%1', error message: '%2'" )
-                                    .arg( res, iface ? iface->lastError().message() \
                : QString() );
-    delete iface;
-    return 0;
-  }
-  mResourceInterfaceCache.insert( res, iface );
-  return iface;
-}
-
 #include "datastore.moc"
--- trunk/kdesupport/akonadi/server/src/storage/datastore.h #933454:933455
@@ -32,16 +32,6 @@
 #include "entities.h"
 #include "notificationcollector.h"
 
-class OrgFreedesktopAkonadiResourceInterface;
-namespace org {
-  namespace freedesktop {
-    namespace Akonadi {
-      typedef ::OrgFreedesktopAkonadiResourceInterface Resource;
-    }
-  }
-}
-
-
 namespace Akonadi {
 
 class NotificationCollector;
@@ -254,8 +244,6 @@
     void debugLastDbError( const char* actionDescription ) const;
     void debugLastQueryError( const QSqlQuery &query, const char* actionDescription \
) const;  public:
-    void triggerCollectionSync( const Collection &collection );
-
     /** Returns the id of the most recent inserted row, or -1 if there's no such
         id.
         @param query the query we want to get the last insert id for
@@ -279,11 +267,6 @@
      */
     static QDateTime dateTimeToQDateTime( const QByteArray & dateTime );
 
-    /**
-      Returns the D-Bus interface of the given resource.
-    */
-    org::freedesktop::Akonadi::Resource *resourceInterface( const QString &res );
-
 private:
     QString m_connectionName;
     QSqlDatabase m_database;
@@ -291,9 +274,6 @@
     uint m_transactionLevel;
     QByteArray mSessionId;
     NotificationCollector* mNotificationCollector;
-
-    // resource dbus interface cache
-    QHash<QString, org::freedesktop::Akonadi::Resource*> mResourceInterfaceCache;
 };
 
 }
--- trunk/kdesupport/akonadi/server/src/storage/itemretrievalmanager.cpp \
#933454:933455 @@ -52,6 +52,7 @@
   connect( QDBusConnection::sessionBus().interface(), \
SIGNAL(serviceOwnerChanged(QString,QString,QString)),  this, \
SLOT(serviceOwnerChanged(QString,QString,QString)) );  connect( this, \
SIGNAL(requestAdded()), this, SLOT(processRequest()), Qt::QueuedConnection ); +  \
connect( this, SIGNAL(syncCollection(QString,qint64)), this, \
SLOT(triggerCollectionSync(QString,qint64)), Qt::QueuedConnection );  }
 
 ItemRetrievalManager::~ItemRetrievalManager()
@@ -82,6 +83,9 @@
 // called within the retrieval thread
 OrgFreedesktopAkonadiResourceInterface* \
ItemRetrievalManager::resourceInterface(const QString& id)  {
+  if ( id.isEmpty() )
+    return 0;
+
   OrgFreedesktopAkonadiResourceInterface *iface = 0;
   if ( mResourceInterfaces.contains( id ) )
     iface = mResourceInterfaces.value( id );
@@ -197,4 +201,16 @@
   mLock->unlock();
 }
 
+void ItemRetrievalManager::requestCollectionSync(const Collection& collection)
+{
+  emit syncCollection( collection.resource().name(), collection.id() );
+}
+
+void ItemRetrievalManager::triggerCollectionSync(const QString& resource, qint64 \
colId) +{
+  OrgFreedesktopAkonadiResourceInterface *interface = resourceInterface( resource );
+  if ( interface )
+    interface->synchronizeCollection( colId );
+}
+
 #include "itemretrievalmanager.moc"
--- trunk/kdesupport/akonadi/server/src/storage/itemretrievalmanager.h #933454:933455
@@ -32,6 +32,8 @@
 
 namespace Akonadi {
 
+class Collection;
+
 /** Manages and processes item retrieval requests. */
 class ItemRetrievalManager : public QObject
 {
@@ -42,11 +44,13 @@
 
     void requestItemDelivery( qint64 uid, const QByteArray& remoteId, const \
                QByteArray& mimeType,
                               const QString &resource, const QStringList &parts );
+    void requestCollectionSync( const Collection &collection );
 
     static ItemRetrievalManager* instance();
 
   signals:
     void requestAdded();
+    void syncCollection( const QString &resource, qint64 colId );
 
   private:
     OrgFreedesktopAkonadiResourceInterface* resourceInterface( const QString &id );
@@ -54,6 +58,7 @@
   private slots:
     void serviceOwnerChanged( const QString &serviceName, const QString &oldOwner, \
const QString &newOwner );  void processRequest();
+    void triggerCollectionSync( const QString &resource, qint64 colId );
 
   private:
     class Request


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

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