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 long sendRemoteDeleteMessage(
41 long targetSentTimestamp
, String recipient
42 ) throws Error
.Failure
, Error
.InvalidNumber
;
44 long sendRemoteDeleteMessage(
45 long targetSentTimestamp
, List
<String
> recipients
46 ) throws Error
.Failure
, Error
.InvalidNumber
;
48 long sendGroupRemoteDeleteMessage(
49 long targetSentTimestamp
, byte[] groupId
50 ) throws Error
.Failure
, Error
.GroupNotFound
, Error
.InvalidGroupId
;
52 long sendMessageReaction(
53 String emoji
, boolean remove
, String targetAuthor
, long targetSentTimestamp
, String recipient
54 ) throws Error
.InvalidNumber
, Error
.Failure
;
56 long sendMessageReaction(
57 String emoji
, boolean remove
, String targetAuthor
, long targetSentTimestamp
, List
<String
> recipients
58 ) throws Error
.InvalidNumber
, Error
.Failure
;
60 void sendContacts() throws Error
.Failure
;
62 void sendSyncRequest() throws Error
.Failure
;
64 long sendNoteToSelfMessage(
65 String message
, List
<String
> attachments
66 ) throws Error
.AttachmentInvalid
, Error
.Failure
;
68 void sendEndSessionMessage(List
<String
> recipients
) throws Error
.Failure
, Error
.InvalidNumber
, Error
.UntrustedIdentity
;
70 long sendGroupMessage(
71 String message
, List
<String
> attachments
, byte[] groupId
72 ) throws Error
.GroupNotFound
, Error
.Failure
, Error
.AttachmentInvalid
, Error
.InvalidGroupId
;
74 long sendGroupMessageReaction(
75 String emoji
, boolean remove
, String targetAuthor
, long targetSentTimestamp
, byte[] groupId
76 ) throws Error
.GroupNotFound
, Error
.Failure
, Error
.InvalidNumber
, Error
.InvalidGroupId
;
78 String
getContactName(String number
) throws Error
.InvalidNumber
;
80 void setContactName(String number
, String name
) throws Error
.InvalidNumber
;
82 void setExpirationTimer(final String number
, final int expiration
) throws Error
.Failure
;
84 void setContactBlocked(String number
, boolean blocked
) throws Error
.InvalidNumber
;
87 void setGroupBlocked(byte[] groupId
, boolean blocked
) throws Error
.GroupNotFound
, Error
.InvalidGroupId
;
90 List
<byte[]> getGroupIds();
92 DBusPath
getGroup(byte[] groupId
);
94 List
<StructGroup
> listGroups();
97 String
getGroupName(byte[] groupId
) throws Error
.InvalidGroupId
;
100 List
<String
> getGroupMembers(byte[] groupId
) throws Error
.InvalidGroupId
;
103 String name
, List
<String
> members
, String avatar
104 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.InvalidNumber
;
108 byte[] groupId
, String name
, List
<String
> members
, String avatar
109 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.InvalidNumber
, Error
.GroupNotFound
, Error
.InvalidGroupId
;
111 boolean isRegistered() throws Error
.Failure
, Error
.InvalidNumber
;
113 boolean isRegistered(String number
) throws Error
.Failure
, Error
.InvalidNumber
;
115 List
<Boolean
> isRegistered(List
<String
> numbers
) throws Error
.Failure
, Error
.InvalidNumber
;
117 void addDevice(String uri
) throws Error
.InvalidUri
;
119 DBusPath
getDevice(long deviceId
);
121 List
<StructDevice
> listDevices() throws Error
.Failure
;
123 DBusPath
getThisDevice();
132 ) throws Error
.Failure
;
135 String name
, String about
, String aboutEmoji
, String avatarPath
, boolean removeAvatar
136 ) throws Error
.Failure
;
140 void setPin(String registrationLockPin
);
144 List
<String
> listNumbers();
146 List
<String
> getContactNumber(final String name
) throws Error
.Failure
;
149 void quitGroup(final byte[] groupId
) throws Error
.GroupNotFound
, Error
.Failure
, Error
.InvalidGroupId
;
151 boolean isContactBlocked(final String number
) throws Error
.InvalidNumber
;
154 boolean isGroupBlocked(final byte[] groupId
) throws Error
.InvalidGroupId
;
157 boolean isMember(final byte[] groupId
) throws Error
.InvalidGroupId
;
159 byte[] joinGroup(final String groupLink
) throws Error
.Failure
;
161 String
uploadStickerPack(String stickerPackPath
) throws Error
.Failure
;
163 void submitRateLimitChallenge(String challenge
, String captchaString
) throws IOErrorException
;
165 class MessageReceived
extends DBusSignal
{
167 private final long timestamp
;
168 private final String sender
;
169 private final byte[] groupId
;
170 private final String message
;
171 private final List
<String
> attachments
;
173 public MessageReceived(
179 List
<String
> attachments
180 ) throws DBusException
{
181 super(objectpath
, timestamp
, sender
, groupId
, message
, attachments
);
182 this.timestamp
= timestamp
;
183 this.sender
= sender
;
184 this.groupId
= groupId
;
185 this.message
= message
;
186 this.attachments
= attachments
;
189 public long getTimestamp() {
193 public String
getSender() {
197 public byte[] getGroupId() {
201 public String
getMessage() {
205 public List
<String
> getAttachments() {
210 class ReceiptReceived
extends DBusSignal
{
212 private final long timestamp
;
213 private final String sender
;
215 public ReceiptReceived(String objectpath
, long timestamp
, String sender
) throws DBusException
{
216 super(objectpath
, timestamp
, sender
);
217 this.timestamp
= timestamp
;
218 this.sender
= sender
;
221 public long getTimestamp() {
225 public String
getSender() {
230 class SyncMessageReceived
extends DBusSignal
{
232 private final long timestamp
;
233 private final String source
;
234 private final String destination
;
235 private final byte[] groupId
;
236 private final String message
;
237 private final List
<String
> attachments
;
239 public SyncMessageReceived(
246 List
<String
> attachments
247 ) throws DBusException
{
248 super(objectpath
, timestamp
, source
, destination
, groupId
, message
, attachments
);
249 this.timestamp
= timestamp
;
250 this.source
= source
;
251 this.destination
= destination
;
252 this.groupId
= groupId
;
253 this.message
= message
;
254 this.attachments
= attachments
;
257 public long getTimestamp() {
261 public String
getSource() {
265 public String
getDestination() {
269 public byte[] getGroupId() {
273 public String
getMessage() {
277 public List
<String
> getAttachments() {
282 class StructDevice
extends Struct
{
293 public StructDevice(final DBusPath objectPath
, final Long id
, final String name
) {
294 this.objectPath
= objectPath
;
299 public DBusPath
getObjectPath() {
303 public Long
getId() {
307 public String
getName() {
312 @DBusProperty(name
= "Id", type
= Long
.class, access
= DBusProperty
.Access
.READ
)
313 @DBusProperty(name
= "Name", type
= String
.class)
314 @DBusProperty(name
= "Created", type
= String
.class, access
= DBusProperty
.Access
.READ
)
315 @DBusProperty(name
= "LastSeen", type
= String
.class, access
= DBusProperty
.Access
.READ
)
316 interface Device
extends DBusInterface
, Properties
{
318 void removeDevice() throws Error
.Failure
;
321 class StructGroup
extends Struct
{
332 public StructGroup(final DBusPath objectPath
, final byte[] id
, final String name
) {
333 this.objectPath
= objectPath
;
338 public DBusPath
getObjectPath() {
342 public byte[] getId() {
346 public String
getName() {
351 @DBusProperty(name
= "Id", type
= Byte
[].class, access
= DBusProperty
.Access
.READ
)
352 @DBusProperty(name
= "Name", type
= String
.class)
353 @DBusProperty(name
= "Description", type
= String
.class)
354 @DBusProperty(name
= "Avatar", type
= String
.class, access
= DBusProperty
.Access
.WRITE
)
355 @DBusProperty(name
= "IsBlocked", type
= Boolean
.class)
356 @DBusProperty(name
= "IsMember", type
= Boolean
.class, access
= DBusProperty
.Access
.READ
)
357 @DBusProperty(name
= "IsAdmin", type
= Boolean
.class, access
= DBusProperty
.Access
.READ
)
358 @DBusProperty(name
= "MessageExpirationTimer", type
= Integer
.class)
359 @DBusProperty(name
= "Members", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
360 @DBusProperty(name
= "PendingMembers", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
361 @DBusProperty(name
= "RequestingMembers", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
362 @DBusProperty(name
= "Admins", type
= String
[].class, access
= DBusProperty
.Access
.READ
)
363 @DBusProperty(name
= "PermissionAddMember", type
= String
.class)
364 @DBusProperty(name
= "PermissionEditDetails", type
= String
.class)
365 @DBusProperty(name
= "PermissionSendMessage", type
= String
.class)
366 @DBusProperty(name
= "GroupInviteLink", type
= String
.class, access
= DBusProperty
.Access
.READ
)
367 interface Group
extends DBusInterface
, Properties
{
369 void quitGroup() throws Error
.Failure
, Error
.LastGroupAdmin
;
371 void addMembers(List
<String
> recipients
) throws Error
.Failure
;
373 void removeMembers(List
<String
> recipients
) throws Error
.Failure
;
375 void addAdmins(List
<String
> recipients
) throws Error
.Failure
;
377 void removeAdmins(List
<String
> recipients
) throws Error
.Failure
;
379 void resetLink() throws Error
.Failure
;
381 void disableLink() throws Error
.Failure
;
383 void enableLink(boolean requiresApproval
) throws Error
.Failure
;
388 class AttachmentInvalid
extends DBusExecutionException
{
390 public AttachmentInvalid(final String message
) {
391 super("Invalid attachment: " + message
);
395 class InvalidUri
extends DBusExecutionException
{
397 public InvalidUri(final String message
) {
398 super("Invalid uri: " + message
);
402 class Failure
extends DBusExecutionException
{
404 public Failure(final Exception e
) {
405 super("Failure: " + e
.getMessage() + " (" + e
.getClass().getSimpleName() + ")");
408 public Failure(final String message
) {
409 super("Failure: " + message
);
413 class DeviceNotFound
extends DBusExecutionException
{
415 public DeviceNotFound(final String message
) {
416 super("Device not found: " + message
);
420 class GroupNotFound
extends DBusExecutionException
{
422 public GroupNotFound(final String message
) {
423 super("Group not found: " + message
);
427 class InvalidGroupId
extends DBusExecutionException
{
429 public InvalidGroupId(final String message
) {
430 super("Invalid group id: " + message
);
434 class LastGroupAdmin
extends DBusExecutionException
{
436 public LastGroupAdmin(final String message
) {
437 super("Last group admin: " + message
);
441 class InvalidNumber
extends DBusExecutionException
{
443 public InvalidNumber(final String message
) {
444 super("Invalid number: " + message
);
448 class UntrustedIdentity
extends DBusExecutionException
{
450 public UntrustedIdentity(final String message
) {
451 super("Untrusted identity: " + message
);