Rename RecipientPreferences -> RecipientSettings

// FREEBIE
This commit is contained in:
Moxie Marlinspike
2017-08-21 18:47:37 -07:00
parent 8e6ca53023
commit d1790dfe17
26 changed files with 156 additions and 156 deletions

View File

@@ -45,7 +45,7 @@ public class MultiDeviceBlockedUpdateJob extends MasterSecretJob implements Inje
public void onRun(MasterSecret masterSecret)
throws IOException, UntrustedIdentityException
{
RecipientDatabase database = DatabaseFactory.getRecipientPreferenceDatabase(context);
RecipientDatabase database = DatabaseFactory.getRecipientDatabase(context);
SignalServiceMessageSender messageSender = messageSenderFactory.create();
BlockedReader reader = database.readerForBlocked(database.getBlocked());
List<String> blocked = new LinkedList<>();

View File

@@ -26,7 +26,7 @@ import org.thoughtcrime.securesms.database.MmsDatabase;
import org.thoughtcrime.securesms.database.NoSuchMessageException;
import org.thoughtcrime.securesms.database.PushDatabase;
import org.thoughtcrime.securesms.database.RecipientDatabase;
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
import org.thoughtcrime.securesms.database.SmsDatabase;
import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.groups.GroupMessageProcessor;
@@ -391,7 +391,7 @@ public class PushDecryptJob extends ContextJob {
database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);
DatabaseFactory.getRecipientPreferenceDatabase(context).setExpireMessages(recipient, message.getExpiresInSeconds());
DatabaseFactory.getRecipientDatabase(context).setExpireMessages(recipient, message.getExpiresInSeconds());
if (smsMessageId.isPresent()) {
DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
@@ -549,7 +549,7 @@ public class PushDecryptJob extends ContextJob {
database.markAsSent(messageId, true);
DatabaseFactory.getRecipientPreferenceDatabase(context).setExpireMessages(recipient, message.getMessage().getExpiresInSeconds());
DatabaseFactory.getRecipientDatabase(context).setExpireMessages(recipient, message.getMessage().getExpiresInSeconds());
if (smsMessageId.isPresent()) {
DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
@@ -803,12 +803,12 @@ public class PushDecryptJob extends ContextJob {
private void handleProfileKey(@NonNull SignalServiceEnvelope envelope,
@NonNull SignalServiceDataMessage message)
{
RecipientDatabase database = DatabaseFactory.getRecipientPreferenceDatabase(context);
Address sourceAddress = Address.fromExternal(context, envelope.getSource());
Optional<RecipientsPreferences> preferences = database.getRecipientsPreferences(sourceAddress);
RecipientDatabase database = DatabaseFactory.getRecipientDatabase(context);
Address sourceAddress = Address.fromExternal(context, envelope.getSource());
Optional<RecipientSettings> settings = database.getRecipientSettings(sourceAddress);
if (!preferences.isPresent() || preferences.get().getProfileKey() == null ||
!MessageDigest.isEqual(message.getProfileKey().get(), preferences.get().getProfileKey()))
if (!settings.isPresent() || settings.get().getProfileKey() == null ||
!MessageDigest.isEqual(message.getProfileKey().get(), settings.get().getProfileKey()))
{
database.setProfileKey(sourceAddress, message.getProfileKey().get());

View File

@@ -7,7 +7,7 @@ import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.util.Util;
@@ -30,7 +30,7 @@ public abstract class PushReceivedJob extends ContextJob {
Address source = Address.fromExternal(context, envelope.getSource());
if (!isActiveNumber(context, source)) {
DatabaseFactory.getRecipientPreferenceDatabase(context).setRegistered(Util.asList(source), new LinkedList<>());
DatabaseFactory.getRecipientDatabase(context).setRegistered(Util.asList(source), new LinkedList<>());
Recipient recipient = Recipient.from(context, source, false);
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, KeyCachingService.getMasterSecret(context), recipient));
}
@@ -69,8 +69,8 @@ public abstract class PushReceivedJob extends ContextJob {
}
private boolean isActiveNumber(Context context, Address address) {
Optional<RecipientsPreferences> preferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(address);
return preferences.isPresent() && preferences.get().isRegistered();
Optional<RecipientSettings> settings = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(address);
return settings.isPresent() && settings.get().isRegistered();
}

View File

@@ -11,7 +11,7 @@ import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
import org.thoughtcrime.securesms.events.PartProgressEvent;
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
import org.thoughtcrime.securesms.mms.PartAuthority;
@@ -66,8 +66,8 @@ public abstract class PushSendJob extends SendJob {
protected Optional<byte[]> getProfileKey(Address address) {
try {
Optional<RecipientsPreferences> recipientsPreferences = DatabaseFactory.getRecipientPreferenceDatabase(context)
.getRecipientsPreferences(address);
Optional<RecipientSettings> recipientsPreferences = DatabaseFactory.getRecipientDatabase(context)
.getRecipientSettings(address);
if (!recipientsPreferences.isPresent()) return Optional.absent();

View File

@@ -7,7 +7,7 @@ import android.util.Log;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.RecipientDatabase;
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.thoughtcrime.securesms.profiles.AvatarHelper;
import org.thoughtcrime.securesms.recipients.Recipient;
@@ -51,20 +51,20 @@ public class RetrieveProfileAvatarJob extends ContextJob implements InjectableTy
@Override
public void onRun() throws IOException {
RecipientDatabase database = DatabaseFactory.getRecipientPreferenceDatabase(context);
Optional<RecipientsPreferences> recipientsPreferences = database.getRecipientsPreferences(recipient.getAddress());
RecipientDatabase database = DatabaseFactory.getRecipientDatabase(context);
Optional<RecipientSettings> recipientSettings = database.getRecipientSettings(recipient.getAddress());
if (!recipientsPreferences.isPresent()) {
if (!recipientSettings.isPresent()) {
Log.w(TAG, "Recipient preference row is gone!");
return;
}
if (recipientsPreferences.get().getProfileKey() == null) {
if (recipientSettings.get().getProfileKey() == null) {
Log.w(TAG, "Recipient profile key is gone!");
return;
}
if (Util.equals(profileAvatar, recipientsPreferences.get().getProfileAvatar())) {
if (Util.equals(profileAvatar, recipientSettings.get().getProfileAvatar())) {
Log.w(TAG, "Already retrieved profile avatar: " + profileAvatar);
return;
}
@@ -78,7 +78,7 @@ public class RetrieveProfileAvatarJob extends ContextJob implements InjectableTy
File downloadDestination = File.createTempFile("avatar", "jpg", context.getCacheDir());
try {
InputStream avatarStream = receiver.retrieveProfileAvatar(profileAvatar, downloadDestination, recipientsPreferences.get().getProfileKey(), MAX_PROFILE_SIZE_BYTES);
InputStream avatarStream = receiver.retrieveProfileAvatar(profileAvatar, downloadDestination, recipientSettings.get().getProfileKey(), MAX_PROFILE_SIZE_BYTES);
File decryptDestination = File.createTempFile("avatar", "jpg", context.getCacheDir());
Util.copy(avatarStream, new FileOutputStream(decryptDestination));

View File

@@ -8,7 +8,7 @@ import android.util.Log;
import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.service.MessageRetrievalService;
@@ -71,13 +71,13 @@ public class RetrieveProfileJob extends ContextJob implements InjectableType {
private void handleIndividualRecipient(Recipient recipient)
throws IOException, InvalidKeyException, InvalidNumberException
{
String number = recipient.getAddress().toPhoneString();
SignalServiceProfile profile = retrieveProfile(number);
Optional<RecipientsPreferences> recipientPreferences = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipient.getAddress());
String number = recipient.getAddress().toPhoneString();
SignalServiceProfile profile = retrieveProfile(number);
Optional<RecipientSettings> recipientSettings = DatabaseFactory.getRecipientDatabase(context).getRecipientSettings(recipient.getAddress());
setIdentityKey(recipient, profile.getIdentityKey());
setProfileName(recipient, recipientPreferences, profile.getName());
setProfileAvatar(recipient, recipientPreferences, profile.getAvatar());
setProfileName(recipient, recipientSettings, profile.getName());
setProfileAvatar(recipient, recipientSettings, profile.getAvatar());
}
private void handleGroupRecipient(Recipient group)
@@ -127,7 +127,7 @@ public class RetrieveProfileJob extends ContextJob implements InjectableType {
}
}
private void setProfileName(Recipient recipient, Optional<RecipientsPreferences> recipientPreferences, String profileName) {
private void setProfileName(Recipient recipient, Optional<RecipientSettings> recipientPreferences, String profileName) {
try {
if (!recipientPreferences.isPresent()) return;
if (recipientPreferences.get().getProfileKey() == null) return;
@@ -140,7 +140,7 @@ public class RetrieveProfileJob extends ContextJob implements InjectableType {
}
if (!Util.equals(plaintextProfileName, recipientPreferences.get().getProfileName())) {
DatabaseFactory.getRecipientPreferenceDatabase(context).setProfileName(recipient.getAddress(), plaintextProfileName);
DatabaseFactory.getRecipientDatabase(context).setProfileName(recipient.getAddress(), plaintextProfileName);
Recipient.clearCache(context);
}
} catch (ProfileCipher.InvalidCiphertextException | IOException e) {
@@ -148,7 +148,7 @@ public class RetrieveProfileJob extends ContextJob implements InjectableType {
}
}
private void setProfileAvatar(Recipient recipient, Optional<RecipientsPreferences> recipientPreferences, String profileAvatar) {
private void setProfileAvatar(Recipient recipient, Optional<RecipientSettings> recipientPreferences, String profileAvatar) {
if (!recipientPreferences.isPresent()) return;
if (recipientPreferences.get().getProfileKey() == null) return;