• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

KIMAP Library

  • kimap
acl.cpp
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#include "acl.h"
21
22#include <QtCore/QByteArray>
23#include <QtCore/QMap>
24#include <KDE/KGlobal>
25
26namespace KIMAP {
27namespace Acl {
28
29class RightsMap
30{
31 public:
32 RightsMap() {
33 map['l'] = Lookup;
34 map['r'] = Read;
35 map['s'] = KeepSeen;
36 map['w'] = Write;
37 map['i'] = Insert;
38 map['p'] = Post;
39 map['c'] = Create; //TODO: obsolete, keep it?
40 map['d'] = Delete; //TODO: obsolete, keep it?
41 map['k'] = CreateMailbox;
42 map['x'] = DeleteMailbox;
43 map['t'] = DeleteMessage;
44 map['e'] = Expunge;
45 map['a'] = Admin;
46 map['n'] = WriteShared;
47 map['0'] = Custom0;
48 map['1'] = Custom1;
49 map['2'] = Custom2;
50 map['3'] = Custom3;
51 map['4'] = Custom4;
52 map['5'] = Custom5;
53 map['6'] = Custom6;
54 map['7'] = Custom7;
55 map['8'] = Custom8;
56 map['9'] = Custom9;
57 }
58
59 QMap<char, Right> map;
60};
61
62K_GLOBAL_STATIC( RightsMap, globalRights )
63
64}
65}
66
67KIMAP::Acl::Rights KIMAP::Acl::rightsFromString( const QByteArray &string )
68{
69 Rights result;
70
71 if ( string.isEmpty() ) {
72 return result;
73 }
74
75 int pos = 0;
76 if ( string[0] == '+' || string[0] == '-' ) { // Skip modifier if any
77 pos++;
78 }
79
80 for ( int i = pos; i < string.size(); i++ ) {
81 if ( globalRights->map.contains( string[i] ) ) {
82 result|= globalRights->map[string[i]];
83 }
84 }
85
86 return result;
87}
88
89QByteArray KIMAP::Acl::rightsToString( Rights rights )
90{
91 QByteArray result;
92
93 for ( int right = Lookup; right <= Custom9; right <<= 1 ) {
94 if ( rights & right ) {
95 result += globalRights->map.key( (Right)right );
96 }
97 }
98
99 return result;
100}
101
102KIMAP::Acl::Rights KIMAP::Acl::normalizedRights( KIMAP::Acl::Rights rights )
103{
104 Rights normalized = rights;
105 if ( normalized & Create ) {
106 normalized |= ( CreateMailbox | DeleteMailbox );
107 normalized &= ~Create;
108 }
109 if ( normalized & Delete ) {
110 normalized |= ( DeleteMessage | Expunge );
111 normalized &= ~Delete;
112 }
113 return normalized;
114}
115
116KIMAP::Acl::Rights KIMAP::Acl::denormalizedRights( KIMAP::Acl::Rights rights )
117{
118 Rights denormalized = normalizedRights( rights );
119 if ( denormalized & ( CreateMailbox | DeleteMailbox ) ) {
120 denormalized |= Create;
121 }
122 if ( denormalized & ( DeleteMessage | Expunge ) ) {
123 denormalized |= Delete;
124 }
125 return denormalized;
126}
KIMAP::Acl::rightsFromString
Rights rightsFromString(const QByteArray &string)
Convert the text form of a set of rights into a Rights bitflag.
Definition: acl.cpp:67
KIMAP::Acl::rightsToString
QByteArray rightsToString(Rights rights)
Convert a set of rights into text format.
Definition: acl.cpp:89
KIMAP::Acl::Right
Right
Possible rights that can be held on a mailbox.
Definition: acl.h:37
KIMAP::Acl::Expunge
@ Expunge
Expunge the messages in this mailbox.
Definition: acl.h:75
KIMAP::Acl::WriteShared
@ WriteShared
Write shared annotations.
Definition: acl.h:81
KIMAP::Acl::CreateMailbox
@ CreateMailbox
Create new child mailboxes, or move a mailbox with this mailbox as the new parent.
Definition: acl.h:61
KIMAP::Acl::Delete
@ Delete
Obsolete as of RFC 4314, replaced by DeleteMessage and Expunge.
Definition: acl.h:67
KIMAP::Acl::Custom3
@ Custom3
Server-specific right 3.
Definition: acl.h:85
KIMAP::Acl::KeepSeen
@ KeepSeen
Set or clear the \Seen flag on messages in the mailbox, and keep it across sessions.
Definition: acl.h:44
KIMAP::Acl::Custom9
@ Custom9
Server-specific right 9.
Definition: acl.h:91
KIMAP::Acl::Admin
@ Admin
View and modify the access control list for the mailbox.
Definition: acl.h:69
KIMAP::Acl::Create
@ Create
Obsolete as of RFC 4314, replaced by CreateMailbox and DeleteMailbox.
Definition: acl.h:55
KIMAP::Acl::Insert
@ Insert
Perform APPEND and COPY with the mailbox as the target.
Definition: acl.h:48
KIMAP::Acl::Custom5
@ Custom5
Server-specific right 5.
Definition: acl.h:87
KIMAP::Acl::Custom0
@ Custom0
Server-specific right 0.
Definition: acl.h:82
KIMAP::Acl::Custom2
@ Custom2
Server-specific right 2.
Definition: acl.h:84
KIMAP::Acl::Lookup
@ Lookup
Mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox.
Definition: acl.h:40
KIMAP::Acl::Custom1
@ Custom1
Server-specific right 1.
Definition: acl.h:83
KIMAP::Acl::Custom4
@ Custom4
Server-specific right 4.
Definition: acl.h:86
KIMAP::Acl::Custom7
@ Custom7
Server-specific right 7.
Definition: acl.h:89
KIMAP::Acl::Post
@ Post
Send mail to the submission address for the mailbox.
Definition: acl.h:53
KIMAP::Acl::DeleteMessage
@ DeleteMessage
Set or clear the \Deleted flag on messages in the mailbox.
Definition: acl.h:65
KIMAP::Acl::Custom6
@ Custom6
Server-specific right 6.
Definition: acl.h:88
KIMAP::Acl::Read
@ Read
SELECT the mailbox, perform STATUS.
Definition: acl.h:42
KIMAP::Acl::Write
@ Write
Set or clear flags other than \Seen and \Deleted on messages in the mailbox.
Definition: acl.h:46
KIMAP::Acl::Custom8
@ Custom8
Server-specific right 8.
Definition: acl.h:90
KIMAP::Acl::DeleteMailbox
@ DeleteMailbox
Delete or move the mailbox.
Definition: acl.h:63
KIMAP::Acl::denormalizedRights
Rights denormalizedRights(Rights rights)
Returns a rights mask that contains both obsolete and new flags if one of them is set.
KIMAP::Acl::normalizedRights
Rights normalizedRights(Rights rights)
Returns a rights mask that has no obsolete members anymore, i.e.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIMAP Library

Skip menu "KIMAP Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal