mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
- Added dbus typings (#35481)
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
3492c0644a
commit
dbe44d6d01
@@ -0,0 +1,19 @@
|
||||
import * as DBus from "dbus";
|
||||
|
||||
const dbus = DBus.getBus("system");
|
||||
|
||||
dbus.getInterface("org.bluez", "/org/bluez/hci0", "org.bluez.Media1", (err, iface) => {});
|
||||
|
||||
dbus.getInterface("org.bluez", "/org/bluez/hci0", "org.bluez.Adapter1", (err, iface) => {
|
||||
if (!err) {
|
||||
iface.setProperty("Powered", true, err => {});
|
||||
}
|
||||
});
|
||||
|
||||
dbus.disconnect();
|
||||
|
||||
const agentPath = "/test/my/agent";
|
||||
const agentService = DBus.registerService("system", agentPath.split("/").slice(1).join("."));
|
||||
const agentObj = agentService.createObject(agentPath);
|
||||
const agentIface = agentObj.createInterface("org.bluez.Agent1");
|
||||
agentIface.addMethod("Release", {in: "", out: ""}, () => {});
|
||||
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
// Type definitions for dbus 1.0
|
||||
// Project: https://github.com/Shouqun/node-dbus#readme
|
||||
// Definitions by: Luca Lindhorst <https://github.com/lal12>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export type busType = "session"|"system";
|
||||
export function getBus(type: busType): DBusConnection;
|
||||
export function registerService(busName: busType, serviceName: string): DBusService;
|
||||
export interface DBusConnection {
|
||||
getInterface(serviceName: string, objectPath: string, interfaceName: string, callback: (err: DBusError, iface: DBusInterface) => void): void;
|
||||
disconnect(): void;
|
||||
}
|
||||
|
||||
export interface DBusInterface {
|
||||
getProperty(name: string, callback: (err: DBusError, name: string) => void): void;
|
||||
setProperty(name: string, value: any, callback: (err: DBusError) => void): void;
|
||||
getProperties(callback: (err: DBusError, properties: Array<{[name: string]: any}>) => void): void;
|
||||
/**
|
||||
* ...args
|
||||
* options: {timeout: number}
|
||||
* callback: (err: DBusError|undefined, res: any)=>void
|
||||
*/
|
||||
[methodName: string]: (...args: any[]) => void;
|
||||
}
|
||||
|
||||
export interface DBusService {
|
||||
createObject(path: string): DBusServiceObject;
|
||||
removeObject(service: DBusServiceObject): void;
|
||||
disconnect(): void;
|
||||
}
|
||||
|
||||
export interface DBusServiceObject {
|
||||
createInterface(name: string): DBusServiceInterface;
|
||||
}
|
||||
|
||||
export type PropsCB = (err: DBusError|undefined, value: any) => void;
|
||||
export interface DBusServiceInterface {
|
||||
addMethod(method: string, opts: {in: string, out: string}, handler: (name: string, quality: any, callback: (res: any) => void) => void): void;
|
||||
addProperty(name: string, opts: {
|
||||
type: string,
|
||||
getter: (cb: (val: string) => void) => void,
|
||||
setter?: (value: any, done: () => void) => void
|
||||
}): void;
|
||||
addSignal(name: string, opts: {types: string[]}): void;
|
||||
emitSignal(name: string, ...values: any[]): void;
|
||||
update(): void;
|
||||
}
|
||||
|
||||
export class DBusError extends Error {
|
||||
readonly dbusName: string;
|
||||
constructor(name: string, message: string);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"dbus-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user