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