org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage Java Examples
The following examples show how to use
org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage.
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[] 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 #2
Source File: JsonSyncMessage.java From signal-cli with GNU General Public License v3.0 | 6 votes |
JsonSyncMessage(SignalServiceSyncMessage syncMessage) { if (syncMessage.getSent().isPresent()) { this.sentMessage = new JsonSyncDataMessage(syncMessage.getSent().get()); } if (syncMessage.getBlockedList().isPresent()) { this.blockedNumbers = new ArrayList<>(syncMessage.getBlockedList().get().getAddresses().size()); for (SignalServiceAddress address : syncMessage.getBlockedList().get().getAddresses()) { this.blockedNumbers.add(address.getNumber().get()); } } if (syncMessage.getRead().isPresent()) { this.readMessages = syncMessage.getRead().get(); } if (syncMessage.getContacts().isPresent()) { this.type = JsonSyncMessageType.CONTACTS_SYNC; } else if (syncMessage.getGroups().isPresent()) { this.type = JsonSyncMessageType.GROUPS_SYNC; } else if (syncMessage.getRequest().isPresent()) { this.type = JsonSyncMessageType.REQUEST_SYNC; } }
Example #3
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 6 votes |
private SendMessageResult sendSelfMessage(SignalServiceDataMessage message) throws IOException { SignalServiceMessageSender messageSender = getMessageSender(); SignalServiceAddress recipient = account.getSelfAddress(); final Optional<UnidentifiedAccessPair> unidentifiedAccess = getAccessFor(recipient); SentTranscriptMessage transcript = new SentTranscriptMessage(Optional.of(recipient), message.getTimestamp(), message, message.getExpiresInSeconds(), Collections.singletonMap(recipient, unidentifiedAccess.isPresent()), false); SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forSentTranscript(transcript); try { messageSender.sendMessage(syncMessage, unidentifiedAccess); return SendMessageResult.success(recipient, unidentifiedAccess.isPresent(), false); } catch (UntrustedIdentityException e) { account.getSignalProtocolStore().saveIdentity(resolveSignalServiceAddress(e.getIdentifier()), e.getIdentityKey(), TrustLevel.UNTRUSTED); return SendMessageResult.identityFailure(recipient, e.getIdentityKey()); } }
Example #4
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 #5
Source File: MultiDeviceReadUpdateJob.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device..."); return; } List<ReadMessage> readMessages = new LinkedList<>(); for (SerializableSyncMessageId messageId : messageIds) { Recipient recipient = Recipient.resolved(RecipientId.from(messageId.recipientId)); readMessages.add(new ReadMessage(RecipientUtil.toSignalServiceAddress(context, recipient), messageId.timestamp)); } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); messageSender.sendMessage(SignalServiceSyncMessage.forRead(readMessages), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example #6
Source File: MultiDeviceStickerPackOperationJob.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override protected void onRun() throws Exception { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device, aborting..."); return; } byte[] packIdBytes = Hex.fromStringCondensed(packId); byte[] packKeyBytes = Hex.fromStringCondensed(packKey); StickerPackOperationMessage.Type remoteType; switch (type) { case INSTALL: remoteType = StickerPackOperationMessage.Type.INSTALL; break; case REMOVE: remoteType = StickerPackOperationMessage.Type.REMOVE; break; default: throw new AssertionError("No matching type?"); } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); StickerPackOperationMessage stickerPackOperation = new StickerPackOperationMessage(packIdBytes, packKeyBytes, remoteType); messageSender.sendMessage(SignalServiceSyncMessage.forStickerPackOperations(Collections.singletonList(stickerPackOperation)), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example #7
Source File: MultiDeviceMessageRequestResponseJob.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device, aborting..."); return; } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); Recipient recipient = Recipient.resolved(threadRecipient); MessageRequestResponseMessage response; if (recipient.isGroup()) { response = MessageRequestResponseMessage.forGroup(recipient.getGroupId().get().getDecodedId(), localToRemoteType(type)); } else { response = MessageRequestResponseMessage.forIndividual(RecipientUtil.toSignalServiceAddress(context, recipient), localToRemoteType(type)); } messageSender.sendMessage(SignalServiceSyncMessage.forMessageRequestResponse(response), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example #8
Source File: MultiDeviceContactUpdateJob.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile, boolean complete) throws IOException, UntrustedIdentityException, NetworkException { if (contactsFile.length() > 0) { FileInputStream contactsFileStream = new FileInputStream(contactsFile); SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder() .withStream(contactsFileStream) .withContentType("application/octet-stream") .withLength(contactsFile.length()) .build(); try { messageSender.sendMessage(SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, complete)), UnidentifiedAccessUtil.getAccessForSync(context)); } catch (IOException ioe) { throw new NetworkException(ioe); } } }
Example #9
Source File: MultiDeviceVerifiedUpdateJob.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { try { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device..."); return; } if (destination == null) { Log.w(TAG, "No destination..."); return; } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); Recipient recipient = Recipient.resolved(destination); VerifiedMessage.VerifiedState verifiedState = getVerifiedState(verifiedStatus); SignalServiceAddress verifiedAddress = RecipientUtil.toSignalServiceAddress(context, recipient); VerifiedMessage verifiedMessage = new VerifiedMessage(verifiedAddress, new IdentityKey(identityKey, 0), verifiedState, timestamp); messageSender.sendMessage(SignalServiceSyncMessage.forVerified(verifiedMessage), UnidentifiedAccessUtil.getAccessFor(context, recipient)); } catch (InvalidKeyException e) { throw new IOException(e); } }
Example #10
Source File: MultiDeviceStickerPackSyncJob.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override protected void onRun() throws Exception { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device, aborting..."); return; } List<StickerPackOperationMessage> operations = new LinkedList<>(); try (StickerPackRecordReader reader = new StickerPackRecordReader(DatabaseFactory.getStickerDatabase(context).getInstalledStickerPacks())) { StickerPackRecord pack; while ((pack = reader.getNext()) != null) { byte[] packIdBytes = Hex.fromStringCondensed(pack.getPackId()); byte[] packKeyBytes = Hex.fromStringCondensed(pack.getPackKey()); operations.add(new StickerPackOperationMessage(packIdBytes, packKeyBytes, StickerPackOperationMessage.Type.INSTALL)); } } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); messageSender.sendMessage(SignalServiceSyncMessage.forStickerPackOperations(operations), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example #11
Source File: MultiDeviceConfigurationUpdateJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device, aborting..."); return; } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); messageSender.sendMessage(SignalServiceSyncMessage.forConfiguration(new ConfigurationMessage(Optional.of(readReceiptsEnabled), Optional.of(unidentifiedDeliveryIndicatorsEnabled), Optional.of(typingIndicatorsEnabled), Optional.of(linkPreviewsEnabled))), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example #12
Source File: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public void sendMessage(SignalServiceSyncMessage message, Optional<UnidentifiedAccessPair> unidentifiedAccess) throws IOException, UntrustedIdentityException { byte[] content; if (message.getContacts().isPresent()) { content = createMultiDeviceContactsContent(message.getContacts().get().getContactsStream().asStream(), message.getContacts().get().isComplete()); } else if (message.getGroups().isPresent()) { content = createMultiDeviceGroupsContent(message.getGroups().get().asStream()); } else if (message.getRead().isPresent()) { content = createMultiDeviceReadContent(message.getRead().get()); } else if (message.getViewOnceOpen().isPresent()) { content = createMultiDeviceViewOnceOpenContent(message.getViewOnceOpen().get()); } else if (message.getBlockedList().isPresent()) { content = createMultiDeviceBlockedContent(message.getBlockedList().get()); } else if (message.getConfiguration().isPresent()) { content = createMultiDeviceConfigurationContent(message.getConfiguration().get()); } else if (message.getSent().isPresent()) { content = createMultiDeviceSentTranscriptContent(message.getSent().get(), unidentifiedAccess); } else if (message.getStickerPackOperations().isPresent()) { content = createMultiDeviceStickerPackOperationContent(message.getStickerPackOperations().get()); } else if (message.getFetchType().isPresent()) { content = createMultiDeviceFetchTypeContent(message.getFetchType().get()); } else if (message.getMessageRequestResponse().isPresent()) { content = createMultiDeviceMessageRequestResponseContent(message.getMessageRequestResponse().get()); } else if (message.getKeys().isPresent()) { content = createMultiDeviceSyncKeysContent(message.getKeys().get()); } else if (message.getVerified().isPresent()) { sendMessage(message.getVerified().get(), unidentifiedAccess); return; } else { throw new IOException("Unsupported sync message!"); } long timestamp = message.getSent().isPresent() ? message.getSent().get().getTimestamp() : System.currentTimeMillis(); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), timestamp, content, false); }
Example #13
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
void sendGroups() throws IOException, UntrustedIdentityException { File groupsFile = IOUtils.createTempFile(); try { try (OutputStream fos = new FileOutputStream(groupsFile)) { DeviceGroupsOutputStream out = new DeviceGroupsOutputStream(fos); for (GroupInfo record : account.getGroupStore().getGroups()) { out.write(new DeviceGroup(record.groupId, Optional.fromNullable(record.name), new ArrayList<>(record.getMembers()), createGroupAvatarAttachment(record.groupId), record.isMember(account.getSelfAddress()), Optional.of(record.messageExpirationTime), Optional.fromNullable(record.color), record.blocked, Optional.fromNullable(record.inboxPosition), record.archived)); } } if (groupsFile.exists() && groupsFile.length() > 0) { try (FileInputStream groupsFileStream = new FileInputStream(groupsFile)) { SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder() .withStream(groupsFileStream) .withContentType("application/octet-stream") .withLength(groupsFile.length()) .build(); sendSyncMessage(SignalServiceSyncMessage.forGroups(attachmentStream)); } } } finally { try { Files.delete(groupsFile.toPath()); } catch (IOException e) { System.err.println("Failed to delete groups temp file “" + groupsFile + "”: " + e.getMessage()); } } }
Example #14
Source File: SignalServiceContent.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private SignalServiceContent(SignalServiceSyncMessage synchronizeMessage, SignalServiceAddress sender, int senderDevice, long timestamp, long serverTimestamp, boolean needsReceipt, SignalServiceContentProto serializedState) { this.sender = sender; this.senderDevice = senderDevice; this.timestamp = timestamp; this.serverTimestamp = serverTimestamp; this.needsReceipt = needsReceipt; this.serializedState = serializedState; this.message = Optional.absent(); this.synchronizeMessage = Optional.fromNullable(synchronizeMessage); this.callMessage = Optional.absent(); this.readMessage = Optional.absent(); this.typingMessage = Optional.absent(); }
Example #15
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
private void sendSyncMessage(SignalServiceSyncMessage message) throws IOException, UntrustedIdentityException { SignalServiceMessageSender messageSender = getMessageSender(); try { messageSender.sendMessage(message, getAccessForSync()); } catch (UntrustedIdentityException e) { account.getSignalProtocolStore().saveIdentity(resolveSignalServiceAddress(e.getIdentifier()), e.getIdentityKey(), TrustLevel.UNTRUSTED); throw e; } }
Example #16
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
void requestSyncConfiguration() throws IOException { SignalServiceProtos.SyncMessage.Request r = SignalServiceProtos.SyncMessage.Request.newBuilder().setType(SignalServiceProtos.SyncMessage.Request.Type.CONFIGURATION).build(); SignalServiceSyncMessage message = SignalServiceSyncMessage.forRequest(new RequestMessage(r)); try { sendSyncMessage(message); } catch (UntrustedIdentityException e) { e.printStackTrace(); } }
Example #17
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
void requestSyncBlocked() throws IOException { SignalServiceProtos.SyncMessage.Request r = SignalServiceProtos.SyncMessage.Request.newBuilder().setType(SignalServiceProtos.SyncMessage.Request.Type.BLOCKED).build(); SignalServiceSyncMessage message = SignalServiceSyncMessage.forRequest(new RequestMessage(r)); try { sendSyncMessage(message); } catch (UntrustedIdentityException e) { e.printStackTrace(); } }
Example #18
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
void requestSyncContacts() throws IOException { SignalServiceProtos.SyncMessage.Request r = SignalServiceProtos.SyncMessage.Request.newBuilder().setType(SignalServiceProtos.SyncMessage.Request.Type.CONTACTS).build(); SignalServiceSyncMessage message = SignalServiceSyncMessage.forRequest(new RequestMessage(r)); try { sendSyncMessage(message); } catch (UntrustedIdentityException e) { e.printStackTrace(); } }
Example #19
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
void requestSyncGroups() throws IOException { SignalServiceProtos.SyncMessage.Request r = SignalServiceProtos.SyncMessage.Request.newBuilder().setType(SignalServiceProtos.SyncMessage.Request.Type.GROUPS).build(); SignalServiceSyncMessage message = SignalServiceSyncMessage.forRequest(new RequestMessage(r)); try { sendSyncMessage(message); } catch (UntrustedIdentityException e) { e.printStackTrace(); } }
Example #20
Source File: SignalServiceContent.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
public SignalServiceContent(SignalServiceSyncMessage synchronizeMessage, SignalServiceAddress sender, int senderDevice, long timestamp, boolean needsReceipt) { this.sender = sender; this.senderDevice = senderDevice; this.timestamp = timestamp; this.needsReceipt = needsReceipt; this.message = Optional.absent(); this.synchronizeMessage = Optional.fromNullable(synchronizeMessage); this.callMessage = Optional.absent(); this.readMessage = Optional.absent(); this.typingMessage = Optional.absent(); }
Example #21
Source File: SignalServiceMessageSender.java From libsignal-service-java with GNU General Public License v3.0 | 5 votes |
public void sendMessage(SignalServiceSyncMessage message, Optional<UnidentifiedAccessPair> unidentifiedAccess) throws IOException, UntrustedIdentityException { byte[] content; if (message.getContacts().isPresent()) { content = createMultiDeviceContactsContent(message.getContacts().get().getContactsStream().asStream(), message.getContacts().get().isComplete()); } else if (message.getGroups().isPresent()) { content = createMultiDeviceGroupsContent(message.getGroups().get().asStream()); } else if (message.getRead().isPresent()) { content = createMultiDeviceReadContent(message.getRead().get()); } else if (message.getViewOnceOpen().isPresent()) { content = createMultiDeviceViewOnceOpenContent(message.getViewOnceOpen().get()); } else if (message.getBlockedList().isPresent()) { content = createMultiDeviceBlockedContent(message.getBlockedList().get()); } else if (message.getConfiguration().isPresent()) { content = createMultiDeviceConfigurationContent(message.getConfiguration().get()); } else if (message.getSent().isPresent()) { content = createMultiDeviceSentTranscriptContent(message.getSent().get(), unidentifiedAccess); } else if (message.getStickerPackOperations().isPresent()) { content = createMultiDeviceStickerPackOperationContent(message.getStickerPackOperations().get()); } else if (message.getFetchType().isPresent()) { content = createMultiDeviceFetchTypeContent(message.getFetchType().get()); } else if (message.getVerified().isPresent()) { sendMessage(message.getVerified().get(), unidentifiedAccess); return; } else { throw new IOException("Unsupported sync message!"); } long timestamp = message.getSent().isPresent() ? message.getSent().get().getTimestamp() : System.currentTimeMillis(); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), timestamp, content, false); }
Example #22
Source File: MultiDeviceKeysUpdateJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device, aborting..."); return; } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); StorageKey storageServiceKey = SignalStore.storageServiceValues().getOrCreateStorageKey(); messageSender.sendMessage(SignalServiceSyncMessage.forKeys(new KeysMessage(Optional.fromNullable(storageServiceKey))), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example #23
Source File: PushSendJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
protected SignalServiceSyncMessage buildSelfSendSyncMessage(@NonNull Context context, @NonNull SignalServiceDataMessage message, Optional<UnidentifiedAccessPair> syncAccess) { SignalServiceAddress localAddress = new SignalServiceAddress(TextSecurePreferences.getLocalUuid(context), TextSecurePreferences.getLocalNumber(context)); SentTranscriptMessage transcript = new SentTranscriptMessage(Optional.of(localAddress), message.getTimestamp(), message, message.getExpiresInSeconds(), Collections.singletonMap(localAddress, syncAccess.isPresent()), false); return SignalServiceSyncMessage.forSentTranscript(transcript); }
Example #24
Source File: PushProcessMessageJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private static void handleSynchronizeFetchMessage(@NonNull SignalServiceSyncMessage.FetchType fetchType) { Log.i(TAG, "Received fetch request with type: " + fetchType); switch (fetchType) { case LOCAL_PROFILE: ApplicationDependencies.getJobManager().add(new RefreshOwnProfileJob()); break; case STORAGE_MANIFEST: StorageSyncHelper.scheduleSyncForDataChange(); break; default: Log.w(TAG, "Received a fetch message for an unknown type."); } }
Example #25
Source File: MultiDeviceViewOnceOpenJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device..."); return; } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); Recipient recipient = Recipient.resolved(RecipientId.from(messageId.recipientId)); ViewOnceOpenMessage openMessage = new ViewOnceOpenMessage(RecipientUtil.toSignalServiceAddress(context, recipient), messageId.timestamp); messageSender.sendMessage(SignalServiceSyncMessage.forViewOnceOpen(openMessage), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example #26
Source File: MultiDeviceBlockedUpdateJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device, aborting..."); return; } RecipientDatabase database = DatabaseFactory.getRecipientDatabase(context); try (RecipientReader reader = database.readerForBlocked(database.getBlocked())) { List<SignalServiceAddress> blockedIndividuals = new LinkedList<>(); List<byte[]> blockedGroups = new LinkedList<>(); Recipient recipient; while ((recipient = reader.getNext()) != null) { if (recipient.isPushGroup()) { blockedGroups.add(recipient.requireGroupId().getDecodedId()); } else if (recipient.hasServiceIdentifier()) { blockedIndividuals.add(RecipientUtil.toSignalServiceAddress(context, recipient)); } } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); messageSender.sendMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blockedIndividuals, blockedGroups)), UnidentifiedAccessUtil.getAccessForSync(context)); } }
Example #27
Source File: MultiDeviceStorageSyncRequestJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override protected void onRun() throws Exception { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device, aborting..."); return; } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); messageSender.sendMessage(SignalServiceSyncMessage.forFetchLatest(SignalServiceSyncMessage.FetchType.STORAGE_MANIFEST), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example #28
Source File: MultiDeviceGroupUpdateJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile) throws IOException, UntrustedIdentityException { FileInputStream contactsFileStream = new FileInputStream(contactsFile); SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder() .withStream(contactsFileStream) .withContentType("application/octet-stream") .withLength(contactsFile.length()) .build(); messageSender.sendMessage(SignalServiceSyncMessage.forGroups(attachmentStream), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example #29
Source File: MultiDeviceProfileContentUpdateJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override protected void onRun() throws Exception { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device, aborting..."); return; } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); messageSender.sendMessage(SignalServiceSyncMessage.forFetchLatest(SignalServiceSyncMessage.FetchType.LOCAL_PROFILE), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example #30
Source File: MultiDeviceProfileKeyUpdateJob.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device..."); return; } Optional<ProfileKey> profileKey = Optional.of(ProfileKeyUtil.getSelfProfileKey()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DeviceContactsOutputStream out = new DeviceContactsOutputStream(baos); out.write(new DeviceContact(RecipientUtil.toSignalServiceAddress(context, Recipient.self()), Optional.absent(), Optional.absent(), Optional.absent(), Optional.absent(), profileKey, false, Optional.absent(), Optional.absent(), false)); out.close(); SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder() .withStream(new ByteArrayInputStream(baos.toByteArray())) .withContentType("application/octet-stream") .withLength(baos.toByteArray().length) .build(); SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, false)); messageSender.sendMessage(syncMessage, UnidentifiedAccessUtil.getAccessForSync(context)); }