connect method

Future<void> connect()

Connects to the fwupd daemon.

Implementation

Future<void> connect() async {
  // Already connected
  if (_propertiesChangedSubscription != null) {
    return;
  }

  _propertiesChangedSubscription = _root.propertiesChanged.listen((signal) {
    if (signal.propertiesInterface == 'org.freedesktop.fwupd') {
      _updateProperties(signal.changedProperties);
    }
  });
  _updateProperties(await _root.getAllProperties('org.freedesktop.fwupd'));

  var deviceAdded = DBusRemoteObjectSignalStream(
      object: _root, interface: 'org.freedesktop.fwupd', name: 'DeviceAdded');
  _deviceAddedSubscription = deviceAdded.listen((signal) =>
      _deviceAdded((signal.values[0] as DBusDict).mapStringVariant()));

  var deviceChanged = DBusRemoteObjectSignalStream(
      object: _root,
      interface: 'org.freedesktop.fwupd',
      name: 'DeviceChanged');
  _deviceChangedSubscription = deviceChanged.listen((signal) =>
      _deviceChanged((signal.values[0] as DBusDict).mapStringVariant()));

  var deviceRemoved = DBusRemoteObjectSignalStream(
      object: _root,
      interface: 'org.freedesktop.fwupd',
      name: 'DeviceRemoved');
  _deviceRemovedSubscription = deviceRemoved.listen((signal) =>
      _deviceRemoved((signal.values[0] as DBusDict).mapStringVariant()));
}