Add possiblity to add new device, as master

This commit is contained in:
AsamK 2016-04-08 23:32:26 +02:00
parent 33956bde62
commit 947818d317
2 changed files with 78 additions and 0 deletions

View file

@ -40,6 +40,8 @@ import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.Security;
import java.util.ArrayList;
import java.util.List;
@ -177,6 +179,28 @@ public class Main {
System.exit(3);
}
break;
case "addDevice":
if (dBusConn != null) {
System.err.println("link is not yet implemented via dbus");
System.exit(1);
}
if (!m.isRegistered()) {
System.err.println("User is not registered.");
System.exit(1);
}
try {
m.addDeviceLink(new URI(ns.getString("uri")));
} catch (IOException e) {
e.printStackTrace();
System.exit(3);
} catch (InvalidKeyException e) {
e.printStackTrace();
System.exit(2);
} catch (URISyntaxException e) {
e.printStackTrace();
System.exit(2);
}
break;
case "send":
if (dBusConn == null && !m.isRegistered()) {
System.err.println("User is not registered.");
@ -462,6 +486,11 @@ public class Main {
parserLink.addArgument("-n", "--name")
.help("Specify a name to describe this new device.");
Subparser parserAddDevice = subparsers.addParser("addDevice");
parserAddDevice.addArgument("--uri")
.required(true)
.help("Specify the uri contained in the QR code shown by the new device.");
Subparser parserRegister = subparsers.addParser("register");
parserRegister.addArgument("-v", "--voice")
.help("The verification should be done over voice, not sms.")