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 12:22:04 -07:00
|
|
|
package org.thoughtcrime.securesms.sms;
|
|
|
|
|
|
|
|
public class IncomingKeyExchangeMessage extends IncomingTextMessage {
|
|
|
|
|
|
|
|
private boolean isStale;
|
|
|
|
private boolean isProcessed;
|
2013-08-21 17:25:19 -07:00
|
|
|
private boolean isCorrupted;
|
|
|
|
private boolean isInvalidVersion;
|
2014-04-09 20:02:46 -07:00
|
|
|
private boolean isLegacyVersion;
|
2014-07-20 14:35:46 -07:00
|
|
|
private boolean isDuplicate;
|
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 12:22:04 -07:00
|
|
|
|
2013-08-21 17:25:19 -07:00
|
|
|
public IncomingKeyExchangeMessage(IncomingTextMessage base, String newBody) {
|
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 12:22:04 -07:00
|
|
|
super(base, newBody);
|
|
|
|
|
|
|
|
if (base instanceof IncomingKeyExchangeMessage) {
|
2013-08-21 17:25:19 -07:00
|
|
|
this.isStale = ((IncomingKeyExchangeMessage)base).isStale;
|
|
|
|
this.isProcessed = ((IncomingKeyExchangeMessage)base).isProcessed;
|
|
|
|
this.isCorrupted = ((IncomingKeyExchangeMessage)base).isCorrupted;
|
|
|
|
this.isInvalidVersion = ((IncomingKeyExchangeMessage)base).isInvalidVersion;
|
2014-04-09 20:02:46 -07:00
|
|
|
this.isLegacyVersion = ((IncomingKeyExchangeMessage)base).isLegacyVersion;
|
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 12:22:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IncomingTextMessage withMessageBody(String messageBody) {
|
|
|
|
return new IncomingKeyExchangeMessage(this, messageBody);
|
|
|
|
}
|
|
|
|
|
2014-04-09 20:02:46 -07:00
|
|
|
public boolean isIdentityUpdate() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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 12:22:04 -07:00
|
|
|
public boolean isStale() {
|
|
|
|
return isStale;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isProcessed() {
|
|
|
|
return isProcessed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setStale(boolean isStale) {
|
|
|
|
this.isStale = isStale;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setProcessed(boolean isProcessed) {
|
|
|
|
this.isProcessed = isProcessed;
|
|
|
|
}
|
|
|
|
|
2013-08-21 17:25:19 -07:00
|
|
|
public boolean isCorrupted() {
|
|
|
|
return isCorrupted;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCorrupted(boolean isCorrupted) {
|
|
|
|
this.isCorrupted = isCorrupted;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isInvalidVersion() {
|
|
|
|
return isInvalidVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setInvalidVersion(boolean isInvalidVersion) {
|
|
|
|
this.isInvalidVersion = isInvalidVersion;
|
|
|
|
}
|
|
|
|
|
2014-04-09 20:02:46 -07:00
|
|
|
public boolean isLegacyVersion() {
|
|
|
|
return isLegacyVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLegacyVersion(boolean isLegacyVersion) {
|
|
|
|
this.isLegacyVersion = isLegacyVersion;
|
|
|
|
}
|
|
|
|
|
2014-07-20 14:35:46 -07:00
|
|
|
public void setDuplicate(boolean isDuplicate) {
|
|
|
|
this.isDuplicate = isDuplicate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isDuplicate() {
|
|
|
|
return isDuplicate;
|
|
|
|
}
|
|
|
|
|
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 12:22:04 -07:00
|
|
|
@Override
|
|
|
|
public boolean isKeyExchange() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|