File indexing completed on 2024-04-21 04:43:23
0001 /* 0002 This file is part of the PolKit1-qt project 0003 SPDX-FileCopyrightText: 2009 Radek Novacek <rnovacek@redhat.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef POLKITQT1_TEMPORARYAUTHORIZATION_H 0009 #define POLKITQT1_TEMPORARYAUTHORIZATION_H 0010 0011 #include "polkitqt1-subject.h" 0012 0013 #include <QObject> 0014 #include <QDateTime> 0015 #include <QMetaType> 0016 #include <QSharedData> 0017 0018 typedef struct _PolkitTemporaryAuthorization PolkitTemporaryAuthorization; 0019 0020 /** 0021 * \namespace PolkitQt1 PolkitQt 0022 * 0023 * \brief Namespace wrapping PolicyKit-Qt classes 0024 * 0025 * This namespace wraps all PolicyKit-Qt classes. 0026 */ 0027 namespace PolkitQt1 0028 { 0029 0030 /** 0031 * \class TemporaryAuthorization polkitqt1-temporaryauthorization.h TemporaryAuthorization 0032 * \author Radek Novacek <rnovacek@redhat.com> 0033 * 0034 * \brief This class represents PolicyKit temporary authorization 0035 * 0036 * This class encapsulates the PolkitTemporaryAuthorization interface. 0037 */ 0038 class POLKITQT1_CORE_EXPORT TemporaryAuthorization 0039 { 0040 public: 0041 typedef QList< TemporaryAuthorization > List; 0042 TemporaryAuthorization(); 0043 /** 0044 * Creates TemporaryAuthorization object from PolkitTemporaryAuthorization 0045 * 0046 * \warning It shouldn't be used directly unless you are completely aware of what are you doing 0047 * 0048 * \param pkTemporaryAuthorization PolkitTemporaryAuthorization object 0049 * \param parent 0050 */ 0051 explicit TemporaryAuthorization(PolkitTemporaryAuthorization *pkTemporaryAuthorization); 0052 TemporaryAuthorization(const TemporaryAuthorization &other); 0053 0054 ~TemporaryAuthorization(); 0055 0056 TemporaryAuthorization &operator=(const TemporaryAuthorization &other); 0057 0058 /** 0059 * \brief Gets the identifier for the authorization. 0060 * 0061 * This identifier can be user by the revokeTemporaryAuthorization function 0062 * 0063 * \return Unique identifier for the authorization 0064 */ 0065 QString id() const; 0066 0067 /** 0068 * \brief Gets the identifier of the action that authorization is for 0069 * 0070 * \return String that identifies the action 0071 */ 0072 QString actionId() const; 0073 0074 /** 0075 * \brief Gets the subject that authorization is for 0076 * 0077 * \return A Subject. 0078 */ 0079 Subject subject() const; 0080 0081 /** 0082 * \brief Gets the time when authorization was obtained 0083 * 0084 * \return Time of obtaining the authorization 0085 */ 0086 QDateTime obtainedAt() const; 0087 0088 /** 0089 * \brief Gets the time when authorizaton will expire 0090 * 0091 * \return Time of expiration 0092 */ 0093 QDateTime expirationTime() const; 0094 0095 /** 0096 * \brief Revoke temporary authorization 0097 * 0098 * \return \c true Authorization has been revoked 0099 * \c false Revoking authorization failed 0100 */ 0101 bool revoke(); 0102 0103 private: 0104 class Data; 0105 QSharedDataPointer< Data > d; 0106 }; 0107 } 0108 0109 Q_DECLARE_METATYPE(PolkitQt1::TemporaryAuthorization::List) 0110 0111 #endif // TEMPORARYAUTHORIZATION_H