X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/9075cc1a309fbc90276d2878d480d1e9e9c81887..32c2fae2f7561972bcd5bf16a41397ec1b15be49:/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 77be3074..c9f2bad1 100644 --- a/lib/src/main/java/org/asamk/signal/manager/Manager.java +++ b/lib/src/main/java/org/asamk/signal/manager/Manager.java @@ -1,5 +1,6 @@ package org.asamk.signal.manager; +import org.asamk.signal.manager.api.Configuration; import org.asamk.signal.manager.api.Device; import org.asamk.signal.manager.api.Group; import org.asamk.signal.manager.api.Identity; @@ -67,7 +68,15 @@ public interface Manager extends Closeable { return new ManagerImpl(account, pathConfig, serviceEnvironmentConfig, userAgent); } - static List getAllLocalNumbers(File settingsPath) { + static void initLogger() { + LibSignalLogger.initLogger(); + } + + static boolean isValidNumber(final String e164Number, final String countryCode) { + return PhoneNumberFormatter.isValidNumber(e164Number, countryCode); + } + + static List getAllLocalAccountNumbers(File settingsPath) { var pathConfig = PathConfig.createDefault(settingsPath); final var dataPath = pathConfig.dataPath(); final var files = dataPath.listFiles(); @@ -91,12 +100,9 @@ public interface Manager extends Closeable { void updateAccountAttributes(String deviceName) throws IOException; - void updateConfiguration( - final Boolean readReceipts, - final Boolean unidentifiedDeliveryIndicators, - final Boolean typingIndicators, - final Boolean linkPreviews - ) throws IOException, NotMasterDeviceException; + Configuration getConfiguration(); + + void updateConfiguration(Configuration configuration) throws IOException, NotMasterDeviceException; void setProfile( String givenName, String familyName, String about, String aboutEmoji, Optional avatar @@ -138,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 @@ -168,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; @@ -192,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. @@ -218,8 +232,6 @@ public interface Manager extends Closeable { boolean isContactBlocked(RecipientIdentifier.Single recipient); - File getAttachmentFile(String attachmentId); - void sendContacts() throws IOException; List> getContacts(); @@ -240,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); } }