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