File indexing completed on 2025-02-16 04:50:17
0001 /* 0002 SPDX-FileCopyrightText: 2007 Till Adam <adam@kde.org> 0003 SPDX-FileCopyrightText: 2008 Omat Holding B.V. <info@omat.nl> 0004 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org> 0005 0006 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> 0007 SPDX-FileContributor: Kevin Ottens <kevin@kdab.com> 0008 0009 SPDX-License-Identifier: LGPL-2.0-or-later 0010 */ 0011 0012 #pragma once 0013 0014 #include "resourcestateinterface.h" 0015 0016 #include <Akonadi/Collection> 0017 0018 #include <QObject> 0019 #include <QPointer> 0020 0021 namespace KIMAP 0022 { 0023 class IdleJob; 0024 class Session; 0025 } 0026 0027 class ImapResourceBase; 0028 class SessionPool; 0029 0030 class KJob; 0031 0032 class QTimer; 0033 0034 class ImapIdleManager : public QObject 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 ImapIdleManager(ResourceStateInterface::Ptr state, SessionPool *pool, ImapResourceBase *parent); 0040 ~ImapIdleManager() override; 0041 void stop(); 0042 0043 KIMAP::Session *session() const; 0044 0045 private Q_SLOTS: 0046 void onConnectionLost(KIMAP::Session *session); 0047 void onPoolDisconnect(); 0048 0049 void onSessionRequestDone(qint64 requestId, KIMAP::Session *session, int errorCode, const QString &errorString); 0050 void onSelectDone(KJob *job); 0051 void onIdleStopped(); 0052 void onStatsReceived(KIMAP::IdleJob *job, const QString &mailBox, int messageCount, int recentCount); 0053 void onFlagsChanged(KIMAP::IdleJob *job); 0054 void reconnect(); 0055 void restartIdle(); 0056 0057 private: 0058 void startIdle(); 0059 0060 qint64 m_sessionRequestId; 0061 SessionPool *m_pool = nullptr; 0062 KIMAP::Session *m_session = nullptr; 0063 QPointer<KIMAP::IdleJob> m_idle; 0064 ImapResourceBase *m_resource = nullptr; 0065 ResourceStateInterface::Ptr m_state; 0066 QTimer *m_idleTimeout = nullptr; 0067 qint64 m_lastMessageCount = -1; 0068 qint64 m_lastRecentCount = -1; 0069 };