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