From f09abff407abf72d439526c0fbafad6960c4f00f Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Wed, 12 Nov 2014 09:09:55 -0800 Subject: [PATCH] Refactor out old classes. --- .../textsecure/push/PushAddress.java | 16 ++++++++-- .../storage/CanonicalRecipient.java | 6 ---- .../textsecure/storage/RecipientDevice.java | 31 ------------------- .../securesms/AutoInitiateActivity.java | 8 ++--- .../securesms/ConversationActivity.java | 6 ++-- .../securesms/VerifyIdentityActivity.java | 10 +++--- .../crypto/KeyExchangeInitiator.java | 8 ++--- .../securesms/crypto/MmsCipher.java | 6 ++-- .../securesms/crypto/SecurityEvent.java | 18 ----------- .../securesms/crypto/SmsCipher.java | 6 ++-- .../storage/TextSecureSessionStore.java | 6 ++-- .../securesms/jobs/PushMediaSendJob.java | 3 +- .../securesms/jobs/PushTextSendJob.java | 3 +- .../securesms/recipients/Recipient.java | 4 +-- .../securesms/sms/IncomingGroupMessage.java | 18 +++++------ .../securesms/sms/IncomingTextMessage.java | 6 ++-- 16 files changed, 53 insertions(+), 102 deletions(-) delete mode 100644 libtextsecure/src/main/java/org/whispersystems/textsecure/storage/CanonicalRecipient.java delete mode 100644 libtextsecure/src/main/java/org/whispersystems/textsecure/storage/RecipientDevice.java diff --git a/libtextsecure/src/main/java/org/whispersystems/textsecure/push/PushAddress.java b/libtextsecure/src/main/java/org/whispersystems/textsecure/push/PushAddress.java index 6ffb9ef735..67200eda80 100644 --- a/libtextsecure/src/main/java/org/whispersystems/textsecure/push/PushAddress.java +++ b/libtextsecure/src/main/java/org/whispersystems/textsecure/push/PushAddress.java @@ -1,15 +1,18 @@ package org.whispersystems.textsecure.push; -import org.whispersystems.textsecure.storage.RecipientDevice; +public class PushAddress { -public class PushAddress extends RecipientDevice { + public static final int DEFAULT_DEVICE_ID = 1; + private final long recipientId; private final String e164number; + private final int deviceId; private final String relay; public PushAddress(long recipientId, String e164number, int deviceId, String relay) { - super(recipientId, deviceId); + this.recipientId = recipientId; this.e164number = e164number; + this.deviceId = deviceId; this.relay = relay; } @@ -21,4 +24,11 @@ public class PushAddress extends RecipientDevice { return relay; } + public long getRecipientId() { + return recipientId; + } + + public int getDeviceId() { + return deviceId; + } } diff --git a/libtextsecure/src/main/java/org/whispersystems/textsecure/storage/CanonicalRecipient.java b/libtextsecure/src/main/java/org/whispersystems/textsecure/storage/CanonicalRecipient.java deleted file mode 100644 index 389cf3f4bb..0000000000 --- a/libtextsecure/src/main/java/org/whispersystems/textsecure/storage/CanonicalRecipient.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.whispersystems.textsecure.storage; - -public interface CanonicalRecipient { -// public String getNumber(); - public long getRecipientId(); -} diff --git a/libtextsecure/src/main/java/org/whispersystems/textsecure/storage/RecipientDevice.java b/libtextsecure/src/main/java/org/whispersystems/textsecure/storage/RecipientDevice.java deleted file mode 100644 index d97d9d460f..0000000000 --- a/libtextsecure/src/main/java/org/whispersystems/textsecure/storage/RecipientDevice.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.whispersystems.textsecure.storage; - -public class RecipientDevice { - - public static final int DEFAULT_DEVICE_ID = 1; - - private final long recipientId; - private final int deviceId; - - public RecipientDevice(long recipientId, int deviceId) { - this.recipientId = recipientId; - this.deviceId = deviceId; - } - - public long getRecipientId() { - return recipientId; - } - - public int getDeviceId() { - return deviceId; - } - - public CanonicalRecipient getRecipient() { - return new CanonicalRecipient() { - @Override - public long getRecipientId() { - return recipientId; - } - }; - } -} diff --git a/src/org/thoughtcrime/securesms/AutoInitiateActivity.java b/src/org/thoughtcrime/securesms/AutoInitiateActivity.java index e5637f6b2a..d185830add 100644 --- a/src/org/thoughtcrime/securesms/AutoInitiateActivity.java +++ b/src/org/thoughtcrime/securesms/AutoInitiateActivity.java @@ -26,14 +26,14 @@ import android.view.View; import android.widget.Button; import org.thoughtcrime.securesms.crypto.KeyExchangeInitiator; +import org.thoughtcrime.securesms.crypto.MasterSecret; +import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore; import org.thoughtcrime.securesms.protocol.Tag; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.util.MemoryCleaner; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.whispersystems.libaxolotl.state.SessionStore; -import org.thoughtcrime.securesms.crypto.MasterSecret; -import org.whispersystems.textsecure.storage.RecipientDevice; -import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore; +import org.whispersystems.textsecure.push.PushAddress; /** * Activity which prompts the user to initiate a secure @@ -118,6 +118,6 @@ public class AutoInitiateActivity extends Activity { Recipient recipient) { SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret); - return sessionStore.containsSession(recipient.getRecipientId(), RecipientDevice.DEFAULT_DEVICE_ID); + return sessionStore.containsSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID); } } diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index 618416ac6e..c6e8a67679 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -107,7 +107,7 @@ import org.thoughtcrime.securesms.util.MemoryCleaner; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.whispersystems.libaxolotl.InvalidMessageException; import org.whispersystems.libaxolotl.state.SessionStore; -import org.whispersystems.textsecure.storage.RecipientDevice; +import org.whispersystems.textsecure.push.PushAddress; import org.whispersystems.textsecure.util.Util; import java.io.IOException; @@ -318,7 +318,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity Recipient primaryRecipient = getRecipients() == null ? null : getRecipients().getPrimaryRecipient(); boolean isPushDestination = DirectoryHelper.isPushDestination(this, getRecipients()); boolean isSecureDestination = isSingleConversation() && sessionStore.containsSession(primaryRecipient.getRecipientId(), - RecipientDevice.DEFAULT_DEVICE_ID); + PushAddress.DEFAULT_DEVICE_ID); getMenuInflater().inflate(R.menu.conversation_button_context, menu); @@ -697,7 +697,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity Recipient primaryRecipient = getRecipients() == null ? null : getRecipients().getPrimaryRecipient(); boolean isPushDestination = DirectoryHelper.isPushDestination(this, getRecipients()); boolean isSecureDestination = isSingleConversation() && sessionStore.containsSession(primaryRecipient.getRecipientId(), - RecipientDevice.DEFAULT_DEVICE_ID); + PushAddress.DEFAULT_DEVICE_ID); if (isPushDestination || isSecureDestination) { this.isEncryptedConversation = true; diff --git a/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java b/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java index 5f4e47922c..c4b8008bf4 100644 --- a/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java +++ b/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java @@ -21,7 +21,10 @@ import android.os.Bundle; import android.widget.TextView; import android.widget.Toast; +import org.thoughtcrime.securesms.crypto.IdentityKeyParcelable; import org.thoughtcrime.securesms.crypto.IdentityKeyUtil; +import org.thoughtcrime.securesms.crypto.MasterSecret; +import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicTheme; @@ -29,10 +32,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.thoughtcrime.securesms.crypto.IdentityKeyParcelable; -import org.thoughtcrime.securesms.crypto.MasterSecret; -import org.whispersystems.textsecure.storage.RecipientDevice; -import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore; +import org.whispersystems.textsecure.push.PushAddress; /** * Activity for verifying identity keys. @@ -184,7 +184,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(), - RecipientDevice.DEFAULT_DEVICE_ID); + PushAddress.DEFAULT_DEVICE_ID); if (record == null) { return null; diff --git a/src/org/thoughtcrime/securesms/crypto/KeyExchangeInitiator.java b/src/org/thoughtcrime/securesms/crypto/KeyExchangeInitiator.java index 02bfa47b88..4331526762 100644 --- a/src/org/thoughtcrime/securesms/crypto/KeyExchangeInitiator.java +++ b/src/org/thoughtcrime/securesms/crypto/KeyExchangeInitiator.java @@ -31,12 +31,12 @@ import org.thoughtcrime.securesms.sms.OutgoingKeyExchangeMessage; import org.thoughtcrime.securesms.util.Dialogs; import org.whispersystems.libaxolotl.SessionBuilder; import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage; -import org.whispersystems.libaxolotl.state.SignedPreKeyStore; import org.whispersystems.libaxolotl.state.IdentityKeyStore; import org.whispersystems.libaxolotl.state.PreKeyStore; import org.whispersystems.libaxolotl.state.SessionRecord; import org.whispersystems.libaxolotl.state.SessionStore; -import org.whispersystems.textsecure.storage.RecipientDevice; +import org.whispersystems.libaxolotl.state.SignedPreKeyStore; +import org.whispersystems.textsecure.push.PushAddress; import org.whispersystems.textsecure.util.Base64; public class KeyExchangeInitiator { @@ -68,7 +68,7 @@ public class KeyExchangeInitiator { SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore, identityKeyStore, recipient.getRecipientId(), - RecipientDevice.DEFAULT_DEVICE_ID); + PushAddress.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(), RecipientDevice.DEFAULT_DEVICE_ID); + SessionRecord sessionRecord = sessionStore.loadSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID); return sessionRecord.getSessionState().hasPendingKeyExchange(); } diff --git a/src/org/thoughtcrime/securesms/crypto/MmsCipher.java b/src/org/thoughtcrime/securesms/crypto/MmsCipher.java index aaf887871e..c650c7b15e 100644 --- a/src/org/thoughtcrime/securesms/crypto/MmsCipher.java +++ b/src/org/thoughtcrime/securesms/crypto/MmsCipher.java @@ -17,7 +17,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.storage.RecipientDevice; +import org.whispersystems.textsecure.push.PushAddress; import org.whispersystems.textsecure.util.Util; import java.io.IOException; @@ -92,11 +92,11 @@ public class MmsCipher { long recipientId = recipients.getPrimaryRecipient().getRecipientId(); byte[] pduBytes = new PduComposer(context, message).make(); - if (!axolotlStore.containsSession(recipientId, RecipientDevice.DEFAULT_DEVICE_ID)) { + if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) { throw new NoSessionException("No session for: " + recipientId); } - SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, RecipientDevice.DEFAULT_DEVICE_ID); + SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID); CiphertextMessage ciphertextMessage = cipher.encrypt(pduBytes); byte[] encryptedPduBytes = textTransport.getEncodedMessage(ciphertextMessage.serialize()); diff --git a/src/org/thoughtcrime/securesms/crypto/SecurityEvent.java b/src/org/thoughtcrime/securesms/crypto/SecurityEvent.java index e91746ca01..035c8527ba 100644 --- a/src/org/thoughtcrime/securesms/crypto/SecurityEvent.java +++ b/src/org/thoughtcrime/securesms/crypto/SecurityEvent.java @@ -3,25 +3,7 @@ package org.thoughtcrime.securesms.crypto; import android.content.Context; import android.content.Intent; -import org.thoughtcrime.securesms.crypto.storage.TextSecureIdentityKeyStore; -import org.thoughtcrime.securesms.crypto.storage.TextSecurePreKeyStore; -import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore; -import org.thoughtcrime.securesms.recipients.Recipient; -import org.thoughtcrime.securesms.recipients.RecipientFactory; import org.thoughtcrime.securesms.service.KeyCachingService; -import org.thoughtcrime.securesms.sms.OutgoingKeyExchangeMessage; -import org.whispersystems.libaxolotl.InvalidKeyException; -import org.whispersystems.libaxolotl.SessionBuilder; -import org.whispersystems.libaxolotl.StaleKeyExchangeException; -import org.whispersystems.libaxolotl.UntrustedIdentityException; -import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage; -import org.whispersystems.libaxolotl.state.SignedPreKeyStore; -import org.whispersystems.libaxolotl.state.IdentityKeyStore; -import org.whispersystems.libaxolotl.state.PreKeyBundle; -import org.whispersystems.libaxolotl.state.PreKeyStore; -import org.whispersystems.libaxolotl.state.SessionStore; -import org.whispersystems.textsecure.storage.RecipientDevice; -import org.whispersystems.textsecure.util.Base64; /** * This class processes key exchange interactions. diff --git a/src/org/thoughtcrime/securesms/crypto/SmsCipher.java b/src/org/thoughtcrime/securesms/crypto/SmsCipher.java index 3d1f1c450e..b3b923c324 100644 --- a/src/org/thoughtcrime/securesms/crypto/SmsCipher.java +++ b/src/org/thoughtcrime/securesms/crypto/SmsCipher.java @@ -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.storage.RecipientDevice; +import org.whispersystems.textsecure.push.PushAddress; 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, RecipientDevice.DEFAULT_DEVICE_ID)) { + if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) { throw new NoSessionException("No session for: " + recipientId); } - SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, RecipientDevice.DEFAULT_DEVICE_ID); + SessionCipher cipher = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID); CiphertextMessage ciphertextMessage = cipher.encrypt(paddedBody); String encodedCiphertext = new String(transportDetails.getEncodedMessage(ciphertextMessage.serialize())); diff --git a/src/org/thoughtcrime/securesms/crypto/storage/TextSecureSessionStore.java b/src/org/thoughtcrime/securesms/crypto/storage/TextSecureSessionStore.java index 15db4c2165..45e65fe0d8 100644 --- a/src/org/thoughtcrime/securesms/crypto/storage/TextSecureSessionStore.java +++ b/src/org/thoughtcrime/securesms/crypto/storage/TextSecureSessionStore.java @@ -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.storage.RecipientDevice; +import org.whispersystems.textsecure.push.PushAddress; import org.whispersystems.textsecure.util.Conversions; import java.io.File; @@ -108,7 +108,7 @@ public class TextSecureSessionStore implements SessionStore { public void deleteAllSessions(long recipientId) { List devices = getSubDeviceSessions(recipientId); - deleteSession(recipientId, RecipientDevice.DEFAULT_DEVICE_ID); + deleteSession(recipientId, PushAddress.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 == RecipientDevice.DEFAULT_DEVICE_ID ? "" : "." + deviceId); + return recipientId + (deviceId == PushAddress.DEFAULT_DEVICE_ID ? "" : "." + deviceId); } private byte[] readBlob(FileInputStream in) throws IOException { diff --git a/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java index f638e8c209..c6b7e6fd1f 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java @@ -26,7 +26,6 @@ import org.whispersystems.textsecure.api.messages.TextSecureAttachment; import org.whispersystems.textsecure.api.messages.TextSecureMessage; import org.whispersystems.textsecure.push.PushAddress; import org.whispersystems.textsecure.push.UnregisteredUserException; -import org.whispersystems.textsecure.storage.RecipientDevice; import org.whispersystems.textsecure.util.InvalidNumberException; import java.io.IOException; @@ -138,7 +137,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(), RecipientDevice.DEFAULT_DEVICE_ID)) { + } else if (!axolotlStore.containsSession(recipient.getRecipientId(), PushAddress.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 { diff --git a/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java index e00a5edf65..ec87793929 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java @@ -24,7 +24,6 @@ import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException; import org.whispersystems.textsecure.api.messages.TextSecureMessage; import org.whispersystems.textsecure.push.PushAddress; import org.whispersystems.textsecure.push.UnregisteredUserException; -import org.whispersystems.textsecure.storage.RecipientDevice; import org.whispersystems.textsecure.util.InvalidNumberException; import java.io.IOException; @@ -137,7 +136,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(), RecipientDevice.DEFAULT_DEVICE_ID)) { + } else if (!axolotlStore.containsSession(recipient.getRecipientId(), PushAddress.DEFAULT_DEVICE_ID)) { Log.w(TAG, "Marking message as pending insecure fallback."); throw new InsecureFallbackApprovalException("Pending user approval for fallback to insecure SMS"); } else { diff --git a/src/org/thoughtcrime/securesms/recipients/Recipient.java b/src/org/thoughtcrime/securesms/recipients/Recipient.java index 6545f28796..2f1843a1df 100644 --- a/src/org/thoughtcrime/securesms/recipients/Recipient.java +++ b/src/org/thoughtcrime/securesms/recipients/Recipient.java @@ -25,15 +25,13 @@ import android.util.Log; import org.thoughtcrime.securesms.contacts.ContactPhotoFactory; import org.thoughtcrime.securesms.recipients.RecipientProvider.RecipientDetails; -import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.GroupUtil; -import org.whispersystems.textsecure.storage.CanonicalRecipient; import org.whispersystems.textsecure.util.FutureTaskListener; import org.whispersystems.textsecure.util.ListenableFutureTask; import java.util.HashSet; -public class Recipient implements Parcelable, CanonicalRecipient { +public class Recipient implements Parcelable { private final static String TAG = Recipient.class.getSimpleName(); diff --git a/src/org/thoughtcrime/securesms/sms/IncomingGroupMessage.java b/src/org/thoughtcrime/securesms/sms/IncomingGroupMessage.java index 2c282d8df0..a36f942545 100644 --- a/src/org/thoughtcrime/securesms/sms/IncomingGroupMessage.java +++ b/src/org/thoughtcrime/securesms/sms/IncomingGroupMessage.java @@ -35,14 +35,14 @@ public class IncomingGroupMessage extends IncomingTextMessage { return groupContext.getType().getNumber() == GroupContext.Type.QUIT_VALUE; } - public static IncomingGroupMessage createForQuit(String groupId, String user) throws IOException { - IncomingTextMessage base = new IncomingTextMessage(user, groupId); - GroupContext context = GroupContext.newBuilder() - .setType(GroupContext.Type.QUIT) - .setId(ByteString.copyFrom(GroupUtil.getDecodedId(groupId))) - .build(); - - return new IncomingGroupMessage(base, context, ""); - } +// public static IncomingGroupMessage createForQuit(String groupId, String user) throws IOException { +// IncomingTextMessage base = new IncomingTextMessage(user, groupId); +// GroupContext context = GroupContext.newBuilder() +// .setType(GroupContext.Type.QUIT) +// .setId(ByteString.copyFrom(GroupUtil.getDecodedId(groupId))) +// .build(); +// +// return new IncomingGroupMessage(base, context, ""); +// } } diff --git a/src/org/thoughtcrime/securesms/sms/IncomingTextMessage.java b/src/org/thoughtcrime/securesms/sms/IncomingTextMessage.java index 4dea924f38..b021703901 100644 --- a/src/org/thoughtcrime/securesms/sms/IncomingTextMessage.java +++ b/src/org/thoughtcrime/securesms/sms/IncomingTextMessage.java @@ -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.storage.RecipientDevice; +import org.whispersystems.textsecure.push.PushAddress; 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 = RecipientDevice.DEFAULT_DEVICE_ID; + this.senderDeviceId = PushAddress.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 = RecipientDevice.DEFAULT_DEVICE_ID; + this.senderDeviceId = PushAddress.DEFAULT_DEVICE_ID; this.protocol = 31338; this.serviceCenterAddress = "Outgoing"; this.replyPathPresent = true;