mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Add exportObject helper method
This commit is contained in:
parent
8a216e3245
commit
82bb4f22f0
2 changed files with 16 additions and 21 deletions
|
@ -32,6 +32,7 @@ import org.freedesktop.dbus.DBusPath;
|
||||||
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
||||||
import org.freedesktop.dbus.exceptions.DBusException;
|
import org.freedesktop.dbus.exceptions.DBusException;
|
||||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||||
|
import org.freedesktop.dbus.interfaces.DBusInterface;
|
||||||
import org.freedesktop.dbus.types.Variant;
|
import org.freedesktop.dbus.types.Variant;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -839,12 +840,7 @@ public class DbusSignalImpl implements Signal {
|
||||||
linkedDevices.forEach(d -> {
|
linkedDevices.forEach(d -> {
|
||||||
final var object = new DbusSignalDeviceImpl(d);
|
final var object = new DbusSignalDeviceImpl(d);
|
||||||
final var deviceObjectPath = object.getObjectPath();
|
final var deviceObjectPath = object.getObjectPath();
|
||||||
try {
|
exportObject(object);
|
||||||
connection.exportObject(object);
|
|
||||||
logger.debug("Exported dbus object: " + deviceObjectPath);
|
|
||||||
} catch (DBusException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (d.isThisDevice()) {
|
if (d.isThisDevice()) {
|
||||||
thisDevice = new DBusPath(deviceObjectPath);
|
thisDevice = new DBusPath(deviceObjectPath);
|
||||||
}
|
}
|
||||||
|
@ -876,12 +872,7 @@ public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
groups.forEach(g -> {
|
groups.forEach(g -> {
|
||||||
final var object = new DbusSignalGroupImpl(g.groupId());
|
final var object = new DbusSignalGroupImpl(g.groupId());
|
||||||
try {
|
exportObject(object);
|
||||||
connection.exportObject(object);
|
|
||||||
logger.debug("Exported dbus object: " + object.getObjectPath());
|
|
||||||
} catch (DBusException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
this.groups.add(new StructGroup(new DBusPath(object.getObjectPath()),
|
this.groups.add(new StructGroup(new DBusPath(object.getObjectPath()),
|
||||||
g.groupId().serialize(),
|
g.groupId().serialize(),
|
||||||
emptyIfNull(g.title())));
|
emptyIfNull(g.title())));
|
||||||
|
@ -898,14 +889,9 @@ public class DbusSignalImpl implements Signal {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateConfiguration() {
|
private void updateConfiguration() {
|
||||||
try {
|
|
||||||
unExportConfiguration();
|
unExportConfiguration();
|
||||||
final var object = new DbusSignalConfigurationImpl();
|
final var object = new DbusSignalConfigurationImpl();
|
||||||
connection.exportObject(object);
|
exportObject(object);
|
||||||
logger.debug("Exported dbus object: " + objectPath + "/Configuration");
|
|
||||||
} catch (DBusException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unExportConfiguration() {
|
private void unExportConfiguration() {
|
||||||
|
@ -913,6 +899,15 @@ public class DbusSignalImpl implements Signal {
|
||||||
connection.unExportObject(objectPath);
|
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 {
|
public class DbusSignalDeviceImpl extends DbusProperties implements Signal.Device {
|
||||||
|
|
||||||
private final org.asamk.signal.manager.api.Device device;
|
private final org.asamk.signal.manager.api.Device device;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue