+ 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 (NotPrimaryDeviceException 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);
+ }
+ }
+