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