X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/805f976d9e3de22e4842df1622941584c7f7c041..a48601b028db52652484d38f83cba97742c27608:/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 aa357444..e034d677 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java @@ -7,10 +7,10 @@ import org.asamk.signal.manager.Manager; import org.asamk.signal.manager.MultiAccountManager; import org.asamk.signal.manager.ProvisioningManager; import org.asamk.signal.manager.RegistrationManager; -import org.asamk.signal.manager.UserAlreadyExists; import org.asamk.signal.manager.api.CaptchaRequiredException; import org.asamk.signal.manager.api.IncorrectPinException; import org.asamk.signal.manager.api.PinLockedException; +import org.asamk.signal.manager.api.UserAlreadyExistsException; import org.freedesktop.dbus.DBusPath; import java.io.IOException; @@ -81,8 +81,14 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl { registrationManager.verifyAccount(verificationCode, pin); } catch (OverlappingFileLockException e) { throw new SignalControl.Error.Failure("Account is already in use"); - } catch (IOException | PinLockedException | IncorrectPinException e) { + } catch (IOException e) { throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage()); + } catch (PinLockedException e) { + throw new Error.Failure( + "Verification failed! This number is locked with a pin. Hours remaining until reset: " + + (e.getTimeRemaining() / 1000 / 60 / 60)); + } catch (IncorrectPinException e) { + throw new Error.Failure("Verification failed! Invalid pin, tries remaining: " + e.getTriesRemaining()); } } @@ -90,14 +96,16 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl { public String link(final String newDeviceName) throws Error.Failure { try { final URI deviceLinkUri = c.getNewProvisioningDeviceLinkUri(); - new Thread(() -> { + final var thread = new Thread(() -> { final ProvisioningManager provisioningManager = c.getProvisioningManagerFor(deviceLinkUri); try { provisioningManager.finishDeviceLink(newDeviceName); - } catch (IOException | TimeoutException | UserAlreadyExists e) { + } catch (IOException | TimeoutException | UserAlreadyExistsException e) { e.printStackTrace(); } - }).start(); + }); + thread.setName("dbus-link"); + thread.start(); return deviceLinkUri.toString(); } catch (TimeoutException | IOException e) { throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage()); @@ -119,7 +127,7 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl { try { final var provisioningManager = c.getProvisioningManagerFor(new URI(deviceLinkUri)); return provisioningManager.finishDeviceLink(newDeviceName); - } catch (TimeoutException | IOException | UserAlreadyExists | URISyntaxException e) { + } catch (TimeoutException | IOException | UserAlreadyExistsException | URISyntaxException e) { throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage()); } }