diff --git a/src/org/thoughtcrime/securesms/ApplicationContext.java b/src/org/thoughtcrime/securesms/ApplicationContext.java index e1a079f16a..ae30fce7b2 100644 --- a/src/org/thoughtcrime/securesms/ApplicationContext.java +++ b/src/org/thoughtcrime/securesms/ApplicationContext.java @@ -109,11 +109,11 @@ import org.whispersystems.signalservice.loki.database.LokiAPIDatabaseProtocol; import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager; import org.whispersystems.signalservice.loki.protocol.meta.SessionMetaProtocol; import org.whispersystems.signalservice.loki.protocol.meta.TTLUtilities; -import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink; -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol; +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.DeviceLink; +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol; import org.whispersystems.signalservice.loki.protocol.sessionmanagement.SessionManagementProtocol; import org.whispersystems.signalservice.loki.protocol.sessionmanagement.SessionManagementProtocolDelegate; -import org.whispersystems.signalservice.loki.protocol.syncmessages.SyncMessagesProtocol; +import org.whispersystems.signalservice.loki.protocol.shelved.syncmessages.SyncMessagesProtocol; import java.io.File; import java.io.FileInputStream; @@ -570,6 +570,10 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc } public void clearData() { + String token = TextSecurePreferences.getFCMToken(this); + if (token != null && !token.isEmpty()) { + LokiPushNotificationManager.unregister(token, this); + } boolean wasUnlinked = TextSecurePreferences.getWasUnlinked(this); TextSecurePreferences.clearAll(this); TextSecurePreferences.setWasUnlinked(this, wasUnlinked); diff --git a/src/org/thoughtcrime/securesms/components/TypingStatusSender.java b/src/org/thoughtcrime/securesms/components/TypingStatusSender.java index 5c1ee0e273..0804d598a5 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.protocol.SessionMetaProtocol; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.util.Util; -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol; +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol; import java.util.HashMap; import java.util.Map; diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index f4e2ff2a51..d2a0122edf 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -226,7 +226,7 @@ import org.whispersystems.signalservice.loki.api.opengroups.PublicChat; import org.whispersystems.signalservice.loki.protocol.mentions.Mention; import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager; import org.whispersystems.signalservice.loki.protocol.meta.SessionMetaProtocol; -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol; +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol; import org.whispersystems.signalservice.loki.utilities.PublicKeyValidation; import java.io.IOException; diff --git a/src/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java b/src/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java index 596d4f84f0..24bf81d97a 100644 --- a/src/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java +++ b/src/org/thoughtcrime/securesms/database/loaders/DeviceListLoader.java @@ -12,7 +12,7 @@ import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities; import org.thoughtcrime.securesms.util.AsyncLoader; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.whispersystems.signalservice.loki.crypto.MnemonicCodec; -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol; +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol; import java.io.File; import java.util.Collections; diff --git a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java index 6ccb3279d9..849cc67a32 100644 --- a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java +++ b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java @@ -20,7 +20,6 @@ import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.loki.protocol.ClosedGroupsProtocol; import org.thoughtcrime.securesms.mms.MmsException; import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage; -import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.sms.IncomingGroupMessage; import org.thoughtcrime.securesms.sms.IncomingTextMessage; @@ -33,7 +32,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceContent; 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.loki.protocol.multidevice.MultiDeviceProtocol; +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol; import java.util.Collections; import java.util.HashSet; diff --git a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index 770c9d0ea9..6183467232 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -1356,14 +1356,14 @@ public class PushDecryptJob extends BaseJob implements InjectableType { } else { String publicKey = message.getDestination().get(); String userPublicKey = TextSecurePreferences.getLocalNumber(context); - Set allUserDevices = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey); + Set allUserDevices = org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey); if (allUserDevices.contains(publicKey)) { return Recipient.from(context, Address.fromSerialized(userPublicKey), false); } else { try { // TODO: Burn this with fire when we can PromiseUtilities.timeout(FileServerAPI.shared.getDeviceLinks(publicKey, false), 6000).get(); - String masterPublicKey = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getMasterDevice(publicKey); + String masterPublicKey = org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol.shared.getMasterDevice(publicKey); if (masterPublicKey == null) { masterPublicKey = publicKey; } @@ -1388,14 +1388,14 @@ public class PushDecryptJob extends BaseJob implements InjectableType { return Recipient.from(context, Address.fromSerialized(publicKey), false); } else { String userPublicKey = TextSecurePreferences.getLocalNumber(context); - Set allUserDevices = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey); + Set allUserDevices = org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey); if (allUserDevices.contains(publicKey)) { return Recipient.from(context, Address.fromSerialized(userPublicKey), false); } else { try { // TODO: Burn this with fire when we can PromiseUtilities.timeout(FileServerAPI.shared.getDeviceLinks(publicKey, false), 6000).get(); - String masterPublicKey = org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.shared.getMasterDevice(publicKey); + String masterPublicKey = org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol.shared.getMasterDevice(publicKey); if (masterPublicKey == null) { masterPublicKey = publicKey; } diff --git a/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt index a25a604766..e67aee1aae 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt @@ -47,9 +47,9 @@ import org.thoughtcrime.securesms.util.Util import org.whispersystems.signalservice.loki.api.fileserver.FileServerAPI import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager import org.whispersystems.signalservice.loki.protocol.meta.SessionMetaProtocol -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol import org.whispersystems.signalservice.loki.protocol.sessionmanagement.SessionManagementProtocol -import org.whispersystems.signalservice.loki.protocol.syncmessages.SyncMessagesProtocol +import org.whispersystems.signalservice.loki.protocol.shelved.syncmessages.SyncMessagesProtocol class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListener, SeedReminderViewDelegate, NewConversationButtonSetViewDelegate { private lateinit var glide: GlideRequests @@ -182,6 +182,10 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe } this.broadcastReceiver = broadcastReceiver LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter("blockedContactsChanged")) + // Clear all data if this is a secondary device + if (TextSecurePreferences.getMasterHexEncodedPublicKey(this) != null) { + ApplicationContext.getInstance(this).clearData() + } } override fun onResume() { diff --git a/src/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt index 94d224c220..8cd45d95f0 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/LandingActivity.kt @@ -29,9 +29,9 @@ import org.whispersystems.libsignal.ecc.ECKeyPair import org.whispersystems.libsignal.util.KeyHelper import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager import org.whispersystems.signalservice.loki.protocol.meta.SessionMetaProtocol -import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.DeviceLink import org.whispersystems.signalservice.loki.protocol.sessionmanagement.SessionManagementProtocol -import org.whispersystems.signalservice.loki.protocol.syncmessages.SyncMessagesProtocol +import org.whispersystems.signalservice.loki.protocol.shelved.syncmessages.SyncMessagesProtocol import org.whispersystems.signalservice.loki.utilities.hexEncodedPublicKey import org.whispersystems.signalservice.loki.utilities.retryIfNeeded @@ -112,7 +112,7 @@ class LandingActivity : BaseActionBarActivity(), LinkDeviceSlaveModeDialogDelega val sessionResetImpl = SessionResetImplementation(this) MentionsManager.configureIfNeeded(userPublicKey, threadDB, userDB) SessionMetaProtocol.configureIfNeeded(apiDB, userPublicKey) - org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.configureIfNeeded(apiDB) + org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol.configureIfNeeded(apiDB) SessionManagementProtocol.configureIfNeeded(sessionResetImpl, threadDB, application) SyncMessagesProtocol.configureIfNeeded(apiDB, userPublicKey) application.setUpP2PAPIIfNeeded() diff --git a/src/org/thoughtcrime/securesms/loki/activities/LinkedDevicesLoader.kt b/src/org/thoughtcrime/securesms/loki/activities/LinkedDevicesLoader.kt index 14f6573e4c..785566b2d7 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/LinkedDevicesLoader.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/LinkedDevicesLoader.kt @@ -7,7 +7,7 @@ import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities import org.thoughtcrime.securesms.util.AsyncLoader import org.thoughtcrime.securesms.util.TextSecurePreferences import org.whispersystems.signalservice.loki.crypto.MnemonicCodec -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol import java.io.File class LinkedDevicesLoader(context: Context) : AsyncLoader>(context) { diff --git a/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt b/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt index 576f2514b9..7aaf2322f7 100644 --- a/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt +++ b/src/org/thoughtcrime/securesms/loki/api/PublicChatPoller.kt @@ -27,7 +27,7 @@ import org.whispersystems.signalservice.loki.api.fileserver.FileServerAPI import org.whispersystems.signalservice.loki.api.opengroups.PublicChat import org.whispersystems.signalservice.loki.api.opengroups.PublicChatAPI import org.whispersystems.signalservice.loki.api.opengroups.PublicChatMessage -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol import java.security.MessageDigest import java.util.* @@ -159,12 +159,12 @@ class PublicChatPoller(private val context: Context, private val group: PublicCh fun pollForNewMessages() { fun processIncomingMessage(message: PublicChatMessage) { // If the sender of the current message is not a slave device, set the display name in the database - val masterHexEncodedPublicKey = MultiDeviceProtocol.shared.getMasterDevice(message.publicKey) + val masterHexEncodedPublicKey = MultiDeviceProtocol.shared.getMasterDevice(message.senderPublicKey) if (masterHexEncodedPublicKey == null) { - val senderDisplayName = "${message.displayName} (...${message.publicKey.takeLast(8)})" - DatabaseFactory.getLokiUserDatabase(context).setServerDisplayName(group.id, message.publicKey, senderDisplayName) + val senderDisplayName = "${message.displayName} (...${message.senderPublicKey.takeLast(8)})" + DatabaseFactory.getLokiUserDatabase(context).setServerDisplayName(group.id, message.senderPublicKey, senderDisplayName) } - val senderHexEncodedPublicKey = masterHexEncodedPublicKey ?: message.publicKey + val senderHexEncodedPublicKey = masterHexEncodedPublicKey ?: message.senderPublicKey val serviceDataMessage = getDataMessage(message) val serviceContent = SignalServiceContent(serviceDataMessage, senderHexEncodedPublicKey, SignalServiceAddress.DEFAULT_DEVICE_ID, message.timestamp, false, false) if (serviceDataMessage.quote.isPresent || (serviceDataMessage.attachments.isPresent && serviceDataMessage.attachments.get().size > 0) || serviceDataMessage.previews.isPresent) { @@ -200,7 +200,7 @@ class PublicChatPoller(private val context: Context, private val group: PublicCh PushDecryptJob(context).handleSynchronizeSentTextMessage(transcript) } // If we got a message from our master device then make sure our mapping stays in sync - val recipient = Recipient.from(context, Address.fromSerialized(message.publicKey), false) + val recipient = Recipient.from(context, Address.fromSerialized(message.senderPublicKey), false) if (recipient.isUserMasterDevice && message.profilePicture != null) { val profileKey = message.profilePicture!!.profileKey val url = message.profilePicture!!.url @@ -219,26 +219,30 @@ class PublicChatPoller(private val context: Context, private val group: PublicCh FileServerAPI.configure(userHexEncodedPublicKey, userPrivateKey, apiDB) // Kovenant propagates a context to chained promises, so LokiPublicChatAPI.sharedContext should be used for all of the below api.getMessages(group.channel, group.server).bind(PublicChatAPI.sharedContext) { messages -> + /* if (messages.isNotEmpty()) { // We need to fetch the device mapping for any devices we don't have - uniqueDevices = messages.map { it.publicKey }.toSet() + uniqueDevices = messages.map { it.senderPublicKey }.toSet() val devicesToUpdate = uniqueDevices.filter { !userDevices.contains(it) && FileServerAPI.shared.hasDeviceLinkCacheExpired(publicKey = it) } if (devicesToUpdate.isNotEmpty()) { return@bind FileServerAPI.shared.getDeviceLinks(devicesToUpdate.toSet()).then { messages } } } + */ Promise.of(messages) }.successBackground { + /* val newDisplayNameUpdatees = uniqueDevices.mapNotNull { // This will return null if the current device is a master device MultiDeviceProtocol.shared.getMasterDevice(it) }.toSet() // Fetch the display names of the master devices displayNameUpdatees = displayNameUpdatees.union(newDisplayNameUpdatees) + */ }.successBackground { messages -> // Process messages in the background messages.forEach { message -> - if (userDevices.contains(message.publicKey)) { + if (userDevices.contains(message.senderPublicKey)) { processOutgoingMessage(message) } else { processIncomingMessage(message) diff --git a/src/org/thoughtcrime/securesms/loki/database/LokiAPIDatabase.kt b/src/org/thoughtcrime/securesms/loki/database/LokiAPIDatabase.kt index ed52a1d9ef..fefcfcc211 100644 --- a/src/org/thoughtcrime/securesms/loki/database/LokiAPIDatabase.kt +++ b/src/org/thoughtcrime/securesms/loki/database/LokiAPIDatabase.kt @@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.util.Base64 import org.thoughtcrime.securesms.util.TextSecurePreferences import org.whispersystems.signalservice.loki.api.Snode import org.whispersystems.signalservice.loki.database.LokiAPIDatabaseProtocol -import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.DeviceLink class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiAPIDatabaseProtocol { @@ -292,6 +292,8 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database( } override fun getDeviceLinks(publicKey: String): Set { + return setOf() + /* val database = databaseHelper.readableDatabase return database.getAll(deviceLinkCache, "$masterPublicKey = ? OR $slavePublicKey = ?", arrayOf( publicKey, publicKey )) { cursor -> val masterHexEncodedPublicKey = cursor.getString(masterPublicKey) @@ -300,14 +302,18 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database( val authorizationSignature: ByteArray? = if (cursor.isNull(cursor.getColumnIndexOrThrow(authorizationSignature))) null else cursor.getBase64EncodedData(authorizationSignature) DeviceLink(masterHexEncodedPublicKey, slaveHexEncodedPublicKey, requestSignature, authorizationSignature) }.toSet() + */ } override fun clearDeviceLinks(publicKey: String) { + /* val database = databaseHelper.writableDatabase database.delete(deviceLinkCache, "$masterPublicKey = ? OR $slavePublicKey = ?", arrayOf( publicKey, publicKey )) + */ } override fun addDeviceLink(deviceLink: DeviceLink) { + /* val database = databaseHelper.writableDatabase val values = ContentValues() values.put(masterPublicKey, deviceLink.masterPublicKey) @@ -315,11 +321,14 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database( if (deviceLink.requestSignature != null) { values.put(requestSignature, Base64.encodeBytes(deviceLink.requestSignature)) } if (deviceLink.authorizationSignature != null) { values.put(authorizationSignature, Base64.encodeBytes(deviceLink.authorizationSignature)) } database.insertOrUpdate(deviceLinkCache, values, "$masterPublicKey = ? AND $slavePublicKey = ?", arrayOf( deviceLink.masterPublicKey, deviceLink.slavePublicKey )) + */ } override fun removeDeviceLink(deviceLink: DeviceLink) { + /* val database = databaseHelper.writableDatabase database.delete(deviceLinkCache, "$masterPublicKey = ? OR $slavePublicKey = ?", arrayOf( deviceLink.masterPublicKey, deviceLink.slavePublicKey )) + */ } fun getUserCount(group: Long, server: String): Int? { diff --git a/src/org/thoughtcrime/securesms/loki/dialogs/LinkDeviceMasterModeDialog.kt b/src/org/thoughtcrime/securesms/loki/dialogs/LinkDeviceMasterModeDialog.kt index dc40272543..fbb476e527 100644 --- a/src/org/thoughtcrime/securesms/loki/dialogs/LinkDeviceMasterModeDialog.kt +++ b/src/org/thoughtcrime/securesms/loki/dialogs/LinkDeviceMasterModeDialog.kt @@ -24,9 +24,9 @@ import org.thoughtcrime.securesms.util.Util import org.whispersystems.signalservice.loki.api.SnodeAPI import org.whispersystems.signalservice.loki.api.fileserver.FileServerAPI import org.whispersystems.signalservice.loki.crypto.MnemonicCodec -import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink -import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLinkingSession -import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLinkingSessionListener +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.DeviceLink +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.DeviceLinkingSession +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.DeviceLinkingSessionListener class LinkDeviceMasterModeDialog : DialogFragment(), DeviceLinkingSessionListener { private val languageFileDirectory by lazy { MnemonicUtilities.getLanguageFileDirectory(context!!) } diff --git a/src/org/thoughtcrime/securesms/loki/dialogs/LinkDeviceSlaveModeDialog.kt b/src/org/thoughtcrime/securesms/loki/dialogs/LinkDeviceSlaveModeDialog.kt index 6f99502ccc..b87530bfa0 100644 --- a/src/org/thoughtcrime/securesms/loki/dialogs/LinkDeviceSlaveModeDialog.kt +++ b/src/org/thoughtcrime/securesms/loki/dialogs/LinkDeviceSlaveModeDialog.kt @@ -16,9 +16,9 @@ import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities import org.thoughtcrime.securesms.util.TextSecurePreferences import org.thoughtcrime.securesms.util.Util import org.whispersystems.signalservice.loki.crypto.MnemonicCodec -import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink -import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLinkingSession -import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLinkingSessionListener +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.DeviceLink +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.DeviceLinkingSession +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.DeviceLinkingSessionListener class LinkDeviceSlaveModeDialog : DialogFragment(), DeviceLinkingSessionListener { private val languageFileDirectory by lazy { MnemonicUtilities.getLanguageFileDirectory(context!!) } diff --git a/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt b/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt index cbcbfb3b71..8bcff5516d 100644 --- a/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt +++ b/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt @@ -19,7 +19,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceGroup import org.whispersystems.signalservice.api.push.SignalServiceAddress import org.whispersystems.signalservice.loki.api.SnodeAPI import org.whispersystems.signalservice.loki.api.fileserver.FileServerAPI -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol import java.util.* object ClosedGroupsProtocol { diff --git a/src/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt b/src/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt index 771e6821b1..4d37ab1e58 100644 --- a/src/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt +++ b/src/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt @@ -20,9 +20,9 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage import org.whispersystems.signalservice.api.push.SignalServiceAddress import org.whispersystems.signalservice.loki.api.fileserver.FileServerAPI import org.whispersystems.signalservice.loki.protocol.meta.SessionMetaProtocol -import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink -import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLinkingSession -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.DeviceLink +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.DeviceLinkingSession +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol import org.whispersystems.signalservice.loki.utilities.retryIfNeeded object MultiDeviceProtocol { diff --git a/src/org/thoughtcrime/securesms/loki/protocol/SessionManagementProtocol.kt b/src/org/thoughtcrime/securesms/loki/protocol/SessionManagementProtocol.kt index c442e060a7..4bd08e275f 100644 --- a/src/org/thoughtcrime/securesms/loki/protocol/SessionManagementProtocol.kt +++ b/src/org/thoughtcrime/securesms/loki/protocol/SessionManagementProtocol.kt @@ -17,7 +17,7 @@ import org.thoughtcrime.securesms.sms.OutgoingTextMessage import org.thoughtcrime.securesms.util.TextSecurePreferences import org.whispersystems.libsignal.loki.SessionResetStatus import org.whispersystems.signalservice.api.messages.SignalServiceContent -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol import java.util.* object SessionManagementProtocol { diff --git a/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt b/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt index 112a39ef94..c0dc77f4b1 100644 --- a/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt +++ b/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt @@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.recipients.Recipient import org.thoughtcrime.securesms.util.TextSecurePreferences import org.whispersystems.signalservice.api.messages.SignalServiceContent import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol import java.security.MessageDigest object SessionMetaProtocol { diff --git a/src/org/thoughtcrime/securesms/loki/protocol/SyncMessagesProtocol.kt b/src/org/thoughtcrime/securesms/loki/protocol/SyncMessagesProtocol.kt index 78eb90486d..5ec37a41dd 100644 --- a/src/org/thoughtcrime/securesms/loki/protocol/SyncMessagesProtocol.kt +++ b/src/org/thoughtcrime/securesms/loki/protocol/SyncMessagesProtocol.kt @@ -26,7 +26,7 @@ import org.whispersystems.signalservice.api.messages.multidevice.ContactsMessage import org.whispersystems.signalservice.api.messages.multidevice.DeviceContactsInputStream import org.whispersystems.signalservice.api.messages.multidevice.DeviceGroupsInputStream import org.whispersystems.signalservice.loki.api.opengroups.PublicChat -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol import org.whispersystems.signalservice.loki.utilities.PublicKeyValidation import java.util.* @@ -35,7 +35,7 @@ object SyncMessagesProtocol { @JvmStatic fun shouldIgnoreSyncMessage(context: Context, sender: Recipient): Boolean { val userPublicKey = TextSecurePreferences.getLocalNumber(context) - return !MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey).contains(sender.address.serialize()) + return userPublicKey == sender.address.serialize() // return !MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey).contains(sender.address.serialize()) } @JvmStatic diff --git a/src/org/thoughtcrime/securesms/loki/utilities/ContactUtilities.kt b/src/org/thoughtcrime/securesms/loki/utilities/ContactUtilities.kt index 67e4f3475b..4bc9db0e3a 100644 --- a/src/org/thoughtcrime/securesms/loki/utilities/ContactUtilities.kt +++ b/src/org/thoughtcrime/securesms/loki/utilities/ContactUtilities.kt @@ -4,7 +4,7 @@ import android.content.Context import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.recipients.Recipient import org.thoughtcrime.securesms.util.TextSecurePreferences -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol data class Contact( val recipient: Recipient, diff --git a/src/org/thoughtcrime/securesms/notifications/MarkReadReceiver.java b/src/org/thoughtcrime/securesms/notifications/MarkReadReceiver.java index 9c3cbccfce..942de714c3 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.protocol.SessionMetaProtocol; import org.thoughtcrime.securesms.loki.protocol.SyncMessagesProtocol; import org.thoughtcrime.securesms.service.ExpiringMessageManager; -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol; +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol; import java.util.LinkedList; import java.util.List; diff --git a/src/org/thoughtcrime/securesms/recipients/Recipient.java b/src/org/thoughtcrime/securesms/recipients/Recipient.java index 9b63f56302..ca78ea9e84 100644 --- a/src/org/thoughtcrime/securesms/recipients/Recipient.java +++ b/src/org/thoughtcrime/securesms/recipients/Recipient.java @@ -52,7 +52,7 @@ import org.thoughtcrime.securesms.util.ListenableFutureTask; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.Util; import org.whispersystems.libsignal.util.guava.Optional; -import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol; +import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol; import java.util.Collections; import java.util.HashSet; diff --git a/src/org/thoughtcrime/securesms/sms/MessageSender.java b/src/org/thoughtcrime/securesms/sms/MessageSender.java index c34721c213..9f16df5c7c 100644 --- a/src/org/thoughtcrime/securesms/sms/MessageSender.java +++ b/src/org/thoughtcrime/securesms/sms/MessageSender.java @@ -36,9 +36,10 @@ import org.thoughtcrime.securesms.database.model.SmsMessageRecord; import org.thoughtcrime.securesms.jobmanager.JobManager; import org.thoughtcrime.securesms.jobs.MmsSendJob; import org.thoughtcrime.securesms.jobs.PushGroupSendJob; +import org.thoughtcrime.securesms.jobs.PushMediaSendJob; +import org.thoughtcrime.securesms.jobs.PushTextSendJob; import org.thoughtcrime.securesms.jobs.SmsSendJob; import org.thoughtcrime.securesms.logging.Log; -import org.thoughtcrime.securesms.loki.protocol.MultiDeviceProtocol; import org.thoughtcrime.securesms.mms.MmsException; import org.thoughtcrime.securesms.mms.OutgoingMediaMessage; import org.thoughtcrime.securesms.push.AccountManagerFactory; @@ -151,11 +152,15 @@ public class MessageSender { } private static void sendTextPush(Context context, Recipient recipient, long messageId) { - MultiDeviceProtocol.sendTextPush(context, recipient, messageId); + JobManager jobManager = ApplicationContext.getInstance(context).getJobManager(); + jobManager.add(new PushTextSendJob(messageId, recipient.getAddress())); +// MultiDeviceProtocol.sendTextPush(context, recipient, messageId); } private static void sendMediaPush(Context context, Recipient recipient, long messageId) { - MultiDeviceProtocol.sendMediaPush(context, recipient, messageId); + JobManager jobManager = ApplicationContext.getInstance(context).getJobManager(); + PushMediaSendJob.enqueue(context, jobManager, messageId, recipient.getAddress()); +// MultiDeviceProtocol.sendMediaPush(context, recipient, messageId); } private static void sendGroupPush(Context context, Recipient recipient, long messageId, Address filterAddress) {