File indexing completed on 2024-06-16 04:50:15

0001 /*
0002     SPDX-FileCopyrightText: 2006-2007 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "akonadicore_export.h"
0010 #include "collection.h"
0011 #include "item.h"
0012 #include "relation.h"
0013 #include "tag.h"
0014 
0015 #include <QObject>
0016 
0017 #include <memory>
0018 
0019 namespace Akonadi
0020 {
0021 class CollectionFetchScope;
0022 class CollectionStatistics;
0023 class Item;
0024 class ItemFetchScope;
0025 class MonitorPrivate;
0026 class Session;
0027 class TagFetchScope;
0028 class NotificationSubscriber;
0029 class ChangeNotification;
0030 
0031 namespace Protocol
0032 {
0033 class Command;
0034 }
0035 
0036 /**
0037  * @short Monitors an item or collection for changes.
0038  *
0039  * The Monitor emits signals if some of these objects are changed or
0040  * removed or new ones are added to the Akonadi storage.
0041  *
0042  * There are various ways to filter these notifications. There are three types of filter
0043  * evaluation:
0044  * - (-) removal-only filter, ie. if the filter matches the notification is dropped,
0045  *   if not filter evaluation continues with the next one
0046  * - (+) pass-exit filter, ie. if the filter matches the notification is delivered,
0047  *   if not evaluation is continued
0048  * - (f) final filter, ie. evaluation ends here if the corresponding filter criteria is set,
0049  *   the notification is delivered depending on the result, evaluation is only continued
0050  *   if no filter criteria is defined
0051  *
0052  * The following filter are available, listed in evaluation order:
0053  * (1) ignored sessions (-)
0054  * (2) monitor everything (+)
0055  * (3a) resource and mimetype filters (f) (items only)
0056  * (3b) resource filters (f) (collections only)
0057  * (4) item is monitored (+)
0058  * (5) collection is monitored (+)
0059  *
0060  * Optionally, the changed objects can be fetched automatically from the server.
0061  * To enable this, see itemFetchScope() and collectionFetchScope().
0062  *
0063  * Note that as a consequence of rule 3a, it is not possible to monitor (more than zero resources
0064  * OR more than zero mimetypes) AND more than zero collections.
0065  *
0066  * @todo Distinguish between monitoring collection properties and collection content.
0067  * @todo Special case for collection content counts changed
0068  *
0069  * @author Volker Krause <vkrause@kde.org>
0070  */
0071 class AKONADICORE_EXPORT Monitor : public QObject
0072 {
0073     Q_OBJECT
0074 
0075 public:
0076     enum Type {
0077         /**
0078          * @internal This must be kept in sync with Akonadi::NotificationMessageV2::Type
0079          */
0080         Collections = 1,
0081         Items,
0082         Tags,
0083         Relations,
0084         /**
0085          * Listen to subscription changes of other Monitors connected to Akonadi.
0086          * This is only for debugging purposes and should not be used in real
0087          * applications.
0088          * @since 5.4
0089          */
0090         Subscribers,
0091         /**
0092          * Listens to all notifications being emitted by the server and provides
0093          * additional information about them. This is only for debugging purposes
0094          * and should not be used in real applications.
0095          *
0096          * @note Enabling monitoring this type has performance impact on the
0097          * Akonadi Server.
0098          *
0099          * @since 5.4
0100          */
0101         Notifications
0102     };
0103 
0104     /**
0105      * Creates a new monitor.
0106      *
0107      * @param parent The parent object.
0108      */
0109     explicit Monitor(QObject *parent = nullptr);
0110 
0111     /**
0112      * Destroys the monitor.
0113      */
0114     ~Monitor() override;
0115 
0116     /**
0117      * Sets whether the specified collection shall be monitored for changes. If
0118      * monitoring is turned on for the collection, all notifications for items
0119      * in that collection will be emitted, and its child collections will also
0120      * be monitored. Note that move notifications will be emitted if either one
0121      * of the collections involved is being monitored.
0122      *
0123      * Note that if a session is being ignored, this takes precedence over
0124      * setCollectionMonitored() on that session.
0125      *
0126      * @param collection The collection to monitor.
0127      *                   If this collection is Collection::root(), all collections
0128      *                   in the Akonadi storage will be monitored.
0129      * @param monitored Whether to monitor the collection.
0130      */
0131     void setCollectionMonitored(const Collection &collection, bool monitored = true);
0132 
0133     /**
0134      * Sets whether the specified item shall be monitored for changes.
0135      *
0136      * Note that if a session is being ignored, this takes precedence over
0137      * setItemMonitored() on that session.
0138      *
0139      * @param item The item to monitor.
0140      * @param monitored Whether to monitor the item.
0141      */
0142     void setItemMonitored(const Item &item, bool monitored = true);
0143 
0144     /**
0145      * Sets whether the specified resource shall be monitored for changes. If
0146      * monitoring is turned on for the resource, all notifications for
0147      * collections and items in that resource will be emitted.
0148      *
0149      * Note that if a session is being ignored, this takes precedence over
0150      * setResourceMonitored() on that session.
0151      *
0152      * @param resource The resource identifier.
0153      * @param monitored Whether to monitor the resource.
0154      */
0155     void setResourceMonitored(const QByteArray &resource, bool monitored = true);
0156 
0157     /**
0158      * Sets whether items of the specified mime type shall be monitored for changes.
0159      * If monitoring is turned on for the mime type, all notifications for items
0160      * matching that mime type will be emitted, but notifications for collections
0161      * matching that mime type will only be emitted if this is otherwise specified,
0162      * for example by setCollectionMonitored().
0163      *
0164      * Note that if a session is being ignored, this takes precedence over
0165      * setMimeTypeMonitored() on that session.
0166      *
0167      * @param mimetype The mime type to monitor.
0168      * @param monitored Whether to monitor the mime type.
0169      */
0170     void setMimeTypeMonitored(const QString &mimetype, bool monitored = true);
0171 
0172     /**
0173      * Sets whether the specified tag shall be monitored for changes.
0174      *
0175      * Same rules as for item monitoring apply.
0176      *
0177      * @param tag Tag to monitor.
0178      * @param monitored Whether to monitor the tag.
0179      * @since 4.13
0180      */
0181     void setTagMonitored(const Tag &tag, bool monitored = true);
0182 
0183     /**
0184      * Sets whether given type (Collection, Item, Tag should be monitored).
0185      *
0186      * By default all types are monitored, but once you change one, you have
0187      * to explicitly enable all other types you want to monitor.
0188      *
0189      * @param type Type to monitor.
0190      * @param monitored Whether to monitor the type
0191      * @since 4.13
0192      */
0193     void setTypeMonitored(Type type, bool monitored = true);
0194 
0195     /**
0196      * Sets whether all items shall be monitored.
0197      * @param monitored sets all items as monitored if set as @c true
0198      * Note that if a session is being ignored, this takes precedence over
0199      * setAllMonitored() on that session.
0200      */
0201     void setAllMonitored(bool monitored = true);
0202 
0203     void setExclusive(bool exclusive = true);
0204     [[nodiscard]] bool exclusive() const;
0205 
0206     /**
0207      * Ignores all change notifications caused by the given session. This
0208      * overrides all other settings on this session.
0209      *
0210      * @param session The session you want to ignore.
0211      */
0212     void ignoreSession(Session *session);
0213 
0214     /**
0215      * Enables automatic fetching of changed collections from the Akonadi storage.
0216      *
0217      * @param enable @c true enables automatic fetching, @c false disables automatic fetching.
0218      */
0219     void fetchCollection(bool enable);
0220 
0221     /**
0222      * Enables automatic fetching of changed collection statistics information from
0223      * the Akonadi storage.
0224      *
0225      * @param enable @c true to enables automatic fetching, @c false disables automatic fetching.
0226      */
0227     void fetchCollectionStatistics(bool enable);
0228 
0229     /**
0230      * Sets the item fetch scope.
0231      *
0232      * Controls how much of an item's data is fetched from the server, e.g.
0233      * whether to fetch the full item payload or only meta data.
0234      *
0235      * @param fetchScope The new scope for item fetch operations.
0236      *
0237      * @see itemFetchScope()
0238      */
0239     void setItemFetchScope(const ItemFetchScope &fetchScope);
0240 
0241     /**
0242      * Instructs the monitor to fetch only those parts that were changed and
0243      * were requested in the fetch scope.
0244      *
0245      * This is taken in account only for item modifications.
0246      * Example usage:
0247      * @code
0248      *   monitor->itemFetchScope().fetchFullPayload( true );
0249      *   monitor->fetchChangedOnly(true);
0250      * @endcode
0251      *
0252      * In the example if an item was changed, but its payload was not, the full
0253      * payload will not be retrieved.
0254      * If the item's payload was changed, the monitor retrieves the changed
0255      * payload as well.
0256      *
0257      * The default is to fetch everything requested.
0258      *
0259      * @since 4.8
0260      *
0261      * @param enable @c true to enable the feature, @c false means everything
0262      * that was requested will be fetched.
0263      */
0264     void fetchChangedOnly(bool enable);
0265 
0266     /**
0267      * Returns the item fetch scope.
0268      *
0269      * Since this returns a reference it can be used to conveniently modify the
0270      * current scope in-place, i.e. by calling a method on the returned reference
0271      * without storing it in a local variable. See the ItemFetchScope documentation
0272      * for an example.
0273      *
0274      * @return a reference to the current item fetch scope
0275      *
0276      * @see setItemFetchScope() for replacing the current item fetch scope
0277      */
0278     ItemFetchScope &itemFetchScope();
0279 
0280     /**
0281      * Sets the collection fetch scope.
0282      *
0283      * Controls which collections are monitored and how much of a collection's data
0284      * is fetched from the server.
0285      *
0286      * @param fetchScope The new scope for collection fetch operations.
0287      *
0288      * @see collectionFetchScope()
0289      * @since 4.4
0290      */
0291     void setCollectionFetchScope(const CollectionFetchScope &fetchScope);
0292 
0293     /**
0294      * Returns the collection fetch scope.
0295      *
0296      * Since this returns a reference it can be used to conveniently modify the
0297      * current scope in-place, i.e. by calling a method on the returned reference
0298      * without storing it in a local variable. See the CollectionFetchScope documentation
0299      * for an example.
0300      *
0301      * @return a reference to the current collection fetch scope
0302      *
0303      * @see setCollectionFetchScope() for replacing the current collection fetch scope
0304      * @since 4.4
0305      */
0306     CollectionFetchScope &collectionFetchScope();
0307 
0308     /**
0309      * Sets the tag fetch scope.
0310      *
0311      * Controls how much of an tag's data is fetched from the server.
0312      *
0313      * @param fetchScope The new scope for tag fetch operations.
0314      *
0315      * @see tagFetchScope()
0316      */
0317     void setTagFetchScope(const TagFetchScope &fetchScope);
0318 
0319     /**
0320      * Returns the tag fetch scope.
0321      *
0322      * Since this returns a reference it can be used to conveniently modify the
0323      * current scope in-place, i.e. by calling a method on the returned reference
0324      * without storing it in a local variable.
0325      *
0326      * @return a reference to the current tag fetch scope
0327      *
0328      * @see setTagFetchScope() for replacing the current tag fetch scope
0329      */
0330     TagFetchScope &tagFetchScope();
0331 
0332     /**
0333      * Returns the list of collections being monitored.
0334      *
0335      * @since 4.3
0336      */
0337     [[nodiscard]] Collection::List collectionsMonitored() const;
0338 
0339     /**
0340      * Returns the set of items being monitored.
0341      *
0342      * Faster version (at least on 32-bit systems) of itemsMonitored().
0343      *
0344      * @since 4.6
0345      */
0346     [[nodiscard]] QList<Item::Id> itemsMonitoredEx() const;
0347 
0348     /**
0349      * Returns the number of items being monitored.
0350      * Optimization.
0351      * @since 4.14.3
0352      */
0353     [[nodiscard]] int numItemsMonitored() const;
0354 
0355     /**
0356      * Returns the set of mimetypes being monitored.
0357      *
0358      * @since 4.3
0359      */
0360     [[nodiscard]] QStringList mimeTypesMonitored() const;
0361 
0362     /**
0363      * Returns the number of mimetypes being monitored.
0364      * Optimization.
0365      * @since 4.14.3
0366      */
0367     [[nodiscard]] int numMimeTypesMonitored() const;
0368 
0369     /**
0370      * Returns the set of tags being monitored.
0371      *
0372      * @since 4.13
0373      */
0374     [[nodiscard]] QList<Tag::Id> tagsMonitored() const;
0375 
0376     /**
0377      * Returns the set of types being monitored.
0378      *
0379      * @since 4.13
0380      */
0381     [[nodiscard]] QList<Type> typesMonitored() const;
0382 
0383     /**
0384      * Returns the set of identifiers for resources being monitored.
0385      *
0386      * @since 4.3
0387      */
0388     [[nodiscard]] QList<QByteArray> resourcesMonitored() const;
0389 
0390     /**
0391      * Returns the number of resources being monitored.
0392      * Optimization.
0393      * @since 4.14.3
0394      */
0395     [[nodiscard]] int numResourcesMonitored() const;
0396 
0397     /**
0398      * Returns true if everything is being monitored.
0399      *
0400      * @since 4.3
0401      */
0402     [[nodiscard]] bool isAllMonitored() const;
0403 
0404     /**
0405      * Sets the session used by the Monitor to communicate with the %Akonadi server.
0406      * If not set, the Akonadi::Session::defaultSession is used.
0407      * @param session the session to be set
0408      * @since 4.4
0409      */
0410     void setSession(Akonadi::Session *session);
0411 
0412     /**
0413      * Returns the Session used by the monitor to communicate with Akonadi.
0414      *
0415      * @since 4.4
0416      */
0417     [[nodiscard]] Session *session() const;
0418 
0419     /**
0420      * Allows to enable/disable collection move translation. If enabled (the default), move
0421      * notifications are automatically translated into add/remove notifications if the source/destination
0422      * is outside of the monitored collection hierarchy.
0423      * @param enabled enables collection move translation if set as @c true
0424      * @since 4.9
0425      */
0426     void setCollectionMoveTranslationEnabled(bool enabled);
0427 
0428 Q_SIGNALS:
0429     /**
0430      * This signal is emitted if a monitored item has changed, e.g. item parts have been modified.
0431      *
0432      * @param item The changed item.
0433      * @param partIdentifiers The identifiers of the item parts that has been changed.
0434      */
0435     void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers);
0436 
0437     /**
0438      * This signal is emitted if flags of monitored items have changed.
0439      *
0440      * @param items Items that were changed
0441      * @param addedFlags Flags that have been added to each item in @p items
0442      * @param removedFlags Flags that have been removed from each item in @p items
0443      * @since 4.11
0444      */
0445     void itemsFlagsChanged(const Akonadi::Item::List &items, const QSet<QByteArray> &addedFlags, const QSet<QByteArray> &removedFlags);
0446 
0447     /**
0448      * This signal is emitted if tags of monitored items have changed.
0449      *
0450      * @param items Items that were changed
0451      * @param addedTags Tags that have been added to each item in @p items.
0452      * @param removedTags Tags that have been removed from each item in @p items
0453      * @since 4.13
0454      */
0455     void itemsTagsChanged(const Akonadi::Item::List &items, const QSet<Akonadi::Tag> &addedTags, const QSet<Akonadi::Tag> &removedTags);
0456 
0457     /**
0458      * This signal is emitted if relations of monitored items have changed.
0459      *
0460      * @param items Items that were changed
0461      * @param addedRelations Relations that have been added to each item in @p items.
0462      * @param removedRelations Relations that have been removed from each item in @p items
0463      * @since 4.15
0464      */
0465     void
0466     itemsRelationsChanged(const Akonadi::Item::List &items, const Akonadi::Relation::List &addedRelations, const Akonadi::Relation::List &removedRelations);
0467 
0468     /**
0469      * This signal is emitted if a monitored item has been moved between two collections
0470      *
0471      * @param item The moved item.
0472      * @param collectionSource The collection the item has been moved from.
0473      * @param collectionDestination The collection the item has been moved to.
0474      */
0475     void itemMoved(const Akonadi::Item &item, const Akonadi::Collection &collectionSource, const Akonadi::Collection &collectionDestination);
0476 
0477     /**
0478      * This is signal is emitted when multiple monitored items have been moved between two collections
0479      *
0480      * @param items Moved items
0481      * @param collectionSource The collection the items have been moved from.
0482      * @param collectionDestination The collection the items have been moved to.
0483      *
0484      * @since 4.11
0485      */
0486     void itemsMoved(const Akonadi::Item::List &items, const Akonadi::Collection &collectionSource, const Akonadi::Collection &collectionDestination);
0487 
0488     /**
0489      * This signal is emitted if an item has been added to a monitored collection in the Akonadi storage.
0490      *
0491      * @param item The new item.
0492      * @param collection The collection the item has been added to.
0493      */
0494     void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection);
0495 
0496     /**
0497      * This signal is emitted if
0498      *   - a monitored item has been removed from the Akonadi storage
0499      * or
0500      *   - a item has been removed from a monitored collection.
0501      *
0502      * @param item The removed item.
0503      */
0504     void itemRemoved(const Akonadi::Item &item);
0505 
0506     /**
0507      * This signal is emitted if monitored items have been removed from Akonadi
0508      * storage of items have been removed from a monitored collection.
0509      *
0510      * @param items Removed items
0511      *
0512      * @since 4.11
0513      */
0514     void itemsRemoved(const Akonadi::Item::List &items);
0515 
0516     /**
0517      * This signal is emitted if a reference to an item is added to a virtual collection.
0518      * @param item The linked item.
0519      * @param collection The collection the item is linked to.
0520      *
0521      * @since 4.2
0522      */
0523     void itemLinked(const Akonadi::Item &item, const Akonadi::Collection &collection);
0524 
0525     /**
0526      * This signal is emitted if a reference to multiple items is added to a virtual collection
0527      *
0528      * @param items The linked items
0529      * @param collection The collections the items are linked to
0530      *
0531      * @since 4.11
0532      */
0533     void itemsLinked(const Akonadi::Item::List &items, const Akonadi::Collection &collection);
0534 
0535     /**
0536      * This signal is emitted if a reference to an item is removed from a virtual collection.
0537      * @param item The unlinked item.
0538      * @param collection The collection the item is unlinked from.
0539      *
0540      * @since 4.2
0541      */
0542     void itemUnlinked(const Akonadi::Item &item, const Akonadi::Collection &collection);
0543 
0544     /**
0545      * This signal is emitted if a reference to items is removed from a virtual collection
0546      *
0547      * @param items The unlinked items
0548      * @param collection The collections the items are unlinked from
0549      *
0550      * @since 4.11
0551      */
0552     void itemsUnlinked(const Akonadi::Item::List &items, const Akonadi::Collection &collection);
0553 
0554     /**
0555      * This signal is emitted if a new collection has been added to a monitored collection in the Akonadi storage.
0556      *
0557      * @param collection The new collection.
0558      * @param parent The parent collection.
0559      */
0560     void collectionAdded(const Akonadi::Collection &collection, const Akonadi::Collection &parent);
0561 
0562     /**
0563      * This signal is emitted if a monitored collection has been changed (properties or content).
0564      *
0565      * @param collection The changed collection.
0566      */
0567     void collectionChanged(const Akonadi::Collection &collection);
0568 
0569     /**
0570      * This signal is emitted if a monitored collection has been changed (properties or attributes).
0571      *
0572      * @param collection The changed collection.
0573      * @param attributeNames The names of the collection attributes that have been changed.
0574      *
0575      * @since 4.4
0576      */
0577     void collectionChanged(const Akonadi::Collection &collection, const QSet<QByteArray> &attributeNames);
0578 
0579     /**
0580      * This signals is emitted if a monitored collection has been moved.
0581      *
0582      * @param collection The moved collection.
0583      * @param source The previous parent collection.
0584      * @param destination The new parent collection.
0585      *
0586      * @since 4.4
0587      */
0588     void collectionMoved(const Akonadi::Collection &collection, const Akonadi::Collection &source, const Akonadi::Collection &destination);
0589 
0590     /**
0591      * This signal is emitted if a monitored collection has been removed from the Akonadi storage.
0592      *
0593      * @param collection The removed collection.
0594      */
0595     void collectionRemoved(const Akonadi::Collection &collection);
0596 
0597     /**
0598      * This signal is emitted if a collection has been subscribed to by the user.
0599      *  It will be emitted even for unmonitored collections as the check for whether to
0600      *  monitor it has not been applied yet.
0601      *
0602      * @param collection The subscribed collection
0603      * @param parent The parent collection of the subscribed collection.
0604      *
0605      * @since 4.6
0606      */
0607     void collectionSubscribed(const Akonadi::Collection &collection, const Akonadi::Collection &parent);
0608 
0609     /**
0610      * This signal is emitted if a user unsubscribes from a collection.
0611      *
0612      * @param collection The unsubscribed collection
0613      *
0614      * @since 4.6
0615      */
0616     void collectionUnsubscribed(const Akonadi::Collection &collection);
0617 
0618     /**
0619      * This signal is emitted if the statistics information of a monitored collection
0620      * has changed.
0621      *
0622      * @param id The collection identifier of the changed collection.
0623      * @param statistics The updated collection statistics, invalid if automatic
0624      *                   fetching of statistics changes is disabled.
0625      */
0626     void collectionStatisticsChanged(Akonadi::Collection::Id id, const Akonadi::CollectionStatistics &statistics);
0627 
0628     /**
0629      * This signal is emitted if a tag has been added to Akonadi storage.
0630      *
0631      * @param tag The added tag
0632      * @since 4.13
0633      */
0634     void tagAdded(const Akonadi::Tag &tag);
0635 
0636     /**
0637      * This signal is emitted if a monitored tag is changed on the server.
0638      *
0639      * @param tag The changed tag.
0640      * @since 4.13
0641      */
0642     void tagChanged(const Akonadi::Tag &tag);
0643 
0644     /**
0645      * This signal is emitted if a monitored tag is removed from the server storage.
0646      *
0647      * The monitor will also emit itemTagsChanged() signal for all monitored items
0648      * (if any) that were tagged by @p tag.
0649      *
0650      * @param tag The removed tag.
0651      * @since 4.13
0652      */
0653     void tagRemoved(const Akonadi::Tag &tag);
0654 
0655     /**
0656      * This signal is emitted if a relation has been added to Akonadi storage.
0657      *
0658      * The monitor will also emit itemRelationsChanged() signal for all monitored items
0659      * hat are affected by @p relation.
0660      *
0661      * @param relation The added relation
0662      * @since 4.13
0663      */
0664     void relationAdded(const Akonadi::Relation &relation);
0665 
0666     /**
0667      * This signal is emitted if a monitored relation is removed from the server storage.
0668      *
0669      * The monitor will also emit itemRelationsChanged() signal for all monitored items
0670      * that were affected by @p relation.
0671      *
0672      * @param relation The removed relation.
0673      * @since 4.13
0674      */
0675     void relationRemoved(const Akonadi::Relation &relation);
0676 
0677     /**
0678      * This signal is emitted when Subscribers are monitored and a new subscriber
0679      * subscribers to the server.
0680      *
0681      * @param subscriber The new subscriber
0682      * @since 5.4
0683      *
0684      * @note Monitoring for subscribers and listening to this signal only makes
0685      * sense if you want to globally debug Monitors. There is no reason to use
0686      * this in regular applications.
0687      */
0688     void notificationSubscriberAdded(const Akonadi::NotificationSubscriber &subscriber);
0689 
0690     /**
0691      * This signal is emitted when Subscribers are monitored and an existing
0692      * subscriber changes its subscription.
0693      *
0694      * @param subscriber The changed subscriber
0695      * @since 5.4
0696      *
0697      * @note Monitoring for subscribers and listening to this signal only makes
0698      * sense if you want to globally debug Monitors. There is no reason to use
0699      * this in regular applications.
0700      */
0701     void notificationSubscriberChanged(const Akonadi::NotificationSubscriber &subscriber);
0702 
0703     /**
0704      * This signal is emitted when Subscribers are monitored and an existing
0705      * subscriber unsubscribes from the server.
0706      *
0707      * @param subscriber The removed subscriber
0708      * @since 5.4
0709      *
0710      * @note Monitoring for subscribers and listening to this signal only makes
0711      * sense if you want to globally debug Monitors. There is no reason to use
0712      * this in regular applications.
0713      */
0714     void notificationSubscriberRemoved(const Akonadi::NotificationSubscriber &subscriber);
0715 
0716     /**
0717      * This signal is emitted when Notifications are monitored and the server emits
0718      * any change notification.
0719      *
0720      * @since 5.4
0721      *
0722      * @note Getting introspection into all change notifications only makes sense
0723      * if you want to globally debug Notifications. There is no reason to use
0724      * this in regular applications.
0725      */
0726     void debugNotification(const Akonadi::ChangeNotification &notification);
0727 
0728     /**
0729      * This signal is emitted if the Monitor starts or stops monitoring @p collection explicitly.
0730      * @param collection The collection
0731      * @param monitored Whether the collection is now being monitored or not.
0732      *
0733      * @since 4.3
0734      */
0735     void collectionMonitored(const Akonadi::Collection &collection, bool monitored);
0736 
0737     /**
0738      * This signal is emitted if the Monitor starts or stops monitoring @p item explicitly.
0739      * @param item The item
0740      * @param monitored Whether the item is now being monitored or not.
0741      *
0742      * @since 4.3
0743      */
0744     void itemMonitored(const Akonadi::Item &item, bool monitored);
0745 
0746     /**
0747      * This signal is emitted if the Monitor starts or stops monitoring the resource with the identifier @p identifier explicitly.
0748      * @param identifier The identifier of the resource.
0749      * @param monitored Whether the resource is now being monitored or not.
0750      *
0751      * @since 4.3
0752      */
0753     void resourceMonitored(const QByteArray &identifier, bool monitored);
0754 
0755     /**
0756      * This signal is emitted if the Monitor starts or stops monitoring @p mimeType explicitly.
0757      * @param mimeType The mimeType.
0758      * @param monitored Whether the mimeType is now being monitored or not.
0759      *
0760      * @since 4.3
0761      */
0762     void mimeTypeMonitored(const QString &mimeType, bool monitored);
0763 
0764     /**
0765      * This signal is emitted if the Monitor starts or stops monitoring everything.
0766      * @param monitored Whether everything is now being monitored or not.
0767      *
0768      * @since 4.3
0769      */
0770     void allMonitored(bool monitored);
0771 
0772     /**
0773      * This signal is emitted if the Monitor starts or stops monitoring @p tag explicitly.
0774      * @param tag The tag.
0775      * @param monitored Whether the tag is now being monitored or not.
0776      * @since 4.13
0777      */
0778     void tagMonitored(const Akonadi::Tag &tag, bool monitored);
0779 
0780     /**
0781      * This signal is emitted if the Monitor starts or stops monitoring @p type explicitly
0782      * @param type The type.
0783      * @param monitored Whether the type is now being monitored or not.
0784      * @since 4.13
0785      */
0786     void typeMonitored(const Akonadi::Monitor::Type type, bool monitored);
0787 
0788     void monitorReady();
0789 
0790 protected:
0791     /// @cond PRIVATE
0792     void connectNotify(const QMetaMethod &signal) override;
0793     void disconnectNotify(const QMetaMethod &signal) override;
0794 
0795     friend class EntityTreeModel;
0796     friend class EntityTreeModelPrivate;
0797     std::unique_ptr<MonitorPrivate> const d_ptr;
0798     explicit Monitor(MonitorPrivate *d, QObject *parent = nullptr);
0799     /// @endcond
0800 
0801 private:
0802     Q_DECLARE_PRIVATE(Monitor)
0803 
0804     /// @cond PRIVATE
0805     Q_PRIVATE_SLOT(d_ptr, void handleCommands())
0806     Q_PRIVATE_SLOT(d_ptr, void invalidateCollectionCache(qint64))
0807     Q_PRIVATE_SLOT(d_ptr, void invalidateItemCache(qint64))
0808     Q_PRIVATE_SLOT(d_ptr, void invalidateTagCache(qint64))
0809 
0810     friend class ResourceBasePrivate;
0811     /// @endcond
0812 };
0813 
0814 }