0

I would like to register an object for a Bus name that's already owned. Below is how I would register an object on a new Bus, but own_name fails if the Bus already exists. Can I retrieve the DBusConnection object some other way so I can call register_object?

Bus.own_name (BusType.SESSION, "net.launchpad.Diodon", BusNameOwnerFlags.NONE,
    conn => {
        try {
            conn.register_object ("/net/launchpad/Diodon", new DBusController (controller));
        } catch (IOError e) {
            stderr.printf ("Could not register service\n");
        }
    },
    () => {},
    () => stderr.printf ("Could not aquire name\n"));
Ava
  • 2,038
  • 3
  • 23
  • 45
  • 3
    Names can only be owned by one program at a time ... do you have any wider context on what you're trying to do? – ptomato Jul 22 '17 at 23:00

1 Answers1

0

As described on Gio docs, if the bus name was owned by a message bus connection using BusNameOwnerFlags.ALLOW_REPLACEMENT you could use BusNameOwnerFlags.REPLACE and take the name from the other connection. Otherwise, the own_name function will fail to acquire the name.

By the commits I could find on Diodon git history, it seems "net.launchpad.Diodon" was acquired using flag NONE.

Perazzo
  • 1,127
  • 13
  • 24