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

@@ -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 {