import org.whispersystems.libaxolotl.state.PreKeyRecord;
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
import org.whispersystems.libaxolotl.util.KeyHelper;
+import org.whispersystems.libaxolotl.util.Medium;
import org.whispersystems.libaxolotl.util.guava.Optional;
import org.whispersystems.textsecure.api.TextSecureAccountManager;
import org.whispersystems.textsecure.api.TextSecureMessagePipe;
return registered;
}
- public void register() throws IOException {
+ public void register(boolean voiceVerication) throws IOException {
password = Util.getSecret(18);
accountManager = new TextSecureAccountManager(URL, TRUST_STORE, username, password);
- accountManager.requestSmsVerificationCode();
+ if (voiceVerication)
+ accountManager.requestVoiceVerificationCode();
+ else
+ accountManager.requestSmsVerificationCode();
+
registered = false;
}
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
registered = true;
+
int start = 0;
List<PreKeyRecord> oneTimePreKeys = KeyHelper.generatePreKeys(start, 100);
+ for (int i = start; i < oneTimePreKeys.size(); i++) {
+ axolotlStore.storePreKey(i, oneTimePreKeys.get(i));
+ }
+
PreKeyRecord lastResortKey = KeyHelper.generateLastResortPreKey();
+ axolotlStore.storePreKey(Medium.MAX_VALUE, lastResortKey);
+
int signedPreKeyId = 0;
SignedPreKeyRecord signedPreKeyRecord;
try {
signedPreKeyRecord = KeyHelper.generateSignedPreKey(axolotlStore.getIdentityKeyPair(), signedPreKeyId);
+ axolotlStore.storeSignedPreKey(signedPreKeyId, signedPreKeyRecord);
} catch (InvalidKeyException e) {
// Should really not happen
System.out.println("invalid key");