mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Adapt code for new libtextsecure-java version
This commit is contained in:
parent
067d14e1ca
commit
73e8c4cabf
3 changed files with 26 additions and 14 deletions
|
@ -22,7 +22,9 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.whispersystems.libaxolotl.InvalidVersionException;
|
||||
import org.whispersystems.textsecure.api.TextSecureMessageSender;
|
||||
import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException;
|
||||
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
||||
import org.whispersystems.textsecure.api.messages.TextSecureContent;
|
||||
import org.whispersystems.textsecure.api.messages.TextSecureDataMessage;
|
||||
import org.whispersystems.textsecure.api.messages.multidevice.TextSecureSyncMessage;
|
||||
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -117,7 +119,7 @@ public class Main {
|
|||
System.exit(1);
|
||||
}
|
||||
}
|
||||
TextSecureMessage message = TextSecureMessage.newBuilder().withBody(messageText).build();
|
||||
TextSecureDataMessage message = TextSecureDataMessage.newBuilder().withBody(messageText).build();
|
||||
for (String recipient : ns.<String>getList("recipient")) {
|
||||
try {
|
||||
messageSender.sendMessage(new TextSecureAddress(recipient), message);
|
||||
|
@ -132,11 +134,23 @@ public class Main {
|
|||
System.exit(1);
|
||||
}
|
||||
try {
|
||||
message = m.receiveMessage();
|
||||
if (message == null) {
|
||||
System.exit(0);
|
||||
} else {
|
||||
System.out.println("Received message: " + message.getBody().get());
|
||||
TextSecureContent content = m.receiveMessage();
|
||||
if (content.getDataMessage().isPresent()) {
|
||||
message = content.getDataMessage().get();
|
||||
if (message == null) {
|
||||
System.exit(0);
|
||||
} else {
|
||||
System.out.println("Received message: " + message.getBody().get());
|
||||
}
|
||||
}
|
||||
if (content.getSyncMessage().isPresent()) {
|
||||
TextSecureSyncMessage syncMessage = content.getSyncMessage().get();
|
||||
|
||||
if (syncMessage == null) {
|
||||
System.exit(0);
|
||||
} else {
|
||||
System.out.println("Received sync message");
|
||||
}
|
||||
}
|
||||
} catch (IOException | InvalidVersionException e) {
|
||||
System.out.println("Receive message: " + e.getMessage());
|
||||
|
|
|
@ -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;
|
||||
|
@ -151,7 +151,7 @@ public class Manager {
|
|||
axolotlStore, Optional.<TextSecureMessageSender.EventListener>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 +164,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) {
|
||||
|
|
|
@ -2,8 +2,6 @@ package cli;
|
|||
|
||||
import org.whispersystems.textsecure.api.push.TrustStore;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class WhisperTrustStore implements TrustStore {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue