PolkitQt-1
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;
44 Subject::Subject(PolkitSubject *subject)
49 if (d->subject !=
nullptr) {
50 g_object_ref(d->subject);
70 bool Subject::isValid()
const
72 return d->subject !=
nullptr;
80 void 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);
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.
qint64 startTime() const
Returns Unix process start time.
QString toString() const
Serialization of object to the string.
QString fromUtf8(const char *str, int size)
QString name() const
Returns system bus name.
UnixSessionSubject(const QString &sessionId)
Subject constructor, takes one parameter - session id.
void setName(const QString &name)
Sets system bus name.
UnixProcessSubject(qint64 pid)
Subject constructor, takes one parameter - PID.
QByteArray toUtf8() const const
PolkitSubject * subject() const
Gets PolkitSubject object.
void setPid(qint64 pid)
Sets Unix process PID.
QString sessionId() const
Returns session id.
qint64 uid() const
Returns Unix process UID.
qint64 pid() const
Returns Unix process PID.
UnixUserIdentity user()
Returns the UnixUserIdentity for this subject.
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
SystemBusNameSubject(const QString &name)
Subject constructor, takes one parameter - system bus name.
Namespace wrapping Polkit-Qt classes.
void setSessionId(const QString &sessionId)
Sets session id.
static Subject fromString(const QString &string)
Creates the Subject object from string reprezentation.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Dec 7 2023 03:58:11 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.