File indexing completed on 2024-11-10 04:40:11

0001 /*
0002     SPDX-FileCopyrightText: 2011 Stephen Kelly <steveire@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "entitycache_p.h"
0010 #include "monitor.h"
0011 #include "monitor_p.h"
0012 
0013 #include "akonaditestfake_export.h"
0014 #include "fakeakonadiservercommand.h"
0015 #include "fakeentitycache.h"
0016 
0017 class InspectableMonitor;
0018 
0019 class InspectableMonitorPrivate : public Akonadi::MonitorPrivate
0020 {
0021 public:
0022     InspectableMonitorPrivate(FakeMonitorDependenciesFactory *dependenciesFactory, InspectableMonitor *parent);
0023     ~InspectableMonitorPrivate() override
0024     {
0025     }
0026 
0027     bool emitNotification(const Akonadi::Protocol::ChangeNotificationPtr &msg) override
0028     {
0029         // TODO: Check/Log
0030         return Akonadi::MonitorPrivate::emitNotification(msg);
0031     }
0032 };
0033 
0034 class AKONADITESTFAKE_EXPORT InspectableMonitor : public Akonadi::Monitor
0035 {
0036     Q_OBJECT
0037 public:
0038     explicit InspectableMonitor(FakeMonitorDependenciesFactory *dependenciesFactory, QObject *parent = nullptr);
0039 
0040     FakeNotificationConnection *notificationConnection() const
0041     {
0042         return qobject_cast<FakeNotificationConnection *>(d_ptr->ntfConnection);
0043     }
0044 
0045     QQueue<Akonadi::Protocol::ChangeNotificationPtr> pendingNotifications() const
0046     {
0047         return d_ptr->pendingNotifications;
0048     }
0049     QQueue<Akonadi::Protocol::ChangeNotificationPtr> pipeline() const
0050     {
0051         return d_ptr->pipeline;
0052     }
0053 
0054 Q_SIGNALS:
0055     void dummySignal();
0056 
0057 private Q_SLOTS:
0058     void dispatchNotifications()
0059     {
0060         d_ptr->dispatchNotifications();
0061     }
0062 
0063     void doConnectToNotificationManager();
0064 
0065 private:
0066     struct MessageStruct {
0067         enum Position {
0068             Queued,
0069             FilterPipelined,
0070             Pipelined,
0071             Emitted,
0072         };
0073         Position position;
0074     };
0075     QQueue<MessageStruct> m_messages;
0076 };