mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-07 14:30:38 +00:00
create new DbusAttachment type allow URLs for --attachment option update manpage update wiki with signalmail implement setExpirationTimer() for DBus implement isRegistered() for DBus add sendNoteToSelfMessageWithDBusAttachments add sendGroupMessageWithDBusAttachments add sendMessageWithDBusAttachments bump version
This commit is contained in:
parent
8f781c019f
commit
8aed357994
18 changed files with 526 additions and 49 deletions
|
@ -2,6 +2,8 @@ package org.asamk.signal.dbus;
|
|||
|
||||
import org.asamk.Signal;
|
||||
import org.asamk.signal.BaseConfig;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.dbus.DbusAttachment;
|
||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
||||
|
@ -52,10 +54,36 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long sendMessage(final String message, final List<String> attachments, final String recipient) {
|
||||
public long sendMessageWithDBusAttachments(final String message, final List<DbusAttachment> dBusAttachments, final String recipient) {
|
||||
var recipients = new ArrayList<String>(1);
|
||||
recipients.add(recipient);
|
||||
return sendMessage(message, attachments, recipients);
|
||||
return sendMessageWithDBusAttachments(message, dBusAttachments, recipients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long sendMessageWithDBusAttachments(final String message, final List<DbusAttachment> dBusAttachments, final List<String> recipients) {
|
||||
try {
|
||||
ArrayList<String> attachmentNames = new ArrayList<>();
|
||||
for (var dBusAttachment : dBusAttachments) {
|
||||
attachmentNames.add(dBusAttachment.getFileName());
|
||||
}
|
||||
final var results = m.sendMessage(message, attachmentNames, recipients);
|
||||
checkSendMessageResults(results.first(), results.second());
|
||||
return results.first();
|
||||
} catch (InvalidNumberException e) {
|
||||
throw new Error.InvalidNumber(e.getMessage());
|
||||
} catch (AttachmentInvalidException e) {
|
||||
throw new Error.AttachmentInvalid(e.getMessage());
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long sendMessage(final String message, final List<String> attachmentNames, final String recipient) {
|
||||
var recipients = new ArrayList<String>(1);
|
||||
recipients.add(recipient);
|
||||
return sendMessage(message, attachmentNames, recipients);
|
||||
}
|
||||
|
||||
private static void checkSendMessageResult(long timestamp, SendMessageResult result) throws DBusExecutionException {
|
||||
|
@ -98,9 +126,9 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long sendMessage(final String message, final List<String> attachments, final List<String> recipients) {
|
||||
public long sendMessage(final String message, final List<String> attachmentNames, final List<String> recipients) {
|
||||
try {
|
||||
final var results = m.sendMessage(message, attachments, recipients);
|
||||
final var results = m.sendMessage(message, attachmentNames, recipients);
|
||||
checkSendMessageResults(results.first(), results.second());
|
||||
return results.first();
|
||||
} catch (InvalidNumberException e) {
|
||||
|
@ -185,10 +213,10 @@ public class DbusSignalImpl implements Signal {
|
|||
|
||||
@Override
|
||||
public long sendNoteToSelfMessage(
|
||||
final String message, final List<String> attachments
|
||||
final String message, final List<String> attachmentNames
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.UntrustedIdentity {
|
||||
try {
|
||||
final var results = m.sendSelfMessage(message, attachments);
|
||||
final var results = m.sendSelfMessage(message, attachmentNames);
|
||||
checkSendMessageResult(results.first(), results.second());
|
||||
return results.first();
|
||||
} catch (AttachmentInvalidException e) {
|
||||
|
@ -198,6 +226,25 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long sendNoteToSelfMessageWithDBusAttachments(
|
||||
final String message, final List<DbusAttachment> dBusAttachments
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.UntrustedIdentity {
|
||||
try {
|
||||
ArrayList<String> attachmentNames = new ArrayList<>();
|
||||
for (var dBusAttachment : dBusAttachments) {
|
||||
attachmentNames.add(dBusAttachment.getFileName());
|
||||
}
|
||||
final var results = m.sendSelfMessage(message, attachmentNames);
|
||||
checkSendMessageResult(results.first(), results.second());
|
||||
return results.first();
|
||||
} catch (AttachmentInvalidException e) {
|
||||
throw new Error.AttachmentInvalid(e.getMessage());
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEndSessionMessage(final List<String> recipients) {
|
||||
try {
|
||||
|
@ -211,9 +258,9 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long sendGroupMessage(final String message, final List<String> attachments, final byte[] groupId) {
|
||||
public long sendGroupMessage(final String message, final List<String> attachmentNames, final byte[] groupId) {
|
||||
try {
|
||||
var results = m.sendGroupMessage(message, attachments, GroupId.unknownVersion(groupId));
|
||||
var results = m.sendGroupMessage(message, attachmentNames, GroupId.unknownVersion(groupId));
|
||||
checkSendMessageResults(results.first(), results.second());
|
||||
return results.first();
|
||||
} catch (IOException e) {
|
||||
|
@ -225,6 +272,26 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long sendGroupMessageWithDBusAttachments(final String message, final List<DbusAttachment> dBusAttachments, final byte[] groupId) {
|
||||
try {
|
||||
ArrayList<String> attachmentNames = new ArrayList<>();
|
||||
for (var dBusAttachment : dBusAttachments) {
|
||||
attachmentNames.add(dBusAttachment.getFileName());
|
||||
}
|
||||
var results = m.sendGroupMessage(message, attachmentNames, GroupId.unknownVersion(groupId));
|
||||
checkSendMessageResults(results.first(), results.second());
|
||||
return results.first();
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (GroupNotFoundException | NotAGroupMemberException e) {
|
||||
throw new Error.GroupNotFound(e.getMessage());
|
||||
} catch (AttachmentInvalidException e) {
|
||||
throw new Error.AttachmentInvalid(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long sendGroupMessageReaction(
|
||||
final String emoji,
|
||||
|
@ -272,6 +339,17 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpirationTimer(final String number, final int expiration) {
|
||||
try {
|
||||
m.setExpirationTimer(number, expiration);
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (InvalidNumberException e) {
|
||||
throw new Error.InvalidNumber(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContactBlocked(final String number, final boolean blocked) {
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue