mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Implement more methods for DbusManagerImpl
This commit is contained in:
parent
4f50668fe3
commit
d248f249e3
5 changed files with 49 additions and 7 deletions
|
@ -530,6 +530,8 @@ public interface Signal extends DBusInterface {
|
|||
|
||||
void quitGroup() throws Error.Failure, Error.LastGroupAdmin;
|
||||
|
||||
void deleteGroup() throws Error.Failure;
|
||||
|
||||
void addMembers(List<String> recipients) throws Error.Failure;
|
||||
|
||||
void removeMembers(List<String> recipients) throws Error.Failure;
|
||||
|
|
|
@ -110,12 +110,28 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public Configuration getConfiguration() {
|
||||
throw new UnsupportedOperationException();
|
||||
final var configuration = getRemoteObject(new DBusPath(signal.getObjectPath() + "/Configuration"),
|
||||
Signal.Configuration.class).GetAll("org.asamk.Signal.Configuration");
|
||||
return new Configuration(Optional.of((Boolean) configuration.get("ReadReceipts").getValue()),
|
||||
Optional.of((Boolean) configuration.get("UnidentifiedDeliveryIndicators").getValue()),
|
||||
Optional.of((Boolean) configuration.get("TypingIndicators").getValue()),
|
||||
Optional.of((Boolean) configuration.get("LinkPreviews").getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateConfiguration(Configuration configuration) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
public void updateConfiguration(Configuration newConfiguration) throws IOException {
|
||||
final var configuration = getRemoteObject(new DBusPath(signal.getObjectPath() + "/Configuration"),
|
||||
Signal.Configuration.class);
|
||||
newConfiguration.readReceipts()
|
||||
.ifPresent(v -> configuration.Set("org.asamk.Signal.Configuration", "ReadReceipts", v));
|
||||
newConfiguration.unidentifiedDeliveryIndicators()
|
||||
.ifPresent(v -> configuration.Set("org.asamk.Signal.Configuration",
|
||||
"UnidentifiedDeliveryIndicators",
|
||||
v));
|
||||
newConfiguration.typingIndicators()
|
||||
.ifPresent(v -> configuration.Set("org.asamk.Signal.Configuration", "TypingIndicators", v));
|
||||
newConfiguration.linkPreviews()
|
||||
.ifPresent(v -> configuration.Set("org.asamk.Signal.Configuration", "LinkPreviews", v));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -136,12 +152,12 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public void unregister() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
signal.unregister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAccount() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
signal.deleteAccount();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -208,7 +224,8 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public void deleteGroup(final GroupId groupId) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
final var group = getRemoteObject(signal.getGroup(groupId.serialize()), Signal.Group.class);
|
||||
group.deleteGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -562,6 +562,7 @@ public class DbusSignalImpl implements Signal {
|
|||
final var memberIdentifiers = getSingleRecipientIdentifiers(members, m.getSelfNumber());
|
||||
if (groupId == null) {
|
||||
final var results = m.createGroup(name, memberIdentifiers, avatar == null ? null : new File(avatar));
|
||||
updateGroups();
|
||||
checkSendMessageResults(results.second().timestamp(), results.second().results());
|
||||
return results.first().serialize();
|
||||
} else {
|
||||
|
@ -1152,6 +1153,16 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteGroup() throws Error.Failure, Error.LastGroupAdmin {
|
||||
try {
|
||||
m.deleteGroup(groupId);
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
}
|
||||
updateGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMembers(final List<String> recipients) throws Error.Failure {
|
||||
final var memberIdentifiers = getSingleRecipientIdentifiers(recipients, m.getSelfNumber());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue