]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/Signal.java
Implement Dbus setPin and removePin (#733)
[signal-cli] / src / main / java / org / asamk / Signal.java
1 package org.asamk;
2
3 import org.asamk.Signal.Error;
4 import org.freedesktop.dbus.exceptions.DBusException;
5 import org.freedesktop.dbus.exceptions.DBusExecutionException;
6 import org.freedesktop.dbus.interfaces.DBusInterface;
7 import org.freedesktop.dbus.messages.DBusSignal;
8 import org.whispersystems.libsignal.util.guava.Optional;
9
10 import java.io.IOException;
11 import java.util.List;
12
13 /**
14 * DBus interface for the org.asamk.Signal service.
15 * Including emitted Signals and returned Errors.
16 */
17 public interface Signal extends DBusInterface {
18
19 long sendMessage(
20 String message, List<String> attachments, String recipient
21 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
22
23 long sendMessage(
24 String message, List<String> attachments, List<String> recipients
25 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
26
27 void sendTyping(
28 String recipient, boolean stop
29 ) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
30
31 void sendReadReceipt(
32 String recipient, List<Long> targetSentTimestamp
33 ) throws Error.Failure, Error.UntrustedIdentity;
34
35 long sendRemoteDeleteMessage(
36 long targetSentTimestamp, String recipient
37 ) throws Error.Failure, Error.InvalidNumber;
38
39 long sendRemoteDeleteMessage(
40 long targetSentTimestamp, List<String> recipients
41 ) throws Error.Failure, Error.InvalidNumber;
42
43 long sendGroupRemoteDeleteMessage(
44 long targetSentTimestamp, byte[] groupId
45 ) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
46
47 long sendMessageReaction(
48 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, String recipient
49 ) throws Error.InvalidNumber, Error.Failure;
50
51 long sendMessageReaction(
52 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
53 ) throws Error.InvalidNumber, Error.Failure;
54
55 long sendNoteToSelfMessage(
56 String message, List<String> attachments
57 ) throws Error.AttachmentInvalid, Error.Failure;
58
59 void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
60
61 long sendGroupMessage(
62 String message, List<String> attachments, byte[] groupId
63 ) throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId;
64
65 long sendGroupMessageReaction(
66 String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, byte[] groupId
67 ) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
68
69 String getContactName(String number) throws Error.InvalidNumber;
70
71 void setContactName(String number, String name) throws Error.InvalidNumber;
72
73 void setContactBlocked(String number, boolean blocked) throws Error.InvalidNumber;
74
75 void setGroupBlocked(byte[] groupId, boolean blocked) throws Error.GroupNotFound, Error.InvalidGroupId;
76
77 List<byte[]> getGroupIds();
78
79 String getGroupName(byte[] groupId) throws Error.InvalidGroupId;
80
81 List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
82
83 byte[] updateGroup(
84 byte[] groupId, String name, List<String> members, String avatar
85 ) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
86
87 boolean isRegistered();
88
89 void updateProfile(
90 String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
91 ) throws Error.Failure;
92
93 void removePin();
94
95 void setPin(String registrationLockPin);
96
97 String version();
98
99 List<String> listNumbers();
100
101 List<String> getContactNumber(final String name) throws Error.Failure;
102
103 void quitGroup(final byte[] groupId) throws Error.GroupNotFound, Error.Failure, Error.InvalidGroupId;
104
105 boolean isContactBlocked(final String number) throws Error.InvalidNumber;
106
107 boolean isGroupBlocked(final byte[] groupId) throws Error.InvalidGroupId;
108
109 boolean isMember(final byte[] groupId) throws Error.InvalidGroupId;
110
111 byte[] joinGroup(final String groupLink) throws Error.Failure;
112
113 class MessageReceived extends DBusSignal {
114
115 private final long timestamp;
116 private final String sender;
117 private final byte[] groupId;
118 private final String message;
119 private final List<String> attachments;
120
121 public MessageReceived(
122 String objectpath,
123 long timestamp,
124 String sender,
125 byte[] groupId,
126 String message,
127 List<String> attachments
128 ) throws DBusException {
129 super(objectpath, timestamp, sender, groupId, message, attachments);
130 this.timestamp = timestamp;
131 this.sender = sender;
132 this.groupId = groupId;
133 this.message = message;
134 this.attachments = attachments;
135 }
136
137 public long getTimestamp() {
138 return timestamp;
139 }
140
141 public String getSender() {
142 return sender;
143 }
144
145 public byte[] getGroupId() {
146 return groupId;
147 }
148
149 public String getMessage() {
150 return message;
151 }
152
153 public List<String> getAttachments() {
154 return attachments;
155 }
156 }
157
158 class ReceiptReceived extends DBusSignal {
159
160 private final long timestamp;
161 private final String sender;
162
163 public ReceiptReceived(String objectpath, long timestamp, String sender) throws DBusException {
164 super(objectpath, timestamp, sender);
165 this.timestamp = timestamp;
166 this.sender = sender;
167 }
168
169 public long getTimestamp() {
170 return timestamp;
171 }
172
173 public String getSender() {
174 return sender;
175 }
176 }
177
178 class SyncMessageReceived extends DBusSignal {
179
180 private final long timestamp;
181 private final String source;
182 private final String destination;
183 private final byte[] groupId;
184 private final String message;
185 private final List<String> attachments;
186
187 public SyncMessageReceived(
188 String objectpath,
189 long timestamp,
190 String source,
191 String destination,
192 byte[] groupId,
193 String message,
194 List<String> attachments
195 ) throws DBusException {
196 super(objectpath, timestamp, source, destination, groupId, message, attachments);
197 this.timestamp = timestamp;
198 this.source = source;
199 this.destination = destination;
200 this.groupId = groupId;
201 this.message = message;
202 this.attachments = attachments;
203 }
204
205 public long getTimestamp() {
206 return timestamp;
207 }
208
209 public String getSource() {
210 return source;
211 }
212
213 public String getDestination() {
214 return destination;
215 }
216
217 public byte[] getGroupId() {
218 return groupId;
219 }
220
221 public String getMessage() {
222 return message;
223 }
224
225 public List<String> getAttachments() {
226 return attachments;
227 }
228 }
229
230 interface Error {
231
232 class AttachmentInvalid extends DBusExecutionException {
233
234 public AttachmentInvalid(final String message) {
235 super(message);
236 }
237 }
238
239 class Failure extends DBusExecutionException {
240
241 public Failure(final String message) {
242 super(message);
243 }
244 }
245
246 class GroupNotFound extends DBusExecutionException {
247
248 public GroupNotFound(final String message) {
249 super(message);
250 }
251 }
252
253 class InvalidGroupId extends DBusExecutionException {
254
255 public InvalidGroupId(final String message) {
256 super(message);
257 }
258 }
259
260 class InvalidNumber extends DBusExecutionException {
261
262 public InvalidNumber(final String message) {
263 super(message);
264 }
265 }
266
267 class UntrustedIdentity extends DBusExecutionException {
268
269 public UntrustedIdentity(final String message) {
270 super(message);
271 }
272 }
273 }
274 }