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"));
782void ResourceBase::collectionsRetrievedIncremental(const Collection::List &changedCollections, const Collection::List &removedCollections)
866 const auto lType = l.hasAttribute<SpecialCollectionAttribute>() ? l.attribute<SpecialCollectionAttribute>()->collectionType() : QByteArray();
867 const bool lInbox = (lType == "inbox") || (QStringView(l.remoteId()).mid(1).compare(QLatin1StringView("inbox"), Qt::CaseInsensitive) == 0);
870 const auto rType = r.hasAttribute<SpecialCollectionAttribute>() ? r.attribute<SpecialCollectionAttribute>()->collectionType() : QByteArray();
871 const bool rInbox = (rType == "inbox") || (QStringView(r.remoteId()).mid(1).compare(QLatin1StringView("inbox"), Qt::CaseInsensitive) == 0);
921 // This can happen due to FetchHelper::triggerOnDemandFetch() in the akonadi server (not an error).
929 Q_EMIT q->status(AgentBase::Running, i18nc("@info:status", "Syncing folder '%1'", currentCollection.displayName()));
932 qCDebug(AKONADIAGENTBASE_LOG) << "Preparing collection sync of collection" << currentCollection.id() << currentCollection.displayName();
935 connect(fetchJob, &KJob::result, this, &ResourceBasePrivate::slotItemRetrievalCollectionFetchDone);
948 qCWarning(AKONADIAGENTBASE_LOG) << "Failed to retrieve collection for sync: " << job->errorString();
955 qCWarning(AKONADIAGENTBASE_LOG) << "The fetch job returned empty collection set. This is unexpected.";
986 connect(fetchJob, &KJob::result, this, &ResourceBasePrivate::slotAttributeRetrievalCollectionFetchDone);
996 qCWarning(AKONADIAGENTBASE_LOG) << "Failed to retrieve collection for attribute sync: " << job->errorString();
1002 QMetaObject::invokeMethod(q, "retrieveCollectionAttributes", Q_ARG(Akonadi::Collection, fetchJob->collections().at(0)));
1018 fetch->fetchScope().setAncestorRetrieval(qMax(ItemFetchScope::Parent, q->changeRecorder()->itemFetchScope().ancestorRetrieval()));
1057 fetch->fetchScope().setAncestorRetrieval(qMax(ItemFetchScope::Parent, q->changeRecorder()->itemFetchScope().ancestorRetrieval()));
1250 auto job = new CollectionFetchJob(Collection(collectionId), recursive ? CollectionFetchJob::Recursive : CollectionFetchJob::Base);
1271 qCWarning(AKONADIAGENTBASE_LOG) << "Failed to fetch collection for collection sync: " << job->errorString();
1357void ResourceBase::itemsRetrievedIncremental(const Item::List &changedItems, const Item::List &removedItems)
1374 scheduler->currentTask().sendDBusReplies((job->error() && job->error() != Job::UserCanceled) ? job->errorString() : QString());
1421void ResourceBase::scheduleCustomTask(QObject *receiver, const char *method, const QVariant &argument, SchedulePriority priority)
1462bool ResourceBase::retrieveItems(const Akonadi::Item::List &items, const QSet<QByteArray> &parts)
1524void ResourceBase::tagsRetrieved(const Tag::List &tags, const QHash<QString, Item::List> &tagMembers)
1527 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:851
void setActivities(const QStringList &activities)
This method is used to set the activities of the agent.
Definition agentbase.cpp:1175
void setActivitiesEnabled(bool enabled)
This method is used to enabled the activities of the agent.
Definition agentbase.cpp:1203
void setAgentName(const QString &name)
This method is used to set the name of the agent.
Definition agentbase.cpp:1141
ChangeRecorder * changeRecorder() const
Returns the Akonadi::ChangeRecorder object used for monitoring.
Definition agentbase.cpp:1221
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:1197
QString identifier() const
Returns the instance identifier of this agent.
Definition agentbase.cpp:1136
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 deletes a collection in the Akonadi storage.
Definition collectiondeletejob.h:47
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
Syncs between items known to a client (usually a resource) and the Akonadi storage.
Definition itemsync.h:41
void readyForNextBatch(int remainingBatchSize)
Signals the resource that new items can be delivered.
void setDisableAutomaticDeliveryDone(bool disable)
Disables the automatic completion of the item sync, based on the number of delivered items.
Definition itemsync.cpp:238
void setMergeMode(MergeMode mergeMode)
Set what merge method should be used for next ItemSync run.
Definition itemsync.cpp:551
void setTransactionMode(TransactionMode mode)
Set the transaction mode to use for this sync.
Definition itemsync.cpp:527
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:975
void setItemTransactionMode(ItemSync::TransactionMode mode)
Set transaction mode for item sync'ing.
Definition resourcebase.cpp:1482
QString dumpNotificationListToString() const
Dump the contents of the current ChangeReplay.
Definition resourcebase.cpp:1500
void dumpMemoryInfo() const
Dumps memory usage information to stdout.
Definition resourcebase.cpp:1512
void invalidateCache(const Collection &collection)
Call this method to invalidate all cached content in collection.
Definition resourcebase.cpp:1140
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:618
int itemSyncBatchSize() const
Returns the batch size used during the item sync.
Definition resourcebase.cpp:963
void setItemSyncBatchSize(int batchSize)
Set the batch size used during the item sync.
Definition resourcebase.cpp:969
void setDisableAutomaticItemDeliveryDone(bool disable)
Disables the automatic completion of the item sync, based on the number of delivered items.
Definition resourcebase.cpp:1312
static int init(int argc, char **argv)
Use this method in the main function of your resource application to initialize your resource subclas...
Definition resourcebase.h:167
void synchronizeCollection(qint64 id)
This method is called whenever the collection with the given id shall be synchronized.
Definition resourcebase.cpp:1242
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:1506
QString dumpMemoryInfoToString() const
Returns a string with memory usage information.
Definition resourcebase.cpp:1518
SchedulePriority
Describes the scheduling priority of a task that has been queued for execution.
Definition resourcebase.h:766
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:831
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:1119
Item::List currentItems() const
Returns the items that are currently retrieved.
Definition resourcebase.cpp:1164
void setTotalItems(int amount)
Call this method when you want to use the itemsRetrieved() method in streaming mode and indicate the ...
Definition resourcebase.cpp:1302
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:1494
void collectionsRetrieved(const Collection::List &collections)
Call this to supply the full folder tree retrieved from the remote server.
Definition resourcebase.cpp:765
void deferTask()
Suspends the execution of the current task and tries again to execute it.
Definition resourcebase.cpp:1227
void setItemStreamingEnabled(bool enable)
Enable item streaming, which is disabled by default.
Definition resourcebase.cpp:1321
void collectionsRetrievalDone()
Call this method to indicate you finished synchronizing the collection tree.
Definition resourcebase.cpp:815
void clearCache()
Call this method to remove all items and collections of the resource from the server cache.
Definition resourcebase.cpp:1134
void scheduleCustomTask(QObject *receiver, const char *method, const QVariant &argument, SchedulePriority priority=Append)
Schedules a custom task in the internal scheduler.
Definition resourcebase.cpp:1421
void collectionsRetrievedIncremental(const Collection::List &changedCollections, const Collection::List &removedCollections)
Call this to supply incrementally retrieved collections from the remote server.
Definition resourcebase.cpp:782
void itemRetrieved(const Item &item)
Call this method from retrieveItem() once the result is available.
Definition resourcebase.cpp:585
virtual AKONADIAGENTBASE_DEPRECATED bool retrieveItem(const Akonadi::Item &item, const QSet< QByteArray > &parts)
Retrieve a single item from the backend.
Definition resourcebase.cpp:1444
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:688
void itemsRetrieved(const Item::List &items)
Call this method to supply the full collection listing from the remote server.
Definition resourcebase.cpp:1330
Collection currentCollection() const
Returns the collection that is currently synchronized.
Definition resourcebase.cpp:1146
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:1183
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:1357
void setItemMergingMode(ItemSync::MergeMode mode)
Set merge mode for item sync'ing.
Definition resourcebase.cpp:1488
void setHierarchicalRemoteIdentifiersEnabled(bool enable)
Indicate the use of hierarchical remote identifiers.
Definition resourcebase.cpp:1415
virtual void retrieveCollectionAttributes(const Akonadi::Collection &collection)
Retrieve the attributes of a single collection from the backend.
Definition resourcebase.cpp:1433
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:799
void changesCommitted(const Item::List &items)
Resets the dirty flag of all given items and updates remote ids.
Definition resourcebase.cpp:693
virtual void abortActivity()
Abort any activity in progress in the backend.
Definition resourcebase.cpp:1478
void synchronizeCollectionAttributes(qint64 id)
This method is called whenever the collection with the given id shall have its attributes synchronize...
Definition resourcebase.cpp:1281
AKONADIAGENTBASE_DEPRECATED Item currentItem() const
Returns the item that is currently retrieved.
Definition resourcebase.cpp:1155
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
static void setApplicationData(const KAboutData &aboutData)
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)
static void setApplicationDomain(const QByteArray &domain)
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.
KCRASH_EXPORT void initialize()
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)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QVariant property(const char *name) const const
bool setProperty(const char *name, QVariant &&value)
T * data() const const
bool contains(const QSet< T > &other) const const
bool isEmpty() const const
QString fromLocal8Bit(QByteArrayView str)
bool isEmpty() const const
QStringView mid(qsizetype start, qsizetype length) const const
int compare(QChar ch) const const
CaseInsensitive
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QThread * currentThread()
void setInterval(int msec)
bool isActive() const const
void setSingleShot(bool singleShot)
void start()
void stop()
void timeout()
QVariant fromValue(T &&value)
T value() const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.