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

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_LISTRIGHTSJOB_H
0021 #define KIMAP2_LISTRIGHTSJOB_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 ListRightsJobPrivate;
0033 
0034 /**
0035  * Lists the possible and automatic rights for
0036  * an identifier on a mailbox
0037  *
0038  * This job can only be run when the session is in the
0039  * authenticated (or selected) state.
0040  *
0041  * The user must have the Acl::Admin permission
0042  * on the mailbox for this job to succeed (see
0043  * MyRightsJob).
0044  *
0045  * This job requires that the server supports the ACL
0046  * capability, defined in
0047  * <a href="http://www.apps.ietf.org/rfc/rfc4314.html">RFC 4314</a>.
0048  */
0049 class KIMAP2_EXPORT ListRightsJob : public AclJobBase
0050 {
0051     Q_OBJECT
0052     Q_DECLARE_PRIVATE(ListRightsJob)
0053 
0054     friend class SessionPrivate;
0055 
0056 public:
0057     explicit ListRightsJob(Session *session);
0058     virtual ~ListRightsJob();
0059 
0060     /**
0061      * Sets the identifier that should be looked up
0062      *
0063      * The meaning of identifiers depends on the server implementation,
0064      * with the following restrictions:
0065      *
0066      * - "anyone" means any authenticated user, including anonymous
0067      * - an identifier starting with a minus sign ('-') indicates
0068      *   "negative rights": rights that should be taken away from
0069      *   matching users
0070      *
0071      * Other than the above restrictions, ACL identifiers are usually
0072      * IMAP usernames, but could potentially be group names as well.
0073      *
0074      * Note that negative rights override positive rights: if
0075      * "fred" and "-fred" are both assigned the 'w' right, the
0076      * user "fred" will not have the 'w' right.
0077      *
0078      * @param identifier  the identifier to list the rights for
0079      */
0080     void setIdentifier(const QByteArray &identifier);
0081     /**
0082      * The identifier that will be looked up
0083      */
0084     QByteArray identifier();
0085 
0086     /**
0087      * The rights that will always be assigned to the identifier,
0088      * regardless of the access control list.
0089      *
0090      * For example, under the UNIX permission model, the owner
0091      * of a mailbox will always have the Acl::Admin right.
0092      */
0093     Acl::Rights defaultRights();
0094 
0095     /**
0096      * The rights it is possible to assign to the identifier.
0097      *
0098      * The rights are grouped by those that are tied together.
0099      * For each set of rights in the returned list, either all
0100      * or none of those rights may be set, but not only some of
0101      * them.
0102      *
0103      * For example, under the UNIX permission model, the following
0104      * rights are all controlled by the "write" flag, and hence
0105      * must either all be set or all be not set:
0106      * - Acl::KeepSeen
0107      * - Acl::Write
0108      * - Acl::Insert
0109      * - Acl::DeleteMessage
0110      * - Acl::Expunge
0111      */
0112     QList<Acl::Rights> possibleRights();
0113 
0114 protected:
0115     void doStart() Q_DECL_OVERRIDE;
0116     void handleResponse(const Message &response) Q_DECL_OVERRIDE;
0117 
0118 };
0119 
0120 }
0121 
0122 #endif