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