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