Akonadi
resourcebase.cpp
82 // HACK: skip local changes of the EntityDisplayAttribute by default. Remove this for KDE5 and adjust resource implementations accordingly.
98 qCCritical(AKONADIAGENTBASE_LOG) << "Unable to register service" << serviceId << "at D-Bus:" << reason;
184 connect(mItemSyncer, &ItemSync::readyForNextBatch, q, &ResourceBase::retrieveNextItemSyncBatch);
208 // reimplementations from AgentbBasePrivate, containing sanity checks that only apply to resources
210 // TODO: we could possibly add recovery code for no-RID notifications by re-enquing those to the change recorder
211 // as the corresponding Add notifications, although that contains a risk of endless fail/retry loops
231 void itemsFlagsChanged(const Akonadi::Item::List &items, const QSet<QByteArray> &addedFlags, const QSet<QByteArray> &removedFlags) override
247 void itemsTagsChanged(const Akonadi::Item::List &items, const QSet<Akonadi::Tag> &addedTags, const QSet<Akonadi::Tag> &removedTags) override
264 void itemMoved(const Akonadi::Item &item, const Akonadi::Collection &source, const Akonadi::Collection &destination) override
273 void itemsMoved(const Akonadi::Item::List &items, const Akonadi::Collection &source, const Akonadi::Collection &destination) override
309 void collectionAdded(const Akonadi::Collection &collection, const Akonadi::Collection &parent) override
327 void collectionChanged(const Akonadi::Collection &collection, const QSet<QByteArray> &partIdentifiers) override
336 void collectionMoved(const Akonadi::Collection &collection, const Akonadi::Collection &source, const Akonadi::Collection &destination) override
344 // inter-resource moves, requires we know which resources the source and destination are in though
345 if (!source.resource().isEmpty() && !destination.resource().isEmpty() && source.resource() != destination.resource()) {
455 connect(d->mChangeRecorder, &ChangeRecorder::changesAdded, d->scheduler, &ResourceScheduler::scheduleChangeReplay);
460 connect(d->scheduler, &ResourceScheduler::executeFullSync, this, &ResourceBase::retrieveCollections);
461 connect(d->scheduler, &ResourceScheduler::executeCollectionTreeSync, this, &ResourceBase::retrieveCollections);
462 connect(d->scheduler, &ResourceScheduler::executeCollectionSync, d, &ResourceBasePrivate::slotSynchronizeCollection);
463 connect(d->scheduler, &ResourceScheduler::executeCollectionAttributesSync, d, &ResourceBasePrivate::slotSynchronizeCollectionAttributes);
464 connect(d->scheduler, &ResourceScheduler::executeTagSync, d, &ResourceBasePrivate::slotSynchronizeTags);
465 connect(d->scheduler, &ResourceScheduler::executeItemFetch, d, &ResourceBasePrivate::slotPrepareItemRetrieval);
466 connect(d->scheduler, &ResourceScheduler::executeItemsFetch, d, &ResourceBasePrivate::slotPrepareItemsRetrieval);
467 connect(d->scheduler, &ResourceScheduler::executeResourceCollectionDeletion, d, &ResourceBasePrivate::slotDeleteResourceCollection);
468 connect(d->scheduler, &ResourceScheduler::executeCacheInvalidation, d, &ResourceBasePrivate::slotInvalidateCache);
469 connect(d->scheduler, &ResourceScheduler::status, this, qOverload<int, const QString &>(&ResourceBase::status));
470 connect(d->scheduler, &ResourceScheduler::executeChangeReplay, d->mChangeRecorder, &ChangeRecorder::replayNext);
471 connect(d->scheduler, &ResourceScheduler::executeRecursiveMoveReplay, d, &ResourceBasePrivate::slotRecursiveMoveReplay);
473 connect(d->scheduler, &ResourceScheduler::collectionTreeSyncComplete, this, &ResourceBase::collectionTreeSynchronized);
474 connect(d->mChangeRecorder, &ChangeRecorder::nothingToReplay, d->scheduler, &ResourceScheduler::taskDone);
475 connect(d->mChangeRecorder, &Monitor::collectionRemoved, d->scheduler, &ResourceScheduler::collectionRemoved);
478 connect(this, &ResourceBase::collectionTreeSynchronized, d->scheduler, &ResourceScheduler::taskDone);
480 connect(&d->mProgressEmissionCompressor, &QTimer::timeout, d, &ResourceBasePrivate::slotDelayedEmitProgress);
489 connect(d->mChangeRecorder->session(), &Session::reconnected, d, &ResourceBasePrivate::slotSessionReconnected);
533 QCommandLineOption identifierOption(QStringLiteral("identifier"), i18nc("@label command line option", "Resource identifier"), QStringLiteral("argument"));
772void ResourceBase::collectionsRetrievedIncremental(const Collection::List &changedCollections, const Collection::List &removedCollections)
856 const auto lType = l.hasAttribute<SpecialCollectionAttribute>() ? l.attribute<SpecialCollectionAttribute>()->collectionType() : QByteArray();
857 const bool lInbox = (lType == "inbox") || (QStringView(l.remoteId()).mid(1).compare(QLatin1StringView("inbox"), Qt::CaseInsensitive) == 0);
860 const auto rType = r.hasAttribute<SpecialCollectionAttribute>() ? r.attribute<SpecialCollectionAttribute>()->collectionType() : QByteArray();
861 const bool rInbox = (rType == "inbox") || (QStringView(r.remoteId()).mid(1).compare(QLatin1StringView("inbox"), Qt::CaseInsensitive) == 0);
911 // This can happen due to FetchHelper::triggerOnDemandFetch() in the akonadi server (not an error).
919 Q_EMIT q->status(AgentBase::Running, i18nc("@info:status", "Syncing folder '%1'", currentCollection.displayName()));
922 qCDebug(AKONADIAGENTBASE_LOG) << "Preparing collection sync of collection" << currentCollection.id() << currentCollection.displayName();
925 connect(fetchJob, &KJob::result, this, &ResourceBasePrivate::slotItemRetrievalCollectionFetchDone);
938 qCWarning(AKONADIAGENTBASE_LOG) << "Failed to retrieve collection for sync: " << job->errorString();
945 qCWarning(AKONADIAGENTBASE_LOG) << "The fetch job returned empty collection set. This is unexpected.";
976 connect(fetchJob, &KJob::result, this, &ResourceBasePrivate::slotAttributeRetrievalCollectionFetchDone);
986 qCWarning(AKONADIAGENTBASE_LOG) << "Failed to retrieve collection for attribute sync: " << job->errorString();
992 QMetaObject::invokeMethod(q, "retrieveCollectionAttributes", Q_ARG(Akonadi::Collection, fetchJob->collections().at(0)));
1008 fetch->fetchScope().setAncestorRetrieval(qMax(ItemFetchScope::Parent, q->changeRecorder()->itemFetchScope().ancestorRetrieval()));
1047 fetch->fetchScope().setAncestorRetrieval(qMax(ItemFetchScope::Parent, q->changeRecorder()->itemFetchScope().ancestorRetrieval()));
1240 auto job = new CollectionFetchJob(Collection(collectionId), recursive ? CollectionFetchJob::Recursive : CollectionFetchJob::Base);
1261 qCWarning(AKONADIAGENTBASE_LOG) << "Failed to fetch collection for collection sync: " << job->errorString();
1347void ResourceBase::itemsRetrievedIncremental(const Item::List &changedItems, const Item::List &removedItems)
1364 scheduler->currentTask().sendDBusReplies((job->error() && job->error() != Job::UserCanceled) ? job->errorString() : QString());
1411void ResourceBase::scheduleCustomTask(QObject *receiver, const char *method, const QVariant &argument, SchedulePriority priority)
1452bool ResourceBase::retrieveItems(const Akonadi::Item::List &items, const QSet<QByteArray> &parts)
1514void ResourceBase::tagsRetrieved(const Tag::List &tags, const QHash<QString, Item::List> &tagMembers)
1517 Q_ASSERT_X(d->scheduler->currentTask().type == ResourceScheduler::SyncTags || d->scheduler->currentTask().type == ResourceScheduler::SyncAll
virtual int status() const
This method returns the current status code of the agent.
Definition agentbase.cpp:858
void setActivities(const QStringList &activities)
This method is used to set the activities of the agent.
Definition agentbase.cpp:1182
void setActivitiesEnabled(bool enabled)
This method is used to enabled the activities of the agent.
Definition agentbase.cpp:1210
void setAgentName(const QString &name)
This method is used to set the name of the agent.
Definition agentbase.cpp:1148
ChangeRecorder * changeRecorder() const
Returns the Akonadi::ChangeRecorder object used for monitoring.
Definition agentbase.cpp:1228
void abortRequested()
Emitted when another application has remotely asked the agent to abort its current operation.
bool activitiesEnabled() const
Returns the activities status of the agent.
Definition agentbase.cpp:1204
QString identifier() const
Returns the instance identifier of this agent.
Definition agentbase.cpp:1143
void agentNameChanged(const QString &name)
This signal is emitted whenever the name of the agent has changed.
void error(const QString &message)
This signal shall be used to report errors.
void replayNext()
Replay the next change notification and erase the previous one from the record.
Definition changerecorder.cpp:43
void nothingToReplay()
Emitted when replayNext() was called, but there was no valid change to replay.
Job that fetches collections from the Akonadi storage.
Definition collectionfetchjob.h:39
@ FirstLevel
Only list direct sub-collections of the base collection.
Definition collectionfetchjob.h:48
@ Sync
Only retrieve collections for synchronization, taking the local preference and enabled into account.
Definition collectionfetchscope.h:98
Job that modifies a collection in the Akonadi storage.
Definition collectionmodifyjob.h:62
bool hasAttribute(const QByteArray &name) const
Returns true if the collection has an attribute of the given type name, false otherwise.
Definition collection.cpp:161
static QString virtualMimeType()
Returns the mimetype used for virtual collections.
Definition collection.cpp:297
bool shouldList(ListPurpose purpose) const
Returns whether the collection should be listed or not for the specified purpose Takes enabled state ...
Definition collection.cpp:397
Attribute * attribute(const QByteArray &name)
Returns the attribute of the given type name if available, 0 otherwise.
Definition collection.cpp:176
Job that creates a new item in the Akonadi storage.
Definition itemcreatejob.h:61
Job that modifies an existing item in the Akonadi storage.
Definition itemmodifyjob.h:82
void readyForNextBatch(int remainingBatchSize)
Signals the resource that new items can be delivered.
QSet< QByteArray > loadedPayloadParts() const
Returns the list of loaded payload parts.
Definition item.cpp:283
void collectionRemoved(const Akonadi::Collection &collection)
This signal is emitted if a monitored collection has been removed from the Akonadi storage.
void setScheduleAttributeSyncBeforeItemSync(bool)
Set to true to schedule an attribute sync before every item sync.
Definition resourcebase.cpp:965
void setItemTransactionMode(ItemSync::TransactionMode mode)
Set transaction mode for item sync'ing.
Definition resourcebase.cpp:1472
QString dumpNotificationListToString() const
Dump the contents of the current ChangeReplay.
Definition resourcebase.cpp:1490
void dumpMemoryInfo() const
Dumps memory usage information to stdout.
Definition resourcebase.cpp:1502
void invalidateCache(const Collection &collection)
Call this method to invalidate all cached content in collection.
Definition resourcebase.cpp:1130
void setActivitiesEnabled(bool enable)
This method enables or not activities support.
Definition resourcebase.cpp:519
void collectionAttributesRetrieved(const Collection &collection)
Call this method from retrieveCollectionAttributes() once the result is available.
Definition resourcebase.cpp:608
int itemSyncBatchSize() const
Returns the batch size used during the item sync.
Definition resourcebase.cpp:953
void setItemSyncBatchSize(int batchSize)
Set the batch size used during the item sync.
Definition resourcebase.cpp:959
void setDisableAutomaticItemDeliveryDone(bool disable)
Disables the automatic completion of the item sync, based on the number of delivered items.
Definition resourcebase.cpp:1302
void synchronizeCollection(qint64 id)
This method is called whenever the collection with the given id shall be synchronized.
Definition resourcebase.cpp:1232
void synchronized()
Emitted when a full synchronization has been completed.
virtual void retrieveCollections()=0
Retrieve the collection tree from the remote server and supply it via collectionsRetrieved() or colle...
QString dumpSchedulerToString() const
Dump the state of the scheduler.
Definition resourcebase.cpp:1496
QString dumpMemoryInfoToString() const
Returns a string with memory usage information.
Definition resourcebase.cpp:1508
SchedulePriority
Describes the scheduling priority of a task that has been queued for execution.
Definition resourcebase.h:718
void retrieveNextItemSyncBatch(int remainingBatchSize)
Emitted when the item synchronization processed the current batch and is ready for a new one.
void setKeepLocalCollectionChanges(const QSet< QByteArray > &parts)
Allows to keep locally changed collection parts during the collection sync.
Definition resourcebase.cpp:821
void attributesSynchronized(qlonglong collectionId)
Emitted when a collection attributes synchronization has been completed.
void itemsRetrievalDone()
Call this method to indicate you finished synchronizing the current collection.
Definition resourcebase.cpp:1109
Item::List currentItems() const
Returns the items that are currently retrieved.
Definition resourcebase.cpp:1154
void setTotalItems(int amount)
Call this method when you want to use the itemsRetrieved() method in streaming mode and indicate the ...
Definition resourcebase.cpp:1292
void setActivities(const QStringList &activities)
This method sets list of activities.
Definition resourcebase.cpp:509
void setAutomaticProgressReporting(bool enabled)
Enable or disable automatic progress reporting.
Definition resourcebase.cpp:1484
void collectionsRetrieved(const Collection::List &collections)
Call this to supply the full folder tree retrieved from the remote server.
Definition resourcebase.cpp:755
void deferTask()
Suspends the execution of the current task and tries again to execute it.
Definition resourcebase.cpp:1217
void setItemStreamingEnabled(bool enable)
Enable item streaming, which is disabled by default.
Definition resourcebase.cpp:1311
void collectionsRetrievalDone()
Call this method to indicate you finished synchronizing the collection tree.
Definition resourcebase.cpp:805
void clearCache()
Call this method to remove all items and collections of the resource from the server cache.
Definition resourcebase.cpp:1124
void scheduleCustomTask(QObject *receiver, const char *method, const QVariant &argument, SchedulePriority priority=Append)
Schedules a custom task in the internal scheduler.
Definition resourcebase.cpp:1411
void collectionsRetrievedIncremental(const Collection::List &changedCollections, const Collection::List &removedCollections)
Call this to supply incrementally retrieved collections from the remote server.
Definition resourcebase.cpp:772
void itemRetrieved(const Item &item)
Call this method from retrieveItem() once the result is available.
Definition resourcebase.cpp:575
virtual AKONADIAGENTBASE_DEPRECATED bool retrieveItem(const Akonadi::Item &item, const QSet< QByteArray > &parts)
Retrieve a single item from the backend.
Definition resourcebase.cpp:1434
void synchronize()
This method is called whenever the resource should start synchronize all data.
Definition resourcebase.cpp:494
void changeCommitted(const Item &item)
Resets the dirty flag of the given item and updates the remote id.
Definition resourcebase.cpp:678
void itemsRetrieved(const Item::List &items)
Call this method to supply the full collection listing from the remote server.
Definition resourcebase.cpp:1320
Collection currentCollection() const
Returns the collection that is currently synchronized.
Definition resourcebase.cpp:1136
void nameChanged(const QString &name)
This signal is emitted whenever the name of the resource has changed.
virtual void retrieveItems(const Akonadi::Collection &collection)=0
Retrieve all (new/changed) items in collection collection.
void cancelTask()
Stops the execution of the current task and continues with the next one.
Definition resourcebase.cpp:1173
void itemsRetrievedIncremental(const Item::List &changedItems, const Item::List &removedItems)
Call this method to supply incrementally retrieved items from the remote server.
Definition resourcebase.cpp:1347
void setItemMergingMode(ItemSync::MergeMode mode)
Set merge mode for item sync'ing.
Definition resourcebase.cpp:1478
void setHierarchicalRemoteIdentifiersEnabled(bool enable)
Indicate the use of hierarchical remote identifiers.
Definition resourcebase.cpp:1405
virtual void retrieveCollectionAttributes(const Akonadi::Collection &collection)
Retrieve the attributes of a single collection from the backend.
Definition resourcebase.cpp:1423
void collectionTreeSynchronized()
Emitted when a collection tree synchronization has been completed.
void setName(const QString &name)
This method is used to set the name of the resource.
Definition resourcebase.cpp:499
void setCollectionStreamingEnabled(bool enable)
Enable collection streaming, that is collections don't have to be delivered at once as result of a re...
Definition resourcebase.cpp:789
void changesCommitted(const Item::List &items)
Resets the dirty flag of all given items and updates remote ids.
Definition resourcebase.cpp:683
virtual void abortActivity()
Abort any activity in progress in the backend.
Definition resourcebase.cpp:1468
void synchronizeCollectionAttributes(qint64 id)
This method is called whenever the collection with the given id shall have its attributes synchronize...
Definition resourcebase.cpp:1271
AKONADIAGENTBASE_DEPRECATED Item currentItem() const
Returns the item that is currently retrieved.
Definition resourcebase.cpp:1145
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:343
static QString addNamespace(const QString &string)
Adds the multi-instance namespace to string if required (with '_' as separator).
Definition servermanager.cpp:367
void reconnected()
This signal is emitted whenever the session has been reconnected to the server (e....
An Attribute that stores the special collection type of a collection.
Definition specialcollectionattribute.h:29
QByteArray collectionType() const
Returns the special collections type of the collection.
Definition specialcollectionattribute.cpp:55
Base class for jobs that need to run a sequence of sub-jobs in a transaction.
Definition transactionsequence.h:55
virtual QString errorString() const
int error() const
void result(KJob *job)
void finished(KJob *job)
QString errorText() const
void percentChanged(KJob *job, unsigned long percent)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
Helper integration between Akonadi and Qt.
KIOCORE_EXPORT QStringList list(const QString &fileClass)
bool isEmpty() const const
QCommandLineOption addHelpOption()
bool addOption(const QCommandLineOption &option)
QCommandLineOption addVersionOption()
bool isSet(const QCommandLineOption &option) const const
void process(const QCoreApplication &app)
void setApplicationDescription(const QString &description)
QString value(const QCommandLineOption &option) const const
void setApplicationName(const QString &application)
void setApplicationVersion(const QString &version)
void exit(int returnCode)
bool installTranslator(QTranslator *translationFile)
QCoreApplication * instance()
QDateTime currentDateTimeUtc()
QDBusError lastError() const const
QDBusConnection sessionBus()
const QDBusMessage & message() const const
void sendErrorReply(QDBusError::ErrorType type, const QString &msg) const const
void setDelayedReply(bool enable) const const
Failed
QString message() const const
const_reference at(qsizetype i) const const
iterator begin()
iterator end()
iterator erase(const_iterator begin, const_iterator end)
T & first()
bool isEmpty() const const
qsizetype removeAll(const AT &t)
iterator insert(const Key &key, const T &value)
bool invokeMethod(QObject *context, Functor &&function, FunctorReturnType *ret)
QObject(QObject *parent)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QVariant property(const char *name) const const
bool contains(const QSet< T > &other) const const
bool isEmpty() const const
QString fromLocal8Bit(QByteArrayView str)
bool isEmpty() const const
CaseInsensitive
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QThread * currentThread()
singleShot
void timeout()
QVariant fromValue(T &&value)
T value() const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:56 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:56 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.