kmail

acljobs.h
1 /*
2  * acljobs.h
3  *
4  * Copyright (c) 2004 David Faure <faure@kde.org>
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * In addition, as a special exception, the copyright holders give
21  * permission to link the code of this program with any edition of
22  * the TQt library by Trolltech AS, Norway (or with modified versions
23  * of TQt that use the same license as TQt), and distribute linked
24  * combinations including the two. You must obey the GNU General
25  * Public License in all respects for all of the code used other than
26  * TQt. If you modify this file, you may extend this exception to
27  * your version of the file, but you are not obligated to do so. If
28  * you do not wish to do so, delete this exception statement from
29  * your version.
30  */
31 
32 #ifndef KMACLJOBS_H
33 #define KMACLJOBS_H
34 
35 #include <tdeio/job.h>
36 #include <tqvaluevector.h>
37 
38 namespace KMail {
39 
41  struct ACLListEntry {
42  ACLListEntry() {} // for TQValueVector
43  ACLListEntry( const TQString& u, const TQString& irl, int p )
44  : userId( u ), internalRightsList( irl ), permissions( p ), changed( false ) {}
45  TQString userId;
46  TQString internalRightsList;
48  bool changed;
49  };
50 
51  typedef TQValueVector<ACLListEntry> ACLList;
52 
60 namespace ACLJobs {
61 
62  // Used by KMFolderCachedImap and KMFolderImap, no better place for that yet, until we have a
63  // common base class for both
66  Ok,
68  };
69 
74  List = 1,
75  Read = 2,
76  WriteFlags = 4,
77  Insert = 8,
78  Create = 16,
79  Delete = 32,
80  Administer = 64,
81  Post = 128,
82  WriteSeenFlag = 256,
83  // alias for "all read/write permissions except admin"
84  AllWrite = List | Read | WriteFlags | Insert | Post | Create | Delete | WriteSeenFlag,
85  // alias for "all permissions"
86  All = List | Read | WriteFlags | Insert | Post | Create | Delete | Administer | WriteSeenFlag
87  };
89  TDEIO::SimpleJob* setACL( TDEIO::Slave* slave, const KURL& url, const TQString& user, unsigned int permissions );
90 
91  class DeleteACLJob;
93  DeleteACLJob* deleteACL( TDEIO::Slave* slave, const KURL& url, const TQString& user );
94 
95  class GetACLJob;
97  GetACLJob* getACL( TDEIO::Slave* slave, const KURL& url );
98 
99  class GetUserRightsJob;
101  GetUserRightsJob* getUserRights( TDEIO::Slave* slave, const KURL& url );
102 
103  class MultiSetACLJob;
105  MultiSetACLJob* multiSetACL( TDEIO::Slave* slave, const KURL& url, const ACLList& acl );
106 
108  class GetACLJob : public TDEIO::SimpleJob
109  {
110  TQ_OBJECT
111 
112  public:
113  GetACLJob( const KURL& url, const TQByteArray &packedArgs,
114  bool showProgressInfo );
115 
116  const ACLList& entries() const { return m_entries; }
117 
118  protected slots:
119  void slotInfoMessage( TDEIO::Job*, const TQString& );
120  private:
121  ACLList m_entries;
122  };
123 
125  class GetUserRightsJob : public TDEIO::SimpleJob
126  {
127  TQ_OBJECT
128 
129  public:
130  GetUserRightsJob( const KURL& url, const TQByteArray &packedArgs,
131  bool showProgressInfo );
132  unsigned int permissions() const { return m_permissions; }
133 
134  protected slots:
135  void slotInfoMessage( TDEIO::Job*, const TQString& );
136  private:
137  unsigned int m_permissions;
138  };
139 
142  class DeleteACLJob : public TDEIO::SimpleJob
143  {
144  TQ_OBJECT
145 
146  public:
147  DeleteACLJob( const KURL& url, const TQString& userId,
148  const TQByteArray &packedArgs,
149  bool showProgressInfo );
150 
151  TQString userId() const { return mUserId; }
152 
153  private:
154  TQString mUserId;
155  };
156 
158  class MultiSetACLJob : public TDEIO::Job {
159  TQ_OBJECT
160 
161 
162  public:
163  MultiSetACLJob( TDEIO::Slave* slave, const KURL& url, const ACLList& acl, bool showProgressInfo );
164 
165  signals:
166  // Emitted when a given user's permissions were successfully changed.
167  // This allows the caller to keep track of what exactly was done (and handle errors better)
168  void aclChanged( const TQString& userId, int permissions );
169 
170  protected slots:
171  virtual void slotStart();
172  virtual void slotResult( TDEIO::Job *job );
173 
174  private:
175  TDEIO::Slave* mSlave;
176  const KURL mUrl;
177  const ACLList mACLList;
178  ACLList::const_iterator mACLListIterator;
179  };
180 
181 
182 #ifndef NDEBUG
183  TQString permissionsToString( unsigned int permissions );
184 #endif
185 }
186 
187 } // namespace
188 
189 #endif /* KMACLJOBS_H */
Delete the permissions for a given user on a given url This class only exists to store the userid in ...
Definition: acljobs.h:143
List all ACLs for a given url.
Definition: acljobs.h:109
Get the users' rights for a given url.
Definition: acljobs.h:126
Set and delete a list of permissions for different users on a given url.
Definition: acljobs.h:158
DeleteACLJob * deleteACL(TDEIO::Slave *slave, const KURL &url, const TQString &user)
Delete the permissions for a given user on a given url.
Definition: acljobs.cpp:136
TDEIO::SimpleJob * setACL(TDEIO::Slave *slave, const KURL &url, const TQString &user, unsigned int permissions)
Set the permissions for a given user on a given url.
Definition: acljobs.cpp:123
GetUserRightsJob * getUserRights(TDEIO::Slave *slave, const KURL &url)
Get the users' rights for a given url.
Definition: acljobs.cpp:158
@ NotFetchedYet
The user rights/ACL have not been fetched from the server yet, we don't know them.
Definition: acljobs.h:65
@ Ok
The user rights/ACL have been fetched from the server sucessfully.
Definition: acljobs.h:66
@ FetchFailed
The attempt to fetch the user rights/ACL from the server failed.
Definition: acljobs.h:67
ACLPermissions
Bitfield modelling the possible permissions.
Definition: acljobs.h:73
MultiSetACLJob * multiSetACL(TDEIO::Slave *slave, const KURL &url, const ACLList &acl)
Set and delete a list of permissions for different users on a given url.
Definition: acljobs.cpp:258
GetACLJob * getACL(TDEIO::Slave *slave, const KURL &url)
List all ACLs for a given url.
Definition: acljobs.cpp:147
folderdiaquotatab.h
Definition: aboutdata.cpp:40
One entry in the ACL list: user and permissions.
Definition: acljobs.h:41
TQString internalRightsList
protocol-dependent string (e.g. IMAP rights list)
Definition: acljobs.h:46
int permissions
based on the ACLPermissions enum
Definition: acljobs.h:47
bool changed
special flag for KMFolderCachedImap
Definition: acljobs.h:48