X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/03f193b34ca7e2685d0166efe28ac02c0f355932..a66dd0dc79330b095a1bc0353ea183d7846fb945:/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java diff --git a/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java b/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java index 3cdce248..d6cd52fa 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java @@ -5,13 +5,25 @@ import org.asamk.signal.DbusConfig; import org.asamk.signal.manager.Manager; import org.asamk.signal.manager.api.AttachmentInvalidException; import org.asamk.signal.manager.api.Configuration; +import org.asamk.signal.manager.api.Contact; import org.asamk.signal.manager.api.Device; +import org.asamk.signal.manager.api.DeviceLinkUrl; import org.asamk.signal.manager.api.Group; +import org.asamk.signal.manager.api.GroupId; +import org.asamk.signal.manager.api.GroupInviteLinkUrl; +import org.asamk.signal.manager.api.GroupNotFoundException; +import org.asamk.signal.manager.api.GroupPermission; +import org.asamk.signal.manager.api.GroupSendingNotAllowedException; import org.asamk.signal.manager.api.Identity; +import org.asamk.signal.manager.api.IdentityVerificationCode; import org.asamk.signal.manager.api.InactiveGroupLinkException; import org.asamk.signal.manager.api.InvalidDeviceLinkException; +import org.asamk.signal.manager.api.InvalidStickerException; +import org.asamk.signal.manager.api.InvalidUsernameException; +import org.asamk.signal.manager.api.LastGroupAdminException; import org.asamk.signal.manager.api.Message; import org.asamk.signal.manager.api.MessageEnvelope; +import org.asamk.signal.manager.api.NotAGroupMemberException; import org.asamk.signal.manager.api.NotPrimaryDeviceException; import org.asamk.signal.manager.api.Pair; import org.asamk.signal.manager.api.ReceiveConfig; @@ -24,18 +36,10 @@ import org.asamk.signal.manager.api.StickerPack; import org.asamk.signal.manager.api.StickerPackInvalidException; import org.asamk.signal.manager.api.StickerPackUrl; import org.asamk.signal.manager.api.TypingAction; +import org.asamk.signal.manager.api.UnregisteredRecipientException; import org.asamk.signal.manager.api.UpdateGroup; import org.asamk.signal.manager.api.UpdateProfile; import org.asamk.signal.manager.api.UserStatus; -import org.asamk.signal.manager.groups.GroupId; -import org.asamk.signal.manager.groups.GroupInviteLinkUrl; -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; -import org.asamk.signal.manager.storage.recipients.Contact; -import org.asamk.signal.manager.storage.recipients.Profile; import org.freedesktop.dbus.DBusMap; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.connections.impl.DBusConnection; @@ -79,6 +83,7 @@ public class DbusManagerImpl implements Manager { private final Set messageHandlers = new HashSet<>(); private final List closedListeners = new ArrayList<>(); private DBusSigHandler dbusMsgHandler; + private DBusSigHandler dbusEditMsgHandler; private DBusSigHandler dbusRcptHandler; private DBusSigHandler dbusSyncHandler; @@ -151,6 +156,16 @@ public class DbusManagerImpl implements Manager { updateProfile.isDeleteAvatar()); } + @Override + public String setUsername(final String username) throws IOException, InvalidUsernameException { + throw new UnsupportedOperationException(); + } + + @Override + public void deleteUsername() throws IOException { + throw new UnsupportedOperationException(); + } + @Override public void unregister() throws IOException { signal.unregister(); @@ -187,8 +202,8 @@ public class DbusManagerImpl implements Manager { } @Override - public void addDeviceLink(final URI linkUri) throws IOException, InvalidDeviceLinkException { - signal.addDevice(linkUri.toString()); + public void addDeviceLink(final DeviceLinkUrl linkUri) throws IOException, InvalidDeviceLinkException { + signal.addDevice(linkUri.createDeviceLinkUri().toString()); } @Override @@ -200,11 +215,6 @@ public class DbusManagerImpl implements Manager { } } - @Override - public Profile getRecipientProfile(final RecipientIdentifier.Single recipient) { - throw new UnsupportedOperationException(); - } - @Override public List getGroups() { final var groups = signal.listGroups(); @@ -358,6 +368,13 @@ public class DbusManagerImpl implements Manager { groupId -> signal.sendGroupMessage(message.messageText(), message.attachments(), groupId)); } + @Override + public SendMessageResults sendEditMessage( + final Message message, final Set recipients, final long editTargetTimestamp + ) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException { + throw new UnsupportedOperationException(); + } + @Override public SendMessageResults sendRemoteDeleteMessage( final long targetSentTimestamp, final Set recipients @@ -465,6 +482,11 @@ public class DbusManagerImpl implements Manager { } } + @Override + public void installStickerPack(final StickerPackUrl url) throws IOException { + throw new UnsupportedOperationException(); + } + @Override public List getStickerPacks() { throw new UnsupportedOperationException(); @@ -554,11 +576,6 @@ public class DbusManagerImpl implements Manager { public void setReceiveConfig(final ReceiveConfig receiveConfig) { } - @Override - public boolean hasCaughtUpWithOldMessages() { - return true; - } - @Override public boolean isContactBlocked(final RecipientIdentifier.Single recipient) { return signal.isContactBlocked(recipient.getIdentifier()); @@ -657,20 +674,8 @@ public class DbusManagerImpl implements Manager { } @Override - public boolean trustIdentityVerified(final RecipientIdentifier.Single recipient, final byte[] fingerprint) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean trustIdentityVerifiedSafetyNumber( - final RecipientIdentifier.Single recipient, final String safetyNumber - ) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean trustIdentityVerifiedSafetyNumber( - final RecipientIdentifier.Single recipient, final byte[] safetyNumber + public boolean trustIdentityVerified( + final RecipientIdentifier.Single recipient, final IdentityVerificationCode verificationCode ) { throw new UnsupportedOperationException(); } @@ -790,10 +795,54 @@ public class DbusManagerImpl implements Manager { List.of())), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); notifyMessageHandlers(envelope); }; connection.addSigHandler(Signal.MessageReceivedV2.class, signal, this.dbusMsgHandler); + this.dbusEditMsgHandler = messageReceived -> { + final var extras = messageReceived.getExtras(); + final var envelope = new MessageEnvelope(Optional.of(new RecipientAddress(null, + messageReceived.getSender())), + 0, + messageReceived.getTimestamp(), + 0, + 0, + false, + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.of(new MessageEnvelope.Edit(messageReceived.getTargetSentTimestamp(), + new MessageEnvelope.Data(messageReceived.getTimestamp(), + messageReceived.getGroupId().length > 0 + ? Optional.of(new MessageEnvelope.Data.GroupContext(GroupId.unknownVersion( + messageReceived.getGroupId()), false, 0)) + : Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.of(messageReceived.getMessage()), + 0, + false, + false, + false, + false, + false, + Optional.empty(), + Optional.empty(), + Optional.empty(), + getAttachments(extras), + Optional.empty(), + Optional.empty(), + List.of(), + List.of(), + List.of(), + List.of()))), + Optional.empty(), + Optional.empty(), + Optional.empty()); + notifyMessageHandlers(envelope); + }; + connection.addSigHandler(Signal.EditMessageReceived.class, signal, this.dbusEditMsgHandler); this.dbusRcptHandler = receiptReceived -> { final var type = switch (receiptReceived.getReceiptType()) { @@ -816,6 +865,7 @@ public class DbusManagerImpl implements Manager { Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty()); notifyMessageHandlers(envelope); }; @@ -833,6 +883,7 @@ public class DbusManagerImpl implements Manager { Optional.empty(), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.of(new MessageEnvelope.Sync(Optional.of(new MessageEnvelope.Sync.Sent(syncReceived.getTimestamp(), syncReceived.getTimestamp(), syncReceived.getDestination().isEmpty() @@ -863,6 +914,7 @@ public class DbusManagerImpl implements Manager { List.of(), List.of(), List.of())), + Optional.empty(), Optional.empty())), Optional.empty(), List.of(), @@ -893,6 +945,7 @@ public class DbusManagerImpl implements Manager { try { signal.unsubscribeReceive(); connection.removeSigHandler(Signal.MessageReceivedV2.class, signal, this.dbusMsgHandler); + connection.removeSigHandler(Signal.EditMessageReceived.class, signal, this.dbusEditMsgHandler); connection.removeSigHandler(Signal.ReceiptReceivedV2.class, signal, this.dbusRcptHandler); connection.removeSigHandler(Signal.SyncMessageReceivedV2.class, signal, this.dbusSyncHandler); } catch (DBusException e) {