File indexing completed on 2024-05-12 05:17:23
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 "listrightsjob.h" 0021 0022 #include "acljobbase_p.h" 0023 #include "message_p.h" 0024 #include "session_p.h" 0025 #include "rfccodecs.h" 0026 0027 namespace KIMAP2 0028 { 0029 class ListRightsJobPrivate : public AclJobBasePrivate 0030 { 0031 public: 0032 ListRightsJobPrivate(Session *session, const QString &name) : AclJobBasePrivate(session, name), defaultRights(Acl::None) {} 0033 ~ListRightsJobPrivate() { } 0034 0035 Acl::Rights defaultRights; 0036 QList<Acl::Rights> possibleRights; 0037 0038 }; 0039 } 0040 0041 using namespace KIMAP2; 0042 0043 ListRightsJob::ListRightsJob(Session *session) 0044 : AclJobBase(*new ListRightsJobPrivate(session, "ListRights")) 0045 { 0046 0047 } 0048 0049 ListRightsJob::~ListRightsJob() 0050 { 0051 } 0052 0053 void ListRightsJob::doStart() 0054 { 0055 Q_D(ListRightsJob); 0056 0057 d->sendCommand("LISTRIGHTS", '\"' + KIMAP2::encodeImapFolderName(d->mailBox.toUtf8()) + "\" \"" + d->id + "\""); 0058 } 0059 0060 void ListRightsJob::handleResponse(const Message &response) 0061 { 0062 Q_D(ListRightsJob); 0063 0064 if (handleErrorReplies(response) == NotHandled) { 0065 if (response.content.size() >= 4 && 0066 response.content[1].toString() == "LISTRIGHTS") { 0067 QByteArray s = response.content[4].toString(); 0068 d->defaultRights = Acl::rightsFromString(s); 0069 int i = 5; 0070 while (i < response.content.size()) { 0071 s = response.content[i].toString(); 0072 d->possibleRights.append(Acl::rightsFromString(s)); 0073 i++; 0074 } 0075 } 0076 } 0077 } 0078 0079 void ListRightsJob::setIdentifier(const QByteArray &identifier) 0080 { 0081 Q_D(ListRightsJob); 0082 d->setIdentifier(identifier); 0083 } 0084 0085 QByteArray ListRightsJob::identifier() 0086 { 0087 Q_D(ListRightsJob); 0088 return d->identifier(); 0089 } 0090 0091 Acl::Rights ListRightsJob::defaultRights() 0092 { 0093 Q_D(ListRightsJob); 0094 return d->defaultRights; 0095 } 0096 0097 QList<Acl::Rights> ListRightsJob::possibleRights() 0098 { 0099 Q_D(ListRightsJob); 0100 return d->possibleRights; 0101 }