Add a new sync dbus message which shows messages you sent. Necessary for having synchronized chats where you want your message to appear. Format is similar to receive message dbus except instead of sender, it has sender (source) and receiver (destination). (#289)

This commit is contained in:
narodnik 2020-04-03 13:16:57 +02:00 committed by GitHub
parent e684a902bb
commit d49d536c32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 114 additions and 22 deletions

View file

@ -53,7 +53,22 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
});
dbusconnection.addSigHandler(Signal.ReceiptReceived.class,
receiptReceived -> System.out.print(String.format("Receipt from: %s\nTimestamp: %s\n",
receiptReceived.getSender(), DateUtils.formatTimestamp(receiptReceived.getTimestamp()))));
receiptReceived.getSender(), DateUtils.formatTimestamp(receiptReceived.getTimestamp()))));
dbusconnection.addSigHandler(Signal.SyncMessageReceived.class, syncReceived -> {
System.out.print(String.format("Sync Envelope from: %s to: %s\nTimestamp: %s\nBody: %s\n",
syncReceived.getSource(), syncReceived.getDestination(), DateUtils.formatTimestamp(syncReceived.getTimestamp()), syncReceived.getMessage()));
if (syncReceived.getGroupId().length > 0) {
System.out.println("Group info:");
System.out.println(" Id: " + Base64.encodeBytes(syncReceived.getGroupId()));
}
if (syncReceived.getAttachments().size() > 0) {
System.out.println("Attachments: ");
for (String attachment : syncReceived.getAttachments()) {
System.out.println("- Stored plaintext in: " + attachment);
}
}
System.out.println();
});
} catch (UnsatisfiedLinkError e) {
System.err.println("Missing native library dependency for dbus service: " + e.getMessage());
return 1;