Polkit-Qt-1  0.95.0
polkitqt1-authority.h
1 /*
2  * This file is part of the Polkit-qt project
3  * Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
4  * Copyright (C) 2009 Dario Freddi <drf@kde.org>
5  * Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
6  * Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef POLKITQT1_AUTHORITY_H
25 #define POLKITQT1_AUTHORITY_H
26 
27 #include "polkitqt1-export.h"
28 #include "polkitqt1-identity.h"
29 #include "polkitqt1-subject.h"
30 #include "polkitqt1-temporaryauthorization.h"
31 #include "polkitqt1-actiondescription.h"
32 
33 #include <QtCore/QObject>
34 #include <QtCore/QMetaType>
35 
36 typedef struct _PolkitAuthority PolkitAuthority;
37 class QStringList;
38 
46 namespace PolkitQt1
47 {
48 
66 class POLKITQT1_EXPORT Authority : public QObject
67 {
68  Q_OBJECT
69  Q_DISABLE_COPY(Authority)
70  Q_ENUMS(Result)
71  Q_ENUMS(ErrorCode)
72 public:
73  enum Result {
75  Unknown = 0x00,
77  Yes = 0x01,
79  No = 0x02,
81  Challenge = 0x03
82  };
83 
86  None = 0x00,
92  AllowUserInteraction = 0x01
93  };
94  Q_DECLARE_FLAGS(AuthorizationFlags, AuthorizationFlag)
95 
96 
97  enum ErrorCode {
99  E_None = 0x00,
101  E_GetAuthority = 0x01,
103  E_CheckFailed = 0x02,
105  E_WrongSubject = 0x03,
107  E_UnknownResult = 0x04,
109  E_EnumFailed = 0x05,
111  E_RegisterFailed = 0x06,
113  E_UnregisterFailed = 0x07,
115  E_CookieOrIdentityEmpty = 0x08,
117  E_AgentResponseFailed = 0x09,
119  E_RevokeFailed = 0x0A
120  };
121 
139  static Authority *instance(PolkitAuthority *authority = 0);
140 
141  ~Authority();
142 
152  bool hasError() const;
153 
157  ErrorCode lastError() const;
158 
164  const QString errorDetails() const;
165 
169  void clearError();
170 
180  PolkitAuthority *polkitAuthority() const;
181 
210  void checkAuthorization(const QString &actionId, const Subject &subject,
211  AuthorizationFlags flags);
212 
222  Result checkAuthorizationSync(const QString &actionId, const Subject &subject,
223  AuthorizationFlags flags);
224 
228  void checkAuthorizationCancel();
229 
240  void enumerateActions();
241 
249  ActionDescription::List enumerateActionsSync();
250 
254  void enumerateActionsCancel();
255 
267  void registerAuthenticationAgent(const Subject &subject, const QString &locale,
268  const QString &objectPath);
269 
282  bool registerAuthenticationAgentSync(const Subject &subject, const QString &locale,
283  const QString &objectPath);
284 
288  void registerAuthenticationAgentCancel();
289 
303  void unregisterAuthenticationAgent(const Subject &subject, const QString &objectPath);
304 
316  bool unregisterAuthenticationAgentSync(const Subject &subject, const QString &objectPath);
317 
321  void unregisterAuthenticationAgentCancel();
322 
333  void authenticationAgentResponse(const QString &cookie, const Identity &identity);
334 
346  bool authenticationAgentResponseSync(const QString& cookie, const PolkitQt1::Identity& identity);
347 
351  void authenticationAgentResponseCancel();
352 
363  void enumerateTemporaryAuthorizations(const Subject &subject);
364 
376  TemporaryAuthorization::List enumerateTemporaryAuthorizationsSync(const Subject &subject);
377 
381  void enumerateTemporaryAuthorizationsCancel();
382 
392  void revokeTemporaryAuthorizations(const Subject &subject);
393 
404  bool revokeTemporaryAuthorizationsSync(const Subject &subject);
405 
409  void revokeTemporaryAuthorizationsCancel();
410 
420  void revokeTemporaryAuthorization(const QString &id);
421 
432  bool revokeTemporaryAuthorizationSync(const QString &id);
433 
437  void revokeTemporaryAuthorizationCancel();
438 
439 Q_SIGNALS:
447  void configChanged();
448 
461  void consoleKitDBChanged();
462 
468  void checkAuthorizationFinished(PolkitQt1::Authority::Result);
469 
475  void enumerateActionsFinished(PolkitQt1::ActionDescription::List);
476 
483  void registerAuthenticationAgentFinished(bool);
484 
491  void unregisterAuthenticationAgentFinished(bool);
492 
498  void authenticationAgentResponseFinished(bool);
499 
507  void enumerateTemporaryAuthorizationsFinished(PolkitQt1::TemporaryAuthorization::List);
508 
515  void revokeTemporaryAuthorizationsFinished(bool);
516 
522  void revokeTemporaryAuthorizationFinished(bool);
523 
524 private:
525  explicit Authority(PolkitAuthority *context, QObject *parent = 0);
526 
527  class Private;
528  friend class Private;
529  Private * const d;
530 
531  Q_PRIVATE_SLOT(d, void dbusFilter(const QDBusMessage &message))
532 };
533 
534 }
535 
536 Q_DECLARE_OPERATORS_FOR_FLAGS(PolkitQt1::Authority::AuthorizationFlags)
537 Q_DECLARE_METATYPE(PolkitQt1::Authority::Result)
538 
539 #endif
Convenience class for Qt/KDE applications.
Definition: polkitqt1-authority.h:66
ErrorCode
Definition: polkitqt1-authority.h:97
Abstract class representing identities.
Definition: polkitqt1-identity.h:59
This class represents PolicyKit subjects.
Definition: polkitqt1-subject.h:55
Contains Macros for exporting symbols.
Namespace wrapping Polkit-Qt classes.
Definition: listeneradapter.cpp:26
AuthorizationFlag
Definition: polkitqt1-authority.h:84
Result
Definition: polkitqt1-authority.h:73