X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/a66dd0dc79330b095a1bc0353ea183d7846fb945..e61f587bfc8f5557587d8c6cd54efcaf6631fdce:/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 d6cd52fa..e9fc3f9c 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java @@ -4,6 +4,7 @@ import org.asamk.Signal; import org.asamk.signal.DbusConfig; import org.asamk.signal.manager.Manager; import org.asamk.signal.manager.api.AttachmentInvalidException; +import org.asamk.signal.manager.api.CaptchaRequiredException; import org.asamk.signal.manager.api.Configuration; import org.asamk.signal.manager.api.Contact; import org.asamk.signal.manager.api.Device; @@ -17,15 +18,19 @@ 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.IncorrectPinException; 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.NonNormalizedPhoneNumberException; 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.PinLockedException; +import org.asamk.signal.manager.api.RateLimitException; import org.asamk.signal.manager.api.ReceiveConfig; import org.asamk.signal.manager.api.Recipient; import org.asamk.signal.manager.api.RecipientAddress; @@ -131,7 +136,7 @@ public class DbusManagerImpl implements Manager { } @Override - public void updateConfiguration(Configuration newConfiguration) throws IOException { + public void updateConfiguration(Configuration newConfiguration) { final var configuration = getRemoteObject(new DBusPath(signal.getObjectPath() + "/Configuration"), Signal.Configuration.class); newConfiguration.readReceipts() @@ -166,6 +171,20 @@ public class DbusManagerImpl implements Manager { throw new UnsupportedOperationException(); } + @Override + public void startChangeNumber( + final String newNumber, final boolean voiceVerification, final String captcha + ) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException { + throw new UnsupportedOperationException(); + } + + @Override + public void finishChangeNumber( + final String newNumber, final String verificationCode, final String pin + ) throws IncorrectPinException, PinLockedException, IOException { + throw new UnsupportedOperationException(); + } + @Override public void unregister() throws IOException { signal.unregister(); @@ -225,7 +244,7 @@ public class DbusManagerImpl implements Manager { public SendGroupMessageResults quitGroup( final GroupId groupId, final Set groupAdmins ) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException { - if (groupAdmins.size() > 0) { + if (!groupAdmins.isEmpty()) { throw new UnsupportedOperationException(); } final var group = getRemoteObject(signal.getGroup(groupId.serialize()), Signal.Group.class); @@ -503,7 +522,7 @@ public class DbusManagerImpl implements Manager { if (isWeakListener) { weakHandlers.add(handler); } else { - if (messageHandlers.size() == 0) { + if (messageHandlers.isEmpty()) { installMessageHandlers(); } messageHandlers.add(handler); @@ -516,7 +535,7 @@ public class DbusManagerImpl implements Manager { synchronized (messageHandlers) { weakHandlers.remove(handler); messageHandlers.remove(handler); - if (messageHandlers.size() == 0) { + if (messageHandlers.isEmpty()) { uninstallMessageHandlers(); } } @@ -525,7 +544,7 @@ public class DbusManagerImpl implements Manager { @Override public boolean isReceiving() { synchronized (messageHandlers) { - return messageHandlers.size() > 0; + return !messageHandlers.isEmpty(); } } @@ -603,7 +622,7 @@ public class DbusManagerImpl implements Manager { return null; } final var contactName = signal.getContactName(n); - if (onlyContacts && contactName.length() == 0) { + if (onlyContacts && contactName.isEmpty()) { return null; } if (name.isPresent() && !name.get().equals(contactName)) { @@ -702,7 +721,7 @@ public class DbusManagerImpl implements Manager { this.notify(); } synchronized (messageHandlers) { - if (messageHandlers.size() > 0) { + if (!messageHandlers.isEmpty()) { uninstallMessageHandlers(); } weakHandlers.clear(); @@ -726,7 +745,7 @@ public class DbusManagerImpl implements Manager { .map(RecipientIdentifier.Single.class::cast) .map(RecipientIdentifier.Single::getIdentifier) .toList(); - if (singleRecipients.size() > 0) { + if (!singleRecipients.isEmpty()) { timestamp = recipientsHandler.apply(singleRecipients); } @@ -929,7 +948,7 @@ public class DbusManagerImpl implements Manager { }; connection.addSigHandler(Signal.SyncMessageReceivedV2.class, signal, this.dbusSyncHandler); } catch (DBusException e) { - e.printStackTrace(); + throw new RuntimeException(e); } signal.subscribeReceive(); } @@ -949,7 +968,7 @@ public class DbusManagerImpl implements Manager { connection.removeSigHandler(Signal.ReceiptReceivedV2.class, signal, this.dbusRcptHandler); connection.removeSigHandler(Signal.SyncMessageReceivedV2.class, signal, this.dbusSyncHandler); } catch (DBusException e) { - e.printStackTrace(); + throw new RuntimeException(e); } }