9#include <KLocalizedString>
13#include "response_p.h"
18class IdleJobPrivate :
public JobPrivate
22 : JobPrivate(session,
name)
32 emitStatsTimer.
stop();
34 Q_EMIT q->
mailBoxStats(q, m_session->selectedMailBox(), messageCount, recentCount);
36 lastMessageCount = messageCount;
37 lastRecentCount = recentCount;
45 sessionInternal()->setSocketTimeout(originalSocketTimeout);
52 int messageCount = -1;
55 int lastMessageCount = -1;
56 int lastRecentCount = -1;
58 int originalSocketTimeout = -1;
64IdleJob::IdleJob(
Session *session)
65 : Job(*new IdleJobPrivate(this, session,
i18nc(
"name of the idle job",
"Idle")))
84 d->sessionInternal()->setSocketTimeout(d->originalSocketTimeout);
85 d->sessionInternal()->sendData(
"DONE");
88void IdleJob::doStart()
91 d->originalSocketTimeout = d->sessionInternal()->socketTimeout();
92 d->sessionInternal()->setSocketTimeout(-1);
93 d->tags << d->sessionInternal()->sendCommand(
"IDLE");
96void IdleJob::handleResponse(
const Response &response)
103 if (!response.content.isEmpty() && d->tags.size() == 1 && d->tags.contains(response.content.first().toString())
104 && (d->messageCount >= 0 || d->recentCount >= 0)) {
108 if (handleErrorReplies(response) == NotHandled) {
109 if (!response.content.isEmpty() && response.content[0].toString() ==
"+") {
113 }
else if (response.content.size() > 2) {
114 const QByteArray ba = response.content[2].toString();
115 if (ba ==
"EXISTS") {
116 if (d->messageCount >= 0) {
120 d->messageCount = response.content[1].toString().toInt();
121 }
else if (ba ==
"RECENT") {
122 if (d->recentCount >= 0) {
126 d->recentCount = response.content[1].toString().toInt();
127 }
else if (ba ==
"FETCH") {
128 const qint64 uid = response.content[1].toString().toLongLong();
133 if (d->messageCount >= 0 && d->recentCount >= 0) {
135 }
else if (d->messageCount >= 0 || d->recentCount >= 0) {
136 d->emitStatsTimer.start(200);
144 return d->m_session->selectedMailBox();
150 return d->lastMessageCount;
156 return d->lastRecentCount;
159#include "moc_idlejob.cpp"
Idles the connection to the IMAP server.
void stop()
Stops the idle job.
int lastRecentCount() const
The last recent message count that was reported.
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.
QString lastMailBox() const
The last mailbox status that was reported.
void mailBoxMessageFlagsChanged(KIMAP::IdleJob *job, qint64 uid)
Signals that the server has notified that the some messages flags have changed.
int lastMessageCount() const
The last message count that was reported.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString name(GameStandardAction id)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)