mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 13:48:26 +00:00
Rename PushAddress to TextSecureAddress
// FREEBIE
This commit is contained in:
parent
753a1c7219
commit
a59feb7ad4
@ -1,13 +1,11 @@
|
|||||||
package org.thoughtcrime.securesms.jobs;
|
package org.thoughtcrime.securesms.jobs;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
|
||||||
|
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.thoughtcrime.securesms.TextSecureTestCase;
|
import org.thoughtcrime.securesms.TextSecureTestCase;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.whispersystems.textsecure.api.TextSecureMessageSender;
|
import org.whispersystems.textsecure.api.TextSecureMessageSender;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.NotFoundException;
|
import org.whispersystems.textsecure.api.push.exceptions.NotFoundException;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.PushNetworkException;
|
import org.whispersystems.textsecure.api.push.exceptions.PushNetworkException;
|
||||||
|
|
||||||
@ -38,7 +36,7 @@ public class DeliveryReceiptJobTest extends TextSecureTestCase {
|
|||||||
|
|
||||||
deliveryReceiptJob.onRun();
|
deliveryReceiptJob.onRun();
|
||||||
|
|
||||||
ArgumentCaptor<PushAddress> captor = ArgumentCaptor.forClass(PushAddress.class);
|
ArgumentCaptor<TextSecureAddress> captor = ArgumentCaptor.forClass(TextSecureAddress.class);
|
||||||
verify(textSecureMessageSender).sendDeliveryReceipt(captor.capture(), eq(timestamp));
|
verify(textSecureMessageSender).sendDeliveryReceipt(captor.capture(), eq(timestamp));
|
||||||
|
|
||||||
assertTrue(captor.getValue().getRelay().equals("foo"));
|
assertTrue(captor.getValue().getRelay().equals("foo"));
|
||||||
@ -51,7 +49,7 @@ public class DeliveryReceiptJobTest extends TextSecureTestCase {
|
|||||||
|
|
||||||
Mockito.doThrow(new PushNetworkException("network error"))
|
Mockito.doThrow(new PushNetworkException("network error"))
|
||||||
.when(textSecureMessageSender)
|
.when(textSecureMessageSender)
|
||||||
.sendDeliveryReceipt(any(PushAddress.class), eq(timestamp));
|
.sendDeliveryReceipt(any(TextSecureAddress.class), eq(timestamp));
|
||||||
|
|
||||||
|
|
||||||
DeliveryReceiptJob deliveryReceiptJob = new DeliveryReceiptJob(getContext(),
|
DeliveryReceiptJob deliveryReceiptJob = new DeliveryReceiptJob(getContext(),
|
||||||
@ -70,7 +68,7 @@ public class DeliveryReceiptJobTest extends TextSecureTestCase {
|
|||||||
|
|
||||||
Mockito.doThrow(new NotFoundException("not found"))
|
Mockito.doThrow(new NotFoundException("not found"))
|
||||||
.when(textSecureMessageSender)
|
.when(textSecureMessageSender)
|
||||||
.sendDeliveryReceipt(any(PushAddress.class), eq(timestamp));
|
.sendDeliveryReceipt(any(TextSecureAddress.class), eq(timestamp));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deliveryReceiptJob.onRun();
|
deliveryReceiptJob.onRun();
|
||||||
|
@ -33,7 +33,7 @@ import org.whispersystems.textsecure.api.messages.TextSecureAttachment;
|
|||||||
import org.whispersystems.textsecure.api.messages.TextSecureAttachmentStream;
|
import org.whispersystems.textsecure.api.messages.TextSecureAttachmentStream;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureGroup;
|
import org.whispersystems.textsecure.api.messages.TextSecureGroup;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
import org.whispersystems.textsecure.api.push.TrustStore;
|
import org.whispersystems.textsecure.api.push.TrustStore;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.NetworkFailureException;
|
import org.whispersystems.textsecure.api.push.exceptions.NetworkFailureException;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.PushNetworkException;
|
import org.whispersystems.textsecure.api.push.exceptions.PushNetworkException;
|
||||||
@ -72,7 +72,7 @@ public class TextSecureMessageSender {
|
|||||||
|
|
||||||
private final PushServiceSocket socket;
|
private final PushServiceSocket socket;
|
||||||
private final AxolotlStore store;
|
private final AxolotlStore store;
|
||||||
private final PushAddress syncAddress;
|
private final TextSecureAddress syncAddress;
|
||||||
private final Optional<EventListener> eventListener;
|
private final Optional<EventListener> eventListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,7 +94,7 @@ public class TextSecureMessageSender {
|
|||||||
{
|
{
|
||||||
this.socket = new PushServiceSocket(url, trustStore, new StaticCredentialsProvider(user, password, null));
|
this.socket = new PushServiceSocket(url, trustStore, new StaticCredentialsProvider(user, password, null));
|
||||||
this.store = store;
|
this.store = store;
|
||||||
this.syncAddress = new PushAddress(userId, user, null);
|
this.syncAddress = new TextSecureAddress(userId, user, null);
|
||||||
this.eventListener = eventListener;
|
this.eventListener = eventListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ public class TextSecureMessageSender {
|
|||||||
* @param messageId The message id of the received message you're acknowledging.
|
* @param messageId The message id of the received message you're acknowledging.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void sendDeliveryReceipt(PushAddress recipient, long messageId) throws IOException {
|
public void sendDeliveryReceipt(TextSecureAddress recipient, long messageId) throws IOException {
|
||||||
this.socket.sendReceipt(recipient.getNumber(), messageId, recipient.getRelay());
|
this.socket.sendReceipt(recipient.getNumber(), messageId, recipient.getRelay());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public class TextSecureMessageSender {
|
|||||||
* @throws UntrustedIdentityException
|
* @throws UntrustedIdentityException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void sendMessage(PushAddress recipient, TextSecureMessage message)
|
public void sendMessage(TextSecureAddress recipient, TextSecureMessage message)
|
||||||
throws UntrustedIdentityException, IOException
|
throws UntrustedIdentityException, IOException
|
||||||
{
|
{
|
||||||
byte[] content = createMessageContent(message);
|
byte[] content = createMessageContent(message);
|
||||||
@ -146,7 +146,7 @@ public class TextSecureMessageSender {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws EncapsulatedExceptions
|
* @throws EncapsulatedExceptions
|
||||||
*/
|
*/
|
||||||
public void sendMessage(List<PushAddress> recipients, TextSecureMessage message)
|
public void sendMessage(List<TextSecureAddress> recipients, TextSecureMessage message)
|
||||||
throws IOException, EncapsulatedExceptions
|
throws IOException, EncapsulatedExceptions
|
||||||
{
|
{
|
||||||
byte[] content = createMessageContent(message);
|
byte[] content = createMessageContent(message);
|
||||||
@ -176,7 +176,7 @@ public class TextSecureMessageSender {
|
|||||||
return builder.build().toByteArray();
|
return builder.build().toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] createSyncMessageContent(byte[] content, PushAddress recipient, long timestamp) {
|
private byte[] createSyncMessageContent(byte[] content, TextSecureAddress recipient, long timestamp) {
|
||||||
try {
|
try {
|
||||||
PushMessageContent.Builder builder = PushMessageContent.parseFrom(content).toBuilder();
|
PushMessageContent.Builder builder = PushMessageContent.parseFrom(content).toBuilder();
|
||||||
builder.setSync(PushMessageContent.SyncMessageContext.newBuilder()
|
builder.setSync(PushMessageContent.SyncMessageContext.newBuilder()
|
||||||
@ -213,14 +213,14 @@ public class TextSecureMessageSender {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessage(List<PushAddress> recipients, long timestamp, byte[] content)
|
private void sendMessage(List<TextSecureAddress> recipients, long timestamp, byte[] content)
|
||||||
throws IOException, EncapsulatedExceptions
|
throws IOException, EncapsulatedExceptions
|
||||||
{
|
{
|
||||||
List<UntrustedIdentityException> untrustedIdentities = new LinkedList<>();
|
List<UntrustedIdentityException> untrustedIdentities = new LinkedList<>();
|
||||||
List<UnregisteredUserException> unregisteredUsers = new LinkedList<>();
|
List<UnregisteredUserException> unregisteredUsers = new LinkedList<>();
|
||||||
List<NetworkFailureException> networkExceptions = new LinkedList<>();
|
List<NetworkFailureException> networkExceptions = new LinkedList<>();
|
||||||
|
|
||||||
for (PushAddress recipient : recipients) {
|
for (TextSecureAddress recipient : recipients) {
|
||||||
try {
|
try {
|
||||||
sendMessage(recipient, timestamp, content);
|
sendMessage(recipient, timestamp, content);
|
||||||
} catch (UntrustedIdentityException e) {
|
} catch (UntrustedIdentityException e) {
|
||||||
@ -240,7 +240,7 @@ public class TextSecureMessageSender {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SendMessageResponse sendMessage(PushAddress recipient, long timestamp, byte[] content)
|
private SendMessageResponse sendMessage(TextSecureAddress recipient, long timestamp, byte[] content)
|
||||||
throws UntrustedIdentityException, IOException
|
throws UntrustedIdentityException, IOException
|
||||||
{
|
{
|
||||||
for (int i=0;i<3;i++) {
|
for (int i=0;i<3;i++) {
|
||||||
@ -297,7 +297,7 @@ public class TextSecureMessageSender {
|
|||||||
|
|
||||||
|
|
||||||
private OutgoingPushMessageList getEncryptedMessages(PushServiceSocket socket,
|
private OutgoingPushMessageList getEncryptedMessages(PushServiceSocket socket,
|
||||||
PushAddress recipient,
|
TextSecureAddress recipient,
|
||||||
long timestamp,
|
long timestamp,
|
||||||
byte[] plaintext)
|
byte[] plaintext)
|
||||||
throws IOException, UntrustedIdentityException
|
throws IOException, UntrustedIdentityException
|
||||||
@ -305,8 +305,8 @@ public class TextSecureMessageSender {
|
|||||||
List<OutgoingPushMessage> messages = new LinkedList<>();
|
List<OutgoingPushMessage> messages = new LinkedList<>();
|
||||||
|
|
||||||
if (!recipient.equals(syncAddress)) {
|
if (!recipient.equals(syncAddress)) {
|
||||||
PushBody masterBody = getEncryptedMessage(socket, recipient, PushAddress.DEFAULT_DEVICE_ID, plaintext);
|
PushBody masterBody = getEncryptedMessage(socket, recipient, TextSecureAddress.DEFAULT_DEVICE_ID, plaintext);
|
||||||
messages.add(new OutgoingPushMessage(recipient, PushAddress.DEFAULT_DEVICE_ID, masterBody));
|
messages.add(new OutgoingPushMessage(recipient, TextSecureAddress.DEFAULT_DEVICE_ID, masterBody));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int deviceId : store.getSubDeviceSessions(recipient.getRecipientId())) {
|
for (int deviceId : store.getSubDeviceSessions(recipient.getRecipientId())) {
|
||||||
@ -317,7 +317,7 @@ public class TextSecureMessageSender {
|
|||||||
return new OutgoingPushMessageList(recipient.getNumber(), timestamp, recipient.getRelay(), messages);
|
return new OutgoingPushMessageList(recipient.getNumber(), timestamp, recipient.getRelay(), messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PushBody getEncryptedMessage(PushServiceSocket socket, PushAddress recipient, int deviceId, byte[] plaintext)
|
private PushBody getEncryptedMessage(PushServiceSocket socket, TextSecureAddress recipient, int deviceId, byte[] plaintext)
|
||||||
throws IOException, UntrustedIdentityException
|
throws IOException, UntrustedIdentityException
|
||||||
{
|
{
|
||||||
if (!store.containsSession(recipient.getRecipientId(), deviceId)) {
|
if (!store.containsSession(recipient.getRecipientId(), deviceId)) {
|
||||||
@ -354,7 +354,7 @@ public class TextSecureMessageSender {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMismatchedDevices(PushServiceSocket socket, PushAddress recipient,
|
private void handleMismatchedDevices(PushServiceSocket socket, TextSecureAddress recipient,
|
||||||
MismatchedDevices mismatchedDevices)
|
MismatchedDevices mismatchedDevices)
|
||||||
throws IOException, UntrustedIdentityException
|
throws IOException, UntrustedIdentityException
|
||||||
{
|
{
|
||||||
@ -378,7 +378,7 @@ public class TextSecureMessageSender {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleStaleDevices(PushAddress recipient, StaleDevices staleDevices) {
|
private void handleStaleDevices(TextSecureAddress recipient, StaleDevices staleDevices) {
|
||||||
long recipientId = recipient.getRecipientId();
|
long recipientId = recipient.getRecipientId();
|
||||||
|
|
||||||
for (int staleDeviceId : staleDevices.getStaleDevices()) {
|
for (int staleDeviceId : staleDevices.getStaleDevices()) {
|
||||||
|
@ -18,6 +18,7 @@ package org.whispersystems.textsecure.api.messages;
|
|||||||
|
|
||||||
import org.whispersystems.libaxolotl.util.guava.Optional;
|
import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,7 +40,11 @@ public class TextSecureMessage {
|
|||||||
* @param body The message contents.
|
* @param body The message contents.
|
||||||
*/
|
*/
|
||||||
public TextSecureMessage(long timestamp, String body) {
|
public TextSecureMessage(long timestamp, String body) {
|
||||||
this(timestamp, null, body);
|
this(timestamp, (List<TextSecureAttachment>)null, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextSecureMessage(final long timestamp, final TextSecureAttachment attachment, final String body) {
|
||||||
|
this(timestamp, new LinkedList<TextSecureAttachment>() {{add(attachment);}}, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@ package org.whispersystems.textsecure.api.push;
|
|||||||
/**
|
/**
|
||||||
* A class representing a message destination or origin.
|
* A class representing a message destination or origin.
|
||||||
*/
|
*/
|
||||||
public class PushAddress {
|
public class TextSecureAddress {
|
||||||
|
|
||||||
public static final int DEFAULT_DEVICE_ID = 1;
|
public static final int DEFAULT_DEVICE_ID = 1;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public class PushAddress {
|
|||||||
* @param e164number The TextSecure username of this destination (eg e164 representation of a phone number).
|
* @param e164number The TextSecure username of this destination (eg e164 representation of a phone number).
|
||||||
* @param relay The TextSecure federated server this user is registered with (if not your own server).
|
* @param relay The TextSecure federated server this user is registered with (if not your own server).
|
||||||
*/
|
*/
|
||||||
public PushAddress(long recipientId, String e164number, String relay) {
|
public TextSecureAddress(long recipientId, String e164number, String relay) {
|
||||||
this.recipientId = recipientId;
|
this.recipientId = recipientId;
|
||||||
this.e164number = e164number;
|
this.e164number = e164number;
|
||||||
this.relay = relay;
|
this.relay = relay;
|
||||||
@ -54,9 +54,9 @@ public class PushAddress {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (other == null || !(other instanceof PushAddress)) return false;
|
if (other == null || !(other instanceof TextSecureAddress)) return false;
|
||||||
|
|
||||||
PushAddress that = (PushAddress)other;
|
TextSecureAddress that = (TextSecureAddress)other;
|
||||||
|
|
||||||
return this.recipientId == that.recipientId &&
|
return this.recipientId == that.recipientId &&
|
||||||
equals(this.e164number, that.e164number) &&
|
equals(this.e164number, that.e164number) &&
|
@ -19,7 +19,7 @@ package org.whispersystems.textsecure.internal.push;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
import org.whispersystems.textsecure.internal.util.Base64;
|
import org.whispersystems.textsecure.internal.util.Base64;
|
||||||
|
|
||||||
public class OutgoingPushMessage {
|
public class OutgoingPushMessage {
|
||||||
@ -33,7 +33,7 @@ public class OutgoingPushMessage {
|
|||||||
@JsonProperty
|
@JsonProperty
|
||||||
private String body;
|
private String body;
|
||||||
|
|
||||||
public OutgoingPushMessage(PushAddress address, int deviceId, PushBody body) {
|
public OutgoingPushMessage(TextSecureAddress address, int deviceId, PushBody body) {
|
||||||
this.type = body.getType();
|
this.type = body.getType();
|
||||||
this.destinationDeviceId = deviceId;
|
this.destinationDeviceId = deviceId;
|
||||||
this.destinationRegistrationId = body.getRemoteRegistrationId();
|
this.destinationRegistrationId = body.getRemoteRegistrationId();
|
||||||
|
@ -28,7 +28,7 @@ import org.whispersystems.libaxolotl.state.PreKeyRecord;
|
|||||||
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
|
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
|
||||||
import org.whispersystems.textsecure.api.crypto.AttachmentCipherOutputStream;
|
import org.whispersystems.textsecure.api.crypto.AttachmentCipherOutputStream;
|
||||||
import org.whispersystems.textsecure.api.push.ContactTokenDetails;
|
import org.whispersystems.textsecure.api.push.ContactTokenDetails;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
import org.whispersystems.textsecure.api.push.SignedPreKeyEntity;
|
import org.whispersystems.textsecure.api.push.SignedPreKeyEntity;
|
||||||
import org.whispersystems.textsecure.api.push.TrustStore;
|
import org.whispersystems.textsecure.api.push.TrustStore;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.AuthorizationFailedException;
|
import org.whispersystems.textsecure.api.push.exceptions.AuthorizationFailedException;
|
||||||
@ -194,7 +194,7 @@ public class PushServiceSocket {
|
|||||||
return preKeyStatus.getCount();
|
return preKeyStatus.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PreKeyBundle> getPreKeys(PushAddress destination, int deviceIdInteger) throws IOException {
|
public List<PreKeyBundle> getPreKeys(TextSecureAddress destination, int deviceIdInteger) throws IOException {
|
||||||
try {
|
try {
|
||||||
String deviceId = String.valueOf(deviceIdInteger);
|
String deviceId = String.valueOf(deviceIdInteger);
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ public class PushServiceSocket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PreKeyBundle getPreKey(PushAddress destination, int deviceId) throws IOException {
|
public PreKeyBundle getPreKey(TextSecureAddress destination, int deviceId) throws IOException {
|
||||||
try {
|
try {
|
||||||
String path = String.format(PREKEY_DEVICE_PATH, destination.getNumber(),
|
String path = String.format(PREKEY_DEVICE_PATH, destination.getNumber(),
|
||||||
String.valueOf(deviceId));
|
String.valueOf(deviceId));
|
||||||
|
@ -33,7 +33,7 @@ import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
|||||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity which prompts the user to initiate a secure
|
* Activity which prompts the user to initiate a secure
|
||||||
@ -118,6 +118,6 @@ public class AutoInitiateActivity extends BaseActivity {
|
|||||||
Recipient recipient)
|
Recipient recipient)
|
||||||
{
|
{
|
||||||
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
|
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
|
||||||
return sessionStore.containsSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID);
|
return sessionStore.containsSession(recipient.getRecipientId(), TextSecureAddress.DEFAULT_DEVICE_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,6 @@ import org.thoughtcrime.securesms.database.DraftDatabase.Draft;
|
|||||||
import org.thoughtcrime.securesms.database.DraftDatabase.Drafts;
|
import org.thoughtcrime.securesms.database.DraftDatabase.Drafts;
|
||||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||||
import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
|
import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
|
||||||
import org.thoughtcrime.securesms.database.TextSecureDirectory;
|
|
||||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||||
import org.thoughtcrime.securesms.mms.AttachmentManager;
|
import org.thoughtcrime.securesms.mms.AttachmentManager;
|
||||||
import org.thoughtcrime.securesms.mms.AttachmentTypeSelectorAdapter;
|
import org.thoughtcrime.securesms.mms.AttachmentTypeSelectorAdapter;
|
||||||
@ -104,7 +103,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.whispersystems.libaxolotl.InvalidMessageException;
|
import org.whispersystems.libaxolotl.InvalidMessageException;
|
||||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
@ -689,7 +688,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
boolean isSecureSmsDestination = isSecureSmsAllowed &&
|
boolean isSecureSmsDestination = isSecureSmsAllowed &&
|
||||||
isSingleConversation() &&
|
isSingleConversation() &&
|
||||||
sessionStore.containsSession(primaryRecipient.getRecipientId(),
|
sessionStore.containsSession(primaryRecipient.getRecipientId(),
|
||||||
PushAddress.DEFAULT_DEVICE_ID);
|
TextSecureAddress.DEFAULT_DEVICE_ID);
|
||||||
|
|
||||||
if (isPushDestination || isSecureSmsDestination) {
|
if (isPushDestination || isSecureSmsDestination) {
|
||||||
this.isEncryptedConversation = true;
|
this.isEncryptedConversation = true;
|
||||||
|
@ -33,7 +33,7 @@ import org.thoughtcrime.securesms.util.MemoryCleaner;
|
|||||||
import org.whispersystems.libaxolotl.IdentityKey;
|
import org.whispersystems.libaxolotl.IdentityKey;
|
||||||
import org.whispersystems.libaxolotl.state.SessionRecord;
|
import org.whispersystems.libaxolotl.state.SessionRecord;
|
||||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity for verifying identity keys.
|
* Activity for verifying identity keys.
|
||||||
@ -185,7 +185,7 @@ public class VerifyIdentityActivity extends KeyScanningActivity {
|
|||||||
private IdentityKey getRemoteIdentityKey(MasterSecret masterSecret, Recipient recipient) {
|
private IdentityKey getRemoteIdentityKey(MasterSecret masterSecret, Recipient recipient) {
|
||||||
SessionStore sessionStore = new TextSecureSessionStore(this, masterSecret);
|
SessionStore sessionStore = new TextSecureSessionStore(this, masterSecret);
|
||||||
SessionRecord record = sessionStore.loadSession(recipient.getRecipientId(),
|
SessionRecord record = sessionStore.loadSession(recipient.getRecipientId(),
|
||||||
PushAddress.DEFAULT_DEVICE_ID);
|
TextSecureAddress.DEFAULT_DEVICE_ID);
|
||||||
|
|
||||||
if (record == null) {
|
if (record == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -37,7 +37,7 @@ import org.whispersystems.libaxolotl.state.PreKeyStore;
|
|||||||
import org.whispersystems.libaxolotl.state.SessionRecord;
|
import org.whispersystems.libaxolotl.state.SessionRecord;
|
||||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||||
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
|
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
|
|
||||||
public class KeyExchangeInitiator {
|
public class KeyExchangeInitiator {
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public class KeyExchangeInitiator {
|
|||||||
|
|
||||||
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
|
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
|
||||||
identityKeyStore, recipient.getRecipientId(),
|
identityKeyStore, recipient.getRecipientId(),
|
||||||
PushAddress.DEFAULT_DEVICE_ID);
|
TextSecureAddress.DEFAULT_DEVICE_ID);
|
||||||
|
|
||||||
KeyExchangeMessage keyExchangeMessage = sessionBuilder.process();
|
KeyExchangeMessage keyExchangeMessage = sessionBuilder.process();
|
||||||
String serializedMessage = Base64.encodeBytesWithoutPadding(keyExchangeMessage.serialize());
|
String serializedMessage = Base64.encodeBytesWithoutPadding(keyExchangeMessage.serialize());
|
||||||
@ -81,7 +81,7 @@ public class KeyExchangeInitiator {
|
|||||||
Recipient recipient)
|
Recipient recipient)
|
||||||
{
|
{
|
||||||
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
|
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
|
||||||
SessionRecord sessionRecord = sessionStore.loadSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID);
|
SessionRecord sessionRecord = sessionStore.loadSession(recipient.getRecipientId(), TextSecureAddress.DEFAULT_DEVICE_ID);
|
||||||
|
|
||||||
return sessionRecord.getSessionState().hasPendingKeyExchange();
|
return sessionRecord.getSessionState().hasPendingKeyExchange();
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import org.whispersystems.libaxolotl.protocol.CiphertextMessage;
|
|||||||
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
|
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
|
||||||
import org.whispersystems.libaxolotl.state.AxolotlStore;
|
import org.whispersystems.libaxolotl.state.AxolotlStore;
|
||||||
import org.whispersystems.libaxolotl.util.guava.Optional;
|
import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -101,11 +101,11 @@ public class MmsCipher {
|
|||||||
throw new UndeliverableMessageException("PDU composition failed, null payload");
|
throw new UndeliverableMessageException("PDU composition failed, null payload");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) {
|
if (!axolotlStore.containsSession(recipientId, TextSecureAddress.DEFAULT_DEVICE_ID)) {
|
||||||
throw new NoSessionException("No session for: " + recipientId);
|
throw new NoSessionException("No session for: " + recipientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID);
|
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, TextSecureAddress.DEFAULT_DEVICE_ID);
|
||||||
CiphertextMessage ciphertextMessage = cipher.encrypt(pduBytes);
|
CiphertextMessage ciphertextMessage = cipher.encrypt(pduBytes);
|
||||||
byte[] encryptedPduBytes = textTransport.getEncodedMessage(ciphertextMessage.serialize());
|
byte[] encryptedPduBytes = textTransport.getEncodedMessage(ciphertextMessage.serialize());
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage;
|
|||||||
import org.whispersystems.libaxolotl.protocol.PreKeyWhisperMessage;
|
import org.whispersystems.libaxolotl.protocol.PreKeyWhisperMessage;
|
||||||
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
|
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
|
||||||
import org.whispersystems.libaxolotl.state.AxolotlStore;
|
import org.whispersystems.libaxolotl.state.AxolotlStore;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -89,11 +89,11 @@ public class SmsCipher {
|
|||||||
byte[] paddedBody = transportDetails.getPaddedMessageBody(message.getMessageBody().getBytes());
|
byte[] paddedBody = transportDetails.getPaddedMessageBody(message.getMessageBody().getBytes());
|
||||||
long recipientId = message.getRecipients().getPrimaryRecipient().getRecipientId();
|
long recipientId = message.getRecipients().getPrimaryRecipient().getRecipientId();
|
||||||
|
|
||||||
if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) {
|
if (!axolotlStore.containsSession(recipientId, TextSecureAddress.DEFAULT_DEVICE_ID)) {
|
||||||
throw new NoSessionException("No session for: " + recipientId);
|
throw new NoSessionException("No session for: " + recipientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID);
|
SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, TextSecureAddress.DEFAULT_DEVICE_ID);
|
||||||
CiphertextMessage ciphertextMessage = cipher.encrypt(paddedBody);
|
CiphertextMessage ciphertextMessage = cipher.encrypt(paddedBody);
|
||||||
String encodedCiphertext = new String(transportDetails.getEncodedMessage(ciphertextMessage.serialize()));
|
String encodedCiphertext = new String(transportDetails.getEncodedMessage(ciphertextMessage.serialize()));
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import org.whispersystems.libaxolotl.InvalidMessageException;
|
|||||||
import org.whispersystems.libaxolotl.state.SessionRecord;
|
import org.whispersystems.libaxolotl.state.SessionRecord;
|
||||||
import org.whispersystems.libaxolotl.state.SessionState;
|
import org.whispersystems.libaxolotl.state.SessionState;
|
||||||
import org.whispersystems.libaxolotl.state.SessionStore;
|
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
import org.thoughtcrime.securesms.util.Conversions;
|
import org.thoughtcrime.securesms.util.Conversions;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -108,7 +108,7 @@ public class TextSecureSessionStore implements SessionStore {
|
|||||||
public void deleteAllSessions(long recipientId) {
|
public void deleteAllSessions(long recipientId) {
|
||||||
List<Integer> devices = getSubDeviceSessions(recipientId);
|
List<Integer> devices = getSubDeviceSessions(recipientId);
|
||||||
|
|
||||||
deleteSession(recipientId, PushAddress.DEFAULT_DEVICE_ID);
|
deleteSession(recipientId, TextSecureAddress.DEFAULT_DEVICE_ID);
|
||||||
|
|
||||||
for (int device : devices) {
|
for (int device : devices) {
|
||||||
deleteSession(recipientId, device);
|
deleteSession(recipientId, device);
|
||||||
@ -156,7 +156,7 @@ public class TextSecureSessionStore implements SessionStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getSessionName(long recipientId, int deviceId) {
|
private String getSessionName(long recipientId, int deviceId) {
|
||||||
return recipientId + (deviceId == PushAddress.DEFAULT_DEVICE_ID ? "" : "." + deviceId);
|
return recipientId + (deviceId == TextSecureAddress.DEFAULT_DEVICE_ID ? "" : "." + deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] readBlob(FileInputStream in) throws IOException {
|
private byte[] readBlob(FileInputStream in) throws IOException {
|
||||||
|
@ -7,7 +7,7 @@ import org.thoughtcrime.securesms.dependencies.InjectableType;
|
|||||||
import org.whispersystems.jobqueue.JobParameters;
|
import org.whispersystems.jobqueue.JobParameters;
|
||||||
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
||||||
import org.whispersystems.textsecure.api.TextSecureMessageSender;
|
import org.whispersystems.textsecure.api.TextSecureMessageSender;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException;
|
import org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.PushNetworkException;
|
import org.whispersystems.textsecure.api.push.exceptions.PushNetworkException;
|
||||||
|
|
||||||
@ -46,9 +46,9 @@ public class DeliveryReceiptJob extends ContextJob implements InjectableType {
|
|||||||
public void onRun() throws IOException {
|
public void onRun() throws IOException {
|
||||||
Log.w("DeliveryReceiptJob", "Sending delivery receipt...");
|
Log.w("DeliveryReceiptJob", "Sending delivery receipt...");
|
||||||
TextSecureMessageSender messageSender = messageSenderFactory.create(null);
|
TextSecureMessageSender messageSender = messageSenderFactory.create(null);
|
||||||
PushAddress pushAddress = new PushAddress(-1, destination, relay);
|
TextSecureAddress textSecureAddress = new TextSecureAddress(-1, destination, relay);
|
||||||
|
|
||||||
messageSender.sendDeliveryReceipt(pushAddress, timestamp);
|
messageSender.sendDeliveryReceipt(textSecureAddress, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,10 +25,9 @@ import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException;
|
|||||||
import org.whispersystems.textsecure.api.messages.TextSecureAttachment;
|
import org.whispersystems.textsecure.api.messages.TextSecureAttachment;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureGroup;
|
import org.whispersystems.textsecure.api.messages.TextSecureGroup;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.EncapsulatedExceptions;
|
import org.whispersystems.textsecure.api.push.exceptions.EncapsulatedExceptions;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.NetworkFailureException;
|
import org.whispersystems.textsecure.api.push.exceptions.NetworkFailureException;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.UnregisteredUserException;
|
|
||||||
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
||||||
import org.whispersystems.textsecure.internal.push.PushMessageProtos;
|
import org.whispersystems.textsecure.internal.push.PushMessageProtos;
|
||||||
|
|
||||||
@ -133,7 +132,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
|||||||
byte[] groupId = GroupUtil.getDecodedId(message.getTo()[0].getString());
|
byte[] groupId = GroupUtil.getDecodedId(message.getTo()[0].getString());
|
||||||
Recipients recipients = DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupId, false);
|
Recipients recipients = DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupId, false);
|
||||||
List<TextSecureAttachment> attachments = getAttachments(masterSecret, message);
|
List<TextSecureAttachment> attachments = getAttachments(masterSecret, message);
|
||||||
List<PushAddress> addresses;
|
List<TextSecureAddress> addresses;
|
||||||
|
|
||||||
if (filterRecipientId >= 0) addresses = getPushAddresses(filterRecipientId);
|
if (filterRecipientId >= 0) addresses = getPushAddresses(filterRecipientId);
|
||||||
else addresses = getPushAddresses(recipients);
|
else addresses = getPushAddresses(recipients);
|
||||||
@ -161,8 +160,8 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PushAddress> getPushAddresses(Recipients recipients) throws InvalidNumberException {
|
private List<TextSecureAddress> getPushAddresses(Recipients recipients) throws InvalidNumberException {
|
||||||
List<PushAddress> addresses = new LinkedList<>();
|
List<TextSecureAddress> addresses = new LinkedList<>();
|
||||||
|
|
||||||
for (Recipient recipient : recipients.getRecipientsList()) {
|
for (Recipient recipient : recipients.getRecipientsList()) {
|
||||||
addresses.add(getPushAddress(recipient));
|
addresses.add(getPushAddress(recipient));
|
||||||
@ -171,8 +170,8 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
|||||||
return addresses;
|
return addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PushAddress> getPushAddresses(long filterRecipientId) throws InvalidNumberException {
|
private List<TextSecureAddress> getPushAddresses(long filterRecipientId) throws InvalidNumberException {
|
||||||
List<PushAddress> addresses = new LinkedList<>();
|
List<TextSecureAddress> addresses = new LinkedList<>();
|
||||||
addresses.add(getPushAddress(RecipientFactory.getRecipientForId(context, filterRecipientId, false)));
|
addresses.add(getPushAddress(RecipientFactory.getRecipientForId(context, filterRecipientId, false)));
|
||||||
return addresses;
|
return addresses;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import org.thoughtcrime.securesms.crypto.storage.TextSecureAxolotlStore;
|
|||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||||
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||||
import org.thoughtcrime.securesms.mms.PartParser;
|
import org.thoughtcrime.securesms.mms.PartParser;
|
||||||
@ -26,7 +25,7 @@ import org.whispersystems.textsecure.api.TextSecureMessageSender;
|
|||||||
import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException;
|
import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureAttachment;
|
import org.whispersystems.textsecure.api.messages.TextSecureAttachment;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.UnregisteredUserException;
|
import org.whispersystems.textsecure.api.push.exceptions.UnregisteredUserException;
|
||||||
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
||||||
|
|
||||||
@ -119,7 +118,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
|||||||
try {
|
try {
|
||||||
prepareMessageMedia(masterSecret, message, MediaConstraints.PUSH_CONSTRAINTS, false);
|
prepareMessageMedia(masterSecret, message, MediaConstraints.PUSH_CONSTRAINTS, false);
|
||||||
Recipients recipients = RecipientFactory.getRecipientsFromString(context, destination, false);
|
Recipients recipients = RecipientFactory.getRecipientsFromString(context, destination, false);
|
||||||
PushAddress address = getPushAddress(recipients.getPrimaryRecipient());
|
TextSecureAddress address = getPushAddress(recipients.getPrimaryRecipient());
|
||||||
List<TextSecureAttachment> attachments = getAttachments(masterSecret, message);
|
List<TextSecureAttachment> attachments = getAttachments(masterSecret, message);
|
||||||
String body = PartParser.getMessageText(message.getBody());
|
String body = PartParser.getMessageText(message.getBody());
|
||||||
TextSecureMessage mediaMessage = new TextSecureMessage(message.getSentTimestamp(), attachments, body);
|
TextSecureMessage mediaMessage = new TextSecureMessage(message.getSentTimestamp(), attachments, body);
|
||||||
@ -150,7 +149,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
|||||||
Log.w(TAG, "Falling back to MMS");
|
Log.w(TAG, "Falling back to MMS");
|
||||||
DatabaseFactory.getMmsDatabase(context).markAsForcedSms(mediaMessage.getDatabaseMessageId());
|
DatabaseFactory.getMmsDatabase(context).markAsForcedSms(mediaMessage.getDatabaseMessageId());
|
||||||
ApplicationContext.getInstance(context).getJobManager().add(new MmsSendJob(context, messageId));
|
ApplicationContext.getInstance(context).getJobManager().add(new MmsSendJob(context, messageId));
|
||||||
} else if (!axolotlStore.containsSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID)) {
|
} else if (!axolotlStore.containsSession(recipient.getRecipientId(), TextSecureAddress.DEFAULT_DEVICE_ID)) {
|
||||||
Log.w(TAG, "Marking message as pending insecure SMS fallback");
|
Log.w(TAG, "Marking message as pending insecure SMS fallback");
|
||||||
throw new InsecureFallbackApprovalException("Pending user approval for fallback to insecure SMS");
|
throw new InsecureFallbackApprovalException("Pending user approval for fallback to insecure SMS");
|
||||||
} else {
|
} else {
|
||||||
|
@ -18,7 +18,7 @@ import org.whispersystems.jobqueue.JobParameters;
|
|||||||
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureAttachment;
|
import org.whispersystems.textsecure.api.messages.TextSecureAttachment;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureAttachmentStream;
|
import org.whispersystems.textsecure.api.messages.TextSecureAttachmentStream;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -76,10 +76,10 @@ public abstract class PushSendJob extends SendJob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PushAddress getPushAddress(Recipient recipient) throws InvalidNumberException {
|
protected TextSecureAddress getPushAddress(Recipient recipient) throws InvalidNumberException {
|
||||||
String e164number = Util.canonicalizeNumber(context, recipient.getNumber());
|
String e164number = Util.canonicalizeNumber(context, recipient.getNumber());
|
||||||
String relay = TextSecureDirectory.getInstance(context).getRelay(e164number);
|
String relay = TextSecureDirectory.getInstance(context).getRelay(e164number);
|
||||||
return new PushAddress(recipient.getRecipientId(), e164number, relay);
|
return new TextSecureAddress(recipient.getRecipientId(), e164number, relay);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isSmsFallbackApprovalRequired(String destination, boolean media) {
|
protected boolean isSmsFallbackApprovalRequired(String destination, boolean media) {
|
||||||
|
@ -24,7 +24,7 @@ import org.whispersystems.libaxolotl.state.AxolotlStore;
|
|||||||
import org.whispersystems.textsecure.api.TextSecureMessageSender;
|
import org.whispersystems.textsecure.api.TextSecureMessageSender;
|
||||||
import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException;
|
import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
import org.whispersystems.textsecure.api.push.exceptions.UnregisteredUserException;
|
import org.whispersystems.textsecure.api.push.exceptions.UnregisteredUserException;
|
||||||
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
|||||||
boolean isSmsFallbackSupported = isSmsFallbackSupported(context, destination, false);
|
boolean isSmsFallbackSupported = isSmsFallbackSupported(context, destination, false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PushAddress address = getPushAddress(message.getIndividualRecipient());
|
TextSecureAddress address = getPushAddress(message.getIndividualRecipient());
|
||||||
TextSecureMessageSender messageSender = messageSenderFactory.create(masterSecret);
|
TextSecureMessageSender messageSender = messageSenderFactory.create(masterSecret);
|
||||||
|
|
||||||
if (message.isEndSession()) {
|
if (message.isEndSession()) {
|
||||||
@ -146,7 +146,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
|||||||
Log.w(TAG, "Falling back to SMS");
|
Log.w(TAG, "Falling back to SMS");
|
||||||
DatabaseFactory.getSmsDatabase(context).markAsForcedSms(smsMessage.getId());
|
DatabaseFactory.getSmsDatabase(context).markAsForcedSms(smsMessage.getId());
|
||||||
ApplicationContext.getInstance(context).getJobManager().add(new SmsSendJob(context, messageId, destination));
|
ApplicationContext.getInstance(context).getJobManager().add(new SmsSendJob(context, messageId, destination));
|
||||||
} else if (!axolotlStore.containsSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID)) {
|
} else if (!axolotlStore.containsSession(recipient.getRecipientId(), TextSecureAddress.DEFAULT_DEVICE_ID)) {
|
||||||
Log.w(TAG, "Marking message as pending insecure fallback.");
|
Log.w(TAG, "Marking message as pending insecure fallback.");
|
||||||
throw new InsecureFallbackApprovalException("Pending user approval for fallback to insecure SMS");
|
throw new InsecureFallbackApprovalException("Pending user approval for fallback to insecure SMS");
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,7 +7,7 @@ import android.telephony.SmsMessage;
|
|||||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||||
import org.whispersystems.libaxolotl.util.guava.Optional;
|
import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||||
import org.whispersystems.textsecure.api.messages.TextSecureGroup;
|
import org.whispersystems.textsecure.api.messages.TextSecureGroup;
|
||||||
import org.whispersystems.textsecure.api.push.PushAddress;
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class IncomingTextMessage implements Parcelable {
|
|||||||
public IncomingTextMessage(SmsMessage message) {
|
public IncomingTextMessage(SmsMessage message) {
|
||||||
this.message = message.getDisplayMessageBody();
|
this.message = message.getDisplayMessageBody();
|
||||||
this.sender = message.getDisplayOriginatingAddress();
|
this.sender = message.getDisplayOriginatingAddress();
|
||||||
this.senderDeviceId = PushAddress.DEFAULT_DEVICE_ID;
|
this.senderDeviceId = TextSecureAddress.DEFAULT_DEVICE_ID;
|
||||||
this.protocol = message.getProtocolIdentifier();
|
this.protocol = message.getProtocolIdentifier();
|
||||||
this.serviceCenterAddress = message.getServiceCenterAddress();
|
this.serviceCenterAddress = message.getServiceCenterAddress();
|
||||||
this.replyPathPresent = message.isReplyPathPresent();
|
this.replyPathPresent = message.isReplyPathPresent();
|
||||||
@ -118,7 +118,7 @@ public class IncomingTextMessage implements Parcelable {
|
|||||||
{
|
{
|
||||||
this.message = "";
|
this.message = "";
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.senderDeviceId = PushAddress.DEFAULT_DEVICE_ID;
|
this.senderDeviceId = TextSecureAddress.DEFAULT_DEVICE_ID;
|
||||||
this.protocol = 31338;
|
this.protocol = 31338;
|
||||||
this.serviceCenterAddress = "Outgoing";
|
this.serviceCenterAddress = "Outgoing";
|
||||||
this.replyPathPresent = true;
|
this.replyPathPresent = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user