]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/Signal.java
implement Dbus sync methods (#737)
[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 setContactBlocked(String number, boolean blocked) throws Error.InvalidNumber;
75
76 void setGroupBlocked(byte[] groupId, boolean blocked) throws Error.GroupNotFound, Error.InvalidGroupId;
77
78 List<byte[]> getGroupIds();
79
80 String getGroupName(byte[] groupId) throws Error.InvalidGroupId;
81
82 List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
83
84 byte[] updateGroup(
85 byte[] groupId, String name, List<String> members, String avatar
86 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
87
88 boolean isRegistered();
89
90 void updateProfile(
91 String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
92 ) throws Error.Failure;
93
94 void removePin();
95
96 void setPin(String registrationLockPin);
97
98 String version();
99
100 List<String> listNumbers();
101
102 List<String> getContactNumber(final String name) throws Error.Failure;
103
104 void quitGroup(final byte[] groupId) throws Error.GroupNotFound, Error.Failure, Error.InvalidGroupId;
105
106 boolean isContactBlocked(final String number) throws Error.InvalidNumber;
107
108 boolean isGroupBlocked(final byte[] groupId) throws Error.InvalidGroupId;
109
110 boolean isMember(final byte[] groupId) throws Error.InvalidGroupId;
111
112 byte[] joinGroup(final String groupLink) throws Error.Failure;
113
114 String uploadStickerPack(String stickerPackPath) throws Error.Failure;
115
116 class MessageReceived extends DBusSignal {
117
118 private final long timestamp;
119 private final String sender;
120 private final byte[] groupId;
121 private final String message;
122 private final List<String> attachments;
123
124 public MessageReceived(
125 String objectpath,
126 long timestamp,
127 String sender,
128 byte[] groupId,
129 String message,
130 List<String> attachments
131 ) throws DBusException {
132 super(objectpath, timestamp, sender, groupId, message, attachments);
133 this.timestamp = timestamp;
134 this.sender = sender;
135 this.groupId = groupId;
136 this.message = message;
137 this.attachments = attachments;
138 }
139
140 public long getTimestamp() {
141 return timestamp;
142 }
143
144 public String getSender() {
145 return sender;
146 }
147
148 public byte[] getGroupId() {
149 return groupId;
150 }
151
152 public String getMessage() {
153 return message;
154 }
155
156 public List<String> getAttachments() {
157 return attachments;
158 }
159 }
160
161 class ReceiptReceived extends DBusSignal {
162
163 private final long timestamp;
164 private final String sender;
165
166 public ReceiptReceived(String objectpath, long timestamp, String sender) throws DBusException {
167 super(objectpath, timestamp, sender);
168 this.timestamp = timestamp;
169 this.sender = sender;
170 }
171
172 public long getTimestamp() {
173 return timestamp;
174 }
175
176 public String getSender() {
177 return sender;
178 }
179 }
180
181 class SyncMessageReceived extends DBusSignal {
182
183 private final long timestamp;
184 private final String source;
185 private final String destination;
186 private final byte[] groupId;
187 private final String message;
188 private final List<String> attachments;
189
190 public SyncMessageReceived(
191 String objectpath,
192 long timestamp,
193 String source,
194 String destination,
195 byte[] groupId,
196 String message,
197 List<String> attachments
198 ) throws DBusException {
199 super(objectpath, timestamp, source, destination, groupId, message, attachments);
200 this.timestamp = timestamp;
201 this.source = source;
202 this.destination = destination;
203 this.groupId = groupId;
204 this.message = message;
205 this.attachments = attachments;
206 }
207
208 public long getTimestamp() {
209 return timestamp;
210 }
211
212 public String getSource() {
213 return source;
214 }
215
216 public String getDestination() {
217 return destination;
218 }
219
220 public byte[] getGroupId() {
221 return groupId;
222 }
223
224 public String getMessage() {
225 return message;
226 }
227
228 public List<String> getAttachments() {
229 return attachments;
230 }
231 }
232
233 interface Error {
234
235 class AttachmentInvalid extends DBusExecutionException {
236
237 public AttachmentInvalid(final String message) {
238 super(message);
239 }
240 }
241
242 class Failure extends DBusExecutionException {
243
244 public Failure(final String message) {
245 super(message);
246 }
247 }
248
249 class GroupNotFound extends DBusExecutionException {
250
251 public GroupNotFound(final String message) {
252 super(message);
253 }
254 }
255
256 class InvalidGroupId extends DBusExecutionException {
257
258 public InvalidGroupId(final String message) {
259 super(message);
260 }
261 }
262
263 class InvalidNumber extends DBusExecutionException {
264
265 public InvalidNumber(final String message) {
266 super(message);
267 }
268 }
269
270 class UntrustedIdentity extends DBusExecutionException {
271
272 public UntrustedIdentity(final String message) {
273 super(message);
274 }
275 }
276 }
277 }