Implement more methods for DbusManagerImpl

This commit is contained in:
AsamK 2021-12-11 19:59:34 +01:00
parent 4f50668fe3
commit d248f249e3
5 changed files with 49 additions and 7 deletions

View file

@ -2,6 +2,12 @@
{ {
"interfaces":["org.asamk.Signal"]} "interfaces":["org.asamk.Signal"]}
, ,
{
"interfaces":["org.asamk.Signal$Configuration"]}
,
{
"interfaces":["org.asamk.Signal$Device"]}
,
{ {
"interfaces":["org.asamk.Signal$Group"]} "interfaces":["org.asamk.Signal$Group"]}
, ,

View file

@ -326,7 +326,9 @@
, ,
{ {
"name":"org.asamk.Signal$StructDevice", "name":"org.asamk.Signal$StructDevice",
"allDeclaredFields":true} "allDeclaredFields":true,
"queryAllDeclaredConstructors":true,
"methods":[{"name":"<init>","parameterTypes":["org.freedesktop.dbus.DBusPath","java.lang.Long","java.lang.String"] }]}
, ,
{ {
"name":"org.asamk.Signal$StructGroup", "name":"org.asamk.Signal$StructGroup",
@ -1472,6 +1474,10 @@
"name":"org.signal.storageservice.protos.groups.GroupChange$Actions$ModifyAddFromInviteLinkAccessControlAction", "name":"org.signal.storageservice.protos.groups.GroupChange$Actions$ModifyAddFromInviteLinkAccessControlAction",
"fields":[{"name":"addFromInviteLinkAccess_"}]} "fields":[{"name":"addFromInviteLinkAccess_"}]}
, ,
{
"name":"org.signal.storageservice.protos.groups.GroupChange$Actions$ModifyAnnouncementsOnlyAction",
"fields":[{"name":"announcementsOnly_"}]}
,
{ {
"name":"org.signal.storageservice.protos.groups.GroupChange$Actions$ModifyAttributesAccessControlAction", "name":"org.signal.storageservice.protos.groups.GroupChange$Actions$ModifyAttributesAccessControlAction",
"fields":[{"name":"attributesAccess_"}]} "fields":[{"name":"attributesAccess_"}]}

View file

@ -530,6 +530,8 @@ public interface Signal extends DBusInterface {
void quitGroup() throws Error.Failure, Error.LastGroupAdmin; void quitGroup() throws Error.Failure, Error.LastGroupAdmin;
void deleteGroup() throws Error.Failure;
void addMembers(List<String> recipients) throws Error.Failure; void addMembers(List<String> recipients) throws Error.Failure;
void removeMembers(List<String> recipients) throws Error.Failure; void removeMembers(List<String> recipients) throws Error.Failure;

View file

@ -110,12 +110,28 @@ public class DbusManagerImpl implements Manager {
@Override @Override
public Configuration getConfiguration() { 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 @Override
public void updateConfiguration(Configuration configuration) throws IOException { public void updateConfiguration(Configuration newConfiguration) throws IOException {
throw new UnsupportedOperationException(); 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 @Override
@ -136,12 +152,12 @@ public class DbusManagerImpl implements Manager {
@Override @Override
public void unregister() throws IOException { public void unregister() throws IOException {
throw new UnsupportedOperationException(); signal.unregister();
} }
@Override @Override
public void deleteAccount() throws IOException { public void deleteAccount() throws IOException {
throw new UnsupportedOperationException(); signal.deleteAccount();
} }
@Override @Override
@ -208,7 +224,8 @@ public class DbusManagerImpl implements Manager {
@Override @Override
public void deleteGroup(final GroupId groupId) throws IOException { 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 @Override

View file

@ -562,6 +562,7 @@ public class DbusSignalImpl implements Signal {
final var memberIdentifiers = getSingleRecipientIdentifiers(members, m.getSelfNumber()); final var memberIdentifiers = getSingleRecipientIdentifiers(members, m.getSelfNumber());
if (groupId == null) { if (groupId == null) {
final var results = m.createGroup(name, memberIdentifiers, avatar == null ? null : new File(avatar)); final var results = m.createGroup(name, memberIdentifiers, avatar == null ? null : new File(avatar));
updateGroups();
checkSendMessageResults(results.second().timestamp(), results.second().results()); checkSendMessageResults(results.second().timestamp(), results.second().results());
return results.first().serialize(); return results.first().serialize();
} else { } 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 @Override
public void addMembers(final List<String> recipients) throws Error.Failure { public void addMembers(final List<String> recipients) throws Error.Failure {
final var memberIdentifiers = getSingleRecipientIdentifiers(recipients, m.getSelfNumber()); final var memberIdentifiers = getSingleRecipientIdentifiers(recipients, m.getSelfNumber());