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