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