From 8c45a9151f241be3e9606a9a9ebf91c0f46ebc7f Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 4 Jun 2019 09:35:18 +1000 Subject: [PATCH] Stub LokiAPIDatabase --- build.gradle | 4 ++ .../database/helpers/SQLCipherOpenHelper.java | 2 + .../securesms/loki/LokiAPIDatabase.kt | 44 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/org/thoughtcrime/securesms/loki/LokiAPIDatabase.kt diff --git a/build.gradle b/build.gradle index 5ccc26e6f4..b2bb46f5a3 100644 --- a/build.gradle +++ b/build.gradle @@ -153,6 +153,10 @@ dependencies { exclude group: 'org.freemarker' } + implementation "com.googlecode.libphonenumber:libphonenumber:8.10.7" + implementation "com.fasterxml.jackson.core:jackson-databind:2.9.8" + implementation "com.squareup.okhttp3:okhttp:3.12.1" + testImplementation 'junit:junit:4.12' testImplementation 'org.assertj:assertj-core:3.11.1' testImplementation 'org.mockito:mockito-core:1.9.5' diff --git a/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java b/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java index 4b7b9eba2c..a1c4adb04a 100644 --- a/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java +++ b/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java @@ -35,6 +35,7 @@ import org.thoughtcrime.securesms.database.SignedPreKeyDatabase; import org.thoughtcrime.securesms.database.SmsDatabase; import org.thoughtcrime.securesms.database.ThreadDatabase; import org.thoughtcrime.securesms.jobs.RefreshPreKeysJob; +import org.thoughtcrime.securesms.loki.LokiAPIDatabase; import org.thoughtcrime.securesms.notifications.NotificationChannels; import org.thoughtcrime.securesms.service.KeyCachingService; import org.thoughtcrime.securesms.util.TextSecurePreferences; @@ -112,6 +113,7 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { for (String sql : JobDatabase.CREATE_TABLE) { db.execSQL(sql); } + db.execSQL(LokiAPIDatabase.getCreateTableCommand()); executeStatements(db, SmsDatabase.CREATE_INDEXS); executeStatements(db, MmsDatabase.CREATE_INDEXS); diff --git a/src/org/thoughtcrime/securesms/loki/LokiAPIDatabase.kt b/src/org/thoughtcrime/securesms/loki/LokiAPIDatabase.kt new file mode 100644 index 0000000000..ff2a4b70b5 --- /dev/null +++ b/src/org/thoughtcrime/securesms/loki/LokiAPIDatabase.kt @@ -0,0 +1,44 @@ +package org.thoughtcrime.securesms.loki + +import android.content.Context +import org.thoughtcrime.securesms.database.Database +import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper +import org.whispersystems.signalservice.loki.api.LokiAPIDatabaseProtocol +import org.whispersystems.signalservice.loki.api.LokiAPITarget + +class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiAPIDatabaseProtocol { + + companion object { + private val tableKey = "loki_api_database" + private val swarmCacheKey = "swarm_cache" + private val lastMessageHashValueKey = "last_message_hash_value" + private val receivedMessageHashValuesKey = "received_message_hash_values" + + @JvmStatic + val createTableCommand = "CREATE TABLE $tableKey ($swarmCacheKey TEXT, $lastMessageHashValueKey TEXT, $receivedMessageHashValuesKey TEXT);" + } + + override fun getSwarmCache(): Map>? { + return null + } + + override fun setSwarmCache(newValue: Map>) { + // TODO: Implement + } + + override fun getLastMessageHashValue(target: LokiAPITarget): String? { + return null + } + + override fun setLastMessageHashValue(target: LokiAPITarget, newValue: String) { + // TODO: Implement + } + + override fun getReceivedMessageHashValues(): Set? { + return null + } + + override fun setReceivedMessageHashValues(newValue: Set) { + // TODO: Implement + } +} \ No newline at end of file