mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-20 14:54:09 +00:00
Refactor recipient access.
1) Refactor recipient class to support asynchronous loading operations. 2) Refactor recipient factory to simplify recipient access. 3) Consoliate everything into one recipient provider that is capable of doing async lookups and intelligent caching.
This commit is contained in:
@@ -94,13 +94,13 @@ public class MessageNotifier {
|
||||
|
||||
private static Recipients getSmsRecipient(Context context, Cursor c) throws RecipientFormattingException {
|
||||
String address = c.getString(c.getColumnIndexOrThrow(SmsDatabase.ADDRESS));
|
||||
return RecipientFactory.getRecipientsFromString(context, address);
|
||||
return RecipientFactory.getRecipientsFromString(context, address, false);
|
||||
}
|
||||
|
||||
private static Recipients getMmsRecipient(Context context, Cursor c) throws RecipientFormattingException {
|
||||
long messageId = c.getLong(c.getColumnIndexOrThrow(MmsDatabase.ID));
|
||||
String address = DatabaseFactory.getMmsDatabase(context).getMessageRecipient(messageId);
|
||||
return RecipientFactory.getRecipientsFromString(context, address);
|
||||
return RecipientFactory.getRecipientsFromString(context, address, false);
|
||||
}
|
||||
|
||||
private static Recipients getMostRecentRecipients(Context context, Cursor c) {
|
||||
|
@@ -108,7 +108,7 @@ public class MmsSender extends MmscProcessor {
|
||||
|
||||
private byte[] getEncryptedPdu(MasterSecret masterSecret, String recipient, byte[] pduBytes) {
|
||||
synchronized (SessionCipher.CIPHER_LOCK) {
|
||||
SessionCipher cipher = new SessionCipher(context, masterSecret, new Recipient(null, recipient, null), new TextTransport());
|
||||
SessionCipher cipher = new SessionCipher(context, masterSecret, new Recipient(null, recipient, null, null), new TextTransport());
|
||||
return cipher.encryptMessage(pduBytes);
|
||||
}
|
||||
}
|
||||
|
@@ -102,7 +102,7 @@ public class SmsReceiver {
|
||||
private void storeKeyExchangeMessage(MasterSecret masterSecret, SmsMessage message, String messageBody) {
|
||||
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ApplicationPreferencesActivity.AUTO_KEY_EXCHANGE_PREF, true)) {
|
||||
try {
|
||||
Recipient recipient = new Recipient(null, message.getDisplayOriginatingAddress(), null);
|
||||
Recipient recipient = new Recipient(null, message.getDisplayOriginatingAddress(), null, null);
|
||||
KeyExchangeMessage keyExchangeMessage = new KeyExchangeMessage(messageBody);
|
||||
KeyExchangeProcessor processor = new KeyExchangeProcessor(context, masterSecret, recipient);
|
||||
|
||||
|
@@ -175,7 +175,7 @@ public class SmsSender {
|
||||
|
||||
private String getAsymmetricEncrypt(MasterSecret masterSecret, String body, String address) {
|
||||
synchronized (SessionCipher.CIPHER_LOCK) {
|
||||
SessionCipher cipher = new SessionCipher(context, masterSecret, new Recipient(null, address, null), new SmsTransportDetails());
|
||||
SessionCipher cipher = new SessionCipher(context, masterSecret, new Recipient(null, address, null, null), new SmsTransportDetails());
|
||||
return new String(cipher.encryptMessage(body.getBytes()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user