22#include <QtCore/QTimer>
30class IdleJobPrivate :
public JobPrivate
34 : JobPrivate(session,
name), q(job),
35 messageCount(-1), recentCount(-1),
36 lastMessageCount(-1), lastRecentCount(-1),
37 originalSocketTimeout(-1) { }
42 emitStatsTimer.
stop();
45 messageCount, recentCount);
47 lastMessageCount = messageCount;
48 lastRecentCount = recentCount;
56 sessionInternal()->setSocketTimeout(originalSocketTimeout);
69 int originalSocketTimeout;
73using namespace KIMAP2;
75IdleJob::IdleJob(
Session *session)
76 : Job(*new IdleJobPrivate(this, session,
"Idle"))
79 connect(&d->emitStatsTimer, SIGNAL(timeout()),
80 this, SLOT(emitStats()));
83 this, SLOT(resetTimeout()));
93 d->sessionInternal()->setSocketTimeout(d->originalSocketTimeout);
94 d->sessionInternal()->sendData(
"DONE");
97void IdleJob::doStart()
100 d->originalSocketTimeout = d->sessionInternal()->socketTimeout();
101 d->sessionInternal()->setSocketTimeout(-1);
102 d->sendCommand(
"IDLE", {});
105void IdleJob::handleResponse(
const Message &response)
112 if (!response.content.isEmpty() &&
113 d->tags.size() == 1 &&
114 d->tags.contains(response.content.first().toString()) &&
115 (d->messageCount >= 0 || d->recentCount >= 0)) {
119 if (handleErrorReplies(response) == NotHandled) {
120 if (response.content.size() > 0 && response.content[0].toString() ==
"+") {
124 }
else if (response.content.size() > 2) {
125 if (response.content[2].toString() ==
"EXISTS") {
126 if (d->messageCount >= 0) {
130 d->messageCount = response.content[1].toString().toInt();
131 }
else if (response.content[2].toString() ==
"RECENT") {
132 if (d->recentCount >= 0) {
136 d->recentCount = response.content[1].toString().toInt();
137 }
else if (response.content[2].toString() ==
"FETCH") {
138 const qint64 uid = response.content[1].toString().toLongLong();
143 if (d->messageCount >= 0 && d->recentCount >= 0) {
145 }
else if (d->messageCount >= 0 || d->recentCount >= 0) {
146 d->emitStatsTimer.start(200);
154 return d->m_session->selectedMailBox();
160 return d->lastMessageCount;
166 return d->lastRecentCount;
169#include "moc_idlejob.cpp"
Idles the connection to the IMAP server.
int lastRecentCount() const
The last recent message count that was reported.
void stop()
Stops the idle job.
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.
int lastMessageCount() const
The last message count that was reported.
QString name(GameStandardAction id)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)