8#include "polkitqt1-subject.h"
9#include "polkitqt1-identity.h"
10#include "polkitqt1-config.h"
13#include <polkit/polkit.h>
25 Data(
const Data& other)
27 , subject(other.subject)
29 g_object_ref(subject);
33 g_object_unref(subject);
36 PolkitSubject *subject;
44Subject::Subject(PolkitSubject *subject)
49 if (d->subject !=
nullptr) {
50 g_object_ref(d->subject);
70bool Subject::isValid()
const
72 return d->subject !=
nullptr;
75PolkitSubject *Subject::subject()
const
80void Subject::setSubject(PolkitSubject *subject)
82 if (d->subject !=
nullptr) {
83 g_object_unref(d->subject);
97 GError *error =
nullptr;
98 subject.d->subject = polkit_subject_from_string(
string.toUtf8().data(), &error);
99 if (error !=
nullptr) {
100 qWarning() <<
QString(
"Cannot create Subject from string: %1").
arg(error->message);
106UnixProcessSubject::UnixProcessSubject(qint64 pid)
109 setSubject(polkit_unix_process_new_for_owner(
pid, 0, -1));
115 setSubject(polkit_unix_process_new_for_owner(
pid,
startTime, -1));
119 :
Subject((PolkitSubject *) pkUnixProcess)
126 return polkit_unix_process_get_pid((PolkitUnixProcess *)
subject());
131 return polkit_unix_process_get_start_time((PolkitUnixProcess *)
subject());
136 return polkit_unix_process_get_uid((PolkitUnixProcess *)
subject());
141 polkit_unix_process_set_pid((PolkitUnixProcess *)
subject(),
pid);
152 :
Subject((PolkitSubject *) pkSystemBusName)
169#if HAVE_POLKIT_SYSTEM_BUS_NAME_GET_USER_SYNC
170 return UnixUserIdentity(polkit_system_bus_name_get_user_sync((PolkitSystemBusName *)
subject(),
nullptr,
nullptr));
172 qWarning(
"Polkit is too old, returning invalid user from SystemBusNameSubject::user()!");
187 GError *error =
nullptr;
188 setSubject(polkit_unix_session_new_for_process_sync(pid,
nullptr, &error));
189 if (error !=
nullptr) {
190 qWarning() <<
QString(
"Cannot create unix session: %1").
arg(error->message);
196 :
Subject((PolkitSubject *) pkUnixSession)
This class represents PolicyKit subjects.
PolkitSubject * subject() const
Gets PolkitSubject object.
void setName(const QString &name)
Sets system bus name.
UnixUserIdentity user()
Returns the UnixUserIdentity for this subject.
SystemBusNameSubject(const QString &name)
Subject constructor, takes one parameter - system bus name.
QString name() const
Returns system bus name.
void setPid(qint64 pid)
Sets Unix process PID.
qint64 uid() const
Returns Unix process UID.
UnixProcessSubject(qint64 pid)
Subject constructor, takes one parameter - PID.
qint64 startTime() const
Returns Unix process start time.
qint64 pid() const
Returns Unix process PID.
void setSessionId(const QString &sessionId)
Sets session id.
QString sessionId() const
Returns session id.
UnixSessionSubject(const QString &sessionId)
Subject constructor, takes one parameter - session id.
An object representing a user identity on a UNIX system.
QString arg(Args &&... args) const const
QString fromUtf8(QByteArrayView str)
QByteArray toUtf8() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:35 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.