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