]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/Signal.java
c65d75c0b5aa1795069c52c70a32f75dbb75cdcd
[signal-cli] / src / main / java / org / asamk / Signal.java
1 package org.asamk;
2
3 import org.freedesktop.dbus.DBusPath;
4 import org.freedesktop.dbus.Struct;
5 import org.freedesktop.dbus.annotations.DBusProperty;
6 import org.freedesktop.dbus.annotations.Position;
7 import org.freedesktop.dbus.exceptions.DBusException;
8 import org.freedesktop.dbus.exceptions.DBusExecutionException;
9 import org.freedesktop.dbus.interfaces.DBusInterface;
10 import org.freedesktop.dbus.interfaces.Properties;
11 import org.freedesktop.dbus.messages.DBusSignal;
12 import org.freedesktop.dbus.types.Variant;
13
14 import java.util.List;
15 import java.util.Map;
16
17 /**
18 * DBus interface for the org.asamk.Signal service.
19 * Including emitted Signals and returned Errors.
20 */
21 public interface Signal extends DBusInterface {
22
23 String getSelfNumber();
24
25 void subscribeReceive();
26
27 void unsubscribeReceive();
28
29 long sendMessage(
30 String message, List<String> attachments, String recipient
31 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
32
33 long sendMessage(
34 String message, List<String> attachments, List<String> recipients
35 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
36
37 void sendTyping(
38 String recipient, boolean stop
39 ) throws Error.Failure, Error.UntrustedIdentity;
40
41 void sendReadReceipt(
42 String recipient, List<Long> messageIds
43 ) throws Error.Failure, Error.UntrustedIdentity;
44
45 void sendViewedReceipt(
46 String recipient, List<Long> messageIds
47 ) throws Error.Failure, Error.UntrustedIdentity;
48
49 long sendRemoteDeleteMessage(
50 long targetSentTimestamp, String recipient
51 ) throws Error.Failure, Error.InvalidNumber;
52
53 long sendRemoteDeleteMessage(
54 long targetSentTimestamp, List<String> recipients
55 ) throws Error.Failure, Error.InvalidNumber;
56
57 long sendMessageReaction(
58 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, String recipient
59 ) throws Error.InvalidNumber, Error.Failure;
60
61 long sendMessageReaction(
62 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
63 ) throws Error.InvalidNumber, Error.Failure;
64
65 long sendPaymentNotification(byte[] receipt, String note, String recipient) throws Error.Failure;
66
67 void sendContacts() throws Error.Failure;
68
69 void sendSyncRequest() throws Error.Failure;
70
71 long sendNoteToSelfMessage(
72 String message, List<String> attachments
73 ) throws Error.AttachmentInvalid, Error.Failure;
74
75 void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
76
77 void deleteRecipient(final String recipient) throws Error.Failure;
78
79 void deleteContact(final String recipient) throws Error.Failure;
80
81 long sendGroupMessage(
82 String message, List<String> attachments, byte[] groupId
83 ) throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId;
84
85 void sendGroupTyping(
86 final byte[] groupId, final boolean stop
87 ) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
88
89 long sendGroupRemoteDeleteMessage(
90 long targetSentTimestamp, byte[] groupId
91 ) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
92
93 long sendGroupMessageReaction(
94 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, byte[] groupId
95 ) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
96
97 String getContactName(String number) throws Error.InvalidNumber;
98
99 void setContactName(String number, String name) throws Error.InvalidNumber;
100
101 void setExpirationTimer(final String number, final int expiration) throws Error.Failure;
102
103 void setContactBlocked(String number, boolean blocked) throws Error.InvalidNumber;
104
105 @Deprecated
106 void setGroupBlocked(byte[] groupId, boolean blocked) throws Error.GroupNotFound, Error.InvalidGroupId;
107
108 @Deprecated
109 List<byte[]> getGroupIds();
110
111 DBusPath getGroup(byte[] groupId);
112
113 List<StructGroup> listGroups();
114
115 @Deprecated
116 String getGroupName(byte[] groupId) throws Error.InvalidGroupId;
117
118 @Deprecated
119 List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
120
121 byte[] createGroup(
122 String name, List<String> members, String avatar
123 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber;
124
125 @Deprecated
126 byte[] updateGroup(
127 byte[] groupId, String name, List<String> members, String avatar
128 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
129
130 @Deprecated
131 boolean isRegistered() throws Error.Failure, Error.InvalidNumber;
132
133 boolean isRegistered(String number) throws Error.Failure, Error.InvalidNumber;
134
135 List<Boolean> isRegistered(List<String> numbers) throws Error.Failure, Error.InvalidNumber;
136
137 void addDevice(String uri) throws Error.InvalidUri;
138
139 DBusPath getDevice(long deviceId);
140
141 List<StructDevice> listDevices() throws Error.Failure;
142
143 DBusPath getThisDevice();
144
145 void updateProfile(
146 String givenName,
147 String familyName,
148 String about,
149 String aboutEmoji,
150 String avatarPath,
151 boolean removeAvatar
152 ) throws Error.Failure;
153
154 void updateProfile(
155 String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
156 ) throws Error.Failure;
157
158 void removePin();
159
160 void setPin(String registrationLockPin);
161
162 String version();
163
164 List<String> listNumbers();
165
166 List<String> getContactNumber(final String name) throws Error.Failure;
167
168 @Deprecated
169 void quitGroup(final byte[] groupId) throws Error.GroupNotFound, Error.Failure, Error.InvalidGroupId;
170
171 boolean isContactBlocked(final String number) throws Error.InvalidNumber;
172
173 @Deprecated
174 boolean isGroupBlocked(final byte[] groupId) throws Error.InvalidGroupId;
175
176 @Deprecated
177 boolean isMember(final byte[] groupId) throws Error.InvalidGroupId;
178
179 byte[] joinGroup(final String groupLink) throws Error.Failure;
180
181 String uploadStickerPack(String stickerPackPath) throws Error.Failure;
182
183 void submitRateLimitChallenge(String challenge, String captchaString) throws Error.Failure;
184
185 void unregister() throws Error.Failure;
186
187 void deleteAccount() throws Error.Failure;
188
189 class MessageReceivedV2 extends DBusSignal {
190
191 private final long timestamp;
192 private final String sender;
193 private final byte[] groupId;
194 private final String message;
195 private final Map<String, Variant<?>> extras;
196
197 public MessageReceivedV2(
198 String objectpath,
199 long timestamp,
200 String sender,
201 byte[] groupId,
202 String message,
203 final Map<String, Variant<?>> extras
204 ) throws DBusException {
205 super(objectpath, timestamp, sender, groupId, message, extras);
206 this.timestamp = timestamp;
207 this.sender = sender;
208 this.groupId = groupId;
209 this.message = message;
210 this.extras = extras;
211 }
212
213 public long getTimestamp() {
214 return timestamp;
215 }
216
217 public String getSender() {
218 return sender;
219 }
220
221 public byte[] getGroupId() {
222 return groupId;
223 }
224
225 public String getMessage() {
226 return message;
227 }
228
229 public Map<String, Variant<?>> getExtras() {
230 return extras;
231 }
232 }
233
234 class MessageReceived extends DBusSignal {
235
236 private final long timestamp;
237 private final String sender;
238 private final byte[] groupId;
239 private final String message;
240 private final List<String> attachments;
241
242 public MessageReceived(
243 String objectpath,
244 long timestamp,
245 String sender,
246 byte[] groupId,
247 String message,
248 List<String> attachments
249 ) throws DBusException {
250 super(objectpath, timestamp, sender, groupId, message, attachments);
251 this.timestamp = timestamp;
252 this.sender = sender;
253 this.groupId = groupId;
254 this.message = message;
255 this.attachments = attachments;
256 }
257
258 public long getTimestamp() {
259 return timestamp;
260 }
261
262 public String getSender() {
263 return sender;
264 }
265
266 public byte[] getGroupId() {
267 return groupId;
268 }
269
270 public String getMessage() {
271 return message;
272 }
273
274 public List<String> getAttachments() {
275 return attachments;
276 }
277 }
278
279 class ReceiptReceived extends DBusSignal {
280
281 private final long timestamp;
282 private final String sender;
283
284 public ReceiptReceived(String objectpath, long timestamp, String sender) throws DBusException {
285 super(objectpath, timestamp, sender);
286 this.timestamp = timestamp;
287 this.sender = sender;
288 }
289
290 public long getTimestamp() {
291 return timestamp;
292 }
293
294 public String getSender() {
295 return sender;
296 }
297 }
298
299 class ReceiptReceivedV2 extends DBusSignal {
300
301 private final long timestamp;
302 private final String sender;
303 private final String type;
304 private final Map<String, Variant<?>> extras;
305
306 public ReceiptReceivedV2(
307 String objectpath,
308 long timestamp,
309 String sender,
310 final String type,
311 final Map<String, Variant<?>> extras
312 ) throws DBusException {
313 super(objectpath, timestamp, sender, type, extras);
314 this.timestamp = timestamp;
315 this.sender = sender;
316 this.type = type;
317 this.extras = extras;
318 }
319
320 public long getTimestamp() {
321 return timestamp;
322 }
323
324 public String getSender() {
325 return sender;
326 }
327
328 public String getReceiptType() {
329 return type;
330 }
331
332 public Map<String, Variant<?>> getExtras() {
333 return extras;
334 }
335 }
336
337 class SyncMessageReceived extends DBusSignal {
338
339 private final long timestamp;
340 private final String source;
341 private final String destination;
342 private final byte[] groupId;
343 private final String message;
344 private final List<String> attachments;
345
346 public SyncMessageReceived(
347 String objectpath,
348 long timestamp,
349 String source,
350 String destination,
351 byte[] groupId,
352 String message,
353 List<String> attachments
354 ) throws DBusException {
355 super(objectpath, timestamp, source, destination, groupId, message, attachments);
356 this.timestamp = timestamp;
357 this.source = source;
358 this.destination = destination;
359 this.groupId = groupId;
360 this.message = message;
361 this.attachments = attachments;
362 }
363
364 public long getTimestamp() {
365 return timestamp;
366 }
367
368 public String getSource() {
369 return source;
370 }
371
372 public String getDestination() {
373 return destination;
374 }
375
376 public byte[] getGroupId() {
377 return groupId;
378 }
379
380 public String getMessage() {
381 return message;
382 }
383
384 public List<String> getAttachments() {
385 return attachments;
386 }
387 }
388
389 class SyncMessageReceivedV2 extends DBusSignal {
390
391 private final long timestamp;
392 private final String source;
393 private final String destination;
394 private final byte[] groupId;
395 private final String message;
396 private final Map<String, Variant<?>> extras;
397
398 public SyncMessageReceivedV2(
399 String objectpath,
400 long timestamp,
401 String source,
402 String destination,
403 byte[] groupId,
404 String message,
405 final Map<String, Variant<?>> extras
406 ) throws DBusException {
407 super(objectpath, timestamp, source, destination, groupId, message, extras);
408 this.timestamp = timestamp;
409 this.source = source;
410 this.destination = destination;
411 this.groupId = groupId;
412 this.message = message;
413 this.extras = extras;
414 }
415
416 public long getTimestamp() {
417 return timestamp;
418 }
419
420 public String getSource() {
421 return source;
422 }
423
424 public String getDestination() {
425 return destination;
426 }
427
428 public byte[] getGroupId() {
429 return groupId;
430 }
431
432 public String getMessage() {
433 return message;
434 }
435
436 public Map<String, Variant<?>> getExtras() {
437 return extras;
438 }
439 }
440
441 class StructDevice extends Struct {
442
443 @Position(0)
444 DBusPath objectPath;
445
446 @Position(1)
447 Long id;
448
449 @Position(2)
450 String name;
451
452 public StructDevice(final DBusPath objectPath, final Long id, final String name) {
453 this.objectPath = objectPath;
454 this.id = id;
455 this.name = name;
456 }
457
458 public DBusPath getObjectPath() {
459 return objectPath;
460 }
461
462 public Long getId() {
463 return id;
464 }
465
466 public String getName() {
467 return name;
468 }
469 }
470
471 @DBusProperty(name = "Id", type = Integer.class, access = DBusProperty.Access.READ)
472 @DBusProperty(name = "Name", type = String.class)
473 @DBusProperty(name = "Created", type = String.class, access = DBusProperty.Access.READ)
474 @DBusProperty(name = "LastSeen", type = String.class, access = DBusProperty.Access.READ)
475 interface Device extends DBusInterface, Properties {
476
477 void removeDevice() throws Error.Failure;
478 }
479
480 @DBusProperty(name = "ReadReceipts", type = Boolean.class)
481 @DBusProperty(name = "UnidentifiedDeliveryIndicators", type = Boolean.class)
482 @DBusProperty(name = "TypingIndicators", type = Boolean.class)
483 @DBusProperty(name = "LinkPreviews", type = Boolean.class)
484 interface Configuration extends DBusInterface, Properties {}
485
486 class StructGroup extends Struct {
487
488 @Position(0)
489 DBusPath objectPath;
490
491 @Position(1)
492 byte[] id;
493
494 @Position(2)
495 String name;
496
497 public StructGroup(final DBusPath objectPath, final byte[] id, final String name) {
498 this.objectPath = objectPath;
499 this.id = id;
500 this.name = name;
501 }
502
503 public DBusPath getObjectPath() {
504 return objectPath;
505 }
506
507 public byte[] getId() {
508 return id;
509 }
510
511 public String getName() {
512 return name;
513 }
514 }
515
516 @DBusProperty(name = "Id", type = Byte[].class, access = DBusProperty.Access.READ)
517 @DBusProperty(name = "Name", type = String.class)
518 @DBusProperty(name = "Description", type = String.class)
519 @DBusProperty(name = "Avatar", type = String.class, access = DBusProperty.Access.WRITE)
520 @DBusProperty(name = "IsBlocked", type = Boolean.class)
521 @DBusProperty(name = "IsMember", type = Boolean.class, access = DBusProperty.Access.READ)
522 @DBusProperty(name = "IsAdmin", type = Boolean.class, access = DBusProperty.Access.READ)
523 @DBusProperty(name = "MessageExpirationTimer", type = Integer.class)
524 @DBusProperty(name = "Members", type = String[].class, access = DBusProperty.Access.READ)
525 @DBusProperty(name = "PendingMembers", type = String[].class, access = DBusProperty.Access.READ)
526 @DBusProperty(name = "RequestingMembers", type = String[].class, access = DBusProperty.Access.READ)
527 @DBusProperty(name = "Admins", type = String[].class, access = DBusProperty.Access.READ)
528 @DBusProperty(name = "Banned", type = String[].class, access = DBusProperty.Access.READ)
529 @DBusProperty(name = "PermissionAddMember", type = String.class)
530 @DBusProperty(name = "PermissionEditDetails", type = String.class)
531 @DBusProperty(name = "PermissionSendMessage", type = String.class)
532 @DBusProperty(name = "GroupInviteLink", type = String.class, access = DBusProperty.Access.READ)
533 interface Group extends DBusInterface, Properties {
534
535 void quitGroup() throws Error.Failure, Error.LastGroupAdmin;
536
537 void deleteGroup() throws Error.Failure;
538
539 void addMembers(List<String> recipients) throws Error.Failure;
540
541 void removeMembers(List<String> recipients) throws Error.Failure;
542
543 void addAdmins(List<String> recipients) throws Error.Failure;
544
545 void removeAdmins(List<String> recipients) throws Error.Failure;
546
547 void resetLink() throws Error.Failure;
548
549 void disableLink() throws Error.Failure;
550
551 void enableLink(boolean requiresApproval) throws Error.Failure;
552 }
553
554 interface Error {
555
556 class AttachmentInvalid extends DBusExecutionException {
557
558 public AttachmentInvalid(final String message) {
559 super("Invalid attachment: " + message);
560 }
561 }
562
563 class InvalidUri extends DBusExecutionException {
564
565 public InvalidUri(final String message) {
566 super("Invalid uri: " + message);
567 }
568 }
569
570 class Failure extends DBusExecutionException {
571
572 public Failure(final Exception e) {
573 super("Failure: " + e.getMessage() + " (" + e.getClass().getSimpleName() + ")");
574 }
575
576 public Failure(final String message) {
577 super("Failure: " + message);
578 }
579 }
580
581 class DeviceNotFound extends DBusExecutionException {
582
583 public DeviceNotFound(final String message) {
584 super("Device not found: " + message);
585 }
586 }
587
588 class GroupNotFound extends DBusExecutionException {
589
590 public GroupNotFound(final String message) {
591 super("Group not found: " + message);
592 }
593 }
594
595 class InvalidGroupId extends DBusExecutionException {
596
597 public InvalidGroupId(final String message) {
598 super("Invalid group id: " + message);
599 }
600 }
601
602 class LastGroupAdmin extends DBusExecutionException {
603
604 public LastGroupAdmin(final String message) {
605 super("Last group admin: " + message);
606 }
607 }
608
609 class InvalidNumber extends DBusExecutionException {
610
611 public InvalidNumber(final String message) {
612 super("Invalid number: " + message);
613 }
614 }
615
616 class UntrustedIdentity extends DBusExecutionException {
617
618 public UntrustedIdentity(final String message) {
619 super("Untrusted identity: " + message);
620 }
621 }
622
623 class UnregisteredRecipient extends DBusExecutionException {
624
625 public UnregisteredRecipient(final String message) {
626 super("Unregistered recipient: " + message);
627 }
628 }
629 }
630 }