X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/e22cc457ae91e22deb54373078bef7e8cd22edcb..e7896235a228e096b373c19307b51012c2ec73f4:/lib/src/main/java/org/asamk/signal/manager/Manager.java diff --git a/lib/src/main/java/org/asamk/signal/manager/Manager.java b/lib/src/main/java/org/asamk/signal/manager/Manager.java index be5238d1..6e9c86ad 100644 --- a/lib/src/main/java/org/asamk/signal/manager/Manager.java +++ b/lib/src/main/java/org/asamk/signal/manager/Manager.java @@ -40,7 +40,6 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; public interface Manager extends Closeable { @@ -60,6 +59,7 @@ public interface Manager extends Closeable { var account = SignalAccount.load(pathConfig.dataPath(), number, true, trustNewIdentity); if (!account.isRegistered()) { + account.close(); throw new NotRegisteredException(); } @@ -76,7 +76,7 @@ public interface Manager extends Closeable { return PhoneNumberFormatter.isValidNumber(e164Number, countryCode); } - static List getAllLocalNumbers(File settingsPath) { + static List getAllLocalAccountNumbers(File settingsPath) { var pathConfig = PathConfig.createDefault(settingsPath); final var dataPath = pathConfig.dataPath(); final var files = dataPath.listFiles(); @@ -89,7 +89,7 @@ public interface Manager extends Closeable { .filter(File::isFile) .map(File::getName) .filter(file -> PhoneNumberFormatter.isValidNumber(file, null)) - .collect(Collectors.toList()); + .toList(); } String getSelfNumber(); @@ -144,17 +144,17 @@ public interface Manager extends Closeable { GroupInviteLinkUrl inviteLinkUrl ) throws IOException, InactiveGroupLinkException; - void sendTypingMessage( + SendMessageResults sendTypingMessage( TypingAction action, Set recipients - ) throws IOException, UntrustedIdentityException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException; + ) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException; - void sendReadReceipt( + SendMessageResults sendReadReceipt( RecipientIdentifier.Single sender, List messageIds - ) throws IOException, UntrustedIdentityException; + ) throws IOException; - void sendViewedReceipt( + SendMessageResults sendViewedReceipt( RecipientIdentifier.Single sender, List messageIds - ) throws IOException, UntrustedIdentityException; + ) throws IOException; SendMessageResults sendMessage( Message message, Set recipients @@ -174,6 +174,10 @@ public interface Manager extends Closeable { SendMessageResults sendEndSessionMessage(Set recipients) throws IOException; + void deleteRecipient(RecipientIdentifier.Single recipient) throws IOException; + + void deleteContact(RecipientIdentifier.Single recipient) throws IOException; + void setContactName( RecipientIdentifier.Single recipient, String name ) throws NotMasterDeviceException, IOException; @@ -198,7 +202,11 @@ public interface Manager extends Closeable { * Add a handler to receive new messages. * Will start receiving messages from server, if not already started. */ - void addReceiveHandler(ReceiveMessageHandler handler); + default void addReceiveHandler(ReceiveMessageHandler handler) { + addReceiveHandler(handler, false); + } + + void addReceiveHandler(ReceiveMessageHandler handler, final boolean isWeakListener); /** * Remove a handler to receive new messages. @@ -244,11 +252,16 @@ public interface Manager extends Closeable { boolean trustIdentityAllKeys(RecipientIdentifier.Single recipient); + void addClosedListener(Runnable listener); + @Override void close() throws IOException; interface ReceiveMessageHandler { + ReceiveMessageHandler EMPTY = (envelope, e) -> { + }; + void handleMessage(MessageEnvelope envelope, Throwable e); } }