File indexing completed on 2024-05-12 05:17:17

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 SetAclJobPrivate;
0018 
0019 /**
0020  * Sets the rights that correspond to an identifier on a mailbox
0021  *
0022  * This job can only be run when the session is in the
0023  * authenticated (or selected) state.
0024  *
0025  * This job requires that the server supports the ACL
0026  * capability, defined in
0027  * <a href="https://tools.ietf.org/html/rfc4314">RFC 4314</a>.
0028  */
0029 class KIMAP_EXPORT SetAclJob : public AclJobBase
0030 {
0031     Q_OBJECT
0032     Q_DECLARE_PRIVATE(SetAclJob)
0033 
0034     friend class SessionPrivate;
0035 
0036 public:
0037     explicit SetAclJob(Session *session);
0038     ~SetAclJob() override;
0039 
0040     /**
0041      * Sets the rights that will be changed for the identifier
0042      *
0043      * Note that multiple calls to this method will have a
0044      * non-intuitive effect: the @p modifier value of the most
0045      * recent call will be used, but the OR'd-together values
0046      * of all calls to setRights() will be used.
0047      *
0048      * If the server does not recognise any of the rights,
0049      * the job will fail and the ACL for the mailbox will
0050      * remain unchanged.
0051      *
0052      * Note that some rights may be tied together, and must be set
0053      * or removed as a group.  See ListRightsJob::possibleRights()
0054      * for more details.  The server will only set a tied group
0055      * of rights if you have requested that all the rights in that
0056      * group should be set.
0057      *
0058      * @param modifier  determines whether the rights will be
0059      *                  added to the identifier, removed from
0060      *                  the identifier or will replace any
0061      *                  existing rights assigned to the
0062      *                  identifier
0063      * @param rights    the rights to be added, removed or set
0064      */
0065     void setRights(AclModifier modifier, Acl::Rights rights);
0066 
0067     /**
0068      * Sets the identifier the rights will be modified for
0069      *
0070      * The meaning of identifiers depends on the server implementation,
0071      * with the following restrictions:
0072      *
0073      * - "anyone" means any authenticated user, including anonymous
0074      * - an identifier starting with a minus sign ('-') indicates
0075      *   "negative rights": rights that should be taken away from
0076      *   matching users
0077      *
0078      * Other than the above restrictions, ACL identifiers are usually
0079      * IMAP usernames, but could potentially be group names as well.
0080      *
0081      * Note that negative rights override positive rights: if
0082      * "fred" and "-fred" are both assigned the 'w' right, the
0083      * user "fred" will not have the 'w' right.
0084      * @param identifier the identifier to set
0085      */
0086     void setIdentifier(const QByteArray &identifier);
0087     /**
0088      * The identifier that rights will be associated with
0089      */
0090     [[nodiscard]] QByteArray identifier();
0091 
0092 protected:
0093     void doStart() override;
0094 };
0095 
0096 }