mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-04 05:00:39 +00:00
implement Dbus addDevice and removeDevice
update documentation as well
This commit is contained in:
parent
b875465eff
commit
8b19312a03
3 changed files with 37 additions and 0 deletions
|
@ -334,6 +334,11 @@ Exceptions: Failure, InvalidNumber
|
||||||
|
|
||||||
=== Other methods
|
=== Other methods
|
||||||
|
|
||||||
|
addDevice(deviceUri<s>) -> <>::
|
||||||
|
* deviceUri : URI in the form of tsdevice:/?uuid=... Normally received from Signal desktop or smartphone app
|
||||||
|
|
||||||
|
Exception: Failure
|
||||||
|
|
||||||
listDevices() -> devices<as>::
|
listDevices() -> devices<as>::
|
||||||
* devices : String array of linked devices
|
* devices : String array of linked devices
|
||||||
|
|
||||||
|
@ -346,6 +351,11 @@ This is a concatenated list of all defined contacts as well of profiles known (e
|
||||||
|
|
||||||
Exceptions: None
|
Exceptions: None
|
||||||
|
|
||||||
|
removeDevice(deviceId<i>) -> <>::
|
||||||
|
* deviceId : Device ID to remove, obtained from listDevices() command
|
||||||
|
|
||||||
|
Exception: Failure
|
||||||
|
|
||||||
sendNoteToSelfMessage(message<s>, attachments<as>) -> timestamp<x>::
|
sendNoteToSelfMessage(message<s>, attachments<as>) -> timestamp<x>::
|
||||||
* message : Text to send (can be UTF8)
|
* message : Text to send (can be UTF8)
|
||||||
* attachments : String array of filenames to send as attachments (passed as filename, so need to be readable by the user signal-cli is running under)
|
* attachments : String array of filenames to send as attachments (passed as filename, so need to be readable by the user signal-cli is running under)
|
||||||
|
|
|
@ -83,6 +83,10 @@ public interface Signal extends DBusInterface {
|
||||||
|
|
||||||
boolean isRegistered();
|
boolean isRegistered();
|
||||||
|
|
||||||
|
void addDevice(String uri) throws Error.Failure;
|
||||||
|
|
||||||
|
void removeDevice(int deviceId) throws Error.Failure;
|
||||||
|
|
||||||
List<String> listDevices() throws Error.Failure;
|
List<String> listDevices() throws Error.Failure;
|
||||||
|
|
||||||
void updateAccount(String deviceName) throws Error.Failure;
|
void updateAccount(String deviceName) throws Error.Failure;
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.asamk.signal.manager.storage.identities.IdentityInfo;
|
||||||
import org.asamk.signal.util.ErrorUtils;
|
import org.asamk.signal.util.ErrorUtils;
|
||||||
import org.asamk.signal.util.Util;
|
import org.asamk.signal.util.Util;
|
||||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||||
|
import org.whispersystems.libsignal.InvalidKeyException;
|
||||||
import org.whispersystems.libsignal.util.Pair;
|
import org.whispersystems.libsignal.util.Pair;
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException;
|
import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException;
|
||||||
|
@ -29,6 +30,8 @@ import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -61,6 +64,26 @@ public class DbusSignalImpl implements Signal {
|
||||||
return objectPath;
|
return objectPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addDevice(String uri) {
|
||||||
|
try {
|
||||||
|
m.addDeviceLink(new URI(uri));
|
||||||
|
} catch (IOException | InvalidKeyException e) {
|
||||||
|
throw new Error.Failure(e.getClass().getSimpleName() + " Add device link failed. " + e.getMessage());
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new Error.Failure(e.getClass().getSimpleName() + " Device link uri has invalid format: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeDevice(int deviceId) {
|
||||||
|
try {
|
||||||
|
m.removeLinkedDevices(deviceId);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Error.Failure(e.getClass().getSimpleName() + ": Error while removing device: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> listDevices() {
|
public List<String> listDevices() {
|
||||||
List<Device> devices;
|
List<Device> devices;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue