Frontends reach a server only through ServerSession

session.connection() is gone: the session hands out the model, our ids,
the microphone and speakers, ping and connection info, the server's
unique id, icon and avatar stores, myTeamSpeak, the connect error and a
blocking disconnectNow. The connection's remaining actions move into
helpers the session hands out instead of forwarding each method:
ClientAdmin (move, kick, ban, groups, talk power, poke, client details),
ChannelFiles (listing, mkdir, rename, delete, transfers and their
sounds) and ClientContacts (display names, volume, auto-mute, whisper
policy, sightings); ChannelAdmin also takes join, move, subscribe and
description requests. Dialogs take the session instead of the
connection.

Android's network handover now uses disconnectNow, which also cancels a
pending auto-reconnect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 20:58:25 +00:00
co-authored by Claude Opus 5.5
parent 9107bdd02e
commit de42429d08
34 changed files with 966 additions and 743 deletions
@@ -3,7 +3,7 @@ package eu.lixko.ts3j.client.android
import android.content.Context
import android.net.Uri
import android.provider.OpenableColumns
import eu.lixko.ts3j.client.net.TeamspeakConnection
import eu.lixko.ts3j.client.net.ChannelFiles
import eu.lixko.ts3j.client.net.filetransfer.FileTransfer
import eu.lixko.ts3j.client.net.filetransfer.RemoteFile
import kotlinx.coroutines.Dispatchers
@@ -37,7 +37,7 @@ data class TransferRow(
* as the core reads and writes plain files: a download is copied where the user picked once
* complete, an upload is copied out of the picked document first. They outlive the browser page.
*/
class FileTransfers internal constructor(private val context: Context, private val conn: () -> TeamspeakConnection) {
class FileTransfers internal constructor(private val context: Context, private val files: ChannelFiles) {
private val ids = AtomicLong()
private val handles = HashMap<Long, FileTransfer>()
@@ -52,7 +52,7 @@ class FileTransfers internal constructor(private val context: Context, private v
start(row, temp, onComplete = {
context.contentResolver.openOutputStream(target)?.use { out -> temp.inputStream().use { it.copyTo(out) } }
?: throw IOException("Could not write the file")
}) { listener -> conn().downloadFile(channelId, password, file.fullPath, temp, listener) }
}) { listener -> files.download(channelId, password, file.fullPath, temp, listener) }
}
/** Uploads the document at [source] into [directory] (ending in "/"), replacing a file of the same name. */
@@ -60,7 +60,7 @@ class FileTransfers internal constructor(private val context: Context, private v
val (name, temp) = withContext(Dispatchers.IO) { copyIn(source) }
val row = add(name, upload = true, channelId, directory, temp.length())
start(row, temp, onComplete = {}) { listener ->
conn().uploadFile(channelId, password, directory + name, temp, true, listener)
files.upload(channelId, password, directory + name, temp, true, listener)
}
}
@@ -144,7 +144,7 @@ class NetworkFollower(context: Context) {
try {
val back = withTimeoutOrNull(GIVE_UP_MS) {
system(if (connectivity.activeNetwork == null) "Network lost." else "Network changed, reconnecting…")
if (session.isBusy) session.connection().disconnectBlocking("Network changed")
session.disconnectNow("Network changed")
var retry = RETRY_MS
while (true) {
val current = awaitNetwork()
@@ -156,13 +156,13 @@ class NetworkFollower(context: Context) {
val connected = done.await()
attempt = null
if (connected) break
if (session.connection().connectErrorId == ERROR_BANNED) break
if (session.connectErrorId() == ERROR_BANNED) break
show("Reconnecting, retrying soon…")
delay(retry)
retry = (retry * 2).coerceAtMost(MAX_RETRY_MS)
}
}
if (session.connection().connectErrorId == ERROR_BANNED) {
if (session.connectErrorId() == ERROR_BANNED) {
wanted = false
unbind()
} else if (back == null) {
@@ -48,7 +48,6 @@ class ServerController internal constructor(
internal val session = ServerSession(
app.settings, app.identityStore, app.audio, app.sounds, app.contactStore, Listener()
)
internal val conn get() = session.connection()
private val network = app.network.follow(session, ::refresh, ::system)
/** Whether this server holds the microphone; set by [SessionController] as it moves. */
@@ -89,7 +88,7 @@ class ServerController internal constructor(
private val _infoUpdates = MutableStateFlow(0)
val infoUpdates: StateFlow<Int> = _infoUpdates
val images = ServerImages(conn)
val images = ServerImages(session.icons(), session.avatars())
/** A private chat a notification asked to show, until the UI took it up. */
private val _chatRequest = MutableStateFlow<ChatKey.Private?>(null)
@@ -105,8 +104,8 @@ class ServerController internal constructor(
val isConnected: Boolean get() = session.isConnected
internal val isBusy: Boolean get() = session.isBusy || network.isRecovering
internal val microphone get() = if (session.isConnected) conn.ownClient().microphone() else null
internal val playback get() = if (session.isConnected) conn.ownClient().playback() else null
internal val microphone get() = if (session.isConnected) session.microphone() else null
internal val playback get() = if (session.isConnected) session.playback() else null
/** Not on the server and not trying to get back on it: done with. */
internal val ended: Boolean get() = started && !isBusy
@@ -147,7 +146,7 @@ class ServerController internal constructor(
}
/** A bookmark leading back to this server, joining [channelId]; not yet saved. */
fun bookmark(channelId: Int): Bookmark? = session.toBookmark(conn.model.channelPath(channelId))
fun bookmark(channelId: Int): Bookmark? = session.toBookmark(session.model().channelPath(channelId))
?.also { it.showWhisperControls = whisperControls }
fun disconnect() {
@@ -183,11 +182,11 @@ class ServerController internal constructor(
// ---- channels and clients ----
fun joinChannel(channelId: Int, password: String? = null) {
if (session.isConnected) conn.joinChannel(channelId, password)
if (session.isConnected) session.channels().join(channelId, password)
}
fun setSubscribed(channelId: Int, subscribed: Boolean) {
if (session.isConnected) conn.setChannelsSubscribed(listOf(channelId), subscribed)
if (session.isConnected) session.channels().setSubscribed(listOf(channelId), subscribed)
}
fun toggleCollapsed(channelId: Int) =
@@ -199,44 +198,44 @@ class ServerController internal constructor(
val permissions: Permissions get() = session.permissions()
/** The channel kicked clients go back to; 0 until the server named it. */
val defaultChannelId: Int get() = conn.model.defaultChannelId()
val defaultChannelId: Int get() = session.model().defaultChannelId()
fun moveClients(clientIds: Collection<Int>, channelId: Int) {
if (session.isConnected) conn.moveClients(clientIds, channelId)
if (session.isConnected) session.clients().move(clientIds, channelId)
}
fun poke(clientId: Int, message: String) {
if (session.isConnected) conn.poke(clientId, message)
if (session.isConnected) session.clients().poke(clientId, message)
}
/** The client's playback volume change in dB; 0 when unchanged. */
fun clientVolume(clientId: Int): Double =
conn.model.getClient(clientId)?.let { conn.getClientVolumeModifier(it) } ?: 0.0
session.model().getClient(clientId)?.let { session.contacts().volumeModifier(it) } ?: 0.0
fun setClientVolume(clientId: Int, decibels: Double) {
conn.model.getClient(clientId)?.let { conn.setClientVolumeModifier(it, decibels) }
session.model().getClient(clientId)?.let { session.contacts().setVolumeModifier(it, decibels) }
}
// ---- whisper ----
fun setWhisper(whisper: Whisper?) = session.setWhisper(whisper)
fun whisperToChannel(channelId: Int) = conn.model.getChannel(channelId)?.let { setWhisper(Whisper.toChannel(it)) }
fun whisperToChannel(channelId: Int) = session.model().getChannel(channelId)?.let { setWhisper(Whisper.toChannel(it)) }
fun whisperToClient(clientId: Int) = conn.model.getClient(clientId)?.let { setWhisper(Whisper.toClient(it)) }
fun whisperToClient(clientId: Int) = session.model().getClient(clientId)?.let { setWhisper(Whisper.toClient(it)) }
/** The client who whispered to us last, while on the server. */
fun lastWhisperer(): ClientEntry? = session.lastWhisperer()
/** A channel as a whisper list holds it: by path, so the list works on any server with that channel. */
fun channelRef(channelId: Int): String? = conn.model.getChannel(channelId)?.let { conn.model.channelPath(it.id) }
fun channelRef(channelId: Int): String? = session.model().getChannel(channelId)?.let { session.model().channelPath(it.id) }
fun clientRef(clientId: Int): WhisperList.Client? =
conn.model.getClient(clientId)?.let { WhisperList.Client(it.uniqueId, it.nickname) }
session.model().getClient(clientId)?.let { WhisperList.Client(it.uniqueId, it.nickname) }
/** The clients on the server, for adding to a whisper list; ourselves left out. */
fun clientRefs(): List<WhisperList.Client> = if (!session.isConnected) emptyList()
else conn.model.allClients().filter { it.id != conn.selfClientId && !it.uniqueId.isNullOrEmpty() }
else session.model().allClients().filter { it.id != session.selfClientId() && !it.uniqueId.isNullOrEmpty() }
.sortedBy { it.nickname.lowercase() }.map { WhisperList.Client(it.uniqueId, it.nickname) }
fun channelPaths(): List<String> = session.channelPaths()
@@ -245,7 +244,7 @@ class ServerController internal constructor(
/** The channels a channel can sort after: its siblings, or [parentId]'s children for a new one. */
fun sortChoices(channelId: Int, parentId: Int): List<ChannelNode> =
if (channelId > 0) conn.model.siblingsOf(channelId) else conn.model.childrenOf(parentId)
if (channelId > 0) session.model().siblingsOf(channelId) else session.model().childrenOf(parentId)
/** A channel's editable properties as the server has them. */
suspend fun channelSettings(channelId: Int): Result<ChannelSettings> = session.channels().settings(channelId).result()
@@ -262,20 +261,20 @@ class ServerController internal constructor(
// ---- files ----
val files = app.fileTransfers { conn }
val files = app.fileTransfers(session.files())
/** The files in a directory of a channel's repository; empty for an empty one. */
suspend fun listFiles(channelId: Int, password: String, path: String): Result<List<RemoteFile>> =
withContext(Dispatchers.IO) { runCatching { conn.listFiles(channelId, password, path) } }
withContext(Dispatchers.IO) { runCatching { session.files().list(channelId, password, path) } }
suspend fun createDirectory(channelId: Int, password: String, path: String): Result<Unit> =
fileCall { conn.createDirectory(channelId, password, path) }
fileCall { session.files().createDirectory(channelId, password, path) }
suspend fun deleteFile(channelId: Int, password: String, path: String): Result<Unit> =
fileCall { conn.deleteFile(channelId, password, path) }
fileCall { session.files().delete(channelId, password, path) }
suspend fun renameFile(channelId: Int, password: String, from: String, to: String): Result<Unit> =
fileCall { conn.renameFile(channelId, password, from, to) }
fileCall { session.files().rename(channelId, password, from, to) }
private suspend fun fileCall(call: () -> Unit): Result<Unit> = withContext(Dispatchers.IO) { runCatching(call) }
@@ -284,37 +283,37 @@ class ServerController internal constructor(
val canRequestTalkPower: Boolean get() = session.canRequestTalkPower()
fun kickFromChannel(clientIds: Collection<Int>, reason: String) {
if (session.isConnected) conn.kickFromChannel(clientIds, reason)
if (session.isConnected) session.clients().kickFromChannel(clientIds, reason)
}
fun kickFromServer(clientIds: Collection<Int>, reason: String) {
if (session.isConnected) conn.kickFromServer(clientIds, reason)
if (session.isConnected) session.clients().kickFromServer(clientIds, reason)
}
fun setTalker(clientIds: Collection<Int>, talker: Boolean) {
if (session.isConnected) conn.setTalker(clientIds, talker)
if (session.isConnected) session.clients().setTalker(clientIds, talker)
}
/** Bans a client for [seconds], or for good with 0. */
fun ban(clientId: Int, seconds: Long, reason: String) {
if (session.isConnected) conn.banClient(clientId, seconds, reason)
if (session.isConnected) session.clients().ban(clientId, seconds, reason)
}
fun serverGroupChoices(clientId: Int): List<GroupChoice> =
conn.model.getClient(clientId)?.let(conn.model::serverGroupChoices).orEmpty()
session.model().getClient(clientId)?.let(session.model()::serverGroupChoices).orEmpty()
fun channelGroupChoices(clientId: Int): List<GroupChoice> =
conn.model.getClient(clientId)?.let(conn.model::channelGroupChoices).orEmpty()
session.model().getClient(clientId)?.let(session.model()::channelGroupChoices).orEmpty()
fun setServerGroup(clientId: Int, groupId: Int, assign: Boolean) {
val client = conn.model.getClient(clientId) ?: return
if (session.isConnected) conn.setClientServerGroup(client.databaseId, groupId, assign)
val client = session.model().getClient(clientId) ?: return
if (session.isConnected) session.clients().setServerGroup(client.databaseId, groupId, assign)
}
/** Gives a client [groupId] in the channel they are in. */
fun setChannelGroup(clientId: Int, groupId: Int) {
val client = conn.model.getClient(clientId) ?: return
if (session.isConnected) conn.setClientChannelGroup(client.databaseId, client.channelId, groupId)
val client = session.model().getClient(clientId) ?: return
if (session.isConnected) session.clients().setChannelGroup(client.databaseId, client.channelId, groupId)
}
// ---- ban list ----
@@ -322,7 +321,7 @@ class ServerController internal constructor(
/** One reading of a client's connection figures, or null when not connected. */
suspend fun connectionStats(clientId: Int): ConnectionStats? =
if (!session.isConnected) null
else suspendCoroutine { done -> conn.requestConnectionInfo(clientId) { done.resume(it) } }
else suspendCoroutine { done -> session.requestConnectionInfo(clientId) { done.resume(it) } }
/** The server's bans, or why they could not be read. */
suspend fun banList(): Result<List<BanEntry>> = session.bans().list().result()
@@ -333,11 +332,11 @@ class ServerController internal constructor(
suspend fun deleteBans(banIds: Collection<Int>): Result<Unit> = session.bans().delete(banIds).done()
fun canDeleteBans(bans: Collection<BanEntry>): Boolean = permissions.canDeleteBans(bans, conn.selfUniqueId)
fun canDeleteBans(bans: Collection<BanEntry>): Boolean = permissions.canDeleteBans(bans, session.selfUniqueId())
fun canEditBan(ban: BanEntry): Boolean = permissions.canEditBan(ban, conn.selfUniqueId)
fun canEditBan(ban: BanEntry): Boolean = permissions.canEditBan(ban, session.selfUniqueId())
fun isOwnBan(ban: BanEntry): Boolean = ban.createdBy(conn.selfUniqueId)
fun isOwnBan(ban: BanEntry): Boolean = ban.createdBy(session.selfUniqueId())
/** Uploads [data] as our avatar. */
suspend fun setAvatar(data: ByteArray): Result<Unit> {
@@ -355,32 +354,32 @@ class ServerController internal constructor(
// ---- details ----
fun serverDetails(): Details? =
if (session.isConnected) Details.server(conn.model, "${conn.serverHost}:${conn.serverPort}") else null
if (session.isConnected) Details.server(session.model(), "${session.address()}:${session.port()}") else null
fun channelDetails(channelId: Int): Details? = conn.model.getChannel(channelId)?.let(Details::channel)
fun channelDetails(channelId: Int): Details? = session.model().getChannel(channelId)?.let(Details::channel)
fun clientDetails(clientId: Int): Details? = conn.model.getClient(clientId)?.let {
Details.client(it, conn.model, app.contactStore.find(it.uniqueId))
fun clientDetails(clientId: Int): Details? = session.model().getClient(clientId)?.let {
Details.client(it, session.model(), app.contactStore.find(it.uniqueId))
}
/** Asks the server for what the channel's details lack; they change once it answers. */
fun requestChannelDetails(channelId: Int) {
val channel = conn.model.getChannel(channelId) ?: return
if (session.isConnected && !channel.descriptionLoaded) conn.requestChannelInfo(channelId)
val channel = session.model().getChannel(channelId) ?: return
if (session.isConnected && !channel.descriptionLoaded) session.channels().requestInfo(channelId)
}
fun requestClientDetails(clientId: Int) {
if (session.isConnected) conn.requestClientInfo(clientId)
if (session.isConnected) session.clients().requestInfo(clientId)
}
/** Files a client on the server as a contact; a new entry takes the type's defaults. */
fun addContact(clientId: Int, type: ContactType) {
val client = conn.model.getClient(clientId) ?: return
val client = session.model().getClient(clientId) ?: return
app.contactStore.add(client.uniqueId, client.nickname, type, app.settings.contactDefaults)
}
internal fun contactsChanged() {
treeScope.launch { conn.applyContacts() }
treeScope.launch { session.contacts().applyAll() }
scheduleTree(structure = false)
}
@@ -389,12 +388,12 @@ class ServerController internal constructor(
/** Opens the private chat with a client, loading what was said before. */
fun openPrivateChat(clientId: Int): ChatKey.Private {
val key = ChatKey.Private(clientId)
val client = conn.model.getClient(clientId)
val client = session.model().getClient(clientId)
if (client != null) {
_chats.update { chats ->
chats.update(key, conn.displayName(client)) { it.copy(uniqueId = client.uniqueId) }
chats.update(key, session.contacts().displayName(client)) { it.copy(uniqueId = client.uniqueId) }
}
conn.loadPrivateChatHistory(clientId, client.uniqueId)
session.loadPrivateChatHistory(clientId, client.uniqueId)
}
return key
}
@@ -419,7 +418,7 @@ class ServerController internal constructor(
private fun peer(key: ChatKey) = if (key is ChatKey.Private) key.clientId else 0
/** Where files shared on this server lie; empty before it is known. */
private val room: String get() = conn.serverUniqueId().orEmpty()
private val room: String get() = session.serverUniqueId().orEmpty()
fun markRead(key: ChatKey) {
if (_chats.value[key]?.unread == true) _chats.update { chats -> chats.update(key) { it.copy(unread = false) } }
@@ -455,7 +454,7 @@ class ServerController internal constructor(
// ---- snapshots ----
private fun snapshotState(): SessionState {
val self = conn.model.getClient(conn.selfClientId)
val self = session.model().getClient(session.selfClientId())
return SessionState(
title = session.title(),
status = network.status ?: session.status(),
@@ -466,10 +465,10 @@ class ServerController internal constructor(
micMuted = session.isMicMuted,
deafened = session.isDeafened,
away = session.isAway,
selfClientId = if (session.isConnected) conn.selfClientId else 0,
selfClientId = if (session.isConnected) session.selfClientId() else 0,
channelId = if (session.isConnected) self?.channelId ?: 0 else 0,
inputMode = app.settings.inputMode,
hostButton = if (session.isConnected) conn.model.hostButton() else null,
hostButton = if (session.isConnected) session.model().hostButton() else null,
self = session.selfState(),
whisper = session.whisper()?.label,
whisperNobody = session.isWhisperingToNobody,
@@ -489,10 +488,10 @@ class ServerController internal constructor(
treeScope.launch {
delay(TREE_FRAME_MS)
treePending.set(false)
if (structureChanged.getAndSet(false)) roots = conn.model.buildTree()
_tree.value = ServerTree.of(roots, conn.model, conn.contacts, app.settings.colorContacts,
if (structureChanged.getAndSet(false)) roots = session.model().buildTree()
_tree.value = ServerTree.of(roots, session.model(), session.contacts().store(), app.settings.colorContacts,
app.settings.countryFlags, app.settings.clientRowColors)
val serverName = if (session.isConnected) conn.model.serverName.orEmpty() else ""
val serverName = if (session.isConnected) session.model().serverName.orEmpty() else ""
val channelName = session.currentChannel()?.name.orEmpty()
_chats.update {
it.copy(
@@ -509,8 +508,8 @@ class ServerController internal constructor(
override fun onSystemMessage(text: String) = system(text)
override fun onOwnChat(scope: ChatScope, peerClientId: Int, peerName: String, text: String) {
val self = conn.model.getClient(conn.selfClientId)?.nickname ?: app.settings.nickname
val html = ChatHtml.message(conn.selfClientId, conn.selfUniqueId, "$self (you)", text, room)
val self = session.model().getClient(session.selfClientId())?.nickname ?: app.settings.nickname
val html = ChatHtml.message(session.selfClientId(), session.selfUniqueId(), "$self (you)", text, room)
append(key(scope, peerClientId), peerName, html)
if (scope == ChatScope.PRIVATE) app.notifier.sent(id, peerClientId, ChatHtml.plainMessage(text))
}
@@ -535,7 +534,7 @@ class ServerController internal constructor(
override fun onModelChanged() {
scheduleTree(structure = true)
// A server edit may have changed it.
if (session.isConnected && conn.model.hostButton() != _state.value.hostButton) refresh()
if (session.isConnected && session.model().hostButton() != _state.value.hostButton) refresh()
}
override fun onServerIconChanged(iconId: Long) =
@@ -564,7 +563,7 @@ class ServerController internal constructor(
setHistory(ChatKey.Private(clientId), nickname, htmlEntries)
override fun onTalkStateChanged(clientId: Int, talking: Boolean) {
if (clientId == conn.selfClientId && micOwner) app.talking(talking)
if (clientId == session.selfClientId() && micOwner) app.talking(talking)
scheduleTree(structure = false)
}
@@ -3,7 +3,8 @@ package eu.lixko.ts3j.client.android
import android.graphics.BitmapFactory
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap
import eu.lixko.ts3j.client.net.TeamspeakConnection
import eu.lixko.ts3j.client.net.IconRepository
import eu.lixko.ts3j.client.net.avatar.AvatarRepository
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
@@ -13,7 +14,10 @@ import java.util.concurrent.ConcurrentHashMap
* One server's icons and its clients' avatars, decoded once. What is still
* downloading reads as null until [version] moves on.
*/
class ServerImages internal constructor(private val conn: TeamspeakConnection) {
class ServerImages internal constructor(
private val iconStore: IconRepository,
private val avatarStore: AvatarRepository,
) {
private val icons = ConcurrentHashMap<Long, ImageBitmap>()
private val avatars = ConcurrentHashMap<String, Picture>()
@@ -26,7 +30,7 @@ class ServerImages internal constructor(private val conn: TeamspeakConnection) {
fun icon(id: Long): ImageBitmap? {
if (id == 0L) return null
icons[id]?.let { return it }
val bitmap = conn.icons.get(id)?.let { decode(it, ICON_PX) } ?: return null
val bitmap = iconStore.get(id)?.let { decode(it, ICON_PX) } ?: return null
icons[id] = bitmap
return bitmap
}
@@ -34,14 +38,14 @@ class ServerImages internal constructor(private val conn: TeamspeakConnection) {
fun avatar(uniqueId: String, flag: String): Picture? {
if (flag.isEmpty()) return null
avatars[flag]?.let { return it }
val picture = conn.avatars.get(uniqueId, flag)?.let { decodePicture(it.data(), AVATAR_PX) } ?: return null
val picture = avatarStore.get(uniqueId, flag)?.let { decodePicture(it.data(), AVATAR_PX) } ?: return null
avatars[flag] = picture
return picture
}
/** The avatar's file as the server keeps it; null while it has none or it is still downloading. */
fun avatarData(uniqueId: String, flag: String): ByteArray? =
if (flag.isEmpty()) null else conn.avatars.get(uniqueId, flag)?.data()
if (flag.isEmpty()) null else avatarStore.get(uniqueId, flag)?.data()
/** Decoded no larger than needed: avatars may be far bigger than they are ever shown. */
private fun decode(data: ByteArray, maxPx: Int): ImageBitmap? {
@@ -25,7 +25,7 @@ import eu.lixko.ts3j.client.myts.ChatAttachments
import eu.lixko.ts3j.client.myts.MyTeamSpeak
import eu.lixko.ts3j.client.myts.MyTeamSpeakLogin
import eu.lixko.ts3j.client.net.HostButton
import eu.lixko.ts3j.client.net.TeamspeakConnection
import eu.lixko.ts3j.client.net.ChannelFiles
import eu.lixko.ts3j.client.session.SelfState
import eu.lixko.ts3j.client.session.ServerLink
import eu.lixko.ts3j.client.session.ServerSession
@@ -97,7 +97,7 @@ class SessionController(private val context: Context) {
private val shortcuts = BookmarkShortcuts(context, icons)
val pictures = WebPictures(context.cacheDir, settings)
internal val cacheDir: File get() = context.cacheDir
internal fun fileTransfers(conn: () -> TeamspeakConnection) = FileTransfers(context, conn)
internal fun fileTransfers(files: ChannelFiles) = FileTransfers(context, files)
private val bookmarkStore = Bookmarks.load()
internal val identityStore = IdentityStore.load(settings)
val identities = IdentityManager(context, identityStore, settings, bookmarkStore) {
@@ -204,7 +204,7 @@ class SessionController(private val context: Context) {
fun connect(bookmark: Bookmark) {
start {
it.conn.setMyTeamSpeakFeatures(bookmark.myTeamSpeakFeatures)
it.session.setMyTeamSpeakFeatures(bookmark.myTeamSpeakFeatures)
it.applyBookmark(bookmark)
it.start(bookmark.address, bookmark.port, bookmark.nickname.orEmpty(), bookmark.password,
bookmark.identityId, bookmark.channel, bookmark.channelPassword)
@@ -218,7 +218,7 @@ class SessionController(private val context: Context) {
private fun start(connect: (ServerController) -> Unit) {
val server = ServerController(nextId.incrementAndGet(), this)
server.conn.setMyTeamSpeakLogin(myTeamSpeak)
server.session.setMyTeamSpeakLogin(myTeamSpeak)
sessions.add(server.session)
_servers.update { it + server }
_current.value = server
@@ -462,7 +462,7 @@ class SessionController(private val context: Context) {
withContext(Dispatchers.IO) { myTeamSpeak.signIn(email, password) }
.also {
_myTeamSpeakSignedIn.value = true
_servers.value.forEach { it.conn.updateMyTeamSpeak() }
_servers.value.forEach { it.session.updateMyTeamSpeak() }
// Shared pictures that could not be had signed out.
pictures.retryFailed()
}
@@ -478,7 +478,7 @@ class SessionController(private val context: Context) {
suspend fun signOutMyTeamSpeak() {
myTeamSpeak.signOut()
_myTeamSpeakSignedIn.value = false
_servers.value.forEach { it.conn.updateMyTeamSpeak() }
_servers.value.forEach { it.session.updateMyTeamSpeak() }
withContext(Dispatchers.IO) { attachments.close() }
}
@@ -37,7 +37,7 @@ import androidx.compose.ui.unit.dp
import eu.lixko.ts3j.client.android.ClientItem
import eu.lixko.ts3j.client.android.ServerController
import eu.lixko.ts3j.client.net.GroupChoice
import eu.lixko.ts3j.client.net.TeamspeakConnection
import eu.lixko.ts3j.client.net.ClientAdmin
import eu.lixko.ts3j.client.net.ban.BanRule
import eu.lixko.ts3j.client.net.ban.BanUnit
@@ -48,7 +48,7 @@ fun KickPrompt(title: String, onDismiss: () -> Unit, onKick: (String) -> Unit) {
AlertDialog(
onDismissRequest = onDismiss,
title = { Text(title) },
text = { LimitedField(reason, { reason = it }, "Reason", TeamspeakConnection.KICK_REASON_LIMIT) },
text = { LimitedField(reason, { reason = it }, "Reason", ClientAdmin.KICK_REASON_LIMIT) },
confirmButton = { TextButton(onClick = { onKick(reason.trim()) }) { Text("Kick") } },
dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } },
)