Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorServiceBluetooth::BluetoothAgent Class Reference

Implements org.bluez.Agent1, the pairing agent BlueZ calls back into during a Pair() handshake. More...

#include <PhosphorServiceBluetooth/BluetoothAgent.h>

Inheritance diagram for PhosphorServiceBluetooth::BluetoothAgent:
[legend]

Public Slots

void Release ()
QString RequestPinCode (const QDBusObjectPath &device)
void DisplayPinCode (const QDBusObjectPath &device, const QString &pincode)
uint RequestPasskey (const QDBusObjectPath &device)
void DisplayPasskey (const QDBusObjectPath &device, uint passkey, ushort entered)
void RequestConfirmation (const QDBusObjectPath &device, uint passkey)
void RequestAuthorization (const QDBusObjectPath &device)
void AuthorizeService (const QDBusObjectPath &device, const QString &uuid)
void Cancel ()

Signals

void availableChanged ()
void pinCodeRequested (const QString &devicePath, quint64 requestId)
 A PIN code (legacy) is required for devicePath.
void passkeyRequested (const QString &devicePath, quint64 requestId)
 A numeric passkey is required. Answer with respondPasskey / rejectRequest.
void confirmationRequested (const QString &devicePath, quint32 passkey, quint64 requestId)
 Confirm that passkey matches the one shown on devicePath.
void authorizationRequested (const QString &devicePath, quint64 requestId)
 Authorize an incoming pairing with no MITM protection.
void serviceAuthorizationRequested (const QString &devicePath, const QString &uuid, quint64 requestId)
 Authorize uuid on devicePath.
void pinCodeDisplayed (const QString &devicePath, const QString &pinCode)
 Display-only: show pinCode / passkey to the user (no response).
void passkeyDisplayed (const QString &devicePath, quint32 passkey, quint16 entered)
void requestCancelled ()
 BlueZ withdrew the in-flight request (Cancel); any prompt should close.
void released ()
 BlueZ released the agent (Release); it is no longer registered.

Public Member Functions

 BluetoothAgent (QObject *parent=nullptr)
 ~BluetoothAgent () override
bool available () const
void setAvailable (bool available)
 Internal registration state, updated by BluetoothHost.
int pendingRequestCount () const
 Number of requests awaiting a consumer response.
void respondPinCode (quint64 requestId, const QString &pinCode)
void respondPasskey (quint64 requestId, quint32 passkey)
void respondConfirmation (quint64 requestId, bool accept)
 Accept (or, with accept false, reject) a confirmation / authorization / service-authorization request.
void rejectRequest (quint64 requestId)
 Reject any pending request with org.bluez.Error.Rejected.

Static Public Member Functions

static QString agentPath ()
 Object path the agent is exported at and registered under with org.bluez.AgentManager1.

Detailed Description

Implements org.bluez.Agent1, the pairing agent BlueZ calls back into during a Pair() handshake.

Registered by BluetoothHost with KeyboardDisplay capability, this is the library's only D-Bus server object. The interactive callbacks (RequestPinCode / RequestPasskey / RequestConfirmation / RequestAuthorization / AuthorizeService) cannot answer BlueZ synchronously: they need the user. Each therefore takes a delayed D-Bus reply (QDBusContext::setDelayedReply) and emits a Qt request signal carrying a requestId; a consumer (the CLI now, a pairing dialog later) answers via respondPinCode / respondPasskey / respondConfirmation / rejectRequest, which sends the held reply.

The agent is implemented directly on this QObject (exported via ExportAllSlots) rather than through a generated QDBusAbstractAdaptor, because the adaptor would become QtDBus's dispatch target and setDelayedReply would no longer apply to this object's calls. Display-only callbacks (DisplayPinCode / DisplayPasskey) and Release / Cancel return immediately.

Constructor & Destructor Documentation

◆ BluetoothAgent()

PhosphorServiceBluetooth::BluetoothAgent::BluetoothAgent ( QObject * parent = nullptr)
explicit

◆ ~BluetoothAgent()

PhosphorServiceBluetooth::BluetoothAgent::~BluetoothAgent ( )
override

Member Function Documentation

◆ agentPath()

QString PhosphorServiceBluetooth::BluetoothAgent::agentPath ( )
staticnodiscard

Object path the agent is exported at and registered under with org.bluez.AgentManager1.

◆ authorizationRequested

void PhosphorServiceBluetooth::BluetoothAgent::authorizationRequested ( const QString & devicePath,
quint64 requestId )
signal

Authorize an incoming pairing with no MITM protection.

Answer with respondConfirmation / rejectRequest.

◆ AuthorizeService

void PhosphorServiceBluetooth::BluetoothAgent::AuthorizeService ( const QDBusObjectPath & device,
const QString & uuid )
slot

◆ available()

bool PhosphorServiceBluetooth::BluetoothAgent::available ( ) const
nodiscard

◆ availableChanged

void PhosphorServiceBluetooth::BluetoothAgent::availableChanged ( )
signal

◆ Cancel

void PhosphorServiceBluetooth::BluetoothAgent::Cancel ( )
slot

◆ confirmationRequested

void PhosphorServiceBluetooth::BluetoothAgent::confirmationRequested ( const QString & devicePath,
quint32 passkey,
quint64 requestId )
signal

Confirm that passkey matches the one shown on devicePath.

Answer with respondConfirmation(requestId, accept) or rejectRequest.

◆ DisplayPasskey

void PhosphorServiceBluetooth::BluetoothAgent::DisplayPasskey ( const QDBusObjectPath & device,
uint passkey,
ushort entered )
slot

◆ DisplayPinCode

void PhosphorServiceBluetooth::BluetoothAgent::DisplayPinCode ( const QDBusObjectPath & device,
const QString & pincode )
slot

◆ passkeyDisplayed

void PhosphorServiceBluetooth::BluetoothAgent::passkeyDisplayed ( const QString & devicePath,
quint32 passkey,
quint16 entered )
signal

◆ passkeyRequested

void PhosphorServiceBluetooth::BluetoothAgent::passkeyRequested ( const QString & devicePath,
quint64 requestId )
signal

A numeric passkey is required. Answer with respondPasskey / rejectRequest.

◆ pendingRequestCount()

int PhosphorServiceBluetooth::BluetoothAgent::pendingRequestCount ( ) const
nodiscard

Number of requests awaiting a consumer response.

Primarily for tests and introspection.

◆ pinCodeDisplayed

void PhosphorServiceBluetooth::BluetoothAgent::pinCodeDisplayed ( const QString & devicePath,
const QString & pinCode )
signal

Display-only: show pinCode / passkey to the user (no response).

◆ pinCodeRequested

void PhosphorServiceBluetooth::BluetoothAgent::pinCodeRequested ( const QString & devicePath,
quint64 requestId )
signal

A PIN code (legacy) is required for devicePath.

Answer with respondPinCode(requestId, ...) or rejectRequest(requestId).

◆ rejectRequest()

void PhosphorServiceBluetooth::BluetoothAgent::rejectRequest ( quint64 requestId)

Reject any pending request with org.bluez.Error.Rejected.

◆ Release

void PhosphorServiceBluetooth::BluetoothAgent::Release ( )
slot

◆ released

void PhosphorServiceBluetooth::BluetoothAgent::released ( )
signal

BlueZ released the agent (Release); it is no longer registered.

◆ RequestAuthorization

void PhosphorServiceBluetooth::BluetoothAgent::RequestAuthorization ( const QDBusObjectPath & device)
slot

◆ requestCancelled

void PhosphorServiceBluetooth::BluetoothAgent::requestCancelled ( )
signal

BlueZ withdrew the in-flight request (Cancel); any prompt should close.

◆ RequestConfirmation

void PhosphorServiceBluetooth::BluetoothAgent::RequestConfirmation ( const QDBusObjectPath & device,
uint passkey )
slot

◆ RequestPasskey

uint PhosphorServiceBluetooth::BluetoothAgent::RequestPasskey ( const QDBusObjectPath & device)
slot

◆ RequestPinCode

QString PhosphorServiceBluetooth::BluetoothAgent::RequestPinCode ( const QDBusObjectPath & device)
slot

◆ respondConfirmation()

void PhosphorServiceBluetooth::BluetoothAgent::respondConfirmation ( quint64 requestId,
bool accept )

Accept (or, with accept false, reject) a confirmation / authorization / service-authorization request.

◆ respondPasskey()

void PhosphorServiceBluetooth::BluetoothAgent::respondPasskey ( quint64 requestId,
quint32 passkey )

◆ respondPinCode()

void PhosphorServiceBluetooth::BluetoothAgent::respondPinCode ( quint64 requestId,
const QString & pinCode )

◆ serviceAuthorizationRequested

void PhosphorServiceBluetooth::BluetoothAgent::serviceAuthorizationRequested ( const QString & devicePath,
const QString & uuid,
quint64 requestId )
signal

Authorize uuid on devicePath.

Answer with respondConfirmation / rejectRequest.

◆ setAvailable()

void PhosphorServiceBluetooth::BluetoothAgent::setAvailable ( bool available)

Internal registration state, updated by BluetoothHost.


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