PolkitQt-1

polkitqt1-temporaryauthorization.cpp
1/*
2 This file is part of the PolKit1-qt project
3 SPDX-FileCopyrightText: 2009 Radek Novacek <rnovacek@redhat.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "polkitqt1-temporaryauthorization.h"
9#include "polkitqt1-authority.h"
10
11#include <polkit/polkit.h>
12
13namespace PolkitQt1
14{
15
16class Q_DECL_HIDDEN TemporaryAuthorization::Data : public QSharedData
17{
18public:
19 Data() {}
20 Data(const Data& other)
21 : QSharedData(other)
22 , id(other.id)
23 , actionId(other.actionId)
24 , subject(other.subject)
25 , timeObtained(other.timeObtained)
26 , timeExpires(other.timeExpires)
27 {
28 }
29 ~Data() {}
30
31 QString id;
32 QString actionId;
33 Subject subject;
34 QDateTime timeObtained;
35 QDateTime timeExpires;
36};
37
38TemporaryAuthorization::TemporaryAuthorization(PolkitTemporaryAuthorization *pkTemporaryAuthorization)
39 : d(new Data)
40{
41 d->id = QString::fromUtf8(polkit_temporary_authorization_get_id(pkTemporaryAuthorization));
42 d->actionId = QString::fromUtf8(polkit_temporary_authorization_get_action_id(pkTemporaryAuthorization));
43 d->subject = Subject::fromString(polkit_subject_to_string(polkit_temporary_authorization_get_subject(pkTemporaryAuthorization)));
44 d->timeObtained = QDateTime::fromSecsSinceEpoch(polkit_temporary_authorization_get_time_obtained(pkTemporaryAuthorization));
45 d->timeExpires = QDateTime::fromSecsSinceEpoch(polkit_temporary_authorization_get_time_expires(pkTemporaryAuthorization));
46 g_object_unref(pkTemporaryAuthorization);
47}
48
49TemporaryAuthorization::TemporaryAuthorization(const PolkitQt1::TemporaryAuthorization& other)
50 : d(other.d)
51{
52
53}
54
55TemporaryAuthorization::TemporaryAuthorization()
56 : d(new Data)
57{
58
59}
60
61TemporaryAuthorization& TemporaryAuthorization::operator=(const PolkitQt1::TemporaryAuthorization& other)
62{
63 d = other.d;
64 return *this;
65}
66
67TemporaryAuthorization::~TemporaryAuthorization()
68{
69}
70
72{
73 return d->id;
74}
75
77{
78 return d->actionId;
79}
80
82{
83 //qFatal(polkit_subject_to_string(polkit_temporary_authorization_get_subject(d->temporaryAuthorization)));
84 return d->subject;//Subject::fromString(polkit_subject_to_string(d->subject));
85}
86
88{
89 return d->timeObtained;
90}
91
93{
94 return d->timeExpires;
95}
96
102
103}
static Authority * instance(PolkitAuthority *authority=nullptr)
Returns the instance of Authority.
void revokeTemporaryAuthorization(const QString &id)
Revokes temporary authorization by id.
This class represents PolicyKit subjects.
static Subject fromString(const QString &string)
Creates the Subject object from string reprezentation.
This class represents PolicyKit temporary authorization.
QDateTime obtainedAt() const
Gets the time when authorization was obtained.
Subject subject() const
Gets the subject that authorization is for.
QDateTime expirationTime() const
Gets the time when authorizaton will expire.
bool revoke()
Revoke temporary authorization.
QString actionId() const
Gets the identifier of the action that authorization is for.
QString id() const
Gets the identifier for the authorization.
QDateTime fromSecsSinceEpoch(qint64 secs)
QString fromUtf8(QByteArrayView str)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:13:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.