]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/commands/ListDevicesCommand.java
1 package org
.asamk
.signal
.commands
;
3 import net
.sourceforge
.argparse4j
.inf
.Namespace
;
4 import net
.sourceforge
.argparse4j
.inf
.Subparser
;
5 import org
.asamk
.signal
.manager
.Manager
;
6 import org
.asamk
.signal
.util
.DateUtils
;
7 import org
.whispersystems
.signalservice
.api
.messages
.multidevice
.DeviceInfo
;
9 import java
.io
.IOException
;
10 import java
.util
.List
;
12 public class ListDevicesCommand
implements LocalCommand
{
15 public void attachToSubparser(final Subparser subparser
) {
19 public int handleCommand(final Namespace ns
, final Manager m
) {
20 if (!m
.isRegistered()) {
21 System
.err
.println("User is not registered.");
25 List
<DeviceInfo
> devices
= m
.getLinkedDevices();
26 for (DeviceInfo d
: devices
) {
27 System
.out
.println("Device " + d
.getId() + (d
.getId() == m
.getDeviceId() ?
" (this device)" : "") + ":");
28 System
.out
.println(" Name: " + d
.getName());
29 System
.out
.println(" Created: " + DateUtils
.formatTimestamp(d
.getCreated()));
30 System
.out
.println(" Last seen: " + DateUtils
.formatTimestamp(d
.getLastSeen()));
33 } catch (IOException e
) {