Exceptions: Failure
+=== Configuration properties
+The configuration's object path, which exists only for primary devices, is constructed as follows:
+"/org/asamk/Signal/" + DBusNumber + "/Configuration"
+* DBusNumber : recipient's phone number, with underscore (_) replacing plus (+)
+
+Configurations have the following (case-sensitive) properties:
+* ReadReceipts<b> : should send read receipts (true/false)
+* UnidentifiedDeliveryIndicators<b> : should show unidentified delivery indicators (true/false)
+* TypingIndicators<b> : should send/show typing indicators (true/false)
+* LinkPreviews<b> : should generate link previews (true/false)
+
+To get a property, use (replacing `--session` with `--system` if needed):
+`dbus-send --session --dest=org.asamk.Signal --print-reply $OBJECT_PATH org.freedesktop.DBus.Properties.Get string:org.asamk.Signal.Configuration string:$PROPERTY_NAME`
+
+To set a property, use:
+`dbus-send --session --dest=org.asamk.Signal --print-reply $OBJECT_PATH org.freedesktop.DBus.Properties.Set string:org.asamk.Signal.Configuration string:$PROPERTY_NAME variant:$PROPERTY_TYPE:$PROPERTY_VALUE`
+
+To get all properties, use:
+`dbus-send --session --dest=org.asamk.Signal --print-reply $OBJECT_PATH org.freedesktop.DBus.Properties.GetAll string:org.asamk.Signal.Configuration`
+
=== Other methods
getContactName(number<s>) -> name<s>::
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
import org.freedesktop.dbus.types.Variant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
private final List<StructDevice> devices = new ArrayList<>();
private final List<StructGroup> groups = new ArrayList<>();
+ private final static Logger logger = LoggerFactory.getLogger(DbusSignalImpl.class);
+
public DbusSignalImpl(final Manager m, DBusConnection connection, final String objectPath) {
this.m = m;
this.connection = connection;
public void initObjects() {
updateDevices();
updateGroups();
+ updateConfiguration();
}
public void close() {
unExportDevices();
unExportGroups();
+ unExportConfiguration();
}
@Override
final var deviceObjectPath = object.getObjectPath();
try {
connection.exportObject(object);
+ logger.debug("Exported dbus object: " + deviceObjectPath);
} catch (DBusException e) {
e.printStackTrace();
}
final var object = new DbusSignalGroupImpl(g.groupId());
try {
connection.exportObject(object);
+ logger.debug("Exported dbus object: " + object.getObjectPath());
} catch (DBusException e) {
e.printStackTrace();
}
this.groups.clear();
}
+ private static String getConfigurationObjectPath(String basePath) {
+ return basePath + "/Configuration";
+ }
+
+ 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();
+ }
+ }
+
+ private void unExportConfiguration() {
+ final var objectPath = getConfigurationObjectPath(this.objectPath);
+ connection.unExportObject(objectPath);
+ }
+
public class DbusSignalDeviceImpl extends DbusProperties implements Signal.Device {
private final org.asamk.signal.manager.api.Device device;
}
}
+ public class DbusSignalConfigurationImpl extends DbusProperties implements Signal.Configuration {
+
+ public DbusSignalConfigurationImpl(
+ ) {
+ super.addPropertiesHandler(new DbusInterfacePropertiesHandler("org.asamk.Signal.Configuration",
+ List.of(new DbusProperty<>("ReadReceipts", this::getReadReceipts, this::setReadReceipts),
+ new DbusProperty<>("UnidentifiedDeliveryIndicators",
+ this::getUnidentifiedDeliveryIndicators,
+ this::setUnidentifiedDeliveryIndicators),
+ new DbusProperty<>("TypingIndicators",
+ this::getTypingIndicators,
+ this::setTypingIndicators),
+ new DbusProperty<>("LinkPreviews", this::getLinkPreviews, this::setLinkPreviews))));
+
+ }
+
+ @Override
+ public String getObjectPath() {
+ return getConfigurationObjectPath(objectPath);
+ }
+
+ public void setReadReceipts(Boolean readReceipts) {
+ setConfiguration(readReceipts, null, null, null);
+ }
+
+ public void setUnidentifiedDeliveryIndicators(Boolean unidentifiedDeliveryIndicators) {
+ setConfiguration(null, unidentifiedDeliveryIndicators, null, null);
+ }
+
+ public void setTypingIndicators(Boolean typingIndicators) {
+ setConfiguration(null, null, typingIndicators, null);
+ }
+
+ public void setLinkPreviews(Boolean linkPreviews) {
+ setConfiguration(null, null, null, linkPreviews);
+ }
+
+ private void setConfiguration(
+ Boolean readReceipts,
+ Boolean unidentifiedDeliveryIndicators,
+ Boolean typingIndicators,
+ Boolean linkPreviews
+ ) {
+ try {
+ m.updateConfiguration(new org.asamk.signal.manager.api.Configuration(Optional.ofNullable(readReceipts),
+ Optional.ofNullable(unidentifiedDeliveryIndicators),
+ Optional.ofNullable(typingIndicators),
+ Optional.ofNullable(linkPreviews)));
+ } catch (IOException e) {
+ throw new Error.Failure("UpdateAccount error: " + e.getMessage());
+ } catch (NotMasterDeviceException e) {
+ throw new Error.Failure("This command doesn't work on linked devices.");
+ }
+ }
+
+ private boolean getReadReceipts() {
+ return m.getConfiguration().readReceipts().orElse(false);
+ }
+
+ private boolean getUnidentifiedDeliveryIndicators() {
+ return m.getConfiguration().unidentifiedDeliveryIndicators().orElse(false);
+ }
+
+ private boolean getTypingIndicators() {
+ return m.getConfiguration().typingIndicators().orElse(false);
+ }
+
+ private boolean getLinkPreviews() {
+ return m.getConfiguration().linkPreviews().orElse(false);
+ }
+ }
+
public class DbusSignalGroupImpl extends DbusProperties implements Signal.Group {
private final GroupId groupId;