]> nmode's Git Repositories - signal-cli/commitdiff
Implement removing linked devices
authorAsamK <asamk@gmx.de>
Sat, 16 Apr 2016 13:03:23 +0000 (15:03 +0200)
committerAsamK <asamk@gmx.de>
Sat, 16 Apr 2016 13:03:23 +0000 (15:03 +0200)
Only allowed from the master device

src/main/java/org/asamk/signal/Main.java
src/main/java/org/asamk/signal/Manager.java

index a6d36d0f248e7880478dfe3c32baf43d30945ed6..8aede3d652d78c532f4fd8919c8cb68ffe7642ea 100644 (file)
@@ -224,6 +224,23 @@ public class Main {
                         System.exit(3);
                     }
                     break;
+                case "removeDevice":
+                    if (dBusConn != null) {
+                        System.err.println("removeDevice is not yet implemented via dbus");
+                        System.exit(1);
+                    }
+                    if (!m.isRegistered()) {
+                        System.err.println("User is not registered.");
+                        System.exit(1);
+                    }
+                    try {
+                        int deviceId = ns.getInt("deviceId");
+                        m.removeLinkedDevices(deviceId);
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                        System.exit(3);
+                    }
+                    break;
                 case "send":
                     if (dBusConn == null && !m.isRegistered()) {
                         System.err.println("User is not registered.");
@@ -516,6 +533,12 @@ public class Main {
 
         Subparser parserDevices = subparsers.addParser("listDevices");
 
+        Subparser parserRemoveDevice = subparsers.addParser("removeDevice");
+        parserRemoveDevice.addArgument("-d", "--deviceId")
+                .type(int.class)
+                .required(true)
+                .help("Specify the device you want to remove. Use listDevices to see the deviceIds.");
+
         Subparser parserRegister = subparsers.addParser("register");
         parserRegister.addArgument("-v", "--voice")
                 .help("The verification should be done over voice, not sms.")
index 961be232048747e56eedfe6f16a99eac4faa9b41..47699c3f78e589caa4aeeaccd3449320f71b1e64 100644 (file)
@@ -264,6 +264,10 @@ class Manager implements Signal {
         return accountManager.getDevices();
     }
 
+    public void removeLinkedDevices(int deviceId) throws IOException {
+        accountManager.removeDevice(deviceId);
+    }
+
     public static Map<String, String> getQueryMap(String query) {
         String[] params = query.split("&");
         Map<String, String> map = new HashMap<>();