mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-29 09:06:37 +00:00
Rename PushAddress to TextSecureAddress
// FREEBIE
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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) &&
|
||||
@@ -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();
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user