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