Akonadi
resourcebase.cpp
83 // HACK: skip local changes of the EntityDisplayAttribute by default. Remove this for KDE5 and adjust resource implementations accordingly.
99 qCCritical(AKONADIAGENTBASE_LOG) << "Unable to register service" << serviceId << "at D-Bus:" << reason;
187 connect(mItemSyncer, &ItemSync::readyForNextBatch, q, &ResourceBase::retrieveNextItemSyncBatch);
211 // reimplementations from AgentbBasePrivate, containing sanity checks that only apply to resources
213 // TODO: we could possibly add recovery code for no-RID notifications by re-enquing those to the change recorder
214 // as the corresponding Add notifications, although that contains a risk of endless fail/retry loops
234 void itemsFlagsChanged(const Akonadi::Item::List &items, const QSet<QByteArray> &addedFlags, const QSet<QByteArray> &removedFlags) override
250 void itemsTagsChanged(const Akonadi::Item::List &items, const QSet<Akonadi::Tag> &addedTags, const QSet<Akonadi::Tag> &removedTags) override
267 void itemMoved(const Akonadi::Item &item, const Akonadi::Collection &source, const Akonadi::Collection &destination) override
276 void itemsMoved(const Akonadi::Item::List &items, const Akonadi::Collection &source, const Akonadi::Collection &destination) override
312 void collectionAdded(const Akonadi::Collection &collection, const Akonadi::Collection &parent) override
330 void collectionChanged(const Akonadi::Collection &collection, const QSet<QByteArray> &partIdentifiers) override
339 void collectionMoved(const Akonadi::Collection &collection, const Akonadi::Collection &source, const Akonadi::Collection &destination) override
347 // inter-resource moves, requires we know which resources the source and destination are in though
348 if (!source.resource().isEmpty() && !destination.resource().isEmpty() && source.resource() != destination.resource()) {
458 connect(d->mChangeRecorder, &ChangeRecorder::changesAdded, d->scheduler, &ResourceScheduler::scheduleChangeReplay);
463 connect(d->scheduler, &ResourceScheduler::executeFullSync, this, &ResourceBase::retrieveCollections);
464 connect(d->scheduler, &ResourceScheduler::executeCollectionTreeSync, this, &ResourceBase::retrieveCollections);
465 connect(d->scheduler, &ResourceScheduler::executeCollectionSync, d, &ResourceBasePrivate::slotSynchronizeCollection);
466 connect(d->scheduler, &ResourceScheduler::executeCollectionAttributesSync, d, &ResourceBasePrivate::slotSynchronizeCollectionAttributes);
467 connect(d->scheduler, &ResourceScheduler::executeTagSync, d, &ResourceBasePrivate::slotSynchronizeTags);
468 connect(d->scheduler, &ResourceScheduler::executeRelationSync, d, &ResourceBasePrivate::slotSynchronizeRelations);
469 connect(d->scheduler, &ResourceScheduler::executeItemFetch, d, &ResourceBasePrivate::slotPrepareItemRetrieval);
470 connect(d->scheduler, &ResourceScheduler::executeItemsFetch, d, &ResourceBasePrivate::slotPrepareItemsRetrieval);
471 connect(d->scheduler, &ResourceScheduler::executeResourceCollectionDeletion, d, &ResourceBasePrivate::slotDeleteResourceCollection);
472 connect(d->scheduler, &ResourceScheduler::executeCacheInvalidation, d, &ResourceBasePrivate::slotInvalidateCache);
473 connect(d->scheduler, &ResourceScheduler::status, this, qOverload<int, const QString &>(&ResourceBase::status));
474 connect(d->scheduler, &ResourceScheduler::executeChangeReplay, d->mChangeRecorder, &ChangeRecorder::replayNext);
475 connect(d->scheduler, &ResourceScheduler::executeRecursiveMoveReplay, d, &ResourceBasePrivate::slotRecursiveMoveReplay);
477 connect(d->scheduler, &ResourceScheduler::collectionTreeSyncComplete, this, &ResourceBase::collectionTreeSynchronized);
478 connect(d->mChangeRecorder, &ChangeRecorder::nothingToReplay, d->scheduler, &ResourceScheduler::taskDone);
479 connect(d->mChangeRecorder, &Monitor::collectionRemoved, d->scheduler, &ResourceScheduler::collectionRemoved);
482 connect(this, &ResourceBase::collectionTreeSynchronized, d->scheduler, &ResourceScheduler::taskDone);
484 connect(&d->mProgressEmissionCompressor, &QTimer::timeout, d, &ResourceBasePrivate::slotDelayedEmitProgress);
493 connect(d->mChangeRecorder->session(), &Session::reconnected, d, &ResourceBasePrivate::slotSessionReconnected);
517 QCommandLineOption identifierOption(QStringLiteral("identifier"), i18nc("@label command line option", "Resource identifier"), QStringLiteral("argument"));
725 void ResourceBase::requestItemDelivery(const QVector<qint64> &uids, const QByteArrayList &parts)
749 Q_ASSERT_X(d->scheduler->currentTask().type == ResourceScheduler::SyncCollectionTree || d->scheduler->currentTask().type == ResourceScheduler::SyncAll,
763 void ResourceBase::collectionsRetrievedIncremental(const Collection::List &changedCollections, const Collection::List &removedCollections)
766 Q_ASSERT_X(d->scheduler->currentTask().type == ResourceScheduler::SyncCollectionTree || d->scheduler->currentTask().type == ResourceScheduler::SyncAll,
783 Q_ASSERT_X(d->scheduler->currentTask().type == ResourceScheduler::SyncCollectionTree || d->scheduler->currentTask().type == ResourceScheduler::SyncAll,
799 Q_ASSERT_X(d->scheduler->currentTask().type == ResourceScheduler::SyncCollectionTree || d->scheduler->currentTask().type == ResourceScheduler::SyncAll,
847 const auto lType = l.hasAttribute<SpecialCollectionAttribute>() ? l.attribute<SpecialCollectionAttribute>()->collectionType() : QByteArray();
849 const bool lInbox = (lType == "inbox") || (l.remoteId().midRef(1).compare(QLatin1String("inbox"), Qt::CaseInsensitive) == 0);
851 const bool lInbox = (lType == "inbox") || (QStringView(l.remoteId()).mid(1).compare(QLatin1String("inbox"), Qt::CaseInsensitive) == 0);
855 const auto rType = r.hasAttribute<SpecialCollectionAttribute>() ? r.attribute<SpecialCollectionAttribute>()->collectionType() : QByteArray();
857 const bool rInbox = (rType == "inbox") || (r.remoteId().midRef(1).compare(QLatin1String("inbox"), Qt::CaseInsensitive) == 0);
859 const bool rInbox = (rType == "inbox") || (QStringView(r.remoteId()).mid(1).compare(QLatin1String("inbox"), Qt::CaseInsensitive) == 0);
910 // This can happen due to FetchHelper::triggerOnDemandFetch() in the akonadi server (not an error).
918 Q_EMIT q->status(AgentBase::Running, i18nc("@info:status", "Syncing folder '%1'", currentCollection.displayName()));
921 qCDebug(AKONADIAGENTBASE_LOG) << "Preparing collection sync of collection" << currentCollection.id() << currentCollection.displayName();
924 connect(fetchJob, &KJob::result, this, &ResourceBasePrivate::slotItemRetrievalCollectionFetchDone);
937 qCWarning(AKONADIAGENTBASE_LOG) << "Failed to retrieve collection for sync: " << job->errorString();
944 qCWarning(AKONADIAGENTBASE_LOG) << "The fetch job returned empty collection set. This is unexpected.";
974 connect(fetchJob, &KJob::result, this, &ResourceBasePrivate::slotAttributeRetrievalCollectionFetchDone);
984 qCWarning(AKONADIAGENTBASE_LOG) << "Failed to retrieve collection for attribute sync: " << job->errorString();
990 QMetaObject::invokeMethod(q, "retrieveCollectionAttributes", Q_ARG(Akonadi::Collection, fetchJob->collections().at(0)));
1014 fetch->fetchScope().setAncestorRetrieval(qMax(ItemFetchScope::Parent, q->changeRecorder()->itemFetchScope().ancestorRetrieval()));
1053 fetch->fetchScope().setAncestorRetrieval(qMax(ItemFetchScope::Parent, q->changeRecorder()->itemFetchScope().ancestorRetrieval()));
1233 // We'd need to d->mItemSyncer->rollback() but also to NOT call taskDone in slotItemSyncDone() here...
1251 auto job = new CollectionFetchJob(Collection(collectionId), recursive ? CollectionFetchJob::Recursive : CollectionFetchJob::Base);
1272 qCWarning(AKONADIAGENTBASE_LOG) << "Failed to fetch collection for collection sync: " << job->errorString();
1358 void ResourceBase::itemsRetrievedIncremental(const Item::List &changedItems, const Item::List &removedItems)
1375 scheduler->currentTask().sendDBusReplies((job->error() && job->error() != Job::UserCanceled) ? job->errorString() : QString());
1422 void ResourceBase::scheduleCustomTask(QObject *receiver, const char *method, const QVariant &argument, SchedulePriority priority)
1462 "You must implement either retrieveItem() or retrieveItems(Akonadi::Item::List, QSet<QByteArray>) overload "
1469 bool ResourceBase::retrieveItems(const Akonadi::Item::List &items, const QSet<QByteArray> &parts)
1531 void ResourceBase::tagsRetrieved(const Tag::List &tags, const QHash<QString, Item::List> &tagMembers)
1534 Q_ASSERT_X(d->scheduler->currentTask().type == ResourceScheduler::SyncTags || d->scheduler->currentTask().type == ResourceScheduler::SyncAll
int itemSyncBatchSize() const
Returns the batch size used during the item sync.
Definition: resourcebase.cpp:951
void scheduleCustomTask(QObject *receiver, const char *method, const QVariant &argument, SchedulePriority priority=Append)
Schedules a custom task in the internal scheduler.
Definition: resourcebase.cpp:1422
T & first()
virtual void abortActivity()
Abort any activity in progress in the backend.
Definition: resourcebase.cpp:1485
void invalidateCache(const Collection &collection)
Call this method to invalidate all cached content in collection.
Definition: resourcebase.cpp:1136
@ Sync
Only retrieve collections for synchronization, taking the local preference and enabled into account.
Definition: collectionfetchscope.h:98
bool isEmpty() const const
virtual void retrieveItems(const Akonadi::Collection &collection)=0
Retrieve all (new/changed) items in collection collection.
void collectionRemoved(const Akonadi::Collection &collection)
This signal is emitted if a monitored collection has been removed from the Akonadi storage.
virtual void retrieveCollectionAttributes(const Akonadi::Collection &collection)
Retrieve the attributes of a single collection from the backend.
Definition: resourcebase.cpp:1434
virtual void retrieveCollections()=0
Retrieve the collection tree from the remote server and supply it via collectionsRetrieved() or colle...
void attributesSynchronized(qlonglong collectionId)
Emitted when a collection attributes synchronization has been completed.
Job that modifies a collection in the Akonadi storage.
Definition: collectionmodifyjob.h:67
void finished(KJob *job)
CaseInsensitive
QVariant fromValue(const T &value)
void setAutomaticProgressReporting(bool enabled)
Enable or disable automatic progress reporting.
Definition: resourcebase.cpp:1501
virtual AKONADIAGENTBASE_DEPRECATED bool retrieveItem(const Akonadi::Item &item, const QSet< QByteArray > &parts)
Retrieve a single item from the backend.
Definition: resourcebase.cpp:1451
Q_EMITQ_EMIT
void result(KJob *job)
void setApplicationDescription(const QString &description)
void reconnected()
This signal is emitted whenever the session has been reconnected to the server (e....
void percentChanged(KJob *job, unsigned long percent)
int removeAll(const T &value)
void collectionsRetrievalDone()
Call this method to indicate you finished synchronizing the collection tree.
Definition: resourcebase.cpp:796
Job that creates a new item in the Akonadi storage.
Definition: itemcreatejob.h:60
QVector::iterator begin()
void synchronizeCollectionAttributes(qint64 id)
This method is called whenever the collection with the given id shall have its attributes synchronize...
Definition: resourcebase.cpp:1282
singleShot
QString message() const const
QStringRef midRef(int position, int n) const const
static void setApplicationData(const KAboutData &aboutData)
T value() const const
Item::List currentItems() const
Returns the items that are currently retrieved.
Definition: resourcebase.cpp:1160
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:780
void itemsRetrieved(const Item::List &items)
Call this method to supply the full collection listing from the remote server.
Definition: resourcebase.cpp:1331
void setDelayedReply(bool enable) const const
void dumpMemoryInfo() const
Dumps memory usage information to stdout.
Definition: resourcebase.cpp:1519
void setApplicationVersion(const QString &version)
void setItemMergingMode(ItemSync::MergeMode mode)
Set merge mode for item sync'ing.
Definition: resourcebase.cpp:1495
void synchronized()
Emitted when a full synchronization has been completed.
void setKeepLocalCollectionChanges(const QSet< QByteArray > &parts)
Allows to keep locally changed collection parts during the collection sync.
Definition: resourcebase.cpp:812
void exit(int returnCode)
void nameChanged(const QString &name)
This signal is emitted whenever the name of the resource has changed.
void setTotalItems(int amount)
Call this method when you want to use the itemsRetrieved() method in streaming mode and indicate the ...
Definition: resourcebase.cpp:1303
KIOFILEWIDGETS_EXPORT QStringList list(const QString &fileClass)
QByteArray collectionType() const
Returns the special collections type of the collection.
Definition: specialcollectionattribute.cpp:55
int compare(const QString &other, Qt::CaseSensitivity cs) const const
T & first()
void replayNext()
Replay the next change notification and erase the previous one from the record.
Definition: changerecorder.cpp:43
void readyForNextBatch(int remainingBatchSize)
Signals the resource that new items can be delivered.
void changesCommitted(const Item::List &items)
Resets the dirty flag of all given items and updates remote ids.
Definition: resourcebase.cpp:674
void retrieveNextItemSyncBatch(int remainingBatchSize)
Emitted when the item synchronization processed the current batch and is ready for a new one.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void itemsRetrievalDone()
Call this method to indicate you finished synchronizing the current collection.
Definition: resourcebase.cpp:1115
QDBusError lastError() const const
void agentNameChanged(const QString &name)
This signal is emitted whenever the name of the agent has changed.
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:351
QString dumpMemoryInfoToString() const
Returns a string with memory usage information.
Definition: resourcebase.cpp:1525
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
virtual void retrieveRelations()
Retrieve all relations from the backend.
Definition: resourcebase.cpp:1445
Job that fetches collections from the Akonadi storage.
Definition: collectionfetchjob.h:39
void synchronize()
This method is called whenever the resource should start synchronize all data.
Definition: resourcebase.cpp:498
Attribute * attribute(const QByteArray &name)
Returns the attribute of the given type name if available, 0 otherwise.
Definition: collection.cpp:176
QMap::iterator insert(const Key &key, const T &value)
void deferTask()
Suspends the execution of the current task and tries again to execute it.
Definition: resourcebase.cpp:1228
Job that modifies an existing item in the Akonadi storage.
Definition: itemmodifyjob.h:81
QString i18n(const char *text, const TYPE &arg...)
QDBusConnection sessionBus()
QString fromLocal8Bit(const char *str, int size)
SchedulePriority
Describes the scheduling priority of a task that has been queued for execution.
Definition: resourcebase.h:757
void setScheduleAttributeSyncBeforeItemSync(bool)
Set to true to schedule an attribute sync before every item sync.
Definition: resourcebase.cpp:963
void clearCache()
Call this method to remove all items and collections of the resource from the server cache.
Definition: resourcebase.cpp:1130
void collectionsRetrieved(const Collection::List &collections)
Call this to supply the full folder tree retrieved from the remote server.
Definition: resourcebase.cpp:746
bool installTranslator(QTranslator *translationFile)
void collectionAttributesRetrieved(const Collection &collection)
Call this method from retrieveCollectionAttributes() once the result is available.
Definition: resourcebase.cpp:599
void process(const QStringList &arguments)
QCommandLineOption addVersionOption()
const T & at(int i) const const
void timeout()
bool isEmpty() const const
static QString addNamespace(const QString &string)
Adds the multi-instance namespace to string if required (with '_' as separator).
Definition: servermanager.cpp:375
QString dumpSchedulerToString() const
Dump the state of the scheduler.
Definition: resourcebase.cpp:1513
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
QString errorText() const
QCoreApplication * instance()
Collection parentCollection() const
Returns the parent collection of this object.
Definition: item.cpp:153
virtual int status() const
This method returns the current status code of the agent.
Definition: agentbase.cpp:946
QThread * currentThread()
QString value(const QString &optionName) const const
static QString virtualMimeType()
Returns the mimetype used for virtual collections.
Definition: collection.cpp:297
void setAgentName(const QString &name)
This method is used to set the name of the agent.
Definition: agentbase.cpp:1249
bool isEmpty() const const
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:1358
@ FirstLevel
Only list direct sub-collections of the base collection.
Definition: collectionfetchjob.h:49
AKONADIAGENTBASE_DEPRECATED Item currentItem() const
Returns the item that is currently retrieved.
Definition: resourcebase.cpp:1151
An Attribute that stores the special collection type of a collection.
Definition: specialcollectionattribute.h:28
void collectionTreeSynchronized()
Emitted when a collection tree synchronization has been completed.
Syncs between items known to a client (usually a resource) and the Akonadi storage.
Definition: itemsync.h:38
void setApplicationName(const QString &application)
bool isSet(const QString &name) const const
const QDBusMessage & message() const const
bool contains(const T &value) const const
void synchronizeCollection(qint64 id)
This method is called whenever the collection with the given id shall be synchronized.
Definition: resourcebase.cpp:1243
Base class for jobs that need to run a sequence of sub-jobs in a transaction.
Definition: transactionsequence.h:54
QVector::iterator end()
void nothingToReplay()
Emitted when replayNext() was called, but there was no valid change to replay.
void setItemTransactionMode(ItemSync::TransactionMode mode)
Set transaction mode for item sync'ing.
Definition: resourcebase.cpp:1489
void changeCommitted(const Item &item)
Resets the dirty flag of the given item and updates the remote id.
Definition: resourcebase.cpp:669
void error(const QString &message)
This signal shall be used to report errors.
bool isEmpty() const const
Job that deletes a collection in the Akonadi storage.
Definition: collectiondeletejob.h:50
QString identifier() const
Returns the instance identifier of this agent.
Definition: agentbase.cpp:1244
void sendErrorReply(const QString &name, const QString &msg) const const
void setHierarchicalRemoteIdentifiersEnabled(bool enable)
Indicate the use of hierarchical remote identifiers.
Definition: resourcebase.cpp:1416
ChangeRecorder * changeRecorder() const
Returns the Akonadi::ChangeRecorder object used for monitoring.
Definition: agentbase.cpp:1289
bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, QGenericReturnArgument ret, QGenericArgument val0, QGenericArgument val1, QGenericArgument val2, QGenericArgument val3, QGenericArgument val4, QGenericArgument val5, QGenericArgument val6, QGenericArgument val7, QGenericArgument val8, QGenericArgument val9)
QVector::iterator erase(QVector::iterator begin, QVector::iterator end)
void itemRetrieved(const Item &item)
Call this method from retrieveItem() once the result is available.
Definition: resourcebase.cpp:566
int compare(QStringView str, Qt::CaseSensitivity cs) const const
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void cancelTask()
Stops the execution of the current task and continues with the next one.
Definition: resourcebase.cpp:1184
QList::iterator begin()
void setItemSyncBatchSize(int batchSize)
Set the batch size used during the item sync.
Definition: resourcebase.cpp:957
bool addOption(const QCommandLineOption &option)
void setItemStreamingEnabled(bool enable)
Enable item streaming, which is disabled by default.
Definition: resourcebase.cpp:1322
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:166
void abortRequested()
Emitted when another application has remotely asked the agent to abort its current operation.
virtual QString errorString() const
int error() const
QSet< QByteArray > loadedPayloadParts() const
Returns the list of loaded payload parts.
Definition: item.cpp:288
QString dumpNotificationListToString() const
Dump the contents of the current ChangeReplay.
Definition: resourcebase.cpp:1507
Collection currentCollection() const
Returns the collection that is currently synchronized.
Definition: resourcebase.cpp:1142
QList::iterator end()
static void setApplicationDomain(const char *domain)
Failed
void setDisableAutomaticItemDeliveryDone(bool disable)
Disables the automatic completion of the item sync, based on the number of delivered items.
Definition: resourcebase.cpp:1313
QCommandLineOption addHelpOption()
void collectionsRetrievedIncremental(const Collection::List &changedCollections, const Collection::List &removedCollections)
Call this to supply incrementally retrieved collections from the remote server.
Definition: resourcebase.cpp:763
bool isEmpty() const const
Q_D(Todo)
void setName(const QString &name)
This method is used to set the name of the resource.
Definition: resourcebase.cpp:503
QVariant property(const char *name) const const
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Jun 27 2022 04:01:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Jun 27 2022 04:01:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.