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