Add dbus methods: deleteContact and deleteRecipient

Closes #814
This commit is contained in:
jonas.hoefer 2021-12-02 11:02:28 +01:00 committed by AsamK
parent e92d37e3a5
commit 861f47d734
4 changed files with 34 additions and 2 deletions

View file

@ -519,6 +519,16 @@ setContactName(number<s>,name<>) -> <>::
Exceptions: InvalidNumber, Failure Exceptions: InvalidNumber, Failure
deleteContact(number<s>) -> <>::
* number : Phone number
Exceptions: Failure
deleteRecipient(number<s>) -> <>::
* number : Phone number
Exceptions: Failure
setExpirationTimer(number<s>, expiration<i>) -> <>:: setExpirationTimer(number<s>, expiration<i>) -> <>::
* number : Phone number of recipient * number : Phone number of recipient
* expiration : int32 for the number of seconds before messages to this recipient disappear. Set to 0 to disable expiration. * expiration : int32 for the number of seconds before messages to this recipient disappear. Set to 0 to disable expiration.

View file

@ -76,6 +76,10 @@ public interface Signal extends DBusInterface {
void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity; void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
void deleteRecipient(final String recipient) throws Error.Failure;
void deleteContact(final String recipient) throws Error.Failure;
long sendGroupMessage( long sendGroupMessage(
String message, List<String> attachments, byte[] groupId String message, List<String> attachments, byte[] groupId
) throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId; ) throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId;

View file

@ -383,12 +383,12 @@ public class DbusManagerImpl implements Manager {
@Override @Override
public void deleteRecipient(final RecipientIdentifier.Single recipient) throws IOException { public void deleteRecipient(final RecipientIdentifier.Single recipient) throws IOException {
throw new UnsupportedOperationException(); signal.deleteRecipient(recipient.getIdentifier());
} }
@Override @Override
public void deleteContact(final RecipientIdentifier.Single recipient) throws IOException { public void deleteContact(final RecipientIdentifier.Single recipient) throws IOException {
throw new UnsupportedOperationException(); signal.deleteContact(recipient.getIdentifier());
} }
@Override @Override

View file

@ -387,6 +387,24 @@ public class DbusSignalImpl implements Signal {
} }
} }
@Override
public void deleteRecipient(final String recipient) throws Error.Failure {
try {
m.deleteRecipient(getSingleRecipientIdentifier(recipient, m.getSelfNumber()));
} catch (IOException e) {
throw new Error.Failure("Recipient not found");
}
}
@Override
public void deleteContact(final String recipient) throws Error.Failure {
try {
m.deleteContact(getSingleRecipientIdentifier(recipient, m.getSelfNumber()));
} catch (IOException e) {
throw new Error.Failure("Contact not found");
}
}
@Override @Override
public long sendGroupMessage(final String message, final List<String> attachments, final byte[] groupId) { public long sendGroupMessage(final String message, final List<String> attachments, final byte[] groupId) {
try { try {