|
|
|
@ -5,6 +5,7 @@ import android.os.Parcelable;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
|
|
|
|
import org.session.libsession.messaging.calls.CallMessageType;
|
|
|
|
|
import org.session.libsession.messaging.messages.visible.OpenGroupInvitation;
|
|
|
|
|
import org.session.libsession.messaging.messages.visible.VisibleMessage;
|
|
|
|
|
import org.session.libsession.utilities.Address;
|
|
|
|
@ -41,12 +42,19 @@ public class IncomingTextMessage implements Parcelable {
|
|
|
|
|
private final int subscriptionId;
|
|
|
|
|
private final long expiresInMillis;
|
|
|
|
|
private final boolean unidentified;
|
|
|
|
|
private final int callType;
|
|
|
|
|
|
|
|
|
|
private boolean isOpenGroupInvitation = false;
|
|
|
|
|
|
|
|
|
|
public IncomingTextMessage(Address sender, int senderDeviceId, long sentTimestampMillis,
|
|
|
|
|
String encodedBody, Optional<SignalServiceGroup> group,
|
|
|
|
|
long expiresInMillis, boolean unidentified) {
|
|
|
|
|
this(sender, senderDeviceId, sentTimestampMillis, encodedBody, group, expiresInMillis, unidentified, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IncomingTextMessage(Address sender, int senderDeviceId, long sentTimestampMillis,
|
|
|
|
|
String encodedBody, Optional<SignalServiceGroup> group,
|
|
|
|
|
long expiresInMillis, boolean unidentified)
|
|
|
|
|
long expiresInMillis, boolean unidentified, int callType)
|
|
|
|
|
{
|
|
|
|
|
this.message = encodedBody;
|
|
|
|
|
this.sender = sender;
|
|
|
|
@ -60,6 +68,7 @@ public class IncomingTextMessage implements Parcelable {
|
|
|
|
|
this.subscriptionId = -1;
|
|
|
|
|
this.expiresInMillis = expiresInMillis;
|
|
|
|
|
this.unidentified = unidentified;
|
|
|
|
|
this.callType = callType;
|
|
|
|
|
|
|
|
|
|
if (group.isPresent()) {
|
|
|
|
|
this.groupId = Address.fromSerialized(GroupUtil.getEncodedId(group.get()));
|
|
|
|
@ -69,36 +78,39 @@ public class IncomingTextMessage implements Parcelable {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IncomingTextMessage(Parcel in) {
|
|
|
|
|
this.message = in.readString();
|
|
|
|
|
this.sender = 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.groupId = in.readParcelable(IncomingTextMessage.class.getClassLoader());
|
|
|
|
|
this.push = (in.readInt() == 1);
|
|
|
|
|
this.subscriptionId = in.readInt();
|
|
|
|
|
this.expiresInMillis = in.readLong();
|
|
|
|
|
this.unidentified = in.readInt() == 1;
|
|
|
|
|
this.message = in.readString();
|
|
|
|
|
this.sender = 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.groupId = in.readParcelable(IncomingTextMessage.class.getClassLoader());
|
|
|
|
|
this.push = (in.readInt() == 1);
|
|
|
|
|
this.subscriptionId = in.readInt();
|
|
|
|
|
this.expiresInMillis = in.readLong();
|
|
|
|
|
this.unidentified = in.readInt() == 1;
|
|
|
|
|
this.isOpenGroupInvitation = in.readInt() == 1;
|
|
|
|
|
this.callType = in.readInt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IncomingTextMessage(IncomingTextMessage base, String newBody) {
|
|
|
|
|
this.message = newBody;
|
|
|
|
|
this.sender = base.getSender();
|
|
|
|
|
this.senderDeviceId = base.getSenderDeviceId();
|
|
|
|
|
this.protocol = base.getProtocol();
|
|
|
|
|
this.serviceCenterAddress = base.getServiceCenterAddress();
|
|
|
|
|
this.replyPathPresent = base.isReplyPathPresent();
|
|
|
|
|
this.pseudoSubject = base.getPseudoSubject();
|
|
|
|
|
this.sentTimestampMillis = base.getSentTimestampMillis();
|
|
|
|
|
this.groupId = base.getGroupId();
|
|
|
|
|
this.push = base.isPush();
|
|
|
|
|
this.subscriptionId = base.getSubscriptionId();
|
|
|
|
|
this.expiresInMillis = base.getExpiresIn();
|
|
|
|
|
this.unidentified = base.isUnidentified();
|
|
|
|
|
this.isOpenGroupInvitation= base.isOpenGroupInvitation();
|
|
|
|
|
this.message = newBody;
|
|
|
|
|
this.sender = base.getSender();
|
|
|
|
|
this.senderDeviceId = base.getSenderDeviceId();
|
|
|
|
|
this.protocol = base.getProtocol();
|
|
|
|
|
this.serviceCenterAddress = base.getServiceCenterAddress();
|
|
|
|
|
this.replyPathPresent = base.isReplyPathPresent();
|
|
|
|
|
this.pseudoSubject = base.getPseudoSubject();
|
|
|
|
|
this.sentTimestampMillis = base.getSentTimestampMillis();
|
|
|
|
|
this.groupId = base.getGroupId();
|
|
|
|
|
this.push = base.isPush();
|
|
|
|
|
this.subscriptionId = base.getSubscriptionId();
|
|
|
|
|
this.expiresInMillis = base.getExpiresIn();
|
|
|
|
|
this.unidentified = base.isUnidentified();
|
|
|
|
|
this.isOpenGroupInvitation = base.isOpenGroupInvitation();
|
|
|
|
|
this.callType = base.callType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IncomingTextMessage from(VisibleMessage message,
|
|
|
|
@ -121,6 +133,13 @@ public class IncomingTextMessage implements Parcelable {
|
|
|
|
|
return incomingTextMessage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IncomingTextMessage fromCallInfo(CallMessageType callMessageType,
|
|
|
|
|
Address sender,
|
|
|
|
|
Optional<SignalServiceGroup> group,
|
|
|
|
|
long sentTimestamp) {
|
|
|
|
|
return new IncomingTextMessage(sender, 1, sentTimestamp, null, group, 0, false, callMessageType.ordinal());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getSubscriptionId() {
|
|
|
|
|
return subscriptionId;
|
|
|
|
|
}
|
|
|
|
@ -183,6 +202,18 @@ public class IncomingTextMessage implements Parcelable {
|
|
|
|
|
|
|
|
|
|
public boolean isOpenGroupInvitation() { return isOpenGroupInvitation; }
|
|
|
|
|
|
|
|
|
|
public boolean isCallInfo() {
|
|
|
|
|
int callMessageTypeLength = CallMessageType.values().length;
|
|
|
|
|
return callType >= 0 && callType < callMessageTypeLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
|
public CallMessageType getCallType() {
|
|
|
|
|
int callTypeLength = CallMessageType.values().length;
|
|
|
|
|
if (callType < 0 || callType >= callTypeLength) return null;
|
|
|
|
|
return CallMessageType.values()[callType];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int describeContents() {
|
|
|
|
|
return 0;
|
|
|
|
@ -202,5 +233,7 @@ public class IncomingTextMessage implements Parcelable {
|
|
|
|
|
out.writeInt(push ? 1 : 0);
|
|
|
|
|
out.writeInt(subscriptionId);
|
|
|
|
|
out.writeInt(unidentified ? 1 : 0);
|
|
|
|
|
out.writeInt(isOpenGroupInvitation ? 1 : 0);
|
|
|
|
|
out.writeInt(callType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|