import org.whispersystems.libsignal.InvalidKeyException;
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
import org.whispersystems.signalservice.api.messages.*;
+import org.whispersystems.signalservice.api.messages.multidevice.DeviceInfo;
import org.whispersystems.signalservice.api.messages.multidevice.ReadMessage;
import org.whispersystems.signalservice.api.messages.multidevice.SentTranscriptMessage;
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
System.exit(2);
}
break;
+ case "listDevices":
+ if (dBusConn != null) {
+ System.err.println("listDevices is not yet implemented via dbus");
+ System.exit(1);
+ }
+ if (!m.isRegistered()) {
+ System.err.println("User is not registered.");
+ System.exit(1);
+ }
+ try {
+ List<DeviceInfo> devices = m.getLinkedDevices();
+ for (DeviceInfo d : devices) {
+ System.out.println("Device " + d.getId() + (d.getId() == m.getDeviceId() ? " (this device)" : "") + ":");
+ System.out.println(" Name: " + d.getName());
+ System.out.println(" Created: " + d.getCreated());
+ System.out.println(" Last seen: " + d.getLastSeen());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(3);
+ }
+ break;
case "send":
if (dBusConn == null && !m.isRegistered()) {
System.err.println("User is not registered.");
.required(true)
.help("Specify the uri contained in the QR code shown by the new device.");
+ Subparser parserDevices = subparsers.addParser("listDevices");
+
Subparser parserRegister = subparsers.addParser("register");
parserRegister.addArgument("-v", "--voice")
.help("The verification should be done over voice, not sms.")
private final ObjectMapper jsonProcessot = new ObjectMapper();
private String username;
- int deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
+ private int deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
private String password;
private String signalingKey;
private int preKeyIdOffset;
return username;
}
+ public int getDeviceId() {
+ return deviceId;
+ }
+
public String getFileName() {
new File(dataPath).mkdirs();
return dataPath + "/" + username;
save();
}
+ public List<DeviceInfo> getLinkedDevices() throws IOException {
+ return accountManager.getDevices();
+ }
public static Map<String, String> getQueryMap(String query) {
String[] params = query.split("&");