X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/8aab644db9baa4feb5ccef4f43144313278f4691..4aa8e3f2f2d10040de2ff57f39a70a0149ce5811:/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java diff --git a/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java b/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java index 2e9ae08b..cfd17610 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java @@ -15,9 +15,9 @@ import org.freedesktop.dbus.DBusPath; import java.io.IOException; import java.net.URI; +import java.nio.channels.OverlappingFileLockException; import java.util.List; import java.util.concurrent.TimeoutException; -import java.util.stream.Collectors; public class DbusSignalControlImpl implements org.asamk.SignalControl { @@ -60,6 +60,8 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl { } catch (CaptchaRequiredException e) { String message = captcha == null ? "Captcha required for verification." : "Invalid captcha given."; throw new SignalControl.Error.RequiresCaptcha(message); + } catch (OverlappingFileLockException e) { + throw new SignalControl.Error.Failure("Account is already in use"); } catch (IOException e) { throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage()); } @@ -76,6 +78,8 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl { ) throws Error.Failure, Error.InvalidNumber { try (final RegistrationManager registrationManager = c.getNewRegistrationManager(number)) { registrationManager.verifyAccount(verificationCode, pin); + } catch (OverlappingFileLockException e) { + throw new SignalControl.Error.Failure("Account is already in use"); } catch (IOException | PinLockedException | IncorrectPinException e) { throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage()); } @@ -106,9 +110,6 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl { @Override public List listAccounts() { - return c.getAccountNumbers() - .stream() - .map(u -> new DBusPath(DbusConfig.getObjectPath(u))) - .collect(Collectors.toList()); + return c.getAccountNumbers().stream().map(u -> new DBusPath(DbusConfig.getObjectPath(u))).toList(); } }