]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/Signal.java
Merge branch 'master' into dbus_sendviewed
[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
14 import java.util.List;
15
16 /**
17 * DBus interface for the org.asamk.Signal service.
18 * Including emitted Signals and returned Errors.
19 */
20 public interface Signal extends DBusInterface {
21
22 String getSelfNumber();
23
24 long sendMessage(
25 String message, List<String> attachments, String recipient
26 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
27
28 long sendMessage(
29 String message, List<String> attachments, List<String> recipients
30 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
31
32 void sendTyping(
33 String recipient, boolean stop
34 ) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
35
36 void sendReadReceipt(
37 String recipient, List<Long> messageIds
38 ) throws Error.Failure, Error.UntrustedIdentity;
39
40 void sendViewedReceipt(
41 String recipient, List<Long> messageIds
42 ) throws Error.Failure, Error.UntrustedIdentity;
43
44 long sendRemoteDeleteMessage(
45 long targetSentTimestamp, String recipient
46 ) throws Error.Failure, Error.InvalidNumber;
47
48 long sendRemoteDeleteMessage(
49 long targetSentTimestamp, List<String> recipients
50 ) throws Error.Failure, Error.InvalidNumber;
51
52 long sendGroupRemoteDeleteMessage(
53 long targetSentTimestamp, byte[] groupId
54 ) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
55
56 long sendMessageReaction(
57 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, String recipient
58 ) throws Error.InvalidNumber, Error.Failure;
59
60 long sendMessageReaction(
61 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
62 ) throws Error.InvalidNumber, Error.Failure;
63
64 void sendContacts() throws Error.Failure;
65
66 void sendSyncRequest() throws Error.Failure;
67
68 long sendNoteToSelfMessage(
69 String message, List<String> attachments
70 ) throws Error.AttachmentInvalid, Error.Failure;
71
72 void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
73
74 long sendGroupMessage(
75 String message, List<String> attachments, byte[] groupId
76 ) throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId;
77
78 long sendGroupMessageReaction(
79 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, byte[] groupId
80 ) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
81
82 String getContactName(String number) throws Error.InvalidNumber;
83
84 void setContactName(String number, String name) throws Error.InvalidNumber;
85
86 void setExpirationTimer(final String number, final int expiration) throws Error.Failure;
87
88 void setContactBlocked(String number, boolean blocked) throws Error.InvalidNumber;
89
90 @Deprecated
91 void setGroupBlocked(byte[] groupId, boolean blocked) throws Error.GroupNotFound, Error.InvalidGroupId;
92
93 @Deprecated
94 List<byte[]> getGroupIds();
95
96 DBusPath getGroup(byte[] groupId);
97
98 List<StructGroup> listGroups();
99
100 @Deprecated
101 String getGroupName(byte[] groupId) throws Error.InvalidGroupId;
102
103 @Deprecated
104 List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
105
106 byte[] createGroup(
107 String name, List<String> members, String avatar
108 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber;
109
110 @Deprecated
111 byte[] updateGroup(
112 byte[] groupId, String name, List<String> members, String avatar
113 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
114
115 boolean isRegistered() throws Error.Failure, Error.InvalidNumber;
116
117 boolean isRegistered(String number) throws Error.Failure, Error.InvalidNumber;
118
119 List<Boolean> isRegistered(List<String> numbers) throws Error.Failure, Error.InvalidNumber;
120
121 void addDevice(String uri) throws Error.InvalidUri;
122
123 DBusPath getDevice(long deviceId);
124
125 List<StructDevice> listDevices() throws Error.Failure;
126
127 DBusPath getThisDevice();
128
129 void updateProfile(
130 String givenName,
131 String familyName,
132 String about,
133 String aboutEmoji,
134 String avatarPath,
135 boolean removeAvatar
136 ) throws Error.Failure;
137
138 void updateProfile(
139 String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
140 ) throws Error.Failure;
141
142 void removePin();
143
144 void setPin(String registrationLockPin);
145
146 String version();
147
148 List<String> listNumbers();
149
150 List<String> getContactNumber(final String name) throws Error.Failure;
151
152 @Deprecated
153 void quitGroup(final byte[] groupId) throws Error.GroupNotFound, Error.Failure, Error.InvalidGroupId;
154
155 boolean isContactBlocked(final String number) throws Error.InvalidNumber;
156
157 @Deprecated
158 boolean isGroupBlocked(final byte[] groupId) throws Error.InvalidGroupId;
159
160 @Deprecated
161 boolean isMember(final byte[] groupId) throws Error.InvalidGroupId;
162
163 byte[] joinGroup(final String groupLink) throws Error.Failure;
164
165 String uploadStickerPack(String stickerPackPath) throws Error.Failure;
166
167 void submitRateLimitChallenge(String challenge, String captchaString) throws IOErrorException;
168
169 class MessageReceived extends DBusSignal {
170
171 private final long timestamp;
172 private final String sender;
173 private final byte[] groupId;
174 private final String message;
175 private final List<String> attachments;
176
177 public MessageReceived(
178 String objectpath,
179 long timestamp,
180 String sender,
181 byte[] groupId,
182 String message,
183 List<String> attachments
184 ) throws DBusException {
185 super(objectpath, timestamp, sender, groupId, message, attachments);
186 this.timestamp = timestamp;
187 this.sender = sender;
188 this.groupId = groupId;
189 this.message = message;
190 this.attachments = attachments;
191 }
192
193 public long getTimestamp() {
194 return timestamp;
195 }
196
197 public String getSender() {
198 return sender;
199 }
200
201 public byte[] getGroupId() {
202 return groupId;
203 }
204
205 public String getMessage() {
206 return message;
207 }
208
209 public List<String> getAttachments() {
210 return attachments;
211 }
212 }
213
214 class ReceiptReceived extends DBusSignal {
215
216 private final long timestamp;
217 private final String sender;
218
219 public ReceiptReceived(String objectpath, long timestamp, String sender) throws DBusException {
220 super(objectpath, timestamp, sender);
221 this.timestamp = timestamp;
222 this.sender = sender;
223 }
224
225 public long getTimestamp() {
226 return timestamp;
227 }
228
229 public String getSender() {
230 return sender;
231 }
232 }
233
234 class SyncMessageReceived extends DBusSignal {
235
236 private final long timestamp;
237 private final String source;
238 private final String destination;
239 private final byte[] groupId;
240 private final String message;
241 private final List<String> attachments;
242
243 public SyncMessageReceived(
244 String objectpath,
245 long timestamp,
246 String source,
247 String destination,
248 byte[] groupId,
249 String message,
250 List<String> attachments
251 ) throws DBusException {
252 super(objectpath, timestamp, source, destination, groupId, message, attachments);
253 this.timestamp = timestamp;
254 this.source = source;
255 this.destination = destination;
256 this.groupId = groupId;
257 this.message = message;
258 this.attachments = attachments;
259 }
260
261 public long getTimestamp() {
262 return timestamp;
263 }
264
265 public String getSource() {
266 return source;
267 }
268
269 public String getDestination() {
270 return destination;
271 }
272
273 public byte[] getGroupId() {
274 return groupId;
275 }
276
277 public String getMessage() {
278 return message;
279 }
280
281 public List<String> getAttachments() {
282 return attachments;
283 }
284 }
285
286 class StructDevice extends Struct {
287
288 @Position(0)
289 DBusPath objectPath;
290
291 @Position(1)
292 Long id;
293
294 @Position(2)
295 String name;
296
297 public StructDevice(final DBusPath objectPath, final Long id, final String name) {
298 this.objectPath = objectPath;
299 this.id = id;
300 this.name = name;
301 }
302
303 public DBusPath getObjectPath() {
304 return objectPath;
305 }
306
307 public Long getId() {
308 return id;
309 }
310
311 public String getName() {
312 return name;
313 }
314 }
315
316 @DBusProperty(name = "Id", type = Long.class, access = DBusProperty.Access.READ)
317 @DBusProperty(name = "Name", type = String.class)
318 @DBusProperty(name = "Created", type = String.class, access = DBusProperty.Access.READ)
319 @DBusProperty(name = "LastSeen", type = String.class, access = DBusProperty.Access.READ)
320 interface Device extends DBusInterface, Properties {
321
322 void removeDevice() throws Error.Failure;
323 }
324
325 class StructGroup extends Struct {
326
327 @Position(0)
328 DBusPath objectPath;
329
330 @Position(1)
331 byte[] id;
332
333 @Position(2)
334 String name;
335
336 public StructGroup(final DBusPath objectPath, final byte[] id, final String name) {
337 this.objectPath = objectPath;
338 this.id = id;
339 this.name = name;
340 }
341
342 public DBusPath getObjectPath() {
343 return objectPath;
344 }
345
346 public byte[] getId() {
347 return id;
348 }
349
350 public String getName() {
351 return name;
352 }
353 }
354
355 @DBusProperty(name = "Id", type = Byte[].class, access = DBusProperty.Access.READ)
356 @DBusProperty(name = "Name", type = String.class)
357 @DBusProperty(name = "Description", type = String.class)
358 @DBusProperty(name = "Avatar", type = String.class, access = DBusProperty.Access.WRITE)
359 @DBusProperty(name = "IsBlocked", type = Boolean.class)
360 @DBusProperty(name = "IsMember", type = Boolean.class, access = DBusProperty.Access.READ)
361 @DBusProperty(name = "IsAdmin", type = Boolean.class, access = DBusProperty.Access.READ)
362 @DBusProperty(name = "MessageExpirationTimer", type = Integer.class)
363 @DBusProperty(name = "Members", type = String[].class, access = DBusProperty.Access.READ)
364 @DBusProperty(name = "PendingMembers", type = String[].class, access = DBusProperty.Access.READ)
365 @DBusProperty(name = "RequestingMembers", type = String[].class, access = DBusProperty.Access.READ)
366 @DBusProperty(name = "Admins", type = String[].class, access = DBusProperty.Access.READ)
367 @DBusProperty(name = "PermissionAddMember", type = String.class)
368 @DBusProperty(name = "PermissionEditDetails", type = String.class)
369 @DBusProperty(name = "PermissionSendMessage", type = String.class)
370 @DBusProperty(name = "GroupInviteLink", type = String.class, access = DBusProperty.Access.READ)
371 interface Group extends DBusInterface, Properties {
372
373 void quitGroup() throws Error.Failure, Error.LastGroupAdmin;
374
375 void addMembers(List<String> recipients) throws Error.Failure;
376
377 void removeMembers(List<String> recipients) throws Error.Failure;
378
379 void addAdmins(List<String> recipients) throws Error.Failure;
380
381 void removeAdmins(List<String> recipients) throws Error.Failure;
382
383 void resetLink() throws Error.Failure;
384
385 void disableLink() throws Error.Failure;
386
387 void enableLink(boolean requiresApproval) throws Error.Failure;
388 }
389
390 interface Error {
391
392 class AttachmentInvalid extends DBusExecutionException {
393
394 public AttachmentInvalid(final String message) {
395 super("Invalid attachment: " + message);
396 }
397 }
398
399 class InvalidUri extends DBusExecutionException {
400
401 public InvalidUri(final String message) {
402 super("Invalid uri: " + message);
403 }
404 }
405
406 class Failure extends DBusExecutionException {
407
408 public Failure(final Exception e) {
409 super("Failure: " + e.getMessage() + " (" + e.getClass().getSimpleName() + ")");
410 }
411
412 public Failure(final String message) {
413 super("Failure: " + message);
414 }
415 }
416
417 class DeviceNotFound extends DBusExecutionException {
418
419 public DeviceNotFound(final String message) {
420 super("Device not found: " + message);
421 }
422 }
423
424 class GroupNotFound extends DBusExecutionException {
425
426 public GroupNotFound(final String message) {
427 super("Group not found: " + message);
428 }
429 }
430
431 class InvalidGroupId extends DBusExecutionException {
432
433 public InvalidGroupId(final String message) {
434 super("Invalid group id: " + message);
435 }
436 }
437
438 class LastGroupAdmin extends DBusExecutionException {
439
440 public LastGroupAdmin(final String message) {
441 super("Last group admin: " + message);
442 }
443 }
444
445 class InvalidNumber extends DBusExecutionException {
446
447 public InvalidNumber(final String message) {
448 super("Invalid number: " + message);
449 }
450 }
451
452 class UntrustedIdentity extends DBusExecutionException {
453
454 public UntrustedIdentity(final String message) {
455 super("Untrusted identity: " + message);
456 }
457 }
458 }
459 }