private String username;
private int deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
private String password;
+ private String registrationLockPin;
private String signalingKey;
private int preKeyIdOffset;
private int nextSignedPreKeyId;
}
username = getNotNullNode(rootNode, "username").asText();
password = getNotNullNode(rootNode, "password").asText();
+ JsonNode pinNode = rootNode.get("registrationLockPin");
+ registrationLockPin = pinNode == null ? null : pinNode.asText();
if (rootNode.has("signalingKey")) {
signalingKey = getNotNullNode(rootNode, "signalingKey").asText();
}
rootNode.put("username", username)
.put("deviceId", deviceId)
.put("password", password)
+ .put("registrationLockPin", registrationLockPin)
.put("signalingKey", signalingKey)
.put("preKeyIdOffset", preKeyIdOffset)
.put("nextSignedPreKeyId", nextSignedPreKeyId)
}
public void updateAccountAttributes() throws IOException {
- accountManager.setAccountAttributes(signalingKey, signalProtocolStore.getLocalRegistrationId(), true);
+ accountManager.setAccountAttributes(signalingKey, signalProtocolStore.getLocalRegistrationId(), true, registrationLockPin);
}
public void unregister() throws IOException {
}
}
- public void verifyAccount(String verificationCode) throws IOException {
+ public void verifyAccount(String verificationCode, String pin) throws IOException {
verificationCode = verificationCode.replace("-", "");
signalingKey = Util.getSecret(52);
- accountManager.verifyAccountWithCode(verificationCode, signalingKey, signalProtocolStore.getLocalRegistrationId(), true);
+ accountManager.verifyAccountWithCode(verificationCode, signalingKey, signalProtocolStore.getLocalRegistrationId(), true, pin);
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
registered = true;
+ registrationLockPin = pin;
refreshPreKeys();
save();
}
+ public void setRegistrationLockPin(Optional<String> pin) throws IOException {
+ accountManager.setPin(pin);
+ if (pin.isPresent()) {
+ registrationLockPin = pin.get();
+ } else {
+ registrationLockPin = null;
+ }
+ }
+
private void refreshPreKeys() throws IOException {
List<PreKeyRecord> oneTimePreKeys = generatePreKeys();
SignedPreKeyRecord signedPreKeyRecord = generateSignedPreKey(signalProtocolStore.getIdentityKeyPair());
save();
}
+ @Override
+ public List<byte[]> getGroupIds() {
+ List<GroupInfo> groups = getGroups();
+ List<byte[]> ids = new ArrayList<byte[]>(groups.size());
+ for (GroupInfo group : groups) {
+ ids.add(group.groupId);
+ }
+ return ids;
+ }
+
@Override
public String getGroupName(byte[] groupId) {
GroupInfo group = getGroup(groupId);