kacl.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 2005 Till Adam <adam@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public 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 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef __kacl_h__ 00021 #define __kacl_h__ 00022 00023 #include <sys/types.h> 00024 #include <kio/global.h> 00025 00026 typedef QPair<TQString, unsigned short> ACLUserPermissions; 00027 typedef TQValueList<ACLUserPermissions> ACLUserPermissionsList; 00028 typedef TQValueListIterator<ACLUserPermissions> ACLUserPermissionsIterator; 00029 typedef TQValueListConstIterator<ACLUserPermissions> ACLUserPermissionsConstIterator; 00030 00031 typedef QPair<TQString, unsigned short> ACLGroupPermissions; 00032 typedef TQValueList<ACLGroupPermissions> ACLGroupPermissionsList; 00033 typedef TQValueListIterator<ACLGroupPermissions> ACLGroupPermissionsIterator; 00034 typedef TQValueListConstIterator<ACLGroupPermissions> ACLGroupPermissionsConstIterator; 00035 00042 class KIO_EXPORT KACL 00043 { 00044 public: 00049 KACL( const TQString & aclString ); 00050 00052 KACL( const KACL& rhs ); 00053 00058 KACL( mode_t basicPermissions ); 00059 00064 KACL(); 00065 00066 virtual ~KACL(); 00067 00068 KACL& operator=( const KACL& rhs ) { 00069 if ( this != &rhs ) 00070 setACL( rhs.asString() ); 00071 return *this; 00072 } 00073 00074 bool operator==( const KACL& rhs ) const; 00075 00076 bool operator!=( const KACL& rhs ) const { 00077 return !operator==( rhs ); 00078 } 00079 00084 bool isValid() const; 00085 00091 unsigned short ownerPermissions() const; 00092 00095 bool setOwnerPermissions( unsigned short ); 00096 00098 unsigned short owningGroupPermissions() const; 00099 00102 bool setOwningGroupPermissions( unsigned short ); 00103 00105 unsigned short othersPermissions() const; 00106 00109 bool setOthersPermissions( unsigned short ); 00110 00112 mode_t basePermissions() const; 00113 00121 bool isExtended() const; 00122 00127 unsigned short maskPermissions( bool &exists ) const; 00128 00133 bool setMaskPermissions( unsigned short ); 00134 00140 unsigned short namedUserPermissions( const TQString& name, bool *exists ) const; 00141 00142 00146 bool setNamedUserPermissions( const TQString& name, unsigned short ); 00147 00152 ACLUserPermissionsList allUserPermissions() const; 00153 00158 bool setAllUserPermissions( const ACLUserPermissionsList &list ); 00159 00165 unsigned short namedGroupPermissions( const TQString& name, bool *exists ) const; 00166 00170 bool setNamedGroupPermissions( const TQString& name, unsigned short ); 00171 00177 ACLGroupPermissionsList allGroupPermissions() const; 00182 bool setAllGroupPermissions( const ACLGroupPermissionsList & ); 00183 00187 bool setACL( const TQString &aclStr ); 00188 00193 TQString asString() const; 00194 00195 protected: 00196 virtual void virtual_hook( int id, void* data ); 00197 private: 00198 class KACLPrivate; 00199 KACLPrivate * d; 00200 KIO_EXPORT friend TQDataStream & operator<< ( TQDataStream & s, const KACL & a ); 00201 KIO_EXPORT friend TQDataStream & operator>> ( TQDataStream & s, KACL & a ); 00202 }; 00203 00204 KIO_EXPORT TQDataStream & operator<< ( TQDataStream & s, const KACL & a ); 00205 KIO_EXPORT TQDataStream & operator>> ( TQDataStream & s, KACL & a ); 00206 00207 #endif