本文整理汇总了Java中org.whispersystems.signalservice.api.SignalServiceMessageSender类的典型用法代码示例。如果您正苦于以下问题:Java SignalServiceMessageSender类的具体用法?Java SignalServiceMessageSender怎么用?Java SignalServiceMessageSender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SignalServiceMessageSender类属于org.whispersystems.signalservice.api包,在下文中一共展示了SignalServiceMessageSender类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)));
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:24,代码来源:MultiDeviceBlockedUpdateJob.java
示例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();
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:23,代码来源:MultiDeviceContactUpdateJob.java
示例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();
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:27,代码来源:MultiDeviceContactUpdateJob.java
示例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);
}
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:19,代码来源:MultiDeviceContactUpdateJob.java
示例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));
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:17,代码来源:MultiDeviceReadUpdateJob.java
示例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"));
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:21,代码来源:DeliveryReceiptJobTest.java
示例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);
}
}
开发者ID:CableIM,项目名称:Cable-Android,代码行数:24,代码来源:MultiDeviceVerifiedUpdateJob.java
示例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);
}
}
}
开发者ID:CableIM,项目名称:Cable-Android,代码行数:19,代码来源:MultiDeviceContactUpdateJob.java
示例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;
}
}
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:11,代码来源:Manager.java
示例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();
}
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:34,代码来源:MultiDeviceGroupUpdateJob.java
示例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));
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:13,代码来源:MultiDeviceGroupUpdateJob.java
示例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);
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:9,代码来源:DeliveryReceiptJob.java
示例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);
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:38,代码来源:PushGroupUpdateJob.java
示例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);
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:16,代码来源:RequestGroupInfoJob.java
示例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)));
}
};
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:16,代码来源:SignalCommunicationModule.java
示例16: provideSignalServiceMessageSenderFactory
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
@Provides
SignalMessageSenderFactory provideSignalServiceMessageSenderFactory() {
return new SignalMessageSenderFactory() {
@Override
public SignalServiceMessageSender create() {
return textSecureMessageSender;
}
};
}
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:10,代码来源:DeliveryReceiptJobTest.java
示例17: 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())
.build();
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
.asGroupMessage(groupContext)
.withTimestamp(System.currentTimeMillis())
.build();
messageSender.sendMessage(new SignalServiceAddress(source), message);
}
开发者ID:CableIM,项目名称:Cable-Android,代码行数:36,代码来源:PushGroupUpdateJob.java
示例18: 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);
Optional<IdentityDatabase.IdentityRecord> identityRecord = DatabaseFactory.getIdentityDatabase(context).getIdentity(recipientId);
Optional<VerifiedMessage> verifiedMessage = getVerifiedMessage(recipient, identityRecord);
out.write(new DeviceContact(Util.canonicalizeNumber(context, recipient.getNumber()),
Optional.fromNullable(recipient.getName()),
getAvatar(recipient.getContactUri()),
Optional.fromNullable(recipient.getColor().serialize()),
verifiedMessage));
out.close();
sendUpdate(messageSender, contactDataFile, false);
} catch(InvalidNumberException e) {
Log.w(TAG, e);
} finally {
if (contactDataFile != null) contactDataFile.delete();
}
}
开发者ID:CableIM,项目名称:Cable-Android,代码行数:28,代码来源:MultiDeviceContactUpdateJob.java
示例19: 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 = Util.canonicalizeNumber(context, contactData.numbers.get(0).number);
Recipient recipient = RecipientFactory.getRecipientsFromString(context, number, true).getPrimaryRecipient();
Optional<IdentityDatabase.IdentityRecord> identity = DatabaseFactory.getIdentityDatabase(context).getIdentity(recipient.getRecipientId());
Optional<VerifiedMessage> verified = getVerifiedMessage(recipient, identity);
Optional<String> name = Optional.fromNullable(contactData.name);
Optional<String> color = getColor(number);
out.write(new DeviceContact(number, name, getAvatar(contactUri), color, verified));
}
out.close();
sendUpdate(messageSender, contactDataFile, true);
} catch(InvalidNumberException e) {
Log.w(TAG, e);
} finally {
if (contactDataFile != null) contactDataFile.delete();
}
}
开发者ID:CableIM,项目名称:Cable-Android,代码行数:31,代码来源:MultiDeviceContactUpdateJob.java
示例20: SofaMessageSender
import org.whispersystems.signalservice.api.SignalServiceMessageSender; //导入依赖的package包/类
public SofaMessageSender(@NonNull final HDWallet wallet,
@NonNull final ProtocolStore protocolStore,
@NonNull final ConversationStore conversationStore,
@NonNull final SignalServiceUrl[] urls) {
this.conversationStore = conversationStore;
this.messageQueue = PublishSubject.create();
this.pendingMessageStore = new PendingMessageStore();
this.protocolStore = protocolStore;
this.subscriptions = new CompositeSubscription();
this.wallet = wallet;
this.signalMessageSender =
new SignalServiceMessageSender(
new SignalServiceConfiguration(urls, new SignalCdnUrl[0]),
this.wallet.getOwnerAddress(),
this.protocolStore.getPassword(),
this.protocolStore,
USER_AGENT,
Optional.absent(),
Optional.absent()
);
this.taskSendMessage = new SendMessageToRecipientTask(
this.conversationStore,
this.pendingMessageStore,
this.protocolStore,
this.signalMessageSender);
this.taskStoreMessage = new StoreMessageTask(this.conversationStore);
attachSubscriber();
}
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:32,代码来源:SofaMessageSender.java
注:本文中的org.whispersystems.signalservice.api.SignalServiceMessageSender类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论