X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/778adacb80bae7d6ecc1d70fa87f9217c7bc1c71..ce7aa580b6f0580cdcf7fd68fcc8efba737d21ed:/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 7a421966..2cb68d20 100644 --- a/lib/src/main/java/org/asamk/signal/manager/Manager.java +++ b/lib/src/main/java/org/asamk/signal/manager/Manager.java @@ -8,13 +8,12 @@ import org.asamk.signal.manager.api.RecipientIdentifier; import org.asamk.signal.manager.api.SendGroupMessageResults; import org.asamk.signal.manager.api.SendMessageResults; import org.asamk.signal.manager.api.TypingAction; +import org.asamk.signal.manager.api.UpdateGroup; import org.asamk.signal.manager.config.ServiceConfig; import org.asamk.signal.manager.config.ServiceEnvironment; import org.asamk.signal.manager.groups.GroupId; import org.asamk.signal.manager.groups.GroupInviteLinkUrl; -import org.asamk.signal.manager.groups.GroupLinkState; import org.asamk.signal.manager.groups.GroupNotFoundException; -import org.asamk.signal.manager.groups.GroupPermission; import org.asamk.signal.manager.groups.GroupSendingNotAllowedException; import org.asamk.signal.manager.groups.LastGroupAdminException; import org.asamk.signal.manager.groups.NotAGroupMemberException; @@ -23,7 +22,6 @@ import org.asamk.signal.manager.storage.identities.TrustNewIdentity; import org.asamk.signal.manager.storage.recipients.Contact; import org.asamk.signal.manager.storage.recipients.Profile; import org.asamk.signal.manager.storage.recipients.RecipientAddress; -import org.whispersystems.libsignal.IdentityKey; import org.whispersystems.libsignal.InvalidKeyException; import org.whispersystems.libsignal.util.Pair; import org.whispersystems.libsignal.util.guava.Optional; @@ -59,11 +57,11 @@ public interface Manager extends Closeable { ) throws IOException, NotRegisteredException { var pathConfig = PathConfig.createDefault(settingsPath); - if (!SignalAccount.userExists(pathConfig.getDataPath(), number)) { + if (!SignalAccount.userExists(pathConfig.dataPath(), number)) { throw new NotRegisteredException(); } - var account = SignalAccount.load(pathConfig.getDataPath(), number, true, trustNewIdentity); + var account = SignalAccount.load(pathConfig.dataPath(), number, true, trustNewIdentity); if (!account.isRegistered()) { throw new NotRegisteredException(); @@ -76,7 +74,7 @@ public interface Manager extends Closeable { static List getAllLocalNumbers(File settingsPath) { var pathConfig = PathConfig.createDefault(settingsPath); - final var dataPath = pathConfig.getDataPath(); + final var dataPath = pathConfig.dataPath(); final var files = dataPath.listFiles(); if (files == null) { @@ -138,20 +136,7 @@ public interface Manager extends Closeable { ) throws IOException, AttachmentInvalidException; SendGroupMessageResults updateGroup( - GroupId groupId, - String name, - String description, - Set members, - Set removeMembers, - Set admins, - Set removeAdmins, - boolean resetGroupLink, - GroupLinkState groupLinkState, - GroupPermission addMemberPermission, - GroupPermission editDetailsPermission, - File avatarFile, - Integer expirationTimer, - Boolean isAnnouncementGroup + final GroupId groupId, final UpdateGroup updateGroup ) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException; Pair joinGroup( @@ -198,7 +183,7 @@ public interface Manager extends Closeable { void setGroupBlocked( GroupId groupId, boolean blocked - ) throws GroupNotFoundException, IOException; + ) throws GroupNotFoundException, IOException, NotMasterDeviceException; void setExpirationTimer( RecipientIdentifier.Single recipient, int messageExpirationTimer @@ -208,13 +193,31 @@ public interface Manager extends Closeable { void requestAllSyncData() throws IOException; - void receiveMessages( - long timeout, - TimeUnit unit, - boolean returnOnTimeout, - boolean ignoreAttachments, - ReceiveMessageHandler handler - ) throws IOException; + /** + * Add a handler to receive new messages. + * Will start receiving messages from server, if not already started. + */ + void addReceiveHandler(ReceiveMessageHandler handler); + + /** + * Remove a handler to receive new messages. + * Will stop receiving messages from server, if this was the last registered receiver. + */ + void removeReceiveHandler(ReceiveMessageHandler handler); + + boolean isReceiving(); + + /** + * Receive new messages from server, returns if no new message arrive in a timespan of timeout. + */ + void receiveMessages(long timeout, TimeUnit unit, ReceiveMessageHandler handler) throws IOException; + + /** + * Receive new messages from server, returns only if the thread is interrupted. + */ + void receiveMessages(ReceiveMessageHandler handler) throws IOException; + + void setIgnoreAttachments(boolean ignoreAttachments); boolean hasCaughtUpWithOldMessages(); @@ -242,8 +245,6 @@ public interface Manager extends Closeable { boolean trustIdentityAllKeys(RecipientIdentifier.Single recipient); - String computeSafetyNumber(SignalServiceAddress theirAddress, IdentityKey theirIdentityKey); - SignalServiceAddress resolveSignalServiceAddress(SignalServiceAddress address); @Override