KIMAP

metadatajobbase.cpp
1 /*
2  SPDX-FileCopyrightText: 2009 Andras Mantia <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "metadatajobbase.h"
8 #include "metadatajobbase_p.h"
9 #include "response_p.h"
10 #include "session_p.h"
11 
12 #include <KLocalizedString>
13 
14 using namespace KIMAP;
15 
16 QByteArray MetaDataJobBasePrivate::addPrefix(const QByteArray &entry, const QByteArray &attribute) const
17 {
18  if (serverCapability == MetaDataJobBase::Annotatemore) {
19  if (attribute == "value.shared") {
20  return QByteArray("/shared").append(entry);
21  } else if (attribute == "value.priv") {
22  return QByteArray("/private").append(entry);
23  }
24  }
25  return entry;
26 }
27 
28 QByteArray MetaDataJobBasePrivate::removePrefix(const QByteArray &entry) const
29 {
30  if (serverCapability == MetaDataJobBase::Annotatemore) {
31  if (entry.startsWith("/shared")) {
32  return entry.mid(QByteArray("/shared").size());
33  } else if (entry.startsWith("/private")) {
34  return entry.mid(QByteArray("/private").size());
35  }
36  }
37  return entry;
38 }
39 
40 QByteArray MetaDataJobBasePrivate::getAttribute(const QByteArray &entry) const
41 {
42  if (serverCapability == MetaDataJobBase::Annotatemore) {
43  if (entry.startsWith("/shared")) {
44  return QByteArray("value.shared");
45  } else if (entry.startsWith("/private")) {
46  return QByteArray("value.priv");
47  }
48  }
49  return QByteArray();
50 }
51 
52 MetaDataJobBase::MetaDataJobBase(Session *session)
53  : Job(*new MetaDataJobBasePrivate(session, i18n("MetaDataJobBase")))
54 {
55 }
56 
57 MetaDataJobBase::MetaDataJobBase(JobPrivate &dd)
58  : Job(dd)
59 {
60 }
61 
62 MetaDataJobBase::~MetaDataJobBase()
63 {
64 }
65 
67 {
69  d->mailBox = mailBox;
70 }
71 
73 {
74  Q_D(const MetaDataJobBase);
75  return d->mailBox;
76 }
77 
79 {
81  d->serverCapability = capability;
82 }
83 
85 {
86  Q_D(const MetaDataJobBase);
87  return d->serverCapability;
88 }
89 
90 #include "moc_metadatajobbase.cpp"
QByteArray & append(char ch)
ServerCapability serverCapability() const
The version of the metadata extension that will be used.
QString mailBox() const
The mailbox that will be acted upon.
ServerCapability
Represents the capability level of the server.
QString i18n(const char *text, const TYPE &arg...)
QByteArray mid(int pos, int len) const const
bool startsWith(const QByteArray &ba) const const
void setMailBox(const QString &mailBox)
Set the mailbox to act on.
@ Annotatemore
Used to indicate that the server supports the draft-daboo-imap-annotatemore-07 version of the extensi...
void setServerCapability(ServerCapability capability)
Set what version of the metadata extension to be compatible with.
Q_D(Todo)
Base class for jobs that operate on mailbox metadata.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 03:51:44 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.