Fix done TODO

This commit is contained in:
Benoit Marty 2019-07-03 11:58:50 +02:00
parent a476ac71da
commit f41c0311fa
16 changed files with 32 additions and 79 deletions

View File

@ -2,8 +2,6 @@

buildscript {
ext.kotlin_version = '1.3.21'
ext.koin_version = '1.0.2'
// TODO ext.koin_version = '2.0.0-GA'
repositories {
google()
jcenter()

View File

@ -148,13 +148,11 @@ dependencies {

testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:4.0.2'
testImplementation "org.koin:koin-test:$koin_version"
//testImplementation 'org.robolectric:shadows-support-v4:3.0'
testImplementation "io.mockk:mockk:1.8.13.kotlin13"
testImplementation 'org.amshove.kluent:kluent-android:1.44'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"

androidTestImplementation "org.koin:koin-test:$koin_version"
androidTestImplementation 'androidx.test:core:1.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'

View File

@ -36,17 +36,15 @@ interface Authenticator {
*/
fun authenticate(homeServerConnectionConfig: HomeServerConnectionConfig, login: String, password: String, callback: MatrixCallback<Session>): Cancelable

//TODO remove this method. Shouldn't be managed like that.
/**
* Check if there is an active [Session].
* Check if there is an authenticated [Session].
* @return true if there is at least one active session.
*/
fun hasAuthenticatedSessions(): Boolean

//TODO remove this method. Shouldn't be managed like that.
/**
* Get the last active [Session], if there is an active session.
* @return the lastActive session if any, or null
* Get the last authenticated [Session], if there is an active session.
* @return the last active session if any, or null
*/
fun getLastAuthenticatedSession(): Session?

@ -58,7 +56,4 @@ interface Authenticator {
* @return the associated session if any, or null
*/
fun getSession(sessionParams: SessionParams): Session?



}

View File

@ -20,7 +20,6 @@ import im.vector.matrix.android.api.session.events.model.Event
import im.vector.matrix.android.api.session.events.model.EventType
import im.vector.matrix.android.api.session.events.model.toModel
import im.vector.matrix.android.api.session.room.model.message.MessageContent
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
import timber.log.Timber
import java.util.regex.Pattern

@ -35,15 +34,15 @@ class ContainsDisplayNameCondition : Condition(Kind.contains_display_name) {
}

fun isSatisfied(event: Event, displayName: String): Boolean {
//TODO the spec says:
// Matches any message whose content is unencrypted and contains the user's current display name
var message = when (event.type) {
EventType.MESSAGE -> {
event.content.toModel<MessageContent>()
}
// EventType.ENCRYPTED -> {
// event.root.getClearContent()?.toModel<MessageContent>()
// }
//TODO the spec says:
// Matches any message whose content is unencrypted and contains the user's current display name
// EventType.ENCRYPTED -> {
// event.root.getClearContent()?.toModel<MessageContent>()
// }
else -> null
} ?: return false


View File

@ -76,7 +76,7 @@ internal abstract class CryptoModule {
@Provides
fun providesCryptoStore(@CryptoDatabase
realmConfiguration: RealmConfiguration, credentials: Credentials): IMXCryptoStore {
return RealmCryptoStore(false /* TODO*/,
return RealmCryptoStore(
realmConfiguration,
credentials)
}

View File

@ -84,7 +84,7 @@ internal class IncomingRoomKeyRequestManager @Inject constructor(
Timber.e("## processReceivedRoomKeyRequests() : Ignoring room key request from other user for now")
return
}
// todo: should we queue up requests we don't yet have keys for, in case they turn up later?
// TODO: should we queue up requests we don't yet have keys for, in case they turn up later?
// if we don't have a decryptor for this room/alg, we don't have
// the keys for the requested events, and can drop the requests.
val decryptor = roomDecryptorProvider.getRoomDecryptor(roomId, alg)

View File

@ -285,7 +285,8 @@ internal class OutgoingRoomKeyRequestManager @Inject constructor(
val contentMap = MXUsersDevicesMap<Any>()

for (recipient in recipients) {
contentMap.setObject(message, recipient["userId"], recipient["deviceId"]) // TODO Change this two hard coded key to something better
// TODO Change this two hard coded key to something better
contentMap.setObject(message, recipient["userId"], recipient["deviceId"])
}

sendToDeviceTask.configureWith(SendToDeviceTask.Params(EventType.ROOM_KEY_REQUEST, contentMap, transactionId))

View File

@ -81,9 +81,6 @@ internal class MessageEncrypter @Inject constructor(private val credentials: Cre
recipientsKeysMap["ed25519"] = deviceInfo.fingerprint()!!
payloadJson["recipient_keys"] = recipientsKeysMap

// FIXME We have to canonicalize the JSON
//JsonUtility.canonicalize(JsonUtility.getGson(false).toJsonTree(payloadJson)).toString()

val payloadString = convertToUTF8(MoshiProvider.getCanonicalJson(Map::class.java, payloadJson))
ciphertext[deviceKey] = olmDevice.encryptMessage(deviceKey, sessionId!!, payloadString!!)!!
}

View File

@ -139,7 +139,8 @@ internal class MXMegolmDecryption(private val credentials: Credentials,
val recipients = ArrayList<Map<String, String>>()

val selfMap = HashMap<String, String>()
selfMap["userId"] = credentials.userId // TODO Replace this hard coded keys (see OutgoingRoomKeyRequestManager)
// TODO Replace this hard coded keys (see OutgoingRoomKeyRequestManager)
selfMap["userId"] = credentials.userId
selfMap["deviceId"] = "*"
recipients.add(selfMap)


View File

@ -25,8 +25,6 @@ import im.vector.matrix.android.internal.crypto.keysbackup.KeysBackup
import im.vector.matrix.android.internal.crypto.repository.WarnOnUnknownDeviceRepository
import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore
import im.vector.matrix.android.internal.crypto.tasks.SendToDeviceTask
import im.vector.matrix.android.internal.session.SessionScope
import im.vector.matrix.android.internal.task.TaskExecutor
import javax.inject.Inject

internal class MXMegolmEncryptionFactory @Inject constructor(
@ -37,8 +35,6 @@ internal class MXMegolmEncryptionFactory @Inject constructor(
private val ensureOlmSessionsForDevicesAction: EnsureOlmSessionsForDevicesAction,
private val credentials: Credentials,
private val sendToDeviceTask: SendToDeviceTask,
// FIXME Why taskExecutor is not used?
private val taskExecutor: TaskExecutor,
private val messageEncrypter: MessageEncrypter,
private val warnOnUnknownDevicesRepository: WarnOnUnknownDeviceRepository) {


View File

@ -39,10 +39,8 @@ import org.matrix.olm.OlmException
import timber.log.Timber
import kotlin.collections.set

// enableFileEncryption is used to migrate the previous store
@SessionScope
internal class RealmCryptoStore(private val enableFileEncryption: Boolean = false,
private val realmConfiguration: RealmConfiguration,
internal class RealmCryptoStore(private val realmConfiguration: RealmConfiguration,
private val credentials: Credentials) : IMXCryptoStore {

/* ==========================================================================================

View File

@ -1,28 +0,0 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// TODO When upgrading to koin 2.0
/*
class ModuleTest : KoinTest {

@Test
fun checkModules() {
startKoin {
listOf(CryptoModule().definition)
}.checkModules()
}
}
*/

View File

@ -166,6 +166,7 @@ class PushrulesConditionTest {


class MockRoomService() : RoomService {

override fun createRoom(createRoomParams: CreateRoomParams, callback: MatrixCallback<String>) {

}
@ -178,24 +179,28 @@ class PushrulesConditionTest {
}
}

override fun liveRoomSummaries(): LiveData<List<RoomSummary>> {
override fun liveRoomSummaries(fetchLastEvents: Boolean): LiveData<List<RoomSummary>> {
return MutableLiveData()
}

}

class MockRoom(override val roomId: String, val _numberOfJoinedMembers: Int) : Room {
override fun liveTimeLineEvent(eventId: String): LiveData<TimelineEvent> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}


override fun getNumberOfJoinedMembers(): Int {
return _numberOfJoinedMembers
}

override val liveRoomSummary: LiveData<RoomSummary>
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
override fun liveRoomSummary(fetchLastEvent: Boolean): LiveData<RoomSummary> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override val roomSummary: RoomSummary?
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
override fun roomSummary(fetchLastEvent: Boolean): RoomSummary? {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override fun createTimeline(eventId: String?, allowedTypes: List<String>?): Timeline {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
@ -277,10 +282,6 @@ class PushrulesConditionTest {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override fun updateQuickReaction(reaction: String, oppositeReaction: String, targetEventId: String, myUserId: String) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override fun editTextMessage(targetEventId: String, newBodyText: String, newBodyAutoMarkdown: Boolean, compatibilityBodyText: String): Cancelable {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@ -289,7 +290,7 @@ class PushrulesConditionTest {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override fun getEventSummaryLive(eventId: String): LiveData<List<EventAnnotationsSummary>> {
override fun getEventSummaryLive(eventId: String): LiveData<EventAnnotationsSummary> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}


View File

@ -105,8 +105,7 @@ fi
echo
echo "Search for long files..."

# TODO Reduce this once VectorSettingsPreferencesFragment.kt has been reworked
${checkLongFilesScript} 3500 \
${checkLongFilesScript} 2000 \
./vector/src/main/java \
./vector/src/main/res/layout \
./vector/src/main/res/values \

View File

@ -45,7 +45,6 @@ abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>() {
@EpoxyAttribute
var urlClickCallback: TimelineEventController.UrlClickCallback? = null

// TODO Move this instantiation somewhere else?
private val mvmtMethod = BetterLinkMovementMethod.newInstance().also {
it.setOnLinkClickListener { _, url ->
//Return false to let android manage the click on the link, or true if the link is handled by the application

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<!-- TODO Design: icon -->
<item
android:id="@+id/bottom_action_home"
android:contentDescription="@string/bottom_action_home"