X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/184354ffb71ea643b62c01c8406402ea4f492ac1..6f7350d031585e47172a52ffd2892b5aceb956b6:/src/main/java/org/asamk/signal/manager/Manager.java diff --git a/src/main/java/org/asamk/signal/manager/Manager.java b/src/main/java/org/asamk/signal/manager/Manager.java index 1b703e42..94605632 100644 --- a/src/main/java/org/asamk/signal/manager/Manager.java +++ b/src/main/java/org/asamk/signal/manager/Manager.java @@ -73,16 +73,14 @@ public class Manager implements Signal { private final String dataPath; private final String attachmentsPath; private final String avatarsPath; + private final SleepTimer timer = new UptimeSleepTimer(); private SignalAccount account; - private String username; private SignalServiceAccountManager accountManager; private SignalServiceMessagePipe messagePipe = null; private SignalServiceMessagePipe unidentifiedMessagePipe = null; - private SleepTimer timer = new UptimeSleepTimer(); - public Manager(String username, String settingsPath) { this.username = username; this.settingsPath = settingsPath; @@ -163,6 +161,7 @@ public class Manager implements Signal { if (account.getProfileKey() == null) { // Old config file, creating new profile key account.setProfileKey(KeyUtils.createProfileKey()); + account.save(); } } @@ -189,10 +188,11 @@ public class Manager implements Signal { account.setPassword(KeyUtils.createPassword()); accountManager = new SignalServiceAccountManager(BaseConfig.serviceConfiguration, account.getUsername(), account.getPassword(), BaseConfig.USER_AGENT, timer); - if (voiceVerification) - accountManager.requestVoiceVerificationCode(); - else - accountManager.requestSmsVerificationCode(); + if (voiceVerification) { + accountManager.requestVoiceVerificationCode(Locale.getDefault(), Optional.absent()); + } else { + accountManager.requestSmsVerificationCode(false, Optional.absent()); + } account.setRegistered(false); account.save(); @@ -250,11 +250,15 @@ public class Manager implements Signal { public List getLinkedDevices() throws IOException { List devices = accountManager.getDevices(); account.setMultiDevice(devices.size() > 1); + account.save(); return devices; } public void removeLinkedDevices(int deviceId) throws IOException { accountManager.removeDevice(deviceId); + List devices = accountManager.getDevices(); + account.setMultiDevice(devices.size() > 1); + account.save(); } public void addDeviceLink(URI linkUri) throws IOException, InvalidKeyException { @@ -269,6 +273,7 @@ public class Manager implements Signal { accountManager.addDevice(deviceIdentifier, deviceKey, identityKeyPair, Optional.of(account.getProfileKey()), verificationCode); account.setMultiDevice(true); + account.save(); } private List generatePreKeys() { @@ -1144,6 +1149,10 @@ public class Manager implements Signal { } if (c.getExpirationTimer().isPresent()) { ThreadInfo thread = account.getThreadStore().getThread(c.getNumber()); + if (thread == null) { + thread = new ThreadInfo(); + thread.id = c.getNumber(); + } thread.messageExpirationTime = c.getExpirationTimer().get(); account.getThreadStore().updateThread(thread); }