Hello everyone,
I’m trying to use the libcloudproviders DBus API in a shell extension I’m writing.
However, I can’t get signals from DBus. Specifically, the InterfacesAdded
and InterfacesRemoved
signals from the ObjectManager
interface (which should be emitted when a provider or an account is added or removed) and the g-properties-changed
signal on accounts objects (which should be emitted when the status of an account changes).
To test this, I’m using the Nextcloud client, and adding/removing folder syncs (that should send the InterfacesAdded
and InterfacesRemoved
signals) and putting/deleting files in these folders (that should send the g-properties-changed
signal). I can see the values changing in D-Feet, but can’t get any signal.
Here’s my code for the ObjectManager:
const { Gio } = imports.gi;
const OBJECT_MANAGER_INTERFACE = `
<node>
<interface name="org.freedesktop.DBus.ObjectManager">
<method name="GetManagedObjects">
<arg type="a{oa{sa{sv}}}" name="object_paths_interfaces_and_properties" direction="out"/>
</method>
<signal name="InterfacesAdded">
<arg type="o" name="object_path"/>
<arg type="a{sa{sv}}" name="interfaces_and_properties"/>
</signal>
<signal name="InterfacesRemoved">
<arg type="o" name="object_path"/>
<arg type="as" name="interfaces"/>
</signal>
</interface>
</node>`;
function enable() {
const ObjectManagerProxy = Gio.DBusProxy.makeProxyWrapper(OBJECT_MANAGER_INTERFACE);
const objectManagerProxy = new ObjectManagerProxy(
Gio.DBus.session,
'com.nextcloudgmbh.Nextcloud',
'/com/nextcloudgmbh/Nextcloud'
);
objectManagerProxy.connectSignal('InterfacesAdded', () => log('Interfaces added'));
objectManagerProxy.connectSignal('InterfacesRemoved', () => log('Interfaces removed'));
}
And the one for listening to an account:
const { Gio } = imports.gi;
const CLOUDPROVIDERS_ACCOUNT_INTERFACE = `
<node>
<interface name="org.freedesktop.CloudProviders.Account">
<property type="s" name="Name" access="read"/>
<property type="s" name="Path" access="read"/>
<property type="s" name="Icon" access="read"/>
<property type="i" name="Status" access="read"/>
<property type="s" name="StatusDetails" access="read"/>
</interface>
</node>`;
function enable() {
const AccountProxy = Gio.DBusProxy.makeProxyWrapper(CLOUDPROVIDERS_ACCOUNT_INTERFACE);
const accountProxy = new AccountProxy(
Gio.DBus.session,
'com.nextcloudgmbh.Nextcloud',
'/com/nextcloudgmbh/Nextcloud/Folder/0'
);
accountProxy.connect('g-properties-changed', () => log('Properties changed'));
}
I tried this on other DBus interfaces, and I get signals. Is there anything I’m missing here? Or do you think it is something not happening in libcloudproviders?