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