3 import org
.asamk
.signal
.commands
.exceptions
.IOErrorException
;
4 import org
.freedesktop
.dbus
.DBusPath
;
5 import org
.freedesktop
.dbus
.Struct
;
6 import org
.freedesktop
.dbus
.annotations
.DBusProperty
;
7 import org
.freedesktop
.dbus
.annotations
.Position
;
8 import org
.freedesktop
.dbus
.exceptions
.DBusException
;
9 import org
.freedesktop
.dbus
.exceptions
.DBusExecutionException
;
10 import org
.freedesktop
.dbus
.interfaces
.DBusInterface
;
11 import org
.freedesktop
.dbus
.interfaces
.Properties
;
12 import org
.freedesktop
.dbus
.messages
.DBusSignal
;
14 import java
.util
.List
;
17 * DBus interface for the org.asamk.Signal service.
18 * Including emitted Signals and returned Errors.
20 public interface Signal
extends DBusInterface
{
22 String
getSelfNumber();
25 String message
, List
<String
> attachments
, String recipient
26 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.InvalidNumber
, Error
.UntrustedIdentity
;
29 String message
, List
<String
> attachments
, List
<String
> recipients
30 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.InvalidNumber
, Error
.UntrustedIdentity
;
33 String recipient
, boolean stop
34 ) throws Error
.Failure
, Error
.GroupNotFound
, Error
.UntrustedIdentity
;
37 String recipient
, List
<Long
> messageIds
38 ) throws Error
.Failure
, Error
.UntrustedIdentity
;
40 void sendViewedReceipt(
41 String recipient
, List
<Long
> messageIds
42 ) throws Error
.Failure
, Error
.UntrustedIdentity
;
44 long sendRemoteDeleteMessage(
45 long targetSentTimestamp
, String recipient
46 ) throws Error
.Failure
, Error
.InvalidNumber
;
48 long sendRemoteDeleteMessage(
49 long targetSentTimestamp
, List
<String
> recipients
50 ) throws Error
.Failure
, Error
.InvalidNumber
;
52 long sendGroupRemoteDeleteMessage(
53 long targetSentTimestamp
, byte[] groupId
54 ) throws Error
.Failure
, Error
.GroupNotFound
, Error
.InvalidGroupId
;
56 long sendMessageReaction(
57 String emoji
, boolean remove
, String targetAuthor
, long targetSentTimestamp
, String recipient
58 ) throws Error
.InvalidNumber
, Error
.Failure
;
60 long sendMessageReaction(
61 String emoji
, boolean remove
, String targetAuthor
, long targetSentTimestamp
, List
<String
> recipients
62 ) throws Error
.InvalidNumber
, Error
.Failure
;
64 void sendContacts() throws Error
.Failure
;
66 void sendSyncRequest() throws Error
.Failure
;
68 long sendNoteToSelfMessage(
69 String message
, List
<String
> attachments
70 ) throws Error
.AttachmentInvalid
, Error
.Failure
;
72 void sendEndSessionMessage(List
<String
> recipients
) throws Error
.Failure
, Error
.InvalidNumber
, Error
.UntrustedIdentity
;
74 long sendGroupMessage(
75 String message
, List
<String
> attachments
, byte[] groupId
76 ) throws Error
.GroupNotFound
, Error
.Failure
, Error
.AttachmentInvalid
, Error
.InvalidGroupId
;
78 long sendGroupMessageReaction(
79 String emoji
, boolean remove
, String targetAuthor
, long targetSentTimestamp
, byte[] groupId
80 ) throws Error
.GroupNotFound
, Error
.Failure
, Error
.InvalidNumber
, Error
.InvalidGroupId
;
82 String
getContactName(String number
) throws Error
.InvalidNumber
;
84 void setContactName(String number
, String name
) throws Error
.InvalidNumber
;
86 void setExpirationTimer(final String number
, final int expiration
) throws Error
.Failure
;
88 void setContactBlocked(String number
, boolean blocked
) throws Error
.InvalidNumber
;
91 void setGroupBlocked(byte[] groupId
, boolean blocked
) throws Error
.GroupNotFound
, Error
.InvalidGroupId
;
94 List
<byte[]> getGroupIds();
96 DBusPath
getGroup(byte[] groupId
);
98 List
<StructGroup
> listGroups();
101 String
getGroupName(byte[] groupId
) throws Error
.InvalidGroupId
;
104 List
<String
> getGroupMembers(byte[] groupId
) throws Error
.InvalidGroupId
;
107 String name
, List
<String
> members
, String avatar
108 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.InvalidNumber
;
112 byte[] groupId
, String name
, List
<String
> members
, String avatar
113 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.InvalidNumber
, Error
.GroupNotFound
, Error
.InvalidGroupId
;
115 boolean isRegistered() throws Error
.Failure
, Error
.InvalidNumber
;
117 boolean isRegistered(String number
) throws Error
.Failure
, Error
.InvalidNumber
;
119 List
<Boolean
> isRegistered(List
<String
> numbers
) throws Error
.Failure
, Error
.InvalidNumber
;
121 void addDevice(String uri
) throws Error
.InvalidUri
;
123 DBusPath
getDevice(long deviceId
);
125 List
<StructDevice
> listDevices() throws Error
.Failure
;
127 DBusPath
getThisDevice();
136 ) throws Error
.Failure
;
139 String name
, String about
, String aboutEmoji
, String avatarPath
, boolean removeAvatar
140 ) throws Error
.Failure
;
144 void setPin(String registrationLockPin
);
148 List
<String
> listNumbers();
150 List
<String
> getContactNumber(final String name
) throws Error
.Failure
;
153 void quitGroup(final byte[] groupId
) throws Error
.GroupNotFound
, Error
.Failure
, Error
.InvalidGroupId
;
155 boolean isContactBlocked(final String number
) throws Error
.InvalidNumber
;
158 boolean isGroupBlocked(final byte[] groupId
) throws Error
.InvalidGroupId
;
161 boolean isMember(final byte[] groupId
) throws Error
.InvalidGroupId
;
163 byte[] joinGroup(final String groupLink
) throws Error
.Failure
;
165 String
uploadStickerPack(String stickerPackPath
) throws Error
.Failure
;
167 void submitRateLimitChallenge(String challenge
, String captchaString
) throws IOErrorException
;
169 class MessageReceived
extends DBusSignal
{
171 private final long timestamp
;
172 private final String sender
;
173 private final byte[] groupId
;
174 private final String message
;
175 private final List
<String
> attachments
;
177 public MessageReceived(
183 List
<String
> attachments
184 ) throws DBusException
{
185 super(objectpath
, timestamp
, sender
, groupId
, message
, attachments
);
186 this.timestamp
= timestamp
;
187 this.sender
= sender
;
188 this.groupId
= groupId
;
189 this.message
= message
;
190 this.attachments
= attachments
;
193 public long getTimestamp() {
197 public String
getSender() {
201 public byte[] getGroupId() {
205 public String
getMessage() {
209 public List
<String
> getAttachments() {
214 class ReceiptReceived
extends DBusSignal
{
216 private final long timestamp
;
217 private final String sender
;
219 public ReceiptReceived(String objectpath
, long timestamp
, String sender
) throws DBusException
{
220 super(objectpath
, timestamp
, sender
);
221 this.timestamp
= timestamp
;
222 this.sender
= sender
;
225 public long getTimestamp() {
229 public String
getSender() {
234 class SyncMessageReceived
extends DBusSignal
{
236 private final long timestamp
;
237 private final String source
;
238 private final String destination
;
239 private final byte[] groupId
;
240 private final String message
;
241 private final List
<String
> attachments
;
243 public SyncMessageReceived(
250 List
<String
> attachments
251 ) throws DBusException
{
252 super(objectpath
, timestamp
, source
, destination
, groupId
, message
, attachments
);
253 this.timestamp
= timestamp
;
254 this.source
= source
;
255 this.destination
= destination
;
256 this.groupId
= groupId
;
257 this.message
= message
;
258 this.attachments
= attachments
;
261 public long getTimestamp() {
265 public String
getSource() {
269 public String
getDestination() {
273 public byte[] getGroupId() {
277 public String
getMessage() {
281 public List
<String
> getAttachments() {
286 class StructDevice
extends Struct
{
297 public StructDevice(final DBusPath objectPath
, final Long id
, final String name
) {
298 this.objectPath
= objectPath
;
303 public DBusPath
getObjectPath() {
307 public Long
getId() {
311 public String
getName() {
316 @DBusProperty(name
= "Id", type
= Long
.class, access
= DBusProperty
.Access
.READ
)
317 @DBusProperty(name
= "Name", type
= String
.class)
318 @DBusProperty(name
= "Created", type
= String
.class, access
= DBusProperty
.Access
.READ
)
319 @DBusProperty(name
= "LastSeen", type
= String
.class, access
= DBusProperty
.Access
.READ
)
320 interface Device
extends DBusInterface
, Properties
{
322 void removeDevice() throws Error
.Failure
;
325 class StructGroup
extends Struct
{
336 public StructGroup(final DBusPath objectPath
, final byte[] id
, final String name
) {
337 this.objectPath
= objectPath
;
342 public DBusPath
getObjectPath() {
346 public byte[] getId() {
350 public String
getName() {
355 @DBusProperty(name
= "Id", type
= Byte
[].class, access
= DBusProperty
.Access
.READ
)
356 @DBusProperty(name
= "Name", type
= String
.class)
357 @DBusProperty(name
= "Description", type
= String
.class)
358 @DBusProperty(name
= "Avatar", type
= String
.class, access
= DBusProperty
.Access
.WRITE
)
359 @DBusProperty(name
= "IsBlocked", type
= Boolean
.class)
360 @DBusProperty(name
= "IsMember", type
= Boolean
.class, access
= DBusProperty
.Access
.READ
)
361 @DBusProperty(name
= "IsAdmin", type
= Boolean
.class, access
= DBusProperty
.Access
.READ
)
362 @DBusProperty(name
= "MessageExpirationTimer", type
= Integer
.class)
363 @DBusProperty(name
= "Members", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
364 @DBusProperty(name
= "PendingMembers", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
365 @DBusProperty(name
= "RequestingMembers", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
366 @DBusProperty(name
= "Admins", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
367 @DBusProperty(name
= "PermissionAddMember", type
= String
.class)
368 @DBusProperty(name
= "PermissionEditDetails", type
= String
.class)
369 @DBusProperty(name
= "PermissionSendMessage", type
= String
.class)
370 @DBusProperty(name
= "GroupInviteLink", type
= String
.class, access
= DBusProperty
.Access
.READ
)
371 interface Group
extends DBusInterface
, Properties
{
373 void quitGroup() throws Error
.Failure
, Error
.LastGroupAdmin
;
375 void addMembers(List
<String
> recipients
) throws Error
.Failure
;
377 void removeMembers(List
<String
> recipients
) throws Error
.Failure
;
379 void addAdmins(List
<String
> recipients
) throws Error
.Failure
;
381 void removeAdmins(List
<String
> recipients
) throws Error
.Failure
;
383 void resetLink() throws Error
.Failure
;
385 void disableLink() throws Error
.Failure
;
387 void enableLink(boolean requiresApproval
) throws Error
.Failure
;
392 class AttachmentInvalid
extends DBusExecutionException
{
394 public AttachmentInvalid(final String message
) {
395 super("Invalid attachment: " + message
);
399 class InvalidUri
extends DBusExecutionException
{
401 public InvalidUri(final String message
) {
402 super("Invalid uri: " + message
);
406 class Failure
extends DBusExecutionException
{
408 public Failure(final Exception e
) {
409 super("Failure: " + e
.getMessage() + " (" + e
.getClass().getSimpleName() + ")");
412 public Failure(final String message
) {
413 super("Failure: " + message
);
417 class DeviceNotFound
extends DBusExecutionException
{
419 public DeviceNotFound(final String message
) {
420 super("Device not found: " + message
);
424 class GroupNotFound
extends DBusExecutionException
{
426 public GroupNotFound(final String message
) {
427 super("Group not found: " + message
);
431 class InvalidGroupId
extends DBusExecutionException
{
433 public InvalidGroupId(final String message
) {
434 super("Invalid group id: " + message
);
438 class LastGroupAdmin
extends DBusExecutionException
{
440 public LastGroupAdmin(final String message
) {
441 super("Last group admin: " + message
);
445 class InvalidNumber
extends DBusExecutionException
{
447 public InvalidNumber(final String message
) {
448 super("Invalid number: " + message
);
452 class UntrustedIdentity
extends DBusExecutionException
{
454 public UntrustedIdentity(final String message
) {
455 super("Untrusted identity: " + message
);