org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content Java Examples
The following examples show how to use
org.whispersystems.signalservice.internal.push.SignalServiceProtos.Content.
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: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceVerifiedContent(VerifiedMessage verifiedMessage, byte[] nullMessage) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); Verified.Builder verifiedMessageBuilder = Verified.newBuilder(); verifiedMessageBuilder.setNullMessage(ByteString.copyFrom(nullMessage)); verifiedMessageBuilder.setIdentityKey(ByteString.copyFrom(verifiedMessage.getIdentityKey().serialize())); if (verifiedMessage.getDestination().getUuid().isPresent()) { verifiedMessageBuilder.setDestinationUuid(verifiedMessage.getDestination().getUuid().get().toString()); } if (verifiedMessage.getDestination().getNumber().isPresent()) { verifiedMessageBuilder.setDestinationE164(verifiedMessage.getDestination().getNumber().get()); } switch(verifiedMessage.getVerified()) { case DEFAULT: verifiedMessageBuilder.setState(Verified.State.DEFAULT); break; case VERIFIED: verifiedMessageBuilder.setState(Verified.State.VERIFIED); break; case UNVERIFIED: verifiedMessageBuilder.setState(Verified.State.UNVERIFIED); break; default: throw new AssertionError("Unknown: " + verifiedMessage.getVerified()); } syncMessage.setVerified(verifiedMessageBuilder); return container.setSyncMessage(syncMessage).build().toByteArray(); }
Example #2
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceVerifiedContent(VerifiedMessage verifiedMessage, byte[] nullMessage) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); Verified.Builder verifiedMessageBuilder = Verified.newBuilder(); verifiedMessageBuilder.setNullMessage(ByteString.copyFrom(nullMessage)); verifiedMessageBuilder.setIdentityKey(ByteString.copyFrom(verifiedMessage.getIdentityKey().serialize())); if (verifiedMessage.getDestination().getUuid().isPresent()) { verifiedMessageBuilder.setDestinationUuid(verifiedMessage.getDestination().getUuid().get().toString()); } if (verifiedMessage.getDestination().getNumber().isPresent()) { verifiedMessageBuilder.setDestinationE164(verifiedMessage.getDestination().getNumber().get()); } switch(verifiedMessage.getVerified()) { case DEFAULT: verifiedMessageBuilder.setState(Verified.State.DEFAULT); break; case VERIFIED: verifiedMessageBuilder.setState(Verified.State.VERIFIED); break; case UNVERIFIED: verifiedMessageBuilder.setState(Verified.State.UNVERIFIED); break; default: throw new AssertionError("Unknown: " + verifiedMessage.getVerified()); } syncMessage.setVerified(verifiedMessageBuilder); return container.setSyncMessage(syncMessage).build().toByteArray(); }
Example #3
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceFetchTypeContent(SignalServiceSyncMessage.FetchType fetchType) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.FetchLatest.Builder fetchMessage = SyncMessage.FetchLatest.newBuilder(); switch (fetchType) { case LOCAL_PROFILE: fetchMessage.setType(SyncMessage.FetchLatest.Type.LOCAL_PROFILE); break; case STORAGE_MANIFEST: fetchMessage.setType(SyncMessage.FetchLatest.Type.STORAGE_MANIFEST); break; default: Log.w(TAG, "Unknown fetch type!"); break; } return container.setSyncMessage(syncMessage.setFetchLatest(fetchMessage)).build().toByteArray(); }
Example #4
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceConfigurationContent(ConfigurationMessage configuration) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Configuration.Builder configurationMessage = SyncMessage.Configuration.newBuilder(); if (configuration.getReadReceipts().isPresent()) { configurationMessage.setReadReceipts(configuration.getReadReceipts().get()); } if (configuration.getUnidentifiedDeliveryIndicators().isPresent()) { configurationMessage.setUnidentifiedDeliveryIndicators(configuration.getUnidentifiedDeliveryIndicators().get()); } if (configuration.getTypingIndicators().isPresent()) { configurationMessage.setTypingIndicators(configuration.getTypingIndicators().get()); } if (configuration.getLinkPreviews().isPresent()) { configurationMessage.setLinkPreviews(configuration.getLinkPreviews().get()); } configurationMessage.setProvisioningVersion(ProvisioningProtos.ProvisioningVersion.CURRENT_VALUE); return container.setSyncMessage(syncMessage.setConfiguration(configurationMessage)).build().toByteArray(); }
Example #5
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceBlockedContent(BlockedListMessage blocked) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Blocked.Builder blockedMessage = SyncMessage.Blocked.newBuilder(); for (SignalServiceAddress address : blocked.getAddresses()) { if (address.getUuid().isPresent()) { blockedMessage.addUuids(address.getUuid().get().toString()); } if (address.getNumber().isPresent()) { blockedMessage.addNumbers(address.getNumber().get()); } } for (byte[] groupId : blocked.getGroupIds()) { blockedMessage.addGroupIds(ByteString.copyFrom(groupId)); } return container.setSyncMessage(syncMessage.setBlocked(blockedMessage)).build().toByteArray(); }
Example #6
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceViewOnceOpenContent(ViewOnceOpenMessage readMessage) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); SyncMessage.ViewOnceOpen.Builder viewOnceBuilder = SyncMessage.ViewOnceOpen.newBuilder().setTimestamp(readMessage.getTimestamp()); if (readMessage.getSender().getUuid().isPresent()) { viewOnceBuilder.setSenderUuid(readMessage.getSender().getUuid().get().toString()); } if (readMessage.getSender().getNumber().isPresent()) { viewOnceBuilder.setSenderE164(readMessage.getSender().getNumber().get()); } builder.setViewOnceOpen(viewOnceBuilder.build()); return container.setSyncMessage(builder).build().toByteArray(); }
Example #7
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceReadContent(List<ReadMessage> readMessages) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); for (ReadMessage readMessage : readMessages) { SyncMessage.Read.Builder readBuilder = SyncMessage.Read.newBuilder().setTimestamp(readMessage.getTimestamp()); if (readMessage.getSender().getUuid().isPresent()) { readBuilder.setSenderUuid(readMessage.getSender().getUuid().get().toString()); } if (readMessage.getSender().getNumber().isPresent()) { readBuilder.setSenderE164(readMessage.getSender().getNumber().get()); } builder.addRead(readBuilder.build()); } return container.setSyncMessage(builder).build().toByteArray(); }
Example #8
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private byte[] createTypingContent(SignalServiceTypingMessage message) { Content.Builder container = Content.newBuilder(); TypingMessage.Builder builder = TypingMessage.newBuilder(); builder.setTimestamp(message.getTimestamp()); if (message.isTypingStarted()) builder.setAction(TypingMessage.Action.STARTED); else if (message.isTypingStopped()) builder.setAction(TypingMessage.Action.STOPPED); else throw new IllegalArgumentException("Unknown typing indicator"); if (message.getGroupId().isPresent()) { builder.setGroupId(ByteString.copyFrom(message.getGroupId().get())); } return container.setTypingMessage(builder).build().toByteArray(); }
Example #9
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 6 votes |
private void sendMessage(VerifiedMessage message, Optional<UnidentifiedAccessPair> unidentifiedAccess) throws IOException, UntrustedIdentityException { byte[] nullMessageBody = DataMessage.newBuilder() .setBody(Base64.encodeBytes(Util.getRandomLengthBytes(140))) .build() .toByteArray(); NullMessage nullMessage = NullMessage.newBuilder() .setPadding(ByteString.copyFrom(nullMessageBody)) .build(); byte[] content = Content.newBuilder() .setNullMessage(nullMessage) .build() .toByteArray(); SendMessageResult result = sendMessage(message.getDestination(), getTargetUnidentifiedAccess(unidentifiedAccess), message.getTimestamp(), content, false); if (result.getSuccess().isNeedsSync()) { byte[] syncMessage = createMultiDeviceVerifiedContent(message, nullMessage.toByteArray()); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), message.getTimestamp(), syncMessage, false); } }
Example #10
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private void sendMessage(VerifiedMessage message, Optional<UnidentifiedAccessPair> unidentifiedAccess) throws IOException, UntrustedIdentityException { byte[] nullMessageBody = DataMessage.newBuilder() .setBody(Base64.encodeBytes(Util.getRandomLengthBytes(140))) .build() .toByteArray(); NullMessage nullMessage = NullMessage.newBuilder() .setPadding(ByteString.copyFrom(nullMessageBody)) .build(); byte[] content = Content.newBuilder() .setNullMessage(nullMessage) .build() .toByteArray(); SendMessageResult result = sendMessage(message.getDestination(), getTargetUnidentifiedAccess(unidentifiedAccess), message.getTimestamp(), content, false); if (result.getSuccess().isNeedsSync()) { byte[] syncMessage = createMultiDeviceVerifiedContent(message, nullMessage.toByteArray()); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), message.getTimestamp(), syncMessage, false); } }
Example #11
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceFetchTypeContent(SignalServiceSyncMessage.FetchType fetchType) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.FetchLatest.Builder fetchMessage = SyncMessage.FetchLatest.newBuilder(); switch (fetchType) { case LOCAL_PROFILE: fetchMessage.setType(SyncMessage.FetchLatest.Type.LOCAL_PROFILE); break; case STORAGE_MANIFEST: fetchMessage.setType(SyncMessage.FetchLatest.Type.STORAGE_MANIFEST); break; default: Log.w(TAG, "Unknown fetch type!"); break; } return container.setSyncMessage(syncMessage.setFetchLatest(fetchMessage)).build().toByteArray(); }
Example #12
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceConfigurationContent(ConfigurationMessage configuration) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Configuration.Builder configurationMessage = SyncMessage.Configuration.newBuilder(); if (configuration.getReadReceipts().isPresent()) { configurationMessage.setReadReceipts(configuration.getReadReceipts().get()); } if (configuration.getUnidentifiedDeliveryIndicators().isPresent()) { configurationMessage.setUnidentifiedDeliveryIndicators(configuration.getUnidentifiedDeliveryIndicators().get()); } if (configuration.getTypingIndicators().isPresent()) { configurationMessage.setTypingIndicators(configuration.getTypingIndicators().get()); } if (configuration.getLinkPreviews().isPresent()) { configurationMessage.setLinkPreviews(configuration.getLinkPreviews().get()); } configurationMessage.setProvisioningVersion(ProvisioningProtos.ProvisioningVersion.CURRENT_VALUE); return container.setSyncMessage(syncMessage.setConfiguration(configurationMessage)).build().toByteArray(); }
Example #13
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createTypingContent(SignalServiceTypingMessage message) { Content.Builder container = Content.newBuilder(); TypingMessage.Builder builder = TypingMessage.newBuilder(); builder.setTimestamp(message.getTimestamp()); if (message.isTypingStarted()) builder.setAction(TypingMessage.Action.STARTED); else if (message.isTypingStopped()) builder.setAction(TypingMessage.Action.STOPPED); else throw new IllegalArgumentException("Unknown typing indicator"); if (message.getGroupId().isPresent()) { builder.setGroupId(ByteString.copyFrom(message.getGroupId().get())); } return container.setTypingMessage(builder).build().toByteArray(); }
Example #14
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceReadContent(List<ReadMessage> readMessages) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); for (ReadMessage readMessage : readMessages) { SyncMessage.Read.Builder readBuilder = SyncMessage.Read.newBuilder().setTimestamp(readMessage.getTimestamp()); if (readMessage.getSender().getUuid().isPresent()) { readBuilder.setSenderUuid(readMessage.getSender().getUuid().get().toString()); } if (readMessage.getSender().getNumber().isPresent()) { readBuilder.setSenderE164(readMessage.getSender().getNumber().get()); } builder.addRead(readBuilder.build()); } return container.setSyncMessage(builder).build().toByteArray(); }
Example #15
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceViewOnceOpenContent(ViewOnceOpenMessage readMessage) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); SyncMessage.ViewOnceOpen.Builder viewOnceBuilder = SyncMessage.ViewOnceOpen.newBuilder().setTimestamp(readMessage.getTimestamp()); if (readMessage.getSender().getUuid().isPresent()) { viewOnceBuilder.setSenderUuid(readMessage.getSender().getUuid().get().toString()); } if (readMessage.getSender().getNumber().isPresent()) { viewOnceBuilder.setSenderE164(readMessage.getSender().getNumber().get()); } builder.setViewOnceOpen(viewOnceBuilder.build()); return container.setSyncMessage(builder).build().toByteArray(); }
Example #16
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private byte[] createMultiDeviceBlockedContent(BlockedListMessage blocked) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Blocked.Builder blockedMessage = SyncMessage.Blocked.newBuilder(); for (SignalServiceAddress address : blocked.getAddresses()) { if (address.getUuid().isPresent()) { blockedMessage.addUuids(address.getUuid().get().toString()); } if (address.getNumber().isPresent()) { blockedMessage.addNumbers(address.getNumber().get()); } } for (byte[] groupId : blocked.getGroupIds()) { blockedMessage.addGroupIds(ByteString.copyFrom(groupId)); } return container.setSyncMessage(syncMessage.setBlocked(blockedMessage)).build().toByteArray(); }
Example #17
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceSyncKeysContent(KeysMessage keysMessage) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Keys.Builder builder = SyncMessage.Keys.newBuilder(); if (keysMessage.getStorageService().isPresent()) { builder.setStorageService(ByteString.copyFrom(keysMessage.getStorageService().get().serialize())); } else { Log.w(TAG, "Invalid keys message!"); } return container.setSyncMessage(syncMessage.setKeys(builder)).build().toByteArray(); }
Example #18
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
private byte[] createReceiptContent(SignalServiceReceiptMessage message) { Content.Builder container = Content.newBuilder(); ReceiptMessage.Builder builder = ReceiptMessage.newBuilder(); for (long timestamp : message.getTimestamps()) { builder.addTimestamp(timestamp); } if (message.isDeliveryReceipt()) builder.setType(ReceiptMessage.Type.DELIVERY); else if (message.isReadReceipt()) builder.setType(ReceiptMessage.Type.READ); return container.setReceiptMessage(builder).build().toByteArray(); }
Example #19
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
private byte[] createCallContent(SignalServiceCallMessage callMessage) { Content.Builder container = Content.newBuilder(); CallMessage.Builder builder = CallMessage.newBuilder(); if (callMessage.getOfferMessage().isPresent()) { OfferMessage offer = callMessage.getOfferMessage().get(); builder.setOffer(CallMessage.Offer.newBuilder() .setId(offer.getId()) .setDescription(offer.getDescription())); } else if (callMessage.getAnswerMessage().isPresent()) { AnswerMessage answer = callMessage.getAnswerMessage().get(); builder.setAnswer(CallMessage.Answer.newBuilder() .setId(answer.getId()) .setDescription(answer.getDescription())); } else if (callMessage.getIceUpdateMessages().isPresent()) { List<IceUpdateMessage> updates = callMessage.getIceUpdateMessages().get(); for (IceUpdateMessage update : updates) { builder.addIceUpdate(CallMessage.IceUpdate.newBuilder() .setId(update.getId()) .setSdp(update.getSdp()) .setSdpMid(update.getSdpMid()) .setSdpMLineIndex(update.getSdpMLineIndex())); } } else if (callMessage.getHangupMessage().isPresent()) { builder.setHangup(CallMessage.Hangup.newBuilder().setId(callMessage.getHangupMessage().get().getId())); } else if (callMessage.getBusyMessage().isPresent()) { builder.setBusy(CallMessage.Busy.newBuilder().setId(callMessage.getBusyMessage().get().getId())); } container.setCallMessage(builder); return container.build().toByteArray(); }
Example #20
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceContactsContent(SignalServiceAttachmentStream contacts, boolean complete) throws IOException { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); builder.setContacts(SyncMessage.Contacts.newBuilder() .setBlob(createAttachmentPointer(contacts)) .setComplete(complete)); return container.setSyncMessage(builder).build().toByteArray(); }
Example #21
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceGroupsContent(SignalServiceAttachmentStream groups) throws IOException { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); builder.setGroups(SyncMessage.Groups.newBuilder() .setBlob(createAttachmentPointer(groups))); return container.setSyncMessage(builder).build().toByteArray(); }
Example #22
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceGroupsContent(SignalServiceAttachmentStream groups) throws IOException { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); builder.setGroups(SyncMessage.Groups.newBuilder() .setBlob(createAttachmentPointer(groups))); return container.setSyncMessage(builder).build().toByteArray(); }
Example #23
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceContactsContent(SignalServiceAttachmentStream contacts, boolean complete) throws IOException { Content.Builder container = Content.newBuilder(); SyncMessage.Builder builder = createSyncMessageBuilder(); builder.setContacts(SyncMessage.Contacts.newBuilder() .setBlob(createAttachmentPointer(contacts)) .setComplete(complete)); return container.setSyncMessage(builder).build().toByteArray(); }
Example #24
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceStickerPackOperationContent(List<StickerPackOperationMessage> stickerPackOperations) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); for (StickerPackOperationMessage stickerPackOperation : stickerPackOperations) { SyncMessage.StickerPackOperation.Builder builder = SyncMessage.StickerPackOperation.newBuilder(); if (stickerPackOperation.getPackId().isPresent()) { builder.setPackId(ByteString.copyFrom(stickerPackOperation.getPackId().get())); } if (stickerPackOperation.getPackKey().isPresent()) { builder.setPackKey(ByteString.copyFrom(stickerPackOperation.getPackKey().get())); } if (stickerPackOperation.getType().isPresent()) { switch (stickerPackOperation.getType().get()) { case INSTALL: builder.setType(SyncMessage.StickerPackOperation.Type.INSTALL); break; case REMOVE: builder.setType(SyncMessage.StickerPackOperation.Type.REMOVE); break; } } syncMessage.addStickerPackOperation(builder); } return container.setSyncMessage(syncMessage).build().toByteArray(); }
Example #25
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private byte[] createReceiptContent(SignalServiceReceiptMessage message) { Content.Builder container = Content.newBuilder(); ReceiptMessage.Builder builder = ReceiptMessage.newBuilder(); for (long timestamp : message.getTimestamps()) { builder.addTimestamp(timestamp); } if (message.isDeliveryReceipt()) builder.setType(ReceiptMessage.Type.DELIVERY); else if (message.isReadReceipt()) builder.setType(ReceiptMessage.Type.READ); return container.setReceiptMessage(builder).build().toByteArray(); }
Example #26
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private byte[] createMultiDeviceStickerPackOperationContent(List<StickerPackOperationMessage> stickerPackOperations) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); for (StickerPackOperationMessage stickerPackOperation : stickerPackOperations) { SyncMessage.StickerPackOperation.Builder builder = SyncMessage.StickerPackOperation.newBuilder(); if (stickerPackOperation.getPackId().isPresent()) { builder.setPackId(ByteString.copyFrom(stickerPackOperation.getPackId().get())); } if (stickerPackOperation.getPackKey().isPresent()) { builder.setPackKey(ByteString.copyFrom(stickerPackOperation.getPackKey().get())); } if (stickerPackOperation.getType().isPresent()) { switch (stickerPackOperation.getType().get()) { case INSTALL: builder.setType(SyncMessage.StickerPackOperation.Type.INSTALL); break; case REMOVE: builder.setType(SyncMessage.StickerPackOperation.Type.REMOVE); break; } } syncMessage.addStickerPackOperation(builder); } return container.setSyncMessage(syncMessage).build().toByteArray(); }
Example #27
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private byte[] createMultiDeviceMessageRequestResponseContent(MessageRequestResponseMessage message) { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.MessageRequestResponse.Builder responseMessage = SyncMessage.MessageRequestResponse.newBuilder(); if (message.getGroupId().isPresent()) { responseMessage.setGroupId(ByteString.copyFrom(message.getGroupId().get())); } if (message.getPerson().isPresent()) { if (message.getPerson().get().getNumber().isPresent()) { responseMessage.setThreadE164(message.getPerson().get().getNumber().get()); } if (message.getPerson().get().getUuid().isPresent()) { responseMessage.setThreadUuid(message.getPerson().get().getUuid().get().toString()); } } switch (message.getType()) { case ACCEPT: responseMessage.setType(SyncMessage.MessageRequestResponse.Type.ACCEPT); break; case DELETE: responseMessage.setType(SyncMessage.MessageRequestResponse.Type.DELETE); break; case BLOCK: responseMessage.setType(SyncMessage.MessageRequestResponse.Type.BLOCK); break; case BLOCK_AND_DELETE: responseMessage.setType(SyncMessage.MessageRequestResponse.Type.BLOCK_AND_DELETE); break; default: Log.w(TAG, "Unknown type!"); responseMessage.setType(SyncMessage.MessageRequestResponse.Type.UNKNOWN); break; } syncMessage.setMessageRequestResponse(responseMessage); return container.setSyncMessage(syncMessage).build().toByteArray(); }
Example #28
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 4 votes |
private byte[] createMultiDeviceSentTranscriptContent(byte[] content, Optional<SignalServiceAddress> recipient, long timestamp, List<SendMessageResult> sendMessageResults, boolean isRecipientUpdate) { try { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Sent.Builder sentMessage = SyncMessage.Sent.newBuilder(); DataMessage dataMessage = Content.parseFrom(content).getDataMessage(); sentMessage.setTimestamp(timestamp); sentMessage.setMessage(dataMessage); for (SendMessageResult result : sendMessageResults) { if (result.getSuccess() != null) { SyncMessage.Sent.UnidentifiedDeliveryStatus.Builder builder = SyncMessage.Sent.UnidentifiedDeliveryStatus.newBuilder(); if (result.getAddress().getUuid().isPresent()) { builder = builder.setDestinationUuid(result.getAddress().getUuid().get().toString()); } if (result.getAddress().getNumber().isPresent()) { builder = builder.setDestinationE164(result.getAddress().getNumber().get()); } builder.setUnidentified(result.getSuccess().isUnidentified()); sentMessage.addUnidentifiedStatus(builder.build()); } } if (recipient.isPresent()) { if (recipient.get().getUuid().isPresent()) sentMessage.setDestinationUuid(recipient.get().getUuid().get().toString()); if (recipient.get().getNumber().isPresent()) sentMessage.setDestinationE164(recipient.get().getNumber().get()); } if (dataMessage.getExpireTimer() > 0) { sentMessage.setExpirationStartTimestamp(System.currentTimeMillis()); } if (dataMessage.getIsViewOnce()) { dataMessage = dataMessage.toBuilder().clearAttachments().build(); sentMessage.setMessage(dataMessage); } sentMessage.setIsRecipientUpdate(isRecipientUpdate); return container.setSyncMessage(syncMessage.setSent(sentMessage)).build().toByteArray(); } catch (InvalidProtocolBufferException e) { throw new AssertionError(e); } }
Example #29
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private byte[] createMultiDeviceSentTranscriptContent(byte[] content, Optional<SignalServiceAddress> recipient, long timestamp, List<SendMessageResult> sendMessageResults, boolean isRecipientUpdate) { try { Content.Builder container = Content.newBuilder(); SyncMessage.Builder syncMessage = createSyncMessageBuilder(); SyncMessage.Sent.Builder sentMessage = SyncMessage.Sent.newBuilder(); DataMessage dataMessage = Content.parseFrom(content).getDataMessage(); sentMessage.setTimestamp(timestamp); sentMessage.setMessage(dataMessage); for (SendMessageResult result : sendMessageResults) { if (result.getSuccess() != null) { SyncMessage.Sent.UnidentifiedDeliveryStatus.Builder builder = SyncMessage.Sent.UnidentifiedDeliveryStatus.newBuilder(); if (result.getAddress().getUuid().isPresent()) { builder = builder.setDestinationUuid(result.getAddress().getUuid().get().toString()); } if (result.getAddress().getNumber().isPresent()) { builder = builder.setDestinationE164(result.getAddress().getNumber().get()); } builder.setUnidentified(result.getSuccess().isUnidentified()); sentMessage.addUnidentifiedStatus(builder.build()); } } if (recipient.isPresent()) { if (recipient.get().getUuid().isPresent()) sentMessage.setDestinationUuid(recipient.get().getUuid().get().toString()); if (recipient.get().getNumber().isPresent()) sentMessage.setDestinationE164(recipient.get().getNumber().get()); } if (dataMessage.getExpireTimer() > 0) { sentMessage.setExpirationStartTimestamp(System.currentTimeMillis()); } if (dataMessage.getIsViewOnce()) { dataMessage = dataMessage.toBuilder().clearAttachments().build(); sentMessage.setMessage(dataMessage); } sentMessage.setIsRecipientUpdate(isRecipientUpdate); return container.setSyncMessage(syncMessage.setSent(sentMessage)).build().toByteArray(); } catch (InvalidProtocolBufferException e) { throw new AssertionError(e); } }
Example #30
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private byte[] createCallContent(SignalServiceCallMessage callMessage) { Content.Builder container = Content.newBuilder(); CallMessage.Builder builder = CallMessage.newBuilder(); if (callMessage.getOfferMessage().isPresent()) { OfferMessage offer = callMessage.getOfferMessage().get(); builder.setOffer(CallMessage.Offer.newBuilder() .setId(offer.getId()) .setDescription(offer.getDescription()) .setType(offer.getType().getProtoType())); } else if (callMessage.getAnswerMessage().isPresent()) { AnswerMessage answer = callMessage.getAnswerMessage().get(); builder.setAnswer(CallMessage.Answer.newBuilder() .setId(answer.getId()) .setDescription(answer.getDescription())); } else if (callMessage.getIceUpdateMessages().isPresent()) { List<IceUpdateMessage> updates = callMessage.getIceUpdateMessages().get(); for (IceUpdateMessage update : updates) { builder.addIceUpdate(CallMessage.IceUpdate.newBuilder() .setId(update.getId()) .setSdp(update.getSdp()) .setSdpMid(update.getSdpMid()) .setSdpMLineIndex(update.getSdpMLineIndex())); } } else if (callMessage.getHangupMessage().isPresent()) { CallMessage.Hangup.Type protoType = callMessage.getHangupMessage().get().getType().getProtoType(); CallMessage.Hangup.Builder builderForHangup = CallMessage.Hangup.newBuilder() .setType(protoType) .setId(callMessage.getHangupMessage().get().getId()); if (protoType != CallMessage.Hangup.Type.HANGUP_NORMAL) { builderForHangup.setDeviceId(callMessage.getHangupMessage().get().getDeviceId()); } if (callMessage.getHangupMessage().get().isLegacy()) { builder.setLegacyHangup(builderForHangup); } else { builder.setHangup(builderForHangup); } } else if (callMessage.getBusyMessage().isPresent()) { builder.setBusy(CallMessage.Busy.newBuilder().setId(callMessage.getBusyMessage().get().getId())); } builder.setMultiRing(callMessage.isMultiRing()); if (callMessage.getDestinationDeviceId().isPresent()) { builder.setDestinationDeviceId(callMessage.getDestinationDeviceId().get()); } container.setCallMessage(builder); return container.build().toByteArray(); }