mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 16:48:26 +00:00
Clean up ahead of protocol changes
This commit is contained in:
parent
3124a59269
commit
4799c13816
@ -95,14 +95,14 @@ import org.whispersystems.libsignal.logging.SignalProtocolLoggerProvider;
|
|||||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
import org.whispersystems.signalservice.api.util.StreamDetails;
|
import org.whispersystems.signalservice.api.util.StreamDetails;
|
||||||
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
|
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiAPI;
|
import org.whispersystems.signalservice.loki.api.Poller;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiPoller;
|
import org.whispersystems.signalservice.loki.api.PushNotificationAcknowledgement;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiPushNotificationAcknowledgement;
|
import org.whispersystems.signalservice.loki.api.SnodeAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiSwarmAPI;
|
import org.whispersystems.signalservice.loki.api.SwarmAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI;
|
import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.opengroups.LokiPublicChatAPI;
|
import org.whispersystems.signalservice.loki.api.opengroups.LokiPublicChatAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.p2p.LokiP2PAPI;
|
import org.whispersystems.signalservice.loki.api.shelved.p2p.LokiP2PAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.p2p.LokiP2PAPIDelegate;
|
import org.whispersystems.signalservice.loki.api.shelved.p2p.LokiP2PAPIDelegate;
|
||||||
import org.whispersystems.signalservice.loki.database.LokiAPIDatabaseProtocol;
|
import org.whispersystems.signalservice.loki.database.LokiAPIDatabaseProtocol;
|
||||||
import org.whispersystems.signalservice.loki.protocol.friendrequests.FriendRequestProtocol;
|
import org.whispersystems.signalservice.loki.protocol.friendrequests.FriendRequestProtocol;
|
||||||
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager;
|
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager;
|
||||||
@ -151,7 +151,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
|
|
||||||
// Loki
|
// Loki
|
||||||
public MessageNotifier messageNotifier = null;
|
public MessageNotifier messageNotifier = null;
|
||||||
public LokiPoller lokiPoller = null;
|
public Poller lokiPoller = null;
|
||||||
public LokiPublicChatManager lokiPublicChatManager = null;
|
public LokiPublicChatManager lokiPublicChatManager = null;
|
||||||
private LokiPublicChatAPI lokiPublicChatAPI = null;
|
private LokiPublicChatAPI lokiPublicChatAPI = null;
|
||||||
public Broadcaster broadcaster = null;
|
public Broadcaster broadcaster = null;
|
||||||
@ -184,8 +184,8 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
String userPublicKey = TextSecurePreferences.getLocalNumber(this);
|
String userPublicKey = TextSecurePreferences.getLocalNumber(this);
|
||||||
LokiSessionResetImplementation sessionResetImpl = new LokiSessionResetImplementation(this);
|
LokiSessionResetImplementation sessionResetImpl = new LokiSessionResetImplementation(this);
|
||||||
if (userPublicKey != null) {
|
if (userPublicKey != null) {
|
||||||
LokiSwarmAPI.Companion.configureIfNeeded(apiDB);
|
SwarmAPI.Companion.configureIfNeeded(apiDB);
|
||||||
LokiAPI.Companion.configureIfNeeded(userPublicKey, apiDB, broadcaster);
|
SnodeAPI.Companion.configureIfNeeded(userPublicKey, apiDB, broadcaster);
|
||||||
FriendRequestProtocol.Companion.configureIfNeeded(apiDB, userPublicKey);
|
FriendRequestProtocol.Companion.configureIfNeeded(apiDB, userPublicKey);
|
||||||
MentionsManager.Companion.configureIfNeeded(userPublicKey, threadDB, userDB);
|
MentionsManager.Companion.configureIfNeeded(userPublicKey, threadDB, userDB);
|
||||||
SessionMetaProtocol.Companion.configureIfNeeded(apiDB, userPublicKey);
|
SessionMetaProtocol.Companion.configureIfNeeded(apiDB, userPublicKey);
|
||||||
@ -194,7 +194,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
MultiDeviceProtocol.Companion.configureIfNeeded(apiDB);
|
MultiDeviceProtocol.Companion.configureIfNeeded(apiDB);
|
||||||
SessionManagementProtocol.Companion.configureIfNeeded(sessionResetImpl, threadDB, this);
|
SessionManagementProtocol.Companion.configureIfNeeded(sessionResetImpl, threadDB, this);
|
||||||
setUpP2PAPIIfNeeded();
|
setUpP2PAPIIfNeeded();
|
||||||
LokiPushNotificationAcknowledgement.Companion.configureIfNeeded(BuildConfig.DEBUG);
|
PushNotificationAcknowledgement.Companion.configureIfNeeded(BuildConfig.DEBUG);
|
||||||
if (setUpStorageAPIIfNeeded()) {
|
if (setUpStorageAPIIfNeeded()) {
|
||||||
if (userPublicKey != null) {
|
if (userPublicKey != null) {
|
||||||
Set<DeviceLink> deviceLinks = DatabaseFactory.getLokiAPIDatabase(this).getDeviceLinks(userPublicKey);
|
Set<DeviceLink> deviceLinks = DatabaseFactory.getLokiAPIDatabase(this).getDeviceLinks(userPublicKey);
|
||||||
@ -493,15 +493,15 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
String userPublicKey = TextSecurePreferences.getLocalNumber(this);
|
String userPublicKey = TextSecurePreferences.getLocalNumber(this);
|
||||||
if (userPublicKey == null) return;
|
if (userPublicKey == null) return;
|
||||||
if (lokiPoller != null) {
|
if (lokiPoller != null) {
|
||||||
LokiAPI.shared.setUserHexEncodedPublicKey(userPublicKey);
|
SnodeAPI.shared.setUserPublicKey(userPublicKey);
|
||||||
lokiPoller.setUserHexEncodedPublicKey(userPublicKey);
|
lokiPoller.setUserPublicKey(userPublicKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LokiAPIDatabase apiDB = DatabaseFactory.getLokiAPIDatabase(this);
|
LokiAPIDatabase apiDB = DatabaseFactory.getLokiAPIDatabase(this);
|
||||||
Context context = this;
|
Context context = this;
|
||||||
LokiSwarmAPI.Companion.configureIfNeeded(apiDB);
|
SwarmAPI.Companion.configureIfNeeded(apiDB);
|
||||||
LokiAPI.Companion.configureIfNeeded(userPublicKey, apiDB, broadcaster);
|
SnodeAPI.Companion.configureIfNeeded(userPublicKey, apiDB, broadcaster);
|
||||||
lokiPoller = new LokiPoller(userPublicKey, apiDB, protos -> {
|
lokiPoller = new Poller(userPublicKey, apiDB, protos -> {
|
||||||
for (SignalServiceProtos.Envelope proto : protos) {
|
for (SignalServiceProtos.Envelope proto : protos) {
|
||||||
new PushContentReceiveJob(context).processEnvelope(new SignalServiceEnvelope(proto), false);
|
new PushContentReceiveJob(context).processEnvelope(new SignalServiceEnvelope(proto), false);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSy
|
|||||||
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiAPI;
|
import org.whispersystems.signalservice.loki.api.SnodeAPI;
|
||||||
import org.whispersystems.signalservice.loki.protocol.meta.SessionMetaProtocol;
|
import org.whispersystems.signalservice.loki.protocol.meta.SessionMetaProtocol;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -231,7 +231,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
|||||||
database.addMismatchedIdentity(messageId, Address.fromSerialized(uie.getE164Number()), uie.getIdentityKey());
|
database.addMismatchedIdentity(messageId, Address.fromSerialized(uie.getE164Number()), uie.getIdentityKey());
|
||||||
database.markAsSentFailed(messageId);
|
database.markAsSentFailed(messageId);
|
||||||
}
|
}
|
||||||
} catch (LokiAPI.Error e) {
|
} catch (SnodeAPI.Error e) {
|
||||||
Log.d("Loki", "Couldn't send message due to error: " + e.getDescription());
|
Log.d("Loki", "Couldn't send message due to error: " + e.getDescription());
|
||||||
if (messageId >= 0) {
|
if (messageId >= 0) {
|
||||||
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
||||||
@ -257,7 +257,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
|||||||
|
|
||||||
private boolean deliver(OutgoingMediaMessage message)
|
private boolean deliver(OutgoingMediaMessage message)
|
||||||
throws RetryLaterException, InsecureFallbackApprovalException, UntrustedIdentityException,
|
throws RetryLaterException, InsecureFallbackApprovalException, UntrustedIdentityException,
|
||||||
UndeliverableMessageException, LokiAPI.Error
|
UndeliverableMessageException, SnodeAPI.Error
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Recipient recipient = Recipient.from(context, destination, false);
|
Recipient recipient = Recipient.from(context, destination, false);
|
||||||
|
@ -32,7 +32,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
|||||||
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
|
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiAPI;
|
import org.whispersystems.signalservice.loki.api.SnodeAPI;
|
||||||
import org.whispersystems.signalservice.loki.protocol.meta.SessionMetaProtocol;
|
import org.whispersystems.signalservice.loki.protocol.meta.SessionMetaProtocol;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -173,7 +173,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
|||||||
database.markAsSentFailed(record.getId());
|
database.markAsSentFailed(record.getId());
|
||||||
database.markAsPush(record.getId());
|
database.markAsPush(record.getId());
|
||||||
}
|
}
|
||||||
} catch (LokiAPI.Error e) {
|
} catch (SnodeAPI.Error e) {
|
||||||
Log.d("Loki", "Couldn't send message due to error: " + e.getDescription());
|
Log.d("Loki", "Couldn't send message due to error: " + e.getDescription());
|
||||||
if (messageId >= 0) {
|
if (messageId >= 0) {
|
||||||
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
||||||
@ -204,7 +204,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean deliver(SmsMessageRecord message)
|
private boolean deliver(SmsMessageRecord message)
|
||||||
throws UntrustedIdentityException, InsecureFallbackApprovalException, RetryLaterException, LokiAPI.Error
|
throws UntrustedIdentityException, InsecureFallbackApprovalException, RetryLaterException, SnodeAPI.Error
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Recipient recipient = Recipient.from(context, destination, false);
|
Recipient recipient = Recipient.from(context, destination, false);
|
||||||
|
@ -9,7 +9,7 @@ import org.thoughtcrime.securesms.jobs.PushContentReceiveJob
|
|||||||
import org.thoughtcrime.securesms.service.PersistentAlarmManagerListener
|
import org.thoughtcrime.securesms.service.PersistentAlarmManagerListener
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope
|
||||||
import org.whispersystems.signalservice.loki.api.LokiAPI
|
import org.whispersystems.signalservice.loki.api.SnodeAPI
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class BackgroundPollWorker : PersistentAlarmManagerListener() {
|
class BackgroundPollWorker : PersistentAlarmManagerListener() {
|
||||||
@ -35,8 +35,8 @@ class BackgroundPollWorker : PersistentAlarmManagerListener() {
|
|||||||
try {
|
try {
|
||||||
val applicationContext = context.applicationContext as ApplicationContext
|
val applicationContext = context.applicationContext as ApplicationContext
|
||||||
val broadcaster = applicationContext.broadcaster
|
val broadcaster = applicationContext.broadcaster
|
||||||
LokiAPI.configureIfNeeded(userPublicKey, lokiAPIDatabase, broadcaster)
|
SnodeAPI.configureIfNeeded(userPublicKey, lokiAPIDatabase, broadcaster)
|
||||||
LokiAPI.shared.getMessages().map { messages ->
|
SnodeAPI.shared.getMessages().map { messages ->
|
||||||
messages.forEach {
|
messages.forEach {
|
||||||
PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it), false)
|
PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it), false)
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,14 @@ import okhttp3.*
|
|||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.whispersystems.libsignal.logging.Log
|
import org.whispersystems.libsignal.logging.Log
|
||||||
import org.whispersystems.signalservice.internal.util.JsonUtil
|
import org.whispersystems.signalservice.internal.util.JsonUtil
|
||||||
import org.whispersystems.signalservice.loki.api.LokiPushNotificationAcknowledgement
|
import org.whispersystems.signalservice.loki.api.PushNotificationAcknowledgement
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
object LokiPushNotificationManager {
|
object LokiPushNotificationManager {
|
||||||
private val connection = OkHttpClient()
|
private val connection = OkHttpClient()
|
||||||
|
|
||||||
private val server by lazy {
|
private val server by lazy {
|
||||||
LokiPushNotificationAcknowledgement.shared.server
|
PushNotificationAcknowledgement.shared.server
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val tokenExpirationInterval = 12 * 60 * 60 * 1000
|
private const val tokenExpirationInterval = 12 * 60 * 60 * 1000
|
||||||
|
@ -7,7 +7,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences
|
|||||||
import org.whispersystems.libsignal.logging.Log
|
import org.whispersystems.libsignal.logging.Log
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope
|
||||||
import org.whispersystems.signalservice.internal.util.Base64
|
import org.whispersystems.signalservice.internal.util.Base64
|
||||||
import org.whispersystems.signalservice.loki.api.LokiMessageWrapper
|
import org.whispersystems.signalservice.loki.api.MessageWrapper
|
||||||
|
|
||||||
class PushNotificationService : FirebaseMessagingService() {
|
class PushNotificationService : FirebaseMessagingService() {
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ class PushNotificationService : FirebaseMessagingService() {
|
|||||||
val data = base64EncodedData?.let { Base64.decode(it) }
|
val data = base64EncodedData?.let { Base64.decode(it) }
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
try {
|
try {
|
||||||
val envelope = LokiMessageWrapper.unwrap(data)
|
val envelope = MessageWrapper.unwrap(data)
|
||||||
PushContentReceiveJob(this).processEnvelope(SignalServiceEnvelope(envelope), true)
|
PushContentReceiveJob(this).processEnvelope(SignalServiceEnvelope(envelope), true)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d("Loki", "Failed to unwrap data for message.")
|
Log.d("Loki", "Failed to unwrap data for message.")
|
||||||
|
@ -8,7 +8,7 @@ import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
|||||||
import org.thoughtcrime.securesms.loki.utilities.*
|
import org.thoughtcrime.securesms.loki.utilities.*
|
||||||
import org.thoughtcrime.securesms.util.Base64
|
import org.thoughtcrime.securesms.util.Base64
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.whispersystems.signalservice.loki.api.LokiAPITarget
|
import org.whispersystems.signalservice.loki.api.Snode
|
||||||
import org.whispersystems.signalservice.loki.database.LokiAPIDatabaseProtocol
|
import org.whispersystems.signalservice.loki.database.LokiAPIDatabaseProtocol
|
||||||
import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink
|
import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
@JvmStatic val createSessionRequestTimestampCacheCommand = "CREATE TABLE $sessionRequestTimestampCache ($publicKey STRING PRIMARY KEY, $timestamp INTEGER DEFAULT 0);"
|
@JvmStatic val createSessionRequestTimestampCacheCommand = "CREATE TABLE $sessionRequestTimestampCache ($publicKey STRING PRIMARY KEY, $timestamp INTEGER DEFAULT 0);"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSnodePool(): Set<LokiAPITarget> {
|
override fun getSnodePool(): Set<Snode> {
|
||||||
val database = databaseHelper.readableDatabase
|
val database = databaseHelper.readableDatabase
|
||||||
return database.get(snodePoolCache, "${Companion.dummyKey} = ?", wrap("dummy_key")) { cursor ->
|
return database.get(snodePoolCache, "${Companion.dummyKey} = ?", wrap("dummy_key")) { cursor ->
|
||||||
val snodePoolAsString = cursor.getString(cursor.getColumnIndexOrThrow(snodePool))
|
val snodePoolAsString = cursor.getString(cursor.getColumnIndexOrThrow(snodePool))
|
||||||
@ -87,12 +87,12 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
val port = components.getOrNull(1)?.toIntOrNull() ?: return@mapNotNull null
|
val port = components.getOrNull(1)?.toIntOrNull() ?: return@mapNotNull null
|
||||||
val ed25519Key = components.getOrNull(2) ?: return@mapNotNull null
|
val ed25519Key = components.getOrNull(2) ?: return@mapNotNull null
|
||||||
val x25519Key = components.getOrNull(3) ?: return@mapNotNull null
|
val x25519Key = components.getOrNull(3) ?: return@mapNotNull null
|
||||||
LokiAPITarget(address, port, LokiAPITarget.KeySet(ed25519Key, x25519Key))
|
Snode(address, port, Snode.KeySet(ed25519Key, x25519Key))
|
||||||
}
|
}
|
||||||
}?.toSet() ?: setOf()
|
}?.toSet() ?: setOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setSnodePool(newValue: Set<LokiAPITarget>) {
|
override fun setSnodePool(newValue: Set<Snode>) {
|
||||||
val database = databaseHelper.writableDatabase
|
val database = databaseHelper.writableDatabase
|
||||||
val snodePoolAsString = newValue.joinToString(", ") { snode ->
|
val snodePoolAsString = newValue.joinToString(", ") { snode ->
|
||||||
var string = "${snode.address}-${snode.port}"
|
var string = "${snode.address}-${snode.port}"
|
||||||
@ -106,9 +106,9 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
database.insertOrUpdate(snodePoolCache, row, "${Companion.dummyKey} = ?", wrap("dummy_key"))
|
database.insertOrUpdate(snodePoolCache, row, "${Companion.dummyKey} = ?", wrap("dummy_key"))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getOnionRequestPaths(): List<List<LokiAPITarget>> {
|
override fun getOnionRequestPaths(): List<List<Snode>> {
|
||||||
val database = databaseHelper.readableDatabase
|
val database = databaseHelper.readableDatabase
|
||||||
fun get(indexPath: String): LokiAPITarget? {
|
fun get(indexPath: String): Snode? {
|
||||||
return database.get(onionRequestPathCache, "${Companion.indexPath} = ?", wrap(indexPath)) { cursor ->
|
return database.get(onionRequestPathCache, "${Companion.indexPath} = ?", wrap(indexPath)) { cursor ->
|
||||||
val snodeAsString = cursor.getString(cursor.getColumnIndexOrThrow(snode))
|
val snodeAsString = cursor.getString(cursor.getColumnIndexOrThrow(snode))
|
||||||
val components = snodeAsString.split("-")
|
val components = snodeAsString.split("-")
|
||||||
@ -117,7 +117,7 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
val ed25519Key = components.getOrNull(2)
|
val ed25519Key = components.getOrNull(2)
|
||||||
val x25519Key = components.getOrNull(3)
|
val x25519Key = components.getOrNull(3)
|
||||||
if (port != null && ed25519Key != null && x25519Key != null) {
|
if (port != null && ed25519Key != null && x25519Key != null) {
|
||||||
LokiAPITarget(address, port, LokiAPITarget.KeySet(ed25519Key, x25519Key))
|
Snode(address, port, Snode.KeySet(ed25519Key, x25519Key))
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
delete("1-1"); delete("1-2")
|
delete("1-1"); delete("1-2")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setOnionRequestPaths(newValue: List<List<LokiAPITarget>>) {
|
override fun setOnionRequestPaths(newValue: List<List<Snode>>) {
|
||||||
// FIXME: This is a bit of a dirty approach that assumes 2 paths of length 3 each. We should do better than this.
|
// FIXME: This is a bit of a dirty approach that assumes 2 paths of length 3 each. We should do better than this.
|
||||||
if (newValue.count() != 2) { return }
|
if (newValue.count() != 2) { return }
|
||||||
val path0 = newValue[0]
|
val path0 = newValue[0]
|
||||||
@ -147,7 +147,7 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
if (path0.count() != 3 || path1.count() != 3) { return }
|
if (path0.count() != 3 || path1.count() != 3) { return }
|
||||||
Log.d("Loki", "Persisting onion request paths to database.")
|
Log.d("Loki", "Persisting onion request paths to database.")
|
||||||
val database = databaseHelper.writableDatabase
|
val database = databaseHelper.writableDatabase
|
||||||
fun set(indexPath: String ,snode: LokiAPITarget) {
|
fun set(indexPath: String ,snode: Snode) {
|
||||||
var snodeAsString = "${snode.address}-${snode.port}"
|
var snodeAsString = "${snode.address}-${snode.port}"
|
||||||
val keySet = snode.publicKeySet
|
val keySet = snode.publicKeySet
|
||||||
if (keySet != null) {
|
if (keySet != null) {
|
||||||
@ -161,7 +161,7 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
set("1-1", path1[1]); set("1-2", path1[2])
|
set("1-1", path1[1]); set("1-2", path1[2])
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSwarm(hexEncodedPublicKey: String): Set<LokiAPITarget>? {
|
override fun getSwarm(hexEncodedPublicKey: String): Set<Snode>? {
|
||||||
val database = databaseHelper.readableDatabase
|
val database = databaseHelper.readableDatabase
|
||||||
return database.get(swarmCache, "${Companion.hexEncodedPublicKey} = ?", wrap(hexEncodedPublicKey)) { cursor ->
|
return database.get(swarmCache, "${Companion.hexEncodedPublicKey} = ?", wrap(hexEncodedPublicKey)) { cursor ->
|
||||||
val swarmAsString = cursor.getString(cursor.getColumnIndexOrThrow(swarm))
|
val swarmAsString = cursor.getString(cursor.getColumnIndexOrThrow(swarm))
|
||||||
@ -171,12 +171,12 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
val port = components.getOrNull(1)?.toIntOrNull() ?: return@mapNotNull null
|
val port = components.getOrNull(1)?.toIntOrNull() ?: return@mapNotNull null
|
||||||
val ed25519Key = components.getOrNull(2) ?: return@mapNotNull null
|
val ed25519Key = components.getOrNull(2) ?: return@mapNotNull null
|
||||||
val x25519Key = components.getOrNull(3) ?: return@mapNotNull null
|
val x25519Key = components.getOrNull(3) ?: return@mapNotNull null
|
||||||
LokiAPITarget(address, port, LokiAPITarget.KeySet(ed25519Key, x25519Key))
|
Snode(address, port, Snode.KeySet(ed25519Key, x25519Key))
|
||||||
}
|
}
|
||||||
}?.toSet()
|
}?.toSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setSwarm(hexEncodedPublicKey: String, newValue: Set<LokiAPITarget>) {
|
override fun setSwarm(hexEncodedPublicKey: String, newValue: Set<Snode>) {
|
||||||
val database = databaseHelper.writableDatabase
|
val database = databaseHelper.writableDatabase
|
||||||
val swarmAsString = newValue.joinToString(", ") { target ->
|
val swarmAsString = newValue.joinToString(", ") { target ->
|
||||||
var string = "${target.address}-${target.port}"
|
var string = "${target.address}-${target.port}"
|
||||||
@ -190,14 +190,14 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
database.insertOrUpdate(swarmCache, row, "${Companion.hexEncodedPublicKey} = ?", wrap(hexEncodedPublicKey))
|
database.insertOrUpdate(swarmCache, row, "${Companion.hexEncodedPublicKey} = ?", wrap(hexEncodedPublicKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLastMessageHashValue(target: LokiAPITarget): String? {
|
override fun getLastMessageHashValue(target: Snode): String? {
|
||||||
val database = databaseHelper.readableDatabase
|
val database = databaseHelper.readableDatabase
|
||||||
return database.get(lastMessageHashValueCache, "${Companion.target} = ?", wrap(target.address)) { cursor ->
|
return database.get(lastMessageHashValueCache, "${Companion.target} = ?", wrap(target.address)) { cursor ->
|
||||||
cursor.getString(cursor.getColumnIndexOrThrow(lastMessageHashValue))
|
cursor.getString(cursor.getColumnIndexOrThrow(lastMessageHashValue))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setLastMessageHashValue(target: LokiAPITarget, newValue: String) {
|
override fun setLastMessageHashValue(target: Snode, newValue: String) {
|
||||||
val database = databaseHelper.writableDatabase
|
val database = databaseHelper.writableDatabase
|
||||||
val row = wrap(mapOf(Companion.target to target.address, lastMessageHashValue to newValue))
|
val row = wrap(mapOf(Companion.target to target.address, lastMessageHashValue to newValue))
|
||||||
database.insertOrUpdate(lastMessageHashValueCache, row, "${Companion.target} = ?", wrap(target.address))
|
database.insertOrUpdate(lastMessageHashValueCache, row, "${Companion.target} = ?", wrap(target.address))
|
||||||
|
@ -21,7 +21,7 @@ import org.thoughtcrime.securesms.loki.utilities.QRCodeUtilities
|
|||||||
import org.thoughtcrime.securesms.loki.utilities.toPx
|
import org.thoughtcrime.securesms.loki.utilities.toPx
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.thoughtcrime.securesms.util.Util
|
import org.thoughtcrime.securesms.util.Util
|
||||||
import org.whispersystems.signalservice.loki.api.LokiAPI
|
import org.whispersystems.signalservice.loki.api.SnodeAPI
|
||||||
import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI
|
import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI
|
||||||
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
|
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
|
||||||
import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink
|
import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink
|
||||||
@ -84,7 +84,7 @@ class LinkDeviceMasterModeDialog : DialogFragment(), DeviceLinkingSessionListene
|
|||||||
contentView.cancelButton.visibility = View.GONE
|
contentView.cancelButton.visibility = View.GONE
|
||||||
contentView.authorizeButton.visibility = View.GONE
|
contentView.authorizeButton.visibility = View.GONE
|
||||||
}
|
}
|
||||||
LokiFileServerAPI.shared.addDeviceLink(deviceLink).bind(LokiAPI.sharedContext) {
|
LokiFileServerAPI.shared.addDeviceLink(deviceLink).bind(SnodeAPI.sharedContext) {
|
||||||
MultiDeviceProtocol.signAndSendDeviceLinkMessage(context!!, deviceLink)
|
MultiDeviceProtocol.signAndSendDeviceLinkMessage(context!!, deviceLink)
|
||||||
}.success {
|
}.success {
|
||||||
TextSecurePreferences.setMultiDevice(context!!, true)
|
TextSecurePreferences.setMultiDevice(context!!, true)
|
||||||
|
@ -17,7 +17,7 @@ import org.whispersystems.libsignal.SignalProtocolAddress
|
|||||||
import org.whispersystems.signalservice.api.messages.SignalServiceContent
|
import org.whispersystems.signalservice.api.messages.SignalServiceContent
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup
|
import org.whispersystems.signalservice.api.messages.SignalServiceGroup
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
||||||
import org.whispersystems.signalservice.loki.api.LokiAPI
|
import org.whispersystems.signalservice.loki.api.SnodeAPI
|
||||||
import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI
|
import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI
|
||||||
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol
|
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -14,8 +14,8 @@ import org.whispersystems.signalservice.api.messages.SignalServiceContent
|
|||||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage
|
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup
|
import org.whispersystems.signalservice.api.messages.SignalServiceGroup
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
||||||
import org.whispersystems.signalservice.loki.api.rssfeeds.LokiRSSFeed
|
import org.whispersystems.signalservice.loki.api.shelved.rssfeeds.LokiRSSFeed
|
||||||
import org.whispersystems.signalservice.loki.api.rssfeeds.LokiRSSFeedProxy
|
import org.whispersystems.signalservice.loki.api.shelved.rssfeeds.LokiRSSFeedProxy
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import org.thoughtcrime.securesms.ApplicationContext;
|
|||||||
import org.thoughtcrime.securesms.loki.api.LokiPublicChatManager;
|
import org.thoughtcrime.securesms.loki.api.LokiPublicChatManager;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.Debouncer;
|
import org.thoughtcrime.securesms.util.Debouncer;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiPoller;
|
import org.whispersystems.signalservice.loki.api.Poller;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateNotification(@NonNull Context context) {
|
public void updateNotification(@NonNull Context context) {
|
||||||
LokiPoller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
Poller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
||||||
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
||||||
Boolean isCaughtUp = false;
|
Boolean isCaughtUp = false;
|
||||||
if (lokiPoller != null && lokiPublicChatManager != null) {
|
if (lokiPoller != null && lokiPublicChatManager != null) {
|
||||||
@ -55,7 +55,7 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateNotification(@NonNull Context context, long threadId) {
|
public void updateNotification(@NonNull Context context, long threadId) {
|
||||||
LokiPoller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
Poller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
||||||
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
||||||
Boolean isCaughtUp = false;
|
Boolean isCaughtUp = false;
|
||||||
if (lokiPoller != null && lokiPublicChatManager != null) {
|
if (lokiPoller != null && lokiPublicChatManager != null) {
|
||||||
@ -71,7 +71,7 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateNotification(@NonNull Context context, long threadId, boolean signal) {
|
public void updateNotification(@NonNull Context context, long threadId, boolean signal) {
|
||||||
LokiPoller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
Poller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
||||||
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
||||||
Boolean isCaughtUp = false;
|
Boolean isCaughtUp = false;
|
||||||
if (lokiPoller != null && lokiPublicChatManager != null) {
|
if (lokiPoller != null && lokiPublicChatManager != null) {
|
||||||
@ -87,7 +87,7 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateNotification(@android.support.annotation.NonNull Context context, boolean signal, int reminderCount) {
|
public void updateNotification(@android.support.annotation.NonNull Context context, boolean signal, int reminderCount) {
|
||||||
LokiPoller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
Poller lokiPoller = ApplicationContext.getInstance(context).lokiPoller;
|
||||||
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
LokiPublicChatManager lokiPublicChatManager = ApplicationContext.getInstance(context).lokiPublicChatManager;
|
||||||
Boolean isCaughtUp = false;
|
Boolean isCaughtUp = false;
|
||||||
if (lokiPoller != null && lokiPublicChatManager != null) {
|
if (lokiPoller != null && lokiPublicChatManager != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user