Error when trying to access nm with vala and gdbus
- From: Florent Thévenet <feuloren free fr>
- To: networkmanager-list gnome org
- Subject: Error when trying to access nm with vala and gdbus
- Date: Thu, 12 Jan 2012 16:35:15 +0100
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 HashTable<string, HashTable<string, 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]