Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming conflicts with NetworkManager's PropertiesChanged signals #99

Closed
jpnurmi opened this issue Sep 4, 2020 · 9 comments · Fixed by #133
Closed

Naming conflicts with NetworkManager's PropertiesChanged signals #99

jpnurmi opened this issue Sep 4, 2020 · 9 comments · Fixed by #133

Comments

@jpnurmi
Copy link
Contributor

jpnurmi commented Sep 4, 2020

NetworkManager has some annoying deprecated PropertiesChanged signals, which are causing naming conflicts with DBusRemoteObject.subscribePropertiesChanged().

  • org.freedesktop.NetworkManager.PropertiesChanged
  • org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged
  • org.freedesktop.NetworkManager.Device.PropertiesChanged
  • ...

For example:

$ dart-dbus generate-remote-object org.freedesktop.NetworkManager.xml

=>

  /// Subscribes to org.freedesktop.NetworkManager.PropertiesChanged
  Future<DBusSignalSubscription> subscribePropertiesChanged(void Function(Map<String, DBusValue> properties) callback) async {
    return await subscribeSignal('org.freedesktop.NetworkManager', 'PropertiesChanged', (values) {
      if (values.length == 1 && values[0].signature == DBusSignature('a{sv}')) {
        callback((values[0] as DBusDict).children.map((key, value) => MapEntry((key as DBusString).value, (value as DBusVariant).value)));
      }
    });
  }

=>

'OrgFreedesktopNetworkManager.subscribePropertiesChanged' ('Future Function(void Function(Map<String, DBusValue>))') isn't a valid override of 'DBusRemoteObject.subscribePropertiesChanged' ('Future Function(void Function(String, Map<String, DBusValue>, List))').

@robert-ancell
Copy link
Contributor

At the top of dart-dbus.dart:

// FIXME(robert-ancell): Check for method name collisions

I was considering if we want to namespace each interface, but it feels like it might be overkill for most cases. So I think the pragmatic solution is to detect the few collisions that occur and add something to the names for those cases only.

@Piero512
Copy link

Hey, I am in the process of writing a dart based connection to Avahi's DBus interface, and since I am not very familiar with how DBus works exactly, is it okay if I edit the generated code and rename the collisions or would something change?

/// Signal data for org.freedesktop.Avahi.AddressResolver.Found.
class OrgFreedesktopDBusIntrospectableFound extends DBusSignal{
  int get interface => (values[0] as DBusInt32).value;
  int get protocol => (values[1] as DBusInt32).value;
  int get aprotocol => (values[2] as DBusInt32).value;
  String get address => (values[3] as DBusString).value;
  String get name => (values[4] as DBusString).value;
  int get flags => (values[5] as DBusUint32).value;

  OrgFreedesktopDBusIntrospectableFound(DBusSignal signal) : super(signal.sender, signal.path, signal.interface, signal.member, signal.values);
}

In this example, the interface name collides with the super class method.

@robert-ancell
Copy link
Contributor

robert-ancell commented Feb 17, 2021

@Piero512 you can edit the generated code and change the names, this API is only used by your app, and the DBus code doesn't call them.

@robert-ancell
Copy link
Contributor

This should be greatly improved in 0.1.2.

@wstrange
Copy link

I think I am running into this issue. I generated a dart file from the systemd1 xml interface.

The generated code has an error:

class OrgFreedesktopDBusPeer extends DBusRemoteObject {
  /// Stream of org.freedesktop.DBus.Properties.PropertiesChanged signals.
  /// ERROR: Isn't a valid override: supertype is <DBusPropertiesChangedSignal>
  late final Stream<OrgFreedesktopDBusPeerPropertiesChanged> propertiesChanged;

...

@robert-ancell
Copy link
Contributor

If your XML file is the same one as the one I found with an internet search it contains definitions for the standard interfaces. You should remove these, and we should probably detect this and ignore them in the generator. Please open a new issue for this if this is a problem.

@wstrange
Copy link

I generated the XML using the following Dart code:

 var client = DBusClient.system();
    var sysd = DBusRemoteObject(client,
        name: 'org.freedesktop.systemd1',
        path: DBusObjectPath('/org/freedesktop/systemd1'));

    var m = await sysd.introspect();

    var f = File('systemd.xml');
    f.writeAsStringSync('${m.toXml()}');

@robert-ancell
Copy link
Contributor

@wstrange I've opened #375 to handle that case.

@robert-ancell
Copy link
Contributor

Note that the original issue here was different interfaces that used the same method names. The case I've opened the new issue for is standard interfaces being defined and dbus.dart generating code for them that is already provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants