clean up unused message types

This commit is contained in:
Ryan ZHAO 2021-02-23 16:23:45 +11:00
parent fec13ba72e
commit 6f002311b8
23 changed files with 13 additions and 553 deletions

View File

@ -470,16 +470,6 @@
<action android:name="network.loki.securesms.DELETE_NOTIFICATION" />
</intent-filter>
</receiver>
<receiver android:name="org.thoughtcrime.securesms.ExperienceUpgradeActivity$AppUpgradeReceiver">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
<intent-filter>
<action android:name="network.loki.securesms.ExperienceUpgradeActivity.DISMISS_ACTION" />
</intent-filter>
</receiver>
<receiver
android:name="org.thoughtcrime.securesms.service.PanicResponderListener"
android:exported="true">

View File

@ -170,7 +170,6 @@ import org.session.libsession.messaging.threads.recipients.RecipientModifiedList
import org.thoughtcrime.securesms.search.model.MessageResult;
import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.sms.OutgoingEncryptedMessage;
import org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.thoughtcrime.securesms.util.BitmapUtil;
import org.thoughtcrime.securesms.util.DateUtils;
@ -893,36 +892,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
startActivityForResult(intent, SMS_DEFAULT);
}
private void handleResetSecureSession() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.ConversationActivity_reset_secure_session_question);
builder.setIconAttribute(R.attr.dialog_alert_icon);
builder.setCancelable(true);
builder.setMessage(R.string.ConversationActivity_this_may_help_if_youre_having_encryption_problems);
builder.setPositiveButton(R.string.ConversationActivity_reset, (dialog, which) -> {
if (isSingleConversation()) {
final Context context = getApplicationContext();
OutgoingEndSessionMessage endSessionMessage =
new OutgoingEndSessionMessage(new OutgoingTextMessage(getRecipient(), "TERMINATE", 0, -1));
new AsyncTask<OutgoingEndSessionMessage, Void, Long>() {
@Override
protected Long doInBackground(OutgoingEndSessionMessage... messages) {
return MessageSender.send(context, messages[0], threadId, false, null);
}
@Override
protected void onPostExecute(Long result) {
sendComplete(result);
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, endSessionMessage);
}
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.show();
}
private void handleBlock() {
int titleRes = R.string.RecipientPreferenceActivity_block_this_contact_question;
int bodyRes = R.string.RecipientPreferenceActivity_you_will_no_longer_receive_messages_and_calls_from_this_contact;

View File

@ -48,7 +48,6 @@ public interface MmsSmsColumns {
OUTGOING_CALL_TYPE};
// Message attributes
protected static final long MESSAGE_ATTRIBUTE_MASK = 0xE0;
protected static final long MESSAGE_FORCE_SMS_BIT = 0x40;
// Key Exchange Information

View File

@ -167,22 +167,10 @@ public class SmsDatabase extends MessagingDatabase {
return 0;
}
public void markAsEndSession(long id) {
updateTypeBitmask(id, Types.KEY_EXCHANGE_MASK, Types.END_SESSION_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);
}
public void markAsPendingInsecureSmsFallback(long id) {
updateTypeBitmask(id, Types.BASE_TYPE_MASK, Types.BASE_PENDING_INSECURE_SMS_FALLBACK);
}
@Override
public void markAsSent(long id, boolean isSecure) {
updateTypeBitmask(id, Types.BASE_TYPE_MASK, Types.BASE_SENT_TYPE | (isSecure ? Types.PUSH_MESSAGE_BIT | Types.SECURE_MESSAGE_BIT : 0));
@ -358,27 +346,15 @@ public class SmsDatabase extends MessagingDatabase {
}
protected Optional<InsertResult> insertMessageInbox(IncomingTextMessage message, long type, long serverTimestamp) {
if (message.isJoined()) {
type = (type & (Types.TOTAL_MASK - Types.BASE_TYPE_MASK)) | Types.JOINED_TYPE;
} else if (message.isPreKeyBundle()) {
type |= Types.KEY_EXCHANGE_BIT | Types.KEY_EXCHANGE_BUNDLE_BIT;
} else if (message.isSecureMessage()) {
if (message.isSecureMessage()) {
type |= Types.SECURE_MESSAGE_BIT;
} else if (message.isGroup()) {
type |= Types.SECURE_MESSAGE_BIT;
if (((IncomingGroupMessage)message).isUpdate()) type |= Types.GROUP_UPDATE_BIT;
else if (((IncomingGroupMessage)message).isQuit()) type |= Types.GROUP_QUIT_BIT;
} else if (message.isEndSession()) {
type |= Types.SECURE_MESSAGE_BIT;
type |= Types.END_SESSION_BIT;
}
if (message.isPush()) type |= Types.PUSH_MESSAGE_BIT;
if (message.isIdentityUpdate()) type |= Types.KEY_EXCHANGE_IDENTITY_UPDATE_BIT;
if (message.isContentPreKeyBundle()) type |= Types.KEY_EXCHANGE_CONTENT_FORMAT;
if (message.isIdentityVerified()) type |= Types.KEY_EXCHANGE_IDENTITY_VERIFIED_BIT;
else if (message.isIdentityDefault()) type |= Types.KEY_EXCHANGE_IDENTITY_DEFAULT_BIT;
Recipient recipient = Recipient.from(context, message.getSender(), true);
@ -391,8 +367,7 @@ public class SmsDatabase extends MessagingDatabase {
}
boolean unread = (Util.isDefaultSmsProvider(context) ||
message.isSecureMessage() || message.isGroup() || message.isPreKeyBundle()) &&
!message.isIdentityUpdate() && !message.isIdentityDefault() && !message.isIdentityVerified();
message.isSecureMessage() || message.isGroup());
long threadId;
@ -433,9 +408,7 @@ public class SmsDatabase extends MessagingDatabase {
DatabaseFactory.getThreadDatabase(context).incrementUnread(threadId, 1);
}
if (!message.isIdentityUpdate() && !message.isIdentityVerified() && !message.isIdentityDefault()) {
DatabaseFactory.getThreadDatabase(context).update(threadId, true);
}
DatabaseFactory.getThreadDatabase(context).update(threadId, true);
if (message.getSubscriptionId() != -1) {
DatabaseFactory.getRecipientDatabase(context).setDefaultSubscriptionId(recipient, message.getSubscriptionId());
@ -443,9 +416,7 @@ public class SmsDatabase extends MessagingDatabase {
notifyConversationListeners(threadId);
if (!message.isIdentityUpdate() && !message.isIdentityVerified() && !message.isIdentityDefault()) {
ApplicationContext.getInstance(context).getJobManager().add(new TrimThreadJob(threadId));
}
ApplicationContext.getInstance(context).getJobManager().add(new TrimThreadJob(threadId));
return Optional.of(new InsertResult(messageId, threadId));
}
@ -476,14 +447,9 @@ public class SmsDatabase extends MessagingDatabase {
{
long type = Types.BASE_SENDING_TYPE;
if (message.isKeyExchange()) type |= Types.KEY_EXCHANGE_BIT;
else if (message.isSecureMessage()) type |= (Types.SECURE_MESSAGE_BIT | Types.PUSH_MESSAGE_BIT);
else if (message.isEndSession()) type |= Types.END_SESSION_BIT;
if (message.isSecureMessage()) type |= (Types.SECURE_MESSAGE_BIT | Types.PUSH_MESSAGE_BIT);
if (forceSms) type |= Types.MESSAGE_FORCE_SMS_BIT;
if (message.isIdentityVerified()) type |= Types.KEY_EXCHANGE_IDENTITY_VERIFIED_BIT;
else if (message.isIdentityDefault()) type |= Types.KEY_EXCHANGE_IDENTITY_DEFAULT_BIT;
Address address = message.getRecipient().getAddress();
Map<Address, Long> earlyDeliveryReceipts = earlyDeliveryReceiptCache.remove(date);
Map<Address, Long> earlyReadReceipts = earlyReadReceiptCache.remove(date);
@ -507,18 +473,14 @@ public class SmsDatabase extends MessagingDatabase {
insertListener.onComplete();
}
if (!message.isIdentityVerified() && !message.isIdentityDefault()) {
DatabaseFactory.getThreadDatabase(context).update(threadId, true);
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
}
DatabaseFactory.getThreadDatabase(context).update(threadId, true);
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
DatabaseFactory.getThreadDatabase(context).setHasSent(threadId, true);
notifyConversationListeners(threadId);
if (!message.isIdentityVerified() && !message.isIdentityDefault()) {
ApplicationContext.getInstance(context).getJobManager().add(new TrimThreadJob(threadId));
}
ApplicationContext.getInstance(context).getJobManager().add(new TrimThreadJob(threadId));
return messageId;
}

View File

@ -1,18 +0,0 @@
package org.thoughtcrime.securesms.service;
public class AccountVerificationTimeoutException extends Exception {
public AccountVerificationTimeoutException() {
}
public AccountVerificationTimeoutException(String detailMessage) {
super(detailMessage);
}
public AccountVerificationTimeoutException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
}
public AccountVerificationTimeoutException(Throwable throwable) {
super(throwable);
}
}

View File

@ -60,12 +60,10 @@ public class KeyCachingService extends Service {
public static final int SERVICE_RUNNING_ID = 4141;
public static final String KEY_PERMISSION = "network.loki.messenger.ACCESS_SESSION_SECRETS";
// public static final String NEW_KEY_EVENT = "org.thoughtcrime.securesms.service.action.NEW_KEY_EVENT";
public static final String CLEAR_KEY_EVENT = "org.thoughtcrime.securesms.service.action.CLEAR_KEY_EVENT";
public static final String LOCK_TOGGLED_EVENT = "org.thoughtcrime.securesms.service.action.LOCK_ENABLED_EVENT";
private static final String PASSPHRASE_EXPIRED_EVENT = "org.thoughtcrime.securesms.service.action.PASSPHRASE_EXPIRED_EVENT";
public static final String CLEAR_KEY_ACTION = "org.thoughtcrime.securesms.service.action.CLEAR_KEY";
// public static final String DISABLE_ACTION = "org.thoughtcrime.securesms.service.action.DISABLE";
private final IBinder binder = new KeySetBinder();
@ -111,14 +109,6 @@ public class KeyCachingService extends Service {
}
public static synchronized @Nullable Object getMasterSecret(Context context) {
// if (masterSecret == null && (TextSecurePreferences.isPasswordDisabled(context) && !TextSecurePreferences.isScreenLockEnabled(context))) {
// try {
// return MasterSecretUtil.getMasterSecret(context, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
// } catch (InvalidPassphraseException e) {
// Log.w("KeyCachingService", e);
// }
// }
return masterSecret;
}
@ -128,7 +118,6 @@ public class KeyCachingService extends Service {
KeyCachingService.masterSecret = masterSecret;
foregroundService();
// broadcastNewSecret();
startTimeoutIfAppropriate(this);
new AsyncTask<Void, Void, Void>() {
@ -152,7 +141,6 @@ public class KeyCachingService extends Service {
switch (intent.getAction()) {
case CLEAR_KEY_ACTION: handleClearKey(); break;
case PASSPHRASE_EXPIRED_EVENT: handleClearKey(); break;
// case DISABLE_ACTION: handleDisableService(); break;
case LOCK_TOGGLED_EVENT: handleLockToggled(); break;
}
}
@ -166,12 +154,7 @@ public class KeyCachingService extends Service {
super.onCreate();
if (TextSecurePreferences.isPasswordDisabled(this) && !TextSecurePreferences.isScreenLockEnabled(this)) {
// try {
// MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
setMasterSecret(new Object());
// } catch (InvalidPassphraseException e) {
// Log.w("KeyCachingService", e);
// }
}
}
@ -215,21 +198,7 @@ public class KeyCachingService extends Service {
private void handleLockToggled() {
stopForeground(true);
// try {
// MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
setMasterSecret(masterSecret);
// } catch (InvalidPassphraseException e) {
// Log.w(TAG, e);
// }
}
private void handleDisableService() {
if (TextSecurePreferences.isPasswordDisabled(this) &&
!TextSecurePreferences.isScreenLockEnabled(this))
{
stopForeground(true);
}
setMasterSecret(masterSecret);
}
private static void startTimeoutIfAppropriate(@NonNull Context context) {
@ -283,15 +252,6 @@ public class KeyCachingService extends Service {
startForeground(SERVICE_RUNNING_ID, builder.build());
}
// private void broadcastNewSecret() {
// Log.i(TAG, "Broadcasting new secret...");
//
// Intent intent = new Intent(NEW_KEY_EVENT);
// intent.setPackage(getApplicationContext().getPackageName());
//
// sendBroadcast(intent, KEY_PERMISSION);
// }
private PendingIntent buildLockIntent() {
Intent intent = new Intent(this, KeyCachingService.class);
intent.setAction(PASSPHRASE_EXPIRED_EVENT);

View File

@ -1,44 +0,0 @@
/**
* Copyright (C) 2011 Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thoughtcrime.securesms.service;
import android.content.Context;
import org.session.libsession.utilities.TextSecurePreferences;
import org.session.libsignal.libsignal.util.guava.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class VerificationCodeParser {
private static final Pattern CHALLENGE_PATTERN = Pattern.compile(".*Your (Signal|TextSecure) verification code:? ([0-9]{3,4})-([0-9]{3,4}).*", Pattern.DOTALL);
public static Optional<String> parse(Context context, String messageBody) {
if (messageBody == null) {
return Optional.absent();
}
Matcher challengeMatcher = CHALLENGE_PATTERN.matcher(messageBody);
if (!challengeMatcher.matches() || !TextSecurePreferences.isVerifying(context)) {
return Optional.absent();
}
return Optional.of(challengeMatcher.group(2) + challengeMatcher.group(3));
}
}

View File

@ -6,7 +6,7 @@ public class IncomingEncryptedMessage extends IncomingTextMessage {
super(base, newBody);
}
@Override
@Override
public boolean isSecureMessage() {
return true;
}

View File

@ -1,17 +0,0 @@
package org.thoughtcrime.securesms.sms;
public class IncomingEndSessionMessage extends IncomingTextMessage {
public IncomingEndSessionMessage(IncomingTextMessage base) {
this(base, base.getMessageBody());
}
public IncomingEndSessionMessage(IncomingTextMessage base, String newBody) {
super(base, newBody);
}
@Override
public boolean isEndSession() {
return true;
}
}

View File

@ -1,15 +0,0 @@
package org.thoughtcrime.securesms.sms;
public class IncomingIdentityDefaultMessage extends IncomingTextMessage {
public IncomingIdentityDefaultMessage(IncomingTextMessage base) {
super(base, "");
}
@Override
public boolean isIdentityDefault() {
return true;
}
}

View File

@ -1,14 +0,0 @@
package org.thoughtcrime.securesms.sms;
public class IncomingIdentityUpdateMessage extends IncomingTextMessage {
public IncomingIdentityUpdateMessage(IncomingTextMessage base) {
super(base, "");
}
@Override
public boolean isIdentityUpdate() {
return true;
}
}

View File

@ -1,15 +0,0 @@
package org.thoughtcrime.securesms.sms;
public class IncomingIdentityVerifiedMessage extends IncomingTextMessage {
public IncomingIdentityVerifiedMessage(IncomingTextMessage base) {
super(base, "");
}
@Override
public boolean isIdentityVerified() {
return true;
}
}

View File

@ -1,23 +0,0 @@
package org.thoughtcrime.securesms.sms;
import org.session.libsession.messaging.threads.Address;
import org.session.libsignal.libsignal.util.guava.Optional;
import org.session.libsignal.service.api.messages.SignalServiceGroup;
public class IncomingJoinedMessage extends IncomingTextMessage {
public IncomingJoinedMessage(Address sender) {
super(sender, 1, System.currentTimeMillis(), null, Optional.<SignalServiceGroup>absent(), 0, false);
}
@Override
public boolean isJoined() {
return true;
}
@Override
public boolean isSecureMessage() {
return true;
}
}

View File

@ -1,22 +0,0 @@
package org.thoughtcrime.securesms.sms;
public class IncomingPreKeyBundleMessage extends IncomingTextMessage {
private final boolean legacy;
public IncomingPreKeyBundleMessage(IncomingTextMessage base, String newBody, boolean legacy) {
super(base, newBody);
this.legacy = legacy;
}
@Override
public boolean isLegacyPreKeyBundle() {
return legacy;
}
@Override
public boolean isContentPreKeyBundle() {
return !legacy;
}
}

View File

@ -45,22 +45,6 @@ public class IncomingTextMessage implements Parcelable {
private final long expiresInMillis;
private final boolean unidentified;
public IncomingTextMessage(@NonNull Context context, @NonNull SmsMessage message, int subscriptionId) {
this.message = message.getDisplayMessageBody();
this.sender = Address.fromSerialized(message.getDisplayOriginatingAddress());
this.senderDeviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
this.protocol = message.getProtocolIdentifier();
this.serviceCenterAddress = message.getServiceCenterAddress();
this.replyPathPresent = message.isReplyPathPresent();
this.pseudoSubject = message.getPseudoSubject();
this.sentTimestampMillis = message.getTimestampMillis();
this.subscriptionId = subscriptionId;
this.expiresInMillis = 0;
this.groupId = null;
this.push = false;
this.unidentified = false;
}
public IncomingTextMessage(Address sender, int senderDeviceId, long sentTimestampMillis,
String encodedBody, Optional<SignalServiceGroup> group,
long expiresInMillis, boolean unidentified)
@ -117,45 +101,6 @@ public class IncomingTextMessage implements Parcelable {
this.unidentified = base.isUnidentified();
}
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();
this.senderDeviceId = fragments.get(0).getSenderDeviceId();
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();
this.groupId = fragments.get(0).getGroupId();
this.push = fragments.get(0).isPush();
this.subscriptionId = fragments.get(0).getSubscriptionId();
this.expiresInMillis = fragments.get(0).getExpiresIn();
this.unidentified = fragments.get(0).isUnidentified();
}
protected IncomingTextMessage(@NonNull Address sender, @Nullable Address groupId)
{
this.message = "";
this.sender = sender;
this.senderDeviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
this.protocol = 31338;
this.serviceCenterAddress = "Outgoing";
this.replyPathPresent = true;
this.pseudoSubject = "";
this.sentTimestampMillis = System.currentTimeMillis();
this.groupId = groupId;
this.push = true;
this.subscriptionId = -1;
this.expiresInMillis = 0;
this.unidentified = false;
}
public static IncomingTextMessage from(VisibleMessage message,
Address sender,
Optional<SignalServiceGroup> group,
@ -208,22 +153,6 @@ public class IncomingTextMessage implements Parcelable {
return false;
}
public boolean isPreKeyBundle() {
return isLegacyPreKeyBundle() || isContentPreKeyBundle();
}
public boolean isLegacyPreKeyBundle() {
return false;
}
public boolean isContentPreKeyBundle() {
return false;
}
public boolean isEndSession() {
return false;
}
public boolean isPush() {
return push;
}
@ -236,22 +165,6 @@ public class IncomingTextMessage implements Parcelable {
return false;
}
public boolean isJoined() {
return false;
}
public boolean isIdentityUpdate() {
return false;
}
public boolean isIdentityVerified() {
return false;
}
public boolean isIdentityDefault() {
return false;
}
public boolean isUnidentified() {
return unidentified;
}

View File

@ -55,7 +55,6 @@ public class MessageSender {
{
SmsDatabase database = DatabaseFactory.getSmsDatabase(context);
Recipient recipient = message.getRecipient();
boolean keyExchange = message.isKeyExchange();
long allocatedThreadId;
@ -67,7 +66,7 @@ public class MessageSender {
long messageId = database.insertMessageOutbox(allocatedThreadId, message, forceSms, System.currentTimeMillis(), insertListener);
sendTextMessage(context, recipient, forceSms, keyExchange, messageId);
sendTextMessage(context, recipient, forceSms, messageId);
return allocatedThreadId;
}
@ -104,14 +103,13 @@ public class MessageSender {
public static void resend(Context context, MessageRecord messageRecord) {
long messageId = messageRecord.getId();
boolean forceSms = messageRecord.isForcedSms();
boolean keyExchange = messageRecord.isKeyExchange();
long expiresIn = messageRecord.getExpiresIn();
Recipient recipient = messageRecord.getRecipient();
if (messageRecord.isMms()) {
sendMediaMessage(context, recipient, forceSms, messageId, expiresIn);
} else {
sendTextMessage(context, recipient, forceSms, keyExchange, messageId);
sendTextMessage(context, recipient, forceSms, messageId);
}
}
@ -127,8 +125,7 @@ public class MessageSender {
}
private static void sendTextMessage(Context context, Recipient recipient,
boolean forceSms, boolean keyExchange,
long messageId)
boolean forceSms, long messageId)
{
if (isLocalSelfSend(context, recipient, forceSms)) {
sendLocalTextSelf(context, messageId);

View File

@ -8,17 +8,8 @@ public class OutgoingEncryptedMessage extends OutgoingTextMessage {
super(recipient, body, expiresIn, -1);
}
private OutgoingEncryptedMessage(OutgoingEncryptedMessage base, String body) {
super(base, body);
}
@Override
public boolean isSecureMessage() {
return true;
}
@Override
public OutgoingTextMessage withBody(String body) {
return new OutgoingEncryptedMessage(this, body);
}
}

View File

@ -1,22 +0,0 @@
package org.thoughtcrime.securesms.sms;
public class OutgoingEndSessionMessage extends OutgoingTextMessage {
public OutgoingEndSessionMessage(OutgoingTextMessage base) {
this(base, base.getMessageBody());
}
public OutgoingEndSessionMessage(OutgoingTextMessage message, String body) {
super(message, body);
}
@Override
public boolean isEndSession() {
return true;
}
@Override
public OutgoingTextMessage withBody(String body) {
return new OutgoingEndSessionMessage(this, body);
}
}

View File

@ -1,24 +0,0 @@
package org.thoughtcrime.securesms.sms;
import org.session.libsession.messaging.threads.recipients.Recipient;
public class OutgoingIdentityDefaultMessage extends OutgoingTextMessage {
public OutgoingIdentityDefaultMessage(Recipient recipient) {
this(recipient, "");
}
private OutgoingIdentityDefaultMessage(Recipient recipient, String body) {
super(recipient, body, -1);
}
@Override
public boolean isIdentityDefault() {
return true;
}
public OutgoingTextMessage withBody(String body) {
return new OutgoingIdentityDefaultMessage(getRecipient());
}
}

View File

@ -1,25 +0,0 @@
package org.thoughtcrime.securesms.sms;
import org.session.libsession.messaging.threads.recipients.Recipient;
public class OutgoingIdentityVerifiedMessage extends OutgoingTextMessage {
public OutgoingIdentityVerifiedMessage(Recipient recipient) {
this(recipient, "");
}
private OutgoingIdentityVerifiedMessage(Recipient recipient, String body) {
super(recipient, body, -1);
}
@Override
public boolean isIdentityVerified() {
return true;
}
@Override
public OutgoingTextMessage withBody(String body) {
return new OutgoingIdentityVerifiedMessage(getRecipient(), body);
}
}

View File

@ -1,24 +0,0 @@
package org.thoughtcrime.securesms.sms;
import org.session.libsession.messaging.threads.recipients.Recipient;
public class OutgoingKeyExchangeMessage extends OutgoingTextMessage {
public OutgoingKeyExchangeMessage(Recipient recipient, String message) {
super(recipient, message, -1);
}
private OutgoingKeyExchangeMessage(OutgoingKeyExchangeMessage base, String body) {
super(base, body);
}
@Override
public boolean isKeyExchange() {
return true;
}
@Override
public OutgoingTextMessage withBody(String body) {
return new OutgoingKeyExchangeMessage(this, body);
}
}

View File

@ -1,19 +0,0 @@
package org.thoughtcrime.securesms.sms;
public class OutgoingPrekeyBundleMessage extends OutgoingTextMessage {
public OutgoingPrekeyBundleMessage(OutgoingTextMessage message, String body) {
super(message, body);
}
@Override
public boolean isPreKeyBundle() {
return true;
}
@Override
public OutgoingTextMessage withBody(String body) {
return new OutgoingPrekeyBundleMessage(this, body);
}
}

View File

@ -11,10 +11,6 @@ public class OutgoingTextMessage {
private final int subscriptionId;
private final long expiresIn;
public OutgoingTextMessage(Recipient recipient, String message, int subscriptionId) {
this(recipient, message, 0, subscriptionId);
}
public OutgoingTextMessage(Recipient recipient, String message, long expiresIn, int subscriptionId) {
this.recipient = recipient;
this.message = message;
@ -22,13 +18,6 @@ public class OutgoingTextMessage {
this.subscriptionId = subscriptionId;
}
protected OutgoingTextMessage(OutgoingTextMessage base, String body) {
this.recipient = base.getRecipient();
this.subscriptionId = base.getSubscriptionId();
this.expiresIn = base.getExpiresIn();
this.message = body;
}
public static OutgoingTextMessage from(VisibleMessage message, Recipient recipient) {
return new OutgoingTextMessage(recipient, message.getText(), recipient.getExpireMessages() * 1000, -1);
}
@ -49,43 +38,15 @@ public class OutgoingTextMessage {
return recipient;
}
public boolean isKeyExchange() {
return false;
}
public boolean isSecureMessage() {
return false;
}
public boolean isEndSession() {
return false;
}
public boolean isPreKeyBundle() {
return false;
}
public boolean isIdentityVerified() {
return false;
}
public boolean isIdentityDefault() {
return false;
}
public static OutgoingTextMessage from(SmsMessageRecord record) {
if (record.isSecure()) {
return new OutgoingEncryptedMessage(record.getRecipient(), record.getBody(), record.getExpiresIn());
} else if (record.isKeyExchange()) {
return new OutgoingKeyExchangeMessage(record.getRecipient(), record.getBody());
} else if (record.isEndSession()) {
return new OutgoingEndSessionMessage(new OutgoingTextMessage(record.getRecipient(), record.getBody(), 0, -1));
} else {
return new OutgoingTextMessage(record.getRecipient(), record.getBody(), record.getExpiresIn(), record.getSubscriptionId());
}
}
public OutgoingTextMessage withBody(String body) {
return new OutgoingTextMessage(this, body);
}
}