KIMAP2

metadatajobbase.cpp
1 /*
2  Copyright (c) 2009 Andras Mantia <[email protected]>
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 #include "metadatajobbase.h"
21 #include "metadatajobbase_p.h"
22 #include "message_p.h"
23 #include "session_p.h"
24 
25 using namespace KIMAP2;
26 
27 QByteArray MetaDataJobBasePrivate::addPrefix(const QByteArray &entry, const QByteArray &attribute) const
28 {
29  if (serverCapability == MetaDataJobBase::Annotatemore) {
30  if (attribute == "value.shared") {
31  return QByteArray("/shared").append(entry);
32  } else if (attribute == "value.priv") {
33  return QByteArray("/private").append(entry);
34  }
35  }
36  return entry;
37 }
38 
39 QByteArray MetaDataJobBasePrivate::removePrefix(const QByteArray &entry) const
40 {
41  if (serverCapability == MetaDataJobBase::Annotatemore) {
42  if (entry.startsWith("/shared")) {
43  return entry.mid(QByteArray("/shared").size());
44  }
45  if (entry.startsWith("/private")) {
46  return entry.mid(QByteArray("/private").size());
47  }
48  }
49  return entry;
50 }
51 
52 QByteArray MetaDataJobBasePrivate::getAttribute(const QByteArray &entry) const
53 {
54  if (serverCapability == MetaDataJobBase::Annotatemore) {
55  if (entry.startsWith("/shared")) {
56  return QByteArray("value.shared");
57  } else if (entry.startsWith("/private")) {
58  return QByteArray("value.priv");
59  }
60  }
61  return QByteArray();
62 }
63 
64 MetaDataJobBase::MetaDataJobBase(Session *session)
65  : Job(*new MetaDataJobBasePrivate(session, "MetaDataJobBase"))
66 {
67 }
68 
69 MetaDataJobBase::MetaDataJobBase(JobPrivate &dd)
70  : Job(dd)
71 {
72 }
73 
74 MetaDataJobBase::~MetaDataJobBase()
75 {
76 }
77 
79 {
80  Q_D(MetaDataJobBase);
81  d->mailBox = mailBox;
82 }
83 
85 {
86  Q_D(const MetaDataJobBase);
87  return d->mailBox;
88 }
89 
91 {
92  Q_D(MetaDataJobBase);
93  d->serverCapability = capability;
94 }
95 
97 {
98  Q_D(const MetaDataJobBase);
99  return d->serverCapability;
100 }
void setMailBox(const QString &mailBox)
Set the mailbox to act on.
bool startsWith(const QByteArray &ba) const const
ServerCapability
Represents the capability level of the server.
Used to indicate that the server supports the draft-daboo-imap-annotatemore-07 version of the extensi...
Definition: acl.cpp:25
Base class for jobs that operate on mailbox metadata.
QByteArray mid(int pos, int len) const const
void setServerCapability(ServerCapability capability)
Set what version of the metadata extension to be compatible with.
QByteArray & append(char ch)
QString mailBox() const
The mailbox that will be acted upon.
Definition: acljobbase.cpp:86
QString mailBox() const
The mailbox that will be acted upon.
ServerCapability serverCapability() const
The version of the metadata extension that will be used.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 23:00:24 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.