22#include "kimap_debug.h"
30class StoreJobPrivate :
public JobPrivate
34 ~StoreJobPrivate() { }
40 case StoreJob::SetFlags:
43 case StoreJob::AppendFlags:
44 parameters +=
"+" + param;
46 case StoreJob::RemoveFlags:
47 parameters +=
"-" + param;
53 parameters += flag +
' ';
65 StoreJob::StoreMode mode;
73using namespace KIMAP2;
75StoreJob::StoreJob(
Session *session)
76 : Job(*new StoreJobPrivate(session,
"Store"))
87void StoreJob::setSequenceSet(
const ImapSet &set)
93ImapSet StoreJob::sequenceSet()
const
99void StoreJob::setUidBased(
bool uidBased)
102 d->uidBased = uidBased;
105bool StoreJob::isUidBased()
const
126 d->gmLabels = gmLabels;
135void StoreJob::setMode(StoreMode mode)
141StoreJob::StoreMode StoreJob::mode()
const
150 return d->resultingFlags;
153void StoreJob::doStart()
157 if (d->set.isEmpty()) {
158 qCWarning(KIMAP2_LOG) <<
"Empty uid set passed to store job";
160 setErrorText(QStringLiteral(
"Empty uid set passed to store job"));
166 QByteArray parameters = d->set.toImapSequenceSet() +
' ';
168 if (!d->flags.isEmpty() || d->mode == SetFlags) {
169 parameters += d->addFlags(
"FLAGS", d->flags);
171 if (!d->gmLabels.isEmpty()) {
172 if (!d->flags.isEmpty()) {
175 parameters += d->addFlags(
"X-GM-LABELS", d->gmLabels);
178 qCDebug(KIMAP2_LOG) << parameters;
182 command =
"UID " + command;
185 d->sendCommand(command, parameters);
188void StoreJob::handleResponse(
const Message &response)
192 if (handleErrorReplies(response) == NotHandled) {
193 if (response.content.size() == 4 &&
194 response.content[2].toString() ==
"FETCH" &&
195 response.content[3].type() == Message::Part::List) {
197 int id = response.content[1].toString().toInt();
199 bool uidFound =
false;
209 if (str ==
"FLAGS") {
210 if ((*it).startsWith(
'(') && (*it).endsWith(
')')) {
214 resultingFlags = str.
split(
' ');
216 resultingFlags << *it;
218 }
else if (str ==
"UID") {
219 uid = it->toLongLong(&uidFound);
224 d->resultingFlags[id] = resultingFlags;
225 }
else if (uidFound) {
226 d->resultingFlags[uid] = resultingFlags;
228 qCWarning(KIMAP2_LOG) <<
"We asked for UID but the server didn't give it back, resultingFlags not stored.";
Represents a set of natural numbers (1->∞) in a as compact as possible form.
void setErrorText(const QString &errorText)
void setError(int errorCode)
QString name(StandardAction id)
QByteArray & remove(qsizetype pos, qsizetype len)
QList< QByteArray > split(char sep) const const
QList< T > toList() const const
const_iterator constBegin() const const
const_iterator constEnd() const const
bool isEmpty() const const