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

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_MYRIGHTSJOB_H
0021 #define KIMAP2_MYRIGHTSJOB_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 MyRightsJobPrivate;
0033 
0034 /**
0035  * Determine the rights the currently-logged-in user
0036  * has on the current mailbox.
0037  *
0038  * This should take into account the full access control
0039  * list.
0040  *
0041  * This job can only be run when the session is in the
0042  * authenticated (or selected) state.
0043  *
0044  * The current user must have one of the following rights
0045  * on the mailbox for this job to succeed:
0046  * - Acl::Lookup
0047  * - Acl::Read
0048  * - Acl::Insert
0049  * - Acl::CreateMailbox
0050  * - Acl::DeleteMailbox
0051  * - Acl::Admin
0052  *
0053  * This job requires that the server supports the ACL
0054  * capability, defined in
0055  * <a href="http://www.apps.ietf.org/rfc/rfc4314.html">RFC 4314</a>.
0056  */
0057 class KIMAP2_EXPORT MyRightsJob : public AclJobBase
0058 {
0059     Q_OBJECT
0060     Q_DECLARE_PRIVATE(MyRightsJob)
0061 
0062     friend class SessionPrivate;
0063 
0064 public:
0065     explicit MyRightsJob(Session *session);
0066     virtual ~MyRightsJob();
0067 
0068     /**
0069      * Check whether the current user has the a particular right
0070      * on the mailbox.
0071      *
0072      * The result of this method is undefined if the job has
0073      * not yet completed.
0074      *
0075      * @param right       the right to check for
0076      */
0077     bool hasRightEnabled(Acl::Right right);
0078     /**
0079      * Get the rights for the current user on the mailbox.
0080      *
0081      * The result of this method is undefined if the job has
0082      * not yet completed.
0083      */
0084     Acl::Rights rights();
0085 
0086 protected:
0087     void doStart() Q_DECL_OVERRIDE;
0088     void handleResponse(const Message &response) Q_DECL_OVERRIDE;
0089 
0090 };
0091 
0092 }
0093 
0094 #endif