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