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