tuned-switcher 1.1.0
Performance profile manager
Loading...
Searching...
No Matches
PortalRequest Class Reference

#include <portalrequest.h>

Inheritance diagram for PortalRequest:
Collaboration diagram for PortalRequest:

Public Types

enum class  BackgroundResult {
  Disabled , Enabled , Cancelled , Timeout ,
  Unknown , NotFinished
}
 

Signals

void finished ()
 

Public Member Functions

 PortalRequest (QObject *parent=nullptr)
 
bool RequestBackground (const bool)
 
BackgroundResult GetResult () const
 
unsigned int GetVersion () const
 

Private Slots

void RequestResponseEvent (const unsigned int, const QVariantMap &)
 

Private Member Functions

QString CreateHandleToken () const
 
QString CreateReasonString () const
 
const QVariantMap CreateOptionsStructure (const bool) const
 
const QList< QVariant > CreateRequestStructure (const bool) const
 
PortalRequest::BackgroundResult ExtractAutostartValue () const
 
void RequestResponseError ()
 

Private Attributes

const QString PortalBusName = QStringLiteral("org.freedesktop.portal.Desktop")
 
const QString PortalBusPath = QStringLiteral("/org/freedesktop/portal/desktop")
 
const QString PortalBusBackgroundInterface = QStringLiteral("org.freedesktop.portal.Background")
 
const QString PortalBusRequestInterface = QStringLiteral("org.freedesktop.portal.Request")
 
const QString PortalBusMethodNameRequestBackground = QStringLiteral("RequestBackground")
 
const QString PortalBusSignalNameResponse = QStringLiteral("Response")
 
const QString PortalBusFieldNameAutostart = QStringLiteral("autostart")
 
const QString PortalBusPropertyNameVersion = QStringLiteral("version")
 
const QString DBusPropertyInterface = QStringLiteral("org.freedesktop.DBus.Properties")
 
const QString DBusPropertyMethodNameGet = QStringLiteral("Get")
 
bool ResponseFinished = false
 
unsigned long ResponseCode = 255UL
 
QVariantMap ResponseResults
 
QDBusConnection DBusInstance = QDBusConnection::sessionBus()
 

Detailed Description

Class for working with portals.

Member Enumeration Documentation

◆ BackgroundResult

Enum with IDs of result codes, used by various methods.

Constructor & Destructor Documentation

◆ PortalRequest()

PortalRequest::PortalRequest ( QObject * parent = nullptr)
explicit

Main constructor of the PortalRequest class.

Parameters
parentParent.

Member Function Documentation

◆ CreateHandleToken()

QString PortalRequest::CreateHandleToken ( ) const
private

Constructs and returns special DBus object path for the request interface.

Returns
Fully-qualified DBus object path.

◆ CreateOptionsStructure()

const QVariantMap PortalRequest::CreateOptionsStructure ( const bool autostart) const
private

Constructs and returns special Options structure for the desktop portal service.

Parameters
autostartNew autorun status.
Returns
Options structure for the desktop portal service.

◆ CreateReasonString()

QString PortalRequest::CreateReasonString ( ) const
private

Constructs and returns DBus activation reason for the request interface.

Returns
DBus activation reason.

◆ CreateRequestStructure()

const QList< QVariant > PortalRequest::CreateRequestStructure ( const bool autostart) const
private

Constructs and returns special Request structure for the desktop portal service.

Parameters
autostartNew autorun status.
Returns
Request structure for the desktop portal service.

◆ ExtractAutostartValue()

PortalRequest::BackgroundResult PortalRequest::ExtractAutostartValue ( ) const
private

Extracts and returns the result of the asynchronous operation.

Returns
Result of the asynchronous operation.

◆ finished

void PortalRequest::finished ( )
signal

Asynchronous request completed signal.

◆ GetResult()

PortalRequest::BackgroundResult PortalRequest::GetResult ( ) const

Returns the result of the asynchronous operation.

Returns
Result of the asynchronous operation.

◆ GetVersion()

unsigned int PortalRequest::GetVersion ( ) const

Returns version of the PortalRequest portal as an unsigned integer.

Returns
Version of the PortalRequest portal, or 0 if an error occurs.

◆ RequestBackground()

bool PortalRequest::RequestBackground ( const bool autostart)

Runs the RequestBackground method and returns the DBus method call status. The GetResult() method should be called after receiving the finished() signal to obtain the result.

Parameters
autostartNew autorun status.
Returns
DBus method call status.
Return values
trueThe requested method was called successfully.
falseAn error occurred when trying to call the the requested method.

◆ RequestResponseError()

void PortalRequest::RequestResponseError ( )
private

Sets error values to various private fields and calls finished() slot.

◆ RequestResponseEvent

void PortalRequest::RequestResponseEvent ( const unsigned int response,
const QVariantMap & results )
privateslot

Response received event slot. Sets received values to various private fields and calls finished() slot.

Parameters
responseResponse code: 0 - success; 1 - cancelled; 2 - timeout.
resultsResults data.

Member Data Documentation

◆ DBusInstance

QDBusConnection PortalRequest::DBusInstance = QDBusConnection::sessionBus()
private

Stores DBus instance.

◆ DBusPropertyInterface

const QString PortalRequest::DBusPropertyInterface = QStringLiteral("org.freedesktop.DBus.Properties")
private

Stores the Systemd Properties DBus interface.

◆ DBusPropertyMethodNameGet

const QString PortalRequest::DBusPropertyMethodNameGet = QStringLiteral("Get")
private

Stores the Systemd DBus GetProperty method name.

◆ PortalBusBackgroundInterface

const QString PortalRequest::PortalBusBackgroundInterface = QStringLiteral("org.freedesktop.portal.Background")
private

Stores the desktop portal Background DBus interface.

◆ PortalBusFieldNameAutostart

const QString PortalRequest::PortalBusFieldNameAutostart = QStringLiteral("autostart")
private

Stores the desktop portal DBus Autostart field name.

◆ PortalBusMethodNameRequestBackground

const QString PortalRequest::PortalBusMethodNameRequestBackground = QStringLiteral("RequestBackground")
private

Stores the desktop portal DBus RequestBackground method name.

◆ PortalBusName

const QString PortalRequest::PortalBusName = QStringLiteral("org.freedesktop.portal.Desktop")
private

Stores the desktop portal DBus interface name.

◆ PortalBusPath

const QString PortalRequest::PortalBusPath = QStringLiteral("/org/freedesktop/portal/desktop")
private

Stores the desktop portal DBus object path.

◆ PortalBusPropertyNameVersion

const QString PortalRequest::PortalBusPropertyNameVersion = QStringLiteral("version")
private

Stores the desktop portal DBus Version property name.

◆ PortalBusRequestInterface

const QString PortalRequest::PortalBusRequestInterface = QStringLiteral("org.freedesktop.portal.Request")
private

Stores the desktop portal Request DBus interface.

◆ PortalBusSignalNameResponse

const QString PortalRequest::PortalBusSignalNameResponse = QStringLiteral("Response")
private

Stores the desktop portal DBus Response signal name.

◆ ResponseCode

unsigned long PortalRequest::ResponseCode = 255UL
private

Stores the response code after running the asynchronous operation.

◆ ResponseFinished

bool PortalRequest::ResponseFinished = false
private

Stores the status of the asynchronous operation.

◆ ResponseResults

QVariantMap PortalRequest::ResponseResults
private

Stores the response results after running the asynchronous operation.


The documentation for this class was generated from the following files: