mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Implement startLink and finishLink for jsonrpc daemon
This commit is contained in:
parent
79cc225869
commit
b7005884fd
9 changed files with 242 additions and 1 deletions
|
@ -1,7 +1,9 @@
|
|||
package org.asamk.signal.manager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface MultiAccountManager extends AutoCloseable {
|
||||
|
@ -14,6 +16,10 @@ public interface MultiAccountManager extends AutoCloseable {
|
|||
|
||||
Manager getManager(String phoneNumber);
|
||||
|
||||
URI getNewProvisioningDeviceLinkUri() throws TimeoutException, IOException;
|
||||
|
||||
ProvisioningManager getProvisioningManagerFor(URI deviceLinkUri);
|
||||
|
||||
ProvisioningManager getNewProvisioningManager();
|
||||
|
||||
RegistrationManager getNewRegistrationManager(String username) throws IOException;
|
||||
|
|
|
@ -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<Consumer<Manager>> onManagerAddedHandlers = new HashSet<>();
|
||||
private final Set<Consumer<Manager>> onManagerRemovedHandlers = new HashSet<>();
|
||||
private final Set<Manager> managers = new HashSet<>();
|
||||
private final Map<URI, ProvisioningManager> 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);
|
||||
|
|
|
@ -146,6 +146,7 @@ public class ProvisioningManager {
|
|||
ManagerImpl m = null;
|
||||
try {
|
||||
m = new ManagerImpl(account, pathConfig, serviceEnvironmentConfig, userAgent);
|
||||
account = null;
|
||||
|
||||
logger.debug("Refreshing pre keys");
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue