X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/28e192c519c59d97d70aea6fabe18927e1aff42a..1ff3f07ab56f4e9762e09bf88f3992ff92aff8fc:/src/main/java/cli/Manager.java diff --git a/src/main/java/cli/Manager.java b/src/main/java/cli/Manager.java index 97070c97..433c43dc 100644 --- a/src/main/java/cli/Manager.java +++ b/src/main/java/cli/Manager.java @@ -30,12 +30,12 @@ import org.whispersystems.textsecure.api.TextSecureMessagePipe; import org.whispersystems.textsecure.api.TextSecureMessageReceiver; import org.whispersystems.textsecure.api.TextSecureMessageSender; import org.whispersystems.textsecure.api.crypto.TextSecureCipher; +import org.whispersystems.textsecure.api.messages.TextSecureContent; import org.whispersystems.textsecure.api.messages.TextSecureEnvelope; -import org.whispersystems.textsecure.api.messages.TextSecureMessage; +import org.whispersystems.textsecure.api.push.TextSecureAddress; import org.whispersystems.textsecure.api.push.TrustStore; import java.io.*; -import java.nio.file.Path; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -81,7 +81,9 @@ public class Manager { JSONObject in = new JSONObject(IOUtils.toString(new FileInputStream(getFileName()))); username = in.getString("username"); password = in.getString("password"); - signalingKey = in.getString("signalingKey"); + if (in.has("signalingKey")) { + signalingKey = in.getString("signalingKey"); + } axolotlStore = new JsonAxolotlStore(in.getJSONObject("axolotlStore")); registered = in.getBoolean("registered"); accountManager = new TextSecureAccountManager(URL, TRUST_STORE, username, password); @@ -115,12 +117,16 @@ public class Manager { 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; } @@ -151,7 +157,7 @@ public class Manager { axolotlStore, Optional.absent()); } - public TextSecureMessage receiveMessage() throws IOException, InvalidVersionException { + public TextSecureContent receiveMessage() throws IOException, InvalidVersionException { TextSecureMessageReceiver messageReceiver = new TextSecureMessageReceiver(URL, TRUST_STORE, username, password, signalingKey); TextSecureMessagePipe messagePipe = null; @@ -164,8 +170,8 @@ public class Manager { } catch (TimeoutException e) { return null; } - TextSecureCipher cipher = new TextSecureCipher(axolotlStore); - TextSecureMessage message = null; + TextSecureCipher cipher = new TextSecureCipher(new TextSecureAddress(username), axolotlStore); + TextSecureContent message = null; try { message = cipher.decrypt(envelope); } catch (Exception e) {