• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KIMAP Library

acl.cpp

00001 /*
00002     Copyright (c) 2009 Andras Mantia <amantia@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #include "acl.h"
00021 
00022 #include <QtCore/QByteArray>
00023 #include <QtCore/QMap>
00024 #include <KDE/KGlobal>
00025 
00026 namespace KIMAP {
00027 namespace Acl {
00028 
00029 class RightsMap
00030 {
00031   public:
00032     RightsMap()
00033     {
00034       map['l'] = Lookup;
00035       map['r'] = Read;
00036       map['s'] = KeepSeen;
00037       map['w'] = Write;
00038       map['i'] = Insert;
00039       map['p'] = Post;
00040       map['c'] = Create; //TODO: obsolete, keep it?
00041       map['d'] = Delete; //TODO: obsolete, keep it?
00042       map['k'] = CreateMailbox;
00043       map['x'] = DeleteMailbox;
00044       map['t'] = DeleteMessage;
00045       map['e'] = Expunge;
00046       map['a'] = Admin;
00047       map['n'] = WriteShared;
00048       map['0'] = Custom0;
00049       map['1'] = Custom1;
00050       map['2'] = Custom2;
00051       map['3'] = Custom3;
00052       map['4'] = Custom4;
00053       map['5'] = Custom5;
00054       map['6'] = Custom6;
00055       map['7'] = Custom7;
00056       map['8'] = Custom8;
00057       map['9'] = Custom9;
00058     }
00059 
00060     QMap<char, Right> map;
00061 };
00062 
00063 K_GLOBAL_STATIC(RightsMap, globalRights)
00064 
00065 }
00066 }
00067 
00068 KIMAP::Acl::Rights KIMAP::Acl::rightsFromString( const QByteArray &string )
00069 {
00070   Rights result;
00071 
00072   if ( string.isEmpty() )
00073     return result;
00074 
00075   int pos = 0;
00076   if ( string[0] == '+' || string[0]== '-') { // Skip modifier if any
00077     pos++;
00078   }
00079 
00080   for ( int i = pos; i < string.size(); i++ ) {
00081     if ( globalRights->map.contains( string[i] ) ) {
00082       result|= globalRights->map[string[i]];
00083     }
00084   }
00085 
00086   return result;
00087 }
00088 
00089 QByteArray KIMAP::Acl::rightsToString( Rights rights )
00090 {
00091   QByteArray result;
00092 
00093   for ( int right = Lookup; right<=Custom9; right<<=1 ) {
00094     if ( rights & right ) {
00095       result+= globalRights->map.key( (Right)right );
00096     }
00097   }
00098 
00099   return result;
00100 }

KIMAP Library

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal