当前位置: 首页>>代码示例>>Java>>正文


Java SignalServiceEnvelope类代码示例

本文整理汇总了Java中org.whispersystems.signalservice.api.messages.SignalServiceEnvelope的典型用法代码示例。如果您正苦于以下问题:Java SignalServiceEnvelope类的具体用法?Java SignalServiceEnvelope怎么用?Java SignalServiceEnvelope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SignalServiceEnvelope类属于org.whispersystems.signalservice.api.messages包,在下文中一共展示了SignalServiceEnvelope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: appendPushNotificationState

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
private static void appendPushNotificationState(@NonNull Context context,
                                                @NonNull NotificationState notificationState,
                                                @NonNull Cursor cursor)
{
  PushDatabase.Reader reader = null;
  SignalServiceEnvelope envelope;

  try {
    reader = DatabaseFactory.getPushDatabase(context).readerFor(cursor);

    while ((envelope = reader.getNext()) != null) {
      Recipients      recipients = RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false);
      Recipient       recipient  = recipients.getPrimaryRecipient();
      long            threadId   = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
      SpannableString body       = new SpannableString(context.getString(R.string.MessageNotifier_locked_message));
      body.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, body.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

      if (!recipients.isMuted()) {
        notificationState.addNotification(new NotificationItem(recipient, recipients, null, threadId, body, 0, null));
      }
    }
  } finally {
    if (reader != null)
      reader.close();
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:27,代码来源:MessageNotifier.java

示例2: handleGroupCreate

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
private static @Nullable Long handleGroupCreate(@NonNull Context context,
                                                @NonNull MasterSecretUnion masterSecret,
                                                @NonNull SignalServiceEnvelope envelope,
                                                @NonNull SignalServiceGroup group,
                                                boolean outgoing)
{
  GroupDatabase        database = DatabaseFactory.getGroupDatabase(context);
  byte[]               id       = group.getGroupId();
  GroupContext.Builder builder  = createGroupContext(group);
  builder.setType(GroupContext.Type.UPDATE);

  SignalServiceAttachment avatar = group.getAvatar().orNull();

  database.create(id, group.getName().orNull(), group.getMembers().orNull(), group.getOwner().orNull(),
                  group.getAdmins().or(Collections.<String>emptyList()),
                  avatar != null && avatar.isPointer() ? avatar.asPointer() : null,
                  envelope.getRelay());

  return storeMessage(context, masterSecret, envelope, group, builder.build(), outgoing);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:21,代码来源:GroupMessageProcessor.java

示例3: handleGroupLeave

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
private static Long handleGroupLeave(@NonNull Context               context,
                                     @NonNull MasterSecretUnion     masterSecret,
                                     @NonNull SignalServiceEnvelope envelope,
                                     @NonNull SignalServiceGroup    group,
                                     @NonNull GroupRecord           record,
                                     boolean  outgoing)
{
  GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
  byte[]        id       = group.getGroupId();
  List<String>  members  = record.getMembers();

  GroupContext.Builder builder = createGroupContext(group);
  builder.setType(GroupContext.Type.QUIT);

  if (members.contains(envelope.getSource())) {
    database.remove(id, envelope.getSource());
    if (outgoing) database.setActive(id, false);

    return storeMessage(context, masterSecret, envelope, group, builder.build(), outgoing);
  }

  return null;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:24,代码来源:GroupMessageProcessor.java

示例4: insert

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
public long insert(@NonNull SignalServiceEnvelope envelope) {
  Optional<Long> messageId = find(envelope);

  if (messageId.isPresent()) {
    return messageId.get();
  } else {
    ContentValues values = new ContentValues();
    values.put(TYPE, envelope.getType());
    values.put(SOURCE, envelope.getSource());
    values.put(DEVICE_ID, envelope.getSourceDevice());
    values.put(LEGACY_MSG, envelope.hasLegacyMessage() ? Base64.encodeBytes(envelope.getLegacyMessage()) : "");
    values.put(CONTENT, envelope.hasContent() ? Base64.encodeBytes(envelope.getContent()) : "");
    values.put(TIMESTAMP, envelope.getTimestamp());

    return databaseHelper.getWritableDatabase().insert(TABLE_NAME, null, values);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:18,代码来源:PushDatabase.java

示例5: find

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
private Optional<Long> find(SignalServiceEnvelope envelope) {
  SQLiteDatabase database = databaseHelper.getReadableDatabase();
  Cursor         cursor   = null;

  try {
    cursor = database.query(TABLE_NAME, null, TYPE + " = ? AND " + SOURCE + " = ? AND " +
                                              DEVICE_ID + " = ? AND " + LEGACY_MSG + " = ? AND " +
                                              CONTENT + " = ? AND " + TIMESTAMP + " = ?" ,
                            new String[] {String.valueOf(envelope.getType()),
                                          envelope.getSource(),
                                          String.valueOf(envelope.getSourceDevice()),
                                          envelope.hasLegacyMessage() ? Base64.encodeBytes(envelope.getLegacyMessage()) : "",
                                          envelope.hasContent() ? Base64.encodeBytes(envelope.getContent()) : "",
                                          String.valueOf(envelope.getTimestamp())},
                            null, null, null);

    if (cursor != null && cursor.moveToFirst()) {
      return Optional.of(cursor.getLong(cursor.getColumnIndexOrThrow(ID)));
    } else {
      return Optional.absent();
    }
  } finally {
    if (cursor != null) cursor.close();
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:26,代码来源:PushDatabase.java

示例6: getNext

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
public SignalServiceEnvelope getNext() {
  try {
    if (cursor == null || !cursor.moveToNext())
      return null;

    int    type          = cursor.getInt(cursor.getColumnIndexOrThrow(TYPE));
    String source        = cursor.getString(cursor.getColumnIndexOrThrow(SOURCE));
    int    deviceId      = cursor.getInt(cursor.getColumnIndexOrThrow(DEVICE_ID));
    String legacyMessage = cursor.getString(cursor.getColumnIndexOrThrow(LEGACY_MSG));
    String content       = cursor.getString(cursor.getColumnIndexOrThrow(CONTENT));
    long   timestamp     = cursor.getLong(cursor.getColumnIndexOrThrow(TIMESTAMP));

    return new SignalServiceEnvelope(type, source, deviceId, "", timestamp,
                                     legacyMessage != null ? Base64.decode(legacyMessage) : null,
                                     content != null ? Base64.decode(content) : null);
  } catch (IOException e) {
    throw new AssertionError(e);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:20,代码来源:PushDatabase.java

示例7: onRun

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
@Override
public void onRun() throws NoSuchMessageException {

  if (!IdentityKeyUtil.hasIdentityKey(context)) {
    Log.w(TAG, "Skipping job, waiting for migration...");
    MessageNotifier.updateNotification(context, null, true, -2);
    return;
  }

  MasterSecret          masterSecret         = KeyCachingService.getMasterSecret(context);
  PushDatabase          database             = DatabaseFactory.getPushDatabase(context);
  SignalServiceEnvelope envelope             = database.get(messageId);
  Optional<Long>        optionalSmsMessageId = smsMessageId > 0 ? Optional.of(smsMessageId) :
                                                               Optional.<Long>absent();

  MasterSecretUnion masterSecretUnion;

  if (masterSecret == null) masterSecretUnion = new MasterSecretUnion(MasterSecretUtil.getAsymmetricMasterSecret(context, null));
  else                      masterSecretUnion = new MasterSecretUnion(masterSecret);

  handleMessage(masterSecretUnion, envelope, optionalSmsMessageId);
  database.delete(messageId);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:24,代码来源:PushDecryptJob.java

示例8: handleCallOfferMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
private void handleCallOfferMessage(@NonNull SignalServiceEnvelope envelope,
                                    @NonNull OfferMessage message,
                                    @NonNull Optional<Long> smsMessageId)
{
  Log.w(TAG, "handleCallOfferMessage...");

  if (smsMessageId.isPresent()) {
    SmsDatabase database = DatabaseFactory.getSmsDatabase(context);
    database.markAsMissedCall(smsMessageId.get());
  } else {
    Intent intent = new Intent(context, WebRtcCallService.class);
    intent.setAction(WebRtcCallService.ACTION_INCOMING_CALL);
    intent.putExtra(WebRtcCallService.EXTRA_CALL_ID, message.getId());
    intent.putExtra(WebRtcCallService.EXTRA_REMOTE_NUMBER, envelope.getSource());
    intent.putExtra(WebRtcCallService.EXTRA_REMOTE_DESCRIPTION, message.getDescription());
    intent.putExtra(WebRtcCallService.EXTRA_TIMESTAMP, envelope.getTimestamp());
    context.startService(intent);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:20,代码来源:PushDecryptJob.java

示例9: handleExpirationUpdate

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
private void handleExpirationUpdate(@NonNull MasterSecretUnion masterSecret,
                                    @NonNull SignalServiceEnvelope envelope,
                                    @NonNull SignalServiceDataMessage message,
                                    @NonNull Optional<Long> smsMessageId)
    throws MmsException
{
  MmsDatabase          database     = DatabaseFactory.getMmsDatabase(context);
  String               localNumber  = TextSecurePreferences.getLocalNumber(context);
  Recipients           recipients   = getMessageDestination(envelope, message);
  IncomingMediaMessage mediaMessage = new IncomingMediaMessage(masterSecret, envelope.getSource(),
                                                               localNumber, message.getTimestamp(), -1,
                                                               message.getExpiresInSeconds() * 1000, true,
                                                               Optional.fromNullable(envelope.getRelay()),
                                                               Optional.<String>absent(), message.getGroupInfo(),
                                                               Optional.<List<SignalServiceAttachment>>absent());



  database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);

  DatabaseFactory.getRecipientPreferenceDatabase(context).setExpireMessages(recipients, message.getExpiresInSeconds());

  if (smsMessageId.isPresent()) {
    DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:27,代码来源:PushDecryptJob.java

示例10: handleInvalidVersionMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
private void handleInvalidVersionMessage(@NonNull MasterSecretUnion masterSecret,
                                         @NonNull SignalServiceEnvelope envelope,
                                         @NonNull Optional<Long> smsMessageId)
{
  EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);

  if (!smsMessageId.isPresent()) {
    Optional<InsertResult> insertResult = insertPlaceholder(envelope);

    if (insertResult.isPresent()) {
      smsDatabase.markAsInvalidVersionKeyExchange(insertResult.get().getMessageId());
      MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
    }
  } else {
    smsDatabase.markAsInvalidVersionKeyExchange(smsMessageId.get());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:18,代码来源:PushDecryptJob.java

示例11: handleCorruptMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
private void handleCorruptMessage(@NonNull MasterSecretUnion masterSecret,
                                  @NonNull SignalServiceEnvelope envelope,
                                  @NonNull Optional<Long> smsMessageId)
{
  EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);

  if (!smsMessageId.isPresent()) {
    Optional<InsertResult> insertResult = insertPlaceholder(envelope);

    if (insertResult.isPresent()) {
      smsDatabase.markAsDecryptFailed(insertResult.get().getMessageId());
      MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
    }
  } else {
    smsDatabase.markAsDecryptFailed(smsMessageId.get());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:18,代码来源:PushDecryptJob.java

示例12: handleNoSessionMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
private void handleNoSessionMessage(@NonNull MasterSecretUnion masterSecret,
                                    @NonNull SignalServiceEnvelope envelope,
                                    @NonNull Optional<Long> smsMessageId)
{
  EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);

  if (!smsMessageId.isPresent()) {
    Optional<InsertResult> insertResult = insertPlaceholder(envelope);

    if (insertResult.isPresent()) {
      smsDatabase.markAsNoSession(insertResult.get().getMessageId());
      MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
    }
  } else {
    smsDatabase.markAsNoSession(smsMessageId.get());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:18,代码来源:PushDecryptJob.java

示例13: handleLegacyMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
private void handleLegacyMessage(@NonNull MasterSecretUnion masterSecret,
                                 @NonNull SignalServiceEnvelope envelope,
                                 @NonNull Optional<Long> smsMessageId)
{
  EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);

  if (!smsMessageId.isPresent()) {
    Optional<InsertResult> insertResult = insertPlaceholder(envelope);

    if (insertResult.isPresent()) {
      smsDatabase.markAsLegacyVersion(insertResult.get().getMessageId());
      MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
    }
  } else {
    smsDatabase.markAsLegacyVersion(smsMessageId.get());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:18,代码来源:PushDecryptJob.java

示例14: handle

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
public void handle(SignalServiceEnvelope envelope, boolean sendExplicitReceipt) {
  if (!isActiveNumber(context, envelope.getSource())) {
    TextSecureDirectory directory           = TextSecureDirectory.getInstance(context);
    ContactTokenDetails contactTokenDetails = new ContactTokenDetails();
    contactTokenDetails.setNumber(envelope.getSource());

    directory.setNumber(contactTokenDetails, true);

    Recipients recipients = RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false);
    ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, KeyCachingService.getMasterSecret(context), recipients));
  }

  if (envelope.isReceipt()) {
    handleReceipt(envelope);
  } else if (envelope.isPreKeySignalMessage() || envelope.isSignalMessage()) {
    handleMessage(envelope, sendExplicitReceipt);
  } else {
    Log.w(TAG, "Received envelope of unknown type: " + envelope.getType());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:21,代码来源:PushReceivedJob.java

示例15: handleMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入依赖的package包/类
private void handleMessage(SignalServiceEnvelope envelope, boolean sendExplicitReceipt) {
  Recipients recipients = RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false);
  JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();

  if (!recipients.isBlocked()) {
    long messageId = DatabaseFactory.getPushDatabase(context).insert(envelope);
    jobManager.add(new PushDecryptJob(context, messageId, envelope.getSource()));
  } else {
    Log.w(TAG, "*** Received blocked push message, ignoring...");
  }

  if (sendExplicitReceipt) {
    jobManager.add(new DeliveryReceiptJob(context, envelope.getSource(),
                                          envelope.getTimestamp(),
                                          envelope.getRelay()));
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:18,代码来源:PushReceivedJob.java


注:本文中的org.whispersystems.signalservice.api.messages.SignalServiceEnvelope类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。