Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Donnerstag, 15. Juli 2021 09:17:00 CEST Andrei Borzenkov wrote: > On Wed, Jul 14, 2021 at 5:52 PM Thomas Haller via networkmanager-list > > wrote: > > So, yes, there should be not much to do except replace the interface > > name "org.freedesktop.NetworkManager*" with > > "org.freedesktop.DBus.Properties". > > It is probably oversimplified. Signatures are different, so any code > that handles these signals has to be modified to account for it. Also > NM signal unambiguously identifies a specific interface, while D-Bus > signal can come from any interface object implements, so additional > verification that we are dealing with the expected interface is needed > before properties can be interpreted. I'm not sure, if I really did it right, but this one seems to work as expected (at least as it did before): !/usr/bin/perl -w use strict; use Data::Dumper; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 1; use Net::DBus; use Net::DBus::Dumper; use Net::DBus::Reactor; my $oBUS = Net::DBus->system || die $!; my $nm = "org.freedesktop.NetworkManager"; my $oNMSVC = $oBUS->get_service( $nm ) || die $!; my $nmobjpath = "/org/freedesktop/NetworkManager"; my $nmif = "org.freedesktop.NetworkManager"; my $oNMIF = $oNMSVC->get_object( $nmobjpath, $nmif ) || die $!; my $busif = "org.freedesktop.DBus.Properties"; my $oBUSIF = $oNMSVC->get_object( $nmobjpath, $busif ); $oBUSIF->connect_to_signal( "PropertiesChanged", sub { &{ \_onNMPropertiesChanged }( $oNMSVC, $oNMIF, @_ ); } ) || die $!; my $reactor = Net::DBus::Reactor->main() || die $!; $reactor->run() || die $!; sub dbnm_onNMPropertiesChanged { my( $oNMSVC, $oNMIF, $props, $propsinval ) = @_; print "got `PropertiesChanged` signal for NetworkManager:\n"; my $sprop = 'ActiveConnections'; if( ref( $props ) eq 'HASH' ) { print "\n- props -\n", Dumper( $props ), "\n--\n"; if( exists( $props->{ $sprop } ) ) { _HandleAllActiveConnections( "PropertiesChanged (NM)", $props->{ $sprop }, $oNMSVC, $oNMIF ); } } elsif( ref( $propsinval ) eq 'HASH' ) { print "\n- propsinval -\n", Dumper( $propsinval ), "\n--\n"; if( exists( $propsinval->{ $sprop } ) ) { _HandleAllActiveConnections( "PropertiesChanged (NM)", $propsinval->{ $sprop }, $oNMSVC, $oNMIF ); } } else { print "WARNING: Expected some property hash, but got `", ref( $props ), "` and `", ref( $propsinval ), "`!\n"; } } Thx to you both! Bye. Michael. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Donnerstag, 15. Juli 2021 10:43:27 CEST Andrei Borzenkov wrote: > On Thu, Jul 15, 2021 at 11:27 AM wrote: > > On Donnerstag, 15. Juli 2021 06:45:06 CEST Andrei Borzenkov via > > networkmanager-list wrote: > > [...] > > > > > > #!/usr/bin/perl -w > > > > > > > > use strict; > > > > > > > > use Data::Dumper; > > > > $Data::Dumper::Sortkeys = 1; > > > > $Data::Dumper::Indent = 1; > > > > use Net::DBus; > > > > use Net::DBus::Dumper; > > > > use Net::DBus::Reactor; > > > > > > > > my $oBUS = Net::DBus->system || die $!; > > > > my $nm = "org.freedesktop.NetworkManager"; > > > > my $oNM = $oBUS->get_service( $nm ) || die $!; > > > > my $nmobjpath = "/org/freedesktop/NetworkManager"; > > > > my $nmif = "org.freedesktop.NetworkManager"; > > my $nmif = "org.freedesktop.DBus.Properties"; > > > > > my $oNMIF = $oNM->get_object( $nmobjpath, $nmif ) || die $!; > > > > > > > > $nmobjpath = "/org/freedesktop/NetworkManager/Settings"; > > > > $nmif = "org.freedesktop.NetworkManager.Settings"; > > my $nmif = "org.freedesktop.DBus.Properties"; > > > > > my $oNMIFS = $oNM->get_object( $nmobjpath, $nmif ) || die $!; > > > > > > > > $oNMIF->connect_to_signal( > > > > > > > > "PropertiesChanged", sub { > > > > > > > > &{ \_onNMPropertiesChanged }( $oNM, $oNMIF, $oNMIFS, @_ ); > > > > > > > > } > > > > > > > > ); > > > > my $reactor = Net::DBus::Reactor->main() || die $!; > > > > $reactor->run() || die $!; > > > > > > > > sub dbnm_onNMPropertiesChanged { > > > > > > > > my( $oNM, $oNMIF, $oNMIFS, $props ) = @_; > > my( $oNM, $oNMIF, $oNMIFS, $interface, $props, $invalidated_props ) = @_; > > > > > print "\n- props -\n", Dumper( $props ), "\n--\n"; > > > > > > > > } > > > > > > NM PropertiesChanged and D-Bus > > > org.freedesktop.DBus.Properties.PropertiesChanged have different > > > signatures. You are dumping interface name, not properties dictionary. > > > > I am not sure, I understand this: > > The example above is the one for NetworkManager's PropertiesChanged > > signal. > > It worked perfectly as long as this signal existed. > > If you replace NM signal with DBus signal you also need to change > handler to look for different parameter > > > Besides that, what does "signature" mean in this context? Different > > parameters? > > Yes. So last questions regarding signatures: A handler only is accepted, if all parameters are correct? Or - a handler is accepted, but not executed, if paramaters are not correct? Thx and bye. Michael. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Thu, Jul 15, 2021 at 11:27 AM wrote: > > On Donnerstag, 15. Juli 2021 06:45:06 CEST Andrei Borzenkov via > networkmanager-list wrote: > [...] > > > #!/usr/bin/perl -w > > > > > > use strict; > > > > > > use Data::Dumper; > > > $Data::Dumper::Sortkeys = 1; > > > $Data::Dumper::Indent = 1; > > > use Net::DBus; > > > use Net::DBus::Dumper; > > > use Net::DBus::Reactor; > > > > > > my $oBUS = Net::DBus->system || die $!; > > > my $nm = "org.freedesktop.NetworkManager"; > > > my $oNM = $oBUS->get_service( $nm ) || die $!; > > > my $nmobjpath = "/org/freedesktop/NetworkManager"; > > > my $nmif = "org.freedesktop.NetworkManager"; my $nmif = "org.freedesktop.DBus.Properties"; > > > my $oNMIF = $oNM->get_object( $nmobjpath, $nmif ) || die $!; > > > > > > $nmobjpath = "/org/freedesktop/NetworkManager/Settings"; > > > $nmif = "org.freedesktop.NetworkManager.Settings"; my $nmif = "org.freedesktop.DBus.Properties"; > > > my $oNMIFS = $oNM->get_object( $nmobjpath, $nmif ) || die $!; > > > > > > $oNMIF->connect_to_signal( > > > > > > "PropertiesChanged", sub { > > > > > > &{ \_onNMPropertiesChanged }( $oNM, $oNMIF, $oNMIFS, @_ ); > > > > > > } > > > > > > ); > > > my $reactor = Net::DBus::Reactor->main() || die $!; > > > $reactor->run() || die $!; > > > > > > sub dbnm_onNMPropertiesChanged { > > > > > > my( $oNM, $oNMIF, $oNMIFS, $props ) = @_; my( $oNM, $oNMIF, $oNMIFS, $interface, $props, $invalidated_props ) = @_; > > > print "\n- props -\n", Dumper( $props ), "\n--\n"; > > > > > > } > > > > NM PropertiesChanged and D-Bus > > org.freedesktop.DBus.Properties.PropertiesChanged have different > > signatures. You are dumping interface name, not properties dictionary. > > I am not sure, I understand this: > The example above is the one for NetworkManager's PropertiesChanged signal. > It worked perfectly as long as this signal existed. > If you replace NM signal with DBus signal you also need to change handler to look for different parameter > Besides that, what does "signature" mean in this context? Different > parameters? > Yes. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Donnerstag, 15. Juli 2021 06:45:06 CEST Andrei Borzenkov via networkmanager-list wrote: [...] > > #!/usr/bin/perl -w > > > > use strict; > > > > use Data::Dumper; > > $Data::Dumper::Sortkeys = 1; > > $Data::Dumper::Indent = 1; > > use Net::DBus; > > use Net::DBus::Dumper; > > use Net::DBus::Reactor; > > > > my $oBUS = Net::DBus->system || die $!; > > my $nm = "org.freedesktop.NetworkManager"; > > my $oNM = $oBUS->get_service( $nm ) || die $!; > > my $nmobjpath = "/org/freedesktop/NetworkManager"; > > my $nmif = "org.freedesktop.NetworkManager"; > > my $oNMIF = $oNM->get_object( $nmobjpath, $nmif ) || die $!; > > > > $nmobjpath = "/org/freedesktop/NetworkManager/Settings"; > > $nmif = "org.freedesktop.NetworkManager.Settings"; > > my $oNMIFS = $oNM->get_object( $nmobjpath, $nmif ) || die $!; > > > > $oNMIF->connect_to_signal( > > > > "PropertiesChanged", sub { > > > > &{ \_onNMPropertiesChanged }( $oNM, $oNMIF, $oNMIFS, @_ ); > > > > } > > > > ); > > my $reactor = Net::DBus::Reactor->main() || die $!; > > $reactor->run() || die $!; > > > > sub dbnm_onNMPropertiesChanged { > > > > my( $oNM, $oNMIF, $oNMIFS, $props ) = @_; > > print "\n- props -\n", Dumper( $props ), "\n--\n"; > > > > } > > NM PropertiesChanged and D-Bus > org.freedesktop.DBus.Properties.PropertiesChanged have different > signatures. You are dumping interface name, not properties dictionary. I am not sure, I understand this: The example above is the one for NetworkManager's PropertiesChanged signal. It worked perfectly as long as this signal existed. Besides that, what does "signature" mean in this context? Different parameters? Bye. Michael. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Thu, 2021-07-15 at 10:17 +0300, Andrei Borzenkov wrote: > On Wed, Jul 14, 2021 at 5:52 PM Thomas Haller via networkmanager-list > wrote: > > > > So, yes, there should be not much to do except replace the > > interface > > name "org.freedesktop.NetworkManager*" with > > "org.freedesktop.DBus.Properties". > > > > It is probably oversimplified. Signatures are different, so any code > that handles these signals has to be modified to account for it. Also > NM signal unambiguously identifies a specific interface, while D-Bus > signal can come from any interface object implements, so additional > verification that we are dealing with the expected interface is > needed > before properties can be interpreted. I agree. You are correct!! best, Thomas ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Wed, Jul 14, 2021 at 5:52 PM Thomas Haller via networkmanager-list wrote: > > So, yes, there should be not much to do except replace the interface > name "org.freedesktop.NetworkManager*" with > "org.freedesktop.DBus.Properties". > It is probably oversimplified. Signatures are different, so any code that handles these signals has to be modified to account for it. Also NM signal unambiguously identifies a specific interface, while D-Bus signal can come from any interface object implements, so additional verification that we are dealing with the expected interface is needed before properties can be interpreted. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On 14.07.2021 19:30, m...@mike.franken.de wrote: > Hi, > > On Mittwoch, 14. Juli 2021 16:52:15 CEST Thomas Haller wrote: > [...] >>> so how can I use org.freedesktop.DBus.Properties.PropertiesChanged >>> then? >>> What would be the correct way instead? >>> Using >>> my $busobjpath = "/org/freedesktop/NetworkManager/Settings"; >>> as before? >>> This doesn't work either, though. >>> >>> Probably there is a fundamental misunderstanding regaring the concept >>> on my >>> side. >> >> Hi, >> >> I am not familiar with this Perl's Net::DBus, but in general: >> >> >> On D-Bus, you have the well-known name >> ("org.freedesktop.NetworkManager") where you find NetworkManager's D- >> Bus API. >> >> >> There, you find many D-Bus objects, at paths that start with >> "/org/freedesktop/NetworkManager". You see them with `busctl tree >> org.freedesktop.NetworkManager`. >> >> All of these objects also implement the standard D-Bus interface >> "org.freedesktop.DBus.Properties" -- as documented at >> https://dbus.freedesktop.org/doc/dbus-specification.html >> That interface, has (among) others a signal "PropertiesChanged". >> >> >> This "org.freedesktop.DBus.Properties.PropertiesChanged" signal works >> very similar to the earlier "PropertiesChanged" signals from the NM >> specific interfaces ( "org.freedesktop.NetworkManager*"). >> >> So, yes, there should be not much to do except replace the interface >> name "org.freedesktop.NetworkManager*" with >> "org.freedesktop.DBus.Properties". >> >> >> you mention specifically >> >> my $busobjpath = "/org/freedesktop/NetworkManager/Settings"; >> >> In `d-feet` you'll see that this object only has three properties. So >> you'll see few PropertiesChanged signals on that object... > > Yeah, my fault, I meant > my $busobjpath = "/org/freedesktop/NetworkManager"; > > 8-( > >> >> >> Does that help? Otherwise, please share a working, minimal example. > > Ok. > This is the working example I used before - btw. it stems from a suggestion > you made back in 2016/2017 :) > > #!/usr/bin/perl -w > > use strict; > > use Data::Dumper; > $Data::Dumper::Sortkeys = 1; > $Data::Dumper::Indent = 1; > use Net::DBus; > use Net::DBus::Dumper; > use Net::DBus::Reactor; > > my $oBUS = Net::DBus->system || die $!; > my $nm = "org.freedesktop.NetworkManager"; > my $oNM = $oBUS->get_service( $nm ) || die $!; > my $nmobjpath = "/org/freedesktop/NetworkManager"; > my $nmif = "org.freedesktop.NetworkManager"; > my $oNMIF = $oNM->get_object( $nmobjpath, $nmif ) || die $!; > > $nmobjpath = "/org/freedesktop/NetworkManager/Settings"; > $nmif = "org.freedesktop.NetworkManager.Settings"; > my $oNMIFS = $oNM->get_object( $nmobjpath, $nmif ) || die $!; > > $oNMIF->connect_to_signal( > "PropertiesChanged", sub { > &{ \_onNMPropertiesChanged }( $oNM, $oNMIF, $oNMIFS, @_ ); > } > ); > my $reactor = Net::DBus::Reactor->main() || die $!; > $reactor->run() || die $!; > > sub dbnm_onNMPropertiesChanged { > my( $oNM, $oNMIF, $oNMIFS, $props ) = @_; > print "\n- props -\n", Dumper( $props ), "\n--\n"; > } > NM PropertiesChanged and D-Bus org.freedesktop.DBus.Properties.PropertiesChanged have different signatures. You are dumping interface name, not properties dictionary. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Mittwoch, 14. Juli 2021 21:06:37 CEST m...@mike.franken.de wrote: > On Mittwoch, 14. Juli 2021 19:47:42 CEST Andrei Borzenkov via > networkmanager- list wrote: > [...] > > > > yes, but because I also need to monitor VPN changes, I have to monitor > > > /o/f/ NM. > > > > In your original mail you only said "monitor connectivity" so anything > > is just guesswork. > > Sorry, connectivity also includes VPNs for me. > > [...] > > > I do not see any reference to object here so I have no idea what this > > code does. The following certainly works > > > > def properties_changed(interface_name, changed_properties, > > > > invalidated_properties): > > print (interface_name, changed_properties, invalidated_properties) > > > > bus = dbus.SystemBus() > > my $oBUS = Net::DBus->system || die $!; > > > obj = bus.get_object("org.freedesktop.NetworkManager", > > "/org/freedesktop/NetworkManager") > > my $nm = "org.freedesktop.NetworkManager"; > my $oNMSVC = $oBUS->get_service( $nm ) || die $!; > > > iface = dbus.Interface(obj, "org.freedesktop.DBus.Properties") > > my $busobjpath = "/org/freedesktop/DBus/Properties"; my $busif = "org.freedesktop.Dbus.Properties"; > my $oBUSIF = $oNMSVC->get_object( $busobjpath ); my $oBUSIF = $oNMSVC->get_object( $busobjpath, $busif ); > > > iface.connect_to_signal("PropertiesChanged", properties_changed) > > $oBUSIF->connect_to_signal( > "PropertiesChanged", sub { > &{ \_onNMPropertiesChanged }( $oNMSVC, @_ ); > } > ); > > -> no signal with name 'PropertiesChanged' is exported in object '/org/ > freedesktop/DBus/Properties' With the above shown additions the code runs without an error, but doesn't catch a signal. > > > Bye. > Michael. > > > > ___ > networkmanager-list mailing list > networkmanager-list@gnome.org > https://mail.gnome.org/mailman/listinfo/networkmanager-list ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Mittwoch, 14. Juli 2021 21:37:43 CEST Andrei Borzenkov via networkmanager- list wrote: > import dbus, sys, uuid > from dbus.mainloop.glib import DBusGMainLoop > from gi.repository import GLib > > DBusGMainLoop(set_as_default=True) > > loop = GLib.MainLoop() > > def properties_changed(interface_name, changed_properties, > invalidated_properties): > print (interface_name, changed_properties, invalidated_properties) > > > bus = dbus.SystemBus() > obj = bus.get_object("org.freedesktop.NetworkManager", > "/org/freedesktop/NetworkManager") > iface = dbus.Interface(obj, "org.freedesktop.DBus.Properties") > iface.connect_to_signal("PropertiesChanged", properties_changed) > > loop.run() Yep, this one runs without an error and catches the signal appropriatly. Now the question is, what I am doing wrong in perl 8-/ Thx! Bye. Michael. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On 14.07.2021 21:57, m...@mike.franken.de wrote: > RuntimeError: To make asynchronous calls, receive signals or export objects, > D-Bus connections must be attached to a main loop by passing mainloop=... to > the constructor or calling dbus.set_default_main_loop(...) > > Here is full import dbus, sys, uuid from dbus.mainloop.glib import DBusGMainLoop from gi.repository import GLib DBusGMainLoop(set_as_default=True) loop = GLib.MainLoop() def properties_changed(interface_name, changed_properties, invalidated_properties): print (interface_name, changed_properties, invalidated_properties) bus = dbus.SystemBus() obj = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager") iface = dbus.Interface(obj, "org.freedesktop.DBus.Properties") iface.connect_to_signal("PropertiesChanged", properties_changed) loop.run() ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Mittwoch, 14. Juli 2021 19:47:42 CEST Andrei Borzenkov via networkmanager- list wrote: [...] > > > > yes, but because I also need to monitor VPN changes, I have to monitor > > /o/f/ NM. > > In your original mail you only said "monitor connectivity" so anything > is just guesswork. Sorry, connectivity also includes VPNs for me. [...] > I do not see any reference to object here so I have no idea what this > code does. The following certainly works > > def properties_changed(interface_name, changed_properties, > invalidated_properties): > print (interface_name, changed_properties, invalidated_properties) > > > bus = dbus.SystemBus() my $oBUS = Net::DBus->system || die $!; > obj = bus.get_object("org.freedesktop.NetworkManager", > "/org/freedesktop/NetworkManager") my $nm = "org.freedesktop.NetworkManager"; my $oNMSVC = $oBUS->get_service( $nm ) || die $!; > iface = dbus.Interface(obj, "org.freedesktop.DBus.Properties") my $busobjpath = "/org/freedesktop/DBus/Properties"; my $oBUSIF = $oNMSVC->get_object( $busobjpath ); > iface.connect_to_signal("PropertiesChanged", properties_changed) $oBUSIF->connect_to_signal( "PropertiesChanged", sub { &{ \_onNMPropertiesChanged }( $oNMSVC, @_ ); } ); -> no signal with name 'PropertiesChanged' is exported in object '/org/ freedesktop/DBus/Properties' Bye. Michael. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Mittwoch, 14. Juli 2021 19:47:42 CEST Andrei Borzenkov via networkmanager- list wrote: [...] > I do not see any reference to object here so I have no idea what this > code does. The following certainly works > > def properties_changed(interface_name, changed_properties, > invalidated_properties): > print (interface_name, changed_properties, invalidated_properties) > > > bus = dbus.SystemBus() > obj = bus.get_object("org.freedesktop.NetworkManager", > "/org/freedesktop/NetworkManager") > iface = dbus.Interface(obj, "org.freedesktop.DBus.Properties") > iface.connect_to_signal("PropertiesChanged", properties_changed) > This example doesn't work here (probaly different python version?): #!/usr/bin/python3 import dbus def properties_changed(interface_name, changed_properties, invalidated_properties): print (interface_name, changed_properties, invalidated_properties) bus = dbus.SystemBus() obj = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager") iface = dbus.Interface(obj, "org.freedesktop.DBus.Properties") iface.connect_to_signal("PropertiesChanged", properties_changed) gives: File "./b", line 13, in iface.connect_to_signal("PropertiesChanged", properties_changed) File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 545, in connect_to_signal return self._obj.connect_to_signal(signal_name, handler_function, File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 366, in connect_to_signal self._bus.add_signal_receiver(handler_function, File "/usr/lib/python3.8/site-packages/dbus/bus.py", line 148, in add_signal_receiver match = super(BusConnection, self).add_signal_receiver( File "/usr/lib/python3.8/site-packages/dbus/connection.py", line 402, in add_signal_receiver self._require_main_loop() RuntimeError: To make asynchronous calls, receive signals or export objects, D-Bus connections must be attached to a main loop by passing mainloop=... to the constructor or calling dbus.set_default_main_loop(...) ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On 14.07.2021 19:58, m...@mike.franken.de wrote: > Hi, > > On Mittwoch, 14. Juli 2021 16:52:53 CEST Andrei Borzenkov via networkmanager- > list wrote: > [...] >>> >>> Probably there is a fundamental misunderstanding regaring the concept on >>> my >>> side. >> >> You have object which has properties. When properties change, you get >> signal *from this object*. If you want to monitor for connectivity >> changes, you need to monitor active connection. >> >> The examples/python/dbus/create-bond.py in NM source tree does precisely >> that - it monitors for connectivity changes on current connection. >> > > yes, but because I also need to monitor VPN changes, I have to monitor /o/f/ > NM. > In your original mail you only said "monitor connectivity" so anything is just guesswork. >> If you want to monitor overall connectivity, you need to monitor main >> /o/f/NM object. > > This is, what I did before NetworkManager's PropertiesChanged signal got > deprecated. > My problem is to understand, what path and what interface I have to use in > this part of my code, after the PropertiesChanged signal moved from > NetworkManager to DBus: > > my $busobjpath = "org.freedesktop.NetworkManager"; > my $busif = "org.freedesktop.DBus.Properties"; > my $oBUSIF = $oBUSSVC->get_object( $busobjpath, $busif ) || die $!; > $oBUSIF->connect_to_signal( > "PropertiesChanged", sub { > &{ \ }( @_ ) > } || die $!; > } > I do not see any reference to object here so I have no idea what this code does. The following certainly works def properties_changed(interface_name, changed_properties, invalidated_properties): print (interface_name, changed_properties, invalidated_properties) bus = dbus.SystemBus() obj = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager") iface = dbus.Interface(obj, "org.freedesktop.DBus.Properties") iface.connect_to_signal("PropertiesChanged", properties_changed) > The original code now tells me > > no signal PropertiesChanged in interface org.freedesktop.NetworkManager at / > usr/lib/perl5/vendor_perl/5.32.1/x86_64-linux-thread-multi/Net/DBus/Binding/ > Introspector.pm line 420. > > which seemed clear to me, because it got deprecated. > > > Thx and bye. > Michael. > > > ___ > networkmanager-list mailing list > networkmanager-list@gnome.org > https://mail.gnome.org/mailman/listinfo/networkmanager-list > ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
Hi, On Mittwoch, 14. Juli 2021 16:52:53 CEST Andrei Borzenkov via networkmanager- list wrote: [...] > > > > Probably there is a fundamental misunderstanding regaring the concept on > > my > > side. > > You have object which has properties. When properties change, you get > signal *from this object*. If you want to monitor for connectivity > changes, you need to monitor active connection. > > The examples/python/dbus/create-bond.py in NM source tree does precisely > that - it monitors for connectivity changes on current connection. > yes, but because I also need to monitor VPN changes, I have to monitor /o/f/ NM. > If you want to monitor overall connectivity, you need to monitor main > /o/f/NM object. This is, what I did before NetworkManager's PropertiesChanged signal got deprecated. My problem is to understand, what path and what interface I have to use in this part of my code, after the PropertiesChanged signal moved from NetworkManager to DBus: my $busobjpath = "org.freedesktop.NetworkManager"; my $busif = "org.freedesktop.DBus.Properties"; my $oBUSIF = $oBUSSVC->get_object( $busobjpath, $busif ) || die $!; $oBUSIF->connect_to_signal( "PropertiesChanged", sub { &{ \ }( @_ ) } || die $!; } The original code now tells me no signal PropertiesChanged in interface org.freedesktop.NetworkManager at / usr/lib/perl5/vendor_perl/5.32.1/x86_64-linux-thread-multi/Net/DBus/Binding/ Introspector.pm line 420. which seemed clear to me, because it got deprecated. Thx and bye. Michael. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
Hi, On Mittwoch, 14. Juli 2021 16:52:15 CEST Thomas Haller wrote: [...] > > so how can I use org.freedesktop.DBus.Properties.PropertiesChanged > > then? > > What would be the correct way instead? > > Using > > my $busobjpath = "/org/freedesktop/NetworkManager/Settings"; > > as before? > > This doesn't work either, though. > > > > Probably there is a fundamental misunderstanding regaring the concept > > on my > > side. > > Hi, > > I am not familiar with this Perl's Net::DBus, but in general: > > > On D-Bus, you have the well-known name > ("org.freedesktop.NetworkManager") where you find NetworkManager's D- > Bus API. > > > There, you find many D-Bus objects, at paths that start with > "/org/freedesktop/NetworkManager". You see them with `busctl tree > org.freedesktop.NetworkManager`. > > All of these objects also implement the standard D-Bus interface > "org.freedesktop.DBus.Properties" -- as documented at > https://dbus.freedesktop.org/doc/dbus-specification.html > That interface, has (among) others a signal "PropertiesChanged". > > > This "org.freedesktop.DBus.Properties.PropertiesChanged" signal works > very similar to the earlier "PropertiesChanged" signals from the NM > specific interfaces ( "org.freedesktop.NetworkManager*"). > > So, yes, there should be not much to do except replace the interface > name "org.freedesktop.NetworkManager*" with > "org.freedesktop.DBus.Properties". > > > you mention specifically > > my $busobjpath = "/org/freedesktop/NetworkManager/Settings"; > > In `d-feet` you'll see that this object only has three properties. So > you'll see few PropertiesChanged signals on that object... Yeah, my fault, I meant my $busobjpath = "/org/freedesktop/NetworkManager"; 8-( > > > Does that help? Otherwise, please share a working, minimal example. Ok. This is the working example I used before - btw. it stems from a suggestion you made back in 2016/2017 :) #!/usr/bin/perl -w use strict; use Data::Dumper; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 1; use Net::DBus; use Net::DBus::Dumper; use Net::DBus::Reactor; my $oBUS = Net::DBus->system || die $!; my $nm = "org.freedesktop.NetworkManager"; my $oNM = $oBUS->get_service( $nm ) || die $!; my $nmobjpath = "/org/freedesktop/NetworkManager"; my $nmif = "org.freedesktop.NetworkManager"; my $oNMIF = $oNM->get_object( $nmobjpath, $nmif ) || die $!; $nmobjpath = "/org/freedesktop/NetworkManager/Settings"; $nmif = "org.freedesktop.NetworkManager.Settings"; my $oNMIFS = $oNM->get_object( $nmobjpath, $nmif ) || die $!; $oNMIF->connect_to_signal( "PropertiesChanged", sub { &{ \_onNMPropertiesChanged }( $oNM, $oNMIF, $oNMIFS, @_ ); } ); my $reactor = Net::DBus::Reactor->main() || die $!; $reactor->run() || die $!; sub dbnm_onNMPropertiesChanged { my( $oNM, $oNMIF, $oNMIFS, $props ) = @_; print "\n- props -\n", Dumper( $props ), "\n--\n"; } It should output the contents of the props hash, whenever the signal gets caught. > > > best, > Thomas Bye. Michael. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On 14.07.2021 14:32, m...@mike.franken.de wrote: > Hi, > > thx for your answer. > > On Mittwoch, 14. Juli 2021 13:19:44 CEST Thomas Haller wrote: > [...] >>> I use the perl module Net::DBus for this job. >>> The following snippet shows how far I got up to date: >>> >>> my $busobjpath = "/org/freedesktop/DBus/Properties"; >> >> Such an object path does not exist on NetworkManager's D-Bus API. >> >> Object paths start with "/org/freedesktop/NetworkManager". >> >> See all object with `d-feet` or `busctl tree >> org.freedesktop.NetworkManager`. > > so how can I use org.freedesktop.DBus.Properties.PropertiesChanged then? > What would be the correct way instead? > Using > my $busobjpath = "/org/freedesktop/NetworkManager/Settings"; > as before? You need to use the object whose properties you want to monitor. > This doesn't work either, though. > > Probably there is a fundamental misunderstanding regaring the concept on my > side. > You have object which has properties. When properties change, you get signal *from this object*. If you want to monitor for connectivity changes, you need to monitor active connection. The examples/python/dbus/create-bond.py in NM source tree does precisely that - it monitors for connectivity changes on current connection. If you want to monitor overall connectivity, you need to monitor main /o/f/NM object. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Wed, 2021-07-14 at 13:32 +0200, m...@mike.franken.de wrote: > Hi, > > thx for your answer. > > On Mittwoch, 14. Juli 2021 13:19:44 CEST Thomas Haller wrote: > [...] > > > I use the perl module Net::DBus for this job. > > > The following snippet shows how far I got up to date: > > > > > > my $busobjpath = "/org/freedesktop/DBus/Properties"; > > > > Such an object path does not exist on NetworkManager's D-Bus API. > > > > Object paths start with "/org/freedesktop/NetworkManager". > > > > See all object with `d-feet` or `busctl tree > > org.freedesktop.NetworkManager`. > > so how can I use org.freedesktop.DBus.Properties.PropertiesChanged > then? > What would be the correct way instead? > Using > my $busobjpath = "/org/freedesktop/NetworkManager/Settings"; > as before? > This doesn't work either, though. > > Probably there is a fundamental misunderstanding regaring the concept > on my > side. Hi, I am not familiar with this Perl's Net::DBus, but in general: On D-Bus, you have the well-known name ("org.freedesktop.NetworkManager") where you find NetworkManager's D- Bus API. There, you find many D-Bus objects, at paths that start with "/org/freedesktop/NetworkManager". You see them with `busctl tree org.freedesktop.NetworkManager`. All of these objects also implement the standard D-Bus interface "org.freedesktop.DBus.Properties" -- as documented at https://dbus.freedesktop.org/doc/dbus-specification.html That interface, has (among) others a signal "PropertiesChanged". This "org.freedesktop.DBus.Properties.PropertiesChanged" signal works very similar to the earlier "PropertiesChanged" signals from the NM specific interfaces ( "org.freedesktop.NetworkManager*"). So, yes, there should be not much to do except replace the interface name "org.freedesktop.NetworkManager*" with "org.freedesktop.DBus.Properties". you mention specifically my $busobjpath = "/org/freedesktop/NetworkManager/Settings"; In `d-feet` you'll see that this object only has three properties. So you'll see few PropertiesChanged signals on that object... Does that help? Otherwise, please share a working, minimal example. best, Thomas ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
Hi, thx for your answer. On Mittwoch, 14. Juli 2021 13:19:44 CEST Thomas Haller wrote: [...] > > I use the perl module Net::DBus for this job. > > The following snippet shows how far I got up to date: > > > > my $busobjpath = "/org/freedesktop/DBus/Properties"; > > Such an object path does not exist on NetworkManager's D-Bus API. > > Object paths start with "/org/freedesktop/NetworkManager". > > See all object with `d-feet` or `busctl tree > org.freedesktop.NetworkManager`. so how can I use org.freedesktop.DBus.Properties.PropertiesChanged then? What would be the correct way instead? Using my $busobjpath = "/org/freedesktop/NetworkManager/Settings"; as before? This doesn't work either, though. Probably there is a fundamental misunderstanding regaring the concept on my side. > > Too bad that there was still a user of this API. We wouldn't have > dropped it yet, if we had been aware of existing users. But it's hard > to know who uses an API, unless you break it. Sorry about the breakage. Don't worry, I'd only like to understand how I can fix it. > > > > best, > Thomas TIA. Bye. Michael. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
On Wed, 2021-07-14 at 13:10 +0200, m...@mike.franken.de wrote: > Hi *, > > since NetworkManager 1.22 using the signal > org.freedesktop.NetworkManager. > Settings.PropertiesChanged is deprecated. One should use > org.freedesktop. > DBus.Properties.PropertiesChanged instead. Since NetworkManager 1.32 > this > signal indeed is completely removed. > I couldn't find any example on how to easily replace the code using > the > deprecated signal. I use PropertiesChanged to listen for connectivity > changes, > escpecially activation/deactivation of interfaces. > Goal is to configure a few things, whenever connections were > (de)activated. > > I use the perl module Net::DBus for this job. > The following snippet shows how far I got up to date: > > my $busobjpath = "/org/freedesktop/DBus/Properties"; Such an object path does not exist on NetworkManager's D-Bus API. Object paths start with "/org/freedesktop/NetworkManager". See all object with `d-feet` or `busctl tree org.freedesktop.NetworkManager`. > my $busif = "org.freedesktop.DBus.Properties"; > my( $oBUSIF ) = $oBUSSVC->get_object( $busobjpath, $busif ) || die > $!; > $oBUSIF->connect_to_signal( > "PropertiesChanged", sub { > &{ \ }( @_ ) > } || die $!; > } > } > my( $reactor ) = Net::DBus::Reactor->main(); > $reactor->run(); > > The code seems to work, but it does not react on any changes > regarding > Networkmanager connections, at least onPropertiesChanged is never > called. > The old code was using NetworkManager's special PropertiesChanged > signal and > worked as expected. > > Any idea? > > Thx and bye. > Michael. Too bad that there was still a user of this API. We wouldn't have dropped it yet, if we had been aware of existing users. But it's hard to know who uses an API, unless you break it. Sorry about the breakage. best, Thomas ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated
Hi *, since NetworkManager 1.22 using the signal org.freedesktop.NetworkManager. Settings.PropertiesChanged is deprecated. One should use org.freedesktop. DBus.Properties.PropertiesChanged instead. Since NetworkManager 1.32 this signal indeed is completely removed. I couldn't find any example on how to easily replace the code using the deprecated signal. I use PropertiesChanged to listen for connectivity changes, escpecially activation/deactivation of interfaces. Goal is to configure a few things, whenever connections were (de)activated. I use the perl module Net::DBus for this job. The following snippet shows how far I got up to date: my $busobjpath = "/org/freedesktop/DBus/Properties"; my $busif = "org.freedesktop.DBus.Properties"; my( $oBUSIF ) = $oBUSSVC->get_object( $busobjpath, $busif ) || die $!; $oBUSIF->connect_to_signal( "PropertiesChanged", sub { &{ \ }( @_ ) } || die $!; } } my( $reactor ) = Net::DBus::Reactor->main(); $reactor->run(); The code seems to work, but it does not react on any changes regarding Networkmanager connections, at least onPropertiesChanged is never called. The old code was using NetworkManager's special PropertiesChanged signal and worked as expected. Any idea? Thx and bye. Michael. ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list