UNPKG

dbus-sdk

Version:

A Node.js SDK for interacting with DBus, enabling seamless service calling and exposure with TypeScript support

67 lines 4.29 kB
import { LocalInterface } from '../../LocalInterface'; import EventEmitter from 'node:events'; /** * A class representing the DBus Properties interface. * This interface provides methods to get, set, and monitor properties of other interfaces * on a DBus object. Implements the 'org.freedesktop.DBus.Properties' interface as per * the DBus specification for standardized property management. */ export declare class PropertiesInterface extends LocalInterface { /** * An EventEmitter instance used to emit signals when properties change. * Specifically used to handle the 'PropertiesChanged' signal to notify clients * about updates to property values or invalidations. */ protected readonly eventEmitter: EventEmitter; /** * Constructor for the PropertiesInterface. * Initializes the interface with the name 'org.freedesktop.DBus.Properties' * and defines methods for getting and setting properties ('Get', 'GetAll', 'Set'), * as well as a signal ('PropertiesChanged') for notifying about property changes. */ constructor(); /** * Retrieves the value of a specific property from the specified interface on the associated object. * Uses the `getPropertySignedValue` method of the target interface to ensure the value is returned * with its DBus signature for proper variant type handling. * * @param interfaceName - The name of the interface containing the property (e.g., 'org.example.Interface'). * @param propertyName - The name of the property to retrieve. * @returns A Promise resolving to the value of the property wrapped as a DBusSignedValue. * @throws {Error} DBus error with code 'org.freedesktop.DBus.Error.UnknownInterface' if the interface is not found. */ protected get(interfaceName: string, propertyName: string): Promise<any>; /** * Sets the value of a specific property on the specified interface of the associated object. * Delegates the operation to the `setProperty` method of the target interface to update the property value. * * @param interfaceName - The name of the interface containing the property (e.g., 'org.example.Interface'). * @param propertyName - The name of the property to set. * @param value - The value to set for the property, provided as a variant type. * @returns A Promise that resolves when the property is successfully set. * @throws {Error} DBus error with code 'org.freedesktop.DBus.Error.UnknownInterface' if the interface is not found, * or other DBus errors if the property is read-only or the value is invalid. */ protected set(interfaceName: string, propertyName: string, value: any): Promise<void>; /** * Retrieves all properties of the specified interface as a key-value map. * Iterates through all property names of the target interface, retrieves their values using the `get` method, * and constructs a single record of property names and values. Returns an empty object if the interface is not found. * * @param interfaceName - The name of the interface to retrieve properties from (e.g., 'org.example.Interface'). * @returns A Promise resolving to a record (object) mapping property names to their values. */ protected getAll(interfaceName: string): Promise<Record<string, any>>; /** * Emits the 'PropertiesChanged' signal to notify listeners of property updates. * Used to inform clients about changes to property values or invalidation of properties on a specific interface. * The signal includes the interface name, a record of changed properties with their new values, * and an optional array of invalidated property names. * * @param interfaceName - The name of the interface whose properties have changed (e.g., 'org.example.Interface'). * @param changedProperties - A record of property names and their new values that have been updated. * @param invalidatedProperties - An optional array of property names that are no longer valid, defaults to an empty array. */ emitPropertiesChanged(interfaceName: string, changedProperties: Record<string, any>, invalidatedProperties?: string[]): void; } //# sourceMappingURL=PropertiesInterface.d.ts.map