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