+ public class DbusSignalConfigurationImpl extends DbusProperties implements Signal.Configuration {
+
+ private final Boolean readReceipts;
+ private final Boolean unidentifiedDeliveryIndicators;
+ private final Boolean typingIndicators;
+ private final Boolean linkPreviews;
+
+ public DbusSignalConfigurationImpl(final Boolean readReceipts, final Boolean unidentifiedDeliveryIndicators, final Boolean typingIndicators, final Boolean linkPreviews) {
+ this.readReceipts = readReceipts;
+ this.unidentifiedDeliveryIndicators = unidentifiedDeliveryIndicators;
+ this.typingIndicators = typingIndicators;
+ this.linkPreviews = linkPreviews;
+ super.addPropertiesHandler(new DbusInterfacePropertiesHandler("org.asamk.Signal.Configuration",
+ List.of(new DbusProperty<>("ConfigurationReadReceipts", () -> getReadReceipts(), this::setReadReceipts),
+ new DbusProperty<>("ConfigurationUnidentifiedDeliveryIndicators", () -> getUnidentifiedDeliveryIndicators(), this::setUnidentifiedDeliveryIndicators),
+ new DbusProperty<>("ConfigurationTypingIndicators", () -> getTypingIndicators(), this::setTypingIndicators),
+ new DbusProperty<>("ConfigurationLinkPreviews", () -> 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 {
+ if (readReceipts == null) {
+ readReceipts = m.getConfiguration().get(0);
+ }
+ if (unidentifiedDeliveryIndicators == null) {
+ unidentifiedDeliveryIndicators = m.getConfiguration().get(1);
+ }
+ if (typingIndicators == null) {
+ typingIndicators = m.getConfiguration().get(2);
+ }
+ if (linkPreviews == null) {
+ linkPreviews = m.getConfiguration().get(3);
+ }
+ m.updateConfiguration(readReceipts, unidentifiedDeliveryIndicators, typingIndicators, linkPreviews);
+ } catch (IOException e) {
+ throw new Error.IOError("UpdateAccount error: " + e.getMessage());
+ } catch (NotMasterDeviceException e) {
+ throw new Error.UserError("This command doesn't work on linked devices.");
+ }
+ }
+
+ public List<Boolean> getConfiguration() {
+ List<Boolean> config = new ArrayList<>(4);
+ try {
+ config = m.getConfiguration();
+ } catch (IOException e) {
+ throw new Error.IOError("Configuration storage error: " + e.getMessage());
+ } catch (NotMasterDeviceException e) {
+ throw new Error.UserError("This command doesn't work on linked devices.");
+ }
+ return config;
+ }
+
+ public Boolean getReadReceipts() {
+ try {
+ return m.getConfiguration().get(0);
+ } catch (IOException e) {
+ throw new Error.IOError("Configuration storage error: " + e.getMessage());
+ } catch (NotMasterDeviceException e) {
+ throw new Error.UserError("This command doesn't work on linked devices.");
+ }
+ }
+
+ public Boolean getUnidentifiedDeliveryIndicators() {
+ try {
+ return m.getConfiguration().get(1);
+ } catch (IOException e) {
+ throw new Error.IOError("Configuration storage error: " + e.getMessage());
+ } catch (NotMasterDeviceException e) {
+ throw new Error.UserError("This command doesn't work on linked devices.");
+ }
+ }
+
+ public Boolean getTypingIndicators() {
+ try {
+ return m.getConfiguration().get(2);
+ } catch (IOException e) {
+ throw new Error.IOError("Configuration storage error: " + e.getMessage());
+ } catch (NotMasterDeviceException e) {
+ throw new Error.UserError("This command doesn't work on linked devices.");
+ }
+ }
+
+ public Boolean getLinkPreviews() {
+ try {
+ return m.getConfiguration().get(3);
+ } catch (IOException e) {
+ throw new Error.IOError("Configuration storage error: " + e.getMessage());
+ } catch (NotMasterDeviceException e) {
+ throw new Error.UserError("This command doesn't work on linked devices.");
+ }
+ }
+ }
+