]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/Signal.java
Merge branch master into dbus_updateConfiguration
[signal-cli] / src / main / java / org / asamk / Signal.java
1 package org.asamk;
2
3 import org.asamk.signal.commands.exceptions.IOErrorException;
4
5 import org.freedesktop.dbus.DBusPath;
6 import org.freedesktop.dbus.Struct;
7 import org.freedesktop.dbus.annotations.DBusProperty;
8 import org.freedesktop.dbus.annotations.Position;
9 import org.freedesktop.dbus.exceptions.DBusException;
10 import org.freedesktop.dbus.exceptions.DBusExecutionException;
11 import org.freedesktop.dbus.interfaces.DBusInterface;
12 import org.freedesktop.dbus.interfaces.Properties;
13 import org.freedesktop.dbus.messages.DBusSignal;
14
15 import java.util.List;
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 long sendMessage(
26 String message, List<String> attachments, String recipient
27 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
28
29 long sendMessage(
30 String message, List<String> attachments, List<String> recipients
31 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
32
33 void sendTyping(
34 String recipient, boolean stop
35 ) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
36
37 void sendReadReceipt(
38 String recipient, List<Long> messageIds
39 ) throws Error.Failure, Error.UntrustedIdentity;
40
41 long sendRemoteDeleteMessage(
42 long targetSentTimestamp, String recipient
43 ) throws Error.Failure, Error.InvalidNumber;
44
45 long sendRemoteDeleteMessage(
46 long targetSentTimestamp, List<String> recipients
47 ) throws Error.Failure, Error.InvalidNumber;
48
49 long sendGroupRemoteDeleteMessage(
50 long targetSentTimestamp, byte[] groupId
51 ) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
52
53 long sendMessageReaction(
54 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, String recipient
55 ) throws Error.InvalidNumber, Error.Failure;
56
57 long sendMessageReaction(
58 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
59 ) throws Error.InvalidNumber, Error.Failure;
60
61 void sendContacts() throws Error.Failure;
62
63 void sendSyncRequest() throws Error.Failure;
64
65 long sendNoteToSelfMessage(
66 String message, List<String> attachments
67 ) throws Error.AttachmentInvalid, Error.Failure;
68
69 void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
70
71 long sendGroupMessage(
72 String message, List<String> attachments, byte[] groupId
73 ) throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId;
74
75 long sendGroupMessageReaction(
76 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, byte[] groupId
77 ) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
78
79 String getContactName(String number) throws Error.InvalidNumber;
80
81 void setContactName(String number, String name) throws Error.InvalidNumber;
82
83 void setExpirationTimer(final String number, final int expiration) throws Error.Failure;
84
85 void setContactBlocked(String number, boolean blocked) throws Error.InvalidNumber;
86
87 void setGroupBlocked(byte[] groupId, boolean blocked) throws Error.GroupNotFound, Error.InvalidGroupId;
88
89 List<byte[]> getGroupIds();
90
91 String getGroupName(byte[] groupId) throws Error.InvalidGroupId;
92
93 List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
94
95 byte[] updateGroup(
96 byte[] groupId, String name, List<String> members, String avatar
97 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
98
99 boolean isRegistered() throws Error.Failure, Error.InvalidNumber;
100
101 boolean isRegistered(String number) throws Error.Failure, Error.InvalidNumber;
102
103 List<Boolean> isRegistered(List<String> numbers) throws Error.Failure, Error.InvalidNumber;
104
105 void addDevice(String uri) throws Error.InvalidUri;
106
107 DBusPath getDevice(long deviceId);
108
109 List<StructDevice> listDevices() throws Error.Failure;
110
111 DBusPath getThisDevice();
112
113 void updateProfile(
114 String givenName,
115 String familyName,
116 String about,
117 String aboutEmoji,
118 String avatarPath,
119 boolean removeAvatar
120 ) throws Error.Failure;
121
122 void updateProfile(
123 String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
124 ) throws Error.Failure;
125
126 void removePin();
127
128 void setPin(String registrationLockPin);
129
130 String version();
131
132 List<String> listNumbers();
133
134 List<String> getContactNumber(final String name) throws Error.Failure;
135
136 void quitGroup(final byte[] groupId) throws Error.GroupNotFound, Error.Failure, Error.InvalidGroupId;
137
138 boolean isContactBlocked(final String number) throws Error.InvalidNumber;
139
140 boolean isGroupBlocked(final byte[] groupId) throws Error.InvalidGroupId;
141
142 boolean isMember(final byte[] groupId) throws Error.InvalidGroupId;
143
144 byte[] joinGroup(final String groupLink) throws Error.Failure;
145
146 String uploadStickerPack(String stickerPackPath) throws Error.Failure;
147
148 void setConfiguration(boolean readReceipts, boolean unidentifiedDeliveryIndicators, boolean typingIndicators, boolean linkPreviews) throws Error.IOError, Error.UserError;
149
150 List<Boolean> getConfiguration();
151
152 void submitRateLimitChallenge(String challenge, String captchaString) throws IOErrorException;
153
154 class MessageReceived extends DBusSignal {
155
156 private final long timestamp;
157 private final String sender;
158 private final byte[] groupId;
159 private final String message;
160 private final List<String> attachments;
161
162 public MessageReceived(
163 String objectpath,
164 long timestamp,
165 String sender,
166 byte[] groupId,
167 String message,
168 List<String> attachments
169 ) throws DBusException {
170 super(objectpath, timestamp, sender, groupId, message, attachments);
171 this.timestamp = timestamp;
172 this.sender = sender;
173 this.groupId = groupId;
174 this.message = message;
175 this.attachments = attachments;
176 }
177
178 public long getTimestamp() {
179 return timestamp;
180 }
181
182 public String getSender() {
183 return sender;
184 }
185
186 public byte[] getGroupId() {
187 return groupId;
188 }
189
190 public String getMessage() {
191 return message;
192 }
193
194 public List<String> getAttachments() {
195 return attachments;
196 }
197 }
198
199 class ReceiptReceived extends DBusSignal {
200
201 private final long timestamp;
202 private final String sender;
203
204 public ReceiptReceived(String objectpath, long timestamp, String sender) throws DBusException {
205 super(objectpath, timestamp, sender);
206 this.timestamp = timestamp;
207 this.sender = sender;
208 }
209
210 public long getTimestamp() {
211 return timestamp;
212 }
213
214 public String getSender() {
215 return sender;
216 }
217 }
218
219 class SyncMessageReceived extends DBusSignal {
220
221 private final long timestamp;
222 private final String source;
223 private final String destination;
224 private final byte[] groupId;
225 private final String message;
226 private final List<String> attachments;
227
228 public SyncMessageReceived(
229 String objectpath,
230 long timestamp,
231 String source,
232 String destination,
233 byte[] groupId,
234 String message,
235 List<String> attachments
236 ) throws DBusException {
237 super(objectpath, timestamp, source, destination, groupId, message, attachments);
238 this.timestamp = timestamp;
239 this.source = source;
240 this.destination = destination;
241 this.groupId = groupId;
242 this.message = message;
243 this.attachments = attachments;
244 }
245
246 public long getTimestamp() {
247 return timestamp;
248 }
249
250 public String getSource() {
251 return source;
252 }
253
254 public String getDestination() {
255 return destination;
256 }
257
258 public byte[] getGroupId() {
259 return groupId;
260 }
261
262 public String getMessage() {
263 return message;
264 }
265
266 public List<String> getAttachments() {
267 return attachments;
268 }
269 }
270
271 class StructDevice extends Struct {
272
273 @Position(0)
274 DBusPath objectPath;
275
276 @Position(1)
277 Long id;
278
279 @Position(2)
280 String name;
281
282 public StructDevice(final DBusPath objectPath, final Long id, final String name) {
283 this.objectPath = objectPath;
284 this.id = id;
285 this.name = name;
286 }
287
288 public DBusPath getObjectPath() {
289 return objectPath;
290 }
291
292 public Long getId() {
293 return id;
294 }
295
296 public String getName() {
297 return name;
298 }
299 }
300
301 @DBusProperty(name = "Id", type = Long.class, access = DBusProperty.Access.READ)
302 @DBusProperty(name = "Name", type = String.class)
303 @DBusProperty(name = "Created", type = String.class, access = DBusProperty.Access.READ)
304 @DBusProperty(name = "LastSeen", type = String.class, access = DBusProperty.Access.READ)
305 interface Device extends DBusInterface, Properties {
306
307 void removeDevice() throws Error.Failure;
308 }
309
310 interface Error {
311
312 class AttachmentInvalid extends DBusExecutionException {
313
314 public AttachmentInvalid(final String message) {
315 super(message);
316 }
317 }
318
319 class InvalidUri extends DBusExecutionException {
320
321 public InvalidUri(final String message) {
322 super(message);
323 }
324 }
325
326 class Failure extends DBusExecutionException {
327
328 public Failure(final String message) {
329 super(message);
330 }
331 }
332
333 class GroupNotFound extends DBusExecutionException {
334
335 public GroupNotFound(final String message) {
336 super(message);
337 }
338 }
339
340 class InvalidGroupId extends DBusExecutionException {
341
342 public InvalidGroupId(final String message) {
343 super(message);
344 }
345 }
346
347 class InvalidNumber extends DBusExecutionException {
348
349 public InvalidNumber(final String message) {
350 super(message);
351 }
352 }
353
354 class UntrustedIdentity extends DBusExecutionException {
355
356 public UntrustedIdentity(final String message) {
357 super(message);
358 }
359 }
360
361 class IOError extends DBusExecutionException {
362
363 public IOError(final String message) {
364 super(message);
365 }
366 }
367
368 class UserError extends DBusExecutionException {
369
370 public UserError(final String message) {
371 super(message);
372 }
373 }
374 }
375 }