summaryrefslogtreecommitdiff
path: root/kimap/acl.h
blob: 40e738fee0d26dae290b94ee148d1a0953356780 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
    Copyright (c) 2009 Andras Mantia <amantia@kde.org>

    This library is free software; you can redistribute it and/or modify it
    under the terms of the GNU Library General Public License as published by
    the Free Software Foundation; either version 2 of the License, or (at your
    option) any later version.

    This library is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
    License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to the
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
*/

#ifndef KIMAP_ACL_H
#define KIMAP_ACL_H

#include "kimap_export.h"

namespace KIMAP {

/**
 * Operations for dealing with mailbox permissions.
 */
namespace Acl {

/**
 * Possible rights that can be held on a mailbox
 */
enum Right {
  None          = 0x000000,
  /** Mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox */
  Lookup        = 0x000001,
  /** SELECT the mailbox, perform STATUS */
  Read          = 0x000002,
  /** Set or clear the \Seen flag on messages in the mailbox, and keep it across sessions */
  KeepSeen      = 0x000004,
  /** Set or clear flags other than \Seen and \Deleted on messages in the mailbox */
  Write         = 0x000008,
  /** Perform APPEND and COPY with the mailbox as the target */
  Insert        = 0x000010,
  /** Send mail to the submission address for the mailbox
   *
   * Note: this is not enforced by IMAP4, but is purely advisory.
   */
  Post          = 0x000020,
  /** Obsolete as of RFC 4314, replaced by CreateMailbox and DeleteMailbox */
  Create        = 0x000040,
  /** Create new child mailboxes, or move a mailbox with this mailbox as the new parent
   *
   * Note that what constitutes a "child" mailbox is implementation-defined, but
   * . or / are usually used as separaters.
   */
  CreateMailbox = 0x000080,
  /** Delete or move the mailbox */
  DeleteMailbox = 0x000100,
  /** Set or clear the \Deleted flag on messages in the mailbox */
  DeleteMessage = 0x000200,
  /** Obsolete as of RFC 4314, replaced by DeleteMessage and Expunge*/
  Delete        = 0x000400,
  /** View and modify the access control list for the mailbox */
  Admin         = 0x000800,
  /** Expunge the messages in this mailbox
   *
   * Note that if this right is not held on a mailbox, closing the mailbox
   * (see CloseJob) will succeed, but will not expunge the messages.
   */
  Expunge       = 0x001000,
  /** Write shared annotations
   *
   * See <a href="http://www.apps.ietf.org/rfc/rfc5257.html" title="IMAP ANNOTATE extension">RFC
   * 5257</a>.  Only supported by servers that implement the ANNOTATE extension.
   */
  WriteShared   = 0x002000,
  Custom0       = 0x004000, /**< Server-specific right 0 */
  Custom1       = 0x008000, /**< Server-specific right 1 */
  Custom2       = 0x010000, /**< Server-specific right 2 */
  Custom3       = 0x020000, /**< Server-specific right 3 */
  Custom4       = 0x040000, /**< Server-specific right 4 */
  Custom5       = 0x080000, /**< Server-specific right 5 */
  Custom6       = 0x100000, /**< Server-specific right 6 */
  Custom7       = 0x200000, /**< Server-specific right 7 */
  Custom8       = 0x400000, /**< Server-specific right 8 */
  Custom9       = 0x800000  /**< Server-specific right 9 */
};

Q_DECLARE_FLAGS(Rights, Right)

/**
 * Returns a rights mask that has no obsolete members anymore, i.e. obsolete flags are removed and
 * replaced by their successors.
 * @since 4.6
 */
KIMAP_EXPORT Rights normalizedRights( Rights rights );

/**
 * Returns a rights mask that contains both obsolete and new flags if one of them is set.
 * @since 4.6
 */
KIMAP_EXPORT Rights denormalizedRights( Rights rights );

/**
 * Convert a set of rights into text format
 *
 * No modifier flag ('+' or '-') will be included.
 */
KIMAP_EXPORT QByteArray rightsToString( Rights rights );
/**
 * Convert the text form of a set of rights into a Rights bitflag
 *
 * Modifier flags ('+' and '-') are ignored, as are any unknown
 * characters.  This method will not complain if you give it
 * something that is not a list of rights.
 */
KIMAP_EXPORT Rights rightsFromString( const QByteArray &string );

}
}

Q_DECLARE_OPERATORS_FOR_FLAGS( KIMAP::Acl::Rights )

#endif