KIMAP

getacljob.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Andras Mantia <amantia@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "getacljob.h"
8
9#include "kimap_debug.h"
10#include <KLocalizedString>
11
12#include "acljobbase_p.h"
13#include "response_p.h"
14#include "rfccodecs.h"
15#include "session_p.h"
16
17namespace KIMAP
18{
19class GetAclJobPrivate : public AclJobBasePrivate
20{
21public:
22 GetAclJobPrivate(Session *session, const QString &name)
23 : AclJobBasePrivate(session, name)
24 {
25 }
26 ~GetAclJobPrivate()
27 {
28 }
29
31};
32}
33
34using namespace KIMAP;
35
36GetAclJob::GetAclJob(Session *session)
37 : AclJobBase(*new GetAclJobPrivate(session, i18n("GetAcl")))
38{
39}
40
41GetAclJob::~GetAclJob()
42{
43}
44
45void GetAclJob::doStart()
46{
48
49 d->tags << d->sessionInternal()->sendCommand("GETACL", '\"' + KIMAP::encodeImapFolderName(d->mailBox.toUtf8()) + '\"');
50}
51
52void GetAclJob::handleResponse(const Response &response)
53{
55 // qCDebug(KIMAP_LOG) << response.toString();
56
57 if (handleErrorReplies(response) == NotHandled) {
58 if (response.content.size() >= 4 && response.content[1].toString() == "ACL") {
59 int i = 3;
60 while (i < response.content.size() - 1) {
61 QByteArray id = response.content[i].toString();
62 QByteArray rights = response.content[i + 1].toString();
63 d->userRights[id] = Acl::rightsFromString(rights);
64 i += 2;
65 }
66 }
67 }
68}
69
71{
72 Q_D(const GetAclJob);
73 return d->userRights.keys();
74}
75
76bool GetAclJob::hasRightEnabled(const QByteArray &identifier, Acl::Right right) const
77{
78 Q_D(const GetAclJob);
79 if (d->userRights.contains(identifier)) {
80 Acl::Rights rights = d->userRights[identifier];
81 return rights & right;
82 }
83
84 return false;
85}
86
88{
89 Q_D(const GetAclJob);
91 if (d->userRights.contains(identifier)) {
92 result = d->userRights[identifier];
93 }
94 return result;
95}
96
98{
99 Q_D(const GetAclJob);
100 return d->userRights;
101}
102
103#include "moc_getacljob.cpp"
Base class for jobs that operate on mailbox ACLs.
Definition acljobbase.h:30
Gets the ACL for a mailbox.
Definition getacljob.h:49
QList< QByteArray > identifiers() const
The identifiers present in the ACL.
Definition getacljob.cpp:70
QMap< QByteArray, Acl::Rights > allRights() const
Gets the full access control list.
Definition getacljob.cpp:97
Acl::Rights rights(const QByteArray &identifier) const
Get the rights associated with an identifier.
Definition getacljob.cpp:87
bool hasRightEnabled(const QByteArray &identifier, Acl::Right right) const
Check whether an identifier has a given right set.
Definition getacljob.cpp:76
void result(KJob *job)
QString i18n(const char *text, const TYPE &arg...)
KIMAP_EXPORT Rights rightsFromString(const QByteArray &string)
Convert the text form of a set of rights into a Rights bitflag.
Definition acl.cpp:55
Right
Possible rights that can be held on a mailbox.
Definition acl.h:23
QString name(StandardAction id)
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 Oct 11 2024 12:13:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.