KIMAP2

idlejob.h
1/*
2 Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#ifndef KIMAP2_IDLEJOB_H
21#define KIMAP2_IDLEJOB_H
22
23#include "kimap2_export.h"
24
25#include "imapset.h"
26#include "job.h"
27
28#include <kmime/kmime_content.h>
29#include <kmime/kmime_message.h>
30
31namespace KIMAP2
32{
33
34class Session;
35struct Message;
36class IdleJobPrivate;
37
38/**
39 * Idles the connection to the IMAP server.
40 *
41 * This job can be run while the client has no other use
42 * for the connection, and the server will send updates
43 * about the selected mailbox.
44 *
45 * Note that although the server may send a variety of
46 * responses while the job is running (including EXPUNGE,
47 * for example), only RECENT and EXISTS responses are
48 * actually reported by this job.
49 *
50 * The job also processes updates in pairs - if the server
51 * sends an EXISTS update but not a RECENT one (because
52 * another client is changing the mailbox contents), this
53 * job will not report the update.
54 *
55 * It only makes sense to run this job when the session is
56 * in the selected state.
57 *
58 * This job requires that the server supports the IDLE
59 * capability, defined in
60 * <a href="http://www.apps.ietf.org/rfc/rfc2177.html">RFC 2177</a>.
61 */
62class KIMAP2_EXPORT IdleJob : public Job
63{
65 Q_DECLARE_PRIVATE(IdleJob)
66
67public:
68 explicit IdleJob(Session *session);
69 virtual ~IdleJob();
70
71 /**
72 * The last mailbox status that was reported.
73 *
74 * This is just the session's selected mailbox.
75 */
76 QString lastMailBox() const;
77 /**
78 * The last message count that was reported.
79 *
80 * The server will send updates about the number of
81 * messages in the mailbox when that number changes.
82 * This is the last number it reported.
83 *
84 * @return the last message count the server reported,
85 * or -1 if it has not reported a message count
86 * since the job started.
87 */
88 int lastMessageCount() const;
89 /**
90 * The last recent message count that was reported.
91 *
92 * The server will send updates about the number of
93 * messages in the mailbox that are tagged with \Recent
94 * when that number changes. This is the last number it
95 * reported.
96 *
97 * @return the last recent message count the server reported,
98 * or -1 if it has not reported a recent message count
99 * since the job started.
100 */
101 int lastRecentCount() const;
102
103public Q_SLOTS:
104 /**
105 * Stops the idle job.
106 */
107 void stop();
108
110 /**
111 * Signals that the server has notified that the total and
112 * recent message counts have changed.
113 *
114 * @param job this object
115 * @param mailBox the selected mailbox
116 * @param messageCount the new total message count reported by the server
117 * @param recentCount the new "recent message" count reported by the server
118 */
119 void mailBoxStats(KIMAP2::IdleJob *job, const QString &mailBox, int messageCount, int recentCount);
120
121 /**
122 * Signals that the server has notified that the some messages flags
123 * have changed
124 *
125 * @param job this object
126 * @param uid UID of message that has changed
127 * @since 4.12
128 */
130
131protected:
132 void doStart() Q_DECL_OVERRIDE;
133 void handleResponse(const Message &response) Q_DECL_OVERRIDE;
134
135private:
136 Q_PRIVATE_SLOT(d_func(), void emitStats())
137 Q_PRIVATE_SLOT(d_func(), void resetTimeout())
138};
139
140}
141
142#endif
Idles the connection to the IMAP server.
Definition idlejob.h:63
int lastRecentCount() const
The last recent message count that was reported.
Definition idlejob.cpp:163
void mailBoxMessageFlagsChanged(KIMAP2::IdleJob *job, qint64 uid)
Signals that the server has notified that the some messages flags have changed.
void mailBoxStats(KIMAP2::IdleJob *job, const QString &mailBox, int messageCount, int recentCount)
Signals that the server has notified that the total and recent message counts have changed.
QString lastMailBox() const
The last mailbox status that was reported.
Definition idlejob.cpp:151
int lastMessageCount() const
The last message count that was reported.
Definition idlejob.cpp:157
void stop(Ekos::AlignState mode)
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 31 2025 12:10:33 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.