File indexing completed on 2024-05-12 05:17:15
0001 /* 0002 SPDX-FileCopyrightText: 2009 Andras Mantia <amantia@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "listrightsjob.h" 0008 0009 #include <KLocalizedString> 0010 0011 #include "acljobbase_p.h" 0012 #include "response_p.h" 0013 #include "rfccodecs.h" 0014 #include "session_p.h" 0015 0016 namespace KIMAP 0017 { 0018 class ListRightsJobPrivate : public AclJobBasePrivate 0019 { 0020 public: 0021 ListRightsJobPrivate(Session *session, const QString &name) 0022 : AclJobBasePrivate(session, name) 0023 , defaultRights(Acl::None) 0024 { 0025 } 0026 ~ListRightsJobPrivate() 0027 { 0028 } 0029 0030 QList<Acl::Rights> possibleRights; 0031 Acl::Rights defaultRights; 0032 }; 0033 } 0034 0035 using namespace KIMAP; 0036 0037 ListRightsJob::ListRightsJob(Session *session) 0038 : AclJobBase(*new ListRightsJobPrivate(session, i18n("ListRights"))) 0039 { 0040 } 0041 0042 ListRightsJob::~ListRightsJob() 0043 { 0044 } 0045 0046 void ListRightsJob::doStart() 0047 { 0048 Q_D(ListRightsJob); 0049 0050 d->tags << d->sessionInternal()->sendCommand("LISTRIGHTS", '\"' + KIMAP::encodeImapFolderName(d->mailBox.toUtf8()) + "\" \"" + d->id + "\""); 0051 } 0052 0053 void ListRightsJob::handleResponse(const Response &response) 0054 { 0055 Q_D(ListRightsJob); 0056 0057 if (handleErrorReplies(response) == NotHandled) { 0058 if (response.content.size() >= 4 && response.content[1].toString() == "LISTRIGHTS") { 0059 QByteArray s = response.content[4].toString(); 0060 d->defaultRights = Acl::rightsFromString(s); 0061 int i = 5; 0062 while (i < response.content.size()) { 0063 s = response.content[i].toString(); 0064 d->possibleRights.append(Acl::rightsFromString(s)); 0065 i++; 0066 } 0067 } 0068 } 0069 } 0070 0071 void ListRightsJob::setIdentifier(const QByteArray &identifier) 0072 { 0073 Q_D(ListRightsJob); 0074 d->setIdentifier(identifier); 0075 } 0076 0077 QByteArray ListRightsJob::identifier() 0078 { 0079 Q_D(ListRightsJob); 0080 return d->identifier(); 0081 } 0082 0083 Acl::Rights ListRightsJob::defaultRights() 0084 { 0085 Q_D(ListRightsJob); 0086 return d->defaultRights; 0087 } 0088 0089 QList<Acl::Rights> ListRightsJob::possibleRights() 0090 { 0091 Q_D(ListRightsJob); 0092 return d->possibleRights; 0093 } 0094 0095 #include "moc_listrightsjob.cpp"