mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Add method to list linked devices
This commit is contained in:
parent
800b92c4ba
commit
17ff7531d4
2 changed files with 33 additions and 1 deletions
|
@ -29,6 +29,7 @@ import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
|||
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;
|
||||
|
@ -201,6 +202,28 @@ public class Main {
|
|||
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.");
|
||||
|
@ -491,6 +514,8 @@ public class Main {
|
|||
.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.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue