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