Rename PushAddress to TextSecureAddress

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2015-02-27 16:57:32 -08:00
parent 753a1c7219
commit a59feb7ad4
19 changed files with 75 additions and 75 deletions

View File

@ -1,13 +1,11 @@
package org.thoughtcrime.securesms.jobs;
import android.test.AndroidTestCase;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.thoughtcrime.securesms.TextSecureTestCase;
import org.thoughtcrime.securesms.crypto.MasterSecret;
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.PushNetworkException;
@ -38,7 +36,7 @@ public class DeliveryReceiptJobTest extends TextSecureTestCase {
deliveryReceiptJob.onRun();
ArgumentCaptor<PushAddress> captor = ArgumentCaptor.forClass(PushAddress.class);
ArgumentCaptor<TextSecureAddress> captor = ArgumentCaptor.forClass(TextSecureAddress.class);
verify(textSecureMessageSender).sendDeliveryReceipt(captor.capture(), eq(timestamp));
assertTrue(captor.getValue().getRelay().equals("foo"));
@ -51,7 +49,7 @@ public class DeliveryReceiptJobTest extends TextSecureTestCase {
Mockito.doThrow(new PushNetworkException("network error"))
.when(textSecureMessageSender)
.sendDeliveryReceipt(any(PushAddress.class), eq(timestamp));
.sendDeliveryReceipt(any(TextSecureAddress.class), eq(timestamp));
DeliveryReceiptJob deliveryReceiptJob = new DeliveryReceiptJob(getContext(),
@ -70,7 +68,7 @@ public class DeliveryReceiptJobTest extends TextSecureTestCase {
Mockito.doThrow(new NotFoundException("not found"))
.when(textSecureMessageSender)
.sendDeliveryReceipt(any(PushAddress.class), eq(timestamp));
.sendDeliveryReceipt(any(TextSecureAddress.class), eq(timestamp));
try {
deliveryReceiptJob.onRun();

View File

@ -33,7 +33,7 @@ import org.whispersystems.textsecure.api.messages.TextSecureAttachment;
import org.whispersystems.textsecure.api.messages.TextSecureAttachmentStream;
import org.whispersystems.textsecure.api.messages.TextSecureGroup;
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.exceptions.NetworkFailureException;
import org.whispersystems.textsecure.api.push.exceptions.PushNetworkException;
@ -72,7 +72,7 @@ public class TextSecureMessageSender {
private final PushServiceSocket socket;
private final AxolotlStore store;
private final PushAddress syncAddress;
private final TextSecureAddress syncAddress;
private final Optional<EventListener> eventListener;
/**
@ -94,7 +94,7 @@ public class TextSecureMessageSender {
{
this.socket = new PushServiceSocket(url, trustStore, new StaticCredentialsProvider(user, password, null));
this.store = store;
this.syncAddress = new PushAddress(userId, user, null);
this.syncAddress = new TextSecureAddress(userId, user, null);
this.eventListener = eventListener;
}
@ -105,7 +105,7 @@ public class TextSecureMessageSender {
* @param messageId The message id of the received message you're acknowledging.
* @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());
}
@ -117,7 +117,7 @@ public class TextSecureMessageSender {
* @throws UntrustedIdentityException
* @throws IOException
*/
public void sendMessage(PushAddress recipient, TextSecureMessage message)
public void sendMessage(TextSecureAddress recipient, TextSecureMessage message)
throws UntrustedIdentityException, IOException
{
byte[] content = createMessageContent(message);
@ -146,7 +146,7 @@ public class TextSecureMessageSender {
* @throws IOException
* @throws EncapsulatedExceptions
*/
public void sendMessage(List<PushAddress> recipients, TextSecureMessage message)
public void sendMessage(List<TextSecureAddress> recipients, TextSecureMessage message)
throws IOException, EncapsulatedExceptions
{
byte[] content = createMessageContent(message);
@ -176,7 +176,7 @@ public class TextSecureMessageSender {
return builder.build().toByteArray();
}
private byte[] createSyncMessageContent(byte[] content, PushAddress recipient, long timestamp) {
private byte[] createSyncMessageContent(byte[] content, TextSecureAddress recipient, long timestamp) {
try {
PushMessageContent.Builder builder = PushMessageContent.parseFrom(content).toBuilder();
builder.setSync(PushMessageContent.SyncMessageContext.newBuilder()
@ -213,14 +213,14 @@ public class TextSecureMessageSender {
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
{
List<UntrustedIdentityException> untrustedIdentities = new LinkedList<>();
List<UnregisteredUserException> unregisteredUsers = new LinkedList<>();
List<NetworkFailureException> networkExceptions = new LinkedList<>();
for (PushAddress recipient : recipients) {
for (TextSecureAddress recipient : recipients) {
try {
sendMessage(recipient, timestamp, content);
} 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
{
for (int i=0;i<3;i++) {
@ -297,7 +297,7 @@ public class TextSecureMessageSender {
private OutgoingPushMessageList getEncryptedMessages(PushServiceSocket socket,
PushAddress recipient,
TextSecureAddress recipient,
long timestamp,
byte[] plaintext)
throws IOException, UntrustedIdentityException
@ -305,8 +305,8 @@ public class TextSecureMessageSender {
List<OutgoingPushMessage> messages = new LinkedList<>();
if (!recipient.equals(syncAddress)) {
PushBody masterBody = getEncryptedMessage(socket, recipient, PushAddress.DEFAULT_DEVICE_ID, plaintext);
messages.add(new OutgoingPushMessage(recipient, PushAddress.DEFAULT_DEVICE_ID, masterBody));
PushBody masterBody = getEncryptedMessage(socket, recipient, TextSecureAddress.DEFAULT_DEVICE_ID, plaintext);
messages.add(new OutgoingPushMessage(recipient, TextSecureAddress.DEFAULT_DEVICE_ID, masterBody));
}
for (int deviceId : store.getSubDeviceSessions(recipient.getRecipientId())) {
@ -317,7 +317,7 @@ public class TextSecureMessageSender {
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
{
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)
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();
for (int staleDeviceId : staleDevices.getStaleDevices()) {

View File

@ -18,6 +18,7 @@ package org.whispersystems.textsecure.api.messages;
import org.whispersystems.libaxolotl.util.guava.Optional;
import java.util.LinkedList;
import java.util.List;
/**
@ -39,7 +40,11 @@ public class TextSecureMessage {
* @param body The message contents.
*/
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);
}
/**

View File

@ -19,7 +19,7 @@ package org.whispersystems.textsecure.api.push;
/**
* A class representing a message destination or origin.
*/
public class PushAddress {
public class TextSecureAddress {
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 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.e164number = e164number;
this.relay = relay;
@ -54,9 +54,9 @@ public class PushAddress {
@Override
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 &&
equals(this.e164number, that.e164number) &&

View File

@ -19,7 +19,7 @@ package org.whispersystems.textsecure.internal.push;
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;
public class OutgoingPushMessage {
@ -33,7 +33,7 @@ public class OutgoingPushMessage {
@JsonProperty
private String body;
public OutgoingPushMessage(PushAddress address, int deviceId, PushBody body) {
public OutgoingPushMessage(TextSecureAddress address, int deviceId, PushBody body) {
this.type = body.getType();
this.destinationDeviceId = deviceId;
this.destinationRegistrationId = body.getRemoteRegistrationId();

View File

@ -28,7 +28,7 @@ import org.whispersystems.libaxolotl.state.PreKeyRecord;
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
import org.whispersystems.textsecure.api.crypto.AttachmentCipherOutputStream;
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.TrustStore;
import org.whispersystems.textsecure.api.push.exceptions.AuthorizationFailedException;
@ -194,7 +194,7 @@ public class PushServiceSocket {
return preKeyStatus.getCount();
}
public List<PreKeyBundle> getPreKeys(PushAddress destination, int deviceIdInteger) throws IOException {
public List<PreKeyBundle> getPreKeys(TextSecureAddress destination, int deviceIdInteger) throws IOException {
try {
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 {
String path = String.format(PREKEY_DEVICE_PATH, destination.getNumber(),
String.valueOf(deviceId));

View File

@ -33,7 +33,7 @@ import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.util.MemoryCleaner;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
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
@ -118,6 +118,6 @@ public class AutoInitiateActivity extends BaseActivity {
Recipient recipient)
{
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
return sessionStore.containsSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID);
return sessionStore.containsSession(recipient.getRecipientId(), TextSecureAddress.DEFAULT_DEVICE_ID);
}
}

View File

@ -68,7 +68,6 @@ import org.thoughtcrime.securesms.database.DraftDatabase.Draft;
import org.thoughtcrime.securesms.database.DraftDatabase.Drafts;
import org.thoughtcrime.securesms.database.GroupDatabase;
import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
import org.thoughtcrime.securesms.database.TextSecureDirectory;
import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.mms.AttachmentManager;
import org.thoughtcrime.securesms.mms.AttachmentTypeSelectorAdapter;
@ -104,7 +103,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.libaxolotl.InvalidMessageException;
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.security.NoSuchAlgorithmException;
@ -689,7 +688,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
boolean isSecureSmsDestination = isSecureSmsAllowed &&
isSingleConversation() &&
sessionStore.containsSession(primaryRecipient.getRecipientId(),
PushAddress.DEFAULT_DEVICE_ID);
TextSecureAddress.DEFAULT_DEVICE_ID);
if (isPushDestination || isSecureSmsDestination) {
this.isEncryptedConversation = true;

View File

@ -33,7 +33,7 @@ import org.thoughtcrime.securesms.util.MemoryCleaner;
import org.whispersystems.libaxolotl.IdentityKey;
import org.whispersystems.libaxolotl.state.SessionRecord;
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.
@ -185,7 +185,7 @@ public class VerifyIdentityActivity extends KeyScanningActivity {
private IdentityKey getRemoteIdentityKey(MasterSecret masterSecret, Recipient recipient) {
SessionStore sessionStore = new TextSecureSessionStore(this, masterSecret);
SessionRecord record = sessionStore.loadSession(recipient.getRecipientId(),
PushAddress.DEFAULT_DEVICE_ID);
TextSecureAddress.DEFAULT_DEVICE_ID);
if (record == null) {
return null;

View File

@ -37,7 +37,7 @@ import org.whispersystems.libaxolotl.state.PreKeyStore;
import org.whispersystems.libaxolotl.state.SessionRecord;
import org.whispersystems.libaxolotl.state.SessionStore;
import org.whispersystems.libaxolotl.state.SignedPreKeyStore;
import org.whispersystems.textsecure.api.push.PushAddress;
import org.whispersystems.textsecure.api.push.TextSecureAddress;
public class KeyExchangeInitiator {
@ -68,7 +68,7 @@ public class KeyExchangeInitiator {
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
identityKeyStore, recipient.getRecipientId(),
PushAddress.DEFAULT_DEVICE_ID);
TextSecureAddress.DEFAULT_DEVICE_ID);
KeyExchangeMessage keyExchangeMessage = sessionBuilder.process();
String serializedMessage = Base64.encodeBytesWithoutPadding(keyExchangeMessage.serialize());
@ -81,7 +81,7 @@ public class KeyExchangeInitiator {
Recipient recipient)
{
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();
}

View File

@ -19,7 +19,7 @@ import org.whispersystems.libaxolotl.protocol.CiphertextMessage;
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
import org.whispersystems.libaxolotl.state.AxolotlStore;
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;
@ -101,11 +101,11 @@ public class MmsCipher {
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);
}
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);
byte[] encryptedPduBytes = textTransport.getEncodedMessage(ciphertextMessage.serialize());

View File

@ -30,7 +30,7 @@ import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage;
import org.whispersystems.libaxolotl.protocol.PreKeyWhisperMessage;
import org.whispersystems.libaxolotl.protocol.WhisperMessage;
import org.whispersystems.libaxolotl.state.AxolotlStore;
import org.whispersystems.textsecure.api.push.PushAddress;
import org.whispersystems.textsecure.api.push.TextSecureAddress;
import java.io.IOException;
@ -89,11 +89,11 @@ public class SmsCipher {
byte[] paddedBody = transportDetails.getPaddedMessageBody(message.getMessageBody().getBytes());
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);
}
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);
String encodedCiphertext = new String(transportDetails.getEncodedMessage(ciphertextMessage.serialize()));

View File

@ -9,7 +9,7 @@ import org.whispersystems.libaxolotl.InvalidMessageException;
import org.whispersystems.libaxolotl.state.SessionRecord;
import org.whispersystems.libaxolotl.state.SessionState;
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 java.io.File;
@ -108,7 +108,7 @@ public class TextSecureSessionStore implements SessionStore {
public void deleteAllSessions(long recipientId) {
List<Integer> devices = getSubDeviceSessions(recipientId);
deleteSession(recipientId, PushAddress.DEFAULT_DEVICE_ID);
deleteSession(recipientId, TextSecureAddress.DEFAULT_DEVICE_ID);
for (int device : devices) {
deleteSession(recipientId, device);
@ -156,7 +156,7 @@ public class TextSecureSessionStore implements SessionStore {
}
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 {

View File

@ -7,7 +7,7 @@ import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.whispersystems.jobqueue.JobParameters;
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
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.PushNetworkException;
@ -45,10 +45,10 @@ public class DeliveryReceiptJob extends ContextJob implements InjectableType {
@Override
public void onRun() throws IOException {
Log.w("DeliveryReceiptJob", "Sending delivery receipt...");
TextSecureMessageSender messageSender = messageSenderFactory.create(null);
PushAddress pushAddress = new PushAddress(-1, destination, relay);
TextSecureMessageSender messageSender = messageSenderFactory.create(null);
TextSecureAddress textSecureAddress = new TextSecureAddress(-1, destination, relay);
messageSender.sendDeliveryReceipt(pushAddress, timestamp);
messageSender.sendDeliveryReceipt(textSecureAddress, timestamp);
}
@Override

View File

@ -25,10 +25,9 @@ import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException;
import org.whispersystems.textsecure.api.messages.TextSecureAttachment;
import org.whispersystems.textsecure.api.messages.TextSecureGroup;
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.NetworkFailureException;
import org.whispersystems.textsecure.api.push.exceptions.UnregisteredUserException;
import org.whispersystems.textsecure.api.util.InvalidNumberException;
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());
Recipients recipients = DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupId, false);
List<TextSecureAttachment> attachments = getAttachments(masterSecret, message);
List<PushAddress> addresses;
List<TextSecureAddress> addresses;
if (filterRecipientId >= 0) addresses = getPushAddresses(filterRecipientId);
else addresses = getPushAddresses(recipients);
@ -161,8 +160,8 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
}
}
private List<PushAddress> getPushAddresses(Recipients recipients) throws InvalidNumberException {
List<PushAddress> addresses = new LinkedList<>();
private List<TextSecureAddress> getPushAddresses(Recipients recipients) throws InvalidNumberException {
List<TextSecureAddress> addresses = new LinkedList<>();
for (Recipient recipient : recipients.getRecipientsList()) {
addresses.add(getPushAddress(recipient));
@ -171,8 +170,8 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
return addresses;
}
private List<PushAddress> getPushAddresses(long filterRecipientId) throws InvalidNumberException {
List<PushAddress> addresses = new LinkedList<>();
private List<TextSecureAddress> getPushAddresses(long filterRecipientId) throws InvalidNumberException {
List<TextSecureAddress> addresses = new LinkedList<>();
addresses.add(getPushAddress(RecipientFactory.getRecipientForId(context, filterRecipientId, false)));
return addresses;
}

View File

@ -9,7 +9,6 @@ import org.thoughtcrime.securesms.crypto.storage.TextSecureAxolotlStore;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.MmsDatabase;
import org.thoughtcrime.securesms.database.NoSuchMessageException;
import org.thoughtcrime.securesms.database.SmsDatabase;
import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.thoughtcrime.securesms.mms.MediaConstraints;
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.messages.TextSecureAttachment;
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.util.InvalidNumberException;
@ -119,7 +118,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
try {
prepareMessageMedia(masterSecret, message, MediaConstraints.PUSH_CONSTRAINTS, false);
Recipients recipients = RecipientFactory.getRecipientsFromString(context, destination, false);
PushAddress address = getPushAddress(recipients.getPrimaryRecipient());
TextSecureAddress address = getPushAddress(recipients.getPrimaryRecipient());
List<TextSecureAttachment> attachments = getAttachments(masterSecret, message);
String body = PartParser.getMessageText(message.getBody());
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");
DatabaseFactory.getMmsDatabase(context).markAsForcedSms(mediaMessage.getDatabaseMessageId());
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");
throw new InsecureFallbackApprovalException("Pending user approval for fallback to insecure SMS");
} else {

View File

@ -18,7 +18,7 @@ import org.whispersystems.jobqueue.JobParameters;
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
import org.whispersystems.textsecure.api.messages.TextSecureAttachment;
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 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 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) {

View File

@ -24,7 +24,7 @@ import org.whispersystems.libaxolotl.state.AxolotlStore;
import org.whispersystems.textsecure.api.TextSecureMessageSender;
import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException;
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.util.InvalidNumberException;
@ -111,7 +111,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
boolean isSmsFallbackSupported = isSmsFallbackSupported(context, destination, false);
try {
PushAddress address = getPushAddress(message.getIndividualRecipient());
TextSecureAddress address = getPushAddress(message.getIndividualRecipient());
TextSecureMessageSender messageSender = messageSenderFactory.create(masterSecret);
if (message.isEndSession()) {
@ -146,7 +146,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
Log.w(TAG, "Falling back to SMS");
DatabaseFactory.getSmsDatabase(context).markAsForcedSms(smsMessage.getId());
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.");
throw new InsecureFallbackApprovalException("Pending user approval for fallback to insecure SMS");
} else {

View File

@ -7,7 +7,7 @@ import android.telephony.SmsMessage;
import org.thoughtcrime.securesms.util.GroupUtil;
import org.whispersystems.libaxolotl.util.guava.Optional;
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;
@ -39,7 +39,7 @@ public class IncomingTextMessage implements Parcelable {
public IncomingTextMessage(SmsMessage message) {
this.message = message.getDisplayMessageBody();
this.sender = message.getDisplayOriginatingAddress();
this.senderDeviceId = PushAddress.DEFAULT_DEVICE_ID;
this.senderDeviceId = TextSecureAddress.DEFAULT_DEVICE_ID;
this.protocol = message.getProtocolIdentifier();
this.serviceCenterAddress = message.getServiceCenterAddress();
this.replyPathPresent = message.isReplyPathPresent();
@ -118,7 +118,7 @@ public class IncomingTextMessage implements Parcelable {
{
this.message = "";
this.sender = sender;
this.senderDeviceId = PushAddress.DEFAULT_DEVICE_ID;
this.senderDeviceId = TextSecureAddress.DEFAULT_DEVICE_ID;
this.protocol = 31338;
this.serviceCenterAddress = "Outgoing";
this.replyPathPresent = true;