• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.11.3 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
agentbase.cpp
1 /*
2  Copyright (c) 2006 Till Adam <adam@kde.org>
3  Copyright (c) 2007 Volker Krause <vkrause@kde.org>
4  Copyright (c) 2007 Bruno Virlet <bruno.virlet@gmail.com>
5  Copyright (c) 2008 Kevin Krammer <kevin.krammer@gmx.at>
6 
7  This library is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Library General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version.
11 
12  This library is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15  License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to the
19  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  02110-1301, USA.
21 */
22 
23 #include "agentbase.h"
24 #include "agentbase_p.h"
25 
26 #include "agentmanager.h"
27 #include "changerecorder.h"
28 #include "controladaptor.h"
29 #include "dbusconnectionpool.h"
30 #include "itemfetchjob.h"
31 #include "kdepimlibs-version.h"
32 #include "monitor_p.h"
33 #include "servermanager_p.h"
34 #include "session.h"
35 #include "session_p.h"
36 #include "statusadaptor.h"
37 
38 #include <kaboutdata.h>
39 #include <kcmdlineargs.h>
40 #include <kdebug.h>
41 #include <kglobal.h>
42 #include <klocalizedstring.h>
43 #include <kstandarddirs.h>
44 
45 #include <Solid/PowerManagement>
46 
47 #include <QtCore/QDir>
48 #include <QtCore/QSettings>
49 #include <QtCore/QTimer>
50 #include <QtDBus/QtDBus>
51 #include <QApplication>
52 
53 #include <signal.h>
54 #include <stdlib.h>
55 
56 
57 //#define EXPERIMENTAL_INPROCESS_AGENTS 1
58 
59 using namespace Akonadi;
60 
61 static AgentBase *sAgentBase = 0;
62 
63 AgentBase::Observer::Observer()
64 {
65 }
66 
67 AgentBase::Observer::~Observer()
68 {
69 }
70 
71 void AgentBase::Observer::itemAdded( const Item &item, const Collection &collection )
72 {
73  Q_UNUSED( item );
74  Q_UNUSED( collection );
75  if ( sAgentBase != 0 ) {
76  sAgentBase->d_ptr->changeProcessed();
77  }
78 }
79 
80 void AgentBase::Observer::itemChanged( const Item &item, const QSet<QByteArray> &partIdentifiers )
81 {
82  Q_UNUSED( item );
83  Q_UNUSED( partIdentifiers );
84  if ( sAgentBase != 0 ) {
85  sAgentBase->d_ptr->changeProcessed();
86  }
87 }
88 
89 void AgentBase::Observer::itemRemoved( const Item &item )
90 {
91  Q_UNUSED( item );
92  if ( sAgentBase != 0 ) {
93  sAgentBase->d_ptr->changeProcessed();
94  }
95 }
96 
97 void AgentBase::Observer::collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent )
98 {
99  Q_UNUSED( collection );
100  Q_UNUSED( parent );
101  if ( sAgentBase != 0 ) {
102  sAgentBase->d_ptr->changeProcessed();
103  }
104 }
105 
106 void AgentBase::Observer::collectionChanged( const Collection &collection )
107 {
108  Q_UNUSED( collection );
109  if ( sAgentBase != 0 ) {
110  sAgentBase->d_ptr->changeProcessed();
111  }
112 }
113 
114 void AgentBase::Observer::collectionRemoved( const Collection &collection )
115 {
116  Q_UNUSED( collection );
117  if ( sAgentBase != 0 ) {
118  sAgentBase->d_ptr->changeProcessed();
119  }
120 }
121 
122 void AgentBase::ObserverV2::itemMoved( const Akonadi::Item &item, const Akonadi::Collection &source, const Akonadi::Collection &dest )
123 {
124  Q_UNUSED( item );
125  Q_UNUSED( source );
126  Q_UNUSED( dest );
127  if ( sAgentBase != 0 ) {
128  sAgentBase->d_ptr->changeProcessed();
129  }
130 }
131 
132 void AgentBase::ObserverV2::itemLinked( const Akonadi::Item& item, const Akonadi::Collection& collection )
133 {
134  Q_UNUSED( item );
135  Q_UNUSED( collection );
136  if ( sAgentBase != 0 ) {
137  // not implementation, let's disconnect the signal to enable optimizations in Monitor
138  QObject::disconnect( sAgentBase->changeRecorder(), SIGNAL(itemLinked(Akonadi::Item,Akonadi::Collection)),
139  sAgentBase->d_ptr, SLOT(itemLinked(Akonadi::Item,Akonadi::Collection)) );
140  sAgentBase->d_ptr->changeProcessed();
141  }
142 }
143 
144 void AgentBase::ObserverV2::itemUnlinked( const Akonadi::Item& item, const Akonadi::Collection& collection )
145 {
146  Q_UNUSED( item );
147  Q_UNUSED( collection );
148  if ( sAgentBase != 0 ) {
149  // not implementation, let's disconnect the signal to enable optimizations in Monitor
150  QObject::disconnect( sAgentBase->changeRecorder(), SIGNAL(itemUnlinked(Akonadi::Item,Akonadi::Collection)),
151  sAgentBase->d_ptr, SLOT(itemUnlinked(Akonadi::Item,Akonadi::Collection)) );
152  sAgentBase->d_ptr->changeProcessed();
153  }
154 }
155 
156 void AgentBase::ObserverV2::collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &source, const Akonadi::Collection &dest )
157 {
158  Q_UNUSED( collection );
159  Q_UNUSED( source );
160  Q_UNUSED( dest );
161  if ( sAgentBase != 0 ) {
162  sAgentBase->d_ptr->changeProcessed();
163  }
164 }
165 
166 void AgentBase::ObserverV2::collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &changedAttributes )
167 {
168  Q_UNUSED( changedAttributes );
169  collectionChanged( collection );
170 }
171 
172 void AgentBase::ObserverV3::itemsFlagsChanged(const Akonadi::Item::List& items, const QSet< QByteArray >& addedFlags, const QSet< QByteArray >& removedFlags)
173 {
174  Q_UNUSED( items );
175  Q_UNUSED( addedFlags );
176  Q_UNUSED( removedFlags );
177 
178  if ( sAgentBase != 0 ) {
179  // not implementation, let's disconnect the signal to enable optimizations in Monitor
180  QObject::disconnect( sAgentBase->changeRecorder(), SIGNAL(itemsFlagsChanged(Akonadi::Item::List,QSet<QByteArray>,QSet<QByteArray>)),
181  sAgentBase->d_ptr, SLOT(itemsFlagsChanged(Akonadi::Item::List,QSet<QByteArray>,QSet<QByteArray>)) );
182  sAgentBase->d_ptr->changeProcessed();
183  }
184 }
185 
186 void AgentBase::ObserverV3::itemsMoved(const Akonadi::Item::List& items, const Collection& sourceCollection, const Collection& destinationCollection)
187 {
188  Q_UNUSED( items );
189  Q_UNUSED( sourceCollection );
190  Q_UNUSED( destinationCollection );
191 
192  if ( sAgentBase != 0 ) {
193  // not implementation, let's disconnect the signal to enable optimizations in Monitor
194  QObject::disconnect( sAgentBase->changeRecorder(), SIGNAL(itemsMoved(Akonadi::Item::List,Akonadi::Collection,Akonadi::Collection)),
195  sAgentBase->d_ptr, SLOT(itemsMoved(Akonadi::Item::List,Akonadi::Collection,Akonadi::Collection)) );
196  sAgentBase->d_ptr->changeProcessed();
197  }
198 }
199 
200 void AgentBase::ObserverV3::itemsRemoved(const Akonadi::Item::List& items)
201 {
202  Q_UNUSED( items );
203 
204  if ( sAgentBase != 0 ) {
205  // not implementation, let's disconnect the signal to enable optimizations in Monitor
206  QObject::disconnect( sAgentBase->changeRecorder(), SIGNAL(itemsRemoved(Akonadi::Item::List)),
207  sAgentBase->d_ptr, SLOT(itemsRemoved(Akonadi::Item::List)) );
208  sAgentBase->d_ptr->changeProcessed();
209  }
210 }
211 
212 void AgentBase::ObserverV3::itemsLinked(const Akonadi::Item::List& items, const Collection& collection)
213 {
214  Q_UNUSED( items );
215  Q_UNUSED( collection );
216 
217  if ( sAgentBase != 0 ) {
218  // not implementation, let's disconnect the signal to enable optimizations in Monitor
219  QObject::disconnect( sAgentBase->changeRecorder(), SIGNAL(itemsLinked(Akonadi::Item::List,Akonadi::Collection)),
220  sAgentBase->d_ptr, SLOT(itemsLinked(Akonadi::Item::List,Akonadi::Collection)) );
221  sAgentBase->d_ptr->changeProcessed();
222  }
223 }
224 
225 void AgentBase::ObserverV3::itemsUnlinked(const Akonadi::Item::List& items, const Collection& collection)
226 {
227  Q_UNUSED( items );
228  Q_UNUSED( collection )
229 
230  if ( sAgentBase != 0 ) {
231  // not implementation, let's disconnect the signal to enable optimizations in Monitor
232  QObject::disconnect( sAgentBase->changeRecorder(), SIGNAL(itemsUnlinked(Akonadi::Item::List,Akonadi::Collection)),
233  sAgentBase->d_ptr, SLOT(itemsUnlinked(Akonadi::Item::List,Akonadi::Collection)) );
234  sAgentBase->d_ptr->changeProcessed();
235  }
236 }
237 
238 //@cond PRIVATE
239 
240 AgentBasePrivate::AgentBasePrivate( AgentBase *parent )
241  : q_ptr( parent ),
242  mDBusConnection( QString() ),
243  mStatusCode( AgentBase::Idle ),
244  mProgress( 0 ),
245  mNeedsNetwork( false ),
246  mOnline( false ),
247  mDesiredOnlineState( false ),
248  mSettings( 0 ),
249  mChangeRecorder( 0 ),
250  mTracer( 0 ),
251  mObserver( 0 )
252 {
253 #ifdef Q_OS_WINCE
254  QThread::currentThread()->setPriority( QThread::LowPriority );
255 #endif
256  Internal::setClientType( Internal::Agent );
257 }
258 
259 AgentBasePrivate::~AgentBasePrivate()
260 {
261  mChangeRecorder->setConfig( 0 );
262  delete mSettings;
263 }
264 
265 void AgentBasePrivate::init()
266 {
267  Q_Q( AgentBase );
268 
272  SessionPrivate::createDefaultSession( mId.toLatin1() );
273 
274  if ( QThread::currentThread() != QCoreApplication::instance()->thread() ) {
275  mDBusConnection = QDBusConnection::connectToBus( QDBusConnection::SessionBus, q->identifier() );
276  Q_ASSERT( mDBusConnection.isConnected() );
277  }
278 
279  mTracer = new org::freedesktop::Akonadi::Tracer( ServerManager::serviceName( ServerManager::Server ),
280  QLatin1String( "/tracing" ),
281  DBusConnectionPool::threadConnection(), q );
282 
283  new Akonadi__ControlAdaptor( q );
284  new Akonadi__StatusAdaptor( q );
285  if ( !DBusConnectionPool::threadConnection().registerObject( QLatin1String( "/" ), q, QDBusConnection::ExportAdaptors ) )
286  q->error( i18n( "Unable to register object at dbus: %1", DBusConnectionPool::threadConnection().lastError().message() ) );
287 
288  mSettings = new QSettings( QString::fromLatin1( "%1/agent_config_%2" ).arg( Internal::xdgSaveDir( "config" ), mId ), QSettings::IniFormat );
289 
290  mChangeRecorder = new ChangeRecorder( q );
291  mChangeRecorder->ignoreSession( Session::defaultSession() );
292  mChangeRecorder->itemFetchScope().setCacheOnly( true );
293  mChangeRecorder->setConfig( mSettings );
294 
295  mDesiredOnlineState = mSettings->value( QLatin1String( "Agent/DesiredOnlineState" ), true ).toBool();
296  mOnline = mDesiredOnlineState;
297 
298  // reinitialize the status message now that online state is available
299  mStatusMessage = defaultReadyMessage();
300 
301  mName = mSettings->value( QLatin1String( "Agent/Name" ) ).toString();
302  if ( mName.isEmpty() ) {
303  mName = mSettings->value( QLatin1String( "Resource/Name" ) ).toString();
304  if ( !mName.isEmpty() ) {
305  mSettings->remove( QLatin1String( "Resource/Name" ) );
306  mSettings->setValue( QLatin1String( "Agent/Name" ), mName );
307  }
308  }
309 
310  connect( mChangeRecorder, SIGNAL(itemAdded(Akonadi::Item,Akonadi::Collection)),
311  SLOT(itemAdded(Akonadi::Item,Akonadi::Collection)) );
312  connect( mChangeRecorder, SIGNAL(itemChanged(Akonadi::Item,QSet<QByteArray>)),
313  SLOT(itemChanged(Akonadi::Item,QSet<QByteArray>)) );
314  connect( mChangeRecorder, SIGNAL(collectionAdded(Akonadi::Collection,Akonadi::Collection)),
315  SLOT(collectionAdded(Akonadi::Collection,Akonadi::Collection)) );
316  connect( mChangeRecorder, SIGNAL(collectionChanged(Akonadi::Collection)),
317  SLOT(collectionChanged(Akonadi::Collection)) );
318  connect( mChangeRecorder, SIGNAL(collectionChanged(Akonadi::Collection,QSet<QByteArray>)),
319  SLOT(collectionChanged(Akonadi::Collection,QSet<QByteArray>)) );
320  connect( mChangeRecorder, SIGNAL(collectionMoved(Akonadi::Collection,Akonadi::Collection,Akonadi::Collection)),
321  SLOT(collectionMoved(Akonadi::Collection,Akonadi::Collection,Akonadi::Collection)) );
322  connect( mChangeRecorder, SIGNAL(collectionRemoved(Akonadi::Collection)),
323  SLOT(collectionRemoved(Akonadi::Collection)) );
324  connect( mChangeRecorder, SIGNAL(collectionSubscribed(Akonadi::Collection,Akonadi::Collection)),
325  SLOT(collectionSubscribed(Akonadi::Collection,Akonadi::Collection)) );
326  connect( mChangeRecorder, SIGNAL(collectionUnsubscribed(Akonadi::Collection)),
327  SLOT(collectionUnsubscribed(Akonadi::Collection)) );
328 
329  connect( q, SIGNAL(status(int,QString)), q, SLOT(slotStatus(int,QString)) );
330  connect( q, SIGNAL(percent(int)), q, SLOT(slotPercent(int)) );
331  connect( q, SIGNAL(warning(QString)), q, SLOT(slotWarning(QString)) );
332  connect( q, SIGNAL(error(QString)), q, SLOT(slotError(QString)) );
333 
334  connect( Solid::PowerManagement::notifier(), SIGNAL(resumingFromSuspend()), q, SLOT(slotResumedFromSuspend()) );
335 
336  // Use reference counting to allow agents to finish internal jobs when the
337  // agent is stopped.
338  KGlobal::ref();
339  if ( QThread::currentThread() == QCoreApplication::instance()->thread() ) {
340  KGlobal::setAllowQuit( true );
341  }
342 
343 #ifndef Q_OS_WINCE
344  // disable session management
345  if ( KApplication::kApplication() ) {
346  KApplication::kApplication()->disableSessionManagement();
347  }
348 #endif
349 
350  mResourceTypeName = AgentManager::self()->instance( mId ).type().name();
351  setProgramName();
352 
353  QTimer::singleShot( 0, q, SLOT(delayedInit()) );
354 }
355 
356 void AgentBasePrivate::delayedInit()
357 {
358  Q_Q( AgentBase );
359 
360  const QString serviceId = ServerManager::agentServiceName( ServerManager::Agent, mId );
361  if ( !DBusConnectionPool::threadConnection().registerService( serviceId ) ) {
362  kFatal() << "Unable to register service" << serviceId << "at dbus:" << DBusConnectionPool::threadConnection().lastError().message();
363  }
364  q->setOnlineInternal( mDesiredOnlineState );
365 }
366 
367 void AgentBasePrivate::setProgramName()
368 {
369  // ugly, really ugly, if you find another solution, change it and blame me for this code (Andras)
370  QString programName = mResourceTypeName;
371  if ( !mName.isEmpty() ) {
372  programName = i18nc( "Name and type of Akonadi resource", "%1 of type %2", mName, mResourceTypeName ) ;
373  }
374  const_cast<KAboutData*>( KGlobal::mainComponent().aboutData() )->setProgramName( ki18n( programName.toUtf8() ) );
375 }
376 
377 void AgentBasePrivate::itemAdded( const Akonadi::Item &item, const Akonadi::Collection &collection )
378 {
379  if ( mObserver != 0 ) {
380  mObserver->itemAdded( item, collection );
381  }
382 }
383 
384 void AgentBasePrivate::itemChanged( const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers )
385 {
386  if ( mObserver != 0 ) {
387  mObserver->itemChanged( item, partIdentifiers );
388  }
389 }
390 
391 void AgentBasePrivate::itemMoved( const Akonadi::Item &item, const Akonadi::Collection &source, const Akonadi::Collection &dest )
392 {
393  AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
394  if ( mObserver ) {
395  // inter-resource moves, requires we know which resources the source and destination are in though
396  if ( !source.resource().isEmpty() && !dest.resource().isEmpty() ) {
397  if ( source.resource() != dest.resource() ) {
398  if ( source.resource() == q_ptr->identifier() ) { // moved away from us
399  Akonadi::Item i( item );
400  i.setParentCollection( source );
401  mObserver->itemRemoved( i );
402  } else if ( dest.resource() == q_ptr->identifier() ) { // moved to us
403  mObserver->itemAdded( item, dest );
404  } else if ( observer2 ) {
405  observer2->itemMoved( item, source, dest );
406  } else {
407  // not for us, not sure if we should get here at all
408  changeProcessed();
409  }
410  return;
411  }
412  }
413  // intra-resource move
414  if ( observer2 ) {
415  observer2->itemMoved( item, source, dest );
416  } else {
417  // ### we cannot just call itemRemoved here as this will already trigger changeProcessed()
418  // so, just itemAdded() is good enough as no resource can have implemented intra-resource moves anyway
419  // without using ObserverV2
420  mObserver->itemAdded( item, dest );
421  // mObserver->itemRemoved( item );
422  }
423  }
424 }
425 
426 void AgentBasePrivate::itemRemoved( const Akonadi::Item &item )
427 {
428  if ( mObserver != 0 ) {
429  mObserver->itemRemoved( item );
430  }
431 }
432 
433 void AgentBasePrivate::itemLinked( const Akonadi::Item &item, const Akonadi::Collection &collection )
434 {
435  AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
436  if ( observer2 ) {
437  observer2->itemLinked( item, collection );
438  } else {
439  changeProcessed();
440  }
441 }
442 
443 void AgentBasePrivate::itemUnlinked( const Akonadi::Item &item, const Akonadi::Collection &collection )
444 {
445  AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
446  if ( observer2 ) {
447  observer2->itemUnlinked( item, collection );
448  } else {
449  changeProcessed();
450  }
451 }
452 
453 void AgentBasePrivate::itemsFlagsChanged( const Akonadi::Item::List &items, const QSet<QByteArray> &addedFlags, const QSet<QByteArray> &removedFlags )
454 {
455  AgentBase::ObserverV3 *observer3 = dynamic_cast<AgentBase::ObserverV3*>( mObserver );
456  if ( observer3 ) {
457  observer3->itemsFlagsChanged( items, addedFlags, removedFlags );
458  } else {
459  Q_ASSERT_X( false, Q_FUNC_INFO, "Batch slots must never be called when ObserverV3 is not available" );
460  }
461 }
462 
463 void AgentBasePrivate::itemsMoved( const Akonadi::Item::List &items, const Akonadi::Collection &source, const Akonadi::Collection &destination )
464 {
465  AgentBase::ObserverV3 *observer3 = dynamic_cast<AgentBase::ObserverV3*>( mObserver );
466  if ( observer3 ) {
467  observer3->itemsMoved( items, source, destination );
468  } else {
469  Q_ASSERT_X( false, Q_FUNC_INFO, "Batch slots must never be called when ObserverV3 is not available" );
470  }
471 }
472 
473 void AgentBasePrivate::itemsRemoved( const Akonadi::Item::List &items )
474 {
475  AgentBase::ObserverV3 *observer3 = dynamic_cast<AgentBase::ObserverV3*>( mObserver );
476  if ( observer3 ) {
477  observer3->itemsRemoved( items );
478  } else {
479  Q_ASSERT_X( false, Q_FUNC_INFO, "Batch slots must never be called when ObserverV3 is not available" );
480  }
481 }
482 
483 void AgentBasePrivate::itemsLinked( const Akonadi::Item::List &items, const Akonadi::Collection &collection )
484 {
485  if ( !mObserver ) {
486  changeProcessed();
487  return;
488  }
489 
490  AgentBase::ObserverV3 *observer3 = dynamic_cast<AgentBase::ObserverV3*>( mObserver );
491  if ( observer3 ) {
492  observer3->itemsLinked( items, collection );
493  } else {
494  Q_ASSERT_X( false, Q_FUNC_INFO, "Batch slots must never be called when ObserverV3 is not available" );
495  }
496 }
497 
498 void AgentBasePrivate::itemsUnlinked( const Akonadi::Item::List &items, const Akonadi::Collection &collection )
499 {
500  if ( !mObserver ) {
501  return;
502  }
503 
504  AgentBase::ObserverV3 *observer3 = dynamic_cast<AgentBase::ObserverV3*>( mObserver );
505  if ( observer3 ) {
506  observer3->itemsUnlinked( items, collection );
507  } else {
508  Q_ASSERT_X( false, Q_FUNC_INFO, "Batch slots must never be called when ObserverV3 is not available" );
509  }
510 }
511 
512 void AgentBasePrivate::collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent )
513 {
514  if ( mObserver != 0 ) {
515  mObserver->collectionAdded( collection, parent );
516  }
517 }
518 
519 void AgentBasePrivate::collectionChanged( const Akonadi::Collection &collection )
520 {
521  AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
522  if ( mObserver != 0 && observer2 == 0 ) { // For ObserverV2 we use the variant with the part identifiers
523  mObserver->collectionChanged( collection );
524  }
525 }
526 
527 void AgentBasePrivate::collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &changedAttributes )
528 {
529  AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
530  if ( observer2 != 0 ) {
531  observer2->collectionChanged( collection, changedAttributes );
532  }
533 }
534 
535 void AgentBasePrivate::collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &source, const Akonadi::Collection &dest )
536 {
537  AgentBase::ObserverV2 *observer2 = dynamic_cast<AgentBase::ObserverV2*>( mObserver );
538  if ( observer2 ) {
539  observer2->collectionMoved( collection, source, dest );
540  } else if ( mObserver ) {
541  // ### we cannot just call collectionRemoved here as this will already trigger changeProcessed()
542  // so, just collectionAdded() is good enough as no resource can have implemented intra-resource moves anyway
543  // without using ObserverV2
544  mObserver->collectionAdded( collection, dest );
545  } else {
546  changeProcessed();
547  }
548 }
549 
550 void AgentBasePrivate::collectionRemoved( const Akonadi::Collection &collection )
551 {
552  if ( mObserver != 0 ) {
553  mObserver->collectionRemoved( collection );
554  }
555 }
556 
557 void AgentBasePrivate::collectionSubscribed( const Akonadi::Collection &collection, const Akonadi::Collection &parent )
558 {
559  Q_UNUSED( collection );
560  Q_UNUSED( parent );
561  changeProcessed();
562 }
563 
564 void AgentBasePrivate::collectionUnsubscribed( const Akonadi::Collection &collection )
565 {
566  Q_UNUSED( collection );
567  changeProcessed();
568 }
569 
570 void AgentBasePrivate::changeProcessed()
571 {
572  mChangeRecorder->changeProcessed();
573  QTimer::singleShot( 0, mChangeRecorder, SLOT(replayNext()) );
574 }
575 
576 void AgentBasePrivate::slotStatus( int status, const QString &message )
577 {
578  mStatusMessage = message;
579  mStatusCode = 0;
580 
581  switch ( status ) {
582  case AgentBase::Idle:
583  if ( mStatusMessage.isEmpty() ) {
584  mStatusMessage = defaultReadyMessage();
585  }
586 
587  mStatusCode = 0;
588  break;
589  case AgentBase::Running:
590  if ( mStatusMessage.isEmpty() ) {
591  mStatusMessage = defaultSyncingMessage();
592  }
593 
594  mStatusCode = 1;
595  break;
596  case AgentBase::Broken:
597  if ( mStatusMessage.isEmpty() ) {
598  mStatusMessage = defaultErrorMessage();
599  }
600 
601  mStatusCode = 2;
602  break;
603 
604  case AgentBase::NotConfigured:
605  if ( mStatusMessage.isEmpty() ) {
606  mStatusMessage = defaultUnconfiguredMessage();
607  }
608 
609  mStatusCode = 3;
610  break;
611 
612  default:
613  Q_ASSERT( !"Unknown status passed" );
614  break;
615  }
616 }
617 
618 void AgentBasePrivate::slotPercent( int progress )
619 {
620  mProgress = progress;
621 }
622 
623 void AgentBasePrivate::slotWarning( const QString& message )
624 {
625  mTracer->warning( QString::fromLatin1( "AgentBase(%1)" ).arg( mId ), message );
626 }
627 
628 void AgentBasePrivate::slotError( const QString& message )
629 {
630  mTracer->error( QString::fromLatin1( "AgentBase(%1)" ).arg( mId ), message );
631 }
632 
633 void AgentBasePrivate::slotNetworkStatusChange( Solid::Networking::Status stat )
634 {
635  Q_Q( AgentBase );
636  q->setOnlineInternal( mDesiredOnlineState && ( stat == Solid::Networking::Unknown || stat == Solid::Networking::Connected ) );
637 }
638 
639 void AgentBasePrivate::slotResumedFromSuspend()
640 {
641  if ( mNeedsNetwork ) {
642  slotNetworkStatusChange( Solid::Networking::status() );
643  }
644 }
645 
646 AgentBase::AgentBase( const QString & id )
647  : d_ptr( new AgentBasePrivate( this ) )
648 {
649  sAgentBase = this;
650  d_ptr->mId = id;
651  d_ptr->init();
652 }
653 
654 AgentBase::AgentBase( AgentBasePrivate* d, const QString &id ) :
655  d_ptr( d )
656 {
657  sAgentBase = this;
658  d_ptr->mId = id;
659  d_ptr->init();
660 }
661 
662 AgentBase::~AgentBase()
663 {
664  delete d_ptr;
665 }
666 
667 QString AgentBase::parseArguments( int argc, char **argv )
668 {
669  QString identifier;
670  if ( argc < 3 ) {
671  kDebug() << "Not enough arguments passed...";
672  exit( 1 );
673  }
674 
675  for ( int i = 1; i < argc - 1; ++i ) {
676  if ( QLatin1String( argv[ i ] ) == QLatin1String( "--identifier" ) ) {
677  identifier = QLatin1String( argv[ i + 1 ] );
678  }
679  }
680 
681  if ( identifier.isEmpty() ) {
682  kDebug() << "Identifier argument missing";
683  exit( 1 );
684  }
685 
686  const QFileInfo fi( QString::fromLocal8Bit( argv[0] ) );
687  // strip off full path and possible .exe suffix
688  const QByteArray catalog = fi.baseName().toLatin1();
689 
690  KCmdLineArgs::init( argc, argv, ServerManager::addNamespace( identifier ).toLatin1(), catalog, ki18n( "Akonadi Agent" ), KDEPIMLIBS_VERSION,
691  ki18n( "Akonadi Agent" ) );
692 
693  KCmdLineOptions options;
694  options.add( "identifier <argument>", ki18n( "Agent identifier" ) );
695  KCmdLineArgs::addCmdLineOptions( options );
696 
697  return identifier;
698 }
699 
700 // @endcond
701 
702 int AgentBase::init( AgentBase *r )
703 {
704  QApplication::setQuitOnLastWindowClosed( false );
705  KGlobal::locale()->insertCatalog( QLatin1String( "libakonadi" ) );
706  int rv = kapp->exec();
707  delete r;
708  return rv;
709 }
710 
711 int AgentBase::status() const
712 {
713  Q_D( const AgentBase );
714 
715  return d->mStatusCode;
716 }
717 
718 QString AgentBase::statusMessage() const
719 {
720  Q_D( const AgentBase );
721 
722  return d->mStatusMessage;
723 }
724 
725 int AgentBase::progress() const
726 {
727  Q_D( const AgentBase );
728 
729  return d->mProgress;
730 }
731 
732 QString AgentBase::progressMessage() const
733 {
734  Q_D( const AgentBase );
735 
736  return d->mProgressMessage;
737 }
738 
739 bool AgentBase::isOnline() const
740 {
741  Q_D( const AgentBase );
742 
743  return d->mOnline;
744 }
745 
746 void AgentBase::setNeedsNetwork( bool needsNetwork )
747 {
748  Q_D( AgentBase );
749  d->mNeedsNetwork = needsNetwork;
750 
751  if ( d->mNeedsNetwork ) {
752  connect( Solid::Networking::notifier()
753  , SIGNAL(statusChanged(Solid::Networking::Status))
754  , this, SLOT(slotNetworkStatusChange(Solid::Networking::Status))
755  , Qt::UniqueConnection );
756 
757  } else {
758  disconnect( Solid::Networking::notifier(), 0, 0, 0 );
759  setOnlineInternal( d->mDesiredOnlineState );
760  }
761 }
762 
763 void AgentBase::setOnline( bool state )
764 {
765  Q_D( AgentBase );
766  d->mDesiredOnlineState = state;
767  d->mSettings->setValue( QLatin1String( "Agent/DesiredOnlineState" ), state );
768  setOnlineInternal( state );
769 }
770 
771 void AgentBase::setOnlineInternal( bool state )
772 {
773  Q_D( AgentBase );
774  d->mOnline = state;
775 
776  const QString newMessage = d->defaultReadyMessage();
777  if ( d->mStatusMessage != newMessage && d->mStatusCode != AgentBase::Broken ) {
778  emit status( d->mStatusCode, newMessage );
779  }
780 
781  doSetOnline( state );
782  emit onlineChanged( state );
783 }
784 
785 void AgentBase::doSetOnline( bool online )
786 {
787  Q_UNUSED( online );
788 }
789 
790 void AgentBase::configure( WId windowId )
791 {
792  Q_UNUSED( windowId );
793  emit configurationDialogAccepted();
794 }
795 
796 #ifdef Q_OS_WIN //krazy:exclude=cpp
797 void AgentBase::configure( qlonglong windowId )
798 {
799  configure( reinterpret_cast<WId>( windowId ) );
800 }
801 #endif
802 
803 WId AgentBase::winIdForDialogs() const
804 {
805  const bool registered = DBusConnectionPool::threadConnection().interface()->isServiceRegistered( QLatin1String( "org.freedesktop.akonaditray" ) );
806  if ( !registered ) {
807  return 0;
808  }
809 
810  QDBusInterface dbus( QLatin1String( "org.freedesktop.akonaditray" ), QLatin1String( "/Actions" ),
811  QLatin1String( "org.freedesktop.Akonadi.Tray" ) );
812  const QDBusMessage reply = dbus.call( QLatin1String( "getWinId" ) );
813 
814  if ( reply.type() == QDBusMessage::ErrorMessage ) {
815  return 0;
816  }
817 
818  const WId winid = (WId)reply.arguments().at( 0 ).toLongLong();
819 
820  return winid;
821 }
822 
823 void AgentBase::quit()
824 {
825  Q_D( AgentBase );
826  aboutToQuit();
827 
828  if ( d->mSettings ) {
829  d->mChangeRecorder->setConfig( 0 );
830  d->mSettings->sync();
831  }
832 
833  KGlobal::deref();
834 }
835 
836 void AgentBase::aboutToQuit()
837 {
838 }
839 
840 void AgentBase::cleanup()
841 {
842  Q_D( AgentBase );
843  // prevent the monitor from picking up deletion signals for our own data if we are a resource
844  // and thus avoid that we kill our own data as last act before our own death
845  d->mChangeRecorder->blockSignals( true );
846 
847  aboutToQuit();
848 
849  const QString fileName = d->mSettings->fileName();
850 
851  /*
852  * First destroy the settings object...
853  */
854  d->mChangeRecorder->setConfig( 0 );
855  delete d->mSettings;
856  d->mSettings = 0;
857 
858  /*
859  * ... then remove the file from hd.
860  */
861  QFile::remove( fileName );
862 
863  /*
864  * ... and remove the changes file from hd.
865  */
866  QFile::remove( fileName + QLatin1String( "_changes.dat" ) );
867 
868  /*
869  * ... and also remove the agent configuration file if there is one.
870  */
871  QString configFile = KStandardDirs::locateLocal( "config", config()->name() );
872  QFile::remove( configFile );
873 
874  KGlobal::deref();
875 }
876 
877 void AgentBase::registerObserver( Observer *observer )
878 {
879  // TODO in theory we should re-connect change recorder signals here that we disconnected previously
880  d_ptr->mObserver = observer;
881 
882  const bool haveObserverV3 = (dynamic_cast<AgentBase::ObserverV3*>(d_ptr->mObserver) != 0);
883 
884  disconnect( d_ptr->mChangeRecorder, SIGNAL(itemsFlagsChanged(Akonadi::Item::List,QSet<QByteArray>,QSet<QByteArray>)),
885  d_ptr, SLOT(itemsFlagsChanged(Akonadi::Item::List,QSet<QByteArray>,QSet<QByteArray>)) );
886  disconnect( d_ptr->mChangeRecorder, SIGNAL(itemsMoved(Akonadi::Item::List,Akonadi::Collection,Akonadi::Collection)),
887  d_ptr, SLOT(itemsMoved(Akonadi::Item::List,Akonadi::Collection,Akonadi::Collection)) );
888  disconnect( d_ptr->mChangeRecorder, SIGNAL(itemsRemoved(Akonadi::Item::List)),
889  d_ptr, SLOT(itemsRemoved(Akonadi::Item::List)) );
890  disconnect( d_ptr->mChangeRecorder, SIGNAL(itemsLinked(Akonadi::Item::List,Akonadi::Collection)),
891  d_ptr, SLOT(itemsLinked(Akonadi::Item::List,Akonadi::Collection)) );
892  disconnect( d_ptr->mChangeRecorder, SIGNAL(itemsUnlinked(Akonadi::Item::List,Akonadi::Collection)),
893  d_ptr, SLOT(itemsUnlinked(Akonadi::Item::List,Akonadi::Collection)) );
894  disconnect( d_ptr->mChangeRecorder, SIGNAL(itemMoved(Akonadi::Item,Akonadi::Collection,Akonadi::Collection)),
895  d_ptr, SLOT(itemMoved(Akonadi::Item,Akonadi::Collection,Akonadi::Collection)) );
896  disconnect( d_ptr->mChangeRecorder, SIGNAL(itemRemoved(Akonadi::Item)),
897  d_ptr, SLOT(itemRemoved(Akonadi::Item)) );
898  disconnect( d_ptr->mChangeRecorder, SIGNAL(itemLinked(Akonadi::Item,Akonadi::Collection)),
899  d_ptr, SLOT(itemLinked(Akonadi::Item,Akonadi::Collection)) );
900  disconnect( d_ptr->mChangeRecorder, SIGNAL(itemUnlinked(Akonadi::Item,Akonadi::Collection)),
901  d_ptr, SLOT(itemUnlinked(Akonadi::Item,Akonadi::Collection)) );
902 
903  if ( haveObserverV3 ) {
904  connect( d_ptr->mChangeRecorder, SIGNAL(itemsFlagsChanged(Akonadi::Item::List,QSet<QByteArray>,QSet<QByteArray>)),
905  d_ptr, SLOT(itemsFlagsChanged(Akonadi::Item::List,QSet<QByteArray>,QSet<QByteArray>)) );
906  connect( d_ptr->mChangeRecorder, SIGNAL(itemsMoved(Akonadi::Item::List,Akonadi::Collection,Akonadi::Collection)),
907  d_ptr, SLOT(itemsMoved(Akonadi::Item::List,Akonadi::Collection,Akonadi::Collection)) );
908  connect( d_ptr->mChangeRecorder, SIGNAL(itemsRemoved(Akonadi::Item::List)),
909  d_ptr, SLOT(itemsRemoved(Akonadi::Item::List)) );
910  connect( d_ptr->mChangeRecorder, SIGNAL(itemsLinked(Akonadi::Item::List,Akonadi::Collection)),
911  d_ptr, SLOT(itemsLinked(Akonadi::Item::List,Akonadi::Collection)) );
912  connect( d_ptr->mChangeRecorder, SIGNAL(itemsUnlinked(Akonadi::Item::List,Akonadi::Collection)),
913  d_ptr, SLOT(itemsUnlinked(Akonadi::Item::List,Akonadi::Collection)) );
914  } else {
915  connect( d_ptr->mChangeRecorder, SIGNAL(itemMoved(Akonadi::Item,Akonadi::Collection,Akonadi::Collection)),
916  d_ptr, SLOT(itemMoved(Akonadi::Item,Akonadi::Collection,Akonadi::Collection)) );
917  connect( d_ptr->mChangeRecorder, SIGNAL(itemRemoved(Akonadi::Item)),
918  d_ptr, SLOT(itemRemoved(Akonadi::Item)) );
919  connect( d_ptr->mChangeRecorder, SIGNAL(itemLinked(Akonadi::Item,Akonadi::Collection)),
920  d_ptr, SLOT(itemLinked(Akonadi::Item,Akonadi::Collection)) );
921  connect( d_ptr->mChangeRecorder, SIGNAL(itemUnlinked(Akonadi::Item,Akonadi::Collection)),
922  d_ptr, SLOT(itemUnlinked(Akonadi::Item,Akonadi::Collection)) );
923  }
924 }
925 
926 QString AgentBase::identifier() const
927 {
928  return d_ptr->mId;
929 }
930 
931 void AgentBase::setAgentName( const QString &name )
932 {
933  Q_D( AgentBase );
934  if ( name == d->mName ) {
935  return;
936  }
937 
938  // TODO: rename collection
939  d->mName = name;
940 
941  if ( d->mName.isEmpty() || d->mName == d->mId ) {
942  d->mSettings->remove( QLatin1String( "Resource/Name" ) );
943  d->mSettings->remove( QLatin1String( "Agent/Name" ) );
944  } else
945  d->mSettings->setValue( QLatin1String( "Agent/Name" ), d->mName );
946 
947  d->mSettings->sync();
948 
949  d->setProgramName();
950 
951  emit agentNameChanged( d->mName );
952 }
953 
954 QString AgentBase::agentName() const
955 {
956  Q_D( const AgentBase );
957  if ( d->mName.isEmpty() ) {
958  return d->mId;
959  } else {
960  return d->mName;
961  }
962 }
963 
964 void AgentBase::changeProcessed()
965 {
966  Q_D( AgentBase );
967  d->changeProcessed();
968 }
969 
970 ChangeRecorder * AgentBase::changeRecorder() const
971 {
972  return d_ptr->mChangeRecorder;
973 }
974 
975 KSharedConfigPtr AgentBase::config()
976 {
977  if ( QCoreApplication::instance()->thread() == QThread::currentThread() ) {
978  return KGlobal::config();
979  } else {
980  return componentData().config();
981  }
982 }
983 
984 void AgentBase::abort()
985 {
986  emit abortRequested();
987 }
988 
989 void AgentBase::reconfigure()
990 {
991  emit reloadConfiguration();
992 }
993 
994 extern QThreadStorage<KComponentData*> s_agentComponentDatas;
995 
996 KComponentData AgentBase::componentData()
997 {
998  if ( QThread::currentThread() == QCoreApplication::instance()->thread() ) {
999  if ( s_agentComponentDatas.hasLocalData() ) {
1000  return *( s_agentComponentDatas.localData() );
1001  } else {
1002  return KGlobal::mainComponent();
1003  }
1004  }
1005 
1006  Q_ASSERT( s_agentComponentDatas.hasLocalData() );
1007  return *( s_agentComponentDatas.localData() );
1008 }
1009 
1010 #include "moc_agentbase.cpp"
1011 #include "moc_agentbase_p.cpp"
Akonadi::AgentBase::winIdForDialogs
WId winIdForDialogs() const
This method returns the windows id, which should be used for dialogs.
Akonadi::AgentBase::ObserverV3::itemsUnlinked
virtual void itemsUnlinked(const Akonadi::Item::List &items, const Akonadi::Collection &collection)
Reimplement to handle batch notifications about items unlinking.
Definition: agentbase.cpp:225
Akonadi::AgentBase::ObserverV3::itemsMoved
virtual void itemsMoved(const Akonadi::Item::List &items, const Akonadi::Collection &sourceCollection, const Akonadi::Collection &destinationCollection)
Reimplement to handle batch notification about items move.
Definition: agentbase.cpp:186
Akonadi::AgentBase::percent
void percent(int progress)
This signal should be emitted whenever the progress of an action in the agent (e.g.
Akonadi::AgentBase::abortRequested
void abortRequested()
Emitted when another application has remotely asked the agent to abort its current operation...
Akonadi::AgentBase::NotConfigured
The agent is lacking required configuration.
Definition: agentbase.h:367
Akonadi::AgentBase::AgentBase
AgentBase(const QString &id)
Creates an agent base.
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::AgentInstance::type
AgentType type() const
Returns the agent type of this instance.
Definition: agentinstance.cpp:51
Akonadi::AgentBase::ObserverV2::itemMoved
virtual void itemMoved(const Akonadi::Item &item, const Akonadi::Collection &collectionSource, const Akonadi::Collection &collectionDestination)
Reimplement to handle item moves.
Definition: agentbase.cpp:122
Akonadi::AgentBase::setNeedsNetwork
void setNeedsNetwork(bool needsNetwork)
Sets whether the agent needs network or not.
Akonadi::AgentType::name
QString name() const
Returns the i18n&#39;ed name of the agent type.
Definition: agenttype.cpp:51
Akonadi::AgentBase::ObserverV2::collectionMoved
virtual void collectionMoved(const Akonadi::Collection &collection, const Akonadi::Collection &collectionSource, const Akonadi::Collection &collectionDestination)
Reimplement to handle collection moves.
Definition: agentbase.cpp:156
Akonadi::AgentBase::Observer
The interface for reacting on monitored or replayed changes.
Definition: agentbase.h:185
Akonadi::AgentBase::componentData
static KComponentData componentData()
Returns the component data object for this agent instance.
Definition: agentbase.cpp:996
Akonadi::AgentBase::agentNameChanged
void agentNameChanged(const QString &name)
This signal is emitted whenever the name of the agent has changed.
Akonadi::AgentBase::reloadConfiguration
void reloadConfiguration()
Emitted if another application has changed the agent&#39;s configuration remotely and called AgentInstanc...
Akonadi::SessionPrivate::createDefaultSession
static void createDefaultSession(const QByteArray &sessionId)
Creates a new default session for this thread with the given sessionId.
Definition: session.cpp:432
Akonadi::ServerManager::serviceName
static QString serviceName(ServiceType serviceType)
Returns the namespaced D-Bus service name for serviceType.
Definition: servermanager.cpp:295
Akonadi::AgentBase::configurationDialogAccepted
void configurationDialogAccepted()
This signal is emitted whenever the user has accepted the configuration dialog.
Akonadi::AgentBase::ObserverV2::collectionChanged
virtual void collectionChanged(const Akonadi::Collection &collection, const QSet< QByteArray > &changedAttributes)
Reimplement to handle changes to existing collections.
Definition: agentbase.cpp:166
Akonadi::Session::defaultSession
static Session * defaultSession()
Returns the default session for this thread.
Definition: session.cpp:447
Akonadi::AgentBase::~AgentBase
~AgentBase()
Destroys the agent base.
Akonadi::AgentBasePrivate
Definition: agentbase_p.h:38
Akonadi::AgentBase
The base class for all Akonadi agents and resources.
Definition: agentbase.h:80
Akonadi::AgentBase::Observer::itemChanged
virtual void itemChanged(const Akonadi::Item &item, const QSet< QByteArray > &partIdentifiers)
Reimplement to handle changes to existing items.
Definition: agentbase.cpp:80
Akonadi::AgentBase::setAgentName
void setAgentName(const QString &name)
This method is used to set the name of the agent.
Definition: agentbase.cpp:931
Akonadi::AgentBase::error
void error(const QString &message)
This signal shall be used to report errors.
Akonadi::AgentBase::aboutToQuit
virtual void aboutToQuit()
This method is called whenever the agent application is about to quit.
Akonadi::AgentBase::Observer::~Observer
virtual ~Observer()
Destroys the observer instance.
Definition: agentbase.cpp:67
Akonadi::AgentBase::status
virtual int status() const
This method returns the current status code of the agent.
Akonadi::AgentBase::setOnline
void setOnline(bool state)
Sets whether the agent shall be online or not.
Akonadi::AgentBase::Observer::itemAdded
virtual void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection)
Reimplement to handle adding of new items.
Definition: agentbase.cpp:71
Akonadi::AgentBase::ObserverV2::itemUnlinked
virtual void itemUnlinked(const Akonadi::Item &item, const Akonadi::Collection &collection)
Reimplement to handle item unlinking.
Definition: agentbase.cpp:144
Akonadi::AgentManager::instance
AgentInstance instance(const QString &identifier) const
Returns the agent instance with the given identifier or an invalid agent instance if the identifier d...
Definition: agentmanager.cpp:403
Akonadi::AgentBase::ObserverV3::itemsFlagsChanged
virtual void itemsFlagsChanged(const Akonadi::Item::List &items, const QSet< QByteArray > &addedFlags, const QSet< QByteArray > &removedFlags)
Reimplement to handle changes in flags of existing items.
Definition: agentbase.cpp:172
Akonadi::AgentBase::config
KSharedConfigPtr config()
Returns the config object for this Agent.
Definition: agentbase.cpp:975
Akonadi::AgentBase::doSetOnline
virtual void doSetOnline(bool online)
This method is called whenever the online status has changed.
Akonadi::AgentBase::configure
virtual void configure(WId windowId)
This method is called whenever the agent shall show its configuration dialog to the user...
Akonadi::AgentBase::ObserverV2
BC extension of Observer with support for monitoring item and collection moves.
Definition: agentbase.h:244
Akonadi::AgentBase::Observer::itemRemoved
virtual void itemRemoved(const Akonadi::Item &item)
Reimplement to handle deletion of items.
Definition: agentbase.cpp:89
Akonadi::AgentBase::cleanup
virtual void cleanup()
This method is called when the agent is removed from the system, so it can do some cleanup stuff...
Akonadi::ServerManager::agentServiceName
static QString agentServiceName(ServiceAgentType agentType, const QString &identifier)
Returns the namespaced D-Bus service name for an agent of type agentType with agent identifier identi...
Definition: servermanager.cpp:307
Akonadi::AgentBase::ObserverV3
BC extension of ObserverV2 with support for batch operations.
Definition: agentbase.h:309
Akonadi::AgentBase::statusMessage
virtual QString statusMessage() const
This method returns an i18n&#39;ed description of the current status code.
Akonadi::AgentBase::Observer::collectionRemoved
virtual void collectionRemoved(const Akonadi::Collection &collection)
Reimplement to handle deletion of collections.
Definition: agentbase.cpp:114
Akonadi::ChangeRecorder::setConfig
void setConfig(QSettings *settings)
Sets the QSettings object used for persistent recorded changes.
Definition: changerecorder.cpp:42
Akonadi::AgentBase::ObserverV3::itemsRemoved
virtual void itemsRemoved(const Akonadi::Item::List &items)
Reimplement to handle batch notification about items deletion.
Definition: agentbase.cpp:200
Akonadi::AgentBase::Broken
The agent encountered an error state.
Definition: agentbase.h:366
Akonadi::AgentBase::progress
virtual int progress() const
This method returns the current progress of the agent in percentage.
Akonadi::AgentBase::Observer::Observer
Observer()
Creates an observer instance.
Definition: agentbase.cpp:63
Akonadi::AgentBase::identifier
QString identifier() const
Returns the instance identifier of this agent.
Definition: agentbase.cpp:926
Akonadi::AgentBase::Observer::collectionChanged
virtual void collectionChanged(const Akonadi::Collection &collection)
Reimplement to handle changes to existing collections.
Definition: agentbase.cpp:106
Akonadi::AgentBase::changeRecorder
ChangeRecorder * changeRecorder() const
Returns the Akonadi::ChangeRecorder object used for monitoring.
Definition: agentbase.cpp:970
Akonadi::AgentBase::registerObserver
void registerObserver(Observer *observer)
Registers the given observer for reacting on monitored or recorded changes.
Definition: agentbase.cpp:877
Akonadi::AgentBase::isOnline
bool isOnline() const
Returns whether the agent is currently online.
Akonadi::AgentBase::changeProcessed
void changeProcessed()
Marks the current change as processes and replays the next change if change recording is enabled (noo...
Definition: agentbase.cpp:964
Akonadi::AgentBase::ObserverV3::itemsLinked
virtual void itemsLinked(const Akonadi::Item::List &items, const Akonadi::Collection &collection)
Reimplement to handle batch notifications about items linking.
Definition: agentbase.cpp:212
Akonadi::AgentBase::ObserverV2::itemLinked
virtual void itemLinked(const Akonadi::Item &item, const Akonadi::Collection &collection)
Reimplement to handle item linking.
Definition: agentbase.cpp:132
Akonadi::AgentManager::self
static AgentManager * self()
Returns the global instance of the agent manager.
Definition: agentmanager.cpp:379
Akonadi::AgentBase::init
static int init(int argc, char **argv)
Use this method in the main function of your agent application to initialize your agent subclass...
Definition: agentbase.h:395
Akonadi::Collection::resource
QString resource() const
Returns the identifier of the resource owning the collection.
Definition: collection.cpp:207
Akonadi::AgentBase::onlineChanged
void onlineChanged(bool online)
Emitted when the online state changed.
Akonadi::AgentBase::Running
The agent is working on something.
Definition: agentbase.h:365
Akonadi::AgentBase::warning
void warning(const QString &message)
This signal shall be used to report warnings.
Akonadi::ServerManager::addNamespace
static QString addNamespace(const QString &string)
Adds the multi-instance namespace to string if required (with &#39;_&#39; as separator).
Definition: servermanager.cpp:321
Akonadi::AgentBase::Observer::collectionAdded
virtual void collectionAdded(const Akonadi::Collection &collection, const Akonadi::Collection &parent)
Reimplement to handle adding of new collections.
Definition: agentbase.cpp:97
Akonadi::AgentBase::progressMessage
virtual QString progressMessage() const
This method returns an i18n&#39;ed description of the current progress.
Akonadi::AgentBase::Idle
The agent does currently nothing.
Definition: agentbase.h:364
Akonadi::AgentBase::agentName
QString agentName() const
Returns the name of the agent.
Definition: agentbase.cpp:954
Akonadi::ChangeRecorder
Records and replays change notification.
Definition: changerecorder.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:03:15 by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs-4.11.3 API Reference

Skip menu "kdepimlibs-4.11.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal