]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/Signal.java
Add DeviceNotFound Error
[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 submitRateLimitChallenge(String challenge, String captchaString) throws IOErrorException;
149
150 class MessageReceived extends DBusSignal {
151
152 private final long timestamp;
153 private final String sender;
154 private final byte[] groupId;
155 private final String message;
156 private final List<String> attachments;
157
158 public MessageReceived(
159 String objectpath,
160 long timestamp,
161 String sender,
162 byte[] groupId,
163 String message,
164 List<String> attachments
165 ) throws DBusException {
166 super(objectpath, timestamp, sender, groupId, message, attachments);
167 this.timestamp = timestamp;
168 this.sender = sender;
169 this.groupId = groupId;
170 this.message = message;
171 this.attachments = attachments;
172 }
173
174 public long getTimestamp() {
175 return timestamp;
176 }
177
178 public String getSender() {
179 return sender;
180 }
181
182 public byte[] getGroupId() {
183 return groupId;
184 }
185
186 public String getMessage() {
187 return message;
188 }
189
190 public List<String> getAttachments() {
191 return attachments;
192 }
193 }
194
195 class ReceiptReceived extends DBusSignal {
196
197 private final long timestamp;
198 private final String sender;
199
200 public ReceiptReceived(String objectpath, long timestamp, String sender) throws DBusException {
201 super(objectpath, timestamp, sender);
202 this.timestamp = timestamp;
203 this.sender = sender;
204 }
205
206 public long getTimestamp() {
207 return timestamp;
208 }
209
210 public String getSender() {
211 return sender;
212 }
213 }
214
215 class SyncMessageReceived extends DBusSignal {
216
217 private final long timestamp;
218 private final String source;
219 private final String destination;
220 private final byte[] groupId;
221 private final String message;
222 private final List<String> attachments;
223
224 public SyncMessageReceived(
225 String objectpath,
226 long timestamp,
227 String source,
228 String destination,
229 byte[] groupId,
230 String message,
231 List<String> attachments
232 ) throws DBusException {
233 super(objectpath, timestamp, source, destination, groupId, message, attachments);
234 this.timestamp = timestamp;
235 this.source = source;
236 this.destination = destination;
237 this.groupId = groupId;
238 this.message = message;
239 this.attachments = attachments;
240 }
241
242 public long getTimestamp() {
243 return timestamp;
244 }
245
246 public String getSource() {
247 return source;
248 }
249
250 public String getDestination() {
251 return destination;
252 }
253
254 public byte[] getGroupId() {
255 return groupId;
256 }
257
258 public String getMessage() {
259 return message;
260 }
261
262 public List<String> getAttachments() {
263 return attachments;
264 }
265 }
266
267 class StructDevice extends Struct {
268
269 @Position(0)
270 DBusPath objectPath;
271
272 @Position(1)
273 Long id;
274
275 @Position(2)
276 String name;
277
278 public StructDevice(final DBusPath objectPath, final Long id, final String name) {
279 this.objectPath = objectPath;
280 this.id = id;
281 this.name = name;
282 }
283
284 public DBusPath getObjectPath() {
285 return objectPath;
286 }
287
288 public Long getId() {
289 return id;
290 }
291
292 public String getName() {
293 return name;
294 }
295 }
296
297 @DBusProperty(name = "Id", type = Long.class, access = DBusProperty.Access.READ)
298 @DBusProperty(name = "Name", type = String.class)
299 @DBusProperty(name = "Created", type = String.class, access = DBusProperty.Access.READ)
300 @DBusProperty(name = "LastSeen", type = String.class, access = DBusProperty.Access.READ)
301 interface Device extends DBusInterface, Properties {
302
303 void removeDevice() throws Error.Failure;
304 }
305
306 interface Error {
307
308 class AttachmentInvalid extends DBusExecutionException {
309
310 public AttachmentInvalid(final String message) {
311 super(message);
312 }
313 }
314
315 class InvalidUri extends DBusExecutionException {
316
317 public InvalidUri(final String message) {
318 super(message);
319 }
320 }
321
322 class Failure extends DBusExecutionException {
323
324 public Failure(final String message) {
325 super(message);
326 }
327 }
328
329 class DeviceNotFound extends DBusExecutionException {
330
331 public DeviceNotFound(final String message) {
332 super(message);
333 }
334 }
335
336 class GroupNotFound extends DBusExecutionException {
337
338 public GroupNotFound(final String message) {
339 super(message);
340 }
341 }
342
343 class InvalidGroupId extends DBusExecutionException {
344
345 public InvalidGroupId(final String message) {
346 super(message);
347 }
348 }
349
350 class InvalidNumber extends DBusExecutionException {
351
352 public InvalidNumber(final String message) {
353 super(message);
354 }
355 }
356
357 class UntrustedIdentity extends DBusExecutionException {
358
359 public UntrustedIdentity(final String message) {
360 super(message);
361 }
362 }
363 }
364 }