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