getProperty method

  1. @override
Future<DBusMethodResponse> getProperty(
  1. String interface,
  2. String name
)

Called when a property is requested on this object. On success, return DBusGetPropertyResponse.

Implementation

@override
Future<DBusMethodResponse> getProperty(String interface, String name) async {
  if (interface != _advertInterfaceName) {
    return DBusMethodErrorResponse.unknownInterface();
  }

  switch (name) {
    case 'ManufacturerData':
      return DBusGetPropertyResponse(DBusDict(
          DBusSignature('q'),
          DBusSignature('v'),
          manufacturerData.map((id, value) =>
              MapEntry(DBusUint16(id.id), DBusVariant(value)))));
    case 'Type':
      return DBusGetPropertyResponse(DBusString(type.name));
    case 'ServiceUUIDs':
      return DBusGetPropertyResponse(DBusArray.string(serviceUuids));
    case 'ServiceData':
      return DBusGetPropertyResponse(DBusDict.stringVariant(serviceData
          .map((uuid, value) => MapEntry(uuid.toString(), value))));
    case 'IncludeTxPower':
      return DBusGetPropertyResponse(DBusBoolean(includeTxPower));
    case 'SolicitUUIDs':
      return DBusGetPropertyResponse(DBusArray.string(solicitUuids));
    case 'Includes':
      return DBusGetPropertyResponse(DBusArray.string(includes));
    case 'Appearance':
      return DBusGetPropertyResponse(DBusUint16(appearance));
    case 'Duration':
      return DBusGetPropertyResponse(DBusUint16(duration));
    case 'Timeout':
      return DBusGetPropertyResponse(DBusUint16(timeout));
    case 'LocalName':
      return DBusGetPropertyResponse(DBusString(localName));
    default:
      return DBusMethodErrorResponse.unknownProperty();
  }
}