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_ACL_H
21#define KIMAP_ACL_H
22
23#include "kimap_export.h"
24
25#include <qglobal.h>
26
27namespace KIMAP {
28
29/**
30 * Operations for dealing with mailbox permissions.
31 */
32namespace Acl {
33
34/**
35 * Possible rights that can be held on a mailbox
36 */
37enum Right {
38 None = 0x000000,
39 /** Mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox */
40 Lookup = 0x000001,
41 /** SELECT the mailbox, perform STATUS */
42 Read = 0x000002,
43 /** Set or clear the \Seen flag on messages in the mailbox, and keep it across sessions */
44 KeepSeen = 0x000004,
45 /** Set or clear flags other than \Seen and \Deleted on messages in the mailbox */
46 Write = 0x000008,
47 /** Perform APPEND and COPY with the mailbox as the target */
48 Insert = 0x000010,
49 /** Send mail to the submission address for the mailbox
50 *
51 * Note: this is not enforced by IMAP4, but is purely advisory.
52 */
53 Post = 0x000020,
54 /** Obsolete as of RFC 4314, replaced by CreateMailbox and DeleteMailbox */
55 Create = 0x000040,
56 /** Create new child mailboxes, or move a mailbox with this mailbox as the new parent
57 *
58 * Note that what constitutes a "child" mailbox is implementation-defined, but
59 * . or / are usually used as separaters.
60 */
61 CreateMailbox = 0x000080,
62 /** Delete or move the mailbox */
63 DeleteMailbox = 0x000100,
64 /** Set or clear the \Deleted flag on messages in the mailbox */
65 DeleteMessage = 0x000200,
66 /** Obsolete as of RFC 4314, replaced by DeleteMessage and Expunge*/
67 Delete = 0x000400,
68 /** View and modify the access control list for the mailbox */
69 Admin = 0x000800,
70 /** Expunge the messages in this mailbox
71 *
72 * Note that if this right is not held on a mailbox, closing the mailbox
73 * (see CloseJob) will succeed, but will not expunge the messages.
74 */
75 Expunge = 0x001000,
76 /** Write shared annotations
77 *
78 * See <a href="http://www.apps.ietf.org/rfc/rfc5257.html" title="IMAP ANNOTATE extension">RFC
79 * 5257</a>. Only supported by servers that implement the ANNOTATE extension.
80 */
81 WriteShared = 0x002000,
82 Custom0 = 0x004000, /**< Server-specific right 0 */
83 Custom1 = 0x008000, /**< Server-specific right 1 */
84 Custom2 = 0x010000, /**< Server-specific right 2 */
85 Custom3 = 0x020000, /**< Server-specific right 3 */
86 Custom4 = 0x040000, /**< Server-specific right 4 */
87 Custom5 = 0x080000, /**< Server-specific right 5 */
88 Custom6 = 0x100000, /**< Server-specific right 6 */
89 Custom7 = 0x200000, /**< Server-specific right 7 */
90 Custom8 = 0x400000, /**< Server-specific right 8 */
91 Custom9 = 0x800000 /**< Server-specific right 9 */
92};
93
94Q_DECLARE_FLAGS( Rights, Right )
95
96/**
97 * Returns a rights mask that has no obsolete members anymore, i.e. obsolete flags are removed and
98 * replaced by their successors.
99 * @param rights set of #Rights flags to normalize
100 * @since 4.6
101 */
102KIMAP_EXPORT Rights normalizedRights( Rights rights );
103
104/**
105 * Returns a rights mask that contains both obsolete and new flags if one of them is set.
106 * @param rights set of #Rights flags to augment
107 * @since 4.6
108 */
109KIMAP_EXPORT Rights denormalizedRights( Rights rights );
110
111/**
112 * Convert a set of rights into text format
113 *
114 * No modifier flag ('+' or '-') will be included.
115 */
116KIMAP_EXPORT QByteArray rightsToString( Rights rights );
117/**
118 * Convert the text form of a set of rights into a Rights bitflag
119 *
120 * Modifier flags ('+' and '-') are ignored, as are any unknown
121 * characters. This method will not complain if you give it
122 * something that is not a list of rights.
123 */
124KIMAP_EXPORT Rights rightsFromString( const QByteArray &string );
125
126}
127}
128
129Q_DECLARE_OPERATORS_FOR_FLAGS( KIMAP::Acl::Rights )
130
131#endif
132