]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/Signal.java
Return struct instead of object path directly for dbus list devices
[signal-cli] / src / main / java / org / asamk / Signal.java
index cc521f6d1eefbf763589ca6ac354edef18dde04b..2f81c196e714950dff561c48586c7e64578d925b 100644 (file)
@@ -1,8 +1,15 @@
 package org.asamk;
 
+import org.asamk.signal.commands.exceptions.IOErrorException;
+
+import org.freedesktop.dbus.DBusPath;
+import org.freedesktop.dbus.Struct;
+import org.freedesktop.dbus.annotations.DBusProperty;
+import org.freedesktop.dbus.annotations.Position;
 import org.freedesktop.dbus.exceptions.DBusException;
 import org.freedesktop.dbus.exceptions.DBusExecutionException;
 import org.freedesktop.dbus.interfaces.DBusInterface;
+import org.freedesktop.dbus.interfaces.Properties;
 import org.freedesktop.dbus.messages.DBusSignal;
 
 import java.util.List;
@@ -97,11 +104,11 @@ public interface Signal extends DBusInterface {
 
     void addDevice(String uri) throws Error.InvalidUri;
 
-    void removeDevice(int deviceId) throws Error.Failure;
+    DBusPath getDevice(long deviceId);
 
-    List<String> listDevices() throws Error.Failure;
+    List<StructDevice> listDevices() throws Error.Failure;
 
-    void updateDeviceName(String deviceName) throws Error.Failure;
+    DBusPath getThisDevice();
 
     void updateProfile(
             String givenName,
@@ -138,6 +145,8 @@ public interface Signal extends DBusInterface {
 
     String uploadStickerPack(String stickerPackPath) throws Error.Failure;
 
+    void submitRateLimitChallenge(String challenge, String captchaString) throws IOErrorException;
+
     class MessageReceived extends DBusSignal {
 
         private final long timestamp;
@@ -255,6 +264,45 @@ public interface Signal extends DBusInterface {
         }
     }
 
+    class StructDevice extends Struct {
+
+        @Position(0)
+        DBusPath objectPath;
+
+        @Position(1)
+        Long id;
+
+        @Position(2)
+        String name;
+
+        public StructDevice(final DBusPath objectPath, final Long id, final String name) {
+            this.objectPath = objectPath;
+            this.id = id;
+            this.name = name;
+        }
+
+        public DBusPath getObjectPath() {
+            return objectPath;
+        }
+
+        public Long getId() {
+            return id;
+        }
+
+        public String getName() {
+            return name;
+        }
+    }
+
+    @DBusProperty(name = "Id", type = Long.class, access = DBusProperty.Access.READ)
+    @DBusProperty(name = "Name", type = String.class)
+    @DBusProperty(name = "Created", type = String.class, access = DBusProperty.Access.READ)
+    @DBusProperty(name = "LastSeen", type = String.class, access = DBusProperty.Access.READ)
+    interface Device extends DBusInterface, Properties {
+
+        void removeDevice() throws Error.Failure;
+    }
+
     interface Error {
 
         class AttachmentInvalid extends DBusExecutionException {