Dbus add/remove/list/update devices

modifications responding to requests by AsamK
This commit is contained in:
John Freed 2021-09-22 20:48:09 +02:00
parent 46eef01d61
commit d3136060a1
3 changed files with 149 additions and 266 deletions

View file

@ -83,13 +83,13 @@ public interface Signal extends DBusInterface {
boolean isRegistered();
void addDevice(String uri) throws Error.Failure;
void addDevice(String uri) throws Error.InvalidUri;
void removeDevice(int deviceId) throws Error.Failure;
List<String> listDevices() throws Error.Failure;
void updateAccount(String deviceName) throws Error.Failure;
void updateDeviceName(String deviceName) throws Error.Failure;
void updateProfile(
String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
@ -241,6 +241,13 @@ public interface Signal extends DBusInterface {
}
}
class InvalidUri extends DBusExecutionException {
public InvalidUri(final String message) {
super(message);
}
}
class Failure extends DBusExecutionException {
public Failure(final String message) {

View file

@ -96,16 +96,13 @@ public class DbusSignalImpl implements Signal {
throw new Error.Failure("Failed to get linked devices: " + e.getMessage());
}
for (var d : devices) {
var name = d.getName();
if (name == null) {name = "null";}
results.add(name);
}
return results;
return devices.stream()
.map(d -> d.getName() == null ? "" : d.getName())
.collect(Collectors.toList());
}
@Override
public void updateAccount(String deviceName) {
public void updateDeviceName(String deviceName) {
try {
m.updateAccountAttributes(deviceName);
} catch (IOException | Signal.Error.Failure e) {