GNOME Bugzilla – Bug 644751
gio-2.0 and codegen: Support for manual dbus object registration
Last modified: 2018-05-22 13:58:13 UTC
Created attachment 183372 [details] [review] gio-2.0 and codegen: Support for manual dbus object registration Added the new GIO function DBusConnection.register_object_vtable it allows to register a dbus object using the manual GDBus registration via interface info and interface vtable. An implementation example follows: const string introspection_xml = """<node> <interface name='org.example.ManualObject'> <method name='Hello'>" <arg type='s' name='greeting' direction='in'/> <arg type='s' name='response' direction='out'/> </method>" </interface> </node>"""; const GLib.DBusInterfaceVTable ivtable = { method_call, null, null }; public void method_call(GLib.DBusConnection connection, string sender, string object_path, string interface_name, string method_name, GLib.Variant parameters, GLib.DBusMethodInvocation invocation) { var s = @"Method $interface_name.$method_name called on $object_path with parameters:\n$(parameters.print(true))"; print(s+"\n"); invocation.return_value(new Variant("(s)", s)); } void on_bus_aquired (DBusConnection conn) { try { var iface_node = new DBusNodeInfo.for_xml(introspection_xml); var iface_info = iface_node.lookup_interface("org.example.ManualObject"); conn.register_object_vtable ("/org/example/demo/manual_object", iface_info, ivtable); } catch (Error e) { stderr.printf (@"Could not register service $(e.message)\n"); } } void main () { Bus.own_name (BusType.SESSION, "org.example.Demo", BusNameOwnerFlags.NONE, on_bus_aquired, () => {}, () => stderr.printf ("Could not aquire name\n")); new MainLoop ().run (); }
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/180.