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 #pragma once
0008 
0009 #include "kimap_export.h"
0010 
0011 #include "acljobbase.h"
0012 
0013 namespace KIMAP
0014 {
0015 class Session;
0016 struct Response;
0017 class ListRightsJobPrivate;
0018 
0019 /**
0020  * Lists the possible and automatic rights for
0021  * an identifier on a mailbox
0022  *
0023  * This job can only be run when the session is in the
0024  * authenticated (or selected) state.
0025  *
0026  * The user must have the Acl::Admin permission
0027  * on the mailbox for this job to succeed (see
0028  * MyRightsJob).
0029  *
0030  * This job requires that the server supports the ACL
0031  * capability, defined in
0032  * <a href="https://tools.ietf.org/html/rfc4314">RFC 4314</a>.
0033  */
0034 class KIMAP_EXPORT ListRightsJob : public AclJobBase
0035 {
0036     Q_OBJECT
0037     Q_DECLARE_PRIVATE(ListRightsJob)
0038 
0039     friend class SessionPrivate;
0040 
0041 public:
0042     explicit ListRightsJob(Session *session);
0043     ~ListRightsJob() override;
0044 
0045     /**
0046      * Sets the identifier that should be looked up
0047      *
0048      * The meaning of identifiers depends on the server implementation,
0049      * with the following restrictions:
0050      *
0051      * - "anyone" means any authenticated user, including anonymous
0052      * - an identifier starting with a minus sign ('-') indicates
0053      *   "negative rights": rights that should be taken away from
0054      *   matching users
0055      *
0056      * Other than the above restrictions, ACL identifiers are usually
0057      * IMAP usernames, but could potentially be group names as well.
0058      *
0059      * Note that negative rights override positive rights: if
0060      * "fred" and "-fred" are both assigned the 'w' right, the
0061      * user "fred" will not have the 'w' right.
0062      *
0063      * @param identifier  the identifier to list the rights for
0064      */
0065     void setIdentifier(const QByteArray &identifier);
0066     /**
0067      * The identifier that will be looked up
0068      */
0069     [[nodiscard]] QByteArray identifier();
0070 
0071     /**
0072      * The rights that will always be assigned to the identifier,
0073      * regardless of the access control list.
0074      *
0075      * For example, under the UNIX permission model, the owner
0076      * of a mailbox will always have the Acl::Admin right.
0077      */
0078     [[nodiscard]] Acl::Rights defaultRights();
0079 
0080     /**
0081      * The rights it is possible to assign to the identifier.
0082      *
0083      * The rights are grouped by those that are tied together.
0084      * For each set of rights in the returned list, either all
0085      * or none of those rights may be set, but not only some of
0086      * them.
0087      *
0088      * For example, under the UNIX permission model, the following
0089      * rights are all controlled by the "write" flag, and hence
0090      * must either all be set or all be not set:
0091      * - Acl::KeepSeen
0092      * - Acl::Write
0093      * - Acl::Insert
0094      * - Acl::DeleteMessage
0095      * - Acl::Expunge
0096      */
0097     [[nodiscard]] QList<Acl::Rights> possibleRights();
0098 
0099 protected:
0100     void doStart() override;
0101     void handleResponse(const Response &response) override;
0102 };
0103 
0104 }