Java Code Examples for org.whispersystems.signalservice.api.messages.SignalServiceEnvelope#getUuid()

The following examples show how to use org.whispersystems.signalservice.api.messages.SignalServiceEnvelope#getUuid() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From signal-cli with GNU General Public License v3.0 5 votes vote down vote up
static void storeEnvelope(SignalServiceEnvelope envelope, File file) throws IOException {
    try (FileOutputStream f = new FileOutputStream(file)) {
        try (DataOutputStream out = new DataOutputStream(f)) {
            out.writeInt(3); // version
            out.writeInt(envelope.getType());
            out.writeUTF(envelope.getSourceE164().isPresent() ? envelope.getSourceE164().get() : "");
            out.writeUTF(envelope.getSourceUuid().isPresent() ? envelope.getSourceUuid().get() : "");
            out.writeInt(envelope.getSourceDevice());
            out.writeLong(envelope.getTimestamp());
            if (envelope.hasContent()) {
                out.writeInt(envelope.getContent().length);
                out.write(envelope.getContent());
            } else {
                out.writeInt(0);
            }
            if (envelope.hasLegacyMessage()) {
                out.writeInt(envelope.getLegacyMessage().length);
                out.write(envelope.getLegacyMessage());
            } else {
                out.writeInt(0);
            }
            out.writeLong(envelope.getServerTimestamp());
            String uuid = envelope.getUuid();
            out.writeUTF(uuid == null ? "" : uuid);
        }
    }
}
 
Example 2
Source File: JsonMessageEnvelope.java    From signald with GNU General Public License v3.0 4 votes vote down vote up
public JsonMessageEnvelope(SignalServiceEnvelope envelope, SignalServiceContent c, String username) throws IOException, NoSuchAccountException {
    SignalServiceAddress sourceAddress = envelope.getSourceAddress();
    this.username = username;

    if (envelope.hasUuid()) {
        uuid = envelope.getUuid();
    }

    if (envelope.hasSource()) {
        source = sourceAddress.getNumber();
    } else if(c != null) {
        source = c.getSender();
    }

    if (envelope.hasSourceDevice()) {
        sourceDevice = envelope.getSourceDevice();
    }

    type = envelope.getType();

    if (sourceAddress.getRelay().isPresent()) {
        relay = sourceAddress.getRelay().get();
    }

    timestamp = envelope.getTimestamp();
    timestampISO = formatTimestampISO(envelope.getTimestamp());
    serverTimestamp = envelope.getServerTimestamp();
    hasLegacyMessage = envelope.hasLegacyMessage();
    hasContent = envelope.hasContent();
    isReceipt = envelope.isReceipt();

    if (c != null) {
        if (c.getDataMessage().isPresent()) {
            this.dataMessage = new JsonDataMessage(c.getDataMessage().get(), username);
        }

        if (c.getSyncMessage().isPresent()) {
            this.syncMessage = new JsonSyncMessage(c.getSyncMessage().get(), username);
        }

        if (c.getCallMessage().isPresent()) {
            this.callMessage = new JsonCallMessage(c.getCallMessage().get());
        }

        if (c.getReceiptMessage().isPresent()) {
            this.receipt = new JsonReceiptMessage(c.getReceiptMessage().get());
        }

        if (c.getTypingMessage().isPresent()) {
            this.typing = new JsonTypingMessage(c.getTypingMessage().get());
        }
    }
    isUnidentifiedSender = envelope.isUnidentifiedSender();
}