[MatrixSDK] finish mapping timeline and makes it compile

This commit is contained in:
ganfra 2023-03-13 20:18:16 +01:00
parent fb85f35525
commit 801eecfe8d
44 changed files with 370 additions and 242 deletions

View file

@ -21,8 +21,6 @@ import io.element.android.libraries.matrix.api.core.SessionId
import io.element.android.libraries.matrix.api.media.MediaResolver
import io.element.android.libraries.matrix.api.room.MatrixRoom
import io.element.android.libraries.matrix.api.room.RoomSummaryDataSource
import org.matrix.rustcomponents.sdk.MediaSource
import java.io.Closeable
interface MatrixClient {
val sessionId: SessionId
@ -34,9 +32,9 @@ interface MatrixClient {
suspend fun logout()
suspend fun loadUserDisplayName(): Result<String>
suspend fun loadUserAvatarURLString(): Result<String>
suspend fun loadMediaContentForSource(source: MediaSource): Result<ByteArray>
suspend fun loadMediaThumbnailForSource(
source: MediaSource,
suspend fun loadMediaContent(url: String): Result<ByteArray>
suspend fun loadMediaThumbnail(
url: String,
width: Long,
height: Long
): Result<ByteArray>

View file

@ -16,8 +16,6 @@
package io.element.android.libraries.matrix.api.auth
import org.matrix.rustcomponents.sdk.AuthenticationException
enum class AuthErrorCode(val value: String) {
UNKNOWN("M_UNKNOWN"),
USER_DEACTIVATED("M_USER_DEACTIVATED"),

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2023 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 io.element.android.libraries.matrix.api.auth
sealed class AuthenticationException(message: String) : Exception(message) {
class ClientMissing(message: String) : AuthenticationException(message)
class InvalidServerName(message: String) : AuthenticationException(message)
class SlidingSyncNotAvailable(message: String) : AuthenticationException(message)
class SessionMissing(message: String) : AuthenticationException(message)
class Generic(message: String) : AuthenticationException(message)
}

View file

@ -24,8 +24,8 @@ import kotlinx.coroutines.flow.StateFlow
interface MatrixAuthenticationService {
fun isLoggedIn(): Flow<Boolean>
suspend fun getLatestSessionId(): SessionId?
suspend fun restoreSession(sessionId: SessionId): MatrixClient?
suspend fun restoreSession(sessionId: SessionId): Result<MatrixClient>
fun getHomeserverDetails(): StateFlow<MatrixHomeServerDetails?>
suspend fun setHomeserver(homeserver: String)
suspend fun login(username: String, password: String): SessionId
suspend fun setHomeserver(homeserver: String): Result<Unit>
suspend fun login(username: String, password: String): Result<SessionId>
}

View file

@ -18,17 +18,10 @@ package io.element.android.libraries.matrix.api.auth
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import org.matrix.rustcomponents.sdk.HomeserverLoginDetails
@Parcelize
data class MatrixHomeServerDetails(
val url: String,
val supportsPasswordLogin: Boolean,
val authenticationIssuer: String?
): Parcelable {
constructor(homeserverLoginDetails: HomeserverLoginDetails) : this(
homeserverLoginDetails.url(),
homeserverLoginDetails.supportsPasswordLogin(),
homeserverLoginDetails.authenticationIssuer()
)
}
): Parcelable

View file

@ -24,11 +24,11 @@ import io.element.android.libraries.matrix.api.media.VideoInfo
sealed interface TimelineEventContent
data class TimelineEventMessageContent(
data class MessageContent(
val body: String,
val inReplyTo: UserId?,
val isEdited: Boolean,
val content: MessageContent?
val type: MessageType?
) : TimelineEventContent
object RedactedContent : TimelineEventContent
@ -39,45 +39,45 @@ data class StickerContent(
val url: String
) : TimelineEventContent
sealed interface EncryptedMessage {
data class OlmV1Curve25519AesSha2(
val senderKey: String
) : EncryptedMessage
data class UnableToDecryptContent(
val data: Data
) : TimelineEventContent {
sealed interface Data {
data class OlmV1Curve25519AesSha2(
val senderKey: String
) : Data
data class MegolmV1AesSha2(
val sessionId: String
) : EncryptedMessage
data class MegolmV1AesSha2(
val sessionId: String
) : Data
object Unknown : EncryptedMessage
object Unknown : Data
}
}
data class UnableToDecryptContent(
val message: EncryptedMessage
) : TimelineEventContent
data class RoomMembership(
data class RoomMembershipContent(
val userId: UserId,
val change: MembershipChange?
) : TimelineEventContent
data class ProfileChange(
data class ProfileChangeContent(
val displayName: String?,
val prevDisplayName: String?,
val avatarUrl: String?,
val prevAvatarUrl: String?
) : TimelineEventContent
data class State(
data class StateContent(
val stateKey: String,
val content: OtherState
) : TimelineEventContent
data class FailedToParseMessageLike(
data class FailedToParseMessageLikeContent(
val eventType: String,
val error: String
) : TimelineEventContent
data class FailedToParseState(
data class FailedToParseStateContent(
val eventType: String,
val stateKey: String,
val error: String
@ -85,9 +85,9 @@ data class FailedToParseState(
object UnknownContent : TimelineEventContent
sealed interface MessageContent
sealed interface MessageType
object UnknownMessageContent : MessageContent
object UnknownMessageType : MessageType
enum class MessageFormat {
HTML, UNKNOWN
@ -98,44 +98,44 @@ data class FormattedBody(
val body: String
)
data class EmoteMessageContent(
data class EmoteMessageType(
val body: String,
val formatted: FormattedBody?
) : MessageContent
) : MessageType
data class ImageMessageContent(
data class ImageMessageType(
val body: String,
val url: String,
val info: ImageInfo?
) : MessageContent
) : MessageType
data class AudioMessageContent(
data class AudioMessageType(
var body: String,
var url: String,
var info: AudioInfo?
) : MessageContent
) : MessageType
data class VideoMessageContent(
data class VideoMessageType(
val body: String,
val url: String,
val info: VideoInfo?
) : MessageContent
) : MessageType
data class FileMessageContent(
data class FileMessageType(
val body: String,
val url: String,
val info: FileInfo?
) : MessageContent
) : MessageType
data class NoticeMessageContent(
data class NoticeMessageType(
val body: String,
val formatted: FormattedBody?
) : MessageContent
) : MessageType
data class TextMessageContent(
data class TextMessageType(
val body: String,
val formatted: FormattedBody?
) : MessageContent
) : MessageType
enum class MembershipChange {
NONE,