X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/404063a080a1a8784a1111304cc6b90b58362923..2a20e70aabaad0106774157a78eba60428604ac1:/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java diff --git a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java index 68218947..850bcf1d 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java @@ -2,20 +2,20 @@ package org.asamk.signal.dbus; import org.asamk.Signal; import org.asamk.signal.BaseConfig; -import org.asamk.signal.manager.AttachmentInvalidException; import org.asamk.signal.manager.Manager; -import org.asamk.signal.manager.NotMasterDeviceException; -import org.asamk.signal.manager.StickerPackInvalidException; +import org.asamk.signal.manager.api.AttachmentInvalidException; import org.asamk.signal.manager.api.Identity; import org.asamk.signal.manager.api.InactiveGroupLinkException; import org.asamk.signal.manager.api.InvalidDeviceLinkException; import org.asamk.signal.manager.api.InvalidNumberException; import org.asamk.signal.manager.api.InvalidStickerException; import org.asamk.signal.manager.api.Message; +import org.asamk.signal.manager.api.NotMasterDeviceException; import org.asamk.signal.manager.api.Pair; import org.asamk.signal.manager.api.RecipientIdentifier; import org.asamk.signal.manager.api.SendMessageResult; import org.asamk.signal.manager.api.SendMessageResults; +import org.asamk.signal.manager.api.StickerPackInvalidException; import org.asamk.signal.manager.api.TypingAction; import org.asamk.signal.manager.api.UnregisteredRecipientException; import org.asamk.signal.manager.api.UpdateGroup; @@ -79,12 +79,22 @@ public class DbusSignalImpl implements Signal { this.connection = connection; this.objectPath = objectPath; this.noReceiveOnStart = noReceiveOnStart; + + m.addAddressChangedListener(() -> { + unExportObjects(); + exportObjects(); + }); } public void initObjects() { + exportObjects(); if (!noReceiveOnStart) { subscribeReceive(); } + } + + private void exportObjects() { + exportObject(this); updateDevices(); updateGroups(); @@ -96,9 +106,14 @@ public class DbusSignalImpl implements Signal { m.removeReceiveHandler(dbusMessageHandler); dbusMessageHandler = null; } + unExportObjects(); + } + + private void unExportObjects() { unExportDevices(); unExportGroups(); unExportConfiguration(); + connection.unExportObject(this.objectPath); } @Override @@ -859,7 +874,7 @@ public class DbusSignalImpl implements Signal { } var errors = SendMessageResultUtils.getErrorMessagesFromSendMessageResults(results); - if (errors.size() < results.size()) { + if (errors.size() == 0 || errors.size() < results.size()) { return; } @@ -942,7 +957,7 @@ public class DbusSignalImpl implements Signal { if (d.isThisDevice()) { thisDevice = new DBusPath(deviceObjectPath); } - this.devices.add(new StructDevice(new DBusPath(deviceObjectPath), d.id(), emptyIfNull(d.name()))); + this.devices.add(new StructDevice(new DBusPath(deviceObjectPath), (long) d.id(), emptyIfNull(d.name()))); }); } @@ -1147,6 +1162,8 @@ public class DbusSignalImpl implements Signal { () -> new Variant<>(getRecipientStrings(getGroup().requestingMembers()), "as")), new DbusProperty<>("Admins", () -> new Variant<>(getRecipientStrings(getGroup().adminMembers()), "as")), + new DbusProperty<>("Banned", + () -> new Variant<>(getRecipientStrings(getGroup().bannedMembers()), "as")), new DbusProperty<>("PermissionAddMember", () -> getGroup().permissionAddMember().name(), this::setGroupPermissionAddMember),