forked from GitHub-Mirror/riotX-android
Dagger: continue reworking on app and sdk [WIP]
This commit is contained in:
parent
ee87c253fe
commit
07fee8ed3d
@ -37,10 +37,7 @@ dependencies {
|
|||||||
implementation project(":matrix-sdk-android")
|
implementation project(":matrix-sdk-android")
|
||||||
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
|
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
|
||||||
implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
|
implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
|
||||||
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
|
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
||||||
|
|
||||||
// Paging
|
|
||||||
implementation 'androidx.paging:paging-runtime:2.0.0'
|
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'androidx.test:runner:1.1.1'
|
androidTestImplementation 'androidx.test:runner:1.1.1'
|
||||||
|
@ -120,7 +120,7 @@ dependencies {
|
|||||||
kapt 'dk.ilios:realmfieldnameshelper:1.1.1'
|
kapt 'dk.ilios:realmfieldnameshelper:1.1.1'
|
||||||
|
|
||||||
// Work
|
// Work
|
||||||
implementation "android.arch.work:work-runtime-ktx:1.0.0"
|
implementation "androidx.work:work-runtime-ktx:2.1.0-beta01"
|
||||||
|
|
||||||
// FP
|
// FP
|
||||||
implementation "io.arrow-kt:arrow-core:$arrow_version"
|
implementation "io.arrow-kt:arrow-core:$arrow_version"
|
||||||
|
@ -39,16 +39,8 @@ import org.koin.test.KoinTest
|
|||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
internal class AuthenticatorTest : InstrumentedTest, KoinTest {
|
internal class AuthenticatorTest : InstrumentedTest, KoinTest {
|
||||||
|
|
||||||
init {
|
lateinit var authenticator: Authenticator
|
||||||
Monarchy.init(context())
|
lateinit var okReplayInterceptor: OkReplayInterceptor
|
||||||
val matrixModule = MatrixModule(context()).definition
|
|
||||||
val networkModule = NetworkModule().definition
|
|
||||||
val authModule = AuthModule().definition
|
|
||||||
loadKoinModules(listOf(matrixModule, networkModule, authModule))
|
|
||||||
}
|
|
||||||
|
|
||||||
private val authenticator: Authenticator by inject()
|
|
||||||
private val okReplayInterceptor: OkReplayInterceptor by inject()
|
|
||||||
|
|
||||||
private val okReplayConfig = OkReplayConfig.Builder()
|
private val okReplayConfig = OkReplayConfig.Builder()
|
||||||
.tapeRoot(AndroidTapeRoot(
|
.tapeRoot(AndroidTapeRoot(
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="im.vector.matrix.android">
|
package="im.vector.matrix.android">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
@ -7,9 +8,10 @@
|
|||||||
|
|
||||||
<application>
|
<application>
|
||||||
|
|
||||||
<provider
|
<provider android:name="androidx.work.impl.WorkManagerInitializer"
|
||||||
android:name=".internal.MatrixInitProvider"
|
android:authorities="${applicationId}.workmanager-init"
|
||||||
android:authorities="im.vector.matrix.android.MatrixInitProvider" />
|
android:exported="false"
|
||||||
|
tools:node="remove" />
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
@ -18,10 +18,13 @@ package im.vector.matrix.android.api
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.lifecycle.ProcessLifecycleOwner
|
import androidx.lifecycle.ProcessLifecycleOwner
|
||||||
|
import androidx.work.Configuration
|
||||||
|
import androidx.work.WorkManager
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
import im.vector.matrix.android.api.auth.Authenticator
|
import im.vector.matrix.android.api.auth.Authenticator
|
||||||
import im.vector.matrix.android.api.session.Session
|
import im.vector.matrix.android.api.session.Session
|
||||||
import im.vector.matrix.android.api.session.sync.FilterService
|
import im.vector.matrix.android.api.session.sync.FilterService
|
||||||
|
import im.vector.matrix.android.internal.SessionManager
|
||||||
import im.vector.matrix.android.internal.di.DaggerMatrixComponent
|
import im.vector.matrix.android.internal.di.DaggerMatrixComponent
|
||||||
import im.vector.matrix.android.internal.network.UserAgentHolder
|
import im.vector.matrix.android.internal.network.UserAgentHolder
|
||||||
import im.vector.matrix.android.internal.util.BackgroundDetectionObserver
|
import im.vector.matrix.android.internal.util.BackgroundDetectionObserver
|
||||||
@ -29,23 +32,37 @@ import org.matrix.olm.OlmManager
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
data class MatrixConfiguration(
|
||||||
|
val applicationFlavor: String = "Default-application-flavor"
|
||||||
|
) {
|
||||||
|
|
||||||
|
interface Provider {
|
||||||
|
fun providesMatrixConfiguration(): MatrixConfiguration
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the matrix sdk.
|
* This is the main entry point to the matrix sdk.
|
||||||
* This class is automatically init by a provider.
|
|
||||||
* To get the singleton instance, use getInstance static method.
|
* To get the singleton instance, use getInstance static method.
|
||||||
*/
|
*/
|
||||||
class Matrix private constructor(context: Context) {
|
class Matrix private constructor(context: Context, matrixConfiguration: MatrixConfiguration) {
|
||||||
|
|
||||||
@Inject internal lateinit var olmManager: OlmManager
|
|
||||||
@Inject internal lateinit var authenticator: Authenticator
|
@Inject internal lateinit var authenticator: Authenticator
|
||||||
@Inject internal lateinit var userAgentHolder: UserAgentHolder
|
@Inject internal lateinit var userAgentHolder: UserAgentHolder
|
||||||
@Inject internal lateinit var backgroundDetectionObserver: BackgroundDetectionObserver
|
@Inject internal lateinit var backgroundDetectionObserver: BackgroundDetectionObserver
|
||||||
|
@Inject internal lateinit var olmManager: OlmManager
|
||||||
|
@Inject internal lateinit var sessionManager: SessionManager
|
||||||
var currentSession: Session? = null
|
var currentSession: Session? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
Monarchy.init(context)
|
Monarchy.init(context)
|
||||||
DaggerMatrixComponent.factory().create(context).inject(this)
|
DaggerMatrixComponent.factory().create(context).inject(this)
|
||||||
|
if (context.applicationContext !is Configuration.Provider) {
|
||||||
|
WorkManager.initialize(context, Configuration.Builder().build())
|
||||||
|
}
|
||||||
ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver)
|
ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver)
|
||||||
|
userAgentHolder.setApplicationFlavor(matrixConfiguration.applicationFlavor)
|
||||||
authenticator.getLastActiveSession()?.also {
|
authenticator.getLastActiveSession()?.also {
|
||||||
currentSession = it
|
currentSession = it
|
||||||
it.open()
|
it.open()
|
||||||
@ -54,30 +71,33 @@ class Matrix private constructor(context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getUserAgent() = userAgentHolder.userAgent
|
||||||
|
|
||||||
fun authenticator(): Authenticator {
|
fun authenticator(): Authenticator {
|
||||||
return authenticator
|
return authenticator
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set application flavor, to alter user agent.
|
|
||||||
*/
|
|
||||||
fun setApplicationFlavor(flavor: String) {
|
|
||||||
userAgentHolder.setApplicationFlavor(flavor)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getUserAgent() = userAgentHolder.userAgent
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private lateinit var instance: Matrix
|
private lateinit var instance: Matrix
|
||||||
private val isInit = AtomicBoolean(false)
|
private val isInit = AtomicBoolean(false)
|
||||||
|
|
||||||
internal fun initialize(context: Context) {
|
fun initialize(context: Context, matrixConfiguration: MatrixConfiguration) {
|
||||||
if (isInit.compareAndSet(false, true)) {
|
if (isInit.compareAndSet(false, true)) {
|
||||||
instance = Matrix(context.applicationContext)
|
instance = Matrix(context.applicationContext, matrixConfiguration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getInstance(): Matrix {
|
fun getInstance(context: Context): Matrix {
|
||||||
|
if (isInit.compareAndSet(false, true)) {
|
||||||
|
val appContext = context.applicationContext
|
||||||
|
if (appContext is MatrixConfiguration.Provider) {
|
||||||
|
val matrixConfiguration = (appContext as MatrixConfiguration.Provider).providesMatrixConfiguration()
|
||||||
|
instance = Matrix(appContext, matrixConfiguration)
|
||||||
|
} else {
|
||||||
|
throw IllegalStateException("Matrix is not initialized properly. You should call Matrix.initialize or let your application implements MatrixConfiguration.Provider.")
|
||||||
|
}
|
||||||
|
}
|
||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,52 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package im.vector.matrix.android.internal
|
|
||||||
|
|
||||||
import android.content.ContentProvider
|
|
||||||
import android.content.ContentValues
|
|
||||||
import android.database.Cursor
|
|
||||||
import android.net.Uri
|
|
||||||
import im.vector.matrix.android.api.Matrix
|
|
||||||
|
|
||||||
internal class MatrixInitProvider : ContentProvider() {
|
|
||||||
|
|
||||||
override fun onCreate(): Boolean {
|
|
||||||
Matrix.initialize(context!!)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun insert(uri: Uri, values: ContentValues?): Uri? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun query(uri: Uri, projection: Array<String>?, selection: String?, selectionArgs: Array<String>?, sortOrder: String?): Cursor? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<String>?): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<String>?): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getType(uri: Uri): String? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -31,6 +31,10 @@ internal class SessionManager @Inject constructor(private val matrixComponent: M
|
|||||||
|
|
||||||
private val sessionComponents = HashMap<String, SessionComponent>()
|
private val sessionComponents = HashMap<String, SessionComponent>()
|
||||||
|
|
||||||
|
fun getSessionComponent(userId: String): SessionComponent? {
|
||||||
|
return sessionComponents[userId]
|
||||||
|
}
|
||||||
|
|
||||||
fun createSession(sessionParams: SessionParams): Session {
|
fun createSession(sessionParams: SessionParams): Session {
|
||||||
val userId = sessionParams.credentials.userId
|
val userId = sessionParams.credentials.userId
|
||||||
if (sessionComponents.containsKey(userId)) {
|
if (sessionComponents.containsKey(userId)) {
|
||||||
|
@ -35,7 +35,6 @@ internal abstract class AuthModule {
|
|||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@MatrixScope
|
|
||||||
@AuthDatabase
|
@AuthDatabase
|
||||||
fun providesRealmConfiguration(context: Context): RealmConfiguration {
|
fun providesRealmConfiguration(context: Context): RealmConfiguration {
|
||||||
val old = File(context.filesDir, "matrix-sdk-auth")
|
val old = File(context.filesDir, "matrix-sdk-auth")
|
||||||
@ -51,11 +50,9 @@ internal abstract class AuthModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@MatrixScope
|
|
||||||
abstract fun bindSessionParamsStore(sessionParamsStore: RealmSessionParamsStore): SessionParamsStore
|
abstract fun bindSessionParamsStore(sessionParamsStore: RealmSessionParamsStore): SessionParamsStore
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@MatrixScope
|
|
||||||
abstract fun bindAuthenticator(authenticator: DefaultAuthenticator): Authenticator
|
abstract fun bindAuthenticator(authenticator: DefaultAuthenticator): Authenticator
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,6 @@ import kotlinx.coroutines.withContext
|
|||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@MatrixScope
|
|
||||||
internal class DefaultAuthenticator @Inject constructor(private val retrofitBuilder: Retrofit.Builder,
|
internal class DefaultAuthenticator @Inject constructor(private val retrofitBuilder: Retrofit.Builder,
|
||||||
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
||||||
private val sessionParamsStore: SessionParamsStore,
|
private val sessionParamsStore: SessionParamsStore,
|
||||||
|
@ -25,7 +25,6 @@ import io.realm.Realm
|
|||||||
import io.realm.RealmConfiguration
|
import io.realm.RealmConfiguration
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@MatrixScope
|
|
||||||
internal class RealmSessionParamsStore @Inject constructor(private val mapper: SessionParamsMapper,
|
internal class RealmSessionParamsStore @Inject constructor(private val mapper: SessionParamsMapper,
|
||||||
@AuthDatabase private val realmConfiguration: RealmConfiguration
|
@AuthDatabase private val realmConfiguration: RealmConfiguration
|
||||||
) : SessionParamsStore {
|
) : SessionParamsStore {
|
||||||
|
@ -23,7 +23,6 @@ import im.vector.matrix.android.api.auth.data.SessionParams
|
|||||||
import im.vector.matrix.android.internal.di.MatrixScope
|
import im.vector.matrix.android.internal.di.MatrixScope
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@MatrixScope
|
|
||||||
internal class SessionParamsMapper @Inject constructor(moshi: Moshi) {
|
internal class SessionParamsMapper @Inject constructor(moshi: Moshi) {
|
||||||
|
|
||||||
private val credentialsAdapter = moshi.adapter(Credentials::class.java)
|
private val credentialsAdapter = moshi.adapter(Credentials::class.java)
|
||||||
|
@ -93,6 +93,8 @@ import kotlin.coroutines.EmptyCoroutineContext
|
|||||||
*/
|
*/
|
||||||
@SessionScope
|
@SessionScope
|
||||||
internal class CryptoManager @Inject constructor(
|
internal class CryptoManager @Inject constructor(
|
||||||
|
// Olm Manager
|
||||||
|
private val olmManager: OlmManager,
|
||||||
// The credentials,
|
// The credentials,
|
||||||
private val credentials: Credentials,
|
private val credentials: Credentials,
|
||||||
private val myDeviceInfoHolder: MyDeviceInfoHolder,
|
private val myDeviceInfoHolder: MyDeviceInfoHolder,
|
||||||
@ -118,8 +120,6 @@ internal class CryptoManager @Inject constructor(
|
|||||||
private val incomingRoomKeyRequestManager: IncomingRoomKeyRequestManager,
|
private val incomingRoomKeyRequestManager: IncomingRoomKeyRequestManager,
|
||||||
//
|
//
|
||||||
private val outgoingRoomKeyRequestManager: OutgoingRoomKeyRequestManager,
|
private val outgoingRoomKeyRequestManager: OutgoingRoomKeyRequestManager,
|
||||||
// Olm Manager
|
|
||||||
private val olmManager: OlmManager,
|
|
||||||
// Actions
|
// Actions
|
||||||
private val setDeviceVerificationAction: SetDeviceVerificationAction,
|
private val setDeviceVerificationAction: SetDeviceVerificationAction,
|
||||||
private val megolmSessionDataImporter: MegolmSessionDataImporter,
|
private val megolmSessionDataImporter: MegolmSessionDataImporter,
|
||||||
|
@ -88,8 +88,8 @@ internal abstract class CryptoModule {
|
|||||||
// Realm configuration, named to avoid clash with main cache realm configuration
|
// Realm configuration, named to avoid clash with main cache realm configuration
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@SessionScope
|
|
||||||
@CryptoDatabase
|
@CryptoDatabase
|
||||||
|
@SessionScope
|
||||||
fun providesRealmConfiguration(context: Context, credentials: Credentials): RealmConfiguration {
|
fun providesRealmConfiguration(context: Context, credentials: Credentials): RealmConfiguration {
|
||||||
return RealmConfiguration.Builder()
|
return RealmConfiguration.Builder()
|
||||||
.directory(File(context.filesDir, credentials.userId.hash()))
|
.directory(File(context.filesDir, credentials.userId.hash()))
|
||||||
@ -102,7 +102,6 @@ internal abstract class CryptoModule {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@SessionScope
|
|
||||||
@CryptoDatabase
|
@CryptoDatabase
|
||||||
fun providesClearCacheTask(@CryptoDatabase realmConfiguration: RealmConfiguration): ClearCacheTask {
|
fun providesClearCacheTask(@CryptoDatabase realmConfiguration: RealmConfiguration): ClearCacheTask {
|
||||||
return RealmClearCacheTask(realmConfiguration)
|
return RealmClearCacheTask(realmConfiguration)
|
||||||
@ -111,7 +110,6 @@ internal abstract class CryptoModule {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@SessionScope
|
|
||||||
fun providesCryptoStore(@CryptoDatabase realmConfiguration: RealmConfiguration, credentials: Credentials): IMXCryptoStore {
|
fun providesCryptoStore(@CryptoDatabase realmConfiguration: RealmConfiguration, credentials: Credentials): IMXCryptoStore {
|
||||||
return RealmCryptoStore(false /* TODO*/,
|
return RealmCryptoStore(false /* TODO*/,
|
||||||
realmConfiguration,
|
realmConfiguration,
|
||||||
@ -142,91 +140,69 @@ internal abstract class CryptoModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindCryptoService(cryptoManager: CryptoManager): CryptoService
|
abstract fun bindCryptoService(cryptoManager: CryptoManager): CryptoService
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindDeleteDeviceTask(deleteDeviceTask: DefaultDeleteDeviceTask): DeleteDeviceTask
|
abstract fun bindDeleteDeviceTask(deleteDeviceTask: DefaultDeleteDeviceTask): DeleteDeviceTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGetDevicesTask(getDevicesTask: DefaultGetDevicesTask): GetDevicesTask
|
abstract fun bindGetDevicesTask(getDevicesTask: DefaultGetDevicesTask): GetDevicesTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindSetDeviceNameTask(getDevicesTask: DefaultSetDeviceNameTask): SetDeviceNameTask
|
abstract fun bindSetDeviceNameTask(getDevicesTask: DefaultSetDeviceNameTask): SetDeviceNameTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindUploadKeysTask(getDevicesTask: DefaultUploadKeysTask): UploadKeysTask
|
abstract fun bindUploadKeysTask(getDevicesTask: DefaultUploadKeysTask): UploadKeysTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindDownloadKeysForUsersTask(downloadKeysForUsers: DefaultDownloadKeysForUsers): DownloadKeysForUsersTask
|
abstract fun bindDownloadKeysForUsersTask(downloadKeysForUsers: DefaultDownloadKeysForUsers): DownloadKeysForUsersTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindCreateKeysBackupVersionTask(createKeysBackupVersionTask: DefaultCreateKeysBackupVersionTask): CreateKeysBackupVersionTask
|
abstract fun bindCreateKeysBackupVersionTask(createKeysBackupVersionTask: DefaultCreateKeysBackupVersionTask): CreateKeysBackupVersionTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindDeleteBackupTask(deleteBackupTask: DefaultDeleteBackupTask): DeleteBackupTask
|
abstract fun bindDeleteBackupTask(deleteBackupTask: DefaultDeleteBackupTask): DeleteBackupTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindDeleteRoomSessionDataTask(deleteRoomSessionDataTask: DefaultDeleteRoomSessionDataTask): DeleteRoomSessionDataTask
|
abstract fun bindDeleteRoomSessionDataTask(deleteRoomSessionDataTask: DefaultDeleteRoomSessionDataTask): DeleteRoomSessionDataTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindDeleteRoomSessionsDataTask(deleteRoomSessionDataTask: DefaultDeleteRoomSessionsDataTask): DeleteRoomSessionsDataTask
|
abstract fun bindDeleteRoomSessionsDataTask(deleteRoomSessionDataTask: DefaultDeleteRoomSessionsDataTask): DeleteRoomSessionsDataTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindDeleteSessionsDataTask(deleteRoomSessionDataTask: DefaultDeleteSessionsDataTask): DeleteSessionsDataTask
|
abstract fun bindDeleteSessionsDataTask(deleteRoomSessionDataTask: DefaultDeleteSessionsDataTask): DeleteSessionsDataTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGetKeysBackupLastVersionTask(getKeysBackupLastVersionTask: DefaultGetKeysBackupLastVersionTask): GetKeysBackupLastVersionTask
|
abstract fun bindGetKeysBackupLastVersionTask(getKeysBackupLastVersionTask: DefaultGetKeysBackupLastVersionTask): GetKeysBackupLastVersionTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGetKeysBackupVersionTask(getKeysBackupVersionTask: DefaultGetKeysBackupVersionTask) : GetKeysBackupVersionTask
|
abstract fun bindGetKeysBackupVersionTask(getKeysBackupVersionTask: DefaultGetKeysBackupVersionTask) : GetKeysBackupVersionTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGetRoomSessionDataTask(getRoomSessionDataTask: DefaultGetRoomSessionDataTask) : GetRoomSessionDataTask
|
abstract fun bindGetRoomSessionDataTask(getRoomSessionDataTask: DefaultGetRoomSessionDataTask) : GetRoomSessionDataTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGetRoomSessionsDataTask(getRoomSessionDataTask: DefaultGetRoomSessionsDataTask) : GetRoomSessionsDataTask
|
abstract fun bindGetRoomSessionsDataTask(getRoomSessionDataTask: DefaultGetRoomSessionsDataTask) : GetRoomSessionsDataTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGetSessionsDataTask(getRoomSessionDataTask: DefaultGetSessionsDataTask) : GetSessionsDataTask
|
abstract fun bindGetSessionsDataTask(getRoomSessionDataTask: DefaultGetSessionsDataTask) : GetSessionsDataTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindStoreRoomSessionDataTask(storeRoomSessionDataTask: DefaultStoreRoomSessionDataTask) : StoreRoomSessionDataTask
|
abstract fun bindStoreRoomSessionDataTask(storeRoomSessionDataTask: DefaultStoreRoomSessionDataTask) : StoreRoomSessionDataTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindStoreRoomSessionsDataTask(storeRoomSessionDataTask: DefaultStoreRoomSessionsDataTask) : StoreRoomSessionsDataTask
|
abstract fun bindStoreRoomSessionsDataTask(storeRoomSessionDataTask: DefaultStoreRoomSessionsDataTask) : StoreRoomSessionsDataTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindStoreSessionsDataTask(storeRoomSessionDataTask: DefaultStoreSessionsDataTask) : StoreSessionsDataTask
|
abstract fun bindStoreSessionsDataTask(storeRoomSessionDataTask: DefaultStoreSessionsDataTask) : StoreSessionsDataTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindUpdateKeysBackupVersionTask(updateKeysBackupVersionTask: DefaultUpdateKeysBackupVersionTask) : UpdateKeysBackupVersionTask
|
abstract fun bindUpdateKeysBackupVersionTask(updateKeysBackupVersionTask: DefaultUpdateKeysBackupVersionTask) : UpdateKeysBackupVersionTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindSendToDeviceTask(sendToDeviceTask: DefaultSendToDeviceTask) : SendToDeviceTask
|
abstract fun bindSendToDeviceTask(sendToDeviceTask: DefaultSendToDeviceTask) : SendToDeviceTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindClaimOneTimeKeysForUsersDeviceTask(claimOneTimeKeysForUsersDevice: DefaultClaimOneTimeKeysForUsersDevice) : ClaimOneTimeKeysForUsersDeviceTask
|
abstract fun bindClaimOneTimeKeysForUsersDeviceTask(claimOneTimeKeysForUsersDevice: DefaultClaimOneTimeKeysForUsersDevice) : ClaimOneTimeKeysForUsersDeviceTask
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ import java.util.*
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
// Legacy name: MXDeviceList
|
// Legacy name: MXDeviceList
|
||||||
|
|
||||||
@SessionScope
|
@SessionScope
|
||||||
internal class DeviceListManager @Inject constructor(private val cryptoStore: IMXCryptoStore,
|
internal class DeviceListManager @Inject constructor(private val cryptoStore: IMXCryptoStore,
|
||||||
private val olmDevice: MXOlmDevice,
|
private val olmDevice: MXOlmDevice,
|
||||||
|
@ -21,7 +21,6 @@ import im.vector.matrix.android.internal.session.SessionScope
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class ObjectSigner @Inject constructor(private val credentials: Credentials,
|
internal class ObjectSigner @Inject constructor(private val credentials: Credentials,
|
||||||
private val olmDevice: MXOlmDevice) {
|
private val olmDevice: MXOlmDevice) {
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ import timber.log.Timber
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class EnsureOlmSessionsForDevicesAction @Inject constructor(private val olmDevice: MXOlmDevice,
|
internal class EnsureOlmSessionsForDevicesAction @Inject constructor(private val olmDevice: MXOlmDevice,
|
||||||
private val oneTimeKeysForUsersDeviceTask: ClaimOneTimeKeysForUsersDeviceTask) {
|
private val oneTimeKeysForUsersDeviceTask: ClaimOneTimeKeysForUsersDeviceTask) {
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ import timber.log.Timber
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class EnsureOlmSessionsForUsersAction @Inject constructor(private val olmDevice: MXOlmDevice,
|
internal class EnsureOlmSessionsForUsersAction @Inject constructor(private val olmDevice: MXOlmDevice,
|
||||||
private val cryptoStore: IMXCryptoStore,
|
private val cryptoStore: IMXCryptoStore,
|
||||||
private val ensureOlmSessionsForDevicesAction: EnsureOlmSessionsForDevicesAction) {
|
private val ensureOlmSessionsForDevicesAction: EnsureOlmSessionsForDevicesAction) {
|
||||||
|
@ -30,7 +30,6 @@ import im.vector.matrix.android.internal.session.SessionScope
|
|||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class MegolmSessionDataImporter @Inject constructor(private val olmDevice: MXOlmDevice,
|
internal class MegolmSessionDataImporter @Inject constructor(private val olmDevice: MXOlmDevice,
|
||||||
private val roomDecryptorProvider: RoomDecryptorProvider,
|
private val roomDecryptorProvider: RoomDecryptorProvider,
|
||||||
private val outgoingRoomKeyRequestManager: OutgoingRoomKeyRequestManager,
|
private val outgoingRoomKeyRequestManager: OutgoingRoomKeyRequestManager,
|
||||||
|
@ -29,7 +29,6 @@ import timber.log.Timber
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class MessageEncrypter @Inject constructor(private val credentials: Credentials,
|
internal class MessageEncrypter @Inject constructor(private val credentials: Credentials,
|
||||||
private val olmDevice: MXOlmDevice) {
|
private val olmDevice: MXOlmDevice) {
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import im.vector.matrix.android.internal.session.SessionScope
|
|||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class SetDeviceVerificationAction @Inject constructor(private val cryptoStore: IMXCryptoStore,
|
internal class SetDeviceVerificationAction @Inject constructor(private val cryptoStore: IMXCryptoStore,
|
||||||
private val credentials: Credentials,
|
private val credentials: Credentials,
|
||||||
private val keysBackup: KeysBackup) {
|
private val keysBackup: KeysBackup) {
|
||||||
|
@ -28,7 +28,6 @@ import im.vector.matrix.android.internal.session.SessionScope
|
|||||||
import im.vector.matrix.android.internal.util.MatrixCoroutineDispatchers
|
import im.vector.matrix.android.internal.util.MatrixCoroutineDispatchers
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class MXMegolmDecryptionFactory @Inject constructor(private val credentials: Credentials,
|
internal class MXMegolmDecryptionFactory @Inject constructor(private val credentials: Credentials,
|
||||||
private val olmDevice: MXOlmDevice,
|
private val olmDevice: MXOlmDevice,
|
||||||
private val deviceListManager: DeviceListManager,
|
private val deviceListManager: DeviceListManager,
|
||||||
|
@ -29,7 +29,6 @@ import im.vector.matrix.android.internal.session.SessionScope
|
|||||||
import im.vector.matrix.android.internal.task.TaskExecutor
|
import im.vector.matrix.android.internal.task.TaskExecutor
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class MXMegolmEncryptionFactory @Inject constructor(
|
internal class MXMegolmEncryptionFactory @Inject constructor(
|
||||||
private val olmDevice: MXOlmDevice,
|
private val olmDevice: MXOlmDevice,
|
||||||
private val keysBackup: KeysBackup,
|
private val keysBackup: KeysBackup,
|
||||||
|
@ -21,7 +21,6 @@ import im.vector.matrix.android.internal.crypto.MXOlmDevice
|
|||||||
import im.vector.matrix.android.internal.session.SessionScope
|
import im.vector.matrix.android.internal.session.SessionScope
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class MXOlmDecryptionFactory @Inject constructor(private val olmDevice: MXOlmDevice,
|
internal class MXOlmDecryptionFactory @Inject constructor(private val olmDevice: MXOlmDevice,
|
||||||
private val credentials: Credentials) {
|
private val credentials: Credentials) {
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import im.vector.matrix.android.internal.session.SessionScope
|
|||||||
import im.vector.matrix.android.internal.util.MatrixCoroutineDispatchers
|
import im.vector.matrix.android.internal.util.MatrixCoroutineDispatchers
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class MXOlmEncryptionFactory @Inject constructor(private val olmDevice: MXOlmDevice,
|
internal class MXOlmEncryptionFactory @Inject constructor(private val olmDevice: MXOlmDevice,
|
||||||
private val cryptoStore: IMXCryptoStore,
|
private val cryptoStore: IMXCryptoStore,
|
||||||
private val messageEncrypter: MessageEncrypter,
|
private val messageEncrypter: MessageEncrypter,
|
||||||
|
@ -21,13 +21,11 @@ import im.vector.matrix.android.internal.crypto.keysbackup.api.RoomKeysApi
|
|||||||
import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.CreateKeysBackupVersionBody
|
import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.CreateKeysBackupVersionBody
|
||||||
import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.KeysVersion
|
import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.KeysVersion
|
||||||
import im.vector.matrix.android.internal.network.executeRequest
|
import im.vector.matrix.android.internal.network.executeRequest
|
||||||
import im.vector.matrix.android.internal.session.SessionScope
|
|
||||||
import im.vector.matrix.android.internal.task.Task
|
import im.vector.matrix.android.internal.task.Task
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal interface CreateKeysBackupVersionTask : Task<CreateKeysBackupVersionBody, KeysVersion>
|
internal interface CreateKeysBackupVersionTask : Task<CreateKeysBackupVersionBody, KeysVersion>
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultCreateKeysBackupVersionTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultCreateKeysBackupVersionTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: CreateKeysBackupVersionTask {
|
: CreateKeysBackupVersionTask {
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ internal interface DeleteBackupTask : Task<DeleteBackupTask.Params, Unit> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultDeleteBackupTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultDeleteBackupTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: DeleteBackupTask {
|
: DeleteBackupTask {
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ internal interface DeleteRoomSessionDataTask : Task<DeleteRoomSessionDataTask.Pa
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultDeleteRoomSessionDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultDeleteRoomSessionDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: DeleteRoomSessionDataTask {
|
: DeleteRoomSessionDataTask {
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ internal interface DeleteRoomSessionsDataTask : Task<DeleteRoomSessionsDataTask.
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultDeleteRoomSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultDeleteRoomSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: DeleteRoomSessionsDataTask {
|
: DeleteRoomSessionsDataTask {
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ internal interface DeleteSessionsDataTask : Task<DeleteSessionsDataTask.Params,
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultDeleteSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultDeleteSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: DeleteSessionsDataTask {
|
: DeleteSessionsDataTask {
|
||||||
|
|
||||||
|
@ -20,13 +20,11 @@ import arrow.core.Try
|
|||||||
import im.vector.matrix.android.internal.crypto.keysbackup.api.RoomKeysApi
|
import im.vector.matrix.android.internal.crypto.keysbackup.api.RoomKeysApi
|
||||||
import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.KeysVersionResult
|
import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.KeysVersionResult
|
||||||
import im.vector.matrix.android.internal.network.executeRequest
|
import im.vector.matrix.android.internal.network.executeRequest
|
||||||
import im.vector.matrix.android.internal.session.SessionScope
|
|
||||||
import im.vector.matrix.android.internal.task.Task
|
import im.vector.matrix.android.internal.task.Task
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal interface GetKeysBackupLastVersionTask : Task<Unit, KeysVersionResult>
|
internal interface GetKeysBackupLastVersionTask : Task<Unit, KeysVersionResult>
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultGetKeysBackupLastVersionTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultGetKeysBackupLastVersionTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: GetKeysBackupLastVersionTask {
|
: GetKeysBackupLastVersionTask {
|
||||||
|
|
||||||
|
@ -20,13 +20,11 @@ import arrow.core.Try
|
|||||||
import im.vector.matrix.android.internal.crypto.keysbackup.api.RoomKeysApi
|
import im.vector.matrix.android.internal.crypto.keysbackup.api.RoomKeysApi
|
||||||
import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.KeysVersionResult
|
import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.KeysVersionResult
|
||||||
import im.vector.matrix.android.internal.network.executeRequest
|
import im.vector.matrix.android.internal.network.executeRequest
|
||||||
import im.vector.matrix.android.internal.session.SessionScope
|
|
||||||
import im.vector.matrix.android.internal.task.Task
|
import im.vector.matrix.android.internal.task.Task
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal interface GetKeysBackupVersionTask : Task<String, KeysVersionResult>
|
internal interface GetKeysBackupVersionTask : Task<String, KeysVersionResult>
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultGetKeysBackupVersionTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultGetKeysBackupVersionTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: GetKeysBackupVersionTask {
|
: GetKeysBackupVersionTask {
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ internal interface GetRoomSessionDataTask : Task<GetRoomSessionDataTask.Params,
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultGetRoomSessionDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultGetRoomSessionDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: GetRoomSessionDataTask {
|
: GetRoomSessionDataTask {
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ internal interface GetRoomSessionsDataTask : Task<GetRoomSessionsDataTask.Params
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultGetRoomSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultGetRoomSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: GetRoomSessionsDataTask {
|
: GetRoomSessionsDataTask {
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ internal interface GetSessionsDataTask : Task<GetSessionsDataTask.Params, KeysBa
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultGetSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultGetSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: GetSessionsDataTask {
|
: GetSessionsDataTask {
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ internal interface StoreRoomSessionDataTask : Task<StoreRoomSessionDataTask.Para
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultStoreRoomSessionDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultStoreRoomSessionDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: StoreRoomSessionDataTask {
|
: StoreRoomSessionDataTask {
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ internal interface StoreRoomSessionsDataTask : Task<StoreRoomSessionsDataTask.Pa
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultStoreRoomSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultStoreRoomSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: StoreRoomSessionsDataTask {
|
: StoreRoomSessionsDataTask {
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ internal interface StoreSessionsDataTask : Task<StoreSessionsDataTask.Params, Ba
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultStoreSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultStoreSessionsDataTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: StoreSessionsDataTask {
|
: StoreSessionsDataTask {
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import arrow.core.Try
|
|||||||
import im.vector.matrix.android.internal.crypto.keysbackup.api.RoomKeysApi
|
import im.vector.matrix.android.internal.crypto.keysbackup.api.RoomKeysApi
|
||||||
import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.UpdateKeysBackupVersionBody
|
import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.UpdateKeysBackupVersionBody
|
||||||
import im.vector.matrix.android.internal.network.executeRequest
|
import im.vector.matrix.android.internal.network.executeRequest
|
||||||
import im.vector.matrix.android.internal.session.SessionScope
|
|
||||||
import im.vector.matrix.android.internal.task.Task
|
import im.vector.matrix.android.internal.task.Task
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -31,7 +30,6 @@ internal interface UpdateKeysBackupVersionTask : Task<UpdateKeysBackupVersionTas
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultUpdateKeysBackupVersionTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
internal class DefaultUpdateKeysBackupVersionTask @Inject constructor(private val roomKeysApi: RoomKeysApi)
|
||||||
: UpdateKeysBackupVersionTask {
|
: UpdateKeysBackupVersionTask {
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import im.vector.matrix.android.internal.crypto.store.db.model.*
|
|||||||
import im.vector.matrix.android.internal.crypto.store.db.query.delete
|
import im.vector.matrix.android.internal.crypto.store.db.query.delete
|
||||||
import im.vector.matrix.android.internal.crypto.store.db.query.getById
|
import im.vector.matrix.android.internal.crypto.store.db.query.getById
|
||||||
import im.vector.matrix.android.internal.crypto.store.db.query.getOrCreate
|
import im.vector.matrix.android.internal.crypto.store.db.query.getOrCreate
|
||||||
|
import im.vector.matrix.android.internal.session.SessionScope
|
||||||
import io.realm.RealmConfiguration
|
import io.realm.RealmConfiguration
|
||||||
import io.realm.Sort
|
import io.realm.Sort
|
||||||
import io.realm.kotlin.where
|
import io.realm.kotlin.where
|
||||||
@ -38,6 +39,7 @@ import timber.log.Timber
|
|||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
|
|
||||||
// enableFileEncryption is used to migrate the previous store
|
// enableFileEncryption is used to migrate the previous store
|
||||||
|
@SessionScope
|
||||||
internal class RealmCryptoStore(private val enableFileEncryption: Boolean = false,
|
internal class RealmCryptoStore(private val enableFileEncryption: Boolean = false,
|
||||||
private val realmConfiguration: RealmConfiguration,
|
private val realmConfiguration: RealmConfiguration,
|
||||||
private val credentials: Credentials) : IMXCryptoStore {
|
private val credentials: Credentials) : IMXCryptoStore {
|
||||||
|
@ -36,7 +36,6 @@ internal interface ClaimOneTimeKeysForUsersDeviceTask : Task<ClaimOneTimeKeysFor
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultClaimOneTimeKeysForUsersDevice @Inject constructor(private val cryptoApi: CryptoApi)
|
internal class DefaultClaimOneTimeKeysForUsersDevice @Inject constructor(private val cryptoApi: CryptoApi)
|
||||||
: ClaimOneTimeKeysForUsersDeviceTask {
|
: ClaimOneTimeKeysForUsersDeviceTask {
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ internal interface DeleteDeviceTask : Task<DeleteDeviceTask.Params, Unit> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultDeleteDeviceTask @Inject constructor(private val cryptoApi: CryptoApi)
|
internal class DefaultDeleteDeviceTask @Inject constructor(private val cryptoApi: CryptoApi)
|
||||||
: DeleteDeviceTask {
|
: DeleteDeviceTask {
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ internal interface DownloadKeysForUsersTask : Task<DownloadKeysForUsersTask.Para
|
|||||||
val token: String?)
|
val token: String?)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultDownloadKeysForUsers @Inject constructor(private val cryptoApi: CryptoApi)
|
internal class DefaultDownloadKeysForUsers @Inject constructor(private val cryptoApi: CryptoApi)
|
||||||
: DownloadKeysForUsersTask {
|
: DownloadKeysForUsersTask {
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
internal interface GetDevicesTask : Task<Unit, DevicesListResponse>
|
internal interface GetDevicesTask : Task<Unit, DevicesListResponse>
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultGetDevicesTask @Inject constructor(private val cryptoApi: CryptoApi)
|
internal class DefaultGetDevicesTask @Inject constructor(private val cryptoApi: CryptoApi)
|
||||||
: GetDevicesTask {
|
: GetDevicesTask {
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ internal interface GetKeyChangesTask : Task<GetKeyChangesTask.Params, KeyChanges
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultGetKeyChangesTask @Inject constructor(private val cryptoApi: CryptoApi)
|
internal class DefaultGetKeyChangesTask @Inject constructor(private val cryptoApi: CryptoApi)
|
||||||
: GetKeyChangesTask {
|
: GetKeyChangesTask {
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ internal interface SendToDeviceTask : Task<SendToDeviceTask.Params, Unit> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultSendToDeviceTask @Inject constructor(private val cryptoApi: CryptoApi)
|
internal class DefaultSendToDeviceTask @Inject constructor(private val cryptoApi: CryptoApi)
|
||||||
: SendToDeviceTask {
|
: SendToDeviceTask {
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ internal interface SetDeviceNameTask : Task<SetDeviceNameTask.Params, Unit> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultSetDeviceNameTask @Inject constructor(private val cryptoApi: CryptoApi)
|
internal class DefaultSetDeviceNameTask @Inject constructor(private val cryptoApi: CryptoApi)
|
||||||
: SetDeviceNameTask {
|
: SetDeviceNameTask {
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ internal interface UploadKeysTask : Task<UploadKeysTask.Params, KeysUploadRespon
|
|||||||
val deviceId: String)
|
val deviceId: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultUploadKeysTask @Inject constructor(private val cryptoApi: CryptoApi)
|
internal class DefaultUploadKeysTask @Inject constructor(private val cryptoApi: CryptoApi)
|
||||||
: UploadKeysTask {
|
: UploadKeysTask {
|
||||||
|
|
||||||
|
@ -29,12 +29,12 @@ import im.vector.matrix.android.internal.network.NetworkConnectivityChecker
|
|||||||
import im.vector.matrix.android.internal.task.TaskExecutor
|
import im.vector.matrix.android.internal.task.TaskExecutor
|
||||||
import im.vector.matrix.android.internal.util.BackgroundDetectionObserver
|
import im.vector.matrix.android.internal.util.BackgroundDetectionObserver
|
||||||
import im.vector.matrix.android.internal.util.MatrixCoroutineDispatchers
|
import im.vector.matrix.android.internal.util.MatrixCoroutineDispatchers
|
||||||
import im.vector.matrix.android.internal.worker.WorkerBindingModule
|
import okhttp3.OkHttpClient
|
||||||
import org.matrix.olm.OlmManager
|
import org.matrix.olm.OlmManager
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
|
|
||||||
|
|
||||||
@Component(modules = [MatrixModule::class, NetworkModule::class, AuthModule::class, WorkerBindingModule::class])
|
@Component(modules = [MatrixModule::class, NetworkModule::class, AuthModule::class])
|
||||||
@MatrixScope
|
@MatrixScope
|
||||||
internal interface MatrixComponent {
|
internal interface MatrixComponent {
|
||||||
|
|
||||||
@ -44,6 +44,8 @@ internal interface MatrixComponent {
|
|||||||
|
|
||||||
fun retrofitBuilder(): Retrofit.Builder
|
fun retrofitBuilder(): Retrofit.Builder
|
||||||
|
|
||||||
|
fun okHttpClient(): OkHttpClient
|
||||||
|
|
||||||
fun authenticator(): Authenticator
|
fun authenticator(): Authenticator
|
||||||
|
|
||||||
fun context(): Context
|
fun context(): Context
|
||||||
|
@ -31,7 +31,6 @@ internal object MatrixModule {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@MatrixScope
|
|
||||||
fun providesMatrixCoroutineDispatchers(): MatrixCoroutineDispatchers {
|
fun providesMatrixCoroutineDispatchers(): MatrixCoroutineDispatchers {
|
||||||
val cryptoHandler = CryptoAsyncHelper.getDecryptBackgroundHandler()
|
val cryptoHandler = CryptoAsyncHelper.getDecryptBackgroundHandler()
|
||||||
return MatrixCoroutineDispatchers(io = Dispatchers.IO,
|
return MatrixCoroutineDispatchers(io = Dispatchers.IO,
|
||||||
@ -43,7 +42,6 @@ internal object MatrixModule {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@MatrixScope
|
|
||||||
fun providesResources(context: Context): Resources {
|
fun providesResources(context: Context): Resources {
|
||||||
return context.resources
|
return context.resources
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ import java.util.concurrent.TimeUnit
|
|||||||
@Module
|
@Module
|
||||||
internal object NetworkModule {
|
internal object NetworkModule {
|
||||||
|
|
||||||
@MatrixScope
|
|
||||||
@Provides
|
@Provides
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun providesHttpLogingInterceptor(): HttpLoggingInterceptor {
|
fun providesHttpLogingInterceptor(): HttpLoggingInterceptor {
|
||||||
@ -46,21 +45,18 @@ internal object NetworkModule {
|
|||||||
return interceptor
|
return interceptor
|
||||||
}
|
}
|
||||||
|
|
||||||
@MatrixScope
|
|
||||||
@Provides
|
@Provides
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun providesOkReplayInterceptor(): OkReplayInterceptor {
|
fun providesOkReplayInterceptor(): OkReplayInterceptor {
|
||||||
return OkReplayInterceptor()
|
return OkReplayInterceptor()
|
||||||
}
|
}
|
||||||
|
|
||||||
@MatrixScope
|
|
||||||
@Provides
|
@Provides
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun providesStethoInterceptor(): StethoInterceptor {
|
fun providesStethoInterceptor(): StethoInterceptor {
|
||||||
return StethoInterceptor()
|
return StethoInterceptor()
|
||||||
}
|
}
|
||||||
|
|
||||||
@MatrixScope
|
|
||||||
@Provides
|
@Provides
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun providesCurlLoggingInterceptor(): CurlLoggingInterceptor {
|
fun providesCurlLoggingInterceptor(): CurlLoggingInterceptor {
|
||||||
@ -93,14 +89,12 @@ internal object NetworkModule {
|
|||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
@MatrixScope
|
|
||||||
@Provides
|
@Provides
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun providesMoshi(): Moshi {
|
fun providesMoshi(): Moshi {
|
||||||
return MoshiProvider.providesMoshi()
|
return MoshiProvider.providesMoshi()
|
||||||
}
|
}
|
||||||
|
|
||||||
@MatrixScope
|
|
||||||
@Provides
|
@Provides
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun providesRetrofitBuilder(okHttpClient: OkHttpClient,
|
fun providesRetrofitBuilder(okHttpClient: OkHttpClient,
|
||||||
|
@ -22,7 +22,6 @@ import okhttp3.Interceptor
|
|||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@MatrixScope
|
|
||||||
internal class AccessTokenInterceptor @Inject constructor(private val sessionParamsStore: SessionParamsStore) : Interceptor {
|
internal class AccessTokenInterceptor @Inject constructor(private val sessionParamsStore: SessionParamsStore) : Interceptor {
|
||||||
|
|
||||||
override fun intercept(chain: Interceptor.Chain): Response {
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
|
@ -21,7 +21,6 @@ import okhttp3.Interceptor
|
|||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@MatrixScope
|
|
||||||
internal class UserAgentInterceptor @Inject constructor(private val userAgentHolder: UserAgentHolder) : Interceptor {
|
internal class UserAgentInterceptor @Inject constructor(private val userAgentHolder: UserAgentHolder) : Interceptor {
|
||||||
|
|
||||||
override fun intercept(chain: Interceptor.Chain): Response {
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
|
@ -143,13 +143,9 @@ internal class DefaultSession @Inject constructor(override val sessionParams: Se
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun contentUrlResolver(): ContentUrlResolver {
|
override fun contentUrlResolver() = contentUrlResolver
|
||||||
return contentUrlResolver
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun contentUploadProgressTracker(): ContentUploadStateTracker {
|
override fun contentUploadProgressTracker() = contentUploadProgressTracker
|
||||||
return contentUploadProgressTracker
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun addListener(listener: Session.Listener) {
|
override fun addListener(listener: Session.Listener) {
|
||||||
sessionListeners.addListener(listener)
|
sessionListeners.addListener(listener)
|
||||||
|
@ -21,13 +21,18 @@ import dagger.Component
|
|||||||
import im.vector.matrix.android.api.auth.data.SessionParams
|
import im.vector.matrix.android.api.auth.data.SessionParams
|
||||||
import im.vector.matrix.android.api.session.Session
|
import im.vector.matrix.android.api.session.Session
|
||||||
import im.vector.matrix.android.internal.crypto.CryptoModule
|
import im.vector.matrix.android.internal.crypto.CryptoModule
|
||||||
import im.vector.matrix.android.internal.di.MatrixAssistedModule
|
|
||||||
import im.vector.matrix.android.internal.di.MatrixComponent
|
import im.vector.matrix.android.internal.di.MatrixComponent
|
||||||
import im.vector.matrix.android.internal.session.cache.CacheModule
|
import im.vector.matrix.android.internal.session.cache.CacheModule
|
||||||
import im.vector.matrix.android.internal.session.content.ContentModule
|
import im.vector.matrix.android.internal.session.content.ContentModule
|
||||||
|
import im.vector.matrix.android.internal.session.content.UploadContentWorker
|
||||||
import im.vector.matrix.android.internal.session.filter.FilterModule
|
import im.vector.matrix.android.internal.session.filter.FilterModule
|
||||||
|
import im.vector.matrix.android.internal.session.group.GetGroupDataWorker
|
||||||
import im.vector.matrix.android.internal.session.group.GroupModule
|
import im.vector.matrix.android.internal.session.group.GroupModule
|
||||||
import im.vector.matrix.android.internal.session.room.RoomModule
|
import im.vector.matrix.android.internal.session.room.RoomModule
|
||||||
|
import im.vector.matrix.android.internal.session.room.relation.SendRelationWorker
|
||||||
|
import im.vector.matrix.android.internal.session.room.send.EncryptEventWorker
|
||||||
|
import im.vector.matrix.android.internal.session.room.send.RedactEventWorker
|
||||||
|
import im.vector.matrix.android.internal.session.room.send.SendEventWorker
|
||||||
import im.vector.matrix.android.internal.session.signout.SignOutModule
|
import im.vector.matrix.android.internal.session.signout.SignOutModule
|
||||||
import im.vector.matrix.android.internal.session.sync.SyncModule
|
import im.vector.matrix.android.internal.session.sync.SyncModule
|
||||||
import im.vector.matrix.android.internal.session.user.UserModule
|
import im.vector.matrix.android.internal.session.user.UserModule
|
||||||
@ -44,8 +49,7 @@ import im.vector.matrix.android.internal.session.user.UserModule
|
|||||||
GroupModule::class,
|
GroupModule::class,
|
||||||
ContentModule::class,
|
ContentModule::class,
|
||||||
CacheModule::class,
|
CacheModule::class,
|
||||||
CryptoModule::class,
|
CryptoModule::class
|
||||||
MatrixAssistedModule::class
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@SessionScope
|
@SessionScope
|
||||||
@ -53,6 +57,19 @@ internal interface SessionComponent {
|
|||||||
|
|
||||||
fun session(): Session
|
fun session(): Session
|
||||||
|
|
||||||
|
fun inject(sendEventWorker: SendEventWorker)
|
||||||
|
|
||||||
|
fun inject(sendEventWorker: SendRelationWorker)
|
||||||
|
|
||||||
|
fun inject(encryptEventWorker: EncryptEventWorker)
|
||||||
|
|
||||||
|
fun inject(redactEventWorker: RedactEventWorker)
|
||||||
|
|
||||||
|
fun inject(getGroupDataWorker: GetGroupDataWorker)
|
||||||
|
|
||||||
|
fun inject(uploadContentWorker: UploadContentWorker)
|
||||||
|
|
||||||
|
|
||||||
@Component.Factory
|
@Component.Factory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
fun create(
|
fun create(
|
||||||
|
@ -46,7 +46,6 @@ internal abstract class SessionModule {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@SessionScope
|
|
||||||
fun providesHomeServerConnectionConfig(sessionParams: SessionParams): HomeServerConnectionConfig {
|
fun providesHomeServerConnectionConfig(sessionParams: SessionParams): HomeServerConnectionConfig {
|
||||||
return sessionParams.homeServerConnectionConfig
|
return sessionParams.homeServerConnectionConfig
|
||||||
}
|
}
|
||||||
@ -54,15 +53,14 @@ internal abstract class SessionModule {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@SessionScope
|
|
||||||
fun providesCredentials(sessionParams: SessionParams): Credentials {
|
fun providesCredentials(sessionParams: SessionParams): Credentials {
|
||||||
return sessionParams.credentials
|
return sessionParams.credentials
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@SessionScope
|
|
||||||
@SessionDatabase
|
@SessionDatabase
|
||||||
|
@SessionScope
|
||||||
fun providesRealmConfiguration(sessionParams: SessionParams, context: Context): RealmConfiguration {
|
fun providesRealmConfiguration(sessionParams: SessionParams, context: Context): RealmConfiguration {
|
||||||
val childPath = sessionParams.credentials.userId.md5()
|
val childPath = sessionParams.credentials.userId.md5()
|
||||||
val directory = File(context.filesDir, childPath)
|
val directory = File(context.filesDir, childPath)
|
||||||
@ -96,27 +94,22 @@ internal abstract class SessionModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindSession(session: DefaultSession): Session
|
abstract fun bindSession(session: DefaultSession): Session
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@IntoSet
|
@IntoSet
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGroupSummaryUpdater(groupSummaryUpdater: GroupSummaryUpdater): LiveEntityObserver
|
abstract fun bindGroupSummaryUpdater(groupSummaryUpdater: GroupSummaryUpdater): LiveEntityObserver
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@IntoSet
|
@IntoSet
|
||||||
@SessionScope
|
|
||||||
abstract fun bindEventsPruner(eventsPruner: EventsPruner): LiveEntityObserver
|
abstract fun bindEventsPruner(eventsPruner: EventsPruner): LiveEntityObserver
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@IntoSet
|
@IntoSet
|
||||||
@SessionScope
|
|
||||||
abstract fun bindEventRelationsAggregationUpdater(groupSummaryUpdater: EventRelationsAggregationUpdater): LiveEntityObserver
|
abstract fun bindEventRelationsAggregationUpdater(groupSummaryUpdater: EventRelationsAggregationUpdater): LiveEntityObserver
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@IntoSet
|
@IntoSet
|
||||||
@SessionScope
|
|
||||||
abstract fun bindUserEntityUpdater(groupSummaryUpdater: UserEntityUpdater): LiveEntityObserver
|
abstract fun bindUserEntityUpdater(groupSummaryUpdater: UserEntityUpdater): LiveEntityObserver
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ internal abstract class CacheModule {
|
|||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@SessionScope
|
|
||||||
@SessionDatabase
|
@SessionDatabase
|
||||||
fun providesClearCacheTask(@SessionDatabase realmConfiguration: RealmConfiguration): ClearCacheTask {
|
fun providesClearCacheTask(@SessionDatabase realmConfiguration: RealmConfiguration): ClearCacheTask {
|
||||||
return RealmClearCacheTask(realmConfiguration)
|
return RealmClearCacheTask(realmConfiguration)
|
||||||
@ -41,7 +40,6 @@ internal abstract class CacheModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindCacheService(cacheService: DefaultCacheService): CacheService
|
abstract fun bindCacheService(cacheService: DefaultCacheService): CacheService
|
||||||
|
|
||||||
}
|
}
|
@ -26,7 +26,6 @@ import javax.inject.Named
|
|||||||
|
|
||||||
internal interface ClearCacheTask : Task<Unit, Unit>
|
internal interface ClearCacheTask : Task<Unit, Unit>
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class RealmClearCacheTask @Inject constructor(private val realmConfiguration: RealmConfiguration) : ClearCacheTask {
|
internal class RealmClearCacheTask @Inject constructor(private val realmConfiguration: RealmConfiguration) : ClearCacheTask {
|
||||||
|
|
||||||
override suspend fun execute(params: Unit): Try<Unit> {
|
override suspend fun execute(params: Unit): Try<Unit> {
|
||||||
|
@ -24,7 +24,6 @@ import im.vector.matrix.android.internal.task.TaskExecutor
|
|||||||
import im.vector.matrix.android.internal.task.configureWith
|
import im.vector.matrix.android.internal.task.configureWith
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultCacheService @Inject constructor(@SessionDatabase private val clearCacheTask: ClearCacheTask,
|
internal class DefaultCacheService @Inject constructor(@SessionDatabase private val clearCacheTask: ClearCacheTask,
|
||||||
private val taskExecutor: TaskExecutor) : CacheService {
|
private val taskExecutor: TaskExecutor) : CacheService {
|
||||||
|
|
||||||
|
@ -26,10 +26,8 @@ import im.vector.matrix.android.internal.session.SessionScope
|
|||||||
internal abstract class ContentModule {
|
internal abstract class ContentModule {
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindContentUploadStateTracker(contentUploadStateTracker: DefaultContentUploadStateTracker): ContentUploadStateTracker
|
abstract fun bindContentUploadStateTracker(contentUploadStateTracker: DefaultContentUploadStateTracker): ContentUploadStateTracker
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindContentUrlResolver(contentUrlResolver: DefaultContentUrlResolver): ContentUrlResolver
|
abstract fun bindContentUrlResolver(contentUrlResolver: DefaultContentUrlResolver): ContentUrlResolver
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package im.vector.matrix.android.internal.session.content
|
|||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import im.vector.matrix.android.api.session.content.ContentUploadStateTracker
|
import im.vector.matrix.android.api.session.content.ContentUploadStateTracker
|
||||||
|
import im.vector.matrix.android.internal.di.MatrixScope
|
||||||
import im.vector.matrix.android.internal.session.SessionScope
|
import im.vector.matrix.android.internal.session.SessionScope
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import javax.inject.Inject
|
|||||||
private const val MATRIX_CONTENT_URI_SCHEME = "mxc://"
|
private const val MATRIX_CONTENT_URI_SCHEME = "mxc://"
|
||||||
private const val URI_PREFIX_CONTENT_API = "_matrix/media/v1/"
|
private const val URI_PREFIX_CONTENT_API = "_matrix/media/v1/"
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultContentUrlResolver @Inject constructor(private val homeServerConnectionConfig: HomeServerConnectionConfig) : ContentUrlResolver {
|
internal class DefaultContentUrlResolver @Inject constructor(private val homeServerConnectionConfig: HomeServerConnectionConfig) : ContentUrlResolver {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -29,7 +29,6 @@ import java.io.IOException
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class FileUploader @Inject constructor(private val okHttpClient: OkHttpClient,
|
internal class FileUploader @Inject constructor(private val okHttpClient: OkHttpClient,
|
||||||
private val sessionParams: SessionParams,
|
private val sessionParams: SessionParams,
|
||||||
private val moshi: Moshi) {
|
private val moshi: Moshi) {
|
||||||
|
@ -19,7 +19,6 @@ package im.vector.matrix.android.internal.session.content
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.work.CoroutineWorker
|
import androidx.work.CoroutineWorker
|
||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
import com.squareup.inject.assisted.Assisted
|
|
||||||
import com.squareup.inject.assisted.AssistedInject
|
import com.squareup.inject.assisted.AssistedInject
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import im.vector.matrix.android.api.session.content.ContentAttachmentData
|
import im.vector.matrix.android.api.session.content.ContentAttachmentData
|
||||||
@ -31,32 +30,37 @@ import im.vector.matrix.android.api.session.room.model.message.MessageContent
|
|||||||
import im.vector.matrix.android.api.session.room.model.message.MessageFileContent
|
import im.vector.matrix.android.api.session.room.model.message.MessageFileContent
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageImageContent
|
import im.vector.matrix.android.api.session.room.model.message.MessageImageContent
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageVideoContent
|
import im.vector.matrix.android.api.session.room.model.message.MessageVideoContent
|
||||||
import im.vector.matrix.android.internal.worker.DelegateWorkerFactory
|
|
||||||
import im.vector.matrix.android.internal.network.ProgressRequestBody
|
import im.vector.matrix.android.internal.network.ProgressRequestBody
|
||||||
import im.vector.matrix.android.internal.session.room.send.SendEventWorker
|
import im.vector.matrix.android.internal.session.room.send.SendEventWorker
|
||||||
|
import im.vector.matrix.android.internal.worker.DelegateWorkerFactory
|
||||||
|
import im.vector.matrix.android.internal.worker.SessionWorkerParams
|
||||||
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
||||||
|
import im.vector.matrix.android.internal.worker.getSessionComponent
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
||||||
internal class UploadContentWorker @AssistedInject constructor(
|
internal class UploadContentWorker(context: Context, params: WorkerParameters) : CoroutineWorker(context, params) {
|
||||||
@Assisted context: Context,
|
|
||||||
@Assisted params: WorkerParameters,
|
|
||||||
private val fileUploader: FileUploader,
|
|
||||||
private val contentUploadStateTracker: DefaultContentUploadStateTracker)
|
|
||||||
: CoroutineWorker(context, params) {
|
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
override val userId: String,
|
||||||
val roomId: String,
|
val roomId: String,
|
||||||
val event: Event,
|
val event: Event,
|
||||||
val attachment: ContentAttachmentData
|
val attachment: ContentAttachmentData
|
||||||
)
|
) : SessionWorkerParams
|
||||||
|
|
||||||
|
@Inject lateinit var fileUploader: FileUploader
|
||||||
|
@Inject lateinit var contentUploadStateTracker: DefaultContentUploadStateTracker
|
||||||
|
|
||||||
override suspend fun doWork(): Result {
|
override suspend fun doWork(): Result {
|
||||||
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
||||||
?: return Result.success()
|
?: return Result.success()
|
||||||
|
|
||||||
|
val sessionComponent = getSessionComponent(params.userId) ?: return Result.success()
|
||||||
|
sessionComponent.inject(this)
|
||||||
|
|
||||||
val eventId = params.event.eventId ?: return Result.success()
|
val eventId = params.event.eventId ?: return Result.success()
|
||||||
val attachment = params.attachment
|
val attachment = params.attachment
|
||||||
|
|
||||||
@ -105,7 +109,7 @@ internal class UploadContentWorker @AssistedInject constructor(
|
|||||||
thumbnailUrl: String?): Result {
|
thumbnailUrl: String?): Result {
|
||||||
contentUploadStateTracker.setSuccess(params.event.eventId!!)
|
contentUploadStateTracker.setSuccess(params.event.eventId!!)
|
||||||
val event = updateEvent(params.event, attachmentUrl, thumbnailUrl)
|
val event = updateEvent(params.event, attachmentUrl, thumbnailUrl)
|
||||||
val sendParams = SendEventWorker.Params(params.roomId, event)
|
val sendParams = SendEventWorker.Params(params.userId, params.roomId, event)
|
||||||
return Result.success(WorkerParamsFactory.toData(sendParams))
|
return Result.success(WorkerParamsFactory.toData(sendParams))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,8 +141,5 @@ internal class UploadContentWorker @AssistedInject constructor(
|
|||||||
return copy(url = url)
|
return copy(url = url)
|
||||||
}
|
}
|
||||||
|
|
||||||
@AssistedInject.Factory
|
|
||||||
interface Factory : DelegateWorkerFactory
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import io.realm.RealmConfiguration
|
|||||||
import io.realm.kotlin.where
|
import io.realm.kotlin.where
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultFilterRepository @Inject constructor(
|
internal class DefaultFilterRepository @Inject constructor(
|
||||||
@SessionDatabase private val realmConfiguration: RealmConfiguration
|
@SessionDatabase private val realmConfiguration: RealmConfiguration
|
||||||
) : FilterRepository {
|
) : FilterRepository {
|
||||||
|
@ -22,7 +22,6 @@ import im.vector.matrix.android.internal.task.TaskExecutor
|
|||||||
import im.vector.matrix.android.internal.task.configureWith
|
import im.vector.matrix.android.internal.task.configureWith
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultFilterService @Inject constructor(private val filterRepository: FilterRepository,
|
internal class DefaultFilterService @Inject constructor(private val filterRepository: FilterRepository,
|
||||||
private val saveFilterTask: SaveFilterTask,
|
private val saveFilterTask: SaveFilterTask,
|
||||||
private val taskExecutor: TaskExecutor) : FilterService {
|
private val taskExecutor: TaskExecutor) : FilterService {
|
||||||
|
@ -35,7 +35,6 @@ internal interface SaveFilterTask : Task<SaveFilterTask.Params, Unit> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultSaveFilterTask @Inject constructor(private val sessionParams: SessionParams,
|
internal class DefaultSaveFilterTask @Inject constructor(private val sessionParams: SessionParams,
|
||||||
private val filterAPI: FilterApi,
|
private val filterAPI: FilterApi,
|
||||||
private val filterRepository: FilterRepository
|
private val filterRepository: FilterRepository
|
||||||
|
@ -30,24 +30,21 @@ internal abstract class FilterModule {
|
|||||||
|
|
||||||
@Module
|
@Module
|
||||||
companion object {
|
companion object {
|
||||||
@SessionScope
|
|
||||||
@Provides
|
@Provides
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@SessionScope
|
||||||
fun providesFilterApi(retrofit: Retrofit): FilterApi {
|
fun providesFilterApi(retrofit: Retrofit): FilterApi {
|
||||||
return retrofit.create(FilterApi::class.java)
|
return retrofit.create(FilterApi::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindFilterRepository(filterRepository: DefaultFilterRepository): FilterRepository
|
abstract fun bindFilterRepository(filterRepository: DefaultFilterRepository): FilterRepository
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindFilterService(filterService: DefaultFilterService): FilterService
|
abstract fun bindFilterService(filterService: DefaultFilterService): FilterService
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindSaveFilterTask(saveFilterTask_Factory: DefaultSaveFilterTask): SaveFilterTask
|
abstract fun bindSaveFilterTask(saveFilterTask_Factory: DefaultSaveFilterTask): SaveFilterTask
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ internal interface GetGroupDataTask : Task<GetGroupDataTask.Params, Unit> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultGetGroupDataTask @Inject constructor(
|
internal class DefaultGetGroupDataTask @Inject constructor(
|
||||||
private val groupAPI: GroupAPI,
|
private val groupAPI: GroupAPI,
|
||||||
private val monarchy: Monarchy
|
private val monarchy: Monarchy
|
||||||
|
@ -28,7 +28,6 @@ import im.vector.matrix.android.internal.database.query.where
|
|||||||
import im.vector.matrix.android.internal.session.SessionScope
|
import im.vector.matrix.android.internal.session.SessionScope
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultGroupService @Inject constructor(private val monarchy: Monarchy) : GroupService {
|
internal class DefaultGroupService @Inject constructor(private val monarchy: Monarchy) : GroupService {
|
||||||
|
|
||||||
override fun getGroup(groupId: String): Group? {
|
override fun getGroup(groupId: String): Group? {
|
||||||
|
@ -24,26 +24,28 @@ import com.squareup.inject.assisted.Assisted
|
|||||||
import com.squareup.inject.assisted.AssistedInject
|
import com.squareup.inject.assisted.AssistedInject
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import im.vector.matrix.android.internal.worker.DelegateWorkerFactory
|
import im.vector.matrix.android.internal.worker.DelegateWorkerFactory
|
||||||
|
import im.vector.matrix.android.internal.worker.SessionWorkerParams
|
||||||
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
||||||
|
import im.vector.matrix.android.internal.worker.getSessionComponent
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class GetGroupDataWorker @AssistedInject constructor(
|
internal class GetGroupDataWorker (context: Context, params: WorkerParameters) : CoroutineWorker(context, params) {
|
||||||
@Assisted context: Context,
|
|
||||||
@Assisted params: WorkerParameters,
|
|
||||||
private val getGroupDataTask: GetGroupDataTask
|
|
||||||
) : CoroutineWorker(context, params) {
|
|
||||||
|
|
||||||
@AssistedInject.Factory
|
|
||||||
interface Factory : DelegateWorkerFactory
|
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
override val userId: String,
|
||||||
val groupIds: List<String>
|
val groupIds: List<String>
|
||||||
)
|
): SessionWorkerParams
|
||||||
|
|
||||||
|
@Inject lateinit var getGroupDataTask: GetGroupDataTask
|
||||||
|
|
||||||
override suspend fun doWork(): Result {
|
override suspend fun doWork(): Result {
|
||||||
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
||||||
?: return Result.failure()
|
?: return Result.failure()
|
||||||
|
|
||||||
|
val sessionComponent = getSessionComponent(params.userId) ?: return Result.success()
|
||||||
|
sessionComponent.inject(this)
|
||||||
|
|
||||||
val results = params.groupIds.map { groupId ->
|
val results = params.groupIds.map { groupId ->
|
||||||
fetchGroupData(groupId)
|
fetchGroupData(groupId)
|
||||||
}
|
}
|
||||||
|
@ -28,19 +28,17 @@ internal abstract class GroupModule {
|
|||||||
|
|
||||||
@Module
|
@Module
|
||||||
companion object {
|
companion object {
|
||||||
@SessionScope
|
|
||||||
@Provides
|
@Provides
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@SessionScope
|
||||||
fun providesGroupAPI(retrofit: Retrofit): GroupAPI {
|
fun providesGroupAPI(retrofit: Retrofit): GroupAPI {
|
||||||
return retrofit.create(GroupAPI::class.java)
|
return retrofit.create(GroupAPI::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGetGroupDataTask(getGroupDataTask: DefaultGetGroupDataTask): GetGroupDataTask
|
abstract fun bindGetGroupDataTask(getGroupDataTask: DefaultGetGroupDataTask): GetGroupDataTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGroupService(groupService: DefaultGroupService): GroupService
|
abstract fun bindGroupService(groupService: DefaultGroupService): GroupService
|
||||||
}
|
}
|
@ -16,23 +16,25 @@
|
|||||||
|
|
||||||
package im.vector.matrix.android.internal.session.group
|
package im.vector.matrix.android.internal.session.group
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.work.Constraints
|
import androidx.work.Constraints
|
||||||
import androidx.work.ExistingWorkPolicy
|
import androidx.work.ExistingWorkPolicy
|
||||||
import androidx.work.NetworkType
|
import androidx.work.NetworkType
|
||||||
import androidx.work.OneTimeWorkRequestBuilder
|
import androidx.work.OneTimeWorkRequestBuilder
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
|
import im.vector.matrix.android.api.auth.data.Credentials
|
||||||
import im.vector.matrix.android.internal.database.RealmLiveEntityObserver
|
import im.vector.matrix.android.internal.database.RealmLiveEntityObserver
|
||||||
import im.vector.matrix.android.internal.database.model.GroupEntity
|
import im.vector.matrix.android.internal.database.model.GroupEntity
|
||||||
import im.vector.matrix.android.internal.database.query.where
|
import im.vector.matrix.android.internal.database.query.where
|
||||||
import im.vector.matrix.android.internal.session.SessionScope
|
|
||||||
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
private const val GET_GROUP_DATA_WORKER = "GET_GROUP_DATA_WORKER"
|
private const val GET_GROUP_DATA_WORKER = "GET_GROUP_DATA_WORKER"
|
||||||
|
|
||||||
@SessionScope
|
internal class GroupSummaryUpdater @Inject constructor(private val context: Context,
|
||||||
internal class GroupSummaryUpdater @Inject constructor(monarchy: Monarchy) : RealmLiveEntityObserver<GroupEntity>(monarchy) {
|
private val credentials: Credentials,
|
||||||
|
monarchy: Monarchy) : RealmLiveEntityObserver<GroupEntity>(monarchy) {
|
||||||
|
|
||||||
override val query = Monarchy.Query<GroupEntity> { GroupEntity.where(it) }
|
override val query = Monarchy.Query<GroupEntity> { GroupEntity.where(it) }
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ internal class GroupSummaryUpdater @Inject constructor(monarchy: Monarchy) : Rea
|
|||||||
|
|
||||||
override fun processChanges(inserted: List<GroupEntity>, updated: List<GroupEntity>, deleted: List<GroupEntity>) {
|
override fun processChanges(inserted: List<GroupEntity>, updated: List<GroupEntity>, deleted: List<GroupEntity>) {
|
||||||
val newGroupIds = inserted.map { it.groupId }
|
val newGroupIds = inserted.map { it.groupId }
|
||||||
val getGroupDataWorkerParams = GetGroupDataWorker.Params(newGroupIds)
|
val getGroupDataWorkerParams = GetGroupDataWorker.Params(credentials.userId, newGroupIds)
|
||||||
val workData = WorkerParamsFactory.toData(getGroupDataWorkerParams)
|
val workData = WorkerParamsFactory.toData(getGroupDataWorkerParams)
|
||||||
|
|
||||||
val sendWork = OneTimeWorkRequestBuilder<GetGroupDataWorker>()
|
val sendWork = OneTimeWorkRequestBuilder<GetGroupDataWorker>()
|
||||||
@ -50,7 +52,7 @@ internal class GroupSummaryUpdater @Inject constructor(monarchy: Monarchy) : Rea
|
|||||||
.setConstraints(workConstraints)
|
.setConstraints(workConstraints)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
WorkManager.getInstance()
|
WorkManager.getInstance(context)
|
||||||
.beginUniqueWork(GET_GROUP_DATA_WORKER, ExistingWorkPolicy.APPEND, sendWork)
|
.beginUniqueWork(GET_GROUP_DATA_WORKER, ExistingWorkPolicy.APPEND, sendWork)
|
||||||
.enqueue()
|
.enqueue()
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package im.vector.matrix.android.internal.session.room
|
|||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.Transformations
|
import androidx.lifecycle.Transformations
|
||||||
|
import com.squareup.inject.assisted.AssistedInject
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
import im.vector.matrix.android.api.session.crypto.CryptoService
|
import im.vector.matrix.android.api.session.crypto.CryptoService
|
||||||
import im.vector.matrix.android.api.session.room.Room
|
import im.vector.matrix.android.api.session.room.Room
|
||||||
@ -33,12 +34,9 @@ import im.vector.matrix.android.internal.database.mapper.asDomain
|
|||||||
import im.vector.matrix.android.internal.database.model.RoomSummaryEntity
|
import im.vector.matrix.android.internal.database.model.RoomSummaryEntity
|
||||||
import im.vector.matrix.android.internal.database.model.RoomSummaryEntityFields
|
import im.vector.matrix.android.internal.database.model.RoomSummaryEntityFields
|
||||||
import im.vector.matrix.android.internal.database.query.where
|
import im.vector.matrix.android.internal.database.query.where
|
||||||
import im.vector.matrix.android.internal.session.SessionScope
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
internal class DefaultRoom @Inject constructor(override val roomId: String,
|
||||||
internal class DefaultRoom @Inject constructor(
|
|
||||||
override val roomId: String,
|
|
||||||
private val monarchy: Monarchy,
|
private val monarchy: Monarchy,
|
||||||
private val timelineService: TimelineService,
|
private val timelineService: TimelineService,
|
||||||
private val sendService: SendService,
|
private val sendService: SendService,
|
||||||
|
@ -35,7 +35,6 @@ import im.vector.matrix.android.internal.task.configureWith
|
|||||||
import im.vector.matrix.android.internal.util.fetchManaged
|
import im.vector.matrix.android.internal.util.fetchManaged
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultRoomService @Inject constructor(private val monarchy: Monarchy,
|
internal class DefaultRoomService @Inject constructor(private val monarchy: Monarchy,
|
||||||
private val createRoomTask: CreateRoomTask,
|
private val createRoomTask: CreateRoomTask,
|
||||||
private val roomFactory: RoomFactory,
|
private val roomFactory: RoomFactory,
|
||||||
|
@ -28,7 +28,6 @@ import javax.inject.Inject
|
|||||||
* Fetches annotations (reactions, edits...) associated to a given eventEntity from the data layer.
|
* Fetches annotations (reactions, edits...) associated to a given eventEntity from the data layer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class EventRelationExtractor @Inject constructor() {
|
internal class EventRelationExtractor @Inject constructor() {
|
||||||
|
|
||||||
fun extractFrom(event: EventEntity, realm: Realm = event.realm): EventAnnotationsSummary? {
|
fun extractFrom(event: EventEntity, realm: Realm = event.realm): EventAnnotationsSummary? {
|
||||||
|
@ -44,7 +44,6 @@ internal interface EventRelationsAggregationTask : Task<EventRelationsAggregatio
|
|||||||
/**
|
/**
|
||||||
* Called by EventRelationAggregationUpdater, when new events that can affect relations are inserted in base.
|
* Called by EventRelationAggregationUpdater, when new events that can affect relations are inserted in base.
|
||||||
*/
|
*/
|
||||||
@SessionScope
|
|
||||||
internal class DefaultEventRelationsAggregationTask @Inject constructor(private val monarchy: Monarchy) : EventRelationsAggregationTask {
|
internal class DefaultEventRelationsAggregationTask @Inject constructor(private val monarchy: Monarchy) : EventRelationsAggregationTask {
|
||||||
|
|
||||||
//OPT OUT serer aggregation until API mature enough
|
//OPT OUT serer aggregation until API mature enough
|
||||||
|
@ -33,7 +33,6 @@ import javax.inject.Inject
|
|||||||
* The summaries can then be extracted and added (as a decoration) to a TimelineEvent for final display.
|
* The summaries can then be extracted and added (as a decoration) to a TimelineEvent for final display.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class EventRelationsAggregationUpdater @Inject constructor(monarchy: Monarchy,
|
internal class EventRelationsAggregationUpdater @Inject constructor(monarchy: Monarchy,
|
||||||
private val credentials: Credentials,
|
private val credentials: Credentials,
|
||||||
private val task: EventRelationsAggregationTask,
|
private val task: EventRelationsAggregationTask,
|
||||||
|
@ -31,7 +31,6 @@ import im.vector.matrix.android.internal.session.SessionScope
|
|||||||
import im.vector.matrix.android.internal.session.room.membership.RoomMembers
|
import im.vector.matrix.android.internal.session.room.membership.RoomMembers
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class RoomAvatarResolver @Inject constructor(private val monarchy: Monarchy,
|
internal class RoomAvatarResolver @Inject constructor(private val monarchy: Monarchy,
|
||||||
private val credentials: Credentials) {
|
private val credentials: Credentials) {
|
||||||
|
|
||||||
|
@ -16,10 +16,11 @@
|
|||||||
|
|
||||||
package im.vector.matrix.android.internal.session.room
|
package im.vector.matrix.android.internal.session.room
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
|
import im.vector.matrix.android.api.auth.data.Credentials
|
||||||
import im.vector.matrix.android.api.session.crypto.CryptoService
|
import im.vector.matrix.android.api.session.crypto.CryptoService
|
||||||
import im.vector.matrix.android.api.session.room.Room
|
import im.vector.matrix.android.api.session.room.Room
|
||||||
import im.vector.matrix.android.internal.session.SessionScope
|
|
||||||
import im.vector.matrix.android.internal.session.room.membership.DefaultMembershipService
|
import im.vector.matrix.android.internal.session.room.membership.DefaultMembershipService
|
||||||
import im.vector.matrix.android.internal.session.room.membership.LoadRoomMembersTask
|
import im.vector.matrix.android.internal.session.room.membership.LoadRoomMembersTask
|
||||||
import im.vector.matrix.android.internal.session.room.membership.SenderRoomMemberExtractor
|
import im.vector.matrix.android.internal.session.room.membership.SenderRoomMemberExtractor
|
||||||
@ -42,8 +43,9 @@ import im.vector.matrix.android.internal.session.room.timeline.TimelineEventFact
|
|||||||
import im.vector.matrix.android.internal.task.TaskExecutor
|
import im.vector.matrix.android.internal.task.TaskExecutor
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
internal class RoomFactory @Inject constructor(private val context: Context,
|
||||||
internal class RoomFactory @Inject constructor(private val monarchy: Monarchy,
|
private val credentials: Credentials,
|
||||||
|
private val monarchy: Monarchy,
|
||||||
private val eventFactory: LocalEchoEventFactory,
|
private val eventFactory: LocalEchoEventFactory,
|
||||||
private val taskExecutor: TaskExecutor,
|
private val taskExecutor: TaskExecutor,
|
||||||
private val loadRoomMembersTask: LoadRoomMembersTask,
|
private val loadRoomMembersTask: LoadRoomMembersTask,
|
||||||
@ -63,11 +65,11 @@ internal class RoomFactory @Inject constructor(private val monarchy: Monarchy,
|
|||||||
val relationExtractor = EventRelationExtractor()
|
val relationExtractor = EventRelationExtractor()
|
||||||
val timelineEventFactory = TimelineEventFactory(roomMemberExtractor, relationExtractor, cryptoService)
|
val timelineEventFactory = TimelineEventFactory(roomMemberExtractor, relationExtractor, cryptoService)
|
||||||
val timelineService = DefaultTimelineService(roomId, monarchy, taskExecutor, timelineEventFactory, contextOfEventTask, paginationTask)
|
val timelineService = DefaultTimelineService(roomId, monarchy, taskExecutor, timelineEventFactory, contextOfEventTask, paginationTask)
|
||||||
val sendService = DefaultSendService(roomId, eventFactory, cryptoService, monarchy)
|
val sendService = DefaultSendService(context, credentials, roomId, eventFactory, cryptoService, monarchy)
|
||||||
val stateService = DefaultStateService(roomId, taskExecutor, sendStateTask)
|
val stateService = DefaultStateService(roomId, taskExecutor, sendStateTask)
|
||||||
val roomMembersService = DefaultMembershipService(roomId, monarchy, taskExecutor, loadRoomMembersTask, inviteTask, joinRoomTask, leaveRoomTask)
|
val roomMembersService = DefaultMembershipService(roomId, monarchy, taskExecutor, loadRoomMembersTask, inviteTask, joinRoomTask, leaveRoomTask)
|
||||||
val readService = DefaultReadService(roomId, monarchy, taskExecutor, setReadMarkersTask)
|
val readService = DefaultReadService(roomId, monarchy, taskExecutor, setReadMarkersTask)
|
||||||
val reactionService = DefaultRelationService(roomId, eventFactory, findReactionEventForUndoTask, updateQuickReactionTask, monarchy, taskExecutor)
|
val reactionService = DefaultRelationService(context, credentials, roomId, eventFactory, findReactionEventForUndoTask, updateQuickReactionTask, monarchy, taskExecutor)
|
||||||
|
|
||||||
return DefaultRoom(
|
return DefaultRoom(
|
||||||
roomId,
|
roomId,
|
||||||
|
@ -61,104 +61,81 @@ internal abstract class RoomModule {
|
|||||||
|
|
||||||
@Module
|
@Module
|
||||||
companion object {
|
companion object {
|
||||||
@SessionScope
|
|
||||||
@Provides
|
@Provides
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@SessionScope
|
||||||
fun providesRoomAPI(retrofit: Retrofit): RoomAPI {
|
fun providesRoomAPI(retrofit: Retrofit): RoomAPI {
|
||||||
return retrofit.create(RoomAPI::class.java)
|
return retrofit.create(RoomAPI::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindRoomService(roomService: DefaultRoomService): RoomService
|
abstract fun bindRoomService(roomService: DefaultRoomService): RoomService
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindRoomDirectoryService(roomDirectoryService: DefaultRoomDirectoryService): RoomDirectoryService
|
abstract fun bindRoomDirectoryService(roomDirectoryService: DefaultRoomDirectoryService): RoomDirectoryService
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindEventRelationsAggregationTask(eventRelationsAggregationTask: DefaultEventRelationsAggregationTask): EventRelationsAggregationTask
|
abstract fun bindEventRelationsAggregationTask(eventRelationsAggregationTask: DefaultEventRelationsAggregationTask): EventRelationsAggregationTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindCreateRoomTask(createRoomTask: DefaultCreateRoomTask): CreateRoomTask
|
abstract fun bindCreateRoomTask(createRoomTask: DefaultCreateRoomTask): CreateRoomTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGetPublicRoomTask(getPublicRoomTask: DefaultGetPublicRoomTask): GetPublicRoomTask
|
abstract fun bindGetPublicRoomTask(getPublicRoomTask: DefaultGetPublicRoomTask): GetPublicRoomTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGetThirdPartyProtocolsTask(getThirdPartyProtocolsTask: DefaultGetThirdPartyProtocolsTask): GetThirdPartyProtocolsTask
|
abstract fun bindGetThirdPartyProtocolsTask(getThirdPartyProtocolsTask: DefaultGetThirdPartyProtocolsTask): GetThirdPartyProtocolsTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindInviteTask(inviteTask: DefaultInviteTask): InviteTask
|
abstract fun bindInviteTask(inviteTask: DefaultInviteTask): InviteTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindJoinRoomTask(joinRoomTask: DefaultJoinRoomTask): JoinRoomTask
|
abstract fun bindJoinRoomTask(joinRoomTask: DefaultJoinRoomTask): JoinRoomTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindLeaveRoomTask(leaveRoomTask: DefaultLeaveRoomTask): LeaveRoomTask
|
abstract fun bindLeaveRoomTask(leaveRoomTask: DefaultLeaveRoomTask): LeaveRoomTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindMembershipService(membershipService: DefaultMembershipService): MembershipService
|
abstract fun bindMembershipService(membershipService: DefaultMembershipService): MembershipService
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindLoadRoomMembersTask(loadRoomMembersTask: DefaultLoadRoomMembersTask): LoadRoomMembersTask
|
abstract fun bindLoadRoomMembersTask(loadRoomMembersTask: DefaultLoadRoomMembersTask): LoadRoomMembersTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindPruneEventTask(pruneEventTask: DefaultPruneEventTask): PruneEventTask
|
abstract fun bindPruneEventTask(pruneEventTask: DefaultPruneEventTask): PruneEventTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindReadService(readService: DefaultReadService): ReadService
|
abstract fun bindReadService(readService: DefaultReadService): ReadService
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindSetReadMarkersTask(setReadMarkersTask: DefaultSetReadMarkersTask): SetReadMarkersTask
|
abstract fun bindSetReadMarkersTask(setReadMarkersTask: DefaultSetReadMarkersTask): SetReadMarkersTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindRelationService(relationService: DefaultRelationService): RelationService
|
abstract fun bindRelationService(relationService: DefaultRelationService): RelationService
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindFindReactionEventForUndoTask(findReactionEventForUndoTask: DefaultFindReactionEventForUndoTask): FindReactionEventForUndoTask
|
abstract fun bindFindReactionEventForUndoTask(findReactionEventForUndoTask: DefaultFindReactionEventForUndoTask): FindReactionEventForUndoTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindUpdateQuickReactionTask(updateQuickReactionTask: DefaultUpdateQuickReactionTask): UpdateQuickReactionTask
|
abstract fun bindUpdateQuickReactionTask(updateQuickReactionTask: DefaultUpdateQuickReactionTask): UpdateQuickReactionTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindSendStateTask(sendStateTask: DefaultSendStateTask): SendStateTask
|
abstract fun bindSendStateTask(sendStateTask: DefaultSendStateTask): SendStateTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindSendService(sendService: DefaultSendService): SendService
|
abstract fun bindSendService(sendService: DefaultSendService): SendService
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindStateService(stateService: DefaultStateService): StateService
|
abstract fun bindStateService(stateService: DefaultStateService): StateService
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindGetContextOfEventTask(getContextOfEventTask: DefaultGetContextOfEventTask): GetContextOfEventTask
|
abstract fun bindGetContextOfEventTask(getContextOfEventTask: DefaultGetContextOfEventTask): GetContextOfEventTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindPaginationTask(paginationTask: DefaultPaginationTask): PaginationTask
|
abstract fun bindPaginationTask(paginationTask: DefaultPaginationTask): PaginationTask
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@SessionScope
|
|
||||||
abstract fun bindTimelineService(timelineService: DefaultTimelineService): TimelineService
|
abstract fun bindTimelineService(timelineService: DefaultTimelineService): TimelineService
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ import io.realm.Realm
|
|||||||
import io.realm.kotlin.createObject
|
import io.realm.kotlin.createObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class RoomSummaryUpdater @Inject constructor(private val credentials: Credentials,
|
internal class RoomSummaryUpdater @Inject constructor(private val credentials: Credentials,
|
||||||
private val roomDisplayNameResolver: RoomDisplayNameResolver,
|
private val roomDisplayNameResolver: RoomDisplayNameResolver,
|
||||||
private val roomAvatarResolver: RoomAvatarResolver) {
|
private val roomAvatarResolver: RoomAvatarResolver) {
|
||||||
|
@ -32,7 +32,6 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
internal interface CreateRoomTask : Task<CreateRoomParams, String>
|
internal interface CreateRoomTask : Task<CreateRoomParams, String>
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultCreateRoomTask @Inject constructor(private val roomAPI: RoomAPI,
|
internal class DefaultCreateRoomTask @Inject constructor(private val roomAPI: RoomAPI,
|
||||||
@SessionDatabase private val realmConfiguration: RealmConfiguration) : CreateRoomTask {
|
@SessionDatabase private val realmConfiguration: RealmConfiguration) : CreateRoomTask {
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ internal interface GetPublicRoomTask : Task<GetPublicRoomTask.Params, PublicRoom
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultGetPublicRoomTask @Inject constructor(private val roomAPI: RoomAPI) : GetPublicRoomTask {
|
internal class DefaultGetPublicRoomTask @Inject constructor(private val roomAPI: RoomAPI) : GetPublicRoomTask {
|
||||||
|
|
||||||
override suspend fun execute(params: GetPublicRoomTask.Params): Try<PublicRoomsResponse> {
|
override suspend fun execute(params: GetPublicRoomTask.Params): Try<PublicRoomsResponse> {
|
||||||
|
@ -26,7 +26,6 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
internal interface GetThirdPartyProtocolsTask : Task<Unit, Map<String, ThirdPartyProtocol>>
|
internal interface GetThirdPartyProtocolsTask : Task<Unit, Map<String, ThirdPartyProtocol>>
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultGetThirdPartyProtocolsTask @Inject constructor (private val roomAPI: RoomAPI) : GetThirdPartyProtocolsTask {
|
internal class DefaultGetThirdPartyProtocolsTask @Inject constructor (private val roomAPI: RoomAPI) : GetThirdPartyProtocolsTask {
|
||||||
|
|
||||||
override suspend fun execute(params: Unit): Try<Map<String, ThirdPartyProtocol>> {
|
override suspend fun execute(params: Unit): Try<Map<String, ThirdPartyProtocol>> {
|
||||||
|
@ -36,7 +36,6 @@ import im.vector.matrix.android.internal.task.configureWith
|
|||||||
import im.vector.matrix.android.internal.util.fetchCopied
|
import im.vector.matrix.android.internal.util.fetchCopied
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultMembershipService @Inject constructor(private val roomId: String,
|
internal class DefaultMembershipService @Inject constructor(private val roomId: String,
|
||||||
private val monarchy: Monarchy,
|
private val monarchy: Monarchy,
|
||||||
private val taskExecutor: TaskExecutor,
|
private val taskExecutor: TaskExecutor,
|
||||||
|
@ -40,7 +40,6 @@ internal interface LoadRoomMembersTask : Task<LoadRoomMembersTask.Params, Boolea
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultLoadRoomMembersTask @Inject constructor(private val roomAPI: RoomAPI,
|
internal class DefaultLoadRoomMembersTask @Inject constructor(private val roomAPI: RoomAPI,
|
||||||
private val monarchy: Monarchy,
|
private val monarchy: Monarchy,
|
||||||
private val syncTokenStore: SyncTokenStore,
|
private val syncTokenStore: SyncTokenStore,
|
||||||
|
@ -31,8 +31,9 @@ import im.vector.matrix.android.internal.database.query.where
|
|||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.RealmList
|
import io.realm.RealmList
|
||||||
import io.realm.RealmQuery
|
import io.realm.RealmQuery
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class SenderRoomMemberExtractor(private val roomId: String) {
|
internal class SenderRoomMemberExtractor @Inject constructor(private val roomId: String) {
|
||||||
|
|
||||||
fun extractFrom(event: EventEntity, realm: Realm = event.realm): RoomMember? {
|
fun extractFrom(event: EventEntity, realm: Realm = event.realm): RoomMember? {
|
||||||
val sender = event.sender ?: return null
|
val sender = event.sender ?: return null
|
||||||
|
@ -31,7 +31,6 @@ internal interface InviteTask : Task<InviteTask.Params, Unit> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultInviteTask @Inject constructor(private val roomAPI: RoomAPI) : InviteTask {
|
internal class DefaultInviteTask @Inject constructor(private val roomAPI: RoomAPI) : InviteTask {
|
||||||
|
|
||||||
override suspend fun execute(params: InviteTask.Params): Try<Unit> {
|
override suspend fun execute(params: InviteTask.Params): Try<Unit> {
|
||||||
|
@ -29,7 +29,6 @@ internal interface JoinRoomTask : Task<JoinRoomTask.Params, Unit> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultJoinRoomTask @Inject constructor(private val roomAPI: RoomAPI) : JoinRoomTask {
|
internal class DefaultJoinRoomTask @Inject constructor(private val roomAPI: RoomAPI) : JoinRoomTask {
|
||||||
|
|
||||||
override suspend fun execute(params: JoinRoomTask.Params): Try<Unit> {
|
override suspend fun execute(params: JoinRoomTask.Params): Try<Unit> {
|
||||||
|
@ -29,7 +29,6 @@ internal interface LeaveRoomTask : Task<LeaveRoomTask.Params, Unit> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultLeaveRoomTask @Inject constructor(private val roomAPI: RoomAPI) : LeaveRoomTask {
|
internal class DefaultLeaveRoomTask @Inject constructor(private val roomAPI: RoomAPI) : LeaveRoomTask {
|
||||||
|
|
||||||
override suspend fun execute(params: LeaveRoomTask.Params): Try<Unit> {
|
override suspend fun execute(params: LeaveRoomTask.Params): Try<Unit> {
|
||||||
|
@ -33,7 +33,6 @@ import javax.inject.Inject
|
|||||||
* Listens to the database for the insertion of any redaction event.
|
* Listens to the database for the insertion of any redaction event.
|
||||||
* As it will actually delete the content, it should be called last in the list of listener.
|
* As it will actually delete the content, it should be called last in the list of listener.
|
||||||
*/
|
*/
|
||||||
@SessionScope
|
|
||||||
internal class EventsPruner @Inject constructor(monarchy: Monarchy,
|
internal class EventsPruner @Inject constructor(monarchy: Monarchy,
|
||||||
private val credentials: Credentials,
|
private val credentials: Credentials,
|
||||||
private val pruneEventTask: PruneEventTask,
|
private val pruneEventTask: PruneEventTask,
|
||||||
|
@ -43,7 +43,6 @@ internal interface PruneEventTask : Task<PruneEventTask.Params, Unit> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultPruneEventTask @Inject constructor(private val monarchy: Monarchy) : PruneEventTask {
|
internal class DefaultPruneEventTask @Inject constructor(private val monarchy: Monarchy) : PruneEventTask {
|
||||||
|
|
||||||
override suspend fun execute(params: PruneEventTask.Params): Try<Unit> {
|
override suspend fun execute(params: PruneEventTask.Params): Try<Unit> {
|
||||||
|
@ -27,7 +27,6 @@ import im.vector.matrix.android.internal.task.configureWith
|
|||||||
import im.vector.matrix.android.internal.util.fetchCopied
|
import im.vector.matrix.android.internal.util.fetchCopied
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultReadService @Inject constructor(private val roomId: String,
|
internal class DefaultReadService @Inject constructor(private val roomId: String,
|
||||||
private val monarchy: Monarchy,
|
private val monarchy: Monarchy,
|
||||||
private val taskExecutor: TaskExecutor,
|
private val taskExecutor: TaskExecutor,
|
||||||
|
@ -47,7 +47,6 @@ internal interface SetReadMarkersTask : Task<SetReadMarkersTask.Params, Unit> {
|
|||||||
private const val READ_MARKER = "m.fully_read"
|
private const val READ_MARKER = "m.fully_read"
|
||||||
private const val READ_RECEIPT = "m.read"
|
private const val READ_RECEIPT = "m.read"
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultSetReadMarkersTask @Inject constructor(private val roomAPI: RoomAPI,
|
internal class DefaultSetReadMarkersTask @Inject constructor(private val roomAPI: RoomAPI,
|
||||||
private val credentials: Credentials,
|
private val credentials: Credentials,
|
||||||
private val monarchy: Monarchy
|
private val monarchy: Monarchy
|
||||||
|
@ -15,10 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package im.vector.matrix.android.internal.session.room.relation
|
package im.vector.matrix.android.internal.session.room.relation
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.work.OneTimeWorkRequest
|
import androidx.work.OneTimeWorkRequest
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
import im.vector.matrix.android.api.MatrixCallback
|
import im.vector.matrix.android.api.MatrixCallback
|
||||||
|
import im.vector.matrix.android.api.auth.data.Credentials
|
||||||
import im.vector.matrix.android.api.session.events.model.Event
|
import im.vector.matrix.android.api.session.events.model.Event
|
||||||
import im.vector.matrix.android.api.session.room.model.EventAnnotationsSummary
|
import im.vector.matrix.android.api.session.room.model.EventAnnotationsSummary
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageType
|
import im.vector.matrix.android.api.session.room.model.message.MessageType
|
||||||
@ -38,11 +40,14 @@ import im.vector.matrix.android.internal.session.room.timeline.TimelineSendEvent
|
|||||||
import im.vector.matrix.android.internal.task.TaskExecutor
|
import im.vector.matrix.android.internal.task.TaskExecutor
|
||||||
import im.vector.matrix.android.internal.task.configureWith
|
import im.vector.matrix.android.internal.task.configureWith
|
||||||
import im.vector.matrix.android.internal.util.CancelableWork
|
import im.vector.matrix.android.internal.util.CancelableWork
|
||||||
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
|
||||||
import im.vector.matrix.android.internal.util.tryTransactionAsync
|
import im.vector.matrix.android.internal.util.tryTransactionAsync
|
||||||
|
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class DefaultRelationService constructor(private val roomId: String,
|
internal class DefaultRelationService @Inject constructor(private val context: Context,
|
||||||
|
private val credentials: Credentials,
|
||||||
|
private val roomId: String,
|
||||||
private val eventFactory: LocalEchoEventFactory,
|
private val eventFactory: LocalEchoEventFactory,
|
||||||
private val findReactionEventForUndoTask: FindReactionEventForUndoTask,
|
private val findReactionEventForUndoTask: FindReactionEventForUndoTask,
|
||||||
private val updateQuickReactionTask: UpdateQuickReactionTask,
|
private val updateQuickReactionTask: UpdateQuickReactionTask,
|
||||||
@ -57,14 +62,13 @@ internal class DefaultRelationService constructor(private val roomId: String,
|
|||||||
saveLocalEcho(it)
|
saveLocalEcho(it)
|
||||||
}
|
}
|
||||||
val sendRelationWork = createSendRelationWork(event)
|
val sendRelationWork = createSendRelationWork(event)
|
||||||
TimelineSendEventWorkCommon.postWork(roomId, sendRelationWork)
|
TimelineSendEventWorkCommon.postWork(context, roomId, sendRelationWork)
|
||||||
return CancelableWork(sendRelationWork.id)
|
return CancelableWork(context, sendRelationWork.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun createSendRelationWork(event: Event): OneTimeWorkRequest {
|
private fun createSendRelationWork(event: Event): OneTimeWorkRequest {
|
||||||
val sendContentWorkerParams = SendEventWorker.Params(
|
val sendContentWorkerParams = SendEventWorker.Params(credentials.userId,roomId, event)
|
||||||
roomId, event)
|
|
||||||
val sendWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
val sendWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
||||||
|
|
||||||
return TimelineSendEventWorkCommon.createWork<SendEventWorker>(sendWorkData)
|
return TimelineSendEventWorkCommon.createWork<SendEventWorker>(sendWorkData)
|
||||||
@ -94,7 +98,7 @@ internal class DefaultRelationService constructor(private val roomId: String,
|
|||||||
}
|
}
|
||||||
val redactWork = createRedactEventWork(redactEvent, toRedact, null)
|
val redactWork = createRedactEventWork(redactEvent, toRedact, null)
|
||||||
|
|
||||||
TimelineSendEventWorkCommon.postWork(roomId, redactWork)
|
TimelineSendEventWorkCommon.postWork(context, roomId, redactWork)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,7 +127,7 @@ internal class DefaultRelationService constructor(private val roomId: String,
|
|||||||
saveLocalEcho(it)
|
saveLocalEcho(it)
|
||||||
}
|
}
|
||||||
val redactWork = createRedactEventWork(redactEvent, it, null)
|
val redactWork = createRedactEventWork(redactEvent, it, null)
|
||||||
TimelineSendEventWorkCommon.postWork(roomId, redactWork)
|
TimelineSendEventWorkCommon.postWork(context, roomId, redactWork)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -137,7 +141,7 @@ internal class DefaultRelationService constructor(private val roomId: String,
|
|||||||
//TODO duplicate with send service?
|
//TODO duplicate with send service?
|
||||||
private fun createRedactEventWork(localEvent: Event, eventId: String, reason: String?): OneTimeWorkRequest {
|
private fun createRedactEventWork(localEvent: Event, eventId: String, reason: String?): OneTimeWorkRequest {
|
||||||
|
|
||||||
val sendContentWorkerParams = RedactEventWorker.Params(localEvent.eventId!!,
|
val sendContentWorkerParams = RedactEventWorker.Params(credentials.userId ,localEvent.eventId!!,
|
||||||
roomId, eventId, reason)
|
roomId, eventId, reason)
|
||||||
val redactWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
val redactWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
||||||
return TimelineSendEventWorkCommon.createWork<RedactEventWorker>(redactWorkData)
|
return TimelineSendEventWorkCommon.createWork<RedactEventWorker>(redactWorkData)
|
||||||
@ -147,14 +151,14 @@ internal class DefaultRelationService constructor(private val roomId: String,
|
|||||||
val event = eventFactory.createReplaceTextEvent(roomId, targetEventId, newBodyText, newBodyAutoMarkdown, MessageType.MSGTYPE_TEXT, compatibilityBodyText).also {
|
val event = eventFactory.createReplaceTextEvent(roomId, targetEventId, newBodyText, newBodyAutoMarkdown, MessageType.MSGTYPE_TEXT, compatibilityBodyText).also {
|
||||||
saveLocalEcho(it)
|
saveLocalEcho(it)
|
||||||
}
|
}
|
||||||
val sendContentWorkerParams = SendEventWorker.Params(roomId, event)
|
val sendContentWorkerParams = SendEventWorker.Params(credentials.userId ,roomId, event)
|
||||||
val sendWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
val sendWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
||||||
|
|
||||||
//TODO use relation API?
|
//TODO use relation API?
|
||||||
|
|
||||||
val workRequest = TimelineSendEventWorkCommon.createWork<SendEventWorker>(sendWorkData)
|
val workRequest = TimelineSendEventWorkCommon.createWork<SendEventWorker>(sendWorkData)
|
||||||
TimelineSendEventWorkCommon.postWork(roomId, workRequest)
|
TimelineSendEventWorkCommon.postWork(context, roomId, workRequest)
|
||||||
return CancelableWork(workRequest.id)
|
return CancelableWork(context, workRequest.id)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,13 +167,13 @@ internal class DefaultRelationService constructor(private val roomId: String,
|
|||||||
val event = eventFactory.createReplyTextEvent(roomId, eventReplied, replyText)?.also {
|
val event = eventFactory.createReplyTextEvent(roomId, eventReplied, replyText)?.also {
|
||||||
saveLocalEcho(it)
|
saveLocalEcho(it)
|
||||||
} ?: return null
|
} ?: return null
|
||||||
val sendContentWorkerParams = SendEventWorker.Params(roomId, event)
|
val sendContentWorkerParams = SendEventWorker.Params(credentials.userId ,roomId, event)
|
||||||
val sendWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
val sendWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
||||||
|
|
||||||
|
|
||||||
val workRequest = TimelineSendEventWorkCommon.createWork<SendEventWorker>(sendWorkData)
|
val workRequest = TimelineSendEventWorkCommon.createWork<SendEventWorker>(sendWorkData)
|
||||||
TimelineSendEventWorkCommon.postWork(roomId, workRequest)
|
TimelineSendEventWorkCommon.postWork(context, roomId, workRequest)
|
||||||
return CancelableWork(workRequest.id)
|
return CancelableWork(context, workRequest.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ internal interface FindReactionEventForUndoTask : Task<FindReactionEventForUndoT
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultFindReactionEventForUndoTask @Inject constructor(private val monarchy: Monarchy) : FindReactionEventForUndoTask {
|
internal class DefaultFindReactionEventForUndoTask @Inject constructor(private val monarchy: Monarchy) : FindReactionEventForUndoTask {
|
||||||
|
|
||||||
override suspend fun execute(params: FindReactionEventForUndoTask.Params): Try<FindReactionEventForUndoTask.Result> {
|
override suspend fun execute(params: FindReactionEventForUndoTask.Params): Try<FindReactionEventForUndoTask.Result> {
|
||||||
|
@ -18,7 +18,6 @@ package im.vector.matrix.android.internal.session.room.relation
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.work.Worker
|
import androidx.work.Worker
|
||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
import com.squareup.inject.assisted.Assisted
|
|
||||||
import com.squareup.inject.assisted.AssistedInject
|
import com.squareup.inject.assisted.AssistedInject
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import im.vector.matrix.android.api.failure.Failure
|
import im.vector.matrix.android.api.failure.Failure
|
||||||
@ -26,30 +25,34 @@ import im.vector.matrix.android.api.session.events.model.Event
|
|||||||
import im.vector.matrix.android.api.session.events.model.toModel
|
import im.vector.matrix.android.api.session.events.model.toModel
|
||||||
import im.vector.matrix.android.api.session.room.model.relation.ReactionContent
|
import im.vector.matrix.android.api.session.room.model.relation.ReactionContent
|
||||||
import im.vector.matrix.android.api.session.room.model.relation.ReactionInfo
|
import im.vector.matrix.android.api.session.room.model.relation.ReactionInfo
|
||||||
import im.vector.matrix.android.internal.worker.DelegateWorkerFactory
|
|
||||||
import im.vector.matrix.android.internal.network.executeRequest
|
import im.vector.matrix.android.internal.network.executeRequest
|
||||||
import im.vector.matrix.android.internal.session.room.RoomAPI
|
import im.vector.matrix.android.internal.session.room.RoomAPI
|
||||||
import im.vector.matrix.android.internal.session.room.send.SendResponse
|
import im.vector.matrix.android.internal.session.room.send.SendResponse
|
||||||
|
import im.vector.matrix.android.internal.worker.DelegateWorkerFactory
|
||||||
|
import im.vector.matrix.android.internal.worker.SessionWorkerParams
|
||||||
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
||||||
|
import im.vector.matrix.android.internal.worker.getSessionComponent
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class SendRelationWorker @AssistedInject constructor(
|
internal class SendRelationWorker(context: Context, params: WorkerParameters): Worker(context, params) {
|
||||||
@Assisted context: Context,
|
|
||||||
@Assisted params: WorkerParameters,
|
|
||||||
private val roomAPI: RoomAPI)
|
|
||||||
: Worker(context, params) {
|
|
||||||
|
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
override val userId: String,
|
||||||
val roomId: String,
|
val roomId: String,
|
||||||
val event: Event,
|
val event: Event,
|
||||||
val relationType: String? = null
|
val relationType: String? = null
|
||||||
)
|
): SessionWorkerParams
|
||||||
|
|
||||||
|
@Inject lateinit var roomAPI: RoomAPI
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
||||||
?: return Result.failure()
|
?: return Result.failure()
|
||||||
|
|
||||||
|
val sessionComponent = getSessionComponent(params.userId) ?: return Result.success()
|
||||||
|
sessionComponent.inject(this)
|
||||||
|
|
||||||
val localEvent = params.event
|
val localEvent = params.event
|
||||||
if (localEvent.eventId == null) {
|
if (localEvent.eventId == null) {
|
||||||
return Result.failure()
|
return Result.failure()
|
||||||
@ -81,6 +84,4 @@ internal class SendRelationWorker @AssistedInject constructor(
|
|||||||
}, { Result.success() })
|
}, { Result.success() })
|
||||||
}
|
}
|
||||||
|
|
||||||
@AssistedInject.Factory
|
|
||||||
interface Factory : DelegateWorkerFactory
|
|
||||||
}
|
}
|
@ -43,7 +43,6 @@ internal interface UpdateQuickReactionTask : Task<UpdateQuickReactionTask.Params
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SessionScope
|
|
||||||
internal class DefaultUpdateQuickReactionTask @Inject constructor(private val monarchy: Monarchy) : UpdateQuickReactionTask {
|
internal class DefaultUpdateQuickReactionTask @Inject constructor(private val monarchy: Monarchy) : UpdateQuickReactionTask {
|
||||||
override suspend fun execute(params: UpdateQuickReactionTask.Params): Try<UpdateQuickReactionTask.Result> {
|
override suspend fun execute(params: UpdateQuickReactionTask.Params): Try<UpdateQuickReactionTask.Result> {
|
||||||
return Try {
|
return Try {
|
||||||
|
@ -16,8 +16,16 @@
|
|||||||
|
|
||||||
package im.vector.matrix.android.internal.session.room.send
|
package im.vector.matrix.android.internal.session.room.send
|
||||||
|
|
||||||
import androidx.work.*
|
import android.content.Context
|
||||||
|
import androidx.work.BackoffPolicy
|
||||||
|
import androidx.work.Constraints
|
||||||
|
import androidx.work.ExistingWorkPolicy
|
||||||
|
import androidx.work.NetworkType
|
||||||
|
import androidx.work.OneTimeWorkRequest
|
||||||
|
import androidx.work.OneTimeWorkRequestBuilder
|
||||||
|
import androidx.work.WorkManager
|
||||||
import com.zhuinden.monarchy.Monarchy
|
import com.zhuinden.monarchy.Monarchy
|
||||||
|
import im.vector.matrix.android.api.auth.data.Credentials
|
||||||
import im.vector.matrix.android.api.session.content.ContentAttachmentData
|
import im.vector.matrix.android.api.session.content.ContentAttachmentData
|
||||||
import im.vector.matrix.android.api.session.crypto.CryptoService
|
import im.vector.matrix.android.api.session.crypto.CryptoService
|
||||||
import im.vector.matrix.android.api.session.events.model.Event
|
import im.vector.matrix.android.api.session.events.model.Event
|
||||||
@ -31,6 +39,7 @@ import im.vector.matrix.android.internal.util.CancelableWork
|
|||||||
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
private const val UPLOAD_WORK = "UPLOAD_WORK"
|
private const val UPLOAD_WORK = "UPLOAD_WORK"
|
||||||
private const val BACKOFF_DELAY = 10_000L
|
private const val BACKOFF_DELAY = 10_000L
|
||||||
@ -39,7 +48,9 @@ private val WORK_CONSTRAINTS = Constraints.Builder()
|
|||||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
internal class DefaultSendService(private val roomId: String,
|
internal class DefaultSendService @Inject constructor(private val context: Context,
|
||||||
|
private val credentials: Credentials,
|
||||||
|
private val roomId: String,
|
||||||
private val localEchoEventFactory: LocalEchoEventFactory,
|
private val localEchoEventFactory: LocalEchoEventFactory,
|
||||||
private val cryptoService: CryptoService,
|
private val cryptoService: CryptoService,
|
||||||
private val monarchy: Monarchy)
|
private val monarchy: Monarchy)
|
||||||
@ -54,8 +65,8 @@ internal class DefaultSendService(private val roomId: String,
|
|||||||
Timber.v("Send event in encrypted room")
|
Timber.v("Send event in encrypted room")
|
||||||
val encryptWork = createEncryptEventWork(event)
|
val encryptWork = createEncryptEventWork(event)
|
||||||
val sendWork = createSendEventWork(event)
|
val sendWork = createSendEventWork(event)
|
||||||
TimelineSendEventWorkCommon.postSequentialWorks(roomId, encryptWork, sendWork)
|
TimelineSendEventWorkCommon.postSequentialWorks(context, roomId, encryptWork, sendWork)
|
||||||
CancelableWork(encryptWork.id)
|
CancelableWork(context, encryptWork.id)
|
||||||
} else {
|
} else {
|
||||||
sendEvent(event)
|
sendEvent(event)
|
||||||
}
|
}
|
||||||
@ -63,8 +74,8 @@ internal class DefaultSendService(private val roomId: String,
|
|||||||
|
|
||||||
private fun sendEvent(event: Event): Cancelable {
|
private fun sendEvent(event: Event): Cancelable {
|
||||||
val sendWork = createSendEventWork(event)
|
val sendWork = createSendEventWork(event)
|
||||||
TimelineSendEventWorkCommon.postWork(roomId, sendWork)
|
TimelineSendEventWorkCommon.postWork(context, roomId, sendWork)
|
||||||
return CancelableWork(sendWork.id)
|
return CancelableWork(context, sendWork.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sendFormattedTextMessage(text: String, formattedText: String): Cancelable {
|
override fun sendFormattedTextMessage(text: String, formattedText: String): Cancelable {
|
||||||
@ -72,8 +83,8 @@ internal class DefaultSendService(private val roomId: String,
|
|||||||
saveLocalEcho(it)
|
saveLocalEcho(it)
|
||||||
}
|
}
|
||||||
val sendWork = createSendEventWork(event)
|
val sendWork = createSendEventWork(event)
|
||||||
TimelineSendEventWorkCommon.postWork(roomId, sendWork)
|
TimelineSendEventWorkCommon.postWork(context, roomId, sendWork)
|
||||||
return CancelableWork(sendWork.id)
|
return CancelableWork(context, sendWork.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sendMedias(attachments: List<ContentAttachmentData>): Cancelable {
|
override fun sendMedias(attachments: List<ContentAttachmentData>): Cancelable {
|
||||||
@ -87,8 +98,8 @@ internal class DefaultSendService(private val roomId: String,
|
|||||||
override fun redactEvent(event: Event, reason: String?): Cancelable {
|
override fun redactEvent(event: Event, reason: String?): Cancelable {
|
||||||
//TODO manage media/attachements?
|
//TODO manage media/attachements?
|
||||||
val redactWork = createRedactEventWork(event, reason)
|
val redactWork = createRedactEventWork(event, reason)
|
||||||
TimelineSendEventWorkCommon.postWork(roomId, redactWork)
|
TimelineSendEventWorkCommon.postWork(context, roomId, redactWork)
|
||||||
return CancelableWork(redactWork.id)
|
return CancelableWork(context, redactWork.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sendMedia(attachment: ContentAttachmentData): Cancelable {
|
override fun sendMedia(attachment: ContentAttachmentData): Cancelable {
|
||||||
@ -99,12 +110,12 @@ internal class DefaultSendService(private val roomId: String,
|
|||||||
val uploadWork = createUploadMediaWork(event, attachment)
|
val uploadWork = createUploadMediaWork(event, attachment)
|
||||||
val sendWork = createSendEventWork(event)
|
val sendWork = createSendEventWork(event)
|
||||||
|
|
||||||
WorkManager.getInstance()
|
WorkManager.getInstance(context)
|
||||||
.beginUniqueWork(buildWorkIdentifier(UPLOAD_WORK), ExistingWorkPolicy.APPEND, uploadWork)
|
.beginUniqueWork(buildWorkIdentifier(UPLOAD_WORK), ExistingWorkPolicy.APPEND, uploadWork)
|
||||||
.then(sendWork)
|
.then(sendWork)
|
||||||
.enqueue()
|
.enqueue()
|
||||||
|
|
||||||
return CancelableWork(sendWork.id)
|
return CancelableWork(context, sendWork.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveLocalEcho(event: Event) {
|
private fun saveLocalEcho(event: Event) {
|
||||||
@ -117,7 +128,7 @@ internal class DefaultSendService(private val roomId: String,
|
|||||||
|
|
||||||
private fun createEncryptEventWork(event: Event): OneTimeWorkRequest {
|
private fun createEncryptEventWork(event: Event): OneTimeWorkRequest {
|
||||||
// Same parameter
|
// Same parameter
|
||||||
val params = EncryptEventWorker.Params(roomId, event)
|
val params = EncryptEventWorker.Params(credentials.userId ,roomId, event)
|
||||||
val sendWorkData = WorkerParamsFactory.toData(params)
|
val sendWorkData = WorkerParamsFactory.toData(params)
|
||||||
|
|
||||||
return OneTimeWorkRequestBuilder<EncryptEventWorker>()
|
return OneTimeWorkRequestBuilder<EncryptEventWorker>()
|
||||||
@ -128,7 +139,7 @@ internal class DefaultSendService(private val roomId: String,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createSendEventWork(event: Event): OneTimeWorkRequest {
|
private fun createSendEventWork(event: Event): OneTimeWorkRequest {
|
||||||
val sendContentWorkerParams = SendEventWorker.Params(roomId, event)
|
val sendContentWorkerParams = SendEventWorker.Params(credentials.userId ,roomId, event)
|
||||||
val sendWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
val sendWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
||||||
|
|
||||||
return TimelineSendEventWorkCommon.createWork<SendEventWorker>(sendWorkData)
|
return TimelineSendEventWorkCommon.createWork<SendEventWorker>(sendWorkData)
|
||||||
@ -138,13 +149,13 @@ internal class DefaultSendService(private val roomId: String,
|
|||||||
val redactEvent = localEchoEventFactory.createRedactEvent(roomId, event.eventId!!, reason).also {
|
val redactEvent = localEchoEventFactory.createRedactEvent(roomId, event.eventId!!, reason).also {
|
||||||
saveLocalEcho(it)
|
saveLocalEcho(it)
|
||||||
}
|
}
|
||||||
val sendContentWorkerParams = RedactEventWorker.Params(redactEvent.eventId!!, roomId, event.eventId, reason)
|
val sendContentWorkerParams = RedactEventWorker.Params(credentials.userId ,redactEvent.eventId!!, roomId, event.eventId, reason)
|
||||||
val redactWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
val redactWorkData = WorkerParamsFactory.toData(sendContentWorkerParams)
|
||||||
return TimelineSendEventWorkCommon.createWork<RedactEventWorker>(redactWorkData)
|
return TimelineSendEventWorkCommon.createWork<RedactEventWorker>(redactWorkData)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createUploadMediaWork(event: Event, attachment: ContentAttachmentData): OneTimeWorkRequest {
|
private fun createUploadMediaWork(event: Event, attachment: ContentAttachmentData): OneTimeWorkRequest {
|
||||||
val uploadMediaWorkerParams = UploadContentWorker.Params(roomId, event, attachment)
|
val uploadMediaWorkerParams = UploadContentWorker.Params(credentials.userId ,roomId, event, attachment)
|
||||||
val uploadWorkData = WorkerParamsFactory.toData(uploadMediaWorkerParams)
|
val uploadWorkData = WorkerParamsFactory.toData(uploadMediaWorkerParams)
|
||||||
|
|
||||||
return OneTimeWorkRequestBuilder<UploadContentWorker>()
|
return OneTimeWorkRequestBuilder<UploadContentWorker>()
|
||||||
|
@ -30,27 +30,32 @@ import im.vector.matrix.android.api.session.room.send.SendState
|
|||||||
import im.vector.matrix.android.internal.crypto.model.MXEncryptEventContentResult
|
import im.vector.matrix.android.internal.crypto.model.MXEncryptEventContentResult
|
||||||
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
import im.vector.matrix.android.internal.worker.WorkerParamsFactory
|
||||||
import im.vector.matrix.android.internal.worker.DelegateWorkerFactory
|
import im.vector.matrix.android.internal.worker.DelegateWorkerFactory
|
||||||
|
import im.vector.matrix.android.internal.worker.SessionWorkerParams
|
||||||
|
import im.vector.matrix.android.internal.worker.getSessionComponent
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class EncryptEventWorker @AssistedInject constructor(
|
internal class EncryptEventWorker(context: Context, params: WorkerParameters)
|
||||||
@Assisted context: Context,
|
|
||||||
@Assisted params: WorkerParameters,
|
|
||||||
private val crypto: CryptoService,
|
|
||||||
private val localEchoUpdater: LocalEchoUpdater)
|
|
||||||
: Worker(context, params) {
|
: Worker(context, params) {
|
||||||
|
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
override val userId: String,
|
||||||
val roomId: String,
|
val roomId: String,
|
||||||
val event: Event
|
val event: Event
|
||||||
)
|
): SessionWorkerParams
|
||||||
|
|
||||||
|
@Inject lateinit var crypto: CryptoService
|
||||||
|
@Inject lateinit var localEchoUpdater: LocalEchoUpdater
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
|
|
||||||
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
val params = WorkerParamsFactory.fromData<Params>(inputData)
|
||||||
?: return Result.success()
|
?: return Result.success()
|
||||||
|
|
||||||
|
val sessionComponent = getSessionComponent(params.userId) ?: return Result.success()
|
||||||
|
sessionComponent.inject(this)
|
||||||
|
|
||||||
val localEvent = params.event
|
val localEvent = params.event
|
||||||
if (localEvent.eventId == null) {
|
if (localEvent.eventId == null) {
|
||||||
return Result.success()
|
return Result.success()
|
||||||
@ -87,7 +92,7 @@ internal class EncryptEventWorker @AssistedInject constructor(
|
|||||||
type = safeResult.eventType,
|
type = safeResult.eventType,
|
||||||
content = safeResult.eventContent
|
content = safeResult.eventContent
|
||||||
)
|
)
|
||||||
val nextWorkerParams = SendEventWorker.Params(params.roomId, encryptedEvent)
|
val nextWorkerParams = SendEventWorker.Params(params.userId, params.roomId, encryptedEvent)
|
||||||
return Result.success(WorkerParamsFactory.toData(nextWorkerParams))
|
return Result.success(WorkerParamsFactory.toData(nextWorkerParams))
|
||||||
}
|
}
|
||||||
val safeError = error
|
val safeError = error
|
||||||
@ -99,8 +104,4 @@ internal class EncryptEventWorker @AssistedInject constructor(
|
|||||||
//always return success, or the chain will be stuck for ever!
|
//always return success, or the chain will be stuck for ever!
|
||||||
return Result.success()
|
return Result.success()
|
||||||
}
|
}
|
||||||
|
|
||||||
@AssistedInject.Factory
|
|
||||||
interface Factory : DelegateWorkerFactory
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user