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