mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
parent
ee1e52aa4c
commit
804949ddea
2 changed files with 37 additions and 1 deletions
|
@ -65,4 +65,23 @@ public interface Signal extends DBusInterface {
|
|||
return attachments;
|
||||
}
|
||||
}
|
||||
|
||||
class ReceiptReceived extends DBusSignal {
|
||||
private long timestamp;
|
||||
private String sender;
|
||||
|
||||
public ReceiptReceived(String objectpath, long timestamp, String sender) throws DBusException {
|
||||
super(objectpath, timestamp, sender);
|
||||
this.timestamp = timestamp;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -397,6 +397,13 @@ public class Main {
|
|||
System.out.println();
|
||||
}
|
||||
});
|
||||
dBusConn.addSigHandler(Signal.ReceiptReceived.class, new DBusSigHandler<Signal.ReceiptReceived>() {
|
||||
@Override
|
||||
public void handle(Signal.ReceiptReceived s) {
|
||||
System.out.print(String.format("Receipt from: %s\nTimestamp: %s\n",
|
||||
s.getSender(), formatTimestamp(s.getTimestamp())));
|
||||
}
|
||||
});
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Missing native library dependency for dbus service: " + e.getMessage());
|
||||
return 1;
|
||||
|
@ -1098,7 +1105,17 @@ public class Main {
|
|||
public void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception) {
|
||||
super.handleMessage(envelope, content, exception);
|
||||
|
||||
if (!envelope.isReceipt() && content != null && content.getDataMessage().isPresent()) {
|
||||
if (envelope.isReceipt()) {
|
||||
try {
|
||||
conn.sendSignal(new Signal.ReceiptReceived(
|
||||
SIGNAL_OBJECTPATH,
|
||||
envelope.getTimestamp(),
|
||||
envelope.getSource()
|
||||
));
|
||||
} catch (DBusException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (content != null && content.getDataMessage().isPresent()) {
|
||||
SignalServiceDataMessage message = content.getDataMessage().get();
|
||||
|
||||
if (!message.isEndSession() &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue