KIMAP

idlejob.h
1/*
2 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "kimap_export.h"
10
11#include "imapset.h"
12#include "job.h"
13
14#include <KMime/Content>
15#include <KMime/Message>
16
17namespace KIMAP
18{
19class Session;
20struct Response;
21class IdleJobPrivate;
22
23/**
24 * Idles the connection to the IMAP server.
25 *
26 * This job can be run while the client has no other use
27 * for the connection, and the server will send updates
28 * about the selected mailbox.
29 *
30 * Note that although the server may send a variety of
31 * responses while the job is running (including EXPUNGE,
32 * for example), only RECENT and EXISTS responses are
33 * actually reported by this job.
34 *
35 * The job also processes updates in pairs - if the server
36 * sends an EXISTS update but not a RECENT one (because
37 * another client is changing the mailbox contents), this
38 * job will not report the update.
39 *
40 * It only makes sense to run this job when the session is
41 * in the selected state.
42 *
43 * This job requires that the server supports the IDLE
44 * capability, defined in
45 * <a href="https://tools.ietf.org/html/rfc2177">RFC 2177</a>.
46 */
47class KIMAP_EXPORT IdleJob : public Job
48{
49 Q_OBJECT
50 Q_DECLARE_PRIVATE(IdleJob)
51
52public:
53 explicit IdleJob(Session *session);
54 ~IdleJob() override;
55
56 /**
57 * The last mailbox status that was reported.
58 *
59 * This is just the session's selected mailbox.
60 */
61 [[nodiscard]] QString lastMailBox() const;
62 /**
63 * The last message count that was reported.
64 *
65 * The server will send updates about the number of
66 * messages in the mailbox when that number changes.
67 * This is the last number it reported.
68 *
69 * @return the last message count the server reported,
70 * or -1 if it has not reported a message count
71 * since the job started.
72 */
73 [[nodiscard]] int lastMessageCount() const;
74 /**
75 * The last recent message count that was reported.
76 *
77 * The server will send updates about the number of
78 * messages in the mailbox that are tagged with \Recent
79 * when that number changes. This is the last number it
80 * reported.
81 *
82 * @return the last recent message count the server reported,
83 * or -1 if it has not reported a recent message count
84 * since the job started.
85 */
86 [[nodiscard]] int lastRecentCount() const;
87
88public Q_SLOTS:
89 /**
90 * Stops the idle job.
91 */
92 void stop();
93
94Q_SIGNALS:
95 /**
96 * Signals that the server has notified that the total and
97 * recent message counts have changed.
98 *
99 * @param job this object
100 * @param mailBox the selected mailbox
101 * @param messageCount the new total message count reported by the server
102 * @param recentCount the new "recent message" count reported by the server
103 */
104 void mailBoxStats(KIMAP::IdleJob *job, const QString &mailBox, int messageCount, int recentCount);
105
106 /**
107 * Signals that the server has notified that the some messages flags
108 * have changed
109 *
110 * @param job this object
111 * @param uid UID of message that has changed
112 * @since 4.12
113 */
115
116protected:
117 void doStart() override;
118 void handleResponse(const Response &response) override;
119
120private:
121 Q_PRIVATE_SLOT(d_func(), void emitStats())
122 Q_PRIVATE_SLOT(d_func(), void resetTimeout())
123};
124
125}
Idles the connection to the IMAP server.
Definition idlejob.h:48
void mailBoxStats(KIMAP::IdleJob *job, const QString &mailBox, int messageCount, int recentCount)
Signals that the server has notified that the total and recent message counts have changed.
void mailBoxMessageFlagsChanged(KIMAP::IdleJob *job, qint64 uid)
Signals that the server has notified that the some messages flags have changed.
void stop(Ekos::AlignState mode)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:12:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.