X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/30e8e36635733b3e8c75a44e95785ba33cf55e61..1bf703b012521ac8b887be8a50b01bc7b62ce677:/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 e6a18307..f56a3ba4 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java @@ -1,7 +1,6 @@ package org.asamk.signal.dbus; import org.asamk.Signal; -import org.asamk.signal.DbusConfig; import org.asamk.signal.manager.Manager; import org.asamk.signal.manager.api.AlreadyReceivingException; import org.asamk.signal.manager.api.AttachmentInvalidException; @@ -90,14 +89,16 @@ public class DbusManagerImpl implements Manager { private final Set weakHandlers = new HashSet<>(); private final Set messageHandlers = new HashSet<>(); private final List closedListeners = new ArrayList<>(); + private final String busname; private DBusSigHandler dbusMsgHandler; private DBusSigHandler dbusEditMsgHandler; private DBusSigHandler dbusRcptHandler; private DBusSigHandler dbusSyncHandler; - public DbusManagerImpl(final Signal signal, DBusConnection connection) { + public DbusManagerImpl(final Signal signal, DBusConnection connection, final String busname) { this.signal = signal; this.connection = connection; + this.busname = busname; } @Override @@ -670,7 +671,18 @@ public class DbusManagerImpl implements Manager { } return Recipient.newBuilder() .withAddress(new RecipientAddress(null, n)) - .withContact(new Contact(contactName, null, null, 0, contactBlocked, false, false, false)) + .withContact(new Contact(contactName, + null, + null, + null, + 0, + 0, + false, + contactBlocked, + false, + false, + false, + null)) .build(); }).filter(Objects::nonNull).toList(); } @@ -809,7 +821,7 @@ public class DbusManagerImpl implements Manager { private T getRemoteObject(final DBusPath path, final Class type) { try { - return connection.getRemoteObject(DbusConfig.getBusname(), path.getPath(), type); + return connection.getRemoteObject(busname, path.getPath(), type); } catch (DBusException e) { throw new AssertionError(e); } @@ -849,7 +861,7 @@ public class DbusManagerImpl implements Manager { Optional.empty(), Optional.empty(), List.of(), - List.of(), + getMentions(extras), List.of(), List.of())), Optional.empty(), @@ -893,7 +905,7 @@ public class DbusManagerImpl implements Manager { Optional.empty(), Optional.empty(), List.of(), - List.of(), + getMentions(extras), List.of(), List.of()))), Optional.empty(), @@ -970,7 +982,7 @@ public class DbusManagerImpl implements Manager { Optional.empty(), Optional.empty(), List.of(), - List.of(), + getMentions(extras), List.of(), List.of())), Optional.empty(), @@ -1039,6 +1051,19 @@ public class DbusManagerImpl implements Manager { }).toList(); } + private List getMentions(final Map> extras) { + if (!extras.containsKey("mentions")) { + return List.of(); + } + + final List>> mentions = getValue(extras, "mentions"); + return mentions.stream() + .map(a -> new MessageEnvelope.Data.Mention(new RecipientAddress(null, getValue(a, "recipient")), + getValue(a, "start"), + getValue(a, "length"))) + .toList(); + } + @Override public InputStream retrieveAttachment(final String id) throws IOException { throw new UnsupportedOperationException();