]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/Signal.java
Proposal for the Manager class to manage an ExecutorService for all SignalServiceMess...
[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 class MessageReceived extends DBusSignal {
55
56 private final long timestamp;
57 private final String sender;
58 private final byte[] groupId;
59 private final String message;
60 private final List<String> attachments;
61
62 public MessageReceived(
63 String objectpath,
64 long timestamp,
65 String sender,
66 byte[] groupId,
67 String message,
68 List<String> attachments
69 ) throws DBusException {
70 super(objectpath, timestamp, sender, groupId, message, attachments);
71 this.timestamp = timestamp;
72 this.sender = sender;
73 this.groupId = groupId;
74 this.message = message;
75 this.attachments = attachments;
76 }
77
78 public long getTimestamp() {
79 return timestamp;
80 }
81
82 public String getSender() {
83 return sender;
84 }
85
86 public byte[] getGroupId() {
87 return groupId;
88 }
89
90 public String getMessage() {
91 return message;
92 }
93
94 public List<String> getAttachments() {
95 return attachments;
96 }
97 }
98
99 class ReceiptReceived extends DBusSignal {
100
101 private final long timestamp;
102 private final String sender;
103
104 public ReceiptReceived(String objectpath, long timestamp, String sender) throws DBusException {
105 super(objectpath, timestamp, sender);
106 this.timestamp = timestamp;
107 this.sender = sender;
108 }
109
110 public long getTimestamp() {
111 return timestamp;
112 }
113
114 public String getSender() {
115 return sender;
116 }
117 }
118
119 class SyncMessageReceived extends DBusSignal {
120
121 private final long timestamp;
122 private final String source;
123 private final String destination;
124 private final byte[] groupId;
125 private final String message;
126 private final List<String> attachments;
127
128 public SyncMessageReceived(
129 String objectpath,
130 long timestamp,
131 String source,
132 String destination,
133 byte[] groupId,
134 String message,
135 List<String> attachments
136 ) throws DBusException {
137 super(objectpath, timestamp, source, destination, groupId, message, attachments);
138 this.timestamp = timestamp;
139 this.source = source;
140 this.destination = destination;
141 this.groupId = groupId;
142 this.message = message;
143 this.attachments = attachments;
144 }
145
146 public long getTimestamp() {
147 return timestamp;
148 }
149
150 public String getSource() {
151 return source;
152 }
153
154 public String getDestination() {
155 return destination;
156 }
157
158 public byte[] getGroupId() {
159 return groupId;
160 }
161
162 public String getMessage() {
163 return message;
164 }
165
166 public List<String> getAttachments() {
167 return attachments;
168 }
169 }
170
171 interface Error {
172
173 class AttachmentInvalid extends DBusExecutionException {
174
175 public AttachmentInvalid(final String message) {
176 super(message);
177 }
178 }
179
180 class Failure extends DBusExecutionException {
181
182 public Failure(final String message) {
183 super(message);
184 }
185 }
186
187 class GroupNotFound extends DBusExecutionException {
188
189 public GroupNotFound(final String message) {
190 super(message);
191 }
192 }
193
194 class InvalidNumber extends DBusExecutionException {
195
196 public InvalidNumber(final String message) {
197 super(message);
198 }
199 }
200
201 class UntrustedIdentity extends DBusExecutionException {
202
203 public UntrustedIdentity(final String message) {
204 super(message);
205 }
206 }
207 }
208 }