On Fri, 2012-10-19 at 14:39 +0200, Pietro Battiston wrote: > Hello, > > I'd like to some apparently simple thing with nm dbus signals: > > 1) get warned that a connection has been activated > 2) do something based on _which_ connection it is. > > Unfortunately all I was able to do so far is: > > 1) get warned that a connection has been activated (by listening at the > dbus interface "org.freedesktop.NetworkManager.Connection.Active") > 2) find out which connections are currently active (by getting the > "ActiveConnections" list from "org.freedesktop.NetworkManager") > 3) pick one of them, not knowing which was just activated rather than > being already active before.
Simplest would be to monitor the "ActiveConnections" property of the org.freedesktop.NetworkManager interface on the /org/freedesktop/NetworkManager interface. When that property changes, which is conveyed to you via the PropertiesChanged signals, you know a connection has been activated or deactivated. At the moment, you need to monitor those objects and listen to their State property to figure out which one gets activated or deactivated, which is a bit more complicated than you probably want. But there is a "UUID" property of the ActiveConnection objects which is exactly what you want for #2. Dan > Basically, I'm currently combining > http://blog.g00se.org/2009/01/getting-dbus-messages-from.html > with > http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python/nm-state.py > > Is there something obvious that I missed? > > Or maybe the right question should be: since among the properties of > http://projects.gnome.org/NetworkManager/developers/api/09/spec.html#org.freedesktop.NetworkManager.Connection.Active > there is also "Connection", why does the dictionary received by the > signal handler of signal "PropertiesChanged" when a connection is > activated contain only parameters "Default" and "State"? > > thanks in advance > > Pietro > > _______________________________________________ > networkmanager-list mailing list > [email protected] > https://mail.gnome.org/mailman/listinfo/networkmanager-list _______________________________________________ networkmanager-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/networkmanager-list
