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

List:       kde-commits
Subject:    KDE/kdepim/akonadi
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2006-09-04 13:39:56
Message-ID: 1157377196.047971.25044.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 580787 by tokoe:

Add method 'synchronize()' to the Resource and AgentManager
interface, so clients can request the resource to do synchronization
with their backends (groupware server, files etc.) now.


 M  +12 -1     clients/akonadiconsole/agentwidget.cpp  
 M  +1 -0      clients/akonadiconsole/agentwidget.h  
 M  +5 -0      libakonadi/agentmanager.cpp  
 M  +6 -0      libakonadi/agentmanager.h  
 M  +3 -0      resources/include/org.kde.Akonadi.Resource.xml  
 M  +6 -0      resources/include/resource.h  
 M  +7 -2      resources/include/resourcebase.h  
 M  +3 -2      resources/src/ical/icalresource.cpp  
 M  +1 -3      resources/src/ical/icalresource.h  
 M  +40 -7     resources/src/knut/knutresource.cpp  
 M  +8 -1      resources/src/knut/knutresource.h  
 M  +4 -0      resources/src/lib/resourcebase.cpp  
 M  +17 -0     server/control/agentmanager.cpp  
 M  +6 -0      server/control/agentmanager.h  
 M  +3 -0      server/interfaces/org.kde.Akonadi.AgentManager.xml  


--- trunk/KDE/kdepim/akonadi/clients/akonadiconsole/agentwidget.cpp #580786:580787
@@ -84,7 +84,7 @@
 
   mView = new PIM::AgentInstanceView( this );
 
-  layout->addWidget( mView, 0, 0, 1, 4 );
+  layout->addWidget( mView, 0, 0, 1, 5 );
 
   QPushButton *button = new QPushButton( "Add...", this );
   connect( button, SIGNAL( clicked() ), this, SLOT( addAgent() ) );
@@ -97,6 +97,10 @@
   button = new QPushButton( "Configure...", this );
   connect( button, SIGNAL( clicked() ), this, SLOT( configureAgent() ) );
   layout->addWidget( button, 1, 3 );
+
+  button = new QPushButton( "Synchronize", this );
+  connect( button, SIGNAL( clicked() ), this, SLOT( synchronizeAgent() ) );
+  layout->addWidget( button, 1, 4 );
 }
 
 void AgentWidget::addAgent()
@@ -124,4 +128,11 @@
     mManager->agentInstanceConfigure( agent );
 }
 
+void AgentWidget::synchronizeAgent()
+{
+  const QString agent = mView->currentAgentInstance();
+  if ( !agent.isEmpty() )
+    mManager->agentInstanceSynchronize( agent );
+}
+
 #include "agentwidget.moc"
--- trunk/KDE/kdepim/akonadi/clients/akonadiconsole/agentwidget.h #580786:580787
@@ -40,6 +40,7 @@
     void addAgent();
     void removeAgent();
     void configureAgent();
+    void synchronizeAgent();
 
   private:
     PIM::AgentInstanceView *mView;
--- trunk/KDE/kdepim/akonadi/libakonadi/agentmanager.cpp #580786:580787
@@ -188,6 +188,11 @@
   return d->mManager->agentInstanceConfiguration( identifier );
 }
 
+void AgentManager::agentInstanceSynchronize( const QString &identifier )
+{
+  d->mManager->agentInstanceSynchronize( identifier );
+}
+
 bool AgentManager::requestItemDelivery( const QString &agentIdentifier, const \
QString &uid,  const QString &remoteId,
                                         const QString &collection, int type )
--- trunk/KDE/kdepim/akonadi/libakonadi/agentmanager.h #580786:580787
@@ -162,6 +162,12 @@
     QString agentInstanceConfiguration( const QString &identifier ) const;
 
     /**
+     * Triggers the agent instance with the given @p identifier to start
+     * synchronization.
+     */
+    void agentInstanceSynchronize( const QString &identifier );
+
+    /**
      * Asks the agent to store the item with the given
      * identifier to the given @p collection as full or lightwight
      * version, depending on @p type.
--- trunk/KDE/kdepim/akonadi/resources/include/org.kde.Akonadi.Resource.xml \
#580786:580787 @@ -33,5 +33,8 @@
     <method name="configuration">
       <arg type="s" direction="out"/>
     </method>
+    <method name="synchronize">
+      <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
+    </method>
   </interface>
 </node>
--- trunk/KDE/kdepim/akonadi/resources/include/resource.h #580786:580787
@@ -101,6 +101,12 @@
      */
     virtual QString configuration() const = 0;
 
+
+    /**
+     * This method is called whenever the resource should start synchronization.
+     */
+    virtual void synchronize() = 0;
+
   Q_SIGNALS:
     /**
      * This signal is emitted whenever the status of the resource has changed.
--- trunk/KDE/kdepim/akonadi/resources/include/resourcebase.h #580786:580787
@@ -121,8 +121,13 @@
     virtual QString configuration() const;
 
     /**
-      Returns the instance identifier of this resource.
-    */
+     * This method is called whenever the resource should start synchronization.
+     */
+    virtual void synchronize() = 0;
+
+    /**
+     * Returns the instance identifier of this resource.
+     */
     QString identifier() const;
 
   public Q_SLOTS:
--- trunk/KDE/kdepim/akonadi/resources/src/ical/icalresource.cpp #580786:580787
@@ -41,7 +41,8 @@
   // ### just for testing
   mCalendar = new KCal::CalendarLocal( "UTC" );
   mCalendar->load( "akonadi_ical_test.ics" );
-  sync();
+
+  synchronize();
 }
 
 PIM::ICalResource::~ ICalResource()
@@ -82,7 +83,7 @@
   return true;
 }
 
-void PIM::ICalResource::sync()
+void PIM::ICalResource::synchronize()
 {
   changeStatus( Syncing, i18n("Syncing with ICal file.") );
 
--- trunk/KDE/kdepim/akonadi/resources/src/ical/icalresource.h #580786:580787
@@ -41,13 +41,11 @@
 
   public Q_SLOTS:
     virtual bool requestItemDelivery( const QString & uid,const QString &remoteId, \
const QString & collection, int type ); +    virtual void synchronize();
 
   protected:
     virtual void aboutToQuit();
 
-  private:
-    void sync();
-
   private Q_SLOTS:
     void done(PIM::Job* job);
 
--- trunk/KDE/kdepim/akonadi/resources/src/knut/knutresource.cpp #580786:580787
@@ -27,12 +27,14 @@
 KnutResource::KnutResource( const QString &id )
   : ResourceBase( id )
 {
-  QTimer *timer = new QTimer( this );
+  mStatusTimer = new QTimer( this );
+  connect( mStatusTimer, SIGNAL( timeout() ), this, SLOT( statusTimeout() ) );
 
-  connect( timer, SIGNAL( timeout() ), this, SLOT( timeout() ) );
+  mSyncTimer = new QTimer( this );
+  connect( mSyncTimer, SIGNAL( timeout() ), this, SLOT( syncTimeout() ) );
 
   int number = id.mid( 22 ).toInt();
-  timer->start( 5000 + ( 100*number ) );
+  mStatusTimer->start( 5000 + ( 100*number ) );
 }
 
 KnutResource::~KnutResource()
@@ -58,25 +60,56 @@
   return mConfig;
 }
 
+void KnutResource::synchronize()
+{
+  mSyncTimer->start( 2000 );
+}
+
 bool KnutResource::requestItemDelivery( const QString&, const QString&, const \
QString&, int )  {
   return false;
 }
 
-void KnutResource::timeout()
+void KnutResource::statusTimeout()
 {
   static Status status = Ready;
 
   if ( status == Ready ) {
-    statusChanged( Syncing, tr( "Syncing with Kolab Server" ) );
+    changeStatus( Syncing, tr( "Syncing with Kolab Server" ) );
     status = Syncing;
   } else if ( status == Syncing ) {
-    statusChanged( Error, tr( "Unable to connect to Kolab Server" ) );
+    changeStatus( Error, tr( "Unable to connect to Kolab Server" ) );
     status = Error;
   } else if ( status == Error ) {
-    statusChanged( Ready, tr( "Data loaded successfully from Kolab Sever" ) );
+    changeStatus( Ready, tr( "Data loaded successfully from Kolab Sever" ) );
     status = Ready;
   }
 }
 
+void KnutResource::syncTimeout()
+{
+  mStatusTimer->stop();
+
+  static int progress = 0;
+
+  if ( progress == 0 )
+    changeStatus( Syncing, "Syncing collection 'contacts'" );
+  else if ( progress == 1 )
+    changeStatus( Syncing, "Syncing collection 'events'" );
+  else if ( progress == 2 )
+    changeStatus( Syncing, "Syncing collection 'notes'" );
+  else if ( progress == 3 )
+    changeStatus( Syncing, "Syncing collection 'tasks'" );
+  else if ( progress == 4 )
+    changeStatus( Syncing, "Syncing collection 'journals'" );
+  else if ( progress == 5 )
+    changeStatus( Syncing, "Syncing collection 'mails'" );
+  
+  if ( progress == 5 ) {
+    progress = 0;
+    mSyncTimer->stop();
+    changeStatus( Ready );
+  }
+}
+
 #include "knutresource.moc"
--- trunk/KDE/kdepim/akonadi/resources/src/knut/knutresource.h #580786:580787
@@ -22,6 +22,8 @@
 
 #include <resourcebase.h>
 
+class QTimer;
+
 namespace PIM {
 
 class KnutResource : public ResourceBase
@@ -39,11 +41,16 @@
     virtual bool setConfiguration( const QString& );
     virtual QString configuration() const;
 
+    virtual void synchronize();
+
   private Q_SLOTS:
-    void timeout();
+    void statusTimeout();
+    void syncTimeout();
 
   private:
     QString mConfig;
+    QTimer *mStatusTimer;
+    QTimer *mSyncTimer;
 };
 
 }
--- trunk/KDE/kdepim/akonadi/resources/src/lib/resourcebase.cpp #580786:580787
@@ -154,6 +154,10 @@
   return QString();
 }
 
+void ResourceBase::synchronize()
+{
+}
+
 QString ResourceBase::parseArguments( int argc, char **argv )
 {
   if ( argc < 3 ) {
--- trunk/KDE/kdepim/akonadi/server/control/agentmanager.cpp #580786:580787
@@ -317,6 +317,23 @@
   return mInstances[ identifier ].interface->configuration();
 }
 
+void AgentManager::agentInstanceSynchronize( const QString &identifier )
+{
+  if ( !mInstances.contains( identifier ) ) {
+    mTracer->warning( QLatin1String( "AgentManager::agentInstanceSynchronize" ),
+                      QString( "Agent instance with identifier '%1' does not exist" \
).arg( identifier ) ); +    return;
+  }
+
+  if ( !mInstances[ identifier ].interface ) {
+    mTracer->error( QLatin1String( "AgentManager::agentInstanceSynchronize" ),
+                    QString( "Agent instance '%1' has no interface!" ).arg( \
identifier ) ); +    return;
+  }
+
+  mInstances[ identifier ].interface->synchronize();
+}
+
 void AgentManager::updatePluginInfos()
 {
   QMap<QString, PluginInfo> oldInfos = mPluginInfos;
--- trunk/KDE/kdepim/akonadi/server/control/agentmanager.h #580786:580787
@@ -153,6 +153,12 @@
     QString agentInstanceConfiguration( const QString &identifier ) const;
 
     /**
+     * Triggers the agent instance with the given @p identifier to start
+     * synchronization.
+     */
+    void agentInstanceSynchronize( const QString &identifier );
+
+    /**
      * Asks the agent to store the item with the given
      * identifier to the given @p collection as full or lightwight
      * version, depending on @p type.
--- trunk/KDE/kdepim/akonadi/server/interfaces/org.kde.Akonadi.AgentManager.xml \
#580786:580787 @@ -91,6 +91,9 @@
       <arg type="s" direction="out"/>
       <arg name="identifier" type="s" direction="in"/>
     </method>
+    <method name="agentInstanceSynchronize">
+      <arg name="identifier" type="s" direction="in"/>
+    </method>
     <method name="requestItemDelivery">
       <arg type="b" direction="out"/>
       <arg name="agentIdentifier" type="s" direction="in"/>


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

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