UNPKG

dbus-sdk

Version:

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

669 lines 37.2 kB
import { DBusService } from './DBusService'; import { DBusObject } from './DBusObject'; import { DBusInterface } from './DBusInterface'; import { ConnectOpts } from './types/ConnectOpts'; import { DBusConnection } from './lib/DBusConnection'; import { DBusMessage } from './lib/DBusMessage'; import { InvokeOpts } from './types/InvokeOpts'; import { GetPropertyValueOpts } from './types/GetPropertyValueOpts'; import { SetPropertyValueOpts } from './types/SetPropertyValueOpts'; import { CreateSignalEmitterOpts } from './types/CreateSignalEmitterOpts'; import { DBusSignalEmitter } from './lib/DBusSignalEmitter'; import { ServiceBasicInfo } from './types/ServiceBasicInfo'; import { RequestNameFlags } from './lib/enums/RequestNameFlags'; import { RequestNameResultCode } from './lib/enums/RequestNameResultCode'; import EventEmitter from 'node:events'; import { ReplyOpts } from './types/ReplyOpts'; import { EmitSignalOpts } from './types/EmitSignalOpts'; import { BusNameBasicInfo } from './types/BusNameBasicInfo'; /** * Main class for interacting with a DBus connection. * Provides methods for connecting to DBus, invoking methods, handling signals, * managing services, objects, and interfaces, and other DBus operations. * Extends EventEmitter to emit events for connection status and DBus signals. */ export declare class DBus extends EventEmitter { #private; /** * Getter for the unique name of this DBus connection. * * @returns The unique name assigned by the DBus daemon (e.g., ':1.123'). */ get uniqueName(): string; /** * Static method to connect to a DBus instance. * Creates a new DBus connection with the provided options and initializes it. * * @param opts - Connection options (e.g., socket path, TCP details, or stream settings). * @returns A Promise resolving to an initialized DBus instance ready for use. */ static connect(opts: ConnectOpts): Promise<DBus>; /** * Initializes the DBus connection. * Performs a 'Hello' call to obtain a unique name, sets up the management interface, * updates services and signal emitters with current name owners, and registers * event listeners for DBus daemon signals. * * @returns A Promise resolving to this DBus instance after initialization is complete. */ protected initialize(): Promise<this>; /** * Sends a 'Hello' message to the DBus daemon to obtain a unique connection name. * Sets the unique name for this connection upon successful response. * This is typically the first step in DBus connection initialization. * * @returns A Promise that resolves when the unique name is set. */ protected hello(): Promise<void>; /** * Writes raw data to the DBus socket. * Throws an error if the connection is not active. * Used internally to send encoded DBus messages to the daemon. * * @param data - The Buffer containing the data to write to the DBus socket. * @throws {Error} If the DBus connection is disconnected, with a specific DBus error code. */ write(data: Buffer): void; /** * Emits a DBus signal with the specified options. * Encodes the signal message using the provided options and writes it to the DBus socket. * Signals are broadcast messages that do not expect a reply. * * @param opts - Options for emitting the signal, including object path, interface, signal name, destination, signature, and data. */ emitSignal(opts: EmitSignalOpts): void; /** * Sends a reply to a DBus method call. * Handles both successful responses (METHOD_RETURN) and error replies (ERROR). * Encodes the reply message and writes it to the DBus socket. * * @param opts - Options for the reply, including reply serial number, destination, signature, and data or error object. */ reply(opts: ReplyOpts): void; /** * Invokes a DBus method call with the specified options, without expecting a reply. * Sends the method call message to the DBus daemon and does not wait for a response. * * @param opts - Options for the method call, including service, object path, interface, method, signature, and arguments. * @param noReply - Set to true to indicate no reply is expected. * @returns void as no response is expected or processed. */ invoke(opts: InvokeOpts, noReply: true): void; /** * Invokes a DBus method call with the specified options, explicitly expecting a reply. * Sends the method call message to the DBus daemon and waits for a response or error. * * @param opts - Options for the method call, including service, object path, interface, method, signature, and arguments. * @param noReply - Set to false to indicate a reply is expected. * @returns A Promise resolving to an array of response data from the method call. */ invoke(opts: InvokeOpts, noReply: false): Promise<any[]>; /** * Invokes a DBus method call with the specified options, defaulting to expecting a reply. * Sends the method call message to the DBus daemon and waits for a response or error. * * @param opts - Options for the method call, including service, object path, interface, method, signature, and arguments. * @returns A Promise resolving to an array of response data from the method call. */ invoke(opts: InvokeOpts): Promise<any[]>; /** * Retrieves the value of a DBus property using the Properties interface. * Calls the 'Get' method of 'org.freedesktop.DBus.Properties' to fetch a property value. * * @param opts - Options for getting the property, including service, object path, interface name, and property name. * @returns A Promise resolving to the value of the requested property. */ getProperty(opts: GetPropertyValueOpts): Promise<any>; /** * Sets the value of a DBus property using the Properties interface. * Calls the 'Set' method of 'org.freedesktop.DBus.Properties' to update a property value. * * @param opts - Options for setting the property, including service, object path, interface name, property name, value, and optional signature. * @returns A Promise that resolves when the property is successfully set. */ setProperty(opts: SetPropertyValueOpts): Promise<void>; /** * Formats a DBus match rule string for signal subscription. * Constructs a rule string to filter incoming signals based on sender, path, interface, and signal name. * * @param uniqueName - The sender's unique name or '*' to match any sender. * @param objectPath - The object path or '*' to match any path. * @param interfaceName - The interface name or '*' to match any interface. * @param signalName - The signal name or '*' to match any signal. * @returns The formatted match rule string (e.g., 'type=signal,sender=:1.123,interface=org.test'). */ protected formatMatchSignalRule(uniqueName: string | '*', objectPath: string | '*', interfaceName: string | '*', signalName: string): string; /** * Registers a signal subscription rule with the DBus daemon. * Adds a match rule to receive signals matching the specified criteria and stores it for management. * * @param uniqueName - The sender's unique name or '*' to match any sender. * @param objectPath - The object path or '*' to match any path. * @param interfaceName - The interface name or '*' to match any interface. * @param signalName - The signal name or '*' to match any signal. */ protected onSignal(uniqueName: string | '*', objectPath: string | '*', interfaceName: string | '*', signalName: string | '*'): void; /** * Removes a signal subscription rule from the DBus daemon. * Removes a previously added match rule to stop receiving specific signals. * * @param signalRuleString - The formatted rule string to remove from the DBus daemon. */ protected offSignal(signalRuleString: string): void; /** * Creates a signal emitter for listening to DBus signals. * Constructs a DBusSignalEmitter instance to handle signal events for specific criteria. * * @param opts - Options for creating the signal emitter, including service name, object path, and interface. * @returns A DBusSignalEmitter instance for subscribing to and handling signals. */ createSignalEmitter(opts: CreateSignalEmitterOpts): DBusSignalEmitter; /** * Constructor for the DBus class. * Initializes the DBus instance with a connection and sets up event listeners for * incoming messages, connection closure, and errors. Dispatches signals to emitters. * * @param connection - The DBusConnection instance to use for low-level communication. */ constructor(connection: DBusConnection); /** * Adds an event listener for various DBus events. * Supports a range of predefined events related to service status, name ownership, * method calls, and connection state, with type-safe callback signatures. * * @param eventName - The name of the event to listen for. Specific event names have predefined * callback signatures for type safety. * @param listener - The callback function to execute when the event occurs. The signature of the * callback depends on the event name. * @returns This instance for method chaining. * * @example * dbus.on('online', (name) => console.log(`Service ${name} is online`)); * dbus.on('methodCall', (message) => console.log('Method call received:', message)); * dbus.on('connectionError', (error) => console.error('Connection error:', error)); */ on(eventName: 'online', listener: (name: string) => void): this; /** * Adds an event listener for the 'offline' event, emitted when a service goes offline. * * @param eventName - The string 'offline', indicating a service disconnection event. * @param listener - A callback function that receives the service name as an argument, invoked when a service goes offline. * @returns This instance for method chaining. */ on(eventName: 'offline', listener: (name: string) => void): this; /** * Adds an event listener for the 'replaced' event, emitted when a service owner is replaced. * * @param eventName - The string 'replaced', indicating a service ownership replacement event. * @param listener - A callback function that receives the service name as an argument, invoked when a service owner changes. * @returns This instance for method chaining. */ on(eventName: 'replaced', listener: (name: string) => void): this; /** * Adds an event listener for the 'methodCall' event, emitted when a method call is received. * * @param eventName - The string 'methodCall', indicating an incoming method call event. * @param listener - A callback function that receives a DBusMessage object as an argument, invoked on incoming method calls. * @returns This instance for method chaining. */ on(eventName: 'methodCall', listener: (message: DBusMessage) => void): this; /** * Adds an event listener for the 'NameOwnerChanged' event, emitted when a bus name owner changes. * * @param eventName - The string 'NameOwnerChanged', indicating a bus name ownership change event. * @param listener - A callback function that receives the bus name, old owner, and new owner as arguments, invoked on ownership change. * @returns This instance for method chaining. */ on(eventName: 'NameOwnerChanged', listener: (name: string, oldOwner: string, newOwner: string) => void): this; /** * Adds an event listener for the 'NameLost' event, emitted when a bus name is lost by this connection. * * @param eventName - The string 'NameLost', indicating a bus name loss event. * @param listener - A callback function that receives the bus name as an argument, invoked when a name is lost. * @returns This instance for method chaining. */ on(eventName: 'NameLost', listener: (name: string) => void): this; /** * Adds an event listener for the 'NameAcquired' event, emitted when a bus name is acquired by this connection. * * @param eventName - The string 'NameAcquired', indicating a bus name acquisition event. * @param listener - A callback function that receives the bus name as an argument, invoked when a name is acquired. * @returns This instance for method chaining. */ on(eventName: 'NameAcquired', listener: (name: string) => void): this; /** * Adds an event listener for the 'connectionClose' event, emitted when the DBus connection is closed. * * @param eventName - The string 'connectionClose', indicating a connection closure event. * @param listener - A callback function with no arguments, invoked when the connection closes. * @returns This instance for method chaining. */ on(eventName: 'connectionClose', listener: () => void): this; /** * Adds an event listener for the 'connectionError' event, emitted when an error occurs on the DBus connection. * * @param eventName - The string 'connectionError', indicating a connection error event. * @param listener - A callback function that receives an Error object as its argument, invoked when an error occurs. * @returns This instance for method chaining. */ on(eventName: 'connectionError', listener: (error: Error) => void): this; /** * Adds an event listener for a generic or custom event name as a string. * This overload allows for flexibility with event names not predefined in the class. * * @param eventName - A string representing any custom or non-predefined event name. * @param listener - A callback function accepting variable arguments, used for handling custom events. * @returns This instance for method chaining. */ on(eventName: string, listener: (...args: any[]) => void): this; /** * Adds a one-time event listener for various DBus events. * The listener is executed only once when the specified event occurs and is then removed. * Supports a range of predefined events with type-safe callback signatures. * * @param eventName - The name of the event to listen for. Specific event names have predefined * callback signatures for type safety. * @param listener - The callback function to execute once when the event occurs. The signature of * the callback depends on the event name. * @returns This instance for method chaining. * * @example * dbus.once('online', (name) => console.log(`Service ${name} is online`)); * dbus.once('methodCall', (message) => console.log('First method call:', message)); * dbus.once('connectionError', (error) => console.error('First error:', error)); */ once(eventName: 'online', listener: (name: string) => void): this; /** * Adds a one-time event listener for the 'offline' event, emitted when a service goes offline. * * @param eventName - The string 'offline', indicating a service disconnection event. * @param listener - A callback function that receives the service name as an argument, invoked once when a service goes offline. * @returns This instance for method chaining. */ once(eventName: 'offline', listener: (name: string) => void): this; /** * Adds a one-time event listener for the 'replaced' event, emitted when a service owner is replaced. * * @param eventName - The string 'replaced', indicating a service ownership replacement event. * @param listener - A callback function that receives the service name as an argument, invoked once when a service owner changes. * @returns This instance for method chaining. */ once(eventName: 'replaced', listener: (name: string) => void): this; /** * Adds a one-time event listener for the 'methodCall' event, emitted when a method call is received. * * @param eventName - The string 'methodCall', indicating an incoming method call event. * @param listener - A callback function that receives a DBusMessage object as an argument, invoked once on an incoming method call. * @returns This instance for method chaining. */ once(eventName: 'methodCall', listener: (message: DBusMessage) => void): this; /** * Adds a one-time event listener for the 'NameOwnerChanged' event, emitted when a bus name owner changes. * * @param eventName - The string 'NameOwnerChanged', indicating a bus name ownership change event. * @param listener - A callback function that receives the bus name, old owner, and new owner as arguments, invoked once on ownership change. * @returns This instance for method chaining. */ once(eventName: 'NameOwnerChanged', listener: (name: string, oldOwner: string, newOwner: string) => void): this; /** * Adds a one-time event listener for the 'NameLost' event, emitted when a bus name is lost by this connection. * * @param eventName - The string 'NameLost', indicating a bus name loss event. * @param listener - A callback function that receives the bus name as an argument, invoked once when a name is lost. * @returns This instance for method chaining. */ once(eventName: 'NameLost', listener: (name: string) => void): this; /** * Adds a one-time event listener for the 'NameAcquired' event, emitted when a bus name is acquired by this connection. * * @param eventName - The string 'NameAcquired', indicating a bus name acquisition event. * @param listener - A callback function that receives the bus name as an argument, invoked once when a name is acquired. * @returns This instance for method chaining. */ once(eventName: 'NameAcquired', listener: (name: string) => void): this; /** * Adds a one-time event listener for the 'connectionClose' event, emitted when the DBus connection is closed. * * @param eventName - The string 'connectionClose', indicating a connection closure event. * @param listener - A callback function with no arguments, invoked once when the connection closes. * @returns This instance for method chaining. */ once(eventName: 'connectionClose', listener: () => void): this; /** * Adds a one-time event listener for the 'connectionError' event, emitted when an error occurs on the DBus connection. * * @param eventName - The string 'connectionError', indicating a connection error event. * @param listener - A callback function that receives an Error object as its argument, invoked once when an error occurs. * @returns This instance for method chaining. */ once(eventName: 'connectionError', listener: (error: Error) => void): this; /** * Adds a one-time event listener for a generic or custom event name as a string. * This overload allows for flexibility with event names not predefined in the class. * * @param eventName - A string representing any custom or non-predefined event name. * @param listener - A callback function accepting variable arguments, used for handling custom events once. * @returns This instance for method chaining. */ once(eventName: string, listener: (...args: any[]) => void): this; /** * Removes an event listener for various DBus events. * Removes a previously registered callback for a specific event type. * Supports a range of predefined events with type-safe callback signatures. * * @param eventName - The name of the event to remove the listener from. Specific event names have predefined * callback signatures for type safety. * @param listener - The callback function to remove from the event listeners. * @returns This instance for method chaining. * * @example * const handler = (name) => console.log(`Service ${name} is online`); * dbus.on('online', handler); * dbus.off('online', handler); // Removes the handler */ off(eventName: 'online', listener: (name: string) => void): this; /** * Removes an event listener for the 'offline' event, related to a service going offline. * * @param eventName - The string 'offline', indicating a service disconnection event. * @param listener - The callback function to remove, which receives the service name as an argument. * @returns This instance for method chaining. */ off(eventName: 'offline', listener: (name: string) => void): this; /** * Removes an event listener for the 'replaced' event, related to a service owner being replaced. * * @param eventName - The string 'replaced', indicating a service ownership replacement event. * @param listener - The callback function to remove, which receives the service name as an argument. * @returns This instance for method chaining. */ off(eventName: 'replaced', listener: (name: string) => void): this; /** * Removes an event listener for the 'methodCall' event, related to incoming method calls. * * @param eventName - The string 'methodCall', indicating an incoming method call event. * @param listener - The callback function to remove, which receives a DBusMessage object as an argument. * @returns This instance for method chaining. */ off(eventName: 'methodCall', listener: (message: DBusMessage) => void): this; /** * Removes an event listener for the 'NameOwnerChanged' event, related to bus name owner changes. * * @param eventName - The string 'NameOwnerChanged', indicating a bus name ownership change event. * @param listener - The callback function to remove, which receives the bus name, old owner, and new owner as arguments. * @returns This instance for method chaining. */ off(eventName: 'NameOwnerChanged', listener: (name: string, oldOwner: string, newOwner: string) => void): this; /** * Removes an event listener for the 'NameLost' event, related to losing a bus name. * * @param eventName - The string 'NameLost', indicating a bus name loss event. * @param listener - The callback function to remove, which receives the bus name as an argument. * @returns This instance for method chaining. */ off(eventName: 'NameLost', listener: (name: string) => void): this; /** * Removes an event listener for the 'NameAcquired' event, related to acquiring a bus name. * * @param eventName - The string 'NameAcquired', indicating a bus name acquisition event. * @param listener - The callback function to remove, which receives the bus name as an argument. * @returns This instance for method chaining. */ off(eventName: 'NameAcquired', listener: (name: string) => void): this; /** * Removes an event listener for the 'connectionClose' event, related to DBus connection closure. * * @param eventName - The string 'connectionClose', indicating a connection closure event. * @param listener - The callback function to remove, which has no arguments. * @returns This instance for method chaining. */ off(eventName: 'connectionClose', listener: () => void): this; /** * Removes an event listener for the 'connectionError' event, related to DBus connection errors. * * @param eventName - The string 'connectionError', indicating a connection error event. * @param listener - The callback function to remove, which receives an Error object as an argument. * @returns This instance for method chaining. */ off(eventName: 'connectionError', listener: (error: Error) => void): this; /** * Removes an event listener for a generic or custom event name as a string. * This overload allows for flexibility with event names not predefined in the class. * * @param eventName - A string representing any custom or non-predefined event name. * @param listener - The callback function to remove, accepting variable arguments for custom events. * @returns This instance for method chaining. */ off(eventName: string, listener: (...args: any[]) => void): this; /** * Removes a specific event listener (alias for `off`). * Removes a previously registered callback for a specific event type. * Supports a range of predefined events with type-safe callback signatures. * * @param eventName - The name of the event to remove the listener from. Specific event names have predefined * callback signatures for type safety. * @param listener - The callback function to remove from the event listeners. * @returns This instance for method chaining. * * @example * const handler = (name) => console.log(`Service ${name} is online`); * dbus.on('online', handler); * dbus.removeListener('online', handler); // Removes the handler */ removeListener(eventName: 'online', listener: (name: string) => void): this; /** * Removes an event listener for the 'offline' event, related to a service going offline. * * @param eventName - The string 'offline', indicating a service disconnection event. * @param listener - The callback function to remove, which receives the service name as an argument. * @returns This instance for method chaining. */ removeListener(eventName: 'offline', listener: (name: string) => void): this; /** * Removes an event listener for the 'replaced' event, related to a service owner being replaced. * * @param eventName - The string 'replaced', indicating a service ownership replacement event. * @param listener - The callback function to remove, which receives the service name as an argument. * @returns This instance for method chaining. */ removeListener(eventName: 'replaced', listener: (name: string) => void): this; /** * Removes an event listener for the 'methodCall' event, related to incoming method calls. * * @param eventName - The string 'methodCall', indicating an incoming method call event. * @param listener - The callback function to remove, which receives a DBusMessage object as an argument. * @returns This instance for method chaining. */ removeListener(eventName: 'methodCall', listener: (message: DBusMessage) => void): this; /** * Removes an event listener for the 'NameOwnerChanged' event, related to bus name owner changes. * * @param eventName - The string 'NameOwnerChanged', indicating a bus name ownership change event. * @param listener - The callback function to remove, which receives the bus name, old owner, and new owner as arguments. * @returns This instance for method chaining. */ removeListener(eventName: 'NameOwnerChanged', listener: (name: string, oldOwner: string, newOwner: string) => void): this; /** * Removes an event listener for the 'NameLost' event, related to losing a bus name. * * @param eventName - The string 'NameLost', indicating a bus name loss event. * @param listener - The callback function to remove, which receives the bus name as an argument. * @returns This instance for method chaining. */ removeListener(eventName: 'NameLost', listener: (name: string) => void): this; /** * Removes an event listener for the 'NameAcquired' event, related to acquiring a bus name. * * @param eventName - The string 'NameAcquired', indicating a bus name acquisition event. * @param listener - The callback function to remove, which receives the bus name as an argument. * @returns This instance for method chaining. */ removeListener(eventName: 'NameAcquired', listener: (name: string) => void): this; /** * Removes an event listener for the 'connectionClose' event, related to DBus connection closure. * * @param eventName - The string 'connectionClose', indicating a connection closure event. * @param listener - The callback function to remove, which has no arguments. * @returns This instance for method chaining. */ removeListener(eventName: 'connectionClose', listener: () => void): this; /** * Removes an event listener for the 'connectionError' event, related to DBus connection errors. * * @param eventName - The string 'connectionError', indicating a connection error event. * @param listener - The callback function to remove, which receives an Error object as an argument. * @returns This instance for method chaining. */ removeListener(eventName: 'connectionError', listener: (error: Error) => void): this; /** * Removes an event listener for a generic or custom event name as a string. * This overload allows for flexibility with event names not predefined in the class. * * @param eventName - A string representing any custom or non-predefined event name. * @param listener - The callback function to remove, accepting variable arguments for custom events. * @returns This instance for method chaining. */ removeListener(eventName: string, listener: (...args: any[]) => void): this; /** * Adds a match rule to receive specific signals from the DBus daemon. * Sends a method call to the DBus daemon to register the rule without waiting for a reply. * * @param rule - The match rule string specifying which signals to receive (e.g., 'type=signal,interface=org.test'). */ addMatch(rule: string): void; /** * Removes a previously added match rule from the DBus daemon. * Sends a method call to the DBus daemon to unregister the rule without waiting for a reply. * * @param rule - The match rule string to remove, previously added with addMatch. */ removeMatch(rule: string): void; /** * Retrieves the unique name of the owner of a given bus name. * Queries the DBus daemon to get the current owner of a well-known bus name. * * @param name - The bus name to query (e.g., 'org.freedesktop.DBus'). * @returns A Promise resolving to the unique name of the owner (e.g., ':1.123') or undefined if not found or an error occurs. */ getNameOwner(name: string): Promise<string | undefined>; /** * Lists all activatable bus names (services that can be started). * Retrieves a list of service names that are registered as activatable with the DBus daemon. * * @returns A Promise resolving to an array of activatable bus names (e.g., ['org.test.Service']). */ listActivatableNames(): Promise<string[]>; /** * Lists all currently active bus names. * Retrieves a list of service names that are currently active (have an owner) on the bus. * * @returns A Promise resolving to an array of active bus names (e.g., ['org.test.Service', ':1.123']). */ listNames(): Promise<string[]>; /** * Checks if a given bus name currently has an owner. * Queries the DBus daemon to determine if a specific bus name is currently owned by a connection. * * @param name - The bus name to check (e.g., 'org.test.Service'). * @returns A Promise resolving to a boolean indicating if the name has an owner (true) or not (false). */ nameHasOwner(name: string): Promise<boolean>; /** * Requests ownership of a bus name with specified flags. * Attempts to acquire a well-known bus name for this connection, with options for behavior on conflict. * * @param name - The bus name to request (e.g., 'org.my.Service'). * @param flags - Optional flags for the request behavior (default: RequestNameFlags.DBUS_NAME_FLAG_DEFAULT). * @returns A Promise resolving to a result code indicating success or the reason for failure (e.g., RequestNameResultCode.DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER). */ requestName(name: string, flags?: RequestNameFlags): Promise<RequestNameResultCode>; /** * Releases ownership of a bus name. * Releases a previously acquired well-known bus name, allowing others to claim it. * * @param name - The bus name to release (e.g., 'org.my.Service'). * @returns A Promise resolving to a numeric result code indicating the outcome of the release operation. */ releaseName(name: string): Promise<number>; /** * Reloads the DBus daemon configuration. * Requests the DBus daemon to reload its configuration files, typically for administrative purposes. * * @returns A Promise that resolves when the configuration reload request is sent and processed. */ reloadConfig(): Promise<void>; /** * Starts a service by its bus name. * Requests the DBus daemon to activate a service if it is activatable and not currently running. * * @param name - The bus name of the service to start (e.g., 'org.my.Service'). * @param flags - Optional flags for starting the service (default: 0, no specific flags). * @returns A Promise resolving to a numeric result code indicating the outcome of the start operation. */ startServiceByName(name: string, flags?: number): Promise<number>; /** * Retrieves the Unix process ID of a connection by its bus name. * Queries the DBus daemon to get the PID of the process owning a specific bus name. * * @param name - The bus name of the connection (e.g., 'org.my.Service' or ':1.123'). * @returns A Promise resolving to the process ID as a number, or undefined if not found or an error occurs. */ getConnectionUnixProcessID(name: string): Promise<number | undefined>; /** * Disconnects from the DBus daemon. * Closes the underlying connection stream, ending communication with the daemon. * * @returns A Promise that resolves when the connection is fully closed. */ disconnect(): Promise<void>; /** * Lists all bus names, including active and activatable ones, with detailed information. * Combines active and activatable names, fetching additional details like owner and PID. * * @returns A Promise resolving to an array of bus name information objects, including name, unique name, active status, activatable status, and PID. */ listBusNames(): Promise<BusNameBasicInfo[]>; /** * Lists all services (bus names that are not unique connection names). * Filters out unique connection names (e.g., ':1.123') to return only well-known service names. * * @returns A Promise resolving to an array of service information objects, excluding unique connection names. */ listServices(): Promise<ServiceBasicInfo[]>; /** * Retrieves all services as DBusService instances. * Converts the list of service information into instantiated DBusService objects for interaction. * * @returns A Promise resolving to an array of DBusService instances representing all available services. */ getServices(): Promise<DBusService[]>; /** * Retrieves a specific service by its bus name. * Starts the service if it is activatable but not currently active, and throws an error if not found. * * @param service - The bus name of the service to retrieve (e.g., 'org.my.Service'). * @returns A Promise resolving to a DBusService instance for the specified service. * @throws {ServiceNotFoundError} If the service is not found in active or activatable lists, or if it has no connection. */ getService(service: string): Promise<DBusService>; /** * Retrieves a specific DBus object by service and object path. * Fetches the service first, then constructs or retrieves the object at the specified path. * * @param service - The bus name of the service (e.g., 'org.my.Service'). * @param objectPath - The object path to retrieve (e.g., '/org/my/Object'). * @returns A Promise resolving to a DBusObject instance for the specified path under the service. */ getObject(service: string, objectPath: string): Promise<DBusObject>; /** * Retrieves a specific DBus interface by service, object path, and interface name. * Fetches the object first, then retrieves or constructs the specified interface on that object. * * @param service - The bus name of the service (e.g., 'org.my.Service'). * @param objectPath - The object path of the object (e.g., '/org/my/Object'). * @param iface - The interface name to retrieve (e.g., 'org.my.Interface'). * @returns A Promise resolving to a DBusInterface instance for the specified interface. */ getInterface(service: string, objectPath: string, iface: string): Promise<DBusInterface>; } //# sourceMappingURL=DBus.d.ts.map