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 MyRightsJobPrivate;
0018 
0019 /**
0020  * Determine the rights the currently-logged-in user
0021  * has on the current mailbox.
0022  *
0023  * This should take into account the full access control
0024  * list.
0025  *
0026  * This job can only be run when the session is in the
0027  * authenticated (or selected) state.
0028  *
0029  * The current user must have one of the following rights
0030  * on the mailbox for this job to succeed:
0031  * - Acl::Lookup
0032  * - Acl::Read
0033  * - Acl::Insert
0034  * - Acl::CreateMailbox
0035  * - Acl::DeleteMailbox
0036  * - Acl::Admin
0037  *
0038  * This job requires that the server supports the ACL
0039  * capability, defined in
0040  * <a href="https://tools.ietf.org/html/rfc4314">RFC 4314</a>.
0041  */
0042 class KIMAP_EXPORT MyRightsJob : public AclJobBase
0043 {
0044     Q_OBJECT
0045     Q_DECLARE_PRIVATE(MyRightsJob)
0046 
0047     friend class SessionPrivate;
0048 
0049 public:
0050     explicit MyRightsJob(Session *session);
0051     ~MyRightsJob() override;
0052 
0053     /**
0054      * Check whether the current user has the a particular right
0055      * on the mailbox.
0056      *
0057      * The result of this method is undefined if the job has
0058      * not yet completed.
0059      *
0060      * @param right       the right to check for
0061      */
0062     [[nodiscard]] bool hasRightEnabled(Acl::Right right);
0063     /**
0064      * Get the rights for the current user on the mailbox.
0065      *
0066      * The result of this method is undefined if the job has
0067      * not yet completed.
0068      */
0069     [[nodiscard]] Acl::Rights rights();
0070 
0071 protected:
0072     void doStart() override;
0073     void handleResponse(const Response &response) override;
0074 };
0075 
0076 }