This commit is contained in:
Niels Andriesse 2019-07-22 14:25:59 +10:00
parent a767c84f74
commit 06e8d20da4
4 changed files with 22 additions and 15 deletions

View File

@ -7,7 +7,7 @@
<color name="signal_primary">@color/loki_green</color>
<color name="signal_primary_dark">@color/loki_green</color>
<color name="signal_primary_alpha33">#555bca5b</color>
<color name="signal_primary_alpha33">#5578be20</color>
<color name="signal_primary_alpha_focus">#882090ea</color>
<color name="textsecure_primary">@color/signal_primary</color>

View File

@ -243,10 +243,10 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
try {
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
SignalProtocolStore axolotlStore = new SignalProtocolStoreImpl(context);
LokiThreadDatabaseProtocol lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context);
LokiPreKeyRecordDatabase preKeyRecordDatabase = DatabaseFactory.getLokiPreKeyRecordDatabase(context);
LokiThreadDatabase lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context);
LokiPreKeyRecordDatabase lokiPreKeyRecordDatabase = DatabaseFactory.getLokiPreKeyRecordDatabase(context);
SignalServiceAddress localAddress = new SignalServiceAddress(TextSecurePreferences.getLocalNumber(context));
LokiServiceCipher cipher = new LokiServiceCipher(localAddress, axolotlStore, lokiThreadDatabase, preKeyRecordDatabase, UnidentifiedAccessUtil.getCertificateValidator());
LokiServiceCipher cipher = new LokiServiceCipher(localAddress, axolotlStore, lokiThreadDatabase, lokiPreKeyRecordDatabase, UnidentifiedAccessUtil.getCertificateValidator());
/* Loki - Original code
SignalServiceCipher cipher = new SignalServiceCipher(localAddress, axolotlStore, UnidentifiedAccessUtil.getCertificateValidator());
*/
@ -480,7 +480,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
lokiThreadDatabase.setSessionResetState(threadId, LokiThreadSessionResetState.REQUEST_RECEIVED);
// TODO: Send a background message here
Log.d("LOKI", "Session reset received from " + content.getSender());
Log.d("Loki", "Received a session reset request from: " + content.getSender() + ".");
SecurityEvent.broadcastSecurityUpdateEvent(context);
MessageNotifier.updateNotification(context, threadId);
@ -498,8 +498,10 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
if (!recipient.isGroupRecipient()) {
// TODO: Handle session reset on sync messages
// SessionStore sessionStore = new TextSecureSessionStore(context);
// sessionStore.deleteAllSessions(recipient.getAddress().toPhoneString());
/*
SessionStore sessionStore = new TextSecureSessionStore(context);
sessionStore.deleteAllSessions(recipient.getAddress().toPhoneString());
*/
SecurityEvent.broadcastSecurityUpdateEvent(context);

View File

@ -164,8 +164,13 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
log(TAG, "Have access key to use: " + unidentifiedAccess.isPresent());
// Loki - Include a pre key bundle if the message is a friend request
PreKeyBundle preKeyBundle = (message.isFriendRequest() || message.isEndSession()) ? DatabaseFactory.getLokiPreKeyBundleDatabase(context).generatePreKeyBundle(address.getNumber()) : null;
// Loki - Include a pre key bundle if the message is a friend request or an end session message
PreKeyBundle preKeyBundle;
if (message.isFriendRequest() || message.isEndSession()) {
preKeyBundle = DatabaseFactory.getLokiPreKeyBundleDatabase(context).generatePreKeyBundle(address.getNumber());
} else {
preKeyBundle = null;
}
SignalServiceDataMessage textSecureMessage = SignalServiceDataMessage.newBuilder()
.withTimestamp(message.getDateSent())

View File

@ -15,13 +15,13 @@ class LokiThreadDatabase(context: Context, helper: SQLCipherOpenHelper) : Databa
var delegate: LokiThreadDatabaseDelegate? = null
companion object {
private val sessionResetTableName = "loki_thread_session_reset_database"
private val friendRequestTableName = "loki_thread_friend_request_database"
private val sessionResetTableName = "loki_thread_session_reset_database"
private val threadID = "thread_id"
private val friendRequestStatus = "friend_request_status"
private val sessionResetState = "session_reset_state"
private val sessionResetStatus = "session_reset_status"
@JvmStatic val createFriendRequestTableCommand = "CREATE TABLE $friendRequestTableName ($threadID INTEGER PRIMARY KEY, $friendRequestStatus INTEGER DEFAULT 0);"
@JvmStatic val createSessionResetTableCommand = "CREATE TABLE $sessionResetTableName ($threadID INTEGER PRIMARY KEY, $sessionResetState INTEGER DEFAULT 0);"
@JvmStatic val createSessionResetTableCommand = "CREATE TABLE $sessionResetTableName ($threadID INTEGER PRIMARY KEY, $sessionResetStatus INTEGER DEFAULT 0);"
}
override fun getThreadID(hexEncodePubKey: String): Long {
@ -66,7 +66,7 @@ class LokiThreadDatabase(context: Context, helper: SQLCipherOpenHelper) : Databa
override fun getSessionResetState(threadID: Long): LokiThreadSessionResetState {
val database = databaseHelper.readableDatabase
val result = database.get(sessionResetTableName, "${Companion.threadID} = ?", arrayOf( threadID.toString() )) { cursor ->
cursor.getInt(sessionResetState)
cursor.getInt(sessionResetStatus)
}
return if (result != null) {
LokiThreadSessionResetState.values().first { it.rawValue == result }
@ -75,11 +75,11 @@ class LokiThreadDatabase(context: Context, helper: SQLCipherOpenHelper) : Databa
}
}
override fun setSessionResetState(threadID: Long, sessionResetState: LokiThreadSessionResetState) {
override fun setSessionResetState(threadID: Long, sessionResetStatus: LokiThreadSessionResetState) {
val database = databaseHelper.writableDatabase
val contentValues = ContentValues(2)
contentValues.put(Companion.threadID, threadID)
contentValues.put(Companion.sessionResetState, sessionResetState.rawValue)
contentValues.put(Companion.sessionResetStatus, sessionResetStatus.rawValue)
database.insertOrUpdate(sessionResetTableName, contentValues, "${Companion.threadID} = ?", arrayOf( threadID.toString() ))
notifyConversationListListeners()
notifyConversationListeners(threadID)