File indexing completed on 2024-05-26 05:14:08

0001 /*
0002     SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "akonadiprivate_export.h"
0010 #include "changerecorder.h"
0011 #include "monitor_p.h"
0012 
0013 namespace Akonadi
0014 {
0015 class ChangeRecorder;
0016 class ChangeNotificationDependenciesFactory;
0017 
0018 class AKONADI_TESTS_EXPORT ChangeRecorderPrivate : public Akonadi::MonitorPrivate
0019 {
0020 public:
0021     ChangeRecorderPrivate(ChangeNotificationDependenciesFactory *dependenciesFactory_, ChangeRecorder *parent);
0022 
0023     Q_DECLARE_PUBLIC(ChangeRecorder)
0024     QSettings *settings = nullptr;
0025     bool enableChangeRecording = true;
0026 
0027     int pipelineSize() const override;
0028     void notificationsEnqueued(int count) override;
0029     void notificationsErased() override;
0030 
0031     void slotNotify(const Protocol::ChangeNotificationPtr &msg) override;
0032     bool emitNotification(const Protocol::ChangeNotificationPtr &msg) override;
0033 
0034     QString notificationsFileName() const;
0035 
0036     void loadNotifications();
0037     QString dumpNotificationListToString() const;
0038     void saveNotifications();
0039 
0040 private:
0041     void dequeueNotification();
0042     void notificationsLoaded();
0043     void writeStartOffset() const;
0044 
0045     int m_lastKnownNotificationsCount = 0; // just for invariant checking
0046     int m_startOffset = 0; // number of saved notifications to skip
0047     bool m_needFullSave = true;
0048 };
0049 
0050 } // namespace Akonadi