本文整理汇总了Java中org.whispersystems.signalservice.api.SignalServiceMessageSender类的典型用法代码示例。如果您正苦于以下问题:Java SignalServiceMessageSender类的具体用法?Java SignalServiceMessageSender怎么用?Java SignalServiceMessageSender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SignalServiceMessageSender类属于org.whispersystems.signalservice.api包,在下文中一共展示了SignalServiceMessageSender类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret)
throws IOException, UntrustedIdentityException
{
RecipientPreferenceDatabase database = DatabaseFactory.getRecipientPreferenceDatabase(context);
SignalServiceMessageSender messageSender = messageSenderFactory.create();
BlockedReader reader = database.readerForBlocked(database.getBlocked());
List<String> blocked = new LinkedList<>();
Recipients recipients;
while ((recipients = reader.getNext()) != null) {
if (recipients.isSingleRecipient()) {
try {
blocked.add(Util.canonicalizeNumber(context, recipients.getPrimaryRecipient().getNumber()));
} catch (InvalidNumberException e) {
Log.w(TAG, e);
}
}
}
messageSender.sendMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blocked)));
}
示例2: generateSingleContactUpdate
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
private void generateSingleContactUpdate(long recipientId)
throws IOException, UntrustedIdentityException, NetworkException
{
SignalServiceMessageSender messageSender = messageSenderFactory.create();
File contactDataFile = createTempFile("multidevice-contact-update");
try {
DeviceContactsOutputStream out = new DeviceContactsOutputStream(new FileOutputStream(contactDataFile));
Recipient recipient = RecipientFactory.getRecipientForId(context, recipientId, false);
out.write(new DeviceContact(recipient.getNumber(),
Optional.fromNullable(recipient.getName()),
getAvatar(recipient.getContactUri()),
Optional.fromNullable(recipient.getColor().serialize())));
out.close();
sendUpdate(messageSender, contactDataFile);
} finally {
if (contactDataFile != null) contactDataFile.delete();
}
}
示例3: generateFullContactUpdate
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
private void generateFullContactUpdate()
throws IOException, UntrustedIdentityException, NetworkException
{
SignalServiceMessageSender messageSender = messageSenderFactory.create();
File contactDataFile = createTempFile("multidevice-contact-update");
try {
DeviceContactsOutputStream out = new DeviceContactsOutputStream(new FileOutputStream(contactDataFile));
Collection<ContactData> contacts = ContactAccessor.getInstance().getContactsWithPush(context);
for (ContactData contactData : contacts) {
Uri contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactData.id));
String number = contactData.numbers.get(0).number;
Optional<String> name = Optional.fromNullable(contactData.name);
Optional<String> color = getColor(number);
out.write(new DeviceContact(number, name, getAvatar(contactUri), color));
}
out.close();
sendUpdate(messageSender, contactDataFile);
} finally {
if (contactDataFile != null) contactDataFile.delete();
}
}
示例4: sendUpdate
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile)
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(attachmentStream));
} catch (IOException ioe) {
throw new NetworkException(ioe);
}
}
}
示例5: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws IOException, UntrustedIdentityException {
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.w(TAG, "Not multi device...");
return;
}
List<ReadMessage> readMessages = new LinkedList<>();
for (SerializableSyncMessageId messageId : messageIds) {
readMessages.add(new ReadMessage(messageId.sender, messageId.timestamp));
}
SignalServiceMessageSender messageSender = messageSenderFactory.create();
messageSender.sendMessage(SignalServiceSyncMessage.forRead(readMessages));
}
示例6: testDelivery
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
@Test
public void testDelivery() throws IOException {
SignalServiceMessageSender textSecureMessageSender = mock(SignalServiceMessageSender.class);
long timestamp = System.currentTimeMillis();
DeliveryReceiptJob deliveryReceiptJob = new DeliveryReceiptJob(context,
"+14152222222",
timestamp, "foo");
ObjectGraph objectGraph = ObjectGraph.create(new TestModule(textSecureMessageSender));
objectGraph.inject(deliveryReceiptJob);
deliveryReceiptJob.onRun();
ArgumentCaptor<SignalServiceAddress> captor = ArgumentCaptor.forClass(SignalServiceAddress.class);
verify(textSecureMessageSender).sendDeliveryReceipt(captor.capture(), eq(timestamp));
assertTrue(captor.getValue().getRelay().get().equals("foo"));
assertTrue(captor.getValue().getNumber().equals("+14152222222"));
}
示例7: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
@Override
public void onRun() throws IOException, UntrustedIdentityException {
try {
if (!TextSecurePreferences.isMultiDevice(context)) {
Log.w(TAG, "Not multi device...");
return;
}
if (destination == null) {
Log.w(TAG, "No destination...");
return;
}
String canonicalDestination = Util.canonicalizeNumber(context, destination);
VerifiedMessage.VerifiedState verifiedState = getVerifiedState(verifiedStatus);
SignalServiceMessageSender messageSender = messageSenderFactory.create();
VerifiedMessage verifiedMessage = new VerifiedMessage(canonicalDestination, new IdentityKey(identityKey, 0), verifiedState, timestamp);
messageSender.sendMessage(SignalServiceSyncMessage.forVerified(verifiedMessage));
} catch (InvalidNumberException | InvalidKeyException e) {
throw new IOException(e);
}
}
示例8: sendUpdate
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
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)));
} catch (IOException ioe) {
throw new NetworkException(ioe);
}
}
}
示例9: sendSyncMessage
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
private void sendSyncMessage(SignalServiceSyncMessage message)
throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(serviceUrls, localIdentity.getToshiId(), localIdentity.getPassword(), signalProtocolStore, USER_AGENT, Optional.<SignalServiceMessagePipe>absent(), Optional.<SignalServiceMessageSender.EventListener>absent());
try {
messageSender.sendMessage(message);
} catch (UntrustedIdentityException e) {
// TODO: save that this is untrusted?
throw e;
}
}
示例10: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
@Override
public void onRun(MasterSecret masterSecret) throws Exception {
SignalServiceMessageSender messageSender = messageSenderFactory.create();
File contactDataFile = createTempFile("multidevice-contact-update");
GroupDatabase.Reader reader = null;
GroupDatabase.GroupRecord record;
try {
DeviceGroupsOutputStream out = new DeviceGroupsOutputStream(new FileOutputStream(contactDataFile));
reader = DatabaseFactory.getGroupDatabase(context).getGroups();
while ((record = reader.getNext()) != null) {
out.write(new DeviceGroup(record.getId(), Optional.fromNullable(record.getTitle()),
record.getMembers(), getAvatar(record.getAvatar()),
record.isActive()));
}
out.close();
if (contactDataFile.exists() && contactDataFile.length() > 0) {
sendUpdate(messageSender, contactDataFile);
} else {
Log.w(TAG, "No groups present for sync message...");
}
} finally {
if (contactDataFile != null) contactDataFile.delete();
if (reader != null) reader.close();
}
}
示例11: sendUpdate
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
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));
}
示例12: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
@Override
public void onRun() throws IOException {
Log.w("DeliveryReceiptJob", "Sending delivery receipt...");
SignalServiceMessageSender messageSender = messageSenderFactory.create();
SignalServiceAddress textSecureAddress = new SignalServiceAddress(destination, Optional.fromNullable(relay));
messageSender.sendDeliveryReceipt(textSecureAddress, timestamp);
}
示例13: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
@Override
public void onRun() throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = messageSenderFactory.create();
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
GroupRecord record = groupDatabase.getGroup(groupId);
SignalServiceAttachment avatar = null;
if (record == null) {
Log.w(TAG, "No information for group record info request: " + new String(groupId));
return;
}
if (record.getAvatar() != null) {
avatar = SignalServiceAttachmentStream.newStreamBuilder()
.withContentType("image/jpeg")
.withStream(new ByteArrayInputStream(record.getAvatar()))
.withLength(record.getAvatar().length)
.build();
}
SignalServiceGroup groupContext = SignalServiceGroup.newBuilder(Type.UPDATE)
.withAvatar(avatar)
.withId(groupId)
.withMembers(record.getMembers())
.withName(record.getTitle())
.withOwner(record.getOwner())
.withAdmins(record.getAdmins())
.build();
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
.asGroupMessage(groupContext)
.withTimestamp(System.currentTimeMillis())
.build();
messageSender.sendMessage(new SignalServiceAddress(source), message);
}
示例14: onRun
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
@Override
public void onRun() throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = messageSenderFactory.create();
SignalServiceGroup group = SignalServiceGroup.newBuilder(Type.REQUEST_INFO)
.withId(groupId)
.build();
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
.asGroupMessage(group)
.withTimestamp(System.currentTimeMillis())
.build();
messageSender.sendMessage(new SignalServiceAddress(source), message);
}
示例15: provideSignalMessageSenderFactory
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
@Provides
SignalMessageSenderFactory provideSignalMessageSenderFactory() {
return new SignalMessageSenderFactory() {
@Override
public SignalServiceMessageSender create() {
return new SignalServiceMessageSender(networkAccess.getConfiguration(context),
TextSecurePreferences.getLocalNumber(context),
TextSecurePreferences.getPushServerPassword(context),
new SignalProtocolStoreImpl(context),
BuildConfig.USER_AGENT,
Optional.fromNullable(MessageRetrievalService.getPipe()),
Optional.<SignalServiceMessageSender.EventListener>of(new SecurityEventListener(context)));
}
};
}