Re: Error when trying to access nm with vala and gdbus
Le jeudi 12 janvier 2012 à 19:01 -0600, Dan Williams a écrit : conn = Bus.get_proxy_sync(BusType.SYSTEM, org.freedesktop.NetworkManager.Settings.Connection, /org/freedesktop/NetworkManager/Settings/15); Here's the problem: you still need to use the NetworkManager dbus service name, which is org.freedesktop.NetworkManager. What you're passing in here looks like the *interface* name you want to use when talking to the /org/freedesktop/NetworkManager/Settings/15 object. So remove the .Settings.Connection bit from that and you should get your proxy. The interface name is already specified at the top where you define the interface for the Connection object. Dan Ok I modified it and it works, next time I'll read the documentation better :-) Thanks a lot Florent ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list
Error when trying to access nm with vala and gdbus
Hi everyone, I'm writing a program to change the evolution smtp server according to the network I'm connected to, implemented in Vala The simpler solution I found to talk to networkmanager is over dbus, here is the code I use: [DBus (name = org.freedesktop.NetworkManager)] interface NetworkManager : Object { [DBus (name = state)] public abstract uint state () throws IOError; public signal void state_changed(uint state); } [DBus (name = org.freedesktop.NetworkManager.Settings.Connection)] interface Connection : Object { public abstract HashTablestring, HashTablestring, Variant get_settings() throws IOError; } [DBus (name = org.freedesktop.NetworkManager.Connection.Active)] interface NetworkManagerActiveConnection : Object { } void main() { var loop = new MainLoop(); //watch state change //get connection infos //get active connection NetworkManager nm; Connection conn; nm = Bus.get_proxy_sync(BusType.SYSTEM, org.freedesktop.NetworkManager, /org/freedesktop/NetworkManager); nm.state_changed.connect((s) = { stdout.printf(state changed : %d\n, s); }); conn = Bus.get_proxy_sync(BusType.SYSTEM, org.freedesktop.NetworkManager.Settings.Connection, /org/freedesktop/NetworkManager/Settings/15); var result = conn.get_settings(); var v = result.get(connection).get(id); stdout.printf(%u\n%s, nm.state(), v.get_string()); loop.run(); } The signal part works great, but I get an error when trying to get a proxy for org.freedesktop.NetworkManager.Settings.Connection: ** (process:4271): CRITICAL **: file /home/florent/Projets/smtp_switcher/nm_detection.vala.c: line 747: unexpected error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.NetworkManager.Settings.Connection was not provided by any .service files (g-dbus-error-quark, 2) I'm using ubuntu 11.10, is there a solution or direct Vala bindings for NetworkManager ? Cheers Florent ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: Error when trying to access nm with vala and gdbus
On Thu, 2012-01-12 at 16:35 +0100, Florent Thévenet wrote: Hi everyone, I'm writing a program to change the evolution smtp server according to the network I'm connected to, implemented in Vala The simpler solution I found to talk to networkmanager is over dbus, here is the code I use: [DBus (name = org.freedesktop.NetworkManager)] interface NetworkManager : Object { [DBus (name = state)] public abstract uint state () throws IOError; public signal void state_changed(uint state); } [DBus (name = org.freedesktop.NetworkManager.Settings.Connection)] interface Connection : Object { public abstract HashTablestring, HashTablestring, Variant get_settings() throws IOError; } [DBus (name = org.freedesktop.NetworkManager.Connection.Active)] interface NetworkManagerActiveConnection : Object { } void main() { var loop = new MainLoop(); //watch state change //get connection infos //get active connection NetworkManager nm; Connection conn; nm = Bus.get_proxy_sync(BusType.SYSTEM, org.freedesktop.NetworkManager, /org/freedesktop/NetworkManager); nm.state_changed.connect((s) = { stdout.printf(state changed : %d\n, s); }); conn = Bus.get_proxy_sync(BusType.SYSTEM, org.freedesktop.NetworkManager.Settings.Connection, /org/freedesktop/NetworkManager/Settings/15); Here's the problem: you still need to use the NetworkManager dbus service name, which is org.freedesktop.NetworkManager. What you're passing in here looks like the *interface* name you want to use when talking to the /org/freedesktop/NetworkManager/Settings/15 object. So remove the .Settings.Connection bit from that and you should get your proxy. The interface name is already specified at the top where you define the interface for the Connection object. Dan var result = conn.get_settings(); var v = result.get(connection).get(id); stdout.printf(%u\n%s, nm.state(), v.get_string()); loop.run(); } The signal part works great, but I get an error when trying to get a proxy for org.freedesktop.NetworkManager.Settings.Connection: ** (process:4271): CRITICAL **: file /home/florent/Projets/smtp_switcher/nm_detection.vala.c: line 747: unexpected error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.NetworkManager.Settings.Connection was not provided by any .service files (g-dbus-error-quark, 2) I'm using ubuntu 11.10, is there a solution or direct Vala bindings for NetworkManager ? Cheers Florent ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list