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

akonadi

  • sources
  • kde-4.14
  • kdepimlibs
  • akonadi
specialcollectionshelperjobs.cpp
1 /*
2  Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "specialcollectionshelperjobs_p.h"
21 
22 #include "dbusconnectionpool.h"
23 #include "specialcollectionattribute_p.h"
24 #include "specialcollections.h"
25 #include "servermanager.h"
26 
27 #include <akonadi/agentinstance.h>
28 #include <akonadi/agentinstancecreatejob.h>
29 #include <akonadi/agentmanager.h>
30 #include <akonadi/collectionfetchjob.h>
31 #include <akonadi/collectionfetchscope.h>
32 #include <akonadi/collectionmodifyjob.h>
33 #include <akonadi/entitydisplayattribute.h>
34 #include <akonadi/resourcesynchronizationjob.h>
35 
36 #include <KDebug>
37 #include <KLocalizedString>
38 #include <kcoreconfigskeleton.h>
39 
40 #include <QtDBus/QDBusConnectionInterface>
41 #include <QtDBus/QDBusInterface>
42 #include <QtDBus/QDBusServiceWatcher>
43 #include <QtCore/QMetaMethod>
44 #include <QtCore/QTime>
45 #include <QtCore/QTimer>
46 
47 #define LOCK_WAIT_TIMEOUT_SECONDS 30
48 
49 using namespace Akonadi;
50 
51 // convenient methods to get/set the default resource id
52 static void setDefaultResourceId(KCoreConfigSkeleton *settings, const QString &value)
53 {
54  KConfigSkeletonItem *item = settings->findItem(QLatin1String("DefaultResourceId"));
55  Q_ASSERT(item);
56  item->setProperty(value);
57 }
58 
59 static QString defaultResourceId(KCoreConfigSkeleton *settings)
60 {
61  const KConfigSkeletonItem *item = settings->findItem(QLatin1String("DefaultResourceId"));
62  Q_ASSERT(item);
63  return item->property().toString();
64 }
65 
66 static QString dbusServiceName()
67 {
68  QString service = QString::fromLatin1("org.kde.pim.SpecialCollections");
69  if (ServerManager::hasInstanceIdentifier()) {
70  return service + ServerManager::instanceIdentifier();
71  }
72  return service;
73 }
74 
75 static QVariant::Type argumentType(const QMetaObject *mo, const QString &method)
76 {
77  QMetaMethod m;
78  for (int i = 0; i < mo->methodCount(); ++i) {
79  const QString signature = QString::fromLatin1(mo->method(i).signature());
80  if (signature.startsWith(method)) {
81  m = mo->method(i);
82  }
83  }
84 
85  if (!m.signature()) {
86  return QVariant::Invalid;
87  }
88 
89  const QList<QByteArray> argTypes = m.parameterTypes();
90  if (argTypes.count() != 1) {
91  return QVariant::Invalid;
92  }
93 
94  return QVariant::nameToType(argTypes.first());
95 }
96 
97 // ===================== ResourceScanJob ============================
98 
102 class Akonadi::ResourceScanJob::Private
103 {
104 public:
105  Private(KCoreConfigSkeleton *settings, ResourceScanJob *qq);
106 
107  void fetchResult(KJob *job); // slot
108 
109  ResourceScanJob *const q;
110 
111  // Input:
112  QString mResourceId;
113  KCoreConfigSkeleton *mSettings;
114 
115  // Output:
116  Collection mRootCollection;
117  Collection::List mSpecialCollections;
118 };
119 
120 ResourceScanJob::Private::Private(KCoreConfigSkeleton *settings, ResourceScanJob *qq)
121  : q(qq)
122  , mSettings(settings)
123 {
124 }
125 
126 void ResourceScanJob::Private::fetchResult(KJob *job)
127 {
128  if (job->error()) {
129  kWarning() << job->errorText();
130  return;
131  }
132 
133  CollectionFetchJob *fetchJob = qobject_cast<CollectionFetchJob *>(job);
134  Q_ASSERT(fetchJob);
135 
136  Q_ASSERT(!mRootCollection.isValid());
137  Q_ASSERT(mSpecialCollections.isEmpty());
138  foreach (const Collection &collection, fetchJob->collections()) {
139  if (collection.parentCollection() == Collection::root()) {
140  if (mRootCollection.isValid()) {
141  kWarning() << "Resource has more than one root collection. I don't know what to do.";
142  } else {
143  mRootCollection = collection;
144  }
145  }
146 
147  if (collection.hasAttribute<SpecialCollectionAttribute>()) {
148  mSpecialCollections.append(collection);
149  }
150  }
151 
152  kDebug() << "Fetched root collection" << mRootCollection.id()
153  << "and" << mSpecialCollections.count() << "local folders"
154  << "(total" << fetchJob->collections().count() << "collections).";
155 
156  if (!mRootCollection.isValid()) {
157  q->setError(Unknown);
158  q->setErrorText(i18n("Could not fetch root collection of resource %1.", mResourceId));
159  q->emitResult();
160  return;
161  }
162 
163  // We are done!
164  q->emitResult();
165 }
166 
167 ResourceScanJob::ResourceScanJob(const QString &resourceId, KCoreConfigSkeleton *settings, QObject *parent)
168  : Job(parent)
169  , d(new Private(settings, this))
170 {
171  setResourceId(resourceId);
172 }
173 
174 ResourceScanJob::~ResourceScanJob()
175 {
176  delete d;
177 }
178 
179 QString ResourceScanJob::resourceId() const
180 {
181  return d->mResourceId;
182 }
183 
184 void ResourceScanJob::setResourceId(const QString &resourceId)
185 {
186  d->mResourceId = resourceId;
187 }
188 
189 Akonadi::Collection ResourceScanJob::rootResourceCollection() const
190 {
191  return d->mRootCollection;
192 }
193 
194 Akonadi::Collection::List ResourceScanJob::specialCollections() const
195 {
196  return d->mSpecialCollections;
197 }
198 
199 void ResourceScanJob::doStart()
200 {
201  if (d->mResourceId.isEmpty()) {
202  if(!qobject_cast<DefaultResourceJob *>(this)) {
203  kError() << "No resource ID given.";
204  setError(Job::Unknown);
205  setErrorText(i18n("No resource ID given."));
206  }
207  emitResult();
208  return;
209  }
210 
211  CollectionFetchJob *fetchJob = new CollectionFetchJob(Collection::root(),
212  CollectionFetchJob::Recursive, this);
213  fetchJob->fetchScope().setResource(d->mResourceId);
214  fetchJob->fetchScope().setIncludeStatistics(true);
215  connect(fetchJob, SIGNAL(result(KJob*)), this, SLOT(fetchResult(KJob*)));
216 }
217 
218 // ===================== DefaultResourceJob ============================
219 
223 class Akonadi::DefaultResourceJobPrivate
224 {
225 public:
226  DefaultResourceJobPrivate(KCoreConfigSkeleton *settings, DefaultResourceJob *qq);
227 
228  void tryFetchResource();
229  void resourceCreateResult(KJob *job); // slot
230  void resourceSyncResult(KJob *job); // slot
231  void collectionFetchResult(KJob *job); // slot
232  void collectionModifyResult(KJob *job); // slot
233 
234  DefaultResourceJob *const q;
235  KCoreConfigSkeleton *mSettings;
236  bool mResourceWasPreexisting;
237  int mPendingModifyJobs;
238  QString mDefaultResourceType;
239  QVariantMap mDefaultResourceOptions;
240  QList<QByteArray> mKnownTypes;
241  QMap<QByteArray, QString> mNameForTypeMap;
242  QMap<QByteArray, QString> mIconForTypeMap;
243 };
244 
245 DefaultResourceJobPrivate::DefaultResourceJobPrivate(KCoreConfigSkeleton *settings, DefaultResourceJob *qq)
246  : q(qq)
247  , mSettings(settings)
248  , mResourceWasPreexisting(true /* for safety, so as not to accidentally delete data */)
249  , mPendingModifyJobs(0)
250 {
251 }
252 
253 void DefaultResourceJobPrivate::tryFetchResource()
254 {
255  // Get the resourceId from config. Another instance might have changed it in the meantime.
256  mSettings->readConfig();
257 
258  const QString resourceId = defaultResourceId(mSettings);
259 
260  kDebug() << "Read defaultResourceId" << resourceId << "from config.";
261 
262  const AgentInstance resource = AgentManager::self()->instance(resourceId);
263  if (resource.isValid()) {
264  // The resource exists; scan it.
265  mResourceWasPreexisting = true;
266  kDebug() << "Found resource" << resourceId;
267  q->setResourceId(resourceId);
268 
269  CollectionFetchJob *fetchJob = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive, q);
270  fetchJob->fetchScope().setResource(resourceId);
271  fetchJob->fetchScope().setIncludeStatistics(true);
272  q->connect(fetchJob, SIGNAL(result(KJob*)), q, SLOT(collectionFetchResult(KJob*)));
273  } else {
274  // Try harder: maybe the default resource has been removed and another one added
275  // without updating the config file, in this case search for a resource
276  // of the same type and the default name
277  const AgentInstance::List resources = AgentManager::self()->instances();
278  foreach (const AgentInstance &resource, resources) {
279  if (resource.type().identifier() == mDefaultResourceType) {
280  if (resource.name() == mDefaultResourceOptions.value(QLatin1String("Name")).toString()) {
281  // found a matching one...
282  setDefaultResourceId(mSettings, resource.identifier());
283  mSettings->writeConfig();
284  mResourceWasPreexisting = true;
285  kDebug() << "Found resource" << resource.identifier();
286  q->setResourceId(resource.identifier());
287  q->ResourceScanJob::doStart();
288  return;
289  }
290  }
291  }
292 
293  // Create the resource.
294  mResourceWasPreexisting = false;
295  kDebug() << "Creating maildir resource.";
296  const AgentType type = AgentManager::self()->type(mDefaultResourceType);
297  AgentInstanceCreateJob *job = new AgentInstanceCreateJob(type, q);
298  QObject::connect(job, SIGNAL(result(KJob*)), q, SLOT(resourceCreateResult(KJob*)));
299  job->start(); // non-Akonadi::Job
300  }
301 }
302 
303 void DefaultResourceJobPrivate::resourceCreateResult(KJob *job)
304 {
305  if (job->error()) {
306  kWarning() << job->errorText();
307  //fail( i18n( "Failed to create the default resource (%1).", job->errorString() ) );
308  q->setError(job->error());
309  q->setErrorText(job->errorText());
310  q->emitResult();
311  return;
312  }
313 
314  AgentInstance agent;
315 
316  // Get the resource instance.
317  {
318  AgentInstanceCreateJob *createJob = qobject_cast<AgentInstanceCreateJob *>(job);
319  Q_ASSERT(createJob);
320  agent = createJob->instance();
321  setDefaultResourceId(mSettings, agent.identifier());
322  kDebug() << "Created maildir resource with id" << defaultResourceId(mSettings);
323  }
324 
325  const QString defaultId = defaultResourceId(mSettings);
326 
327  // Configure the resource.
328  {
329  agent.setName(mDefaultResourceOptions.value(QLatin1String("Name")).toString());
330 
331  QDBusInterface conf(QString::fromLatin1("org.freedesktop.Akonadi.Resource.") + defaultId,
332  QString::fromLatin1("/Settings"), QString());
333 
334  if (!conf.isValid()) {
335  q->setError(-1);
336  q->setErrorText(i18n("Invalid resource identifier '%1'", defaultId));
337  q->emitResult();
338  return;
339  }
340 
341  QMapIterator<QString, QVariant> it(mDefaultResourceOptions);
342  while (it.hasNext()) {
343  it.next();
344 
345  if (it.key() == QLatin1String("Name")) {
346  continue;
347  }
348 
349  const QString methodName = QString::fromLatin1("set%1").arg(it.key());
350  const QVariant::Type argType = argumentType(conf.metaObject(), methodName);
351  if (argType == QVariant::Invalid) {
352  q->setError(Job::Unknown);
353  q->setErrorText(i18n("Failed to configure default resource via D-Bus."));
354  q->emitResult();
355  return;
356  }
357 
358  QDBusReply<void> reply = conf.call(methodName, it.value());
359  if (!reply.isValid()) {
360  q->setError(Job::Unknown);
361  q->setErrorText(i18n("Failed to configure default resource via D-Bus."));
362  q->emitResult();
363  return;
364  }
365  }
366 
367  conf.call(QLatin1String("writeConfig"));
368 
369  agent.reconfigure();
370  }
371 
372  // Sync the resource.
373  {
374  ResourceSynchronizationJob *syncJob = new ResourceSynchronizationJob(agent, q);
375  QObject::connect(syncJob, SIGNAL(result(KJob*)), q, SLOT(resourceSyncResult(KJob*)));
376  syncJob->start(); // non-Akonadi
377  }
378 }
379 
380 void DefaultResourceJobPrivate::resourceSyncResult(KJob *job)
381 {
382  if (job->error()) {
383  kWarning() << job->errorText();
384  //fail( i18n( "ResourceSynchronizationJob failed (%1).", job->errorString() ) );
385  return;
386  }
387 
388  // Fetch the collections of the resource.
389  kDebug() << "Fetching maildir collections.";
390  CollectionFetchJob *fetchJob = new CollectionFetchJob(Collection::root(), CollectionFetchJob::Recursive, q);
391  fetchJob->fetchScope().setResource(defaultResourceId(mSettings));
392  QObject::connect(fetchJob, SIGNAL(result(KJob*)), q, SLOT(collectionFetchResult(KJob*)));
393 }
394 
395 void DefaultResourceJobPrivate::collectionFetchResult(KJob *job)
396 {
397  if (job->error()) {
398  kWarning() << job->errorText();
399  //fail( i18n( "Failed to fetch the root maildir collection (%1).", job->errorString() ) );
400  return;
401  }
402 
403  CollectionFetchJob *fetchJob = qobject_cast<CollectionFetchJob *>(job);
404  Q_ASSERT(fetchJob);
405 
406  const Collection::List collections = fetchJob->collections();
407  kDebug() << "Fetched" << collections.count() << "collections.";
408 
409  // Find the root maildir collection.
410  Collection::List toRecover;
411  Collection resourceCollection;
412  foreach (const Collection &collection, collections) {
413  if (collection.parentCollection() == Collection::root()) {
414  resourceCollection = collection;
415  toRecover.append(collection);
416  break;
417  }
418  }
419 
420  if (!resourceCollection.isValid()) {
421  q->setError(Job::Unknown);
422  q->setErrorText(i18n("Failed to fetch the resource collection."));
423  q->emitResult();
424  return;
425  }
426 
427  // Find all children of the resource collection.
428  foreach (const Collection &collection, collections) {
429  if (collection.parentCollection() == resourceCollection) {
430  toRecover.append(collection);
431  }
432  }
433 
434  QHash<QString, QByteArray> typeForName;
435  foreach (const QByteArray &type, mKnownTypes) {
436  const QString displayName = mNameForTypeMap.value(type);
437  typeForName[displayName] = type;
438  }
439 
440  // These collections have been created by the maildir resource, when it
441  // found the folders on disk. So give them the necessary attributes now.
442  Q_ASSERT(mPendingModifyJobs == 0);
443  foreach (Collection collection, toRecover) { // krazy:exclude=foreach
444 
445  if (collection.hasAttribute<SpecialCollectionAttribute>()) {
446  continue;
447  }
448 
449  // Find the type for the collection.
450  const QString name = collection.displayName();
451  const QByteArray type = typeForName.value(name);
452 
453  if (!type.isEmpty()) {
454  kDebug() << "Recovering collection" << name;
455  setCollectionAttributes(collection, type, mNameForTypeMap, mIconForTypeMap);
456 
457  CollectionModifyJob *modifyJob = new CollectionModifyJob(collection, q);
458  QObject::connect(modifyJob, SIGNAL(result(KJob*)), q, SLOT(collectionModifyResult(KJob*)));
459  mPendingModifyJobs++;
460  } else {
461  kDebug() << "Searching for names: " << typeForName.keys();
462  kDebug() << "Unknown collection name" << name << "-- not recovering.";
463  }
464  }
465 
466  if (mPendingModifyJobs == 0) {
467  // Scan the resource.
468  q->setResourceId(defaultResourceId(mSettings));
469  q->ResourceScanJob::doStart();
470  }
471 }
472 
473 void DefaultResourceJobPrivate::collectionModifyResult(KJob *job)
474 {
475  if (job->error()) {
476  kWarning() << job->errorText();
477  //fail( i18n( "Failed to modify the root maildir collection (%1).", job->errorString() ) );
478  return;
479  }
480 
481  Q_ASSERT(mPendingModifyJobs > 0);
482  mPendingModifyJobs--;
483  kDebug() << "pendingModifyJobs now" << mPendingModifyJobs;
484  if (mPendingModifyJobs == 0) {
485  // Write the updated config.
486  kDebug() << "Writing defaultResourceId" << defaultResourceId(mSettings) << "to config.";
487  mSettings->writeConfig();
488 
489  // Scan the resource.
490  q->setResourceId(defaultResourceId(mSettings));
491  q->ResourceScanJob::doStart();
492  }
493 }
494 
495 DefaultResourceJob::DefaultResourceJob(KCoreConfigSkeleton *settings, QObject *parent)
496  : ResourceScanJob(QString(), settings, parent)
497  , d(new DefaultResourceJobPrivate(settings, this))
498 {
499 }
500 
501 DefaultResourceJob::~DefaultResourceJob()
502 {
503  delete d;
504 }
505 
506 void DefaultResourceJob::setDefaultResourceType(const QString &type)
507 {
508  d->mDefaultResourceType = type;
509 }
510 
511 void DefaultResourceJob::setDefaultResourceOptions(const QVariantMap &options)
512 {
513  d->mDefaultResourceOptions = options;
514 }
515 
516 void DefaultResourceJob::setTypes(const QList<QByteArray> &types)
517 {
518  d->mKnownTypes = types;
519 }
520 
521 void DefaultResourceJob::setNameForTypeMap(const QMap<QByteArray, QString> &map)
522 {
523  d->mNameForTypeMap = map;
524 }
525 
526 void DefaultResourceJob::setIconForTypeMap(const QMap<QByteArray, QString> &map)
527 {
528  d->mIconForTypeMap = map;
529 }
530 
531 void DefaultResourceJob::doStart()
532 {
533  d->tryFetchResource();
534 }
535 
536 void DefaultResourceJob::slotResult(KJob *job)
537 {
538  if (job->error()) {
539  kWarning() << job->errorText();
540  // Do some cleanup.
541  if (!d->mResourceWasPreexisting) {
542  // We only removed the resource instance if we have created it.
543  // Otherwise we might lose the user's data.
544  const AgentInstance resource = AgentManager::self()->instance(defaultResourceId(d->mSettings));
545  kDebug() << "Removing resource" << resource.identifier();
546  AgentManager::self()->removeInstance(resource);
547  }
548  }
549 
550  Job::slotResult(job);
551 }
552 
553 // ===================== GetLockJob ============================
554 
555 class Akonadi::GetLockJob::Private
556 {
557 public:
558  Private(GetLockJob *qq);
559 
560  void doStart(); // slot
561  void serviceOwnerChanged(const QString &name, const QString &oldOwner,
562  const QString &newOwner); // slot
563  void timeout(); // slot
564 
565  GetLockJob *const q;
566  QTimer *mSafetyTimer;
567 };
568 
569 GetLockJob::Private::Private(GetLockJob *qq)
570  : q(qq)
571  , mSafetyTimer(0)
572 {
573 }
574 
575 void GetLockJob::Private::doStart()
576 {
577  // Just doing registerService() and checking its return value is not sufficient,
578  // since we may *already* own the name, and then registerService() returns true.
579 
580  QDBusConnection bus = DBusConnectionPool::threadConnection();
581  const bool alreadyLocked = bus.interface()->isServiceRegistered(dbusServiceName());
582  const bool gotIt = bus.registerService(dbusServiceName());
583 
584  if (gotIt && !alreadyLocked) {
585  //kDebug() << "Got lock immediately.";
586  q->emitResult();
587  } else {
588  QDBusServiceWatcher *watcher = new QDBusServiceWatcher(dbusServiceName(), DBusConnectionPool::threadConnection(),
589  QDBusServiceWatcher::WatchForOwnerChange, q);
590  //kDebug() << "Waiting for lock.";
591  connect(watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
592  q, SLOT(serviceOwnerChanged(QString,QString,QString)));
593 
594  mSafetyTimer = new QTimer(q);
595  mSafetyTimer->setSingleShot(true);
596  mSafetyTimer->setInterval(LOCK_WAIT_TIMEOUT_SECONDS * 1000);
597  mSafetyTimer->start();
598  connect(mSafetyTimer, SIGNAL(timeout()), q, SLOT(timeout()));
599  }
600 }
601 
602 void GetLockJob::Private::serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner)
603 {
604  if (newOwner.isEmpty()) {
605  const bool gotIt = DBusConnectionPool::threadConnection().registerService(dbusServiceName());
606  if (gotIt) {
607  mSafetyTimer->stop();
608  q->emitResult();
609  }
610  }
611 }
612 
613 void GetLockJob::Private::timeout()
614 {
615  kWarning() << "Timeout trying to get lock. Check who has acquired the name" << dbusServiceName() << "on DBus, using qdbus or qdbusviewer.";
616  q->setError(Job::Unknown);
617  q->setErrorText(i18n("Timeout trying to get lock."));
618  q->emitResult();
619 }
620 
621 GetLockJob::GetLockJob(QObject *parent)
622  : KJob(parent)
623  , d(new Private(this))
624 {
625 }
626 
627 GetLockJob::~GetLockJob()
628 {
629  delete d;
630 }
631 
632 void GetLockJob::start()
633 {
634  QTimer::singleShot(0, this, SLOT(doStart()));
635 }
636 
637 void Akonadi::setCollectionAttributes(Akonadi::Collection &collection, const QByteArray &type,
638  const QMap<QByteArray, QString> &nameForType,
639  const QMap<QByteArray, QString> &iconForType)
640 {
641  {
642  EntityDisplayAttribute *attr = new EntityDisplayAttribute;
643  attr->setIconName(iconForType.value(type));
644  attr->setDisplayName(nameForType.value(type));
645  collection.addAttribute(attr);
646  }
647 
648  {
649  SpecialCollectionAttribute *attr = new SpecialCollectionAttribute;
650  attr->setCollectionType(type);
651  collection.addAttribute(attr);
652  }
653 }
654 
655 bool Akonadi::releaseLock()
656 {
657  return DBusConnectionPool::threadConnection().unregisterService(dbusServiceName());
658 }
659 
660 #include "moc_specialcollectionshelperjobs_p.cpp"
Akonadi::CollectionModifyJob
Job that modifies a collection in the Akonadi storage.
Definition: collectionmodifyjob.h:82
Akonadi::AgentManager::instances
AgentInstance::List instances() const
Returns the list of all available agent instances.
Definition: agentmanager.cpp:396
Akonadi::DefaultResourceJob::setNameForTypeMap
void setNameForTypeMap(const QMap< QByteArray, QString > &map)
Sets the map of special collection types to display names.
Definition: specialcollectionshelperjobs.cpp:521
Akonadi::CollectionFetchJob::collections
Collection::List collections() const
Returns the list of fetched collection.
Definition: collectionfetchjob.cpp:169
Akonadi::releaseLock
bool AKONADI_TESTS_EXPORT releaseLock()
Releases the SpecialCollectionsRequestJob lock that was obtained through GetLockJob.
Definition: specialcollectionshelperjobs.cpp:655
Akonadi::ServerManager::instanceIdentifier
static QString instanceIdentifier()
Returns the identifier of the Akonadi instance we are connected to.
Definition: servermanager.cpp:284
Akonadi::Collection::displayName
QString displayName() const
Returns the display name (EntityDisplayAttribute::displayName()) if set, and Collection::name() other...
Definition: collection.cpp:86
QByteArray
Akonadi::GetLockJob::GetLockJob
GetLockJob(QObject *parent=0)
Creates a new GetLockJob.
Definition: specialcollectionshelperjobs.cpp:621
QDBusReply
Akonadi::Job::Unknown
Unknown error.
Definition: job.h:108
QDBusConnection::interface
QDBusConnectionInterface * interface() const
Akonadi::CollectionFetchJob::fetchScope
CollectionFetchScope & fetchScope()
Returns the collection fetch scope.
Definition: collectionfetchjob.cpp:439
Akonadi::CollectionFetchScope::setResource
void setResource(const QString &resource)
Sets a resource filter, that is only collections owned by the specified resource are retrieved...
Definition: collectionfetchscope.cpp:118
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:50
QMap
Akonadi::CollectionFetchJob
Job that fetches collections from the Akonadi storage.
Definition: collectionfetchjob.h:53
Akonadi::DefaultResourceJob::setDefaultResourceOptions
void setDefaultResourceOptions(const QVariantMap &options)
Sets the configuration options that shall be applied to the new resource that is created if the reque...
Definition: specialcollectionshelperjobs.cpp:511
QByteArray::isEmpty
bool isEmpty() const
Akonadi::CollectionFetchScope::setIncludeStatistics
void setIncludeStatistics(bool include)
Sets whether collection statistics should be included in the retrieved results.
Definition: collectionfetchscope.cpp:108
Akonadi::SpecialCollectionAttribute
An Attribute that stores the special collection type of a collection.
Definition: specialcollectionattribute_p.h:39
Akonadi::DefaultResourceJob::doStart
virtual void doStart()
This method must be reimplemented in the concrete jobs.
Definition: specialcollectionshelperjobs.cpp:531
Akonadi::GetLockJob
Definition: specialcollectionshelperjobs_p.h:194
QDBusConnection
QDBusReply::isValid
bool isValid() const
Akonadi::AgentInstance::identifier
QString identifier() const
Returns the unique identifier of the agent instance.
Definition: agentinstance.cpp:55
Akonadi::Job
Base class for all actions in the Akonadi storage.
Definition: job.h:86
QMetaMethod::parameterTypes
QList< QByteArray > parameterTypes() const
Akonadi::AgentType::identifier
QString identifier() const
Returns the unique identifier of the agent type.
Definition: agenttype.cpp:46
Akonadi::AgentManager::removeInstance
void removeInstance(const AgentInstance &instance)
Removes the given agent instance.
Definition: agentmanager.cpp:406
QDBusConnectionInterface::isServiceRegistered
QDBusReply< bool > isServiceRegistered(const QString &serviceName) const
Akonadi::ResourceScanJob::~ResourceScanJob
~ResourceScanJob()
Destroys this ResourceScanJob.
Definition: specialcollectionshelperjobs.cpp:174
Akonadi::ResourceSynchronizationJob
Job that synchronizes a resource.
Definition: resourcesynchronizationjob.h:59
Akonadi::ResourceScanJob::ResourceScanJob
ResourceScanJob(const QString &resourceId, KCoreConfigSkeleton *settings, QObject *parent=0)
Creates a new ResourceScanJob.
Definition: specialcollectionshelperjobs.cpp:167
QList::count
int count(const T &value) const
Akonadi::AgentType
A representation of an agent type.
Definition: agenttype.h:58
QList::append
void append(const T &value)
QMapIterator
QMetaObject
QTimer
Akonadi::Entity::parentCollection
Collection parentCollection() const
Returns the parent collection of this object.
Definition: entity.cpp:185
QHash
Akonadi::Entity::addAttribute
void addAttribute(Attribute *attribute)
Adds an attribute to the entity.
Definition: entity.cpp:127
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:401
QObject
Akonadi::EntityDisplayAttribute::setIconName
void setIconName(const QString &name)
Sets the icon name for the default icon.
Definition: entitydisplayattribute.cpp:72
QVariant::nameToType
Type nameToType(const char *name)
Akonadi::AgentInstance::isValid
bool isValid() const
Returns whether the agent instance object is valid.
Definition: agentinstance.cpp:45
QString::isEmpty
bool isEmpty() const
QMetaObject::methodCount
int methodCount() const
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
QMetaMethod::signature
const char * signature() const
Akonadi::Collection::root
static Collection root()
Returns the root collection.
Definition: collection.cpp:192
QList::first
T & first()
QString
QList< QByteArray >
Akonadi::DefaultResourceJob
Definition: specialcollectionshelperjobs_p.h:116
Akonadi::EntityDisplayAttribute::setDisplayName
void setDisplayName(const QString &name)
Sets the name that should be used for display.
Definition: entitydisplayattribute.cpp:57
Akonadi::Entity::id
Id id() const
Returns the unique identifier of the entity.
Definition: entity.cpp:72
QHash::keys
QList< Key > keys() const
QDBusInterface
QHash::value
const T value(const Key &key) const
Akonadi::ResourceScanJob::rootResourceCollection
Akonadi::Collection rootResourceCollection() const
Returns the root collection of the resource being scanned.
Definition: specialcollectionshelperjobs.cpp:189
Akonadi::AgentManager::type
AgentType type(const QString &identifier) const
Returns the agent type with the given identifier or an invalid agent type if the identifier does not ...
Definition: agentmanager.cpp:391
Akonadi::AgentInstance::setName
void setName(const QString &name)
Sets the user visible name of the agent instance.
Definition: agentinstance.cpp:60
Akonadi::ResourceScanJob::specialCollections
Akonadi::Collection::List specialCollections() const
Returns all the collections of this resource which have a SpecialCollectionAttribute.
Definition: specialcollectionshelperjobs.cpp:194
Akonadi::AgentInstanceCreateJob
Job for creating new agent instances.
Definition: agentinstancecreatejob.h:71
Akonadi::SpecialCollectionAttribute::setCollectionType
void setCollectionType(const QByteArray &type)
Sets the special collections type of the collection.
Definition: specialcollectionattribute.cpp:69
Akonadi::DefaultResourceJob::setIconForTypeMap
void setIconForTypeMap(const QMap< QByteArray, QString > &map)
Sets the map of special collection types to icon names.
Definition: specialcollectionshelperjobs.cpp:526
QLatin1String
Akonadi::AgentInstance::name
QString name() const
Returns the user visible name of the agent instance.
Definition: agentinstance.cpp:65
Akonadi::Entity::hasAttribute
bool hasAttribute(const QByteArray &name) const
Returns true if the entity has an attribute of the given type name, false otherwise.
Definition: entity.cpp:148
Akonadi::ResourceScanJob::setResourceId
void setResourceId(const QString &resourceId)
Sets the resource ID of the resource to scan.
Definition: specialcollectionshelperjobs.cpp:184
Akonadi::AgentManager::self
static AgentManager * self()
Returns the global instance of the agent manager.
Definition: agentmanager.cpp:377
QString::fromLatin1
QString fromLatin1(const char *str, int size)
Akonadi::ResourceScanJob
Definition: specialcollectionshelperjobs_p.h:45
Akonadi::AgentInstance
A representation of an agent instance.
Definition: agentinstance.h:62
Akonadi::DefaultResourceJob::setDefaultResourceType
void setDefaultResourceType(const QString &type)
Sets the type of the resource that shall be created if the requested special collection does not exis...
Definition: specialcollectionshelperjobs.cpp:506
Akonadi::Entity::isValid
bool isValid() const
Returns whether the entity is valid.
Definition: entity.cpp:97
Akonadi::DefaultResourceJob::setTypes
void setTypes(const QList< QByteArray > &types)
Sets the list of well known special collection types.
Definition: specialcollectionshelperjobs.cpp:516
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Akonadi::GetLockJob::~GetLockJob
~GetLockJob()
Destroys the GetLockJob.
Definition: specialcollectionshelperjobs.cpp:627
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Akonadi::ResourceScanJob::doStart
virtual void doStart()
This method must be reimplemented in the concrete jobs.
Definition: specialcollectionshelperjobs.cpp:199
Akonadi::CollectionFetchJob::Recursive
List all sub-collections.
Definition: collectionfetchjob.h:64
QMetaObject::method
QMetaMethod method(int index) const
QMetaMethod
Akonadi::EntityDisplayAttribute
Attribute that stores the properties that are used to display an entity.
Definition: entitydisplayattribute.h:39
Akonadi::ResourceScanJob::resourceId
QString resourceId() const
Returns the resource ID of the resource being scanned.
Definition: specialcollectionshelperjobs.cpp:179
Akonadi::ServerManager::hasInstanceIdentifier
static bool hasInstanceIdentifier()
Returns true if we are connected to a non-default Akonadi server instance.
Definition: servermanager.cpp:289
Akonadi::DefaultResourceJob::~DefaultResourceJob
~DefaultResourceJob()
Destroys the DefaultResourceJob.
Definition: specialcollectionshelperjobs.cpp:501
QDBusConnection::registerService
bool registerService(const QString &serviceName)
Akonadi::setCollectionAttributes
void setCollectionAttributes(Akonadi::Collection &col, const QByteArray &type, const QMap< QByteArray, QString > &nameForType, const QMap< QByteArray, QString > &iconForType)
Sets on col the required attributes of SpecialCollection type type These are a SpecialCollectionAttri...
Definition: specialcollectionshelperjobs.cpp:637
QDBusServiceWatcher
Akonadi::AgentInstanceCreateJob::start
void start()
Starts the instance creation.
Definition: agentinstancecreatejob.cpp:176
Akonadi::DefaultResourceJob::DefaultResourceJob
DefaultResourceJob(KCoreConfigSkeleton *settings, QObject *parent=0)
Creates a new DefaultResourceJob.
Definition: specialcollectionshelperjobs.cpp:495
QMap::value
const T value(const Key &key) const
QTimer::singleShot
singleShot
Akonadi::AgentInstance::reconfigure
void reconfigure() const
Tell the agent that its configuration has been changed remotely via D-Bus.
Definition: agentinstance.cpp:149
Akonadi::AgentInstanceCreateJob::instance
AgentInstance instance() const
Returns the AgentInstance object of the newly created agent instance.
Definition: agentinstancecreatejob.cpp:171
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:03 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs 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

Search



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