mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-07 14:30:38 +00:00
implement Dbus updateAccount and listDevices
implement updateAccount(deviceName<s>) to change device name implement listDevices update documentation
This commit is contained in:
parent
6c29d90503
commit
b875465eff
4 changed files with 337 additions and 112 deletions
|
@ -83,6 +83,10 @@ public interface Signal extends DBusInterface {
|
|||
|
||||
boolean isRegistered();
|
||||
|
||||
List<String> listDevices() throws Error.Failure;
|
||||
|
||||
void updateAccount(String deviceName) throws Error.Failure;
|
||||
|
||||
void updateProfile(
|
||||
String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
|
||||
) throws Error.Failure;
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.asamk.signal.manager.AttachmentInvalidException;
|
|||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
||||
import org.asamk.signal.manager.UntrustedIdentityException;
|
||||
import org.asamk.signal.manager.api.Device;
|
||||
import org.asamk.signal.manager.api.Message;
|
||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||
import org.asamk.signal.manager.api.TypingAction;
|
||||
|
@ -60,6 +61,34 @@ public class DbusSignalImpl implements Signal {
|
|||
return objectPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listDevices() {
|
||||
List<Device> devices;
|
||||
List<String> results = new ArrayList<String>();
|
||||
|
||||
try {
|
||||
devices = m.getLinkedDevices();
|
||||
} catch (IOException | Error.Failure e) {
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAccount(String deviceName) {
|
||||
try {
|
||||
m.updateAccountAttributes(deviceName);
|
||||
} catch (IOException | Signal.Error.Failure e) {
|
||||
throw new Error.Failure("UpdateAccount error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long sendMessage(final String message, final List<String> attachments, final String recipient) {
|
||||
var recipients = new ArrayList<String>(1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue