KIMAP2

getacljob.cpp
1/*
2 Copyright (c) 2009 Andras Mantia <amantia@kde.org>
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 "getacljob.h"
21
22#include "kimap_debug.h"
23
24#include "acljobbase_p.h"
25#include "message_p.h"
26#include "session_p.h"
27#include "rfccodecs.h"
28
29namespace KIMAP2
30{
31class GetAclJobPrivate : public AclJobBasePrivate
32{
33public:
34 GetAclJobPrivate(Session *session, const QString &name) : AclJobBasePrivate(session, name) {}
35 ~GetAclJobPrivate() { }
36
38};
39}
40
41using namespace KIMAP2;
42
43GetAclJob::GetAclJob(Session *session)
44 : AclJobBase(*new GetAclJobPrivate(session, "GetAcl"))
45{
46}
47
48GetAclJob::~GetAclJob()
49{
50}
51
52void GetAclJob::doStart()
53{
55
56 d->sendCommand("GETACL", '\"' + KIMAP2::encodeImapFolderName(d->mailBox.toUtf8()) + '\"');
57}
58
59void GetAclJob::handleResponse(const Message &response)
60{
62// qCDebug(KIMAP2_LOG) << response.toString();
63
64 if (handleErrorReplies(response) == NotHandled) {
65 if (response.content.size() >= 4 &&
66 response.content[1].toString() == "ACL") {
67 int i = 3;
68 while (i < response.content.size() - 1) {
69 QByteArray id = response.content[i].toString();
70 QByteArray rights = response.content[i + 1].toString();
71 d->userRights[id] = Acl::rightsFromString(rights);
72 i += 2;
73 }
74 }
75 }
76}
77
79{
80 Q_D(const GetAclJob);
81 return d->userRights.keys();
82}
83
84bool GetAclJob::hasRightEnabled(const QByteArray &identifier, Acl::Right right) const
85{
86 Q_D(const GetAclJob);
87 if (d->userRights.contains(identifier)) {
88 Acl::Rights rights = d->userRights[identifier];
89 return rights & right;
90 }
91
92 return false;
93}
94
96{
97 Q_D(const GetAclJob);
99 if (d->userRights.contains(identifier)) {
100 result = d->userRights[identifier];
101 }
102 return result;
103}
104
106{
107 Q_D(const GetAclJob);
108 return d->userRights;
109}
Base class for jobs that operate on mailbox ACLs.
Definition acljobbase.h:45
Gets the ACL for a mailbox.
Definition getacljob.h:64
QList< QByteArray > identifiers() const
The identifiers present in the ACL.
Definition getacljob.cpp:78
QMap< QByteArray, Acl::Rights > allRights() const
Gets the full access control list.
Acl::Rights rights(const QByteArray &identifier) const
Get the rights associated with an identifier.
Definition getacljob.cpp:95
bool hasRightEnabled(const QByteArray &identifier, Acl::Right right) const
Check whether an identifier has a given right set.
Definition getacljob.cpp:84
void result(KJob *job)
QString name(GameStandardAction id)
Right
Possible rights that can be held on a mailbox.
Definition acl.h:39
KIMAP2_EXPORT Rights rightsFromString(const QByteArray &string)
Convert the text form of a set of rights into a Rights bitflag.
Definition acl.cpp:69
This file is part of the IMAP support library and defines the RfcCodecs class.
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:56:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.