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
;
13 import org
.freedesktop
.dbus
.types
.Variant
;
15 import java
.util
.List
;
19 * DBus interface for the org.asamk.Signal service.
20 * Including emitted Signals and returned Errors.
22 public interface Signal
extends DBusInterface
{
24 String
getSelfNumber();
27 String message
, List
<String
> attachments
, String recipient
28 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.InvalidNumber
, Error
.UntrustedIdentity
;
31 String message
, List
<String
> attachments
, List
<String
> recipients
32 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.InvalidNumber
, Error
.UntrustedIdentity
;
35 String recipient
, boolean stop
36 ) throws Error
.Failure
, Error
.GroupNotFound
, Error
.UntrustedIdentity
;
39 String recipient
, List
<Long
> messageIds
40 ) throws Error
.Failure
, Error
.UntrustedIdentity
;
42 void sendViewedReceipt(
43 String recipient
, List
<Long
> messageIds
44 ) throws Error
.Failure
, Error
.UntrustedIdentity
;
46 long sendRemoteDeleteMessage(
47 long targetSentTimestamp
, String recipient
48 ) throws Error
.Failure
, Error
.InvalidNumber
;
50 long sendRemoteDeleteMessage(
51 long targetSentTimestamp
, List
<String
> recipients
52 ) throws Error
.Failure
, Error
.InvalidNumber
;
54 long sendGroupRemoteDeleteMessage(
55 long targetSentTimestamp
, byte[] groupId
56 ) throws Error
.Failure
, Error
.GroupNotFound
, Error
.InvalidGroupId
;
58 long sendMessageReaction(
59 String emoji
, boolean remove
, String targetAuthor
, long targetSentTimestamp
, String recipient
60 ) throws Error
.InvalidNumber
, Error
.Failure
;
62 long sendMessageReaction(
63 String emoji
, boolean remove
, String targetAuthor
, long targetSentTimestamp
, List
<String
> recipients
64 ) throws Error
.InvalidNumber
, Error
.Failure
;
66 void sendContacts() throws Error
.Failure
;
68 void sendSyncRequest() throws Error
.Failure
;
70 long sendNoteToSelfMessage(
71 String message
, List
<String
> attachments
72 ) throws Error
.AttachmentInvalid
, Error
.Failure
;
74 void sendEndSessionMessage(List
<String
> recipients
) throws Error
.Failure
, Error
.InvalidNumber
, Error
.UntrustedIdentity
;
76 long sendGroupMessage(
77 String message
, List
<String
> attachments
, byte[] groupId
78 ) throws Error
.GroupNotFound
, Error
.Failure
, Error
.AttachmentInvalid
, Error
.InvalidGroupId
;
80 long sendGroupMessageReaction(
81 String emoji
, boolean remove
, String targetAuthor
, long targetSentTimestamp
, byte[] groupId
82 ) throws Error
.GroupNotFound
, Error
.Failure
, Error
.InvalidNumber
, Error
.InvalidGroupId
;
84 String
getContactName(String number
) throws Error
.InvalidNumber
;
86 void setContactName(String number
, String name
) throws Error
.InvalidNumber
;
88 void setExpirationTimer(final String number
, final int expiration
) throws Error
.Failure
;
90 void setContactBlocked(String number
, boolean blocked
) throws Error
.InvalidNumber
;
93 void setGroupBlocked(byte[] groupId
, boolean blocked
) throws Error
.GroupNotFound
, Error
.InvalidGroupId
;
96 List
<byte[]> getGroupIds();
98 DBusPath
getGroup(byte[] groupId
);
100 List
<StructGroup
> listGroups();
103 String
getGroupName(byte[] groupId
) throws Error
.InvalidGroupId
;
106 List
<String
> getGroupMembers(byte[] groupId
) throws Error
.InvalidGroupId
;
109 String name
, List
<String
> members
, String avatar
110 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.InvalidNumber
;
114 byte[] groupId
, String name
, List
<String
> members
, String avatar
115 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.InvalidNumber
, Error
.GroupNotFound
, Error
.InvalidGroupId
;
117 boolean isRegistered() throws Error
.Failure
, Error
.InvalidNumber
;
119 boolean isRegistered(String number
) throws Error
.Failure
, Error
.InvalidNumber
;
121 List
<Boolean
> isRegistered(List
<String
> numbers
) throws Error
.Failure
, Error
.InvalidNumber
;
123 void addDevice(String uri
) throws Error
.InvalidUri
;
125 DBusPath
getDevice(long deviceId
);
127 List
<StructDevice
> listDevices() throws Error
.Failure
;
129 DBusPath
getThisDevice();
138 ) throws Error
.Failure
;
141 String name
, String about
, String aboutEmoji
, String avatarPath
, boolean removeAvatar
142 ) throws Error
.Failure
;
146 void setPin(String registrationLockPin
);
150 List
<String
> listNumbers();
152 List
<String
> getContactNumber(final String name
) throws Error
.Failure
;
155 void quitGroup(final byte[] groupId
) throws Error
.GroupNotFound
, Error
.Failure
, Error
.InvalidGroupId
;
157 boolean isContactBlocked(final String number
) throws Error
.InvalidNumber
;
160 boolean isGroupBlocked(final byte[] groupId
) throws Error
.InvalidGroupId
;
163 boolean isMember(final byte[] groupId
) throws Error
.InvalidGroupId
;
165 byte[] joinGroup(final String groupLink
) throws Error
.Failure
;
167 String
uploadStickerPack(String stickerPackPath
) throws Error
.Failure
;
169 void submitRateLimitChallenge(String challenge
, String captchaString
) throws IOErrorException
;
171 class MessageReceivedV2
extends DBusSignal
{
173 private final long timestamp
;
174 private final String sender
;
175 private final byte[] groupId
;
176 private final String message
;
177 private final Map
<String
, Variant
<?
>> extras
;
179 public MessageReceivedV2(
185 final Map
<String
, Variant
<?
>> extras
186 ) throws DBusException
{
187 super(objectpath
, timestamp
, sender
, groupId
, message
, extras
);
188 this.timestamp
= timestamp
;
189 this.sender
= sender
;
190 this.groupId
= groupId
;
191 this.message
= message
;
192 this.extras
= extras
;
195 public long getTimestamp() {
199 public String
getSender() {
203 public byte[] getGroupId() {
207 public String
getMessage() {
211 public Map
<String
, Variant
<?
>> getExtras() {
216 class MessageReceived
extends DBusSignal
{
218 private final long timestamp
;
219 private final String sender
;
220 private final byte[] groupId
;
221 private final String message
;
222 private final List
<String
> attachments
;
224 public MessageReceived(
230 List
<String
> attachments
231 ) throws DBusException
{
232 super(objectpath
, timestamp
, sender
, groupId
, message
, attachments
);
233 this.timestamp
= timestamp
;
234 this.sender
= sender
;
235 this.groupId
= groupId
;
236 this.message
= message
;
237 this.attachments
= attachments
;
240 public long getTimestamp() {
244 public String
getSender() {
248 public byte[] getGroupId() {
252 public String
getMessage() {
256 public List
<String
> getAttachments() {
261 class ReceiptReceived
extends DBusSignal
{
263 private final long timestamp
;
264 private final String sender
;
266 public ReceiptReceived(String objectpath
, long timestamp
, String sender
) throws DBusException
{
267 super(objectpath
, timestamp
, sender
);
268 this.timestamp
= timestamp
;
269 this.sender
= sender
;
272 public long getTimestamp() {
276 public String
getSender() {
281 class ReceiptReceivedV2
extends DBusSignal
{
283 private final long timestamp
;
284 private final String sender
;
285 private final String type
;
286 private final Map
<String
, Variant
<?
>> extras
;
288 public ReceiptReceivedV2(
293 final Map
<String
, Variant
<?
>> extras
294 ) throws DBusException
{
295 super(objectpath
, timestamp
, sender
, type
, extras
);
296 this.timestamp
= timestamp
;
297 this.sender
= sender
;
299 this.extras
= extras
;
302 public long getTimestamp() {
306 public String
getSender() {
310 public String
getReceiptType() {
314 public Map
<String
, Variant
<?
>> getExtras() {
319 class SyncMessageReceived
extends DBusSignal
{
321 private final long timestamp
;
322 private final String source
;
323 private final String destination
;
324 private final byte[] groupId
;
325 private final String message
;
326 private final List
<String
> attachments
;
328 public SyncMessageReceived(
335 List
<String
> attachments
336 ) throws DBusException
{
337 super(objectpath
, timestamp
, source
, destination
, groupId
, message
, attachments
);
338 this.timestamp
= timestamp
;
339 this.source
= source
;
340 this.destination
= destination
;
341 this.groupId
= groupId
;
342 this.message
= message
;
343 this.attachments
= attachments
;
346 public long getTimestamp() {
350 public String
getSource() {
354 public String
getDestination() {
358 public byte[] getGroupId() {
362 public String
getMessage() {
366 public List
<String
> getAttachments() {
371 class SyncMessageReceivedV2
extends DBusSignal
{
373 private final long timestamp
;
374 private final String source
;
375 private final String destination
;
376 private final byte[] groupId
;
377 private final String message
;
378 private final Map
<String
, Variant
<?
>> extras
;
380 public SyncMessageReceivedV2(
387 final Map
<String
, Variant
<?
>> extras
388 ) throws DBusException
{
389 super(objectpath
, timestamp
, source
, destination
, groupId
, message
, extras
);
390 this.timestamp
= timestamp
;
391 this.source
= source
;
392 this.destination
= destination
;
393 this.groupId
= groupId
;
394 this.message
= message
;
395 this.extras
= extras
;
398 public long getTimestamp() {
402 public String
getSource() {
406 public String
getDestination() {
410 public byte[] getGroupId() {
414 public String
getMessage() {
418 public Map
<String
, Variant
<?
>> getExtras() {
423 class StructDevice
extends Struct
{
434 public StructDevice(final DBusPath objectPath
, final Long id
, final String name
) {
435 this.objectPath
= objectPath
;
440 public DBusPath
getObjectPath() {
444 public Long
getId() {
448 public String
getName() {
453 @DBusProperty(name
= "Id", type
= Long
.class, access
= DBusProperty
.Access
.READ
)
454 @DBusProperty(name
= "Name", type
= String
.class)
455 @DBusProperty(name
= "Created", type
= String
.class, access
= DBusProperty
.Access
.READ
)
456 @DBusProperty(name
= "LastSeen", type
= String
.class, access
= DBusProperty
.Access
.READ
)
457 interface Device
extends DBusInterface
, Properties
{
459 void removeDevice() throws Error
.Failure
;
462 class StructGroup
extends Struct
{
473 public StructGroup(final DBusPath objectPath
, final byte[] id
, final String name
) {
474 this.objectPath
= objectPath
;
479 public DBusPath
getObjectPath() {
483 public byte[] getId() {
487 public String
getName() {
492 @DBusProperty(name
= "Id", type
= Byte
[].class, access
= DBusProperty
.Access
.READ
)
493 @DBusProperty(name
= "Name", type
= String
.class)
494 @DBusProperty(name
= "Description", type
= String
.class)
495 @DBusProperty(name
= "Avatar", type
= String
.class, access
= DBusProperty
.Access
.WRITE
)
496 @DBusProperty(name
= "IsBlocked", type
= Boolean
.class)
497 @DBusProperty(name
= "IsMember", type
= Boolean
.class, access
= DBusProperty
.Access
.READ
)
498 @DBusProperty(name
= "IsAdmin", type
= Boolean
.class, access
= DBusProperty
.Access
.READ
)
499 @DBusProperty(name
= "MessageExpirationTimer", type
= Integer
.class)
500 @DBusProperty(name
= "Members", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
501 @DBusProperty(name
= "PendingMembers", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
502 @DBusProperty(name
= "RequestingMembers", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
503 @DBusProperty(name
= "Admins", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
504 @DBusProperty(name
= "PermissionAddMember", type
= String
.class)
505 @DBusProperty(name
= "PermissionEditDetails", type
= String
.class)
506 @DBusProperty(name
= "PermissionSendMessage", type
= String
.class)
507 @DBusProperty(name
= "GroupInviteLink", type
= String
.class, access
= DBusProperty
.Access
.READ
)
508 interface Group
extends DBusInterface
, Properties
{
510 void quitGroup() throws Error
.Failure
, Error
.LastGroupAdmin
;
512 void addMembers(List
<String
> recipients
) throws Error
.Failure
;
514 void removeMembers(List
<String
> recipients
) throws Error
.Failure
;
516 void addAdmins(List
<String
> recipients
) throws Error
.Failure
;
518 void removeAdmins(List
<String
> recipients
) throws Error
.Failure
;
520 void resetLink() throws Error
.Failure
;
522 void disableLink() throws Error
.Failure
;
524 void enableLink(boolean requiresApproval
) throws Error
.Failure
;
529 class AttachmentInvalid
extends DBusExecutionException
{
531 public AttachmentInvalid(final String message
) {
532 super("Invalid attachment: " + message
);
536 class InvalidUri
extends DBusExecutionException
{
538 public InvalidUri(final String message
) {
539 super("Invalid uri: " + message
);
543 class Failure
extends DBusExecutionException
{
545 public Failure(final Exception e
) {
546 super("Failure: " + e
.getMessage() + " (" + e
.getClass().getSimpleName() + ")");
549 public Failure(final String message
) {
550 super("Failure: " + message
);
554 class DeviceNotFound
extends DBusExecutionException
{
556 public DeviceNotFound(final String message
) {
557 super("Device not found: " + message
);
561 class GroupNotFound
extends DBusExecutionException
{
563 public GroupNotFound(final String message
) {
564 super("Group not found: " + message
);
568 class InvalidGroupId
extends DBusExecutionException
{
570 public InvalidGroupId(final String message
) {
571 super("Invalid group id: " + message
);
575 class LastGroupAdmin
extends DBusExecutionException
{
577 public LastGroupAdmin(final String message
) {
578 super("Last group admin: " + message
);
582 class InvalidNumber
extends DBusExecutionException
{
584 public InvalidNumber(final String message
) {
585 super("Invalid number: " + message
);
589 class UntrustedIdentity
extends DBusExecutionException
{
591 public UntrustedIdentity(final String message
) {
592 super("Untrusted identity: " + message
);