mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-23 22:39:02 +03:00
Integration with old SDK - make it works
This commit is contained in:
parent
108fae2f28
commit
f9e6f4b533
11 changed files with 52 additions and 13 deletions
.idea/caches
app/src/main/java/im/vector/riotredesign/features/login
matrix-sdk-android/src/main/java/im/vector/matrix/android
api/auth/data
internal
di
events/sync
legacy/util
network
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
|
@ -32,6 +32,7 @@ class LoginActivity : RiotActivity() {
|
||||||
val homeServerConnectionConfig = HomeServerConnectionConfig.Builder()
|
val homeServerConnectionConfig = HomeServerConnectionConfig.Builder()
|
||||||
.withHomeServerUri("https://matrix.org/")
|
.withHomeServerUri("https://matrix.org/")
|
||||||
.withIdentityServerUri("https://vector.im")
|
.withIdentityServerUri("https://vector.im")
|
||||||
|
.withAntiVirusServerUri("https://matrix.org/")
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback<Session> {
|
authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback<Session> {
|
||||||
|
|
|
@ -43,7 +43,7 @@ data class HomeServerConnectionConfig(
|
||||||
*/
|
*/
|
||||||
fun withHomeServerUri(hsUri: Uri): Builder {
|
fun withHomeServerUri(hsUri: Uri): Builder {
|
||||||
if (hsUri.scheme != "http" && hsUri.scheme != "https") {
|
if (hsUri.scheme != "http" && hsUri.scheme != "https") {
|
||||||
throw RuntimeException("Invalid home server URI: " + hsUri!!)
|
throw RuntimeException("Invalid home server URI: " + hsUri)
|
||||||
}
|
}
|
||||||
// remove trailing /
|
// remove trailing /
|
||||||
homeServerUri = if (hsUri.toString().endsWith("/")) {
|
homeServerUri = if (hsUri.toString().endsWith("/")) {
|
||||||
|
@ -148,6 +148,10 @@ data class HomeServerConnectionConfig(
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun withAntiVirusServerUri(antivirusServerUriString: String?): Builder {
|
||||||
|
return withAntiVirusServerUri(antivirusServerUriString?.let { Uri.parse(it) })
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the anti-virus server URI.
|
* Update the anti-virus server URI.
|
||||||
*
|
*
|
||||||
|
@ -211,7 +215,18 @@ data class HomeServerConnectionConfig(
|
||||||
* @return the [HomeServerConnectionConfig]
|
* @return the [HomeServerConnectionConfig]
|
||||||
*/
|
*/
|
||||||
fun build(): HomeServerConnectionConfig {
|
fun build(): HomeServerConnectionConfig {
|
||||||
return HomeServerConnectionConfig(homeServerUri, identityServerUri, antiVirusServerUri, allowedFingerprints, shouldPin, tlsVersions, tlsCipherSuites, shouldAcceptTlsExtensions, allowHttpExtension, forceUsageTlsVersions)
|
return HomeServerConnectionConfig(
|
||||||
|
homeServerUri,
|
||||||
|
identityServerUri,
|
||||||
|
antiVirusServerUri,
|
||||||
|
allowedFingerprints,
|
||||||
|
shouldPin,
|
||||||
|
tlsVersions,
|
||||||
|
tlsCipherSuites,
|
||||||
|
shouldAcceptTlsExtensions,
|
||||||
|
allowHttpExtension,
|
||||||
|
forceUsageTlsVersions
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package im.vector.matrix.android.internal.di
|
package im.vector.matrix.android.internal.di
|
||||||
|
|
||||||
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
|
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
|
||||||
|
import com.squareup.moshi.Moshi
|
||||||
import im.vector.matrix.android.internal.network.AccessTokenInterceptor
|
import im.vector.matrix.android.internal.network.AccessTokenInterceptor
|
||||||
|
import im.vector.matrix.android.internal.network.parsing.UriMoshiAdapter
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
import org.koin.dsl.context.ModuleDefinition
|
import org.koin.dsl.context.ModuleDefinition
|
||||||
|
@ -38,7 +40,7 @@ class NetworkModule : Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
single {
|
single {
|
||||||
MoshiProvider.providesMoshi()
|
Moshi.Builder().add(UriMoshiAdapter()).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
single {
|
single {
|
||||||
|
|
|
@ -13,10 +13,11 @@ import retrofit2.Retrofit
|
||||||
class SessionModule(private val sessionParams: SessionParams) : Module {
|
class SessionModule(private val sessionParams: SessionParams) : Module {
|
||||||
|
|
||||||
override fun invoke(): ModuleDefinition = module(override = true) {
|
override fun invoke(): ModuleDefinition = module(override = true) {
|
||||||
|
|
||||||
scope(DefaultSession.SCOPE) {
|
scope(DefaultSession.SCOPE) {
|
||||||
val retrofitBuilder = get() as Retrofit.Builder
|
val retrofitBuilder = get() as Retrofit.Builder
|
||||||
retrofitBuilder
|
retrofitBuilder
|
||||||
.baseUrl(sessionParams.homeServerConnectionConfig?.homeServerUri.toString())
|
.baseUrl(sessionParams.homeServerConnectionConfig.homeServerUri.toString())
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +25,8 @@ class SessionModule(private val sessionParams: SessionParams) : Module {
|
||||||
val store = MXFileStore(sessionParams.credentials, false, get())
|
val store = MXFileStore(sessionParams.credentials, false, get())
|
||||||
val dataHandler = MXDataHandler(store, sessionParams.credentials)
|
val dataHandler = MXDataHandler(store, sessionParams.credentials)
|
||||||
MXSession.Builder(sessionParams, dataHandler, get()).build()
|
MXSession.Builder(sessionParams, dataHandler, get()).build()
|
||||||
|
store.setDataHandler(dataHandler)
|
||||||
|
dataHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
}.invoke()
|
}.invoke()
|
||||||
|
|
|
@ -16,7 +16,7 @@ class SyncModule : Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
scope(DefaultSession.SCOPE) {
|
scope(DefaultSession.SCOPE) {
|
||||||
SyncResponseHandler(get(), get())
|
SyncResponseHandler(get())
|
||||||
}
|
}
|
||||||
|
|
||||||
scope(DefaultSession.SCOPE) {
|
scope(DefaultSession.SCOPE) {
|
||||||
|
|
|
@ -22,9 +22,9 @@ import kotlin.collections.emptyList
|
||||||
import kotlin.collections.isNotEmpty
|
import kotlin.collections.isNotEmpty
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
|
|
||||||
class SyncResponseHandler(private val dataHandler: MXDataHandler,
|
class SyncResponseHandler(private val dataHandler: MXDataHandler) {
|
||||||
private val store: IMXStore) {
|
|
||||||
|
|
||||||
|
private val store = dataHandler.store
|
||||||
private val leftRoomsStore = MXMemoryStore()
|
private val leftRoomsStore = MXMemoryStore()
|
||||||
private var isStartingCryptoWithInitialSync = false
|
private var isStartingCryptoWithInitialSync = false
|
||||||
private var areLeftRoomsSynced = false
|
private var areLeftRoomsSynced = false
|
||||||
|
|
|
@ -74,9 +74,9 @@ public class ContentManager {
|
||||||
public void configureAntiVirusScanner(boolean isEnabled) {
|
public void configureAntiVirusScanner(boolean isEnabled) {
|
||||||
mIsAvScannerEnabled = isEnabled;
|
mIsAvScannerEnabled = isEnabled;
|
||||||
if (isEnabled) {
|
if (isEnabled) {
|
||||||
mDownloadUrlPrefix = mHsConfig.getAntiVirusServerUri().toString() + "/" + RestClient.URI_API_PREFIX_PATH_MEDIA_PROXY_UNSTABLE;
|
mDownloadUrlPrefix = mHsConfig.getAntiVirusServerUri() + "/" + RestClient.URI_API_PREFIX_PATH_MEDIA_PROXY_UNSTABLE;
|
||||||
} else {
|
} else {
|
||||||
mDownloadUrlPrefix = mHsConfig.getHomeServerUri().toString() + URI_PREFIX_CONTENT_API;
|
mDownloadUrlPrefix = mHsConfig.getHomeServerUri() + URI_PREFIX_CONTENT_API;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package im.vector.matrix.android.internal.network.parsing
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import com.squareup.moshi.FromJson
|
||||||
|
import com.squareup.moshi.ToJson
|
||||||
|
|
||||||
|
class UriMoshiAdapter {
|
||||||
|
|
||||||
|
@ToJson
|
||||||
|
fun toJson(uri: Uri): String {
|
||||||
|
return uri.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
@FromJson
|
||||||
|
fun fromJson(uriString: String): Uri {
|
||||||
|
return Uri.parse(uriString)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -141,7 +141,7 @@ object CertUtil {
|
||||||
try {
|
try {
|
||||||
tf = TrustManagerFactory.getInstance("PKIX")
|
tf = TrustManagerFactory.getInstance("PKIX")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e("## newPinnedSSLSocketFactory() : TrustManagerFactory.getInstance failed " + e.message, e)
|
Timber.e(e, "## newPinnedSSLSocketFactory() : TrustManagerFactory.getInstance failed " + e.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// it doesn't exist, use the default one.
|
// it doesn't exist, use the default one.
|
||||||
|
@ -149,7 +149,7 @@ object CertUtil {
|
||||||
try {
|
try {
|
||||||
tf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
|
tf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e("## addRule : onBingRuleUpdateFailure failed " + e.message, e)
|
Timber.e(e, "## addRule : onBingRuleUpdateFailure failed " + e.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ object CertUtil {
|
||||||
|
|
||||||
return HostnameVerifier { hostname, session ->
|
return HostnameVerifier { hostname, session ->
|
||||||
if (defaultVerifier.verify(hostname, session)) return@HostnameVerifier true
|
if (defaultVerifier.verify(hostname, session)) return@HostnameVerifier true
|
||||||
if (trustedFingerprints == null || trustedFingerprints.size == 0) return@HostnameVerifier false
|
if (trustedFingerprints.isEmpty()) return@HostnameVerifier false
|
||||||
|
|
||||||
// If remote cert matches an allowed fingerprint, just accept it.
|
// If remote cert matches an allowed fingerprint, just accept it.
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue