File indexing completed on 2024-05-12 05:17:24

0001 /*
0002     Copyright (c) 2009 Andras Mantia <amantia@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or modify it
0005     under the terms of the GNU Library General Public License as published by
0006     the Free Software Foundation; either version 2 of the License, or (at your
0007     option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful, but WITHOUT
0010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
0012     License for more details.
0013 
0014     You should have received a copy of the GNU Library General Public License
0015     along with this library; see the file COPYING.LIB.  If not, write to the
0016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0017     02110-1301, USA.
0018 */
0019 
0020 #include "metadatajobbase.h"
0021 #include "metadatajobbase_p.h"
0022 #include "message_p.h"
0023 #include "session_p.h"
0024 
0025 using namespace KIMAP2;
0026 
0027 QByteArray MetaDataJobBasePrivate::addPrefix(const QByteArray &entry, const QByteArray &attribute) const
0028 {
0029     if (serverCapability == MetaDataJobBase::Annotatemore) {
0030         if (attribute == "value.shared") {
0031             return QByteArray("/shared").append(entry);
0032         } else if (attribute == "value.priv") {
0033             return QByteArray("/private").append(entry);
0034         }
0035     }
0036     return entry;
0037 }
0038 
0039 QByteArray MetaDataJobBasePrivate::removePrefix(const QByteArray &entry) const
0040 {
0041     if (serverCapability == MetaDataJobBase::Annotatemore) {
0042         if (entry.startsWith("/shared")) {
0043             return entry.mid(QByteArray("/shared").size());
0044         }
0045         if (entry.startsWith("/private")) {
0046             return entry.mid(QByteArray("/private").size());
0047         }
0048     }
0049     return entry;
0050 }
0051 
0052 QByteArray MetaDataJobBasePrivate::getAttribute(const QByteArray &entry) const
0053 {
0054     if (serverCapability == MetaDataJobBase::Annotatemore) {
0055         if (entry.startsWith("/shared")) {
0056             return QByteArray("value.shared");
0057         } else if (entry.startsWith("/private")) {
0058             return QByteArray("value.priv");
0059         }
0060     }
0061     return QByteArray();
0062 }
0063 
0064 MetaDataJobBase::MetaDataJobBase(Session *session)
0065     : Job(*new MetaDataJobBasePrivate(session, "MetaDataJobBase"))
0066 {
0067 }
0068 
0069 MetaDataJobBase::MetaDataJobBase(JobPrivate &dd)
0070     : Job(dd)
0071 {
0072 }
0073 
0074 MetaDataJobBase::~MetaDataJobBase()
0075 {
0076 }
0077 
0078 void MetaDataJobBase::setMailBox(const QString &mailBox)
0079 {
0080     Q_D(MetaDataJobBase);
0081     d->mailBox = mailBox;
0082 }
0083 
0084 QString MetaDataJobBase::mailBox() const
0085 {
0086     Q_D(const MetaDataJobBase);
0087     return d->mailBox;
0088 }
0089 
0090 void MetaDataJobBase::setServerCapability(ServerCapability capability)
0091 {
0092     Q_D(MetaDataJobBase);
0093     d->serverCapability = capability;
0094 }
0095 
0096 MetaDataJobBase::ServerCapability MetaDataJobBase::serverCapability() const
0097 {
0098     Q_D(const MetaDataJobBase);
0099     return d->serverCapability;
0100 }