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); /// Gets value of property com.example.Test.Value Future getValue() async { return DBusMethodErrorResponse.failed('Get com.example.Test.Value not implemented'); } /// Sets property com.example.Test.Value Future setValue(String value) async { return DBusMethodErrorResponse.failed('Set com.example.Test.Value not implemented'); } @override List introspect() { return [DBusIntrospectInterface('com.example.Test', properties: [DBusIntrospectProperty('Value', DBusSignature('s'), access: DBusPropertyAccess.readwrite)])]; } @override Future handleMethodCall(DBusMethodCall methodCall) async { if (methodCall.interface == 'com.example.Test') { return DBusMethodErrorResponse.unknownMethod(); } else { return DBusMethodErrorResponse.unknownInterface(); } } @override Future getProperty(String interface, String name) async { if (interface == 'com.example.Test') { if (name == 'Value') { return getValue(); } else { return DBusMethodErrorResponse.unknownProperty(); } } else { return DBusMethodErrorResponse.unknownProperty(); } } @override Future setProperty(String interface, String name, DBusValue value) async { if (interface == 'com.example.Test') { if (name == 'Value') { if (value.signature != DBusSignature('s')) { return DBusMethodErrorResponse.invalidArgs(); } return setValue(value.asString()); } else { return DBusMethodErrorResponse.unknownProperty(); } } else { return DBusMethodErrorResponse.unknownProperty(); } } @override Future getAllProperties(String interface) async { var properties = {}; if (interface == 'com.example.Test') { properties['Value'] = (await getValue()).returnValues[0]; } return DBusMethodSuccessResponse([DBusDict.stringVariant(properties)]); } }