I have a following Vala code:
------------------------- >8 =======================
class Application {
private GLib.DBusProxy m_proxy;
private const string m_notification_watcher =
“<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n” +
“<node name=”/StatusNotifierWatcher">\n" +
" <interface name=“foo.StatusNotifierWatcher”>\n" +
" <property name=“ProtocolVersion” type=“i” access=“read” />\n" +
" \n" +
“\n”;
private const string IFACE = “foo.StatusNotifierWatcher”;
public Application() {
GLib.DBusConnection connection;
GLib.DBusNodeInfo node_info;
try {
connection = GLib.Bus.get_sync(GLib.BusType.SESSION);
} catch (GLib.IOError e) {
warning("Failed to get session bus: " + e.message);
return;
}
try {
node_info = new GLib.DBusNodeInfo.for_xml(m_notification_watcher);
} catch (GLib.Error e) {
warning("Failed to get node info: " + e.message);
return;
}
unowned GLib.DBusInterfaceInfo interface_info =
node_info.lookup_interface(IFACE);
GLib.DBusProxy.new.begin(
connection,
GLib.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES |
GLib.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS,
interface_info,
"foo.StatusNotifierWatcher",
"/StatusNotifierWatcher",
IFACE,
null,
(obj, res) => {
bus_watcher_ready(obj, res);
});
}
private void
bus_watcher_ready(GLib.Object? obj, GLib.AsyncResult? res) {
try {
m_proxy = GLib.DBusProxy.new.end(res);
} catch (GLib.IOError e) {
warning("Failed to call dbus proxy: " + e.message);
}
}
static void main() {
new Application();
}
}
------------------------- >8 =======================
When I run valac, I got a deprecated warning of “GLib.DBusProxy.new has been deprecated since vala-0.36. Use DBusProxy”.
But I don’t know how to write GLib.DBusProxy().
I referred https://wiki.gnome.org/Projects/Vala/AsyncSamples and vala/tests but no idea.