import 'dart:io'; import 'package:dbus/dbus.dart'; class ComExampleTest extends DBusObject { /// Creates a new object to expose on [path]. ComExampleTest({DBusObjectPath path = const DBusObjectPath.unchecked('/')}) : super(path); /// Implementation of com.example.Test.Hello() Future doHello(String value) async { } @override List introspect() { return [DBusIntrospectInterface('com.example.Test', methods: [DBusIntrospectMethod('Hello', args: [DBusIntrospectArgument(DBusSignature('s'), DBusArgumentDirection.in_, name: 'value')])])]; } @override Future handleMethodCall(DBusMethodCall methodCall) async { if (methodCall.interface == 'com.example.Test') { if (methodCall.name == 'Hello') { if (methodCall.signature != DBusSignature('s')) { return DBusMethodErrorResponse.invalidArgs(); } await doHello(methodCall.values[0].asString()); return DBusMethodSuccessResponse(); } else { return DBusMethodErrorResponse.unknownMethod(); } } else { return DBusMethodErrorResponse.unknownInterface(); } } @override Future getProperty(String interface, String name) async { if (interface == 'com.example.Test') { return DBusMethodErrorResponse.unknownProperty(); } else { return DBusMethodErrorResponse.unknownProperty(); } } @override Future setProperty(String interface, String name, DBusValue value) async { if (interface == 'com.example.Test') { return DBusMethodErrorResponse.unknownProperty(); } else { return DBusMethodErrorResponse.unknownProperty(); } } }