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