Internal + add some doc

This commit is contained in:
Benoit Marty 2022-04-12 09:26:19 +02:00 committed by Benoit Marty
parent 83570dc24b
commit b4dbb389b1
34 changed files with 50 additions and 41 deletions

View File

@ -23,7 +23,7 @@ import org.json.JSONException
import org.json.JSONObject
import timber.log.Timber
class FormattedJsonHttpLogger : HttpLoggingInterceptor.Logger {
internal class FormattedJsonHttpLogger : HttpLoggingInterceptor.Logger {
companion object {
private const val INDENT_SPACE = 2

View File

@ -17,7 +17,7 @@ package org.commonmark.ext.maths
import org.commonmark.node.CustomBlock
class DisplayMaths(private val delimiter: DisplayDelimiter) : CustomBlock() {
internal class DisplayMaths(private val delimiter: DisplayDelimiter) : CustomBlock() {
enum class DisplayDelimiter {
DOUBLE_DOLLAR,
SQUARE_BRACKET_ESCAPED

View File

@ -18,7 +18,7 @@ package org.commonmark.ext.maths
import org.commonmark.node.CustomNode
import org.commonmark.node.Delimited
class InlineMaths(private val delimiter: InlineDelimiter) : CustomNode(), Delimited {
internal class InlineMaths(private val delimiter: InlineDelimiter) : CustomNode(), Delimited {
enum class InlineDelimiter {
SINGLE_DOLLAR,
ROUND_BRACKET_ESCAPED

View File

@ -21,7 +21,7 @@ import org.commonmark.ext.maths.internal.MathsHtmlNodeRenderer
import org.commonmark.parser.Parser
import org.commonmark.renderer.html.HtmlRenderer
class MathsExtension private constructor() : Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension {
internal class MathsExtension private constructor() : Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension {
override fun extend(parserBuilder: Parser.Builder) {
parserBuilder.customDelimiterProcessor(DollarMathsDelimiterProcessor())
}

View File

@ -20,10 +20,19 @@ package org.matrix.android.sdk.api.auth
* A simple service to remember homeservers you already connected to.
*/
interface HomeServerHistoryService {
/**
* Get a list of stored homeserver urls.
*/
fun getKnownServersUrls(): List<String>
/**
* Add a homeserver url to the list of stored homeserver urls.
* Will not be added again if already present in the list.
*/
fun addHomeServerToHistory(url: String)
/**
* Delete the list of stored homeserver urls.
*/
fun clearHistory()
}

View File

@ -23,7 +23,7 @@ import org.matrix.android.sdk.internal.database.model.KnownServerUrlEntity
import org.matrix.android.sdk.internal.di.GlobalDatabase
import javax.inject.Inject
class DefaultHomeServerHistoryService @Inject constructor(
internal class DefaultHomeServerHistoryService @Inject constructor(
@GlobalDatabase private val monarchy: Monarchy
) : HomeServerHistoryService {

View File

@ -21,7 +21,7 @@ import com.squareup.moshi.JsonClass
import org.matrix.android.sdk.api.extensions.orFalse
@JsonClass(generateAdapter = true)
data class SuccessResult(
internal data class SuccessResult(
@Json(name = "success")
val success: Boolean?
) {

View File

@ -23,7 +23,7 @@ import com.squareup.moshi.JsonClass
* This object is used to send a code received by SMS to validate Msisdn ownership
*/
@JsonClass(generateAdapter = true)
data class ValidationCodeBody(
internal data class ValidationCodeBody(
@Json(name = "client_secret")
val clientSecret: String,

View File

@ -30,7 +30,7 @@ import java.util.Timer
import java.util.TimerTask
import javax.inject.Inject
data class InboundGroupSessionHolder(
internal data class InboundGroupSessionHolder(
val wrapper: OlmInboundGroupSessionWrapper2,
val mutex: Mutex = Mutex()
)

View File

@ -31,7 +31,7 @@ import kotlin.math.min
// The spec recommend a 5mn delay, but due to federation
// or server downtime we give it a bit more time (1 hour)
const val FALLBACK_KEY_FORGET_DELAY = 60 * 60_000L
private const val FALLBACK_KEY_FORGET_DELAY = 60 * 60_000L
@SessionScope
internal class OneTimeKeysUploader @Inject constructor(

View File

@ -22,7 +22,7 @@ import com.squareup.moshi.JsonClass
* Represents an outgoing room key request
*/
@JsonClass(generateAdapter = true)
class OutgoingSecretRequest(
internal class OutgoingSecretRequest(
// Secret Name
val secretName: String?,
// list of recipients for the request

View File

@ -25,7 +25,7 @@ import org.matrix.android.sdk.internal.network.parsing.ForceToBoolean
* Backup data for one key.
*/
@JsonClass(generateAdapter = true)
data class KeyBackupData(
internal data class KeyBackupData(
/**
* Required. The index of the first message in the session that the key can decrypt.
*/

View File

@ -23,7 +23,7 @@ import com.squareup.moshi.JsonClass
* Backup data for several keys in several rooms.
*/
@JsonClass(generateAdapter = true)
data class KeysBackupData(
internal data class KeysBackupData(
// the keys are the room IDs, and the values are RoomKeysBackupData
@Json(name = "rooms")
val roomIdToRoomKeysBackupData: MutableMap<String, RoomKeysBackupData> = HashMap()

View File

@ -23,7 +23,7 @@ import com.squareup.moshi.JsonClass
* Backup data for several keys within a room.
*/
@JsonClass(generateAdapter = true)
data class RoomKeysBackupData(
internal data class RoomKeysBackupData(
// the keys are the session IDs, and the values are KeyBackupData
@Json(name = "sessions")
val sessionIdToKeyBackupData: MutableMap<String, KeyBackupData> = HashMap()

View File

@ -21,7 +21,7 @@ import com.squareup.moshi.JsonClass
import org.matrix.android.sdk.api.util.JsonDict
@JsonClass(generateAdapter = true)
data class UpdateKeysBackupVersionBody(
internal data class UpdateKeysBackupVersionBody(
/**
* The algorithm used for storing backups. Currently, only "m.megolm_backup.v1.curve25519-aes-sha2" is defined
*/

View File

@ -28,7 +28,7 @@ import java.util.zip.GZIPOutputStream
/**
* Get realm, invoke the action, close realm, and return the result of the action
*/
fun <T> doWithRealm(realmConfiguration: RealmConfiguration, action: (Realm) -> T): T {
internal fun <T> doWithRealm(realmConfiguration: RealmConfiguration, action: (Realm) -> T): T {
return Realm.getInstance(realmConfiguration).use { realm ->
action.invoke(realm)
}
@ -37,7 +37,7 @@ fun <T> doWithRealm(realmConfiguration: RealmConfiguration, action: (Realm) -> T
/**
* Get realm, do the query, copy from realm, close realm, and return the copied result
*/
fun <T : RealmObject> doRealmQueryAndCopy(realmConfiguration: RealmConfiguration, action: (Realm) -> T?): T? {
internal fun <T : RealmObject> doRealmQueryAndCopy(realmConfiguration: RealmConfiguration, action: (Realm) -> T?): T? {
return Realm.getInstance(realmConfiguration).use { realm ->
action.invoke(realm)?.let { realm.copyFromRealm(it) }
}
@ -46,7 +46,7 @@ fun <T : RealmObject> doRealmQueryAndCopy(realmConfiguration: RealmConfiguration
/**
* Get realm, do the list query, copy from realm, close realm, and return the copied result
*/
fun <T : RealmObject> doRealmQueryAndCopyList(realmConfiguration: RealmConfiguration, action: (Realm) -> Iterable<T>): Iterable<T> {
internal fun <T : RealmObject> doRealmQueryAndCopyList(realmConfiguration: RealmConfiguration, action: (Realm) -> Iterable<T>): Iterable<T> {
return Realm.getInstance(realmConfiguration).use { realm ->
action.invoke(realm).let { realm.copyFromRealm(it) }
}
@ -55,13 +55,13 @@ fun <T : RealmObject> doRealmQueryAndCopyList(realmConfiguration: RealmConfigura
/**
* Get realm instance, invoke the action in a transaction and close realm
*/
fun doRealmTransaction(realmConfiguration: RealmConfiguration, action: (Realm) -> Unit) {
internal fun doRealmTransaction(realmConfiguration: RealmConfiguration, action: (Realm) -> Unit) {
Realm.getInstance(realmConfiguration).use { realm ->
realm.executeTransaction { action.invoke(it) }
}
}
fun doRealmTransactionAsync(realmConfiguration: RealmConfiguration, action: (Realm) -> Unit) {
internal fun doRealmTransactionAsync(realmConfiguration: RealmConfiguration, action: (Realm) -> Unit) {
Realm.getInstance(realmConfiguration).use { realm ->
realm.executeTransactionAsync { action.invoke(it) }
}
@ -70,7 +70,7 @@ fun doRealmTransactionAsync(realmConfiguration: RealmConfiguration, action: (Rea
/**
* Serialize any Serializable object, zip it and convert to Base64 String
*/
fun serializeForRealm(o: Any?): String? {
internal fun serializeForRealm(o: Any?): String? {
if (o == null) {
return null
}
@ -88,7 +88,7 @@ fun serializeForRealm(o: Any?): String? {
* Do the opposite of serializeForRealm.
*/
@Suppress("UNCHECKED_CAST")
fun <T> deserializeFromRealm(string: String?): T? {
internal fun <T> deserializeFromRealm(string: String?): T? {
if (string == null) {
return null
}

View File

@ -24,7 +24,7 @@ import org.matrix.android.sdk.internal.crypto.model.rest.UnsignedDeviceInfo
import org.matrix.android.sdk.internal.di.SerializeNulls
import timber.log.Timber
object CryptoMapper {
internal object CryptoMapper {
private val moshi = Moshi.Builder().add(SerializeNulls.JSON_ADAPTER_FACTORY).build()
private val listMigrationAdapter = moshi.adapter<List<String>>(Types.newParameterizedType(

View File

@ -26,7 +26,7 @@ import kotlin.math.ceil
* HMAC-based Extract-and-Expand Key Derivation Function (HkdfSha256)
* [RFC-5869] https://tools.ietf.org/html/rfc5869
*/
object HkdfSha256 {
internal object HkdfSha256 {
fun deriveSecret(inputKeyMaterial: ByteArray, salt: ByteArray?, info: ByteArray, outputLength: Int): ByteArray {
return expand(extract(salt, inputKeyMaterial), info, outputLength)

View File

@ -18,7 +18,7 @@ package org.matrix.android.sdk.internal.crypto.verification
import org.matrix.android.sdk.api.session.events.model.Content
import org.matrix.android.sdk.internal.crypto.model.rest.SendToDeviceObject
interface VerificationInfo<ValidObjectType> {
internal interface VerificationInfo<ValidObjectType> {
fun toEventContent(): Content? = null
fun toSendToDeviceObject(): SendToDeviceObject? = null

View File

@ -103,7 +103,7 @@ internal interface VerificationInfoStart : VerificationInfo<ValidVerificationInf
}
}
sealed class ValidVerificationInfoStart(
internal sealed class ValidVerificationInfoStart(
open val transactionId: String,
open val fromDevice: String) {
data class SasVerificationInfoStart(

View File

@ -19,7 +19,7 @@ package org.matrix.android.sdk.internal.crypto.verification.qrcode
/**
* Ref: https://github.com/uhoreg/matrix-doc/blob/qr_key_verification/proposals/1543-qr_code_key_verification.md#qr-code-format
*/
sealed class QrCodeData(
internal sealed class QrCodeData(
/**
* the event ID or transaction_id of the associated verification
*/

View File

@ -19,7 +19,7 @@ package org.matrix.android.sdk.internal.crypto.verification.qrcode
import org.matrix.android.sdk.internal.crypto.crosssigning.toBase64NoPadding
import java.security.SecureRandom
fun generateSharedSecretV2(): String {
internal fun generateSharedSecretV2(): String {
val secureRandom = SecureRandom()
// 8 bytes long

View File

@ -118,7 +118,7 @@ internal fun ChunkEntity.addTimelineEvent(roomId: String,
return timelineEventEntity
}
fun computeIsUnique(
internal fun computeIsUnique(
realm: Realm,
roomId: String,
isLastForward: Boolean,

View File

@ -19,4 +19,4 @@ package org.matrix.android.sdk.internal.extensions
/**
* Convert a signed byte to a int value
*/
fun Byte.toUnsignedInt() = toInt() and 0xff
internal fun Byte.toUnsignedInt() = toInt() and 0xff

View File

@ -19,7 +19,7 @@ package org.matrix.android.sdk.internal.query
import io.realm.RealmObject
import io.realm.RealmQuery
fun <T : RealmObject, E : Enum<E>> RealmQuery<T>.process(field: String, enums: List<Enum<E>>): RealmQuery<T> {
internal fun <T : RealmObject, E : Enum<E>> RealmQuery<T>.process(field: String, enums: List<Enum<E>>): RealmQuery<T> {
val lastEnumValue = enums.lastOrNull()
beginGroup()
for (enumValue in enums) {

View File

@ -106,7 +106,7 @@ import javax.inject.Qualifier
@Qualifier
@Retention(AnnotationRetention.RUNTIME)
annotation class MockHttpInterceptor
internal annotation class MockHttpInterceptor
@Module
internal abstract class SessionModule {

View File

@ -18,6 +18,6 @@ package org.matrix.android.sdk.internal.session
import okhttp3.Interceptor
interface TestInterceptor : Interceptor {
internal interface TestInterceptor : Interceptor {
var sessionId: String?
}

View File

@ -24,7 +24,7 @@ import okio.ForwardingSource
import okio.Source
import okio.buffer
class ProgressResponseBody(
internal class ProgressResponseBody(
private val responseBody: ResponseBody,
private val chainUrl: String,
private val progressListener: ProgressListener) : ResponseBody() {
@ -56,7 +56,7 @@ class ProgressResponseBody(
}
}
interface ProgressListener {
internal interface ProgressListener {
fun update(url: String, bytesRead: Long, contentLength: Long, done: Boolean)
fun error(url: String, errorCode: Int)
}

View File

@ -23,7 +23,7 @@ import com.squareup.moshi.JsonClass
* https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-client-r0-user-userid-filter
*/
@JsonClass(generateAdapter = true)
data class EventFilter(
internal data class EventFilter(
/**
* The maximum number of events to return.
*/

View File

@ -23,7 +23,7 @@ import com.squareup.moshi.JsonClass
* https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-client-r0-user-userid-filter
*/
@JsonClass(generateAdapter = true)
data class FilterResponse(
internal data class FilterResponse(
/**
* Required. The ID of the filter that was created. Cannot start with a { as this character
* is used to determine if the filter provided is inline JSON or a previously declared

View File

@ -24,7 +24,7 @@ import org.matrix.android.sdk.internal.di.MoshiProvider
* https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-client-r0-user-userid-filter
*/
@JsonClass(generateAdapter = true)
data class RoomEventFilter(
internal data class RoomEventFilter(
/**
* The maximum number of events to return.
*/

View File

@ -23,7 +23,7 @@ import com.squareup.moshi.JsonClass
* https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-client-r0-user-userid-filter
*/
@JsonClass(generateAdapter = true)
data class RoomFilter(
internal data class RoomFilter(
/**
* A list of room IDs to exclude. If this list is absent then no rooms are excluded.
* A matching room will be excluded even if it is listed in the 'rooms' filter.

View File

@ -20,7 +20,7 @@ import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class InviteBody(
internal data class InviteBody(
@Json(name = "user_id") val userId: String,
@Json(name = "reason") val reason: String?
)

View File

@ -26,7 +26,7 @@ import org.matrix.android.sdk.api.session.presence.model.PresenceEnum
* parameter is set to "offline" then the client is not marked as being online when it uses this API.
* When set to "unavailable", the client is marked as being idle. One of: ["offline", "online", "unavailable"]
*/
enum class SyncPresence(val value: String) {
internal enum class SyncPresence(val value: String) {
Offline("offline"),
Online("online"),
Unavailable("unavailable");