本文整理汇总了Java中org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage类的典型用法代码示例。如果您正苦于以下问题:Java VerifiedMessage类的具体用法?Java VerifiedMessage怎么用?Java VerifiedMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VerifiedMessage类属于org.whispersystems.signalservice.api.messages.multidevice包,在下文中一共展示了VerifiedMessage类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRun
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage; //导入依赖的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);
}
}
示例2: getVerifiedMessage
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage; //导入依赖的package包/类
private Optional<VerifiedMessage> getVerifiedMessage(Recipient recipient, Optional<IdentityDatabase.IdentityRecord> identity) throws InvalidNumberException {
if (!identity.isPresent()) return Optional.absent();
String destination = Util.canonicalizeNumber(context, recipient.getNumber());
IdentityKey identityKey = identity.get().getIdentityKey();
VerifiedMessage.VerifiedState state;
switch (identity.get().getVerifiedStatus()) {
case VERIFIED: state = VerifiedMessage.VerifiedState.VERIFIED; break;
case UNVERIFIED: state = VerifiedMessage.VerifiedState.UNVERIFIED; break;
case DEFAULT: state = VerifiedMessage.VerifiedState.DEFAULT; break;
default: throw new AssertionError("Unknown state: " + identity.get().getVerifiedStatus());
}
return Optional.of(new VerifiedMessage(destination, identityKey, state, System.currentTimeMillis()));
}
示例3: processVerifiedMessage
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage; //导入依赖的package包/类
public static void processVerifiedMessage(Context context, MasterSecretUnion masterSecret, VerifiedMessage verifiedMessage) {
synchronized (SESSION_LOCK) {
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context);
Recipient recipient = RecipientFactory.getRecipientsFromString(context, verifiedMessage.getDestination(), true).getPrimaryRecipient();
Optional<IdentityRecord> identityRecord = identityDatabase.getIdentity(recipient.getRecipientId());
if (!identityRecord.isPresent() && verifiedMessage.getVerified() == VerifiedMessage.VerifiedState.DEFAULT) {
Log.w(TAG, "No existing record for default status");
return;
}
if (verifiedMessage.getVerified() == VerifiedMessage.VerifiedState.DEFAULT &&
identityRecord.isPresent() &&
identityRecord.get().getIdentityKey().equals(verifiedMessage.getIdentityKey()) &&
identityRecord.get().getVerifiedStatus() != IdentityDatabase.VerifiedStatus.DEFAULT)
{
identityDatabase.setVerified(recipient.getRecipientId(), identityRecord.get().getIdentityKey(), IdentityDatabase.VerifiedStatus.DEFAULT);
markIdentityVerified(context, masterSecret, recipient, false, true);
}
if (verifiedMessage.getVerified() == VerifiedMessage.VerifiedState.VERIFIED &&
(!identityRecord.isPresent() ||
(identityRecord.isPresent() && !identityRecord.get().getIdentityKey().equals(verifiedMessage.getIdentityKey())) ||
(identityRecord.isPresent() && identityRecord.get().getVerifiedStatus() != IdentityDatabase.VerifiedStatus.VERIFIED)))
{
saveIdentity(context, verifiedMessage.getDestination(), verifiedMessage.getIdentityKey());
identityDatabase.setVerified(recipient.getRecipientId(), verifiedMessage.getIdentityKey(), IdentityDatabase.VerifiedStatus.VERIFIED);
markIdentityVerified(context, masterSecret, recipient, true, true);
}
}
}
示例4: getVerifiedState
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage; //导入依赖的package包/类
private VerifiedMessage.VerifiedState getVerifiedState(VerifiedStatus status) {
VerifiedMessage.VerifiedState verifiedState;
switch (status) {
case DEFAULT: verifiedState = VerifiedMessage.VerifiedState.DEFAULT; break;
case VERIFIED: verifiedState = VerifiedMessage.VerifiedState.VERIFIED; break;
case UNVERIFIED: verifiedState = VerifiedMessage.VerifiedState.UNVERIFIED; break;
default: throw new AssertionError("Unknown status: " + verifiedStatus);
}
return verifiedState;
}
示例5: generateSingleContactUpdate
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage; //导入依赖的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();
}
}
示例6: generateFullContactUpdate
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage; //导入依赖的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();
}
}
示例7: handleSynchronizeVerifiedMessage
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage; //导入依赖的package包/类
private void handleSynchronizeVerifiedMessage(@NonNull MasterSecretUnion masterSecret,
@NonNull VerifiedMessage verifiedMessage)
{
IdentityUtil.processVerifiedMessage(context, masterSecret, verifiedMessage);
}