mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Merge IncomingTextMessages into IncomingMessage.
This commit is contained in:
committed by
Cody Henthorne
parent
23b696c9cf
commit
6b3f41d675
@@ -1,13 +0,0 @@
|
||||
package org.thoughtcrime.securesms.sms;
|
||||
|
||||
public class IncomingEncryptedMessage extends IncomingTextMessage {
|
||||
|
||||
public IncomingEncryptedMessage(IncomingTextMessage base, String newBody) {
|
||||
super(base, newBody);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecureMessage() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.thoughtcrime.securesms.sms;
|
||||
|
||||
public class IncomingEndSessionMessage extends IncomingTextMessage {
|
||||
|
||||
public IncomingEndSessionMessage(IncomingTextMessage base) {
|
||||
this(base, base.getMessageBody());
|
||||
}
|
||||
|
||||
public IncomingEndSessionMessage(IncomingTextMessage base, String newBody) {
|
||||
super(base, newBody);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEndSession() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package org.thoughtcrime.securesms.sms;
|
||||
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context;
|
||||
import org.thoughtcrime.securesms.mms.MessageGroupContext;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public final class IncomingGroupUpdateMessage extends IncomingTextMessage {
|
||||
|
||||
private final MessageGroupContext groupContext;
|
||||
|
||||
public IncomingGroupUpdateMessage(IncomingTextMessage base, DecryptedGroupV2Context groupV2Context) {
|
||||
this(base, new MessageGroupContext(groupV2Context));
|
||||
}
|
||||
|
||||
public IncomingGroupUpdateMessage(IncomingTextMessage base, MessageGroupContext groupContext) {
|
||||
super(base, groupContext.getEncodedGroupContext());
|
||||
this.groupContext = groupContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGroup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isUpdate() {
|
||||
return GroupV2UpdateMessageUtil.isUpdate(groupContext) || groupContext.requireGroupV1Properties().isUpdate();
|
||||
}
|
||||
|
||||
public boolean isGroupV2() {
|
||||
return GroupV2UpdateMessageUtil.isGroupV2(groupContext);
|
||||
}
|
||||
|
||||
public boolean isQuit() {
|
||||
return !isGroupV2() && groupContext.requireGroupV1Properties().isQuit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJustAGroupLeave() {
|
||||
return GroupV2UpdateMessageUtil.isJustAGroupLeave(groupContext);
|
||||
}
|
||||
|
||||
public boolean isCancelJoinRequest() {
|
||||
return GroupV2UpdateMessageUtil.isJoinRequestCancel(groupContext);
|
||||
}
|
||||
|
||||
public int getChangeRevision() {
|
||||
return GroupV2UpdateMessageUtil.getChangeRevision(groupContext);
|
||||
}
|
||||
|
||||
public Optional<ServiceId> getChangeEditor() {
|
||||
return GroupV2UpdateMessageUtil.getChangeEditor(groupContext);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.thoughtcrime.securesms.sms;
|
||||
|
||||
|
||||
public class IncomingIdentityDefaultMessage extends IncomingTextMessage {
|
||||
|
||||
public IncomingIdentityDefaultMessage(IncomingTextMessage base) {
|
||||
super(base, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIdentityDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package org.thoughtcrime.securesms.sms;
|
||||
|
||||
public class IncomingIdentityUpdateMessage extends IncomingTextMessage {
|
||||
|
||||
public IncomingIdentityUpdateMessage(IncomingTextMessage base) {
|
||||
super(base, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIdentityUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.thoughtcrime.securesms.sms;
|
||||
|
||||
|
||||
public class IncomingIdentityVerifiedMessage extends IncomingTextMessage {
|
||||
|
||||
public IncomingIdentityVerifiedMessage(IncomingTextMessage base) {
|
||||
super(base, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIdentityVerified() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.thoughtcrime.securesms.sms;
|
||||
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class IncomingJoinedMessage extends IncomingTextMessage {
|
||||
|
||||
public IncomingJoinedMessage(RecipientId sender) {
|
||||
super(sender, 1, System.currentTimeMillis(), -1, System.currentTimeMillis(), null, Optional.empty(), 0, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJoined() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecureMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,294 +0,0 @@
|
||||
package org.thoughtcrime.securesms.sms;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.telephony.SmsMessage;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class IncomingTextMessage implements Parcelable {
|
||||
|
||||
public static final Parcelable.Creator<IncomingTextMessage> CREATOR = new Parcelable.Creator<IncomingTextMessage>() {
|
||||
@Override
|
||||
public IncomingTextMessage createFromParcel(Parcel in) {
|
||||
return new IncomingTextMessage(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IncomingTextMessage[] newArray(int size) {
|
||||
return new IncomingTextMessage[size];
|
||||
}
|
||||
};
|
||||
private static final String TAG = Log.tag(IncomingTextMessage.class);
|
||||
|
||||
private final String message;
|
||||
private final RecipientId authorId;
|
||||
private final int senderDeviceId;
|
||||
private final int protocol;
|
||||
private final String serviceCenterAddress;
|
||||
private final boolean replyPathPresent;
|
||||
private final String pseudoSubject;
|
||||
private final long sentTimestampMillis;
|
||||
private final long serverTimestampMillis;
|
||||
private final long receivedTimestampMillis;
|
||||
@Nullable private final GroupId groupId;
|
||||
private final boolean push;
|
||||
private final int subscriptionId;
|
||||
private final long expiresInMillis;
|
||||
private final boolean unidentified;
|
||||
@Nullable private final String serverGuid;
|
||||
|
||||
public IncomingTextMessage(@NonNull RecipientId authorId, @NonNull SmsMessage message, int subscriptionId) {
|
||||
this.message = message.getDisplayMessageBody();
|
||||
this.authorId = authorId;
|
||||
this.senderDeviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
|
||||
this.protocol = message.getProtocolIdentifier();
|
||||
this.serviceCenterAddress = message.getServiceCenterAddress();
|
||||
this.replyPathPresent = message.isReplyPathPresent();
|
||||
this.pseudoSubject = message.getPseudoSubject();
|
||||
this.sentTimestampMillis = message.getTimestampMillis();
|
||||
this.serverTimestampMillis = -1;
|
||||
this.receivedTimestampMillis = System.currentTimeMillis();
|
||||
this.subscriptionId = subscriptionId;
|
||||
this.expiresInMillis = 0;
|
||||
this.groupId = null;
|
||||
this.push = false;
|
||||
this.unidentified = false;
|
||||
this.serverGuid = null;
|
||||
}
|
||||
|
||||
public IncomingTextMessage(@NonNull RecipientId authorId,
|
||||
int senderDeviceId,
|
||||
long sentTimestampMillis,
|
||||
long serverTimestampMillis,
|
||||
long receivedTimestampMillis,
|
||||
String encodedBody,
|
||||
Optional<GroupId> groupId,
|
||||
long expiresInMillis,
|
||||
boolean unidentified,
|
||||
String serverGuid)
|
||||
{
|
||||
this.message = encodedBody;
|
||||
this.authorId = authorId;
|
||||
this.senderDeviceId = senderDeviceId;
|
||||
this.protocol = 31337;
|
||||
this.serviceCenterAddress = "GCM";
|
||||
this.replyPathPresent = true;
|
||||
this.pseudoSubject = "";
|
||||
this.sentTimestampMillis = sentTimestampMillis;
|
||||
this.serverTimestampMillis = serverTimestampMillis;
|
||||
this.receivedTimestampMillis = receivedTimestampMillis;
|
||||
this.push = true;
|
||||
this.subscriptionId = -1;
|
||||
this.expiresInMillis = expiresInMillis;
|
||||
this.unidentified = unidentified;
|
||||
this.groupId = groupId.orElse(null);
|
||||
this.serverGuid = serverGuid;
|
||||
}
|
||||
|
||||
public IncomingTextMessage(Parcel in) {
|
||||
this.message = in.readString();
|
||||
this.authorId = in.readParcelable(IncomingTextMessage.class.getClassLoader());
|
||||
this.senderDeviceId = in.readInt();
|
||||
this.protocol = in.readInt();
|
||||
this.serviceCenterAddress = in.readString();
|
||||
this.replyPathPresent = (in.readInt() == 1);
|
||||
this.pseudoSubject = in.readString();
|
||||
this.sentTimestampMillis = in.readLong();
|
||||
this.serverTimestampMillis = in.readLong();
|
||||
this.receivedTimestampMillis = in.readLong();
|
||||
this.groupId = GroupId.parseNullableOrThrow(in.readString());
|
||||
this.push = (in.readInt() == 1);
|
||||
this.subscriptionId = in.readInt();
|
||||
this.expiresInMillis = in.readLong();
|
||||
this.unidentified = in.readInt() == 1;
|
||||
this.serverGuid = in.readString();
|
||||
}
|
||||
|
||||
public IncomingTextMessage(IncomingTextMessage base, String newBody) {
|
||||
this.message = newBody;
|
||||
this.authorId = base.getAuthorId();
|
||||
this.senderDeviceId = base.getAuthorDeviceId();
|
||||
this.protocol = base.getProtocol();
|
||||
this.serviceCenterAddress = base.getServiceCenterAddress();
|
||||
this.replyPathPresent = base.isReplyPathPresent();
|
||||
this.pseudoSubject = base.getPseudoSubject();
|
||||
this.sentTimestampMillis = base.getSentTimestampMillis();
|
||||
this.serverTimestampMillis = base.getServerTimestampMillis();
|
||||
this.receivedTimestampMillis = base.getReceivedTimestampMillis();
|
||||
this.groupId = base.getGroupId();
|
||||
this.push = base.isPush();
|
||||
this.subscriptionId = base.getSubscriptionId();
|
||||
this.expiresInMillis = base.getExpiresIn();
|
||||
this.unidentified = base.isUnidentified();
|
||||
this.serverGuid = base.getServerGuid();
|
||||
}
|
||||
|
||||
public IncomingTextMessage(List<IncomingTextMessage> fragments) {
|
||||
StringBuilder body = new StringBuilder();
|
||||
|
||||
for (IncomingTextMessage message : fragments) {
|
||||
body.append(message.getMessageBody());
|
||||
}
|
||||
|
||||
this.message = body.toString();
|
||||
this.authorId = fragments.get(0).getAuthorId();
|
||||
this.senderDeviceId = fragments.get(0).getAuthorDeviceId();
|
||||
this.protocol = fragments.get(0).getProtocol();
|
||||
this.serviceCenterAddress = fragments.get(0).getServiceCenterAddress();
|
||||
this.replyPathPresent = fragments.get(0).isReplyPathPresent();
|
||||
this.pseudoSubject = fragments.get(0).getPseudoSubject();
|
||||
this.sentTimestampMillis = fragments.get(0).getSentTimestampMillis();
|
||||
this.serverTimestampMillis = fragments.get(0).getServerTimestampMillis();
|
||||
this.receivedTimestampMillis = fragments.get(0).getReceivedTimestampMillis();
|
||||
this.groupId = fragments.get(0).getGroupId();
|
||||
this.push = fragments.get(0).isPush();
|
||||
this.subscriptionId = fragments.get(0).getSubscriptionId();
|
||||
this.expiresInMillis = fragments.get(0).getExpiresIn();
|
||||
this.unidentified = fragments.get(0).isUnidentified();
|
||||
this.serverGuid = fragments.get(0).getServerGuid();
|
||||
}
|
||||
|
||||
public int getSubscriptionId() {
|
||||
return subscriptionId;
|
||||
}
|
||||
|
||||
public long getExpiresIn() {
|
||||
return expiresInMillis;
|
||||
}
|
||||
|
||||
public long getSentTimestampMillis() {
|
||||
return sentTimestampMillis;
|
||||
}
|
||||
|
||||
public long getServerTimestampMillis() {
|
||||
return serverTimestampMillis;
|
||||
}
|
||||
|
||||
public long getReceivedTimestampMillis() {
|
||||
return receivedTimestampMillis;
|
||||
}
|
||||
|
||||
public String getPseudoSubject() {
|
||||
return pseudoSubject;
|
||||
}
|
||||
|
||||
public String getMessageBody() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public RecipientId getAuthorId() {
|
||||
return authorId;
|
||||
}
|
||||
|
||||
public int getAuthorDeviceId() {
|
||||
return senderDeviceId;
|
||||
}
|
||||
|
||||
public int getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public String getServiceCenterAddress() {
|
||||
return serviceCenterAddress;
|
||||
}
|
||||
|
||||
public boolean isReplyPathPresent() {
|
||||
return replyPathPresent;
|
||||
}
|
||||
|
||||
public boolean isSecureMessage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPreKeyBundle() {
|
||||
return isLegacyPreKeyBundle() || isContentPreKeyBundle();
|
||||
}
|
||||
|
||||
public boolean isLegacyPreKeyBundle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isContentPreKeyBundle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isEndSession() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPush() {
|
||||
return push;
|
||||
}
|
||||
|
||||
public @Nullable GroupId getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public boolean isGroup() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isJoined() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isIdentityUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isIdentityVerified() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isIdentityDefault() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True iff the message is only a group leave of a single member.
|
||||
*/
|
||||
public boolean isJustAGroupLeave() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isUnidentified() {
|
||||
return unidentified;
|
||||
}
|
||||
|
||||
public @Nullable String getServerGuid() {
|
||||
return serverGuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeString(message);
|
||||
out.writeParcelable(authorId, flags);
|
||||
out.writeInt(senderDeviceId);
|
||||
out.writeInt(protocol);
|
||||
out.writeString(serviceCenterAddress);
|
||||
out.writeInt(replyPathPresent ? 1 : 0);
|
||||
out.writeString(pseudoSubject);
|
||||
out.writeLong(sentTimestampMillis);
|
||||
out.writeString(groupId == null ? null : groupId.toString());
|
||||
out.writeInt(push ? 1 : 0);
|
||||
out.writeInt(subscriptionId);
|
||||
out.writeLong(expiresInMillis);
|
||||
out.writeInt(unidentified ? 1 : 0);
|
||||
out.writeString(serverGuid);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user