import org.asamk.signal.manager.MultiAccountManager;
import org.asamk.signal.manager.ProvisioningManager;
import org.asamk.signal.manager.RegistrationManager;
import org.asamk.signal.manager.MultiAccountManager;
import org.asamk.signal.manager.ProvisioningManager;
import org.asamk.signal.manager.RegistrationManager;
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.CaptchaRequiredException;
import org.asamk.signal.manager.api.IncorrectPinException;
import org.asamk.signal.manager.api.PinLockedException;
public String link(final String newDeviceName) throws Error.Failure {
try {
final URI deviceLinkUri = c.getNewProvisioningDeviceLinkUri();
public String link(final String newDeviceName) throws Error.Failure {
try {
final URI deviceLinkUri = c.getNewProvisioningDeviceLinkUri();
final ProvisioningManager provisioningManager = c.getProvisioningManagerFor(deviceLinkUri);
try {
provisioningManager.finishDeviceLink(newDeviceName);
final ProvisioningManager provisioningManager = c.getProvisioningManagerFor(deviceLinkUri);
try {
provisioningManager.finishDeviceLink(newDeviceName);
return deviceLinkUri.toString();
} catch (TimeoutException | IOException e) {
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
return deviceLinkUri.toString();
} catch (TimeoutException | IOException e) {
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
try {
final var provisioningManager = c.getProvisioningManagerFor(new URI(deviceLinkUri));
return provisioningManager.finishDeviceLink(newDeviceName);
try {
final var provisioningManager = c.getProvisioningManagerFor(new URI(deviceLinkUri));
return provisioningManager.finishDeviceLink(newDeviceName);