X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/79cc225869b9a97bbb5b3f054970d5a6bb2222ee..b7005884fdcfa8d95f54e557ddbf2fe4201962f8:/lib/src/main/java/org/asamk/signal/manager/MultiAccountManagerImpl.java diff --git a/lib/src/main/java/org/asamk/signal/manager/MultiAccountManagerImpl.java b/lib/src/main/java/org/asamk/signal/manager/MultiAccountManagerImpl.java index df74cf42..26f8b961 100644 --- a/lib/src/main/java/org/asamk/signal/manager/MultiAccountManagerImpl.java +++ b/lib/src/main/java/org/asamk/signal/manager/MultiAccountManagerImpl.java @@ -6,10 +6,14 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; +import java.net.URI; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.concurrent.TimeoutException; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -20,6 +24,7 @@ public class MultiAccountManagerImpl implements MultiAccountManager { private final Set> onManagerAddedHandlers = new HashSet<>(); private final Set> onManagerRemovedHandlers = new HashSet<>(); private final Set managers = new HashSet<>(); + private final Map provisioningManagers = new HashMap<>(); private final File dataPath; private final ServiceEnvironment serviceEnvironment; private final String userAgent; @@ -78,6 +83,19 @@ public class MultiAccountManagerImpl implements MultiAccountManager { } } + @Override + public URI getNewProvisioningDeviceLinkUri() throws TimeoutException, IOException { + final var provisioningManager = getNewProvisioningManager(); + final var deviceLinkUri = provisioningManager.getDeviceLinkUri(); + provisioningManagers.put(deviceLinkUri, provisioningManager); + return deviceLinkUri; + } + + @Override + public ProvisioningManager getProvisioningManagerFor(final URI deviceLinkUri) { + return provisioningManagers.remove(deviceLinkUri); + } + @Override public ProvisioningManager getNewProvisioningManager() { return ProvisioningManager.init(dataPath, serviceEnvironment, userAgent, this::addManager);