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