mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Make deviceId an int
This commit is contained in:
parent
a3c5cfd2f4
commit
80befec589
7 changed files with 9 additions and 9 deletions
|
@ -134,7 +134,7 @@ public interface Manager extends Closeable {
|
||||||
|
|
||||||
List<Device> getLinkedDevices() throws IOException;
|
List<Device> getLinkedDevices() throws IOException;
|
||||||
|
|
||||||
void removeLinkedDevices(long deviceId) throws IOException;
|
void removeLinkedDevices(int deviceId) throws IOException;
|
||||||
|
|
||||||
void addDeviceLink(URI linkUri) throws IOException, InvalidDeviceLinkException;
|
void addDeviceLink(URI linkUri) throws IOException, InvalidDeviceLinkException;
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,7 @@ public class ManagerImpl implements Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeLinkedDevices(long deviceId) throws IOException {
|
public void removeLinkedDevices(int deviceId) throws IOException {
|
||||||
context.getAccountHelper().removeLinkedDevices(deviceId);
|
context.getAccountHelper().removeLinkedDevices(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
package org.asamk.signal.manager.api;
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
public record Device(long id, String name, long created, long lastSeen, boolean isThisDevice) {}
|
public record Device(int id, String name, long created, long lastSeen, boolean isThisDevice) {}
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class AccountHelper {
|
||||||
account.setMultiDevice(true);
|
account.setMultiDevice(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeLinkedDevices(long deviceId) throws IOException {
|
public void removeLinkedDevices(int deviceId) throws IOException {
|
||||||
dependencies.getAccountManager().removeDevice(deviceId);
|
dependencies.getAccountManager().removeDevice(deviceId);
|
||||||
var devices = dependencies.getAccountManager().getDevices();
|
var devices = dependencies.getAccountManager().getDevices();
|
||||||
account.setMultiDevice(devices.size() > 1);
|
account.setMultiDevice(devices.size() > 1);
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class RemoveDeviceCommand implements JsonRpcLocalCommand {
|
||||||
public void attachToSubparser(final Subparser subparser) {
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
subparser.help("Remove a linked device.");
|
subparser.help("Remove a linked device.");
|
||||||
subparser.addArgument("-d", "--device-id", "--deviceId")
|
subparser.addArgument("-d", "--device-id", "--deviceId")
|
||||||
.type(long.class)
|
.type(int.class)
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("Specify the device you want to remove. Use listDevices to see the deviceIds.");
|
.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
|
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
try {
|
try {
|
||||||
final var deviceId = ns.getLong("device-id");
|
final var deviceId = ns.getInt("device-id");
|
||||||
m.removeLinkedDevices(deviceId);
|
m.removeLinkedDevices(deviceId);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IOErrorException("Error while removing device: " + e.getMessage(), e);
|
throw new IOErrorException("Error while removing device: " + e.getMessage(), e);
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class DbusManagerImpl implements Manager {
|
||||||
return signal.listDevices().stream().map(d -> {
|
return signal.listDevices().stream().map(d -> {
|
||||||
final var device = getRemoteObject(d.getObjectPath(),
|
final var device = getRemoteObject(d.getObjectPath(),
|
||||||
Signal.Device.class).GetAll("org.asamk.Signal.Device");
|
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(),
|
(String) device.get("Name").getValue(),
|
||||||
(long) device.get("Created").getValue(),
|
(long) device.get("Created").getValue(),
|
||||||
(long) device.get("LastSeen").getValue(),
|
(long) device.get("LastSeen").getValue(),
|
||||||
|
@ -182,7 +182,7 @@ public class DbusManagerImpl implements Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeLinkedDevices(final long deviceId) throws IOException {
|
public void removeLinkedDevices(final int deviceId) throws IOException {
|
||||||
final var devicePath = signal.getDevice(deviceId);
|
final var devicePath = signal.getDevice(deviceId);
|
||||||
getRemoteObject(devicePath, Signal.Device.class).removeDevice();
|
getRemoteObject(devicePath, Signal.Device.class).removeDevice();
|
||||||
}
|
}
|
||||||
|
|
|
@ -942,7 +942,7 @@ public class DbusSignalImpl implements Signal {
|
||||||
if (d.isThisDevice()) {
|
if (d.isThisDevice()) {
|
||||||
thisDevice = new DBusPath(deviceObjectPath);
|
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())));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue