]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/Signal.java
2ca23dfbc808263b9845052f9fa859abdc73db33
[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 public DBusPath getIdentity(String number);
142
143 public 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 MessageReceived extends DBusSignal {
239
240 private final long timestamp;
241 private final String sender;
242 private final byte[] groupId;
243 private final String message;
244 private final List<String> attachments;
245
246 public MessageReceived(
247 String objectpath,
248 long timestamp,
249 String sender,
250 byte[] groupId,
251 String message,
252 List<String> attachments
253 ) throws DBusException {
254 super(objectpath, timestamp, sender, groupId, message, attachments);
255 this.timestamp = timestamp;
256 this.sender = sender;
257 this.groupId = groupId;
258 this.message = message;
259 this.attachments = attachments;
260 }
261
262 public long getTimestamp() {
263 return timestamp;
264 }
265
266 public String getSender() {
267 return sender;
268 }
269
270 public byte[] getGroupId() {
271 return groupId;
272 }
273
274 public String getMessage() {
275 return message;
276 }
277
278 public List<String> getAttachments() {
279 return attachments;
280 }
281 }
282
283 class ReceiptReceived extends DBusSignal {
284
285 private final long timestamp;
286 private final String sender;
287
288 public ReceiptReceived(String objectpath, long timestamp, String sender) throws DBusException {
289 super(objectpath, timestamp, sender);
290 this.timestamp = timestamp;
291 this.sender = sender;
292 }
293
294 public long getTimestamp() {
295 return timestamp;
296 }
297
298 public String getSender() {
299 return sender;
300 }
301 }
302
303 class ReceiptReceivedV2 extends DBusSignal {
304
305 private final long timestamp;
306 private final String sender;
307 private final String type;
308 private final Map<String, Variant<?>> extras;
309
310 public ReceiptReceivedV2(
311 String objectpath,
312 long timestamp,
313 String sender,
314 final String type,
315 final Map<String, Variant<?>> extras
316 ) throws DBusException {
317 super(objectpath, timestamp, sender, type, extras);
318 this.timestamp = timestamp;
319 this.sender = sender;
320 this.type = type;
321 this.extras = extras;
322 }
323
324 public long getTimestamp() {
325 return timestamp;
326 }
327
328 public String getSender() {
329 return sender;
330 }
331
332 public String getReceiptType() {
333 return type;
334 }
335
336 public Map<String, Variant<?>> getExtras() {
337 return extras;
338 }
339 }
340
341 class SyncMessageReceived extends DBusSignal {
342
343 private final long timestamp;
344 private final String source;
345 private final String destination;
346 private final byte[] groupId;
347 private final String message;
348 private final List<String> attachments;
349
350 public SyncMessageReceived(
351 String objectpath,
352 long timestamp,
353 String source,
354 String destination,
355 byte[] groupId,
356 String message,
357 List<String> attachments
358 ) throws DBusException {
359 super(objectpath, timestamp, source, destination, groupId, message, attachments);
360 this.timestamp = timestamp;
361 this.source = source;
362 this.destination = destination;
363 this.groupId = groupId;
364 this.message = message;
365 this.attachments = attachments;
366 }
367
368 public long getTimestamp() {
369 return timestamp;
370 }
371
372 public String getSource() {
373 return source;
374 }
375
376 public String getDestination() {
377 return destination;
378 }
379
380 public byte[] getGroupId() {
381 return groupId;
382 }
383
384 public String getMessage() {
385 return message;
386 }
387
388 public List<String> getAttachments() {
389 return attachments;
390 }
391 }
392
393 class SyncMessageReceivedV2 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 Map<String, Variant<?>> extras;
401
402 public SyncMessageReceivedV2(
403 String objectpath,
404 long timestamp,
405 String source,
406 String destination,
407 byte[] groupId,
408 String message,
409 final Map<String, Variant<?>> extras
410 ) throws DBusException {
411 super(objectpath, timestamp, source, destination, groupId, message, extras);
412 this.timestamp = timestamp;
413 this.source = source;
414 this.destination = destination;
415 this.groupId = groupId;
416 this.message = message;
417 this.extras = extras;
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 Map<String, Variant<?>> getExtras() {
441 return extras;
442 }
443 }
444
445 class StructDevice extends Struct {
446
447 @Position(0)
448 DBusPath objectPath;
449
450 @Position(1)
451 Long id;
452
453 @Position(2)
454 String name;
455
456 public StructDevice(final DBusPath objectPath, final Long id, final String name) {
457 this.objectPath = objectPath;
458 this.id = id;
459 this.name = name;
460 }
461
462 public DBusPath getObjectPath() {
463 return objectPath;
464 }
465
466 public Long getId() {
467 return id;
468 }
469
470 public String getName() {
471 return name;
472 }
473 }
474
475 @DBusProperty(name = "Id", type = Integer.class, access = DBusProperty.Access.READ)
476 @DBusProperty(name = "Name", type = String.class)
477 @DBusProperty(name = "Created", type = String.class, access = DBusProperty.Access.READ)
478 @DBusProperty(name = "LastSeen", type = String.class, access = DBusProperty.Access.READ)
479 interface Device extends DBusInterface, Properties {
480
481 void removeDevice() throws Error.Failure;
482 }
483
484 @DBusProperty(name = "ReadReceipts", type = Boolean.class)
485 @DBusProperty(name = "UnidentifiedDeliveryIndicators", type = Boolean.class)
486 @DBusProperty(name = "TypingIndicators", type = Boolean.class)
487 @DBusProperty(name = "LinkPreviews", type = Boolean.class)
488 interface Configuration extends DBusInterface, Properties {}
489
490 class StructGroup extends Struct {
491
492 @Position(0)
493 DBusPath objectPath;
494
495 @Position(1)
496 byte[] id;
497
498 @Position(2)
499 String name;
500
501 public StructGroup(final DBusPath objectPath, final byte[] id, final String name) {
502 this.objectPath = objectPath;
503 this.id = id;
504 this.name = name;
505 }
506
507 public DBusPath getObjectPath() {
508 return objectPath;
509 }
510
511 public byte[] getId() {
512 return id;
513 }
514
515 public String getName() {
516 return name;
517 }
518 }
519
520 @DBusProperty(name = "Id", type = Byte[].class, access = DBusProperty.Access.READ)
521 @DBusProperty(name = "Name", type = String.class)
522 @DBusProperty(name = "Description", type = String.class)
523 @DBusProperty(name = "Avatar", type = String.class, access = DBusProperty.Access.WRITE)
524 @DBusProperty(name = "IsBlocked", type = Boolean.class)
525 @DBusProperty(name = "IsMember", type = Boolean.class, access = DBusProperty.Access.READ)
526 @DBusProperty(name = "IsAdmin", type = Boolean.class, access = DBusProperty.Access.READ)
527 @DBusProperty(name = "MessageExpirationTimer", type = Integer.class)
528 @DBusProperty(name = "Members", type = String[].class, access = DBusProperty.Access.READ)
529 @DBusProperty(name = "PendingMembers", type = String[].class, access = DBusProperty.Access.READ)
530 @DBusProperty(name = "RequestingMembers", type = String[].class, access = DBusProperty.Access.READ)
531 @DBusProperty(name = "Admins", type = String[].class, access = DBusProperty.Access.READ)
532 @DBusProperty(name = "Banned", type = String[].class, access = DBusProperty.Access.READ)
533 @DBusProperty(name = "PermissionAddMember", type = String.class)
534 @DBusProperty(name = "PermissionEditDetails", type = String.class)
535 @DBusProperty(name = "PermissionSendMessage", type = String.class)
536 @DBusProperty(name = "GroupInviteLink", type = String.class, access = DBusProperty.Access.READ)
537 interface Group extends DBusInterface, Properties {
538
539 void quitGroup() throws Error.Failure, Error.LastGroupAdmin;
540
541 void deleteGroup() throws Error.Failure;
542
543 void addMembers(List<String> recipients) throws Error.Failure;
544
545 void removeMembers(List<String> recipients) throws Error.Failure;
546
547 void addAdmins(List<String> recipients) throws Error.Failure;
548
549 void removeAdmins(List<String> recipients) throws Error.Failure;
550
551 void resetLink() throws Error.Failure;
552
553 void disableLink() throws Error.Failure;
554
555 void enableLink(boolean requiresApproval) throws Error.Failure;
556 }
557
558 class StructIdentity extends Struct {
559
560 @Position(0)
561 DBusPath objectPath;
562
563 @Position(1)
564 String uuid;
565
566 @Position(2)
567 String name;
568
569 public StructIdentity(final DBusPath objectPath, final String uuid, final String name) {
570 this.objectPath = objectPath;
571 this.uuid = uuid;
572 this.name = name;
573 }
574
575 public DBusPath getObjectPath() {
576 return objectPath;
577 }
578
579 public String getUuid() {
580 return uuid;
581 }
582
583 public String getName() {
584 return name;
585 }
586 }
587
588 @DBusProperty(name = "Number", type = String.class, access = DBusProperty.Access.READ)
589 @DBusProperty(name = "Uuid", type = String.class, access = DBusProperty.Access.READ)
590 @DBusProperty(name = "Fingerprint", type = Byte[].class, access = DBusProperty.Access.READ)
591 @DBusProperty(name = "SafetyNumber", type = String.class, access = DBusProperty.Access.READ)
592 @DBusProperty(name = "TrustLevel", type = String.class, access = DBusProperty.Access.READ)
593 @DBusProperty(name = "AddedDate", type = Integer.class, access = DBusProperty.Access.READ)
594 @DBusProperty(name = "ScannableSafetyNumber", type = Byte[].class, access = DBusProperty.Access.READ)
595 interface Identity extends DBusInterface, Properties {
596
597 void trust() throws Error.Failure;
598
599 void trustVerified(String safetyNumber) throws Error.Failure;
600 }
601
602 interface Error {
603
604 class AttachmentInvalid extends DBusExecutionException {
605
606 public AttachmentInvalid(final String message) {
607 super("Invalid attachment: " + message);
608 }
609 }
610
611 class InvalidUri extends DBusExecutionException {
612
613 public InvalidUri(final String message) {
614 super("Invalid uri: " + message);
615 }
616 }
617
618 class Failure extends DBusExecutionException {
619
620 public Failure(final Exception e) {
621 super("Failure: " + e.getMessage() + " (" + e.getClass().getSimpleName() + ")");
622 }
623
624 public Failure(final String message) {
625 super("Failure: " + message);
626 }
627 }
628
629 class DeviceNotFound extends DBusExecutionException {
630
631 public DeviceNotFound(final String message) {
632 super("Device not found: " + message);
633 }
634 }
635
636 class GroupNotFound extends DBusExecutionException {
637
638 public GroupNotFound(final String message) {
639 super("Group not found: " + message);
640 }
641 }
642
643 class NotAGroupMember extends DBusExecutionException {
644
645 public NotAGroupMember(final String message) {
646 super("Not a group member: " + message);
647 }
648 }
649
650 class InvalidGroupId extends DBusExecutionException {
651
652 public InvalidGroupId(final String message) {
653 super("Invalid group id: " + message);
654 }
655 }
656
657 class LastGroupAdmin extends DBusExecutionException {
658
659 public LastGroupAdmin(final String message) {
660 super("Last group admin: " + message);
661 }
662 }
663
664 class InvalidNumber extends DBusExecutionException {
665
666 public InvalidNumber(final String message) {
667 super("Invalid number: " + message);
668 }
669 }
670
671 class UntrustedIdentity extends DBusExecutionException {
672
673 public UntrustedIdentity(final String message) {
674 super("Untrusted identity: " + message);
675 }
676 }
677
678 class UnregisteredRecipient extends DBusExecutionException {
679
680 public UnregisteredRecipient(final String message) {
681 super("Unregistered recipient: " + message);
682 }
683 }
684 }
685 }