Make deviceId an int

This commit is contained in:
AsamK 2022-01-22 16:41:00 +01:00
parent a3c5cfd2f4
commit 80befec589
7 changed files with 9 additions and 9 deletions

View file

@ -21,7 +21,7 @@ public class RemoveDeviceCommand implements JsonRpcLocalCommand {
public void attachToSubparser(final Subparser subparser) {
subparser.help("Remove a linked device.");
subparser.addArgument("-d", "--device-id", "--deviceId")
.type(long.class)
.type(int.class)
.required(true)
.help("Specify the device you want to remove. Use listDevices to see the deviceIds.");
}
@ -31,7 +31,7 @@ public class RemoveDeviceCommand implements JsonRpcLocalCommand {
final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException {
try {
final var deviceId = ns.getLong("device-id");
final var deviceId = ns.getInt("device-id");
m.removeLinkedDevices(deviceId);
} catch (IOException e) {
throw new IOErrorException("Error while removing device: " + e.getMessage(), e);

View file

@ -173,7 +173,7 @@ public class DbusManagerImpl implements Manager {
return signal.listDevices().stream().map(d -> {
final var device = getRemoteObject(d.getObjectPath(),
Signal.Device.class).GetAll("org.asamk.Signal.Device");
return new Device((long) device.get("Id").getValue(),
return new Device(((Long) device.get("Id").getValue()).intValue(),
(String) device.get("Name").getValue(),
(long) device.get("Created").getValue(),
(long) device.get("LastSeen").getValue(),
@ -182,7 +182,7 @@ public class DbusManagerImpl implements Manager {
}
@Override
public void removeLinkedDevices(final long deviceId) throws IOException {
public void removeLinkedDevices(final int deviceId) throws IOException {
final var devicePath = signal.getDevice(deviceId);
getRemoteObject(devicePath, Signal.Device.class).removeDevice();
}

View file

@ -942,7 +942,7 @@ public class DbusSignalImpl implements Signal {
if (d.isThisDevice()) {
thisDevice = new DBusPath(deviceObjectPath);
}
this.devices.add(new StructDevice(new DBusPath(deviceObjectPath), d.id(), emptyIfNull(d.name())));
this.devices.add(new StructDevice(new DBusPath(deviceObjectPath), (long) d.id(), emptyIfNull(d.name())));
});
}