2
* Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
3
* Copyright (c) 2010 Tobias Koenig <tokoe@kdab.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
#include "aclutils_p.h"
24
using namespace PimCommon;
27
KIMAP::Acl::Rights permissions;
28
const char *userString;
29
} standardPermissions[] = {
31
I18N_NOOP2( "Permissions", "None" ) },
33
{ KIMAP::Acl::Lookup | KIMAP::Acl::Read | KIMAP::Acl::KeepSeen,
34
I18N_NOOP2( "Permissions", "Read" ) },
36
{ KIMAP::Acl::Lookup | KIMAP::Acl::Read | KIMAP::Acl::KeepSeen |
37
KIMAP::Acl::Insert | KIMAP::Acl::Post,
38
I18N_NOOP2( "Permissions", "Append" ) },
40
{ KIMAP::Acl::Lookup | KIMAP::Acl::Read | KIMAP::Acl::KeepSeen |
41
KIMAP::Acl::Insert | KIMAP::Acl::Post | KIMAP::Acl::Write |
42
KIMAP::Acl::CreateMailbox | KIMAP::Acl::DeleteMailbox |
43
KIMAP::Acl::DeleteMessage | KIMAP::Acl::Expunge,
44
I18N_NOOP2( "Permissions", "Write" ) },
46
{ KIMAP::Acl::Lookup | KIMAP::Acl::Read | KIMAP::Acl::KeepSeen |
47
KIMAP::Acl::Insert | KIMAP::Acl::Post | KIMAP::Acl::Write |
48
KIMAP::Acl::CreateMailbox | KIMAP::Acl::DeleteMailbox |
49
KIMAP::Acl::DeleteMessage | KIMAP::Acl::Expunge | KIMAP::Acl::Admin,
50
I18N_NOOP2( "Permissions", "All" ) }
53
uint AclUtils::standardPermissionsCount()
55
return ( sizeof( standardPermissions ) / sizeof( *standardPermissions ) );
58
KIMAP::Acl::Rights AclUtils::permissionsForIndex( uint index )
60
Q_ASSERT( index < standardPermissionsCount() );
62
return standardPermissions[ index ].permissions;
65
int AclUtils::indexForPermissions( KIMAP::Acl::Rights permissions )
67
const uint maxSize( sizeof( standardPermissions ) / sizeof( *standardPermissions ) );
68
for ( uint i = 0; i < maxSize; ++i ) {
69
if ( KIMAP::Acl::normalizedRights( permissions ) == standardPermissions[i].permissions ) {
77
QString AclUtils::permissionsToUserString( KIMAP::Acl::Rights permissions )
79
const uint maxSize( sizeof( standardPermissions ) / sizeof( *standardPermissions ) );
80
for ( uint i = 0; i < maxSize; ++i ) {
81
if ( KIMAP::Acl::normalizedRights( permissions ) == standardPermissions[i].permissions ) {
82
return i18nc( "Permissions", standardPermissions[ i ].userString );
86
return i18n( "Custom Permissions (%1)",
87
QString::fromLatin1( KIMAP::Acl::rightsToString( permissions ) ) );