PolkitQt-1

polkitqt1-temporaryauthorization.cpp
1 /*
2  This file is part of the PolKit1-qt project
3  SPDX-FileCopyrightText: 2009 Radek Novacek <[email protected]>
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 
13 namespace PolkitQt1
14 {
15 
16 class Q_DECL_HIDDEN TemporaryAuthorization::Data : public QSharedData
17 {
18 public:
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 
38 TemporaryAuthorization::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 
49 TemporaryAuthorization::TemporaryAuthorization(const PolkitQt1::TemporaryAuthorization& other)
50  : d(other.d)
51 {
52 
53 }
54 
55 TemporaryAuthorization::TemporaryAuthorization()
56  : d(new Data)
57 {
58 
59 }
60 
61 TemporaryAuthorization& TemporaryAuthorization::operator=(const PolkitQt1::TemporaryAuthorization& other)
62 {
63  d = other.d;
64  return *this;
65 }
66 
67 TemporaryAuthorization::~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 
98 {
100  return true;
101 }
102 
103 }
This class represents PolicyKit subjects.
QString fromUtf8(const char *str, int size)
Subject
QDateTime expirationTime() const
Gets the time when authorizaton will expire.
QDateTime obtainedAt() const
Gets the time when authorization was obtained.
void revokeTemporaryAuthorization(const QString &id)
Revokes temporary authorization by id.
This class represents PolicyKit temporary authorization.
static Authority * instance(PolkitAuthority *authority=nullptr)
Returns the instance of Authority.
Subject subject() const
Gets the subject that authorization is for.
QDateTime fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spec, int offsetSeconds)
bool revoke()
Revoke temporary authorization.
QString id() const
Gets the identifier for the authorization.
Namespace wrapping Polkit-Qt classes.
QString actionId() const
Gets the identifier of the action that authorization is for.
static Subject fromString(const QString &string)
Creates the Subject object from string reprezentation.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Jun 26 2022 04:06:09 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.