KIMAP

listrightsjob.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 "listrightsjob.h"
8
9#include <KLocalizedString>
10
11#include "acljobbase_p.h"
12#include "response_p.h"
13#include "rfccodecs.h"
14#include "session_p.h"
15
16namespace KIMAP
17{
18class ListRightsJobPrivate : public AclJobBasePrivate
19{
20public:
21 ListRightsJobPrivate(Session *session, const QString &name)
22 : AclJobBasePrivate(session, name)
23 , defaultRights(Acl::None)
24 {
25 }
26 ~ListRightsJobPrivate()
27 {
28 }
29
30 QList<Acl::Rights> possibleRights;
31 Acl::Rights defaultRights;
32};
33}
34
35using namespace KIMAP;
36
37ListRightsJob::ListRightsJob(Session *session)
38 : AclJobBase(*new ListRightsJobPrivate(session, i18n("ListRights")))
39{
40}
41
42ListRightsJob::~ListRightsJob()
43{
44}
45
46void ListRightsJob::doStart()
47{
49
50 d->tags << d->sessionInternal()->sendCommand("LISTRIGHTS", '\"' + KIMAP::encodeImapFolderName(d->mailBox.toUtf8()) + "\" \"" + d->id + "\"");
51}
52
53void ListRightsJob::handleResponse(const Response &response)
54{
56
57 if (handleErrorReplies(response) == NotHandled) {
58 if (response.content.size() >= 4 && response.content[1].toString() == "LISTRIGHTS") {
59 QByteArray s = response.content[4].toString();
60 d->defaultRights = Acl::rightsFromString(s);
61 int i = 5;
62 while (i < response.content.size()) {
63 s = response.content[i].toString();
64 d->possibleRights.append(Acl::rightsFromString(s));
65 i++;
66 }
67 }
68 }
69}
70
72{
74 d->setIdentifier(identifier);
75}
76
78{
80 return d->identifier();
81}
82
84{
86 return d->defaultRights;
87}
88
90{
92 return d->possibleRights;
93}
94
95#include "moc_listrightsjob.cpp"
Base class for jobs that operate on mailbox ACLs.
Definition acljobbase.h:30
Lists the possible and automatic rights for an identifier on a mailbox.
QList< Acl::Rights > possibleRights()
The rights it is possible to assign to the identifier.
QByteArray identifier()
The identifier that will be looked up.
Acl::Rights defaultRights()
The rights that will always be assigned to the identifier, regardless of the access control list.
void setIdentifier(const QByteArray &identifier)
Sets the identifier that should be looked up.
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
QString name(StandardAction id)
QByteArray & append(QByteArrayView data)
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 Mon Nov 18 2024 12:09:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.