1/*
2 Copyright (c) 2009 Andras Mantia <amantia@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#ifndef KIMAP_MYRIGHTSJOB_H
21#define KIMAP_MYRIGHTSJOB_H
22
23#include "kimap_export.h"
24
25#include "acljobbase.h"
26
27namespace KIMAP {
28
29class Session;
30struct Message;
31class MyRightsJobPrivate;
32
33/**
34 * Determine the rights the currently-logged-in user
35 * has on the current mailbox.
36 *
37 * This should take into account the full access control
38 * list.
39 *
40 * This job can only be run when the session is in the
41 * authenticated (or selected) state.
42 *
43 * The current user must have one of the following rights
44 * on the mailbox for this job to succeed:
45 * - Acl::Lookup
46 * - Acl::Read
47 * - Acl::Insert
48 * - Acl::CreateMailbox
49 * - Acl::DeleteMailbox
50 * - Acl::Admin
51 *
52 * This job requires that the server supports the ACL
53 * capability, defined in
54 * <a href="http://www.apps.ietf.org/rfc/rfc4314.html">RFC 4314</a>.
55 */
56class KIMAP_EXPORT MyRightsJob : public AclJobBase
57{
58 Q_OBJECT
59 Q_DECLARE_PRIVATE( MyRightsJob )
60
61 friend class SessionPrivate;
62
63 public:
64 explicit MyRightsJob( Session *session );
65 virtual ~MyRightsJob();
66
67 /**
68 * Check whether the current user has the a particular right
69 * on the mailbox.
70 *
71 * The result of this method is undefined if the job has
72 * not yet completed.
73 *
74 * @param right the right to check for
75 */
76 bool hasRightEnabled(Acl::Right right);
77 /**
78 * Get the rights for the current user on the mailbox.
79 *
80 * The result of this method is undefined if the job has
81 * not yet completed.
82 */
83 Acl::Rights rights();
84
85 protected:
86 virtual void doStart();
87 virtual void handleResponse(const Message &response);
88
89};
90
91}
92
93#endif
94