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