]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/Signal.java
Update libsignal-service
[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 DBusPath getIdentity(String number);
142
143 List<StructIdentity> listIdentities();
144
145 List<StructDevice> listDevices() throws Error.Failure;
146
147 DBusPath getThisDevice();
148
149 void updateProfile(
150 String givenName,
151 String familyName,
152 String about,
153 String aboutEmoji,
154 String avatarPath,
155 boolean removeAvatar
156 ) throws Error.Failure;
157
158 void updateProfile(
159 String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
160 ) throws Error.Failure;
161
162 void removePin();
163
164 void setPin(String registrationLockPin);
165
166 String version();
167
168 List<String> listNumbers();
169
170 List<String> getContactNumber(final String name) throws Error.Failure;
171
172 @Deprecated
173 void quitGroup(final byte[] groupId) throws Error.GroupNotFound, Error.Failure, Error.InvalidGroupId;
174
175 boolean isContactBlocked(final String number) throws Error.InvalidNumber;
176
177 @Deprecated
178 boolean isGroupBlocked(final byte[] groupId) throws Error.InvalidGroupId;
179
180 @Deprecated
181 boolean isMember(final byte[] groupId) throws Error.InvalidGroupId;
182
183 byte[] joinGroup(final String groupLink) throws Error.Failure;
184
185 String uploadStickerPack(String stickerPackPath) throws Error.Failure;
186
187 void submitRateLimitChallenge(String challenge, String captchaString) throws Error.Failure;
188
189 void unregister() throws Error.Failure;
190
191 void deleteAccount() throws Error.Failure;
192
193 class MessageReceivedV2 extends DBusSignal {
194
195 private final long timestamp;
196 private final String sender;
197 private final byte[] groupId;
198 private final String message;
199 private final Map<String, Variant<?>> extras;
200
201 public MessageReceivedV2(
202 String objectpath,
203 long timestamp,
204 String sender,
205 byte[] groupId,
206 String message,
207 final Map<String, Variant<?>> extras
208 ) throws DBusException {
209 super(objectpath, timestamp, sender, groupId, message, extras);
210 this.timestamp = timestamp;
211 this.sender = sender;
212 this.groupId = groupId;
213 this.message = message;
214 this.extras = extras;
215 }
216
217 public long getTimestamp() {
218 return timestamp;
219 }
220
221 public String getSender() {
222 return sender;
223 }
224
225 public byte[] getGroupId() {
226 return groupId;
227 }
228
229 public String getMessage() {
230 return message;
231 }
232
233 public Map<String, Variant<?>> getExtras() {
234 return extras;
235 }
236 }
237
238 class EditMessageReceived extends DBusSignal {
239
240 private final long timestamp;
241 private final long targetSentTimestamp;
242 private final String sender;
243 private final byte[] groupId;
244 private final String message;
245 private final Map<String, Variant<?>> extras;
246
247 public EditMessageReceived(
248 String objectpath,
249 long timestamp,
250 final long targetSentTimestamp,
251 String sender,
252 byte[] groupId,
253 String message,
254 final Map<String, Variant<?>> extras
255 ) throws DBusException {
256 super(objectpath, timestamp, targetSentTimestamp, sender, groupId, message, extras);
257 this.timestamp = timestamp;
258 this.targetSentTimestamp = targetSentTimestamp;
259 this.sender = sender;
260 this.groupId = groupId;
261 this.message = message;
262 this.extras = extras;
263 }
264
265 public long getTimestamp() {
266 return timestamp;
267 }
268
269 public long getTargetSentTimestamp() {
270 return targetSentTimestamp;
271 }
272
273 public String getSender() {
274 return sender;
275 }
276
277 public byte[] getGroupId() {
278 return groupId;
279 }
280
281 public String getMessage() {
282 return message;
283 }
284
285 public Map<String, Variant<?>> getExtras() {
286 return extras;
287 }
288 }
289
290 class MessageReceived extends DBusSignal {
291
292 private final long timestamp;
293 private final String sender;
294 private final byte[] groupId;
295 private final String message;
296 private final List<String> attachments;
297
298 public MessageReceived(
299 String objectpath,
300 long timestamp,
301 String sender,
302 byte[] groupId,
303 String message,
304 List<String> attachments
305 ) throws DBusException {
306 super(objectpath, timestamp, sender, groupId, message, attachments);
307 this.timestamp = timestamp;
308 this.sender = sender;
309 this.groupId = groupId;
310 this.message = message;
311 this.attachments = attachments;
312 }
313
314 public long getTimestamp() {
315 return timestamp;
316 }
317
318 public String getSender() {
319 return sender;
320 }
321
322 public byte[] getGroupId() {
323 return groupId;
324 }
325
326 public String getMessage() {
327 return message;
328 }
329
330 public List<String> getAttachments() {
331 return attachments;
332 }
333 }
334
335 class ReceiptReceived extends DBusSignal {
336
337 private final long timestamp;
338 private final String sender;
339
340 public ReceiptReceived(String objectpath, long timestamp, String sender) throws DBusException {
341 super(objectpath, timestamp, sender);
342 this.timestamp = timestamp;
343 this.sender = sender;
344 }
345
346 public long getTimestamp() {
347 return timestamp;
348 }
349
350 public String getSender() {
351 return sender;
352 }
353 }
354
355 class ReceiptReceivedV2 extends DBusSignal {
356
357 private final long timestamp;
358 private final String sender;
359 private final String type;
360 private final Map<String, Variant<?>> extras;
361
362 public ReceiptReceivedV2(
363 String objectpath,
364 long timestamp,
365 String sender,
366 final String type,
367 final Map<String, Variant<?>> extras
368 ) throws DBusException {
369 super(objectpath, timestamp, sender, type, extras);
370 this.timestamp = timestamp;
371 this.sender = sender;
372 this.type = type;
373 this.extras = extras;
374 }
375
376 public long getTimestamp() {
377 return timestamp;
378 }
379
380 public String getSender() {
381 return sender;
382 }
383
384 public String getReceiptType() {
385 return type;
386 }
387
388 public Map<String, Variant<?>> getExtras() {
389 return extras;
390 }
391 }
392
393 class SyncMessageReceived extends DBusSignal {
394
395 private final long timestamp;
396 private final String source;
397 private final String destination;
398 private final byte[] groupId;
399 private final String message;
400 private final List<String> attachments;
401
402 public SyncMessageReceived(
403 String objectpath,
404 long timestamp,
405 String source,
406 String destination,
407 byte[] groupId,
408 String message,
409 List<String> attachments
410 ) throws DBusException {
411 super(objectpath, timestamp, source, destination, groupId, message, attachments);
412 this.timestamp = timestamp;
413 this.source = source;
414 this.destination = destination;
415 this.groupId = groupId;
416 this.message = message;
417 this.attachments = attachments;
418 }
419
420 public long getTimestamp() {
421 return timestamp;
422 }
423
424 public String getSource() {
425 return source;
426 }
427
428 public String getDestination() {
429 return destination;
430 }
431
432 public byte[] getGroupId() {
433 return groupId;
434 }
435
436 public String getMessage() {
437 return message;
438 }
439
440 public List<String> getAttachments() {
441 return attachments;
442 }
443 }
444
445 class SyncMessageReceivedV2 extends DBusSignal {
446
447 private final long timestamp;
448 private final String source;
449 private final String destination;
450 private final byte[] groupId;
451 private final String message;
452 private final Map<String, Variant<?>> extras;
453
454 public SyncMessageReceivedV2(
455 String objectpath,
456 long timestamp,
457 String source,
458 String destination,
459 byte[] groupId,
460 String message,
461 final Map<String, Variant<?>> extras
462 ) throws DBusException {
463 super(objectpath, timestamp, source, destination, groupId, message, extras);
464 this.timestamp = timestamp;
465 this.source = source;
466 this.destination = destination;
467 this.groupId = groupId;
468 this.message = message;
469 this.extras = extras;
470 }
471
472 public long getTimestamp() {
473 return timestamp;
474 }
475
476 public String getSource() {
477 return source;
478 }
479
480 public String getDestination() {
481 return destination;
482 }
483
484 public byte[] getGroupId() {
485 return groupId;
486 }
487
488 public String getMessage() {
489 return message;
490 }
491
492 public Map<String, Variant<?>> getExtras() {
493 return extras;
494 }
495 }
496
497 class StructDevice extends Struct {
498
499 @Position(0)
500 final DBusPath objectPath;
501
502 @Position(1)
503 final Long id;
504
505 @Position(2)
506 final String name;
507
508 public StructDevice(final DBusPath objectPath, final Long id, final String name) {
509 this.objectPath = objectPath;
510 this.id = id;
511 this.name = name;
512 }
513
514 public DBusPath getObjectPath() {
515 return objectPath;
516 }
517
518 public Long getId() {
519 return id;
520 }
521
522 public String getName() {
523 return name;
524 }
525 }
526
527 @DBusProperty(name = "Id", type = Integer.class, access = DBusProperty.Access.READ)
528 @DBusProperty(name = "Name", type = String.class)
529 @DBusProperty(name = "Created", type = String.class, access = DBusProperty.Access.READ)
530 @DBusProperty(name = "LastSeen", type = String.class, access = DBusProperty.Access.READ)
531 interface Device extends DBusInterface, Properties {
532
533 void removeDevice() throws Error.Failure;
534 }
535
536 @DBusProperty(name = "ReadReceipts", type = Boolean.class)
537 @DBusProperty(name = "UnidentifiedDeliveryIndicators", type = Boolean.class)
538 @DBusProperty(name = "TypingIndicators", type = Boolean.class)
539 @DBusProperty(name = "LinkPreviews", type = Boolean.class)
540 interface Configuration extends DBusInterface, Properties {}
541
542 class StructGroup extends Struct {
543
544 @Position(0)
545 final DBusPath objectPath;
546
547 @Position(1)
548 final byte[] id;
549
550 @Position(2)
551 final String name;
552
553 public StructGroup(final DBusPath objectPath, final byte[] id, final String name) {
554 this.objectPath = objectPath;
555 this.id = id;
556 this.name = name;
557 }
558
559 public DBusPath getObjectPath() {
560 return objectPath;
561 }
562
563 public byte[] getId() {
564 return id;
565 }
566
567 public String getName() {
568 return name;
569 }
570 }
571
572 @DBusProperty(name = "Id", type = Byte[].class, access = DBusProperty.Access.READ)
573 @DBusProperty(name = "Name", type = String.class)
574 @DBusProperty(name = "Description", type = String.class)
575 @DBusProperty(name = "Avatar", type = String.class, access = DBusProperty.Access.WRITE)
576 @DBusProperty(name = "IsBlocked", type = Boolean.class)
577 @DBusProperty(name = "IsMember", type = Boolean.class, access = DBusProperty.Access.READ)
578 @DBusProperty(name = "IsAdmin", type = Boolean.class, access = DBusProperty.Access.READ)
579 @DBusProperty(name = "MessageExpirationTimer", type = Integer.class)
580 @DBusProperty(name = "Members", type = String[].class, access = DBusProperty.Access.READ)
581 @DBusProperty(name = "PendingMembers", type = String[].class, access = DBusProperty.Access.READ)
582 @DBusProperty(name = "RequestingMembers", type = String[].class, access = DBusProperty.Access.READ)
583 @DBusProperty(name = "Admins", type = String[].class, access = DBusProperty.Access.READ)
584 @DBusProperty(name = "Banned", type = String[].class, access = DBusProperty.Access.READ)
585 @DBusProperty(name = "PermissionAddMember", type = String.class)
586 @DBusProperty(name = "PermissionEditDetails", type = String.class)
587 @DBusProperty(name = "PermissionSendMessage", type = String.class)
588 @DBusProperty(name = "GroupInviteLink", type = String.class, access = DBusProperty.Access.READ)
589 interface Group extends DBusInterface, Properties {
590
591 void quitGroup() throws Error.Failure, Error.LastGroupAdmin;
592
593 void deleteGroup() throws Error.Failure;
594
595 void addMembers(List<String> recipients) throws Error.Failure;
596
597 void removeMembers(List<String> recipients) throws Error.Failure;
598
599 void addAdmins(List<String> recipients) throws Error.Failure;
600
601 void removeAdmins(List<String> recipients) throws Error.Failure;
602
603 void resetLink() throws Error.Failure;
604
605 void disableLink() throws Error.Failure;
606
607 void enableLink(boolean requiresApproval) throws Error.Failure;
608 }
609
610 class StructIdentity extends Struct {
611
612 @Position(0)
613 final DBusPath objectPath;
614
615 @Position(1)
616 final String uuid;
617
618 @Position(2)
619 final String number;
620
621 public StructIdentity(final DBusPath objectPath, final String uuid, final String number) {
622 this.objectPath = objectPath;
623 this.uuid = uuid;
624 this.number = number;
625 }
626
627 public DBusPath getObjectPath() {
628 return objectPath;
629 }
630
631 public String getUuid() {
632 return uuid;
633 }
634
635 public String getNumber() {
636 return number;
637 }
638 }
639
640 @DBusProperty(name = "Number", type = String.class, access = DBusProperty.Access.READ)
641 @DBusProperty(name = "Uuid", type = String.class, access = DBusProperty.Access.READ)
642 @DBusProperty(name = "Fingerprint", type = Byte[].class, access = DBusProperty.Access.READ)
643 @DBusProperty(name = "SafetyNumber", type = String.class, access = DBusProperty.Access.READ)
644 @DBusProperty(name = "TrustLevel", type = String.class, access = DBusProperty.Access.READ)
645 @DBusProperty(name = "AddedDate", type = Long.class, access = DBusProperty.Access.READ)
646 @DBusProperty(name = "ScannableSafetyNumber", type = Byte[].class, access = DBusProperty.Access.READ)
647 interface Identity extends DBusInterface, Properties {
648
649 void trust() throws Error.Failure;
650
651 void trustVerified(String safetyNumber) throws Error.Failure;
652 }
653
654 interface Error {
655
656 class AttachmentInvalid extends DBusExecutionException {
657
658 public AttachmentInvalid(final String message) {
659 super("Invalid attachment: " + message);
660 }
661 }
662
663 class InvalidUri extends DBusExecutionException {
664
665 public InvalidUri(final String message) {
666 super("Invalid uri: " + message);
667 }
668 }
669
670 class Failure extends DBusExecutionException {
671
672 public Failure(final Exception e) {
673 super("Failure: " + e.getMessage() + " (" + e.getClass().getSimpleName() + ")");
674 }
675
676 public Failure(final String message) {
677 super("Failure: " + message);
678 }
679 }
680
681 class DeviceNotFound extends DBusExecutionException {
682
683 public DeviceNotFound(final String message) {
684 super("Device not found: " + message);
685 }
686 }
687
688 class GroupNotFound extends DBusExecutionException {
689
690 public GroupNotFound(final String message) {
691 super("Group not found: " + message);
692 }
693 }
694
695 class NotAGroupMember extends DBusExecutionException {
696
697 public NotAGroupMember(final String message) {
698 super("Not a group member: " + message);
699 }
700 }
701
702 class InvalidGroupId extends DBusExecutionException {
703
704 public InvalidGroupId(final String message) {
705 super("Invalid group id: " + message);
706 }
707 }
708
709 class LastGroupAdmin extends DBusExecutionException {
710
711 public LastGroupAdmin(final String message) {
712 super("Last group admin: " + message);
713 }
714 }
715
716 class InvalidNumber extends DBusExecutionException {
717
718 public InvalidNumber(final String message) {
719 super("Invalid number: " + message);
720 }
721 }
722
723 class UntrustedIdentity extends DBusExecutionException {
724
725 public UntrustedIdentity(final String message) {
726 super("Untrusted identity: " + message);
727 }
728 }
729
730 class UnregisteredRecipient extends DBusExecutionException {
731
732 public UnregisteredRecipient(final String message) {
733 super("Unregistered recipient: " + message);
734 }
735 }
736 }
737 }