2013-04-01 02:16:06 +00:00
|
|
|
package org.thoughtcrime.securesms.sms;
|
|
|
|
|
|
|
|
import android.os.Parcel;
|
|
|
|
import android.os.Parcelable;
|
|
|
|
import android.telephony.SmsMessage;
|
|
|
|
|
2014-02-16 23:23:49 +00:00
|
|
|
import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
2014-02-14 23:59:57 +00:00
|
|
|
import org.thoughtcrime.securesms.util.GroupUtil;
|
2013-07-19 00:42:45 +00:00
|
|
|
import org.whispersystems.textsecure.push.IncomingPushMessage;
|
2014-02-03 03:38:06 +00:00
|
|
|
import org.whispersystems.textsecure.storage.RecipientDevice;
|
2013-04-01 02:16:06 +00:00
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
import java.util.List;
|
2013-04-01 02:16:06 +00:00
|
|
|
|
2014-02-16 23:23:49 +00:00
|
|
|
import ws.com.google.android.mms.pdu.SendReq;
|
|
|
|
|
2014-02-14 23:59:57 +00:00
|
|
|
import static org.whispersystems.textsecure.push.PushMessageProtos.PushMessageContent.GroupContext;
|
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
public class IncomingTextMessage implements Parcelable {
|
|
|
|
|
|
|
|
public static final Parcelable.Creator<IncomingTextMessage> CREATOR = new Parcelable.Creator<IncomingTextMessage>() {
|
2013-04-01 02:16:06 +00:00
|
|
|
@Override
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
public IncomingTextMessage createFromParcel(Parcel in) {
|
|
|
|
return new IncomingTextMessage(in);
|
2013-04-01 02:16:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
public IncomingTextMessage[] newArray(int size) {
|
|
|
|
return new IncomingTextMessage[size];
|
2013-04-01 02:16:06 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
private final String message;
|
|
|
|
private final String sender;
|
2014-02-03 03:38:06 +00:00
|
|
|
private final int senderDeviceId;
|
2013-04-01 02:16:06 +00:00
|
|
|
private final int protocol;
|
|
|
|
private final String serviceCenterAddress;
|
|
|
|
private final boolean replyPathPresent;
|
|
|
|
private final String pseudoSubject;
|
|
|
|
private final long sentTimestampMillis;
|
2014-01-14 08:26:43 +00:00
|
|
|
private final String groupId;
|
2013-04-01 02:16:06 +00:00
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
public IncomingTextMessage(SmsMessage message) {
|
2013-04-01 02:16:06 +00:00
|
|
|
this.message = message.getDisplayMessageBody();
|
|
|
|
this.sender = message.getDisplayOriginatingAddress();
|
2014-02-03 03:38:06 +00:00
|
|
|
this.senderDeviceId = RecipientDevice.DEFAULT_DEVICE_ID;
|
2013-04-01 02:16:06 +00:00
|
|
|
this.protocol = message.getProtocolIdentifier();
|
|
|
|
this.serviceCenterAddress = message.getServiceCenterAddress();
|
|
|
|
this.replyPathPresent = message.isReplyPathPresent();
|
|
|
|
this.pseudoSubject = message.getPseudoSubject();
|
|
|
|
this.sentTimestampMillis = message.getTimestampMillis();
|
2014-01-14 08:26:43 +00:00
|
|
|
this.groupId = null;
|
2013-04-01 02:16:06 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 23:59:57 +00:00
|
|
|
public IncomingTextMessage(IncomingPushMessage message, String encodedBody, GroupContext group) {
|
2013-08-31 16:28:49 +00:00
|
|
|
this.message = encodedBody;
|
2013-04-01 02:16:06 +00:00
|
|
|
this.sender = message.getSource();
|
2014-02-03 03:38:06 +00:00
|
|
|
this.senderDeviceId = message.getSourceDevice();
|
2013-04-01 02:16:06 +00:00
|
|
|
this.protocol = 31337;
|
|
|
|
this.serviceCenterAddress = "GCM";
|
|
|
|
this.replyPathPresent = true;
|
|
|
|
this.pseudoSubject = "";
|
|
|
|
this.sentTimestampMillis = message.getTimestampMillis();
|
2014-02-14 23:59:57 +00:00
|
|
|
|
2014-02-20 05:06:54 +00:00
|
|
|
if (group.hasId()) {
|
|
|
|
this.groupId = GroupUtil.getEncodedId(group.getId().toByteArray());
|
2014-02-14 23:59:57 +00:00
|
|
|
} else {
|
2014-02-20 05:06:54 +00:00
|
|
|
this.groupId = null;
|
2014-02-14 23:59:57 +00:00
|
|
|
}
|
2013-04-01 02:16:06 +00:00
|
|
|
}
|
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
public IncomingTextMessage(Parcel in) {
|
2013-04-01 02:16:06 +00:00
|
|
|
this.message = in.readString();
|
|
|
|
this.sender = in.readString();
|
2014-02-03 03:38:06 +00:00
|
|
|
this.senderDeviceId = in.readInt();
|
2013-04-01 02:16:06 +00:00
|
|
|
this.protocol = in.readInt();
|
|
|
|
this.serviceCenterAddress = in.readString();
|
|
|
|
this.replyPathPresent = (in.readInt() == 1);
|
|
|
|
this.pseudoSubject = in.readString();
|
|
|
|
this.sentTimestampMillis = in.readLong();
|
2014-01-14 08:26:43 +00:00
|
|
|
this.groupId = in.readString();
|
2013-04-01 02:16:06 +00:00
|
|
|
}
|
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
public IncomingTextMessage(IncomingTextMessage base, String newBody) {
|
|
|
|
this.message = newBody;
|
|
|
|
this.sender = base.getSender();
|
2014-02-03 03:38:06 +00:00
|
|
|
this.senderDeviceId = base.getSenderDeviceId();
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
this.protocol = base.getProtocol();
|
|
|
|
this.serviceCenterAddress = base.getServiceCenterAddress();
|
|
|
|
this.replyPathPresent = base.isReplyPathPresent();
|
|
|
|
this.pseudoSubject = base.getPseudoSubject();
|
|
|
|
this.sentTimestampMillis = base.getSentTimestampMillis();
|
2014-01-14 08:26:43 +00:00
|
|
|
this.groupId = base.getGroupId();
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public IncomingTextMessage(List<IncomingTextMessage> fragments) {
|
|
|
|
StringBuilder body = new StringBuilder();
|
|
|
|
|
|
|
|
for (IncomingTextMessage message : fragments) {
|
|
|
|
body.append(message.getMessageBody());
|
|
|
|
}
|
|
|
|
|
|
|
|
this.message = body.toString();
|
|
|
|
this.sender = fragments.get(0).getSender();
|
2014-02-03 03:38:06 +00:00
|
|
|
this.senderDeviceId = fragments.get(0).getSenderDeviceId();
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
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();
|
2014-01-14 08:26:43 +00:00
|
|
|
this.groupId = fragments.get(0).getGroupId();
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
}
|
|
|
|
|
2014-02-16 23:23:49 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-02-20 05:06:54 +00:00
|
|
|
protected IncomingTextMessage(String sender, String groupId)
|
2014-02-17 19:42:51 +00:00
|
|
|
{
|
|
|
|
this.message = "";
|
|
|
|
this.sender = sender;
|
|
|
|
this.senderDeviceId = RecipientDevice.DEFAULT_DEVICE_ID;
|
|
|
|
this.protocol = 31338;
|
|
|
|
this.serviceCenterAddress = "Outgoing";
|
|
|
|
this.replyPathPresent = true;
|
|
|
|
this.pseudoSubject = "";
|
|
|
|
this.sentTimestampMillis = System.currentTimeMillis();
|
|
|
|
this.groupId = groupId;
|
|
|
|
}
|
|
|
|
|
2013-04-01 02:16:06 +00:00
|
|
|
public long getSentTimestampMillis() {
|
|
|
|
return sentTimestampMillis;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getPseudoSubject() {
|
|
|
|
return pseudoSubject;
|
|
|
|
}
|
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
public String getMessageBody() {
|
2013-04-01 02:16:06 +00:00
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
public IncomingTextMessage withMessageBody(String message) {
|
|
|
|
return new IncomingTextMessage(this, message);
|
|
|
|
}
|
|
|
|
|
2013-04-01 02:16:06 +00:00
|
|
|
public String getSender() {
|
|
|
|
return sender;
|
|
|
|
}
|
|
|
|
|
2014-02-03 03:38:06 +00:00
|
|
|
public int getSenderDeviceId() {
|
|
|
|
return senderDeviceId;
|
|
|
|
}
|
|
|
|
|
2013-04-01 02:16:06 +00:00
|
|
|
public int getProtocol() {
|
|
|
|
return protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getServiceCenterAddress() {
|
|
|
|
return serviceCenterAddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isReplyPathPresent() {
|
|
|
|
return replyPathPresent;
|
|
|
|
}
|
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
public boolean isKeyExchange() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isSecureMessage() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-22 00:25:19 +00:00
|
|
|
public boolean isPreKeyBundle() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-19 21:46:49 +00:00
|
|
|
public boolean isEndSession() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-16 23:23:49 +00:00
|
|
|
public boolean isIdentityUpdate() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-14 08:26:43 +00:00
|
|
|
public String getGroupId() {
|
|
|
|
return groupId;
|
|
|
|
}
|
|
|
|
|
2014-02-20 05:06:54 +00:00
|
|
|
public boolean isGroup() {
|
|
|
|
return false;
|
2014-02-14 23:59:57 +00:00
|
|
|
}
|
|
|
|
|
2013-04-01 02:16:06 +00:00
|
|
|
@Override
|
|
|
|
public int describeContents() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToParcel(Parcel out, int flags) {
|
|
|
|
out.writeString(message);
|
|
|
|
out.writeString(sender);
|
2014-02-03 03:38:06 +00:00
|
|
|
out.writeInt(senderDeviceId);
|
2013-04-01 02:16:06 +00:00
|
|
|
out.writeInt(protocol);
|
|
|
|
out.writeString(serviceCenterAddress);
|
|
|
|
out.writeInt(replyPathPresent ? 1 : 0);
|
|
|
|
out.writeString(pseudoSubject);
|
|
|
|
out.writeLong(sentTimestampMillis);
|
2014-01-14 08:26:43 +00:00
|
|
|
out.writeString(groupId);
|
2014-02-17 19:42:51 +00:00
|
|
|
}
|
2013-04-01 02:16:06 +00:00
|
|
|
}
|