import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
-import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@Override
public Configuration getConfiguration() {
- throw new UnsupportedOperationException();
+ final var configuration = getRemoteObject(new DBusPath(signal.getObjectPath() + "/Configuration"),
+ Signal.Configuration.class).GetAll("org.asamk.Signal.Configuration");
+ return new Configuration(Optional.of((Boolean) configuration.get("ReadReceipts").getValue()),
+ Optional.of((Boolean) configuration.get("UnidentifiedDeliveryIndicators").getValue()),
+ Optional.of((Boolean) configuration.get("TypingIndicators").getValue()),
+ Optional.of((Boolean) configuration.get("LinkPreviews").getValue()));
}
@Override
- public void updateConfiguration(Configuration configuration) throws IOException {
- throw new UnsupportedOperationException();
+ public void updateConfiguration(Configuration newConfiguration) throws IOException {
+ final var configuration = getRemoteObject(new DBusPath(signal.getObjectPath() + "/Configuration"),
+ Signal.Configuration.class);
+ newConfiguration.readReceipts()
+ .ifPresent(v -> configuration.Set("org.asamk.Signal.Configuration", "ReadReceipts", v));
+ newConfiguration.unidentifiedDeliveryIndicators()
+ .ifPresent(v -> configuration.Set("org.asamk.Signal.Configuration",
+ "UnidentifiedDeliveryIndicators",
+ v));
+ newConfiguration.typingIndicators()
+ .ifPresent(v -> configuration.Set("org.asamk.Signal.Configuration", "TypingIndicators", v));
+ newConfiguration.linkPreviews()
+ .ifPresent(v -> configuration.Set("org.asamk.Signal.Configuration", "LinkPreviews", v));
}
@Override
@Override
public void unregister() throws IOException {
- throw new UnsupportedOperationException();
+ signal.unregister();
}
@Override
public void deleteAccount() throws IOException {
- throw new UnsupportedOperationException();
+ signal.deleteAccount();
}
@Override
@Override
public void deleteGroup(final GroupId groupId) throws IOException {
- throw new UnsupportedOperationException();
+ final var group = getRemoteObject(signal.getGroup(groupId.serialize()), Signal.Group.class);
+ group.deleteGroup();
}
@Override
}
@Override
- public void deleteRecipient(final RecipientIdentifier.Single recipient) throws IOException {
+ public void deleteRecipient(final RecipientIdentifier.Single recipient) {
signal.deleteRecipient(recipient.getIdentifier());
}
@Override
- public void deleteContact(final RecipientIdentifier.Single recipient) throws IOException {
+ public void deleteContact(final RecipientIdentifier.Single recipient) {
signal.deleteContact(recipient.getIdentifier());
}
@Override
public void receiveMessages(
- final long timeout, final TimeUnit unit, final ReceiveMessageHandler handler
+ final Duration timeout, final ReceiveMessageHandler handler
) throws IOException {
addReceiveHandler(handler);
try {
- Thread.sleep(unit.toMillis(timeout));
+ Thread.sleep(timeout.toMillis());
} catch (InterruptedException ignored) {
}
removeReceiveHandler(handler);
}
@Override
- public void close() throws IOException {
+ public void close() {
synchronized (this) {
this.notify();
}
return string == null ? "" : string;
}
- private <T extends DBusInterface> T getRemoteObject(final DBusPath devicePath, final Class<T> type) {
+ private <T extends DBusInterface> T getRemoteObject(final DBusPath path, final Class<T> type) {
try {
- return connection.getRemoteObject(DbusConfig.getBusname(), devicePath.getPath(), type);
+ return connection.getRemoteObject(DbusConfig.getBusname(), path.getPath(), type);
} catch (DBusException e) {
throw new AssertionError(e);
}