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

0001 /*
0002     Copyright (c) 2009 Andras Mantia <amantia@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or modify it
0005     under the terms of the GNU Library General Public License as published by
0006     the Free Software Foundation; either version 2 of the License, or (at your
0007     option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful, but WITHOUT
0010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
0012     License for more details.
0013 
0014     You should have received a copy of the GNU Library General Public License
0015     along with this library; see the file COPYING.LIB.  If not, write to the
0016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0017     02110-1301, USA.
0018 */
0019 
0020 #ifndef KIMAP2_SETACLJOB_H
0021 #define KIMAP2_SETACLJOB_H
0022 
0023 #include "kimap2_export.h"
0024 
0025 #include "acljobbase.h"
0026 
0027 namespace KIMAP2
0028 {
0029 
0030 class Session;
0031 struct Message;
0032 class SetAclJobPrivate;
0033 
0034 /**
0035  * Sets the rights that correspond to an identifier on a mailbox
0036  *
0037  * This job can only be run when the session is in the
0038  * authenticated (or selected) state.
0039  *
0040  * This job requires that the server supports the ACL
0041  * capability, defined in
0042  * <a href="http://www.apps.ietf.org/rfc/rfc4314.html">RFC 4314</a>.
0043  */
0044 class KIMAP2_EXPORT SetAclJob : public AclJobBase
0045 {
0046     Q_OBJECT
0047     Q_DECLARE_PRIVATE(SetAclJob)
0048 
0049     friend class SessionPrivate;
0050 
0051 public:
0052     explicit SetAclJob(Session *session);
0053     virtual ~SetAclJob();
0054 
0055     /**
0056      * Sets the rights that will be changed for the identifier
0057      *
0058      * Note that multiple calls to this method will have a
0059      * non-intuitive effect: the @p modifier value of the most
0060      * recent call will be used, but the OR'd-together values
0061      * of all calls to setRights() will be used.
0062      *
0063      * If the server does not recognise any of the rights,
0064      * the job will fail and the ACL for the mailbox will
0065      * remain unchanged.
0066      *
0067      * Note that some rights may be tied together, and must be set
0068      * or removed as a group.  See ListRightsJob::possibleRights()
0069      * for more details.  The server will only set a tied group
0070      * of rights if you have requested that all the rights in that
0071      * group should be set.
0072      *
0073      * @param modifier  determines whether the rights will be
0074      *                  added to the identifier, removed from
0075      *                  the identifier or will replace any
0076      *                  existing rights assigned to the
0077      *                  identifier
0078      * @param rights    the rights to be added, removed or set
0079      */
0080     void setRights(AclModifier modifier, Acl::Rights rights);
0081 
0082     /**
0083      * Sets the identifier the rights will be modified for
0084      *
0085      * The meaning of identifiers depends on the server implementation,
0086      * with the following restrictions:
0087      *
0088      * - "anyone" means any authenticated user, including anonymous
0089      * - an identifier starting with a minus sign ('-') indicates
0090      *   "negative rights": rights that should be taken away from
0091      *   matching users
0092      *
0093      * Other than the above restrictions, ACL identifiers are usually
0094      * IMAP usernames, but could potentially be group names as well.
0095      *
0096      * Note that negative rights override positive rights: if
0097      * "fred" and "-fred" are both assigned the 'w' right, the
0098      * user "fred" will not have the 'w' right.
0099      * @param identifier the identifier to set
0100      */
0101     void setIdentifier(const QByteArray &identifier);
0102     /**
0103      * The identifier that rights will be associated with
0104      */
0105     QByteArray identifier();
0106 
0107 protected:
0108     void doStart() Q_DECL_OVERRIDE;
0109 
0110 };
0111 
0112 }
0113 
0114 #endif