mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-04 05:00:39 +00:00
implement Dbus addDevice and removeDevice methods
update documentation
This commit is contained in:
parent
bc3f8803dc
commit
da1bb918bf
4 changed files with 37 additions and 4 deletions
|
@ -268,9 +268,6 @@ isRegistered(numbers<as>) -> results<ab>::
|
||||||
* result : true=number is registered, false=number is not registered
|
* result : true=number is registered, false=number is not registered
|
||||||
* results : Boolean array of results
|
* results : Boolean array of results
|
||||||
|
|
||||||
listDevices() -> devices<as>::
|
|
||||||
* devices : String array of linked devices
|
|
||||||
|
|
||||||
listIdentity(number<s>) -> results<a(ssss)>::
|
listIdentity(number<s>) -> results<a(ssss)>::
|
||||||
* number : Phone number
|
* number : Phone number
|
||||||
* results : Array of elements, each consisting of four strings: trust_level, date_added, fingerprint, safety_number
|
* results : Array of elements, each consisting of four strings: trust_level, date_added, fingerprint, safety_number
|
||||||
|
@ -297,6 +294,15 @@ link(newDeviceName<s>) -> deviceLinkUri<s>::
|
||||||
* newDeviceName : Name to give new device (defaults to "cli" if no name is given)
|
* newDeviceName : Name to give new device (defaults to "cli" if no name is given)
|
||||||
* deviceLinkUri : URI of newly linked device
|
* deviceLinkUri : URI of newly linked device
|
||||||
|
|
||||||
|
addDevice(deviceUri<s>) -> <>::
|
||||||
|
* deviceUri : URI in the form of tsdevice:/?uuid=... Normally received from Signal desktop or smartphone app
|
||||||
|
|
||||||
|
listDevices() -> devices<as>::
|
||||||
|
* devices : String array of linked devices
|
||||||
|
|
||||||
|
removeDevice(deviceId<i>) -> <>::
|
||||||
|
* deviceId : Device ID to remove, obtained from listDevices() command
|
||||||
|
|
||||||
register(number<s>, voiceVerification<b>) -> <>::
|
register(number<s>, voiceVerification<b>) -> <>::
|
||||||
* number : Phone number
|
* number : Phone number
|
||||||
* voiceVerification : true = use voice verification; false = use SMS verification
|
* voiceVerification : true = use voice verification; false = use SMS verification
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.whispersystems.libsignal.InvalidKeyException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -139,6 +140,10 @@ public interface Signal extends DBusInterface {
|
||||||
|
|
||||||
String link(String newDeviceName) throws Error.Failure;
|
String link(String newDeviceName) throws Error.Failure;
|
||||||
|
|
||||||
|
void addDevice(String uri) throws Error.Failure;
|
||||||
|
|
||||||
|
void removeDevice(int deviceId) throws Error.Failure;
|
||||||
|
|
||||||
void register(
|
void register(
|
||||||
String number, boolean voiceVerification
|
String number, boolean voiceVerification
|
||||||
) throws Error.Failure, Error.InvalidNumber, SignalControl.Error.RequiresCaptcha;
|
) throws Error.Failure, Error.InvalidNumber, SignalControl.Error.RequiresCaptcha;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.asamk.signal.BaseConfig;
|
||||||
import org.asamk.signal.DbusConfig;
|
import org.asamk.signal.DbusConfig;
|
||||||
import org.asamk.signal.commands.SignalCreator;
|
import org.asamk.signal.commands.SignalCreator;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
|
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.PathConfig;
|
import org.asamk.signal.manager.PathConfig;
|
||||||
|
@ -26,6 +27,7 @@ import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
@ -186,7 +188,6 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
||||||
return BaseConfig.PROJECT_VERSION;
|
return BaseConfig.PROJECT_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DBusPath> listAccounts() {
|
public List<DBusPath> listAccounts() {
|
||||||
synchronized (receiveThreads) {
|
synchronized (receiveThreads) {
|
||||||
|
|
|
@ -39,6 +39,7 @@ 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.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -699,6 +700,26 @@ public class DbusSignalImpl implements Signal {
|
||||||
return DbusSignalControlImpl.link(newDeviceName);
|
return DbusSignalControlImpl.link(newDeviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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 void register(
|
public void register(
|
||||||
String number, boolean voiceVerification
|
String number, boolean voiceVerification
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue