import org.freedesktop.dbus.connections.impl.DBusConnection;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
+import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
linkedDevices.forEach(d -> {
final var object = new DbusSignalDeviceImpl(d);
final var deviceObjectPath = object.getObjectPath();
- try {
- connection.exportObject(object);
- logger.debug("Exported dbus object: " + deviceObjectPath);
- } catch (DBusException e) {
- e.printStackTrace();
- }
+ exportObject(object);
if (d.isThisDevice()) {
thisDevice = new DBusPath(deviceObjectPath);
}
groups.forEach(g -> {
final var object = new DbusSignalGroupImpl(g.groupId());
- try {
- connection.exportObject(object);
- logger.debug("Exported dbus object: " + object.getObjectPath());
- } catch (DBusException e) {
- e.printStackTrace();
- }
+ exportObject(object);
this.groups.add(new StructGroup(new DBusPath(object.getObjectPath()),
g.groupId().serialize(),
emptyIfNull(g.title())));
}
private void updateConfiguration() {
- try {
- unExportConfiguration();
- final var object = new DbusSignalConfigurationImpl();
- connection.exportObject(object);
- logger.debug("Exported dbus object: " + objectPath + "/Configuration");
- } catch (DBusException e) {
- e.printStackTrace();
- }
+ unExportConfiguration();
+ final var object = new DbusSignalConfigurationImpl();
+ exportObject(object);
}
private void unExportConfiguration() {
connection.unExportObject(objectPath);
}
+ private void exportObject(final DBusInterface object) {
+ try {
+ connection.exportObject(object);
+ logger.debug("Exported dbus object: " + object.getObjectPath());
+ } catch (DBusException e) {
+ e.printStackTrace();
+ }
+ }
+
public class DbusSignalDeviceImpl extends DbusProperties implements Signal.Device {
private final org.asamk.signal.manager.api.Device device;