Correctly store destination SMS state.

This commit is contained in:
Moxie Marlinspike 2013-10-20 12:15:36 -07:00
parent 51b9affe90
commit 44d59d0fd1
4 changed files with 10 additions and 9 deletions

View File

@ -109,7 +109,7 @@ public class Directory {
values.put(TOKEN, token.getToken()); values.put(TOKEN, token.getToken());
values.put(RELAY, token.getRelay()); values.put(RELAY, token.getRelay());
values.put(REGISTERED, active ? 1 : 0); values.put(REGISTERED, active ? 1 : 0);
values.put(SUPPORTS_SMS, token.isSupportsSms()); values.put(SUPPORTS_SMS, token.isSupportsSms() ? 1 : 0);
values.put(TIMESTAMP, System.currentTimeMillis()); values.put(TIMESTAMP, System.currentTimeMillis());
db.replace(TABLE_NAME, null, values); db.replace(TABLE_NAME, null, values);
} }
@ -127,6 +127,7 @@ public class Directory {
values.put(REGISTERED, 1); values.put(REGISTERED, 1);
values.put(TIMESTAMP, timestamp); values.put(TIMESTAMP, timestamp);
values.put(RELAY, token.getRelay()); values.put(RELAY, token.getRelay());
values.put(SUPPORTS_SMS, token.isSupportsSms() ? 1 : 0);
db.replace(TABLE_NAME, null, values); db.replace(TABLE_NAME, null, values);
} }

View File

@ -23,9 +23,9 @@ public class PushDestination {
return relay; return relay;
} }
public static PushDestination getInstance(Context context, public static PushDestination create(Context context,
PushServiceSocket.PushCredentials credentials, PushServiceSocket.PushCredentials credentials,
String destinationNumber) String destinationNumber)
{ {
String e164destination = PhoneNumberFormatter.formatNumber(destinationNumber, credentials.getLocalNumber(context)); String e164destination = PhoneNumberFormatter.formatNumber(destinationNumber, credentials.getLocalNumber(context));
String relay = Directory.getInstance(context).getRelay(e164destination); String relay = Directory.getInstance(context).getRelay(e164destination);

View File

@ -59,8 +59,8 @@ public class PushTransport extends BaseTransport {
TextSecurePushCredentials credentials = TextSecurePushCredentials.getInstance(); TextSecurePushCredentials credentials = TextSecurePushCredentials.getInstance();
Recipient recipient = message.getIndividualRecipient(); Recipient recipient = message.getIndividualRecipient();
PushServiceSocket socket = new PushServiceSocket(context, credentials); PushServiceSocket socket = new PushServiceSocket(context, credentials);
PushDestination destination = PushDestination.getInstance(context, credentials, PushDestination destination = PushDestination.create(context, credentials,
recipient.getNumber()); recipient.getNumber());
String plaintextBody = message.getBody().getBody(); String plaintextBody = message.getBody().getBody();
byte[] plaintext = PushMessageContent.newBuilder() byte[] plaintext = PushMessageContent.newBuilder()

View File

@ -104,19 +104,19 @@ public class UniversalTransport {
if (mediaMessage.getTo() != null) { if (mediaMessage.getTo() != null) {
for (EncodedStringValue to : mediaMessage.getTo()) { for (EncodedStringValue to : mediaMessage.getTo()) {
destinations.add(PushDestination.getInstance(context, credentials, to.getString())); destinations.add(PushDestination.create(context, credentials, to.getString()));
} }
} }
if (mediaMessage.getCc() != null) { if (mediaMessage.getCc() != null) {
for (EncodedStringValue cc : mediaMessage.getCc()) { for (EncodedStringValue cc : mediaMessage.getCc()) {
destinations.add(PushDestination.getInstance(context, credentials, cc.getString())); destinations.add(PushDestination.create(context, credentials, cc.getString()));
} }
} }
if (mediaMessage.getBcc() != null) { if (mediaMessage.getBcc() != null) {
for (EncodedStringValue bcc : mediaMessage.getBcc()) { for (EncodedStringValue bcc : mediaMessage.getBcc()) {
destinations.add(PushDestination.getInstance(context, credentials, bcc.getString())); destinations.add(PushDestination.create(context, credentials, bcc.getString()));
} }
} }