use of org.whispersystems.signalservice.api.messages.SignalServiceEnvelope in project Signal-Android by WhisperSystems.
the class PushDecryptJob method onRun.
@Override
public void onRun() throws NoSuchMessageException {
if (!IdentityKeyUtil.hasIdentityKey(context)) {
Log.w(TAG, "Skipping job, waiting for migration...");
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);
}
use of org.whispersystems.signalservice.api.messages.SignalServiceEnvelope in project Signal-Android by WhisperSystems.
the class PushContentReceiveJob method onRun.
@Override
public void onRun() {
try {
String sessionKey = TextSecurePreferences.getSignalingKey(context);
SignalServiceEnvelope envelope = new SignalServiceEnvelope(data, sessionKey);
handle(envelope, true);
} catch (IOException | InvalidVersionException e) {
Log.w(TAG, e);
}
}
use of org.whispersystems.signalservice.api.messages.SignalServiceEnvelope in project Signal-Android by WhisperSystems.
the class PushDatabase method get.
public SignalServiceEnvelope get(long id) throws NoSuchMessageException {
Cursor cursor = null;
try {
cursor = databaseHelper.getReadableDatabase().query(TABLE_NAME, null, ID_WHERE, new String[] { String.valueOf(id) }, null, null, null);
if (cursor != null && cursor.moveToNext()) {
String legacyMessage = cursor.getString(cursor.getColumnIndexOrThrow(LEGACY_MSG));
String content = cursor.getString(cursor.getColumnIndexOrThrow(CONTENT));
return new SignalServiceEnvelope(cursor.getInt(cursor.getColumnIndexOrThrow(TYPE)), cursor.getString(cursor.getColumnIndexOrThrow(SOURCE)), cursor.getInt(cursor.getColumnIndexOrThrow(DEVICE_ID)), "", cursor.getLong(cursor.getColumnIndexOrThrow(TIMESTAMP)), Util.isEmpty(legacyMessage) ? null : Base64.decode(legacyMessage), Util.isEmpty(content) ? null : Base64.decode(content));
}
} catch (IOException e) {
Log.w(TAG, e);
throw new NoSuchMessageException(e);
} finally {
if (cursor != null)
cursor.close();
}
throw new NoSuchMessageException("Not found");
}
Aggregations