mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Manager : removeLinkedDevices updates isMultiDevice and saves the account
Manager : addDevice, getLinkedDevices save the account SignalAccount : save/load isMultiDevice SignalAccount : save profileKey SignalAccount : registrationLockPin doesn't automagically becomes the "null" string, and stays null if null
This commit is contained in:
parent
7e897fa6d0
commit
cf972e5b6c
2 changed files with 9 additions and 1 deletions
|
@ -248,11 +248,15 @@ public class Manager implements Signal {
|
||||||
public List<DeviceInfo> getLinkedDevices() throws IOException {
|
public List<DeviceInfo> getLinkedDevices() throws IOException {
|
||||||
List<DeviceInfo> devices = accountManager.getDevices();
|
List<DeviceInfo> devices = accountManager.getDevices();
|
||||||
account.setMultiDevice(devices.size() > 1);
|
account.setMultiDevice(devices.size() > 1);
|
||||||
|
account.save();
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeLinkedDevices(int deviceId) throws IOException {
|
public void removeLinkedDevices(int deviceId) throws IOException {
|
||||||
accountManager.removeDevice(deviceId);
|
accountManager.removeDevice(deviceId);
|
||||||
|
List<DeviceInfo> devices = accountManager.getDevices();
|
||||||
|
account.setMultiDevice(devices.size() > 1);
|
||||||
|
account.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDeviceLink(URI linkUri) throws IOException, InvalidKeyException {
|
public void addDeviceLink(URI linkUri) throws IOException, InvalidKeyException {
|
||||||
|
@ -267,6 +271,7 @@ public class Manager implements Signal {
|
||||||
|
|
||||||
accountManager.addDevice(deviceIdentifier, deviceKey, identityKeyPair, Optional.of(account.getProfileKey()), verificationCode);
|
accountManager.addDevice(deviceIdentifier, deviceKey, identityKeyPair, Optional.of(account.getProfileKey()), verificationCode);
|
||||||
account.setMultiDevice(true);
|
account.setMultiDevice(true);
|
||||||
|
account.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PreKeyRecord> generatePreKeys() {
|
private List<PreKeyRecord> generatePreKeys() {
|
||||||
|
|
|
@ -135,10 +135,11 @@ public class SignalAccount {
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
deviceId = node.asInt();
|
deviceId = node.asInt();
|
||||||
}
|
}
|
||||||
|
if (rootNode.has("isMultiDevice")) isMultiDevice = Util.getNotNullNode(rootNode, "isMultiDevice").asBoolean();
|
||||||
username = Util.getNotNullNode(rootNode, "username").asText();
|
username = Util.getNotNullNode(rootNode, "username").asText();
|
||||||
password = Util.getNotNullNode(rootNode, "password").asText();
|
password = Util.getNotNullNode(rootNode, "password").asText();
|
||||||
JsonNode pinNode = rootNode.get("registrationLockPin");
|
JsonNode pinNode = rootNode.get("registrationLockPin");
|
||||||
registrationLockPin = pinNode == null ? null : pinNode.asText();
|
registrationLockPin = pinNode == null || pinNode.isNull() ? null : pinNode.asText();
|
||||||
if (rootNode.has("signalingKey")) {
|
if (rootNode.has("signalingKey")) {
|
||||||
signalingKey = Util.getNotNullNode(rootNode, "signalingKey").asText();
|
signalingKey = Util.getNotNullNode(rootNode, "signalingKey").asText();
|
||||||
}
|
}
|
||||||
|
@ -189,11 +190,13 @@ public class SignalAccount {
|
||||||
ObjectNode rootNode = jsonProcessor.createObjectNode();
|
ObjectNode rootNode = jsonProcessor.createObjectNode();
|
||||||
rootNode.put("username", username)
|
rootNode.put("username", username)
|
||||||
.put("deviceId", deviceId)
|
.put("deviceId", deviceId)
|
||||||
|
.put("isMultiDevice", isMultiDevice)
|
||||||
.put("password", password)
|
.put("password", password)
|
||||||
.put("registrationLockPin", registrationLockPin)
|
.put("registrationLockPin", registrationLockPin)
|
||||||
.put("signalingKey", signalingKey)
|
.put("signalingKey", signalingKey)
|
||||||
.put("preKeyIdOffset", preKeyIdOffset)
|
.put("preKeyIdOffset", preKeyIdOffset)
|
||||||
.put("nextSignedPreKeyId", nextSignedPreKeyId)
|
.put("nextSignedPreKeyId", nextSignedPreKeyId)
|
||||||
|
.put("profileKey", Base64.encodeBytes(profileKey))
|
||||||
.put("registered", registered)
|
.put("registered", registered)
|
||||||
.putPOJO("axolotlStore", signalProtocolStore)
|
.putPOJO("axolotlStore", signalProtocolStore)
|
||||||
.putPOJO("groupStore", groupStore)
|
.putPOJO("groupStore", groupStore)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue