mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
Make 'push' status a type bit on both incoming and outgoing msgs.
This commit is contained in:
parent
2026330f8a
commit
ccd1691b22
@ -136,10 +136,15 @@ public class ConversationFragment extends SherlockListFragment
|
||||
|
||||
private void handleDisplayDetails(MessageRecord message) {
|
||||
String sender = message.getIndividualRecipient().getNumber();
|
||||
String transport = message.isMms() ? "mms" : "sms";
|
||||
long dateReceived = message.getDateReceived();
|
||||
long dateSent = message.getDateSent();
|
||||
|
||||
String transport;
|
||||
|
||||
if (message.isPush()) transport = "push";
|
||||
else if (message.isMms()) transport = "mms";
|
||||
else transport = "sms";
|
||||
|
||||
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("EEE MMM d, yyyy 'at' hh:mm:ss a zzz");
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
@ -175,7 +175,7 @@ public class ConversationItem extends LinearLayout {
|
||||
|
||||
private void setBodyText(MessageRecord messageRecord) {
|
||||
// TODO jake is going to fix this up
|
||||
if (messageRecord.isPushSent()) {
|
||||
if (messageRecord.isPush() && messageRecord.isOutgoing()) {
|
||||
bodyText.setText("PUSH " + messageRecord.getDisplayBody());
|
||||
return;
|
||||
}
|
||||
|
@ -308,6 +308,10 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
updateMailboxBitmask(messageId, 0, Types.SECURE_MESSAGE_BIT);
|
||||
}
|
||||
|
||||
public void markAsPush(long messageId) {
|
||||
updateMailboxBitmask(messageId, 0, Types.PUSH_MESSAGE_BIT);
|
||||
}
|
||||
|
||||
public void markAsDecryptFailed(long messageId, long threadId) {
|
||||
updateMailboxBitmask(messageId, Types.ENCRYPTION_MASK, Types.ENCRYPTION_REMOTE_FAILED_BIT);
|
||||
notifyConversationListeners(threadId);
|
||||
@ -448,7 +452,8 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
throws MmsException
|
||||
{
|
||||
return insertMessageInbox(masterSecret, retrieved, contentLocation, threadId,
|
||||
Types.BASE_INBOX_TYPE | Types.ENCRYPTION_SYMMETRIC_BIT);
|
||||
Types.BASE_INBOX_TYPE | Types.ENCRYPTION_SYMMETRIC_BIT |
|
||||
(retrieved.isPushMessage() ? Types.PUSH_MESSAGE_BIT : 0));
|
||||
}
|
||||
|
||||
public Pair<Long, Long> insertSecureMessageInbox(MasterSecret masterSecret,
|
||||
@ -457,7 +462,8 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
throws MmsException
|
||||
{
|
||||
return insertMessageInbox(masterSecret, retrieved, contentLocation, threadId,
|
||||
Types.BASE_INBOX_TYPE | Types.SECURE_MESSAGE_BIT | Types.ENCRYPTION_REMOTE_BIT);
|
||||
Types.BASE_INBOX_TYPE | Types.SECURE_MESSAGE_BIT |
|
||||
Types.ENCRYPTION_REMOTE_BIT);
|
||||
}
|
||||
|
||||
public Pair<Long, Long> insertSecureDecryptedMessageInbox(MasterSecret masterSecret,
|
||||
@ -466,7 +472,9 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
throws MmsException
|
||||
{
|
||||
return insertMessageInbox(masterSecret, retrieved, "", threadId,
|
||||
Types.BASE_INBOX_TYPE | Types.SECURE_MESSAGE_BIT | Types.ENCRYPTION_SYMMETRIC_BIT);
|
||||
Types.BASE_INBOX_TYPE | Types.SECURE_MESSAGE_BIT |
|
||||
Types.ENCRYPTION_SYMMETRIC_BIT |
|
||||
(retrieved.isPushMessage() ? Types.PUSH_MESSAGE_BIT : 0));
|
||||
}
|
||||
|
||||
public Pair<Long, Long> insertMessageInbox(NotificationInd notification) {
|
||||
@ -870,7 +878,6 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
long threadId = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.THREAD_ID));
|
||||
String address = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS));
|
||||
int addressDeviceId = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS_DEVICE_ID));
|
||||
int status = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.STATUS));
|
||||
DisplayRecord.Body body = getBody(cursor);
|
||||
int partCount = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.PART_COUNT));
|
||||
Recipients recipients = getRecipientsFor(address);
|
||||
@ -879,7 +886,7 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
|
||||
return new MediaMmsMessageRecord(context, id, recipients, recipients.getPrimaryRecipient(),
|
||||
addressDeviceId, dateSent, dateReceived, threadId, body,
|
||||
slideDeck, partCount, status, box);
|
||||
slideDeck, partCount, box);
|
||||
}
|
||||
|
||||
private Recipients getRecipientsFor(String address) {
|
||||
|
@ -38,6 +38,7 @@ public interface MmsSmsColumns {
|
||||
// Secure Message Information
|
||||
protected static final long SECURE_MESSAGE_BIT = 0x800000;
|
||||
protected static final long END_SESSION_BIT = 0x400000;
|
||||
protected static final long PUSH_MESSAGE_BIT = 0x200000;
|
||||
|
||||
// Group Message Information
|
||||
protected static final long GROUP_ADD_MEMBERS_BIT = 0x10000;
|
||||
@ -79,6 +80,10 @@ public interface MmsSmsColumns {
|
||||
return (type & SECURE_MESSAGE_BIT) != 0;
|
||||
}
|
||||
|
||||
public static boolean isPushType(long type) {
|
||||
return (type & PUSH_MESSAGE_BIT) != 0;
|
||||
}
|
||||
|
||||
public static boolean isEndSessionType(long type) {
|
||||
return (type & END_SESSION_BIT) != 0;
|
||||
}
|
||||
|
@ -174,6 +174,10 @@ public class SmsDatabase extends Database implements MmsSmsColumns {
|
||||
updateTypeBitmask(id, 0, Types.SECURE_MESSAGE_BIT);
|
||||
}
|
||||
|
||||
public void markAsPush(long id) {
|
||||
updateTypeBitmask(id, 0, Types.PUSH_MESSAGE_BIT);
|
||||
}
|
||||
|
||||
public void markAsDecryptFailed(long id) {
|
||||
updateTypeBitmask(id, Types.ENCRYPTION_MASK, Types.ENCRYPTION_REMOTE_FAILED_BIT);
|
||||
}
|
||||
@ -267,6 +271,8 @@ public class SmsDatabase extends Database implements MmsSmsColumns {
|
||||
type |= Types.ENCRYPTION_REMOTE_BIT;
|
||||
}
|
||||
|
||||
if (message.isPush()) type |= Types.PUSH_MESSAGE_BIT;
|
||||
|
||||
Recipients recipients;
|
||||
|
||||
try {
|
||||
@ -470,7 +476,6 @@ public class SmsDatabase extends Database implements MmsSmsColumns {
|
||||
public static final int STATUS_COMPLETE = 0;
|
||||
public static final int STATUS_PENDING = 0x20;
|
||||
public static final int STATUS_FAILED = 0x40;
|
||||
public static final int STATUS_SENT_PUSH = 0x8000;
|
||||
}
|
||||
|
||||
public Reader readerFor(Cursor cursor) {
|
||||
|
@ -45,10 +45,10 @@ public class MediaMmsMessageRecord extends MessageRecord {
|
||||
Recipient individualRecipient, int recipientDeviceId,
|
||||
long dateSent, long dateReceived, long threadId, Body body,
|
||||
ListenableFutureTask<SlideDeck> slideDeck,
|
||||
int partCount, int deliveryStatus, long mailbox)
|
||||
int partCount, long mailbox)
|
||||
{
|
||||
super(context, id, body, recipients, individualRecipient, recipientDeviceId,
|
||||
dateSent, dateReceived, threadId, getGenericDeliveryStatus(deliveryStatus), mailbox);
|
||||
dateSent, dateReceived, threadId, DELIVERY_STATUS_NONE, mailbox);
|
||||
|
||||
this.context = context.getApplicationContext();
|
||||
this.partCount = partCount;
|
||||
@ -82,8 +82,4 @@ public class MediaMmsMessageRecord extends MessageRecord {
|
||||
|
||||
return super.getDisplayBody();
|
||||
}
|
||||
|
||||
private static int getGenericDeliveryStatus(int status) {
|
||||
return status == SmsDatabase.Status.STATUS_SENT_PUSH ? DELVIERY_STATUS_PUSH : DELIVERY_STATUS_NONE;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
public static final int DELIVERY_STATUS_RECEIVED = 1;
|
||||
public static final int DELIVERY_STATUS_PENDING = 2;
|
||||
public static final int DELIVERY_STATUS_FAILED = 3;
|
||||
public static final int DELVIERY_STATUS_PUSH = 4;
|
||||
|
||||
private final Recipient individualRecipient;
|
||||
private final int recipientDeviceId;
|
||||
@ -108,8 +107,8 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
return getDeliveryStatus() == DELIVERY_STATUS_RECEIVED;
|
||||
}
|
||||
|
||||
public boolean isPushSent() {
|
||||
return getDeliveryStatus() == DELVIERY_STATUS_PUSH;
|
||||
public boolean isPush() {
|
||||
return SmsDatabase.Types.isPushType(type);
|
||||
}
|
||||
|
||||
public boolean isStaleKeyExchange() {
|
||||
|
@ -97,8 +97,6 @@ public class SmsMessageRecord extends MessageRecord {
|
||||
private static int getGenericDeliveryStatus(int status) {
|
||||
if (status == SmsDatabase.Status.STATUS_NONE) {
|
||||
return MessageRecord.DELIVERY_STATUS_NONE;
|
||||
} else if (status >= SmsDatabase.Status.STATUS_SENT_PUSH) {
|
||||
return MessageRecord.DELVIERY_STATUS_PUSH;
|
||||
} else if (status >= SmsDatabase.Status.STATUS_FAILED) {
|
||||
return MessageRecord.DELIVERY_STATUS_FAILED;
|
||||
} else if (status >= SmsDatabase.Status.STATUS_PENDING) {
|
||||
|
@ -20,11 +20,13 @@ public class IncomingMediaMessage {
|
||||
private final PduHeaders headers;
|
||||
private final PduBody body;
|
||||
private final String groupId;
|
||||
private final boolean push;
|
||||
|
||||
public IncomingMediaMessage(RetrieveConf retreived) {
|
||||
this.headers = retreived.getPduHeaders();
|
||||
this.body = retreived.getBody();
|
||||
this.groupId = null;
|
||||
this.push = false;
|
||||
}
|
||||
|
||||
public IncomingMediaMessage(MasterSecret masterSecret, String localNumber,
|
||||
@ -33,6 +35,7 @@ public class IncomingMediaMessage {
|
||||
{
|
||||
this.headers = new PduHeaders();
|
||||
this.body = new PduBody();
|
||||
this.push = true;
|
||||
|
||||
if (messageContent.hasGroup()) {
|
||||
this.groupId = GroupUtil.getEncodedId(messageContent.getGroup().getId().toByteArray());
|
||||
@ -84,6 +87,10 @@ public class IncomingMediaMessage {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public boolean isPushMessage() {
|
||||
return push;
|
||||
}
|
||||
|
||||
public boolean isGroupMessage() {
|
||||
return groupId != null ||
|
||||
!Util.isEmpty(headers.getEncodedStringValues(PduHeaders.CC)) ||
|
||||
|
@ -79,8 +79,7 @@ public class MmsSender {
|
||||
MmsSendResult result = transport.deliver(message, threadId);
|
||||
|
||||
if (result.isUpgradedSecure()) database.markAsSecure(message.getDatabaseMessageId());
|
||||
if (result.isPush()) database.markDeliveryStatus(message.getDatabaseMessageId(),
|
||||
Status.STATUS_SENT_PUSH);
|
||||
if (result.isPush()) database.markAsPush(message.getDatabaseMessageId());
|
||||
|
||||
database.markAsSent(message.getDatabaseMessageId(), result.getMessageId(),
|
||||
result.getResponseStatus());
|
||||
|
@ -121,7 +121,7 @@ public class SmsSender {
|
||||
database.markAsSent(messageId);
|
||||
|
||||
if (upgraded) database.markAsSecure(messageId);
|
||||
if (push) database.markStatus(messageId, SmsDatabase.Status.STATUS_SENT_PUSH);
|
||||
if (push) database.markAsPush(messageId);
|
||||
|
||||
SmsMessageRecord record = reader.getNext();
|
||||
|
||||
|
@ -4,15 +4,12 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.telephony.SmsMessage;
|
||||
|
||||
import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.whispersystems.textsecure.push.IncomingPushMessage;
|
||||
import org.whispersystems.textsecure.storage.RecipientDevice;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ws.com.google.android.mms.pdu.SendReq;
|
||||
|
||||
import static org.whispersystems.textsecure.push.PushMessageProtos.PushMessageContent.GroupContext;
|
||||
|
||||
public class IncomingTextMessage implements Parcelable {
|
||||
@ -38,6 +35,7 @@ public class IncomingTextMessage implements Parcelable {
|
||||
private final String pseudoSubject;
|
||||
private final long sentTimestampMillis;
|
||||
private final String groupId;
|
||||
private final boolean push;
|
||||
|
||||
public IncomingTextMessage(SmsMessage message) {
|
||||
this.message = message.getDisplayMessageBody();
|
||||
@ -49,6 +47,7 @@ public class IncomingTextMessage implements Parcelable {
|
||||
this.pseudoSubject = message.getPseudoSubject();
|
||||
this.sentTimestampMillis = message.getTimestampMillis();
|
||||
this.groupId = null;
|
||||
this.push = false;
|
||||
}
|
||||
|
||||
public IncomingTextMessage(IncomingPushMessage message, String encodedBody, GroupContext group) {
|
||||
@ -60,6 +59,7 @@ public class IncomingTextMessage implements Parcelable {
|
||||
this.replyPathPresent = true;
|
||||
this.pseudoSubject = "";
|
||||
this.sentTimestampMillis = message.getTimestampMillis();
|
||||
this.push = true;
|
||||
|
||||
if (group != null && group.hasId()) {
|
||||
this.groupId = GroupUtil.getEncodedId(group.getId().toByteArray());
|
||||
@ -78,6 +78,7 @@ public class IncomingTextMessage implements Parcelable {
|
||||
this.pseudoSubject = in.readString();
|
||||
this.sentTimestampMillis = in.readLong();
|
||||
this.groupId = in.readString();
|
||||
this.push = (in.readInt() == 1);
|
||||
}
|
||||
|
||||
public IncomingTextMessage(IncomingTextMessage base, String newBody) {
|
||||
@ -90,6 +91,7 @@ public class IncomingTextMessage implements Parcelable {
|
||||
this.pseudoSubject = base.getPseudoSubject();
|
||||
this.sentTimestampMillis = base.getSentTimestampMillis();
|
||||
this.groupId = base.getGroupId();
|
||||
this.push = base.isPush();
|
||||
}
|
||||
|
||||
public IncomingTextMessage(List<IncomingTextMessage> fragments) {
|
||||
@ -108,30 +110,7 @@ public class IncomingTextMessage implements Parcelable {
|
||||
this.pseudoSubject = fragments.get(0).getPseudoSubject();
|
||||
this.sentTimestampMillis = fragments.get(0).getSentTimestampMillis();
|
||||
this.groupId = fragments.get(0).getGroupId();
|
||||
}
|
||||
|
||||
public IncomingTextMessage(SendReq record) {
|
||||
this.message = "";
|
||||
this.sender = record.getTo()[0].getString();
|
||||
this.senderDeviceId = RecipientDevice.DEFAULT_DEVICE_ID;
|
||||
this.protocol = 31338;
|
||||
this.serviceCenterAddress = "Outgoing";
|
||||
this.replyPathPresent = true;
|
||||
this.pseudoSubject = "";
|
||||
this.sentTimestampMillis = System.currentTimeMillis();
|
||||
this.groupId = null;
|
||||
}
|
||||
|
||||
public IncomingTextMessage(SmsMessageRecord record) {
|
||||
this.message = record.getBody().getBody();
|
||||
this.sender = record.getIndividualRecipient().getNumber();
|
||||
this.senderDeviceId = RecipientDevice.DEFAULT_DEVICE_ID;
|
||||
this.protocol = 31338;
|
||||
this.serviceCenterAddress = "Outgoing";
|
||||
this.replyPathPresent = true;
|
||||
this.pseudoSubject = "";
|
||||
this.sentTimestampMillis = System.currentTimeMillis();
|
||||
this.groupId = null;
|
||||
this.push = fragments.get(0).isPush();
|
||||
}
|
||||
|
||||
protected IncomingTextMessage(String sender, String groupId)
|
||||
@ -145,6 +124,7 @@ public class IncomingTextMessage implements Parcelable {
|
||||
this.pseudoSubject = "";
|
||||
this.sentTimestampMillis = System.currentTimeMillis();
|
||||
this.groupId = groupId;
|
||||
this.push = true;
|
||||
}
|
||||
|
||||
public long getSentTimestampMillis() {
|
||||
@ -203,6 +183,10 @@ public class IncomingTextMessage implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPush() {
|
||||
return push;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
@ -227,5 +211,6 @@ public class IncomingTextMessage implements Parcelable {
|
||||
out.writeString(pseudoSubject);
|
||||
out.writeLong(sentTimestampMillis);
|
||||
out.writeString(groupId);
|
||||
out.writeInt(push ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user