DBusObjectManagerProxy class

Namespace Runic.Platform.Linux.DBus in Runic.Platform.Linux.DBus 0.23.0

public sealed class DBusObjectManagerProxy : DBusProxy

Inherits or implements DBusProxy.

Reads the objects of a service that implements org.freedesktop.DBus.ObjectManager, such as UDisks2, BlueZ or NetworkManager, and the interfaces they gain and lose.

Remarks

Create it for the object manager's path, which the service documents; UDisks2's is /org/freedesktop/UDisks2. DBusObjectManagerProxy.GetManagedObjectsAsync returns every object below that path with the properties of each of its interfaces, unwrapped from their variants.

To follow the objects without missing a change, call DBusObjectManagerProxy.SubscribeInterfaceChangesAsync first, then DBusObjectManagerProxy.GetManagedObjectsAsync, then read each signal of the subscription with DBusObjectManagerProxy.ReadInterfaceChanges. Property changes of the objects themselves arrive as PropertiesChanged; subscribe to them with DBusConnection.SubscribeAsync and a DBusSignalFilter.PathNamespace.

Constructors

DBusObjectManagerProxy

public DBusObjectManagerProxy(DBusConnection connection, string? destination, DBusObjectPath path)

Creates a proxy for the object manager at path of the service destination.

Parameters

connection

The connection that carries the calls.

destination

The service's bus name, such as org.freedesktop.UDisks2, or null on a peer-to-peer connection.

path

The object manager.

Exceptions

ArgumentException

destination is not a bus name.

Fields

InterfaceName

public const string InterfaceName = "org.freedesktop.DBus.ObjectManager"

The D-Bus interface name, org.freedesktop.DBus.ObjectManager.

Methods

GetManagedObjectsAsync

public ValueTask<ImmutableDictionary<DBusObjectPath, ImmutableDictionary<string, ImmutableDictionary<string, DBusValue>>>> GetManagedObjectsAsync(CancellationToken cancellationToken = default)

Reads every object the manager reports: each object's interfaces, with their properties unwrapped from their variants.

Exceptions

DBusException

The object is no object manager, the reply has another type, or the service replied with another error.

ReadInterfaceChanges

public static DBusInterfaceChanges? ReadInterfaceChanges(DBusSignal signal)

Reads an InterfacesAdded or InterfacesRemoved signal, or returns null for any other signal, including one whose arguments have other types.

SubscribeInterfaceChangesAsync

public ValueTask<DBusSignalSubscription> SubscribeInterfaceChangesAsync(CancellationToken cancellationToken = default)

Starts receiving InterfacesAdded and InterfacesRemoved from the manager, in the order it emits them.

Returns

A subscription that is active when this completes; read each signal with DBusObjectManagerProxy.ReadInterfaceChanges.

WatchInterfaceChangesAsync

public IAsyncEnumerable<DBusInterfaceChanges> WatchInterfaceChangesAsync(CancellationToken cancellationToken = default)

Reports the interfaces objects gain and lose as they arrive.

Remarks

The subscription starts when enumeration starts. To read the current objects without missing a change, call DBusObjectManagerProxy.SubscribeInterfaceChangesAsync first, then DBusObjectManagerProxy.GetManagedObjectsAsync, then enumerate the subscription.