X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/1856e79a507e97c523f40426e0e30c5c72b50ad7..942999b7b4beebf4519eed9b216587519b47e6c6:/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java diff --git a/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java b/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java index 3478239f..244a110f 100644 --- a/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java +++ b/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java @@ -18,9 +18,9 @@ import org.whispersystems.signalservice.api.groupsv2.GroupsV2Api; import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations; import org.whispersystems.signalservice.api.push.SignalServiceAddress; import org.whispersystems.signalservice.api.services.ProfileService; +import org.whispersystems.signalservice.api.util.CredentialsProvider; import org.whispersystems.signalservice.api.util.UptimeSleepTimer; import org.whispersystems.signalservice.api.websocket.WebSocketFactory; -import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider; import org.whispersystems.signalservice.internal.websocket.WebSocketConnection; import java.util.concurrent.ExecutorService; @@ -34,7 +34,7 @@ public class SignalDependencies { private final ServiceEnvironmentConfig serviceEnvironmentConfig; private final String userAgent; - private final DynamicCredentialsProvider credentialsProvider; + private final CredentialsProvider credentialsProvider; private final SignalServiceDataStore dataStore; private final ExecutorService executor; private final SignalSessionLock sessionLock; @@ -52,10 +52,10 @@ public class SignalDependencies { private ProfileService profileService; private SignalServiceCipher cipher; - public SignalDependencies( + SignalDependencies( final ServiceEnvironmentConfig serviceEnvironmentConfig, final String userAgent, - final DynamicCredentialsProvider credentialsProvider, + final CredentialsProvider credentialsProvider, final SignalServiceDataStore dataStore, final ExecutorService executor, final SignalSessionLock sessionLock @@ -68,6 +68,15 @@ public class SignalDependencies { this.sessionLock = sessionLock; } + public void resetAfterAddressChange() { + this.messageSender = null; + this.cipher = null; + } + + public ServiceEnvironmentConfig getServiceEnvironmentConfig() { + return serviceEnvironmentConfig; + } + public SignalServiceAccountManager getAccountManager() { return getOrCreate(() -> accountManager, () -> accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.getSignalServiceConfiguration(), @@ -77,6 +86,17 @@ public class SignalDependencies { ServiceConfig.AUTOMATIC_NETWORK_RETRY)); } + public SignalServiceAccountManager createUnauthenticatedAccountManager(String number, String password) { + return new SignalServiceAccountManager(getServiceEnvironmentConfig().getSignalServiceConfiguration(), + null, + null, + number, + SignalServiceAddress.DEFAULT_DEVICE_ID, + password, + userAgent, + ServiceConfig.AUTOMATIC_NETWORK_RETRY); + } + public GroupsV2Api getGroupsV2Api() { return getOrCreate(() -> groupsV2Api, () -> groupsV2Api = getAccountManager().getGroupsV2Api()); } @@ -170,8 +190,9 @@ public class SignalDependencies { public SignalServiceCipher getCipher() { return getOrCreate(() -> cipher, () -> { final var certificateValidator = new CertificateValidator(serviceEnvironmentConfig.getUnidentifiedSenderTrustRoot()); - final var address = new SignalServiceAddress(credentialsProvider.getUuid(), credentialsProvider.getE164()); - cipher = new SignalServiceCipher(address, dataStore, sessionLock, certificateValidator); + final var address = new SignalServiceAddress(credentialsProvider.getAci(), credentialsProvider.getE164()); + final var deviceId = credentialsProvider.getDeviceId(); + cipher = new SignalServiceCipher(address, deviceId, dataStore.aci(), sessionLock, certificateValidator); }); }