This commit is contained in:
Juraj Bednar 2015-07-05 21:50:54 +00:00
commit 82637fb148
2 changed files with 13 additions and 5 deletions

View file

@ -17,6 +17,7 @@
package cli;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.impl.Arguments;
import net.sourceforge.argparse4j.inf.*;
import org.apache.commons.io.IOUtils;
import org.whispersystems.libaxolotl.InvalidVersionException;
@ -43,9 +44,12 @@ public class Main {
.description("valid subcommands")
.help("additional help");
Subparser parserRegister = subparsers.addParser("register");
parserRegister.addArgument("-v", "--voice")
.help("The verification should be done over voice, not sms.")
.action(Arguments.storeTrue());
Subparser parserVerify = subparsers.addParser("verify");
parserVerify.addArgument("verificationCode")
.help("The verification code you received via sms.");
.help("The verification code you received via sms or voice call.");
Subparser parserSend = subparsers.addParser("send");
parserSend.addArgument("recipient")
.help("Specify the recipients' phone number.")
@ -80,7 +84,7 @@ public class Main {
m.createNewIdentity();
}
try {
m.register();
m.register(ns.getBoolean("voice"));
} catch (IOException e) {
System.out.println("Request verify error: " + e.getMessage());
System.exit(3);

View file

@ -115,18 +115,22 @@ public class Manager {
return registered;
}
public void register() throws IOException {
public void register(boolean voiceVerication) throws IOException {
password = Util.getSecret(18);
signalingKey = Util.getSecret(52);
accountManager = new TextSecureAccountManager(URL, TRUST_STORE, username, password);
if (voiceVerication)
accountManager.requestVoiceVerificationCode();
else
accountManager.requestSmsVerificationCode();
registered = false;
}
public void verifyAccount(String verificationCode) throws IOException {
verificationCode = verificationCode.replace("-", "");
signalingKey = Util.getSecret(52);
accountManager.verifyAccount(verificationCode, signalingKey, false, axolotlStore.getLocalRegistrationId());
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));