From b5792a81aafc5de93d8591cd28466b69a2f0f185 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 11 Feb 2020 09:38:05 +1100 Subject: [PATCH] Update for core changes --- res/xml/network_security_configuration.xml | 1 + .../securesms/ApplicationContext.java | 6 +++--- .../securesms/CreateProfileActivity.java | 4 ++-- .../securesms/components/TypingStatusSender.java | 6 +++--- .../conversation/ConversationActivity.java | 4 ++-- .../database/loaders/DeviceListLoader.java | 4 ++-- .../securesms/groups/GroupMessageProcessor.java | 6 +++--- .../securesms/jobs/AttachmentUploadJob.java | 2 +- .../securesms/jobs/PushDecryptJob.java | 10 +++++----- .../securesms/jobs/PushGroupSendJob.java | 4 ++-- .../securesms/jobs/PushMediaSendJob.java | 4 ++-- .../securesms/jobs/PushTextSendJob.java | 4 ++-- .../securesms/loki/MultiDeviceUtilities.kt | 16 ++++++++-------- .../redesign/activities/LinkedDevicesActivity.kt | 4 ++-- .../redesign/activities/LinkedDevicesLoader.kt | 4 ++-- .../loki/redesign/activities/SettingsActivity.kt | 4 ++-- .../redesign/messaging/LokiPublicChatPoller.kt | 14 +++++++------- .../loki/redesign/messaging/LokiRSSFeedPoller.kt | 4 ++-- .../notifications/MarkReadReceiver.java | 2 +- .../securesms/sms/MessageSender.java | 6 +++--- 20 files changed, 55 insertions(+), 54 deletions(-) diff --git a/res/xml/network_security_configuration.xml b/res/xml/network_security_configuration.xml index df97928889..c62b3d962e 100644 --- a/res/xml/network_security_configuration.xml +++ b/res/xml/network_security_configuration.xml @@ -6,6 +6,7 @@ storage.seed1.loki.network storage.seed2.loki.network public.loki.foundation:22023 + file-dev.lokinet.org 127.0.0.1 \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/ApplicationContext.java b/src/org/thoughtcrime/securesms/ApplicationContext.java index 7f099f4617..5bcc0d948c 100644 --- a/src/org/thoughtcrime/securesms/ApplicationContext.java +++ b/src/org/thoughtcrime/securesms/ApplicationContext.java @@ -103,7 +103,7 @@ import org.whispersystems.signalservice.loki.api.LokiP2PAPIDelegate; import org.whispersystems.signalservice.loki.api.LokiPublicChat; import org.whispersystems.signalservice.loki.api.LokiPublicChatAPI; import org.whispersystems.signalservice.loki.api.LokiRSSFeed; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import java.security.Security; import java.util.ArrayList; @@ -188,7 +188,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc LokiDotNetAPI.setCache(new Cache(this.getCacheDir(), OK_HTTP_CACHE_SIZE)); // Loki - Update device mappings if (setUpStorageAPIIfNeeded()) { - LokiStorageAPI.Companion.getShared().updateUserDeviceMappings(); + LokiFileServerAPI.Companion.getShared().updateUserDeviceMappings(); if (TextSecurePreferences.needsRevocationCheck(this)) { checkNeedsRevocation(); } @@ -466,7 +466,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc boolean isDebugMode = BuildConfig.DEBUG; byte[] userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).getPrivateKey().serialize(); LokiAPIDatabaseProtocol database = DatabaseFactory.getLokiAPIDatabase(this); - LokiStorageAPI.Companion.configure(isDebugMode, userHexEncodedPublicKey, userPrivateKey, database); + LokiFileServerAPI.Companion.configure(isDebugMode, userHexEncodedPublicKey, userPrivateKey, database); return true; } return false; diff --git a/src/org/thoughtcrime/securesms/CreateProfileActivity.java b/src/org/thoughtcrime/securesms/CreateProfileActivity.java index b2eb3f32e8..74d7f81b32 100644 --- a/src/org/thoughtcrime/securesms/CreateProfileActivity.java +++ b/src/org/thoughtcrime/securesms/CreateProfileActivity.java @@ -59,7 +59,7 @@ import org.whispersystems.signalservice.api.crypto.ProfileCipher; import org.whispersystems.signalservice.api.util.StreamDetails; import org.whispersystems.signalservice.loki.api.LokiDotNetAPI; import org.whispersystems.signalservice.loki.api.LokiPublicChatAPI; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import java.io.ByteArrayInputStream; import java.io.File; @@ -407,7 +407,7 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje //Loki - Upload the profile photo here if (avatar != null) { Log.d("Loki", "Start uploading profile photo"); - LokiStorageAPI storageAPI = LokiStorageAPI.shared; + LokiFileServerAPI storageAPI = LokiFileServerAPI.shared; LokiDotNetAPI.UploadResult result = storageAPI.uploadProfilePicture(storageAPI.getServer(), profileKey, avatar); Log.d("Loki", "Profile photo uploaded, the url is " + result.getUrl()); TextSecurePreferences.setProfileAvatarUrl(context, result.getUrl()); diff --git a/src/org/thoughtcrime/securesms/components/TypingStatusSender.java b/src/org/thoughtcrime/securesms/components/TypingStatusSender.java index 927b158e42..4b7908cbb6 100644 --- a/src/org/thoughtcrime/securesms/components/TypingStatusSender.java +++ b/src/org/thoughtcrime/securesms/components/TypingStatusSender.java @@ -12,7 +12,7 @@ import org.thoughtcrime.securesms.jobs.TypingSendJob; import org.thoughtcrime.securesms.loki.MultiDeviceUtilities; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.util.Util; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import java.util.HashMap; import java.util.Map; @@ -83,7 +83,7 @@ public class TypingStatusSender { } private void sendTyping(long threadId, boolean typingStarted) { - LokiStorageAPI storageAPI = LokiStorageAPI.Companion.getShared(); + LokiFileServerAPI storageAPI = LokiFileServerAPI.Companion.getShared(); ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context); Recipient recipient = threadDatabase.getRecipientForThreadId(threadId); @@ -91,7 +91,7 @@ public class TypingStatusSender { ApplicationContext.getInstance(context).getJobManager().add(new TypingSendJob(threadId, typingStarted)); return; } - LokiStorageAPI.shared.getAllDevicePublicKeys(recipient.getAddress().serialize()).success(devices -> { + LokiFileServerAPI.shared.getAllDevicePublicKeys(recipient.getAddress().serialize()).success(devices -> { for (String device : devices) { Recipient deviceRecipient = Recipient.from(context, Address.fromSerialized(device), false); long deviceThreadID = threadDatabase.getThreadIdIfExistsFor(deviceRecipient); diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index c180b5f054..2d1dabb73b 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -234,7 +234,7 @@ import org.whispersystems.libsignal.InvalidMessageException; import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.signalservice.loki.api.LokiAPI; import org.whispersystems.signalservice.loki.api.LokiPublicChat; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import org.whispersystems.signalservice.loki.api.PairingAuthorisation; import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus; import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus; @@ -2290,7 +2290,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity if (threadID != this.threadId) { Recipient threadRecipient = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadID); if (threadRecipient != null && !threadRecipient.isGroupRecipient()) { - LokiStorageAPI.shared.getAllDevicePublicKeys(threadRecipient.getAddress().serialize()).success(devices -> { + LokiFileServerAPI.shared.getAllDevicePublicKeys(threadRecipient.getAddress().serialize()).success(devices -> { // We should update our input if this thread is a part of the other threads device if (devices.contains(recipient.getAddress().serialize())) { this.updateInputPanel(); diff --git a/src/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java b/src/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java index 031eb62a4d..e5abc7d886 100644 --- a/src/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java +++ b/src/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java @@ -11,7 +11,7 @@ import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities; import org.thoughtcrime.securesms.util.AsyncLoader; import org.thoughtcrime.securesms.util.TextSecurePreferences; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import org.whispersystems.signalservice.loki.crypto.MnemonicCodec; import java.io.File; @@ -33,7 +33,7 @@ public class DeviceListLoader extends AsyncLoader> { public List loadInBackground() { try { String ourPublicKey = TextSecurePreferences.getLocalNumber(getContext()); - List secondaryDevicePublicKeys = LokiStorageAPI.shared.getSecondaryDevicePublicKeys(ourPublicKey).get(); + List secondaryDevicePublicKeys = LokiFileServerAPI.shared.getSecondaryDevicePublicKeys(ourPublicKey).get(); List devices = Stream.of(secondaryDevicePublicKeys).map(this::mapToDevice).toList(); Collections.sort(devices, new DeviceComparator()); return devices; diff --git a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java index 9f216e2fad..3ba89fe908 100644 --- a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java +++ b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java @@ -36,7 +36,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage; import org.whispersystems.signalservice.api.messages.SignalServiceGroup; import org.whispersystems.signalservice.api.messages.SignalServiceGroup.Type; import org.whispersystems.signalservice.api.push.SignalServiceAddress; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import org.whispersystems.signalservice.loki.utilities.PromiseUtil; import java.util.Collections; @@ -318,7 +318,7 @@ public class GroupMessageProcessor { try { String masterHexEncodedPublicKey = hexEncodedPublicKey.equalsIgnoreCase(ourPublicKey) ? TextSecurePreferences.getMasterHexEncodedPublicKey(context) - : PromiseUtil.timeout(LokiStorageAPI.shared.getPrimaryDevicePublicKey(hexEncodedPublicKey), 5000).get(); + : PromiseUtil.timeout(LokiFileServerAPI.shared.getPrimaryDevicePublicKey(hexEncodedPublicKey), 5000).get(); return masterHexEncodedPublicKey != null ? masterHexEncodedPublicKey : hexEncodedPublicKey; } catch (Exception e) { return hexEncodedPublicKey; @@ -329,7 +329,7 @@ public class GroupMessageProcessor { String ourNumber = TextSecurePreferences.getLocalNumber(context); for (String member : members) { // Make sure we have session with all of the members secondary devices - LokiStorageAPI.shared.getAllDevicePublicKeys(member).success(devices -> { + LokiFileServerAPI.shared.getAllDevicePublicKeys(member).success(devices -> { if (devices.contains(ourNumber)) { return Unit.INSTANCE; } for (String device : devices) { SignalProtocolAddress protocolAddress = new SignalProtocolAddress(device, SignalServiceAddress.DEFAULT_DEVICE_ID); diff --git a/src/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java b/src/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java index dce85f83e6..3bb54e43d9 100644 --- a/src/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java +++ b/src/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java @@ -27,7 +27,7 @@ import org.whispersystems.signalservice.api.SignalServiceMessageSender; import org.whispersystems.signalservice.api.messages.SignalServiceAttachment; import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer; import org.whispersystems.signalservice.api.push.SignalServiceAddress; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import java.io.IOException; import java.io.InputStream; diff --git a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index 6282120598..0507e8c0f0 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -131,7 +131,7 @@ import org.whispersystems.signalservice.api.messages.shared.SharedContact; import org.whispersystems.signalservice.api.push.SignalServiceAddress; import org.whispersystems.signalservice.loki.api.DeviceLinkingSession; import org.whispersystems.signalservice.loki.api.LokiAPI; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import org.whispersystems.signalservice.loki.api.PairingAuthorisation; import org.whispersystems.signalservice.loki.crypto.LokiServiceCipher; import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus; @@ -1177,7 +1177,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { // Send a background message to the primary device MessageSender.sendBackgroundMessage(context, authorisation.getPrimaryDevicePublicKey()); // Propagate the updates to the file server - LokiStorageAPI storageAPI = LokiStorageAPI.Companion.getShared(); + LokiFileServerAPI storageAPI = LokiFileServerAPI.Companion.getShared(); storageAPI.updateUserDeviceMappings(); // Update display names if (content.senderDisplayName.isPresent() && content.senderDisplayName.get().length() > 0) { @@ -1245,7 +1245,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { private void handleSessionRequestIfNeeded(@NonNull SignalServiceContent content) { if (content.isFriendRequest() && isSessionRequest(content)) { // Check if the session request from a member in one of our groups or our friend - LokiStorageAPI.shared.getPrimaryDevicePublicKey(content.getSender()).success(primaryDevicePublicKey -> { + LokiFileServerAPI.shared.getPrimaryDevicePublicKey(content.getSender()).success(primaryDevicePublicKey -> { String sender = primaryDevicePublicKey != null ? primaryDevicePublicKey : content.getSender(); long threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(Recipient.from(context, Address.fromSerialized(sender), false)); LokiThreadFriendRequestStatus threadFriendRequestStatus = DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadID); @@ -1284,7 +1284,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { // Allow profile sharing with contact DatabaseFactory.getRecipientDatabase(context).setProfileSharing(contactID, true); // Update the last message if needed - LokiStorageAPI.shared.getPrimaryDevicePublicKey(pubKey).success(primaryDevice -> { + LokiFileServerAPI.shared.getPrimaryDevicePublicKey(pubKey).success(primaryDevice -> { Util.runOnMain(() -> { long primaryDeviceThreadID = primaryDevice == null ? threadID : DatabaseFactory.getThreadDatabase(context).getThreadIdFor(Recipient.from(context, Address.fromSerialized(primaryDevice), false)); FriendRequestHandler.updateLastFriendRequestMessage(context, primaryDeviceThreadID, LokiMessageFriendRequestStatus.REQUEST_ACCEPTED); @@ -1799,7 +1799,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { */ private Recipient getPrimaryDeviceRecipient(String pubKey) { try { - String primaryDevice = PromiseUtil.timeout(LokiStorageAPI.shared.getPrimaryDevicePublicKey(pubKey), 5000).get(); + String primaryDevice = PromiseUtil.timeout(LokiFileServerAPI.shared.getPrimaryDevicePublicKey(pubKey), 5000).get(); String publicKey = (primaryDevice != null) ? primaryDevice : pubKey; // If the public key matches our primary device then we need to forward the message to ourselves (Note to self) String ourPrimaryDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context); diff --git a/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java index 04e672c20a..1c07fd611a 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java @@ -51,7 +51,7 @@ import org.whispersystems.signalservice.api.messages.shared.SharedContact; import org.whispersystems.signalservice.api.push.SignalServiceAddress; import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext; import org.whispersystems.signalservice.loki.api.LokiPublicChat; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import org.whispersystems.signalservice.loki.utilities.PromiseUtil; import java.io.IOException; @@ -368,7 +368,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType { if (!member.isPhone() || member.serialize().equalsIgnoreCase(localNumber)) { continue; } try { - List secondaryDevices = PromiseUtil.timeout(LokiStorageAPI.shared.getSecondaryDevicePublicKeys(member.serialize()), 5000).get(); + List secondaryDevices = PromiseUtil.timeout(LokiFileServerAPI.shared.getSecondaryDevicePublicKeys(member.serialize()), 5000).get(); memberSet.addAll(Stream.of(secondaryDevices).map(string -> { // Loki - Calling .map(Address::fromSerialized) is causing errors, thus we use the long method :( return Address.fromSerialized(string); diff --git a/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java index ae133a0394..13de89022b 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java @@ -43,7 +43,7 @@ import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSy import org.whispersystems.signalservice.api.messages.shared.SharedContact; import org.whispersystems.signalservice.api.push.SignalServiceAddress; import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import org.whispersystems.signalservice.loki.messaging.LokiSyncMessage; import org.whispersystems.signalservice.loki.utilities.PromiseUtil; @@ -292,7 +292,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType { LokiSyncMessage syncMessage = null; if (shouldSendSyncMessage) { // Set the sync message destination the primary device, this way it will show that we sent a message to the primary device and not a secondary device - String primaryDevice = PromiseUtil.get(LokiStorageAPI.shared.getPrimaryDevicePublicKey(address.getNumber()), null); + String primaryDevice = PromiseUtil.get(LokiFileServerAPI.shared.getPrimaryDevicePublicKey(address.getNumber()), null); SignalServiceAddress primaryAddress = primaryDevice == null ? address : new SignalServiceAddress(primaryDevice); // We also need to use the original message id and not -1 syncMessage = new LokiSyncMessage(primaryAddress, templateMessageId); diff --git a/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java index a8a084a447..dfa291436d 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java @@ -30,7 +30,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage; import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage; import org.whispersystems.signalservice.api.push.SignalServiceAddress; import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import org.whispersystems.signalservice.loki.messaging.LokiSyncMessage; import org.whispersystems.signalservice.loki.utilities.PromiseUtil; @@ -237,7 +237,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType { LokiSyncMessage syncMessage = null; if (shouldSendSyncMessage) { // Set the sync message destination to the primary device, this way it will show that we sent a message to the primary device and not a secondary device - String primaryDevice = PromiseUtil.get(LokiStorageAPI.shared.getPrimaryDevicePublicKey(address.getNumber()), null); + String primaryDevice = PromiseUtil.get(LokiFileServerAPI.shared.getPrimaryDevicePublicKey(address.getNumber()), null); SignalServiceAddress primaryAddress = primaryDevice == null ? address : new SignalServiceAddress(primaryDevice); // We also need to use the original message id and not -1 syncMessage = new LokiSyncMessage(primaryAddress, templateMessageId); diff --git a/src/org/thoughtcrime/securesms/loki/MultiDeviceUtilities.kt b/src/org/thoughtcrime/securesms/loki/MultiDeviceUtilities.kt index 125fcdd226..ebdcff428e 100644 --- a/src/org/thoughtcrime/securesms/loki/MultiDeviceUtilities.kt +++ b/src/org/thoughtcrime/securesms/loki/MultiDeviceUtilities.kt @@ -20,7 +20,7 @@ import org.thoughtcrime.securesms.sms.MessageSender import org.thoughtcrime.securesms.util.TextSecurePreferences import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage import org.whispersystems.signalservice.api.push.SignalServiceAddress -import org.whispersystems.signalservice.loki.api.LokiStorageAPI +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI import org.whispersystems.signalservice.loki.api.PairingAuthorisation import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus import org.whispersystems.signalservice.loki.utilities.recover @@ -32,12 +32,12 @@ fun checkForRevocation(context: Context) { val primaryDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context) ?: return val ourDevice = TextSecurePreferences.getLocalNumber(context) - LokiStorageAPI.shared.fetchDeviceMappings(primaryDevice).bind { mappings -> + LokiFileServerAPI.shared.fetchDeviceMappings(primaryDevice).bind { mappings -> val ourMapping = mappings.find { it.secondaryDevicePublicKey == ourDevice } if (ourMapping != null) throw Error("Device has not been revoked") // remove pairing authorisations for our device DatabaseFactory.getLokiAPIDatabase(context).removePairingAuthorisations(ourDevice) - LokiStorageAPI.shared.updateUserDeviceMappings() + LokiFileServerAPI.shared.updateUserDeviceMappings() }.successUi { TextSecurePreferences.setNeedsRevocationCheck(context, false) ApplicationContext.getInstance(context).clearData() @@ -49,7 +49,7 @@ fun checkForRevocation(context: Context) { fun getAllDeviceFriendRequestStatuses(context: Context, hexEncodedPublicKey: String): Promise, Exception> { val lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context) - return LokiStorageAPI.shared.getAllDevicePublicKeys(hexEncodedPublicKey).map { keys -> + return LokiFileServerAPI.shared.getAllDevicePublicKeys(hexEncodedPublicKey).map { keys -> val map = mutableMapOf() for (devicePublicKey in keys) { val device = Recipient.from(context, Address.fromSerialized(devicePublicKey), false) @@ -63,7 +63,7 @@ fun getAllDeviceFriendRequestStatuses(context: Context, hexEncodedPublicKey: Str fun getAllDevicePublicKeysWithFriendStatus(context: Context, hexEncodedPublicKey: String): Promise, Unit> { val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context) - return LokiStorageAPI.shared.getAllDevicePublicKeys(hexEncodedPublicKey).map { keys -> + return LokiFileServerAPI.shared.getAllDevicePublicKeys(hexEncodedPublicKey).map { keys -> val devices = keys.toMutableSet() if (hexEncodedPublicKey != userHexEncodedPublicKey) { devices.remove(userHexEncodedPublicKey) @@ -92,7 +92,7 @@ fun shouldAutomaticallyBecomeFriendsWithDevice(publicKey: String, context: Conte return Promise.of(true) } - return LokiStorageAPI.shared.getPrimaryDevicePublicKey(publicKey).bind { primaryDevicePublicKey -> + return LokiFileServerAPI.shared.getPrimaryDevicePublicKey(publicKey).bind { primaryDevicePublicKey -> // If the public key doesn't have any other devices then go through regular friend request logic if (primaryDevicePublicKey == null) { return@bind Promise.of(false) @@ -157,7 +157,7 @@ fun signAndSendPairingAuthorisationMessage(context: Context, pairingAuthorisatio Log.d("Loki", "Failed to send pairing authorization message to ${address.serialize()}.") } - val updatePromise = LokiStorageAPI.shared.updateUserDeviceMappings().fail { + val updatePromise = LokiFileServerAPI.shared.updateUserDeviceMappings().fail { Log.d("Loki", "Failed to update device mapping") } @@ -177,7 +177,7 @@ fun isOneOfOurDevices(context: Context, address: Address): Promise + return LokiFileServerAPI.shared.getAllDevicePublicKeys(ourPublicKey).map { devices -> devices.contains(address.serialize()) } } diff --git a/src/org/thoughtcrime/securesms/loki/redesign/activities/LinkedDevicesActivity.kt b/src/org/thoughtcrime/securesms/loki/redesign/activities/LinkedDevicesActivity.kt index ba659cfa21..5cc7a152ed 100644 --- a/src/org/thoughtcrime/securesms/loki/redesign/activities/LinkedDevicesActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/redesign/activities/LinkedDevicesActivity.kt @@ -20,7 +20,7 @@ import org.thoughtcrime.securesms.loki.signAndSendPairingAuthorisationMessage import org.thoughtcrime.securesms.sms.MessageSender import org.thoughtcrime.securesms.util.TextSecurePreferences import org.thoughtcrime.securesms.util.Util -import org.whispersystems.signalservice.loki.api.LokiStorageAPI +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI import org.whispersystems.signalservice.loki.api.PairingAuthorisation class LinkedDevicesActivity : PassphraseRequiredActionBarActivity, LoaderManager.LoaderCallbacks>, DeviceClickListener, EditDeviceNameDialogDelegate, LinkDeviceMasterModeDialogDelegate { @@ -119,7 +119,7 @@ class LinkedDevicesActivity : PassphraseRequiredActionBarActivity, LoaderManager val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this) val database = DatabaseFactory.getLokiAPIDatabase(this) database.removePairingAuthorisation(userHexEncodedPublicKey, slaveDeviceHexEncodedPublicKey) - LokiStorageAPI.shared.updateUserDeviceMappings().success { + LokiFileServerAPI.shared.updateUserDeviceMappings().success { MessageSender.sendUnpairRequest(this, slaveDeviceHexEncodedPublicKey) } LoaderManager.getInstance(this).restartLoader(0, null, this) diff --git a/src/org/thoughtcrime/securesms/loki/redesign/activities/LinkedDevicesLoader.kt b/src/org/thoughtcrime/securesms/loki/redesign/activities/LinkedDevicesLoader.kt index 324dd6362f..a2519801d5 100644 --- a/src/org/thoughtcrime/securesms/loki/redesign/activities/LinkedDevicesLoader.kt +++ b/src/org/thoughtcrime/securesms/loki/redesign/activities/LinkedDevicesLoader.kt @@ -6,7 +6,7 @@ import org.thoughtcrime.securesms.devicelist.Device import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities import org.thoughtcrime.securesms.util.AsyncLoader import org.thoughtcrime.securesms.util.TextSecurePreferences -import org.whispersystems.signalservice.loki.api.LokiStorageAPI +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI import org.whispersystems.signalservice.loki.crypto.MnemonicCodec import java.io.File @@ -20,7 +20,7 @@ class LinkedDevicesLoader(context: Context) : AsyncLoader>(context) override fun loadInBackground(): List? { try { val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context) - val slaveDeviceHexEncodedPublicKeys = LokiStorageAPI.shared.getSecondaryDevicePublicKeys(userHexEncodedPublicKey).get() + val slaveDeviceHexEncodedPublicKeys = LokiFileServerAPI.shared.getSecondaryDevicePublicKeys(userHexEncodedPublicKey).get() return slaveDeviceHexEncodedPublicKeys.map { hexEncodedPublicKey -> val shortID = MnemonicUtilities.getFirst3Words(mnemonicCodec, hexEncodedPublicKey) val name = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(hexEncodedPublicKey) diff --git a/src/org/thoughtcrime/securesms/loki/redesign/activities/SettingsActivity.kt b/src/org/thoughtcrime/securesms/loki/redesign/activities/SettingsActivity.kt index e26846e074..79134bb621 100644 --- a/src/org/thoughtcrime/securesms/loki/redesign/activities/SettingsActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/redesign/activities/SettingsActivity.kt @@ -41,7 +41,7 @@ import org.thoughtcrime.securesms.util.BitmapUtil import org.thoughtcrime.securesms.util.TextSecurePreferences import org.whispersystems.signalservice.api.crypto.ProfileCipher import org.whispersystems.signalservice.api.util.StreamDetails -import org.whispersystems.signalservice.loki.api.LokiStorageAPI +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI import java.io.ByteArrayInputStream import java.io.File import java.security.SecureRandom @@ -159,7 +159,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { val encodedProfileKey = ProfileKeyUtil.generateEncodedProfileKey(this) val profileKey = ProfileKeyUtil.getProfileKeyFromEncodedString(encodedProfileKey) if (isUpdatingProfilePicture && profilePicture != null) { - val storageAPI = LokiStorageAPI.shared + val storageAPI = LokiFileServerAPI.shared val deferred = deferred() AsyncTask.execute { val stream = StreamDetails(ByteArrayInputStream(profilePicture), "image/jpeg", profilePicture.size.toLong()) diff --git a/src/org/thoughtcrime/securesms/loki/redesign/messaging/LokiPublicChatPoller.kt b/src/org/thoughtcrime/securesms/loki/redesign/messaging/LokiPublicChatPoller.kt index 1a600e4293..fd618562c6 100644 --- a/src/org/thoughtcrime/securesms/loki/redesign/messaging/LokiPublicChatPoller.kt +++ b/src/org/thoughtcrime/securesms/loki/redesign/messaging/LokiPublicChatPoller.kt @@ -24,7 +24,7 @@ import org.whispersystems.signalservice.api.push.SignalServiceAddress import org.whispersystems.signalservice.loki.api.LokiPublicChat import org.whispersystems.signalservice.loki.api.LokiPublicChatAPI import org.whispersystems.signalservice.loki.api.LokiPublicChatMessage -import org.whispersystems.signalservice.loki.api.LokiStorageAPI +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus import org.whispersystems.signalservice.loki.utilities.successBackground import java.security.MessageDigest @@ -156,7 +156,7 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki fun pollForNewMessages() { fun processIncomingMessage(message: LokiPublicChatMessage) { // If the sender of the current message is not a secondary device, we need to set the display name in the database - val primaryDevice = LokiStorageAPI.shared.getPrimaryDevicePublicKey(message.hexEncodedPublicKey).get() + val primaryDevice = LokiFileServerAPI.shared.getPrimaryDevicePublicKey(message.hexEncodedPublicKey).get() if (primaryDevice == null) { val senderDisplayName = "${message.displayName} (...${message.hexEncodedPublicKey.takeLast(8)})" DatabaseFactory.getLokiUserDatabase(context).setServerDisplayName(group.id, message.hexEncodedPublicKey, senderDisplayName) @@ -219,17 +219,17 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki var uniqueDevices = setOf() val userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(context).privateKey.serialize() val database = DatabaseFactory.getLokiAPIDatabase(context) - LokiStorageAPI.configure(false, userHexEncodedPublicKey, userPrivateKey, database) - LokiStorageAPI.shared.getAllDevicePublicKeys(userHexEncodedPublicKey).bind { devices -> + LokiFileServerAPI.configure(false, userHexEncodedPublicKey, userPrivateKey, database) + LokiFileServerAPI.shared.getAllDevicePublicKeys(userHexEncodedPublicKey).bind { devices -> userDevices = devices api.getMessages(group.channel, group.server) }.bind { messages -> if (messages.isNotEmpty()) { // We need to fetch device mappings for all the devices we don't have uniqueDevices = messages.map { it.hexEncodedPublicKey }.toSet() - val devicesToUpdate = uniqueDevices.filter { !userDevices.contains(it) && LokiStorageAPI.shared.hasCacheExpired(it) } + val devicesToUpdate = uniqueDevices.filter { !userDevices.contains(it) && LokiFileServerAPI.shared.hasCacheExpired(it) } if (devicesToUpdate.isNotEmpty()) { - return@bind LokiStorageAPI.shared.getDeviceMappings(devicesToUpdate.toSet()).then { messages } + return@bind LokiFileServerAPI.shared.getDeviceMappings(devicesToUpdate.toSet()).then { messages } } } Promise.of(messages) @@ -238,7 +238,7 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki val newDisplayNameUpdatees = uniqueDevices.mapNotNull { // This will return null if current device is primary // So if it's non-null then we know the device is a secondary device - val primaryDevice = LokiStorageAPI.shared.getPrimaryDevicePublicKey(it).get() + val primaryDevice = LokiFileServerAPI.shared.getPrimaryDevicePublicKey(it).get() primaryDevice }.toSet() // Fetch the display names of the primary devices diff --git a/src/org/thoughtcrime/securesms/loki/redesign/messaging/LokiRSSFeedPoller.kt b/src/org/thoughtcrime/securesms/loki/redesign/messaging/LokiRSSFeedPoller.kt index d7a6c3398b..b45ce47ade 100644 --- a/src/org/thoughtcrime/securesms/loki/redesign/messaging/LokiRSSFeedPoller.kt +++ b/src/org/thoughtcrime/securesms/loki/redesign/messaging/LokiRSSFeedPoller.kt @@ -14,7 +14,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage import org.whispersystems.signalservice.api.messages.SignalServiceGroup import org.whispersystems.signalservice.api.push.SignalServiceAddress import org.whispersystems.signalservice.loki.api.LokiRSSFeed -import org.whispersystems.signalservice.loki.api.LokiRSSProxy +import org.whispersystems.signalservice.loki.api.LokiRSSFeedProxy import org.whispersystems.signalservice.loki.utilities.successBackground import java.text.SimpleDateFormat import java.util.regex.Pattern @@ -48,7 +48,7 @@ class LokiRSSFeedPoller(private val context: Context, private val feed: LokiRSSF } private fun poll() { - LokiRSSProxy.fetch(feed.url).successBackground { xml -> + LokiRSSFeedProxy.fetch(feed.url).successBackground { xml -> val items = XMLParser(xml).call() items.reversed().forEach { item -> val title = item.title ?: return@forEach diff --git a/src/org/thoughtcrime/securesms/notifications/MarkReadReceiver.java b/src/org/thoughtcrime/securesms/notifications/MarkReadReceiver.java index f92ff642f0..ed82b436a0 100644 --- a/src/org/thoughtcrime/securesms/notifications/MarkReadReceiver.java +++ b/src/org/thoughtcrime/securesms/notifications/MarkReadReceiver.java @@ -23,7 +23,7 @@ import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.loki.MultiDeviceUtilities; import org.thoughtcrime.securesms.service.ExpiringMessageManager; import org.thoughtcrime.securesms.util.Util; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import java.util.LinkedList; import java.util.List; diff --git a/src/org/thoughtcrime/securesms/sms/MessageSender.java b/src/org/thoughtcrime/securesms/sms/MessageSender.java index df26a6ec03..4dfa91f4c3 100644 --- a/src/org/thoughtcrime/securesms/sms/MessageSender.java +++ b/src/org/thoughtcrime/securesms/sms/MessageSender.java @@ -60,7 +60,7 @@ import org.thoughtcrime.securesms.util.Util; import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.signalservice.api.SignalServiceAccountManager; import org.whispersystems.signalservice.api.push.ContactTokenDetails; -import org.whispersystems.signalservice.loki.api.LokiStorageAPI; +import org.whispersystems.signalservice.loki.api.LokiFileServerAPI; import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus; import org.whispersystems.signalservice.loki.utilities.PromiseUtil; @@ -99,7 +99,7 @@ public class MessageSender { sendBackgroundMessage(context, contactHexEncodedPublicKey); // Go through the other devices and only send background messages if we're friends or we have received friend request - LokiStorageAPI.shared.getAllDevicePublicKeys(contactHexEncodedPublicKey).success(devices -> { + LokiFileServerAPI.shared.getAllDevicePublicKeys(contactHexEncodedPublicKey).success(devices -> { Util.runOnMain(() -> { for (String device : devices) { // Don't send message to the device we already have sent to @@ -234,7 +234,7 @@ public class MessageSender { final int ttl) { String ourPublicKey = TextSecurePreferences.getLocalNumber(context); JobManager jobManager = ApplicationContext.getInstance(context).getJobManager(); - LokiStorageAPI.shared.getAllDevicePublicKeys(ourPublicKey).success(devices -> { + LokiFileServerAPI.shared.getAllDevicePublicKeys(ourPublicKey).success(devices -> { Util.runOnMain(() -> { for (String device : devices) { // Don't send to ourselves