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:
@@ -3,7 +3,7 @@ package eu.lixko.ts3j.client.android
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.OpenableColumns
|
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.FileTransfer
|
||||||
import eu.lixko.ts3j.client.net.filetransfer.RemoteFile
|
import eu.lixko.ts3j.client.net.filetransfer.RemoteFile
|
||||||
import kotlinx.coroutines.Dispatchers
|
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
|
* 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.
|
* 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 ids = AtomicLong()
|
||||||
private val handles = HashMap<Long, FileTransfer>()
|
private val handles = HashMap<Long, FileTransfer>()
|
||||||
@@ -52,7 +52,7 @@ class FileTransfers internal constructor(private val context: Context, private v
|
|||||||
start(row, temp, onComplete = {
|
start(row, temp, onComplete = {
|
||||||
context.contentResolver.openOutputStream(target)?.use { out -> temp.inputStream().use { it.copyTo(out) } }
|
context.contentResolver.openOutputStream(target)?.use { out -> temp.inputStream().use { it.copyTo(out) } }
|
||||||
?: throw IOException("Could not write the file")
|
?: 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. */
|
/** 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 (name, temp) = withContext(Dispatchers.IO) { copyIn(source) }
|
||||||
val row = add(name, upload = true, channelId, directory, temp.length())
|
val row = add(name, upload = true, channelId, directory, temp.length())
|
||||||
start(row, temp, onComplete = {}) { listener ->
|
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 {
|
try {
|
||||||
val back = withTimeoutOrNull(GIVE_UP_MS) {
|
val back = withTimeoutOrNull(GIVE_UP_MS) {
|
||||||
system(if (connectivity.activeNetwork == null) "Network lost." else "Network changed, reconnecting…")
|
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
|
var retry = RETRY_MS
|
||||||
while (true) {
|
while (true) {
|
||||||
val current = awaitNetwork()
|
val current = awaitNetwork()
|
||||||
@@ -156,13 +156,13 @@ class NetworkFollower(context: Context) {
|
|||||||
val connected = done.await()
|
val connected = done.await()
|
||||||
attempt = null
|
attempt = null
|
||||||
if (connected) break
|
if (connected) break
|
||||||
if (session.connection().connectErrorId == ERROR_BANNED) break
|
if (session.connectErrorId() == ERROR_BANNED) break
|
||||||
show("Reconnecting, retrying soon…")
|
show("Reconnecting, retrying soon…")
|
||||||
delay(retry)
|
delay(retry)
|
||||||
retry = (retry * 2).coerceAtMost(MAX_RETRY_MS)
|
retry = (retry * 2).coerceAtMost(MAX_RETRY_MS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (session.connection().connectErrorId == ERROR_BANNED) {
|
if (session.connectErrorId() == ERROR_BANNED) {
|
||||||
wanted = false
|
wanted = false
|
||||||
unbind()
|
unbind()
|
||||||
} else if (back == null) {
|
} else if (back == null) {
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ class ServerController internal constructor(
|
|||||||
internal val session = ServerSession(
|
internal val session = ServerSession(
|
||||||
app.settings, app.identityStore, app.audio, app.sounds, app.contactStore, Listener()
|
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)
|
private val network = app.network.follow(session, ::refresh, ::system)
|
||||||
|
|
||||||
/** Whether this server holds the microphone; set by [SessionController] as it moves. */
|
/** 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)
|
private val _infoUpdates = MutableStateFlow(0)
|
||||||
val infoUpdates: StateFlow<Int> = _infoUpdates
|
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. */
|
/** A private chat a notification asked to show, until the UI took it up. */
|
||||||
private val _chatRequest = MutableStateFlow<ChatKey.Private?>(null)
|
private val _chatRequest = MutableStateFlow<ChatKey.Private?>(null)
|
||||||
@@ -105,8 +104,8 @@ class ServerController internal constructor(
|
|||||||
|
|
||||||
val isConnected: Boolean get() = session.isConnected
|
val isConnected: Boolean get() = session.isConnected
|
||||||
internal val isBusy: Boolean get() = session.isBusy || network.isRecovering
|
internal val isBusy: Boolean get() = session.isBusy || network.isRecovering
|
||||||
internal val microphone get() = if (session.isConnected) conn.ownClient().microphone() else null
|
internal val microphone get() = if (session.isConnected) session.microphone() else null
|
||||||
internal val playback get() = if (session.isConnected) conn.ownClient().playback() 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. */
|
/** Not on the server and not trying to get back on it: done with. */
|
||||||
internal val ended: Boolean get() = started && !isBusy
|
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. */
|
/** 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 }
|
?.also { it.showWhisperControls = whisperControls }
|
||||||
|
|
||||||
fun disconnect() {
|
fun disconnect() {
|
||||||
@@ -183,11 +182,11 @@ class ServerController internal constructor(
|
|||||||
// ---- channels and clients ----
|
// ---- channels and clients ----
|
||||||
|
|
||||||
fun joinChannel(channelId: Int, password: String? = null) {
|
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) {
|
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) =
|
fun toggleCollapsed(channelId: Int) =
|
||||||
@@ -199,44 +198,44 @@ class ServerController internal constructor(
|
|||||||
val permissions: Permissions get() = session.permissions()
|
val permissions: Permissions get() = session.permissions()
|
||||||
|
|
||||||
/** The channel kicked clients go back to; 0 until the server named it. */
|
/** 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) {
|
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) {
|
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. */
|
/** The client's playback volume change in dB; 0 when unchanged. */
|
||||||
fun clientVolume(clientId: Int): Double =
|
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) {
|
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 ----
|
// ---- whisper ----
|
||||||
|
|
||||||
fun setWhisper(whisper: Whisper?) = session.setWhisper(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. */
|
/** The client who whispered to us last, while on the server. */
|
||||||
fun lastWhisperer(): ClientEntry? = session.lastWhisperer()
|
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. */
|
/** 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? =
|
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. */
|
/** The clients on the server, for adding to a whisper list; ourselves left out. */
|
||||||
fun clientRefs(): List<WhisperList.Client> = if (!session.isConnected) emptyList()
|
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) }
|
.sortedBy { it.nickname.lowercase() }.map { WhisperList.Client(it.uniqueId, it.nickname) }
|
||||||
|
|
||||||
fun channelPaths(): List<String> = session.channelPaths()
|
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. */
|
/** 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> =
|
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. */
|
/** A channel's editable properties as the server has them. */
|
||||||
suspend fun channelSettings(channelId: Int): Result<ChannelSettings> = session.channels().settings(channelId).result()
|
suspend fun channelSettings(channelId: Int): Result<ChannelSettings> = session.channels().settings(channelId).result()
|
||||||
@@ -262,20 +261,20 @@ class ServerController internal constructor(
|
|||||||
|
|
||||||
// ---- files ----
|
// ---- 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. */
|
/** 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>> =
|
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> =
|
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> =
|
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> =
|
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) }
|
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()
|
val canRequestTalkPower: Boolean get() = session.canRequestTalkPower()
|
||||||
|
|
||||||
fun kickFromChannel(clientIds: Collection<Int>, reason: String) {
|
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) {
|
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) {
|
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. */
|
/** Bans a client for [seconds], or for good with 0. */
|
||||||
fun ban(clientId: Int, seconds: Long, reason: String) {
|
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> =
|
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> =
|
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) {
|
fun setServerGroup(clientId: Int, groupId: Int, assign: Boolean) {
|
||||||
val client = conn.model.getClient(clientId) ?: return
|
val client = session.model().getClient(clientId) ?: return
|
||||||
if (session.isConnected) conn.setClientServerGroup(client.databaseId, groupId, assign)
|
if (session.isConnected) session.clients().setServerGroup(client.databaseId, groupId, assign)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gives a client [groupId] in the channel they are in. */
|
/** Gives a client [groupId] in the channel they are in. */
|
||||||
fun setChannelGroup(clientId: Int, groupId: Int) {
|
fun setChannelGroup(clientId: Int, groupId: Int) {
|
||||||
val client = conn.model.getClient(clientId) ?: return
|
val client = session.model().getClient(clientId) ?: return
|
||||||
if (session.isConnected) conn.setClientChannelGroup(client.databaseId, client.channelId, groupId)
|
if (session.isConnected) session.clients().setChannelGroup(client.databaseId, client.channelId, groupId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- ban list ----
|
// ---- ban list ----
|
||||||
@@ -322,7 +321,7 @@ class ServerController internal constructor(
|
|||||||
/** One reading of a client's connection figures, or null when not connected. */
|
/** One reading of a client's connection figures, or null when not connected. */
|
||||||
suspend fun connectionStats(clientId: Int): ConnectionStats? =
|
suspend fun connectionStats(clientId: Int): ConnectionStats? =
|
||||||
if (!session.isConnected) null
|
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. */
|
/** The server's bans, or why they could not be read. */
|
||||||
suspend fun banList(): Result<List<BanEntry>> = session.bans().list().result()
|
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()
|
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. */
|
/** Uploads [data] as our avatar. */
|
||||||
suspend fun setAvatar(data: ByteArray): Result<Unit> {
|
suspend fun setAvatar(data: ByteArray): Result<Unit> {
|
||||||
@@ -355,32 +354,32 @@ class ServerController internal constructor(
|
|||||||
// ---- details ----
|
// ---- details ----
|
||||||
|
|
||||||
fun serverDetails(): 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 {
|
fun clientDetails(clientId: Int): Details? = session.model().getClient(clientId)?.let {
|
||||||
Details.client(it, conn.model, app.contactStore.find(it.uniqueId))
|
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. */
|
/** Asks the server for what the channel's details lack; they change once it answers. */
|
||||||
fun requestChannelDetails(channelId: Int) {
|
fun requestChannelDetails(channelId: Int) {
|
||||||
val channel = conn.model.getChannel(channelId) ?: return
|
val channel = session.model().getChannel(channelId) ?: return
|
||||||
if (session.isConnected && !channel.descriptionLoaded) conn.requestChannelInfo(channelId)
|
if (session.isConnected && !channel.descriptionLoaded) session.channels().requestInfo(channelId)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun requestClientDetails(clientId: Int) {
|
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. */
|
/** Files a client on the server as a contact; a new entry takes the type's defaults. */
|
||||||
fun addContact(clientId: Int, type: ContactType) {
|
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)
|
app.contactStore.add(client.uniqueId, client.nickname, type, app.settings.contactDefaults)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun contactsChanged() {
|
internal fun contactsChanged() {
|
||||||
treeScope.launch { conn.applyContacts() }
|
treeScope.launch { session.contacts().applyAll() }
|
||||||
scheduleTree(structure = false)
|
scheduleTree(structure = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,12 +388,12 @@ class ServerController internal constructor(
|
|||||||
/** Opens the private chat with a client, loading what was said before. */
|
/** Opens the private chat with a client, loading what was said before. */
|
||||||
fun openPrivateChat(clientId: Int): ChatKey.Private {
|
fun openPrivateChat(clientId: Int): ChatKey.Private {
|
||||||
val key = ChatKey.Private(clientId)
|
val key = ChatKey.Private(clientId)
|
||||||
val client = conn.model.getClient(clientId)
|
val client = session.model().getClient(clientId)
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
_chats.update { chats ->
|
_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
|
return key
|
||||||
}
|
}
|
||||||
@@ -419,7 +418,7 @@ class ServerController internal constructor(
|
|||||||
private fun peer(key: ChatKey) = if (key is ChatKey.Private) key.clientId else 0
|
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. */
|
/** 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) {
|
fun markRead(key: ChatKey) {
|
||||||
if (_chats.value[key]?.unread == true) _chats.update { chats -> chats.update(key) { it.copy(unread = false) } }
|
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 ----
|
// ---- snapshots ----
|
||||||
|
|
||||||
private fun snapshotState(): SessionState {
|
private fun snapshotState(): SessionState {
|
||||||
val self = conn.model.getClient(conn.selfClientId)
|
val self = session.model().getClient(session.selfClientId())
|
||||||
return SessionState(
|
return SessionState(
|
||||||
title = session.title(),
|
title = session.title(),
|
||||||
status = network.status ?: session.status(),
|
status = network.status ?: session.status(),
|
||||||
@@ -466,10 +465,10 @@ class ServerController internal constructor(
|
|||||||
micMuted = session.isMicMuted,
|
micMuted = session.isMicMuted,
|
||||||
deafened = session.isDeafened,
|
deafened = session.isDeafened,
|
||||||
away = session.isAway,
|
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,
|
channelId = if (session.isConnected) self?.channelId ?: 0 else 0,
|
||||||
inputMode = app.settings.inputMode,
|
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(),
|
self = session.selfState(),
|
||||||
whisper = session.whisper()?.label,
|
whisper = session.whisper()?.label,
|
||||||
whisperNobody = session.isWhisperingToNobody,
|
whisperNobody = session.isWhisperingToNobody,
|
||||||
@@ -489,10 +488,10 @@ class ServerController internal constructor(
|
|||||||
treeScope.launch {
|
treeScope.launch {
|
||||||
delay(TREE_FRAME_MS)
|
delay(TREE_FRAME_MS)
|
||||||
treePending.set(false)
|
treePending.set(false)
|
||||||
if (structureChanged.getAndSet(false)) roots = conn.model.buildTree()
|
if (structureChanged.getAndSet(false)) roots = session.model().buildTree()
|
||||||
_tree.value = ServerTree.of(roots, conn.model, conn.contacts, app.settings.colorContacts,
|
_tree.value = ServerTree.of(roots, session.model(), session.contacts().store(), app.settings.colorContacts,
|
||||||
app.settings.countryFlags, app.settings.clientRowColors)
|
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()
|
val channelName = session.currentChannel()?.name.orEmpty()
|
||||||
_chats.update {
|
_chats.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
@@ -509,8 +508,8 @@ class ServerController internal constructor(
|
|||||||
override fun onSystemMessage(text: String) = system(text)
|
override fun onSystemMessage(text: String) = system(text)
|
||||||
|
|
||||||
override fun onOwnChat(scope: ChatScope, peerClientId: Int, peerName: String, text: String) {
|
override fun onOwnChat(scope: ChatScope, peerClientId: Int, peerName: String, text: String) {
|
||||||
val self = conn.model.getClient(conn.selfClientId)?.nickname ?: app.settings.nickname
|
val self = session.model().getClient(session.selfClientId())?.nickname ?: app.settings.nickname
|
||||||
val html = ChatHtml.message(conn.selfClientId, conn.selfUniqueId, "$self (you)", text, room)
|
val html = ChatHtml.message(session.selfClientId(), session.selfUniqueId(), "$self (you)", text, room)
|
||||||
append(key(scope, peerClientId), peerName, html)
|
append(key(scope, peerClientId), peerName, html)
|
||||||
if (scope == ChatScope.PRIVATE) app.notifier.sent(id, peerClientId, ChatHtml.plainMessage(text))
|
if (scope == ChatScope.PRIVATE) app.notifier.sent(id, peerClientId, ChatHtml.plainMessage(text))
|
||||||
}
|
}
|
||||||
@@ -535,7 +534,7 @@ class ServerController internal constructor(
|
|||||||
override fun onModelChanged() {
|
override fun onModelChanged() {
|
||||||
scheduleTree(structure = true)
|
scheduleTree(structure = true)
|
||||||
// A server edit may have changed it.
|
// 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) =
|
override fun onServerIconChanged(iconId: Long) =
|
||||||
@@ -564,7 +563,7 @@ class ServerController internal constructor(
|
|||||||
setHistory(ChatKey.Private(clientId), nickname, htmlEntries)
|
setHistory(ChatKey.Private(clientId), nickname, htmlEntries)
|
||||||
|
|
||||||
override fun onTalkStateChanged(clientId: Int, talking: Boolean) {
|
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)
|
scheduleTree(structure = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ package eu.lixko.ts3j.client.android
|
|||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import androidx.compose.ui.graphics.ImageBitmap
|
import androidx.compose.ui.graphics.ImageBitmap
|
||||||
import androidx.compose.ui.graphics.asImageBitmap
|
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.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
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
|
* One server's icons and its clients' avatars, decoded once. What is still
|
||||||
* downloading reads as null until [version] moves on.
|
* 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 icons = ConcurrentHashMap<Long, ImageBitmap>()
|
||||||
private val avatars = ConcurrentHashMap<String, Picture>()
|
private val avatars = ConcurrentHashMap<String, Picture>()
|
||||||
@@ -26,7 +30,7 @@ class ServerImages internal constructor(private val conn: TeamspeakConnection) {
|
|||||||
fun icon(id: Long): ImageBitmap? {
|
fun icon(id: Long): ImageBitmap? {
|
||||||
if (id == 0L) return null
|
if (id == 0L) return null
|
||||||
icons[id]?.let { return it }
|
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
|
icons[id] = bitmap
|
||||||
return bitmap
|
return bitmap
|
||||||
}
|
}
|
||||||
@@ -34,14 +38,14 @@ class ServerImages internal constructor(private val conn: TeamspeakConnection) {
|
|||||||
fun avatar(uniqueId: String, flag: String): Picture? {
|
fun avatar(uniqueId: String, flag: String): Picture? {
|
||||||
if (flag.isEmpty()) return null
|
if (flag.isEmpty()) return null
|
||||||
avatars[flag]?.let { return it }
|
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
|
avatars[flag] = picture
|
||||||
return picture
|
return picture
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The avatar's file as the server keeps it; null while it has none or it is still downloading. */
|
/** 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? =
|
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. */
|
/** Decoded no larger than needed: avatars may be far bigger than they are ever shown. */
|
||||||
private fun decode(data: ByteArray, maxPx: Int): ImageBitmap? {
|
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.MyTeamSpeak
|
||||||
import eu.lixko.ts3j.client.myts.MyTeamSpeakLogin
|
import eu.lixko.ts3j.client.myts.MyTeamSpeakLogin
|
||||||
import eu.lixko.ts3j.client.net.HostButton
|
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.SelfState
|
||||||
import eu.lixko.ts3j.client.session.ServerLink
|
import eu.lixko.ts3j.client.session.ServerLink
|
||||||
import eu.lixko.ts3j.client.session.ServerSession
|
import eu.lixko.ts3j.client.session.ServerSession
|
||||||
@@ -97,7 +97,7 @@ class SessionController(private val context: Context) {
|
|||||||
private val shortcuts = BookmarkShortcuts(context, icons)
|
private val shortcuts = BookmarkShortcuts(context, icons)
|
||||||
val pictures = WebPictures(context.cacheDir, settings)
|
val pictures = WebPictures(context.cacheDir, settings)
|
||||||
internal val cacheDir: File get() = context.cacheDir
|
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()
|
private val bookmarkStore = Bookmarks.load()
|
||||||
internal val identityStore = IdentityStore.load(settings)
|
internal val identityStore = IdentityStore.load(settings)
|
||||||
val identities = IdentityManager(context, identityStore, settings, bookmarkStore) {
|
val identities = IdentityManager(context, identityStore, settings, bookmarkStore) {
|
||||||
@@ -204,7 +204,7 @@ class SessionController(private val context: Context) {
|
|||||||
|
|
||||||
fun connect(bookmark: Bookmark) {
|
fun connect(bookmark: Bookmark) {
|
||||||
start {
|
start {
|
||||||
it.conn.setMyTeamSpeakFeatures(bookmark.myTeamSpeakFeatures)
|
it.session.setMyTeamSpeakFeatures(bookmark.myTeamSpeakFeatures)
|
||||||
it.applyBookmark(bookmark)
|
it.applyBookmark(bookmark)
|
||||||
it.start(bookmark.address, bookmark.port, bookmark.nickname.orEmpty(), bookmark.password,
|
it.start(bookmark.address, bookmark.port, bookmark.nickname.orEmpty(), bookmark.password,
|
||||||
bookmark.identityId, bookmark.channel, bookmark.channelPassword)
|
bookmark.identityId, bookmark.channel, bookmark.channelPassword)
|
||||||
@@ -218,7 +218,7 @@ class SessionController(private val context: Context) {
|
|||||||
|
|
||||||
private fun start(connect: (ServerController) -> Unit) {
|
private fun start(connect: (ServerController) -> Unit) {
|
||||||
val server = ServerController(nextId.incrementAndGet(), this)
|
val server = ServerController(nextId.incrementAndGet(), this)
|
||||||
server.conn.setMyTeamSpeakLogin(myTeamSpeak)
|
server.session.setMyTeamSpeakLogin(myTeamSpeak)
|
||||||
sessions.add(server.session)
|
sessions.add(server.session)
|
||||||
_servers.update { it + server }
|
_servers.update { it + server }
|
||||||
_current.value = server
|
_current.value = server
|
||||||
@@ -462,7 +462,7 @@ class SessionController(private val context: Context) {
|
|||||||
withContext(Dispatchers.IO) { myTeamSpeak.signIn(email, password) }
|
withContext(Dispatchers.IO) { myTeamSpeak.signIn(email, password) }
|
||||||
.also {
|
.also {
|
||||||
_myTeamSpeakSignedIn.value = true
|
_myTeamSpeakSignedIn.value = true
|
||||||
_servers.value.forEach { it.conn.updateMyTeamSpeak() }
|
_servers.value.forEach { it.session.updateMyTeamSpeak() }
|
||||||
// Shared pictures that could not be had signed out.
|
// Shared pictures that could not be had signed out.
|
||||||
pictures.retryFailed()
|
pictures.retryFailed()
|
||||||
}
|
}
|
||||||
@@ -478,7 +478,7 @@ class SessionController(private val context: Context) {
|
|||||||
suspend fun signOutMyTeamSpeak() {
|
suspend fun signOutMyTeamSpeak() {
|
||||||
myTeamSpeak.signOut()
|
myTeamSpeak.signOut()
|
||||||
_myTeamSpeakSignedIn.value = false
|
_myTeamSpeakSignedIn.value = false
|
||||||
_servers.value.forEach { it.conn.updateMyTeamSpeak() }
|
_servers.value.forEach { it.session.updateMyTeamSpeak() }
|
||||||
withContext(Dispatchers.IO) { attachments.close() }
|
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.ClientItem
|
||||||
import eu.lixko.ts3j.client.android.ServerController
|
import eu.lixko.ts3j.client.android.ServerController
|
||||||
import eu.lixko.ts3j.client.net.GroupChoice
|
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.BanRule
|
||||||
import eu.lixko.ts3j.client.net.ban.BanUnit
|
import eu.lixko.ts3j.client.net.ban.BanUnit
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ fun KickPrompt(title: String, onDismiss: () -> Unit, onKick: (String) -> Unit) {
|
|||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = onDismiss,
|
onDismissRequest = onDismiss,
|
||||||
title = { Text(title) },
|
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") } },
|
confirmButton = { TextButton(onClick = { onKick(reason.trim()) }) { Text("Kick") } },
|
||||||
dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } },
|
dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } },
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ Items are worked through in the order below. Status: open, done (commit), or clo
|
|||||||
| 4a | … chat log and what we tell the user (log lines, sounds, links and sound variables) | done (`1bc7eb5`): `ChatLog`, `Announcer` |
|
| 4a | … chat log and what we tell the user (log lines, sounds, links and sound variables) | done (`1bc7eb5`): `ChatLog`, `Announcer` |
|
||||||
| 4b | … request plumbing into its own class; `*Admin` helpers on narrow dependencies instead of the whole connection | done (`da908f7`; renamed `Uplink` in 4c, as `session.ServerLink` is the `ts3server://` link): `ServerLink` owns the socket, event and request threads and file transfers, and runs requests; the helpers take it (plus the model, permissions or avatars where they need them) |
|
| 4b | … request plumbing into its own class; `*Admin` helpers on narrow dependencies instead of the whole connection | done (`da908f7`; renamed `Uplink` in 4c, as `session.ServerLink` is the `ts3server://` link): `ServerLink` owns the socket, event and request threads and file transfers, and runs requests; the helpers take it (plus the model, permissions or avatars where they need them) |
|
||||||
| 4c | … frontends reach the admin helpers directly instead of ~40 one-line forwarders | done (`959f7ed`): the helpers are public with non-blocking methods, reached through `ServerSession`/`TeamspeakConnection` getters; 30 forwarders gone, and what they added (stop-at-first-refusal loops, log lines, description refresh, own avatar flag) moved into the helpers. Swing dialogs still take the whole connection for the model and our ids (item 5) |
|
| 4c | … frontends reach the admin helpers directly instead of ~40 one-line forwarders | done (`959f7ed`): the helpers are public with non-blocking methods, reached through `ServerSession`/`TeamspeakConnection` getters; 30 forwarders gone, and what they added (stop-at-first-refusal loops, log lines, description refresh, own avatar flag) moved into the helpers. Swing dialogs still take the whole connection for the model and our ids (item 5) |
|
||||||
| 4d | … our own state (mic, speakers, away, talk request, recording) out of the connection | done (uncommitted): `OwnClient` owns the devices and our flags, and publishes them; `Recording` the recorder. `ServerSession` no longer keeps its own copy of the flags, and they are cleared when a connect starts rather than once it is done |
|
| 4d | … our own state (mic, speakers, away, talk request, recording) out of the connection | done (`9107bdd`): `OwnClient` owns the devices and our flags, and publishes them; `Recording` the recorder. `ServerSession` no longer keeps its own copy of the flags, and they are cleared when a connect starts rather than once it is done |
|
||||||
| 5 | Two front doors: frontends use both `ServerSession` and `session.connection()` with no rule for which | open |
|
| 5 | Two front doors: frontends use both `ServerSession` and `session.connection()` with no rule for which | done (uncommitted): `connection()` is gone; frontends reach the model, our ids, devices and the helpers through `ServerSession`. New helpers took the remaining actions off the connection: `ClientAdmin` (move, kick, ban, groups, talk power, poke, details), `ChannelFiles`, `ClientContacts`; `ChannelAdmin` also joins, moves and subscribes. Dialogs take the session, or only the helper they use |
|
||||||
| 6 | Menu bar, toolbar and hotkeys each implement the same commands: `MainMenuBar.Listener` (~50 methods, ~210 lines of forwarding in `MainFrame`), `MainToolbar.Listener`, `HotkeyActions` | open |
|
| 6 | Menu bar, toolbar and hotkeys each implement the same commands: `MainMenuBar.Listener` (~50 methods, ~210 lines of forwarding in `MainFrame`), `MainToolbar.Listener`, `HotkeyActions` | open |
|
||||||
| 7 | The admin list dialogs (bans, complaints, offline messages, privilege keys, server log) repeat the load/status/table-model scaffolding | open |
|
| 7 | The admin list dialogs (bans, complaints, offline messages, privilege keys, server log) repeat the load/status/table-model scaffolding | open |
|
||||||
| 8 | `Settings`: 58 public fields, each key spelled twice (load and save), no change notification, so callers fan changes out by hand | open |
|
| 8 | `Settings`: 58 public fields, each key spelled twice (load and save), no change notification, so callers fan changes out by hand | open |
|
||||||
|
|||||||
@@ -226,15 +226,19 @@ core/ eu.lixko.ts3j.client
|
|||||||
│ AwayMessages, …; AppDirs finds it, ProfileFiles writes it
|
│ AwayMessages, …; AppDirs finds it, ProfileFiles writes it
|
||||||
│ privately and all at once
|
│ privately and all at once
|
||||||
├── session
|
├── session
|
||||||
│ ├── ServerSession one server tab's state and actions, whatever the frontend
|
│ ├── ServerSession one server tab's state and actions, whatever the frontend;
|
||||||
|
│ │ the frontends' only way in to a server
|
||||||
│ └── Sessions what the servers share: the microphone, away state, nickname
|
│ └── Sessions what the servers share: the microphone, away state, nickname
|
||||||
├── net
|
├── net
|
||||||
│ ├── TeamspeakConnection ties socket + audio + model; runs requests on its own pool
|
│ ├── TeamspeakConnection ties socket + audio + model; the connection lifecycle
|
||||||
│ ├── ConnectionEventHandler server events → model changes, sounds and log lines
|
│ ├── ConnectionEventHandler server events → model changes, sounds and log lines
|
||||||
│ ├── ServerModel channel/client state; ChannelNode/ClientEntry view models
|
│ ├── ServerModel channel/client state; ChannelNode/ClientEntry view models
|
||||||
│ ├── ChannelAdmin/BanAdmin/AvatarAdmin channel editing, the ban list, our own avatar
|
│ ├── ClientAdmin/ChannelAdmin what we do to clients and channels
|
||||||
|
│ ├── BanAdmin/AvatarAdmin/… the ban list, our own avatar and the other admin lists
|
||||||
|
│ ├── ChannelFiles channel file browsing, up- and downloads
|
||||||
|
│ ├── ClientContacts the contact list applied to a server's clients
|
||||||
│ ├── IconRepository server icons (avatar/ holds the client avatar cache)
|
│ ├── IconRepository server icons (avatar/ holds the client avatar cache)
|
||||||
│ ├── filetransfer channel file browsing, up- and downloads
|
│ ├── filetransfer the file transfer protocol
|
||||||
│ └── ConnectionListener frontend callbacks
|
│ └── ConnectionListener frontend callbacks
|
||||||
├── audio the voice pipelines every platform shares
|
├── audio the voice pipelines every platform shares
|
||||||
│ ├── AudioBackend/AudioIo what a platform supplies: devices, lines, Opus
|
│ ├── AudioBackend/AudioIo what a platform supplies: devices, lines, Opus
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Everything the channel editor needs of the server: reading and writing a channel's
|
* What we do with channels: joining, moving and subscribing to them, and what the channel
|
||||||
* properties and its needed-power permissions, plus the virtual server's icon store.
|
* editor needs of the server: reading and writing a channel's properties and its
|
||||||
|
* needed-power permissions, plus the virtual server's icon store.
|
||||||
*
|
*
|
||||||
* <p>Requests run in the background and fail with a {@link RequestException}.
|
* <p>Requests run in the background and fail with a {@link RequestException}; the actions
|
||||||
|
* that return nothing report a failure in the log.
|
||||||
*/
|
*/
|
||||||
public final class ChannelAdmin {
|
public final class ChannelAdmin {
|
||||||
|
|
||||||
@@ -38,6 +40,7 @@ public final class ChannelAdmin {
|
|||||||
|
|
||||||
private final Uplink uplink;
|
private final Uplink uplink;
|
||||||
private final ServerModel model;
|
private final ServerModel model;
|
||||||
|
private final Announcer announce;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code channelpermlist} reply in progress. TeamSpeak answers the command with a
|
* The {@code channelpermlist} reply in progress. TeamSpeak answers the command with a
|
||||||
@@ -47,9 +50,79 @@ public final class ChannelAdmin {
|
|||||||
*/
|
*/
|
||||||
private volatile PermRequest permRequest;
|
private volatile PermRequest permRequest;
|
||||||
|
|
||||||
ChannelAdmin(Uplink uplink, ServerModel model) {
|
ChannelAdmin(Uplink uplink, ServerModel model, Announcer announce) {
|
||||||
this.uplink = uplink;
|
this.uplink = uplink;
|
||||||
this.model = model;
|
this.model = model;
|
||||||
|
this.announce = announce;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- channel actions ----
|
||||||
|
|
||||||
|
/** @param password the channel's password, or null or empty when it has none */
|
||||||
|
public void join(int channelId, String password) {
|
||||||
|
act("Could not join channel: ", sock ->
|
||||||
|
sock.joinChannel(channelId, (password == null || password.isEmpty()) ? null : password));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-parents and repositions a channel.
|
||||||
|
*
|
||||||
|
* @param orderPredecessorId the channel this one should sit below among its new
|
||||||
|
* siblings, or 0 to place it first
|
||||||
|
*/
|
||||||
|
public void move(int channelId, int newParentId, int orderPredecessorId) {
|
||||||
|
ChannelNode channel = model.getChannel(channelId);
|
||||||
|
// The server refuses channelmove within the same parent ("already member of
|
||||||
|
// channel"); sorting among the same siblings is an edit of channel_order.
|
||||||
|
boolean reorder = channel != null && channel.parentId == newParentId;
|
||||||
|
act("Could not move channel: ", sock -> {
|
||||||
|
SingleCommand cmd;
|
||||||
|
if (reorder) {
|
||||||
|
cmd = new SingleCommand("channeledit", ProtocolRole.CLIENT);
|
||||||
|
cmd.add(new CommandSingleParameter("cid", Integer.toString(channelId)));
|
||||||
|
cmd.add(new CommandSingleParameter("channel_order", Integer.toString(orderPredecessorId)));
|
||||||
|
} else {
|
||||||
|
cmd = new SingleCommand("channelmove", ProtocolRole.CLIENT);
|
||||||
|
cmd.add(new CommandSingleParameter("cid", Integer.toString(channelId)));
|
||||||
|
cmd.add(new CommandSingleParameter("cpid", Integer.toString(newParentId)));
|
||||||
|
cmd.add(new CommandSingleParameter("order", Integer.toString(orderPredecessorId)));
|
||||||
|
}
|
||||||
|
sock.executeCommand(cmd).complete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subscribes to (or unsubscribes from) a set of channels in one command. The model
|
||||||
|
* is left alone: the server answers with the subscription events that update it.
|
||||||
|
*/
|
||||||
|
public void setSubscribed(Collection<Integer> channelIds, boolean subscribed) {
|
||||||
|
if (channelIds.isEmpty()) return;
|
||||||
|
List<Integer> ids = List.copyOf(channelIds);
|
||||||
|
String name = subscribed ? "channelsubscribe" : "channelunsubscribe";
|
||||||
|
act(subscribed ? "Could not subscribe: " : "Could not unsubscribe: ", sock -> {
|
||||||
|
List<SingleCommand> parts = new ArrayList<>(ids.size());
|
||||||
|
for (int id : ids) {
|
||||||
|
parts.add(new SingleCommand(name, ProtocolRole.CLIENT,
|
||||||
|
new CommandSingleParameter("cid", Integer.toString(id))));
|
||||||
|
}
|
||||||
|
sock.executeCommand(new MultiCommand(name, ProtocolRole.CLIENT, parts)).complete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asks for a channel's description. The answer arrives as a channel edit, see
|
||||||
|
* {@link ConnectionEventHandler#onChannelEdit}. Uses {@code channelgetdescription}, not
|
||||||
|
* {@code channelinfo}, which counts heavily against the server's flood protection. May
|
||||||
|
* be refused; the description then stays unknown.
|
||||||
|
*/
|
||||||
|
public void requestInfo(int channelId) {
|
||||||
|
uplink.submit(sock -> sock.executeCommand(new SingleCommand("channelgetdescription", ProtocolRole.CLIENT,
|
||||||
|
new CommandSingleParameter("cid", Integer.toString(channelId)))).complete(), e -> {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void act(String errorPrefix, Uplink.Action action) {
|
||||||
|
uplink.submit(action, e -> announce.error(errorPrefix, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- channel properties ----
|
// ---- channel properties ----
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package eu.lixko.ts3j.client.net;
|
||||||
|
|
||||||
|
import eu.lixko.ts3j.client.net.filetransfer.FileTransfer;
|
||||||
|
import eu.lixko.ts3j.client.net.filetransfer.RemoteFile;
|
||||||
|
import eu.lixko.ts3j.client.sound.SoundEvent;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The channels' file repositories: browsing, managing and transferring files. The listing
|
||||||
|
* and management calls block; call them off the UI thread. They throw when not connected
|
||||||
|
* or when the server refuses.
|
||||||
|
*/
|
||||||
|
public final class ChannelFiles {
|
||||||
|
|
||||||
|
private final Uplink uplink;
|
||||||
|
private final Announcer announce;
|
||||||
|
|
||||||
|
ChannelFiles(Uplink uplink, Announcer announce) {
|
||||||
|
this.uplink = uplink;
|
||||||
|
this.announce = announce;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether a live connection capable of file transfers is available. */
|
||||||
|
public boolean isAvailable() {
|
||||||
|
return uplink.canTransferFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Lists the files under {@code path} in a channel's repository. */
|
||||||
|
public List<RemoteFile> list(int channelId, String channelPassword, String path) throws Exception {
|
||||||
|
return uplink.files().list(channelId, channelPassword, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createDirectory(int channelId, String channelPassword, String dirPath) throws Exception {
|
||||||
|
uplink.files().createDirectory(channelId, channelPassword, dirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(int channelId, String channelPassword, String fullPath) throws Exception {
|
||||||
|
uplink.files().delete(channelId, channelPassword, fullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rename(int channelId, String channelPassword, String oldFullPath, String newFullPath)
|
||||||
|
throws Exception {
|
||||||
|
uplink.files().rename(channelId, channelPassword, oldFullPath, newFullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Begins downloading a channel file to {@code target}; progress arrives via {@code listener}. */
|
||||||
|
public FileTransfer download(int channelId, String channelPassword, String remoteFullPath,
|
||||||
|
File target, FileTransfer.Listener listener) {
|
||||||
|
return uplink.files().download(channelId, channelPassword, remoteFullPath, target, announcing(listener));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Begins uploading {@code source} into a channel; progress arrives via {@code listener}. */
|
||||||
|
public FileTransfer upload(int channelId, String channelPassword, String remoteFullPath,
|
||||||
|
File source, boolean overwrite, FileTransfer.Listener listener) {
|
||||||
|
return uplink.files().upload(channelId, channelPassword, remoteFullPath, source, overwrite, announcing(listener));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps a transfer listener so the completion and failure sounds play once the
|
||||||
|
* transfer finishes, whoever is watching it.
|
||||||
|
*/
|
||||||
|
private FileTransfer.Listener announcing(FileTransfer.Listener listener) {
|
||||||
|
AtomicBoolean announced = new AtomicBoolean();
|
||||||
|
return transfer -> {
|
||||||
|
FileTransfer.State state = transfer.getState();
|
||||||
|
if (state != FileTransfer.State.CANCELLED && transfer.isDone()
|
||||||
|
&& announced.compareAndSet(false, true)) {
|
||||||
|
announce.sound(state == FileTransfer.State.COMPLETED
|
||||||
|
? SoundEvent.OTHER_FILETRANSFER_COMPLETE
|
||||||
|
: SoundEvent.OTHER_FILETRANSFER_FAILED, announce.serverVars());
|
||||||
|
}
|
||||||
|
if (listener != null) listener.onTransferChanged(transfer);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,225 @@
|
|||||||
|
package eu.lixko.ts3j.client.net;
|
||||||
|
|
||||||
|
import com.github.manevolent.ts3j.api.Client;
|
||||||
|
import com.github.manevolent.ts3j.command.MultiCommand;
|
||||||
|
import com.github.manevolent.ts3j.command.SingleCommand;
|
||||||
|
import com.github.manevolent.ts3j.command.parameter.CommandSingleParameter;
|
||||||
|
import com.github.manevolent.ts3j.protocol.ProtocolRole;
|
||||||
|
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
||||||
|
import eu.lixko.ts3j.client.sound.SoundEvent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.function.IntSupplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What we do to other clients (or ourselves among them): moving, kicking, banning, groups,
|
||||||
|
* talk power, pokes, and reading or editing their details.
|
||||||
|
*
|
||||||
|
* <p>The actions run in the background and report a failure in the log; the requests that
|
||||||
|
* return a future fail it with a {@link RequestException} instead.
|
||||||
|
*/
|
||||||
|
public final class ClientAdmin {
|
||||||
|
|
||||||
|
/** The longest reason the protocol carries with a kick. */
|
||||||
|
public static final int KICK_REASON_LIMIT = 40;
|
||||||
|
|
||||||
|
/** The protocol's reason ids for the two flavours of <b>clientkick</b>. */
|
||||||
|
private static final int REASON_KICK_CHANNEL = 4;
|
||||||
|
private static final int REASON_KICK_SERVER = 5;
|
||||||
|
|
||||||
|
private final Uplink uplink;
|
||||||
|
private final ServerModel model;
|
||||||
|
private final Announcer announce;
|
||||||
|
private final IntSupplier selfClientId;
|
||||||
|
/** Tells the frontend a client's details changed where the server will not. */
|
||||||
|
private final Runnable infoUpdated;
|
||||||
|
|
||||||
|
ClientAdmin(Uplink uplink, ServerModel model, Announcer announce, IntSupplier selfClientId, Runnable infoUpdated) {
|
||||||
|
this.uplink = uplink;
|
||||||
|
this.model = model;
|
||||||
|
this.announce = announce;
|
||||||
|
this.selfClientId = selfClientId;
|
||||||
|
this.infoUpdated = infoUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves several clients (ourselves among them, if wanted) into a channel in one piped
|
||||||
|
* command. Clients already in it are left out, which the server would refuse.
|
||||||
|
*/
|
||||||
|
public void move(Collection<Integer> clientIds, int channelId) {
|
||||||
|
List<SingleCommand> rows = new ArrayList<>(clientIds.size());
|
||||||
|
for (int id : clientIds) {
|
||||||
|
ClientEntry client = model.getClient(id);
|
||||||
|
if (client != null && client.channelId == channelId) continue;
|
||||||
|
rows.add(new SingleCommand("clientmove", ProtocolRole.CLIENT,
|
||||||
|
new CommandSingleParameter("clid", Integer.toString(id))));
|
||||||
|
}
|
||||||
|
if (rows.isEmpty()) return;
|
||||||
|
act(rows.size() == 1 ? "Could not move client: " : "Could not move clients: ", sock -> {
|
||||||
|
MultiCommand cmd = new MultiCommand("clientmove", ProtocolRole.CLIENT, rows);
|
||||||
|
cmd.add(new CommandSingleParameter("cid", Integer.toString(channelId)));
|
||||||
|
sock.executeCommand(cmd).complete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kicks clients out of their channels in one command; we are never among them, nor are
|
||||||
|
* clients already in the default channel, as the server would refuse the whole command.
|
||||||
|
*/
|
||||||
|
public void kickFromChannel(Collection<Integer> clientIds, String reason) {
|
||||||
|
int defaultChannel = model.defaultChannelId();
|
||||||
|
List<Integer> ids = new ArrayList<>(clientIds.size());
|
||||||
|
for (int id : clientIds) {
|
||||||
|
ClientEntry client = model.getClient(id);
|
||||||
|
if (client == null || client.channelId != defaultChannel) ids.add(id);
|
||||||
|
}
|
||||||
|
kick(ids, REASON_KICK_CHANNEL, reason, "channel");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Kicks clients off the server in one command; we are never among them. */
|
||||||
|
public void kickFromServer(Collection<Integer> clientIds, String reason) {
|
||||||
|
kick(clientIds, REASON_KICK_SERVER, reason, "server");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void kick(Collection<Integer> clientIds, int reasonId, String reason, String from) {
|
||||||
|
int self = selfClientId.getAsInt();
|
||||||
|
List<SingleCommand> rows = new ArrayList<>(clientIds.size());
|
||||||
|
for (int id : clientIds) {
|
||||||
|
if (id == self) continue;
|
||||||
|
rows.add(new SingleCommand("clientkick", ProtocolRole.CLIENT,
|
||||||
|
new CommandSingleParameter("clid", Integer.toString(id))));
|
||||||
|
}
|
||||||
|
if (rows.isEmpty()) return;
|
||||||
|
String errorPrefix = "Could not kick " + (rows.size() == 1 ? "client" : "clients") + " from the " + from + ": ";
|
||||||
|
act(errorPrefix, sock -> {
|
||||||
|
MultiCommand cmd = new MultiCommand("clientkick", ProtocolRole.CLIENT, rows);
|
||||||
|
cmd.add(new CommandSingleParameter("reasonid", Integer.toString(reasonId)));
|
||||||
|
if (reason != null && !reason.isEmpty()) {
|
||||||
|
cmd.add(new CommandSingleParameter("reasonmsg", reason));
|
||||||
|
}
|
||||||
|
sock.executeCommand(cmd).complete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bans a client from the server.
|
||||||
|
*
|
||||||
|
* @param seconds how long the ban lasts, or 0 for a permanent one
|
||||||
|
*/
|
||||||
|
public void ban(int clientId, long seconds, String reason) {
|
||||||
|
act("Could not ban client: ", sock -> sock.banClient(clientId,
|
||||||
|
seconds <= 0 ? null : (int) Math.min(seconds, Integer.MAX_VALUE),
|
||||||
|
reason == null || reason.isEmpty() ? null : reason));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Assigns or removes a server group for a client (by database id, as {@code servergroupaddclient} needs). */
|
||||||
|
public void setServerGroup(int clientDatabaseId, int groupId, boolean assign) {
|
||||||
|
act("Could not " + (assign ? "assign" : "remove") + " server group: ", sock -> {
|
||||||
|
if (assign) sock.serverGroupAddClient(groupId, clientDatabaseId);
|
||||||
|
else sock.serverGroupRemoveClient(groupId, clientDatabaseId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Assigns a channel group for a client in the channel it currently sits in. */
|
||||||
|
public void setChannelGroup(int clientDatabaseId, int channelId, int groupId) {
|
||||||
|
act("Could not set channel group: ", sock -> {
|
||||||
|
SingleCommand cmd = new SingleCommand("setclientchannelgroup", ProtocolRole.CLIENT);
|
||||||
|
cmd.add(new CommandSingleParameter("cgid", Integer.toString(groupId)));
|
||||||
|
cmd.add(new CommandSingleParameter("cid", Integer.toString(channelId)));
|
||||||
|
cmd.add(new CommandSingleParameter("cldbid", Integer.toString(clientDatabaseId)));
|
||||||
|
sock.executeCommand(cmd).complete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void poke(int clientId, String message) {
|
||||||
|
act("Poke failed: ", sock -> {
|
||||||
|
sock.clientPoke(clientId, message);
|
||||||
|
announce.sound(SoundEvent.OTHER_SENT_POKE, announce.clientVars(clientId, null));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Grants or revokes clients' talk power, which lets them talk whatever their channel needs. */
|
||||||
|
public void setTalker(Collection<Integer> clientIds, boolean talker) {
|
||||||
|
if (clientIds.isEmpty()) return;
|
||||||
|
act(talker ? "Error granting talk power: " : "Error revoking talk power: ", sock -> {
|
||||||
|
for (int id : clientIds) setTalker(sock, id, talker);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Grants talk power to whoever in a channel has waited longest for it, first revoking
|
||||||
|
* it from everyone who has it there when {@code revokeOthers}.
|
||||||
|
*/
|
||||||
|
public void grantNextTalkPower(int channelId, boolean revokeOthers) {
|
||||||
|
ClientEntry next = model.nextTalkRequest(channelId);
|
||||||
|
List<ClientEntry> talkers = revokeOthers ? model.talkersIn(channelId) : List.of();
|
||||||
|
if (next == null && talkers.isEmpty()) return;
|
||||||
|
act("Error granting talk power: ", sock -> {
|
||||||
|
for (ClientEntry c : talkers) {
|
||||||
|
if (c != next) setTalker(sock, c.id, false);
|
||||||
|
}
|
||||||
|
if (next != null) setTalker(sock, next.id, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setTalker(LocalTeamspeakClientSocket sock, int clientId, boolean talker) throws Exception {
|
||||||
|
sock.executeCommand(new SingleCommand("clientedit", ProtocolRole.CLIENT,
|
||||||
|
new CommandSingleParameter("clid", Integer.toString(clientId)),
|
||||||
|
new CommandSingleParameter("client_is_talker", talker ? "1" : "0"))).complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asks for a client's version and platform, the only details the enter-view event
|
||||||
|
* lacks. The answer arrives as a client update, see {@link ConnectionEventHandler#onClientChanged}.
|
||||||
|
* Uses {@code clientgetvariables}, not {@code clientinfo}, which counts heavily against the
|
||||||
|
* server's flood protection. May be refused; the details then stay as they are.
|
||||||
|
*/
|
||||||
|
public void requestInfo(int clientId) {
|
||||||
|
uplink.submit(sock -> sock.executeCommand(new SingleCommand("clientgetvariables", ProtocolRole.CLIENT,
|
||||||
|
new CommandSingleParameter("clid", Integer.toString(clientId)))).complete(), e -> {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a client's description straight from the server, so an editor opens on the
|
||||||
|
* live text instead of whatever an earlier info request cached.
|
||||||
|
*/
|
||||||
|
public CompletableFuture<String> description(int clientId) {
|
||||||
|
return uplink.request(() -> {
|
||||||
|
Client c = uplink.socket().getClientInfo(clientId);
|
||||||
|
String description = c == null ? "" : TeamspeakConnection.orEmpty(c.get("client_description"));
|
||||||
|
ClientEntry e = model.getClient(clientId);
|
||||||
|
if (e != null) e.description = description;
|
||||||
|
return description;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes a client's description. Unlike the nickname or the away state, this is not
|
||||||
|
* a {@code clientupdate} property even for ourselves: the server only takes it
|
||||||
|
* through {@code clientedit}, gated by {@code b_client_modify_own_description}.
|
||||||
|
*/
|
||||||
|
public CompletableFuture<Void> setDescription(int clientId, String description) {
|
||||||
|
boolean self = clientId == selfClientId.getAsInt();
|
||||||
|
return uplink.requestVoid(() -> {
|
||||||
|
SingleCommand cmd = new SingleCommand("clientedit", ProtocolRole.CLIENT);
|
||||||
|
cmd.add(new CommandSingleParameter("clid", Integer.toString(clientId)));
|
||||||
|
cmd.add(new CommandSingleParameter("client_description", description));
|
||||||
|
uplink.socket().executeCommand(cmd).complete();
|
||||||
|
// Only the other clients are told about our own update, so the local entry
|
||||||
|
// (and the info panel showing it) has to be caught up here.
|
||||||
|
if (self) {
|
||||||
|
ClientEntry e = model.getClient(clientId);
|
||||||
|
if (e != null) e.description = description;
|
||||||
|
infoUpdated.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void act(String errorPrefix, Uplink.Action action) {
|
||||||
|
uplink.submit(action, e -> announce.error(errorPrefix, e));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package eu.lixko.ts3j.client.net;
|
||||||
|
|
||||||
|
import eu.lixko.ts3j.client.audio.VoiceOutput;
|
||||||
|
import eu.lixko.ts3j.client.config.Settings;
|
||||||
|
import eu.lixko.ts3j.client.contacts.Contact;
|
||||||
|
import eu.lixko.ts3j.client.contacts.ContactStore;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The contact list as it applies to the clients on this server: the names they are shown
|
||||||
|
* under, their automatic mute and volume, whose whispers we hear, and where they were seen.
|
||||||
|
*/
|
||||||
|
public final class ClientContacts {
|
||||||
|
|
||||||
|
private final ContactStore store;
|
||||||
|
private final Settings settings;
|
||||||
|
private final ServerModel model;
|
||||||
|
private final OwnClient own;
|
||||||
|
private final Uplink uplink;
|
||||||
|
/** The server address we are on, recorded with a sighting. */
|
||||||
|
private final Supplier<String> address;
|
||||||
|
|
||||||
|
ClientContacts(ContactStore store, Settings settings, ServerModel model, OwnClient own, Uplink uplink,
|
||||||
|
Supplier<String> address) {
|
||||||
|
this.store = store;
|
||||||
|
this.settings = settings;
|
||||||
|
this.model = model;
|
||||||
|
this.own = own;
|
||||||
|
this.uplink = uplink;
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Friends, blocked clients and their per-client filters, shared by every server. */
|
||||||
|
public ContactStore store() {
|
||||||
|
return store;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The name a client is shown under: its contact's custom name where it has one. */
|
||||||
|
public String displayName(ClientEntry client) {
|
||||||
|
return store.displayName(client.uniqueId, client.nickname);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a whisper from a client is played, per the global whisper policy and the
|
||||||
|
* client's contact entry. A client that has already left is judged by the policy alone.
|
||||||
|
*/
|
||||||
|
boolean isWhisperAllowed(int clientId) {
|
||||||
|
Settings.WhisperPolicy policy = settings.whisperPolicy;
|
||||||
|
if (policy == Settings.WhisperPolicy.NOBODY) return false;
|
||||||
|
ClientEntry c = model.getClient(clientId);
|
||||||
|
Contact contact = c == null ? null : store.find(c.uniqueId);
|
||||||
|
if (contact != null) return contact.whisperAllowed;
|
||||||
|
return policy == Settings.WhisperPolicy.ALLOW_UNLESS_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a client's contact entry to its playback — the automatic mute and the
|
||||||
|
* volume modifier — and records the sighting. Called when the client appears, which
|
||||||
|
* is also when its myTeamSpeak ID can first match a contact.
|
||||||
|
*/
|
||||||
|
void apply(ClientEntry client) {
|
||||||
|
store.link(client.uniqueId, client.myTeamSpeakId);
|
||||||
|
Contact contact = applyPlayback(client);
|
||||||
|
if (contact != null) store.markSeen(client.uniqueId, model.getServerName(), address.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Contact applyPlayback(ClientEntry client) {
|
||||||
|
if (client == null || client.self) return null;
|
||||||
|
Contact contact = store.find(client.uniqueId);
|
||||||
|
VoiceOutput out = own.playback();
|
||||||
|
if (contact != null && out != null) {
|
||||||
|
if (contact.automute) out.setClientMuted(client.id, true);
|
||||||
|
out.setClientVolume(client.id, contact.volumeGain());
|
||||||
|
}
|
||||||
|
return contact;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-applies every contact entry to the clients on the server, after the list changed.
|
||||||
|
* A client that just became a contact is also marked as seen. One seen before keeps
|
||||||
|
* where it was seen: with it on two servers, each re-application would claim it for its
|
||||||
|
* own server, which is a change that triggers the other's re-application, and so on.
|
||||||
|
*/
|
||||||
|
public void applyAll() {
|
||||||
|
if (!uplink.isUp()) return;
|
||||||
|
for (ClientEntry c : model.allClients()) {
|
||||||
|
Contact contact = applyPlayback(c);
|
||||||
|
if (contact != null && contact.lastSeen == null) {
|
||||||
|
store.markSeen(c.uniqueId, model.getServerName(), address.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Remembers a per-client volume, in the contact entry when the client has one. */
|
||||||
|
public void setVolumeModifier(ClientEntry client, double decibels) {
|
||||||
|
VoiceOutput out = own.playback();
|
||||||
|
if (out != null) out.setClientVolume(client.id, Math.pow(10.0, decibels / 20.0));
|
||||||
|
Contact contact = store.find(client.uniqueId);
|
||||||
|
if (contact == null) return;
|
||||||
|
contact.hasVolumeModifier = decibels != 0;
|
||||||
|
contact.volumeModifier = decibels;
|
||||||
|
store.put(contact);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double volumeModifier(ClientEntry client) {
|
||||||
|
VoiceOutput out = own.playback();
|
||||||
|
if (out == null) return 0;
|
||||||
|
double gain = out.getClientVolume(client.id);
|
||||||
|
return gain <= 0 ? -60 : 20.0 * Math.log10(gain);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,7 +42,7 @@ final class ConnectionEventHandler implements TS3Listener {
|
|||||||
c.self = (e.getClientId() == conn.getSelfClientId());
|
c.self = (e.getClientId() == conn.getSelfClientId());
|
||||||
// Query clients stay out of sight, as they do in the tree and in TS3's log.
|
// Query clients stay out of sight, as they do in the tree and in TS3's log.
|
||||||
if (!c.self && !c.isQuery()) {
|
if (!c.self && !c.isQuery()) {
|
||||||
conn.applyContact(c);
|
conn.contacts.apply(c);
|
||||||
announceClientEntered(e);
|
announceClientEntered(e);
|
||||||
logClientEntered(e);
|
logClientEntered(e);
|
||||||
}
|
}
|
||||||
@@ -308,7 +308,7 @@ final class ConnectionEventHandler implements TS3Listener {
|
|||||||
if (reported(e, "client_description") || has(e, "client_version") || has(e, "client_platform")) {
|
if (reported(e, "client_description") || has(e, "client_version") || has(e, "client_platform")) {
|
||||||
conn.ui.onInfoUpdated();
|
conn.ui.onInfoUpdated();
|
||||||
}
|
}
|
||||||
if (reported(e, "client_myteamspeak_id") && !c.self && !c.isQuery()) conn.applyContact(c);
|
if (reported(e, "client_myteamspeak_id") && !c.self && !c.isQuery()) conn.contacts.apply(c);
|
||||||
if (has(e, "client_unread_messages") && c.id == conn.getSelfClientId()) conn.unreadMessagesChanged(unreadBefore);
|
if (has(e, "client_unread_messages") && c.id == conn.getSelfClientId()) conn.unreadMessagesChanged(unreadBefore);
|
||||||
announceClientUpdate(e, c, renamed, oldName);
|
announceClientUpdate(e, c, renamed, oldName);
|
||||||
conn.ui.onModelChanged();
|
conn.ui.onModelChanged();
|
||||||
@@ -479,7 +479,7 @@ final class ConnectionEventHandler implements TS3Listener {
|
|||||||
ChannelNode ch = conn.getModel().getChannel(safeInt(e, "cid"));
|
ChannelNode ch = conn.getModel().getChannel(safeInt(e, "cid"));
|
||||||
if (ch == null || !ch.descriptionLoaded) return;
|
if (ch == null || !ch.descriptionLoaded) return;
|
||||||
ch.descriptionLoaded = false;
|
ch.descriptionLoaded = false;
|
||||||
conn.requestChannelInfo(ch.id);
|
conn.channels.requestInfo(ch.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -646,7 +646,7 @@ final class ConnectionEventHandler implements TS3Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void onTextMessage(TextMessageEvent e) {
|
public void onTextMessage(TextMessageEvent e) {
|
||||||
if (e.getInvokerId() == conn.getSelfClientId()) return; // don't echo our own
|
if (e.getInvokerId() == conn.getSelfClientId()) return; // don't echo our own
|
||||||
Contact contact = conn.contacts.find(e.getInvokerUniqueId());
|
Contact contact = conn.contacts.store().find(e.getInvokerUniqueId());
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
boolean isPrivate = e.getTargetMode() == TextMessageTargetMode.CLIENT;
|
boolean isPrivate = e.getTargetMode() == TextMessageTargetMode.CLIENT;
|
||||||
if (isPrivate ? contact.ignorePrivateMessages : contact.ignorePublicMessages) return;
|
if (isPrivate ? contact.ignorePrivateMessages : contact.ignorePublicMessages) return;
|
||||||
@@ -674,10 +674,10 @@ final class ConnectionEventHandler implements TS3Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClientPoke(ClientPokeEvent e) {
|
public void onClientPoke(ClientPokeEvent e) {
|
||||||
Contact contact = conn.contacts.find(e.getInvokerUniqueId());
|
Contact contact = conn.contacts.store().find(e.getInvokerUniqueId());
|
||||||
if (contact != null && contact.ignorePokes) return;
|
if (contact != null && contact.ignorePokes) return;
|
||||||
conn.announce.sound(SoundEvent.OTHER_RECEIVED_POKE, conn.announce.clientVars(e.getInvokerId(), e.getInvokerName()));
|
conn.announce.sound(SoundEvent.OTHER_RECEIVED_POKE, conn.announce.clientVars(e.getInvokerId(), e.getInvokerName()));
|
||||||
String from = conn.contacts.displayName(e.getInvokerUniqueId(), TeamspeakConnection.orEmpty(e.getInvokerName()));
|
String from = conn.contacts.store().displayName(e.getInvokerUniqueId(), TeamspeakConnection.orEmpty(e.getInvokerName()));
|
||||||
conn.ui.onPoke(from, TeamspeakConnection.orEmpty(e.get("msg")));
|
conn.ui.onPoke(from, TeamspeakConnection.orEmpty(e.get("msg")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -125,7 +125,7 @@ final class ConnectionStatsCollector {
|
|||||||
Long last = variablesAskedAt.get(clientId);
|
Long last = variablesAskedAt.get(clientId);
|
||||||
if (last != null && now - last < VARIABLES_REFRESH_MS) return;
|
if (last != null && now - last < VARIABLES_REFRESH_MS) return;
|
||||||
variablesAskedAt.put(clientId, now);
|
variablesAskedAt.put(clientId, now);
|
||||||
conn.requestClientInfo(clientId);
|
conn.clients.requestInfo(clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Our own traffic, straight from the socket. */
|
/** Our own traffic, straight from the socket. */
|
||||||
|
|||||||
@@ -15,31 +15,22 @@ import com.github.manevolent.ts3j.util.Ts3Crypt;
|
|||||||
import eu.lixko.ts3j.client.audio.AudioBackend;
|
import eu.lixko.ts3j.client.audio.AudioBackend;
|
||||||
import eu.lixko.ts3j.client.audio.VoiceOutput;
|
import eu.lixko.ts3j.client.audio.VoiceOutput;
|
||||||
import eu.lixko.ts3j.client.config.Settings;
|
import eu.lixko.ts3j.client.config.Settings;
|
||||||
import eu.lixko.ts3j.client.contacts.Contact;
|
|
||||||
import eu.lixko.ts3j.client.contacts.ContactStore;
|
import eu.lixko.ts3j.client.contacts.ContactStore;
|
||||||
import eu.lixko.ts3j.client.myts.MyTeamSpeakIdentity;
|
import eu.lixko.ts3j.client.myts.MyTeamSpeakIdentity;
|
||||||
import eu.lixko.ts3j.client.myts.MyTeamSpeakLogin;
|
import eu.lixko.ts3j.client.myts.MyTeamSpeakLogin;
|
||||||
import eu.lixko.ts3j.client.net.avatar.Avatar;
|
import eu.lixko.ts3j.client.net.avatar.Avatar;
|
||||||
import eu.lixko.ts3j.client.net.avatar.AvatarNaming;
|
import eu.lixko.ts3j.client.net.avatar.AvatarNaming;
|
||||||
import eu.lixko.ts3j.client.net.avatar.AvatarRepository;
|
import eu.lixko.ts3j.client.net.avatar.AvatarRepository;
|
||||||
import eu.lixko.ts3j.client.net.filetransfer.FileTransfer;
|
|
||||||
import eu.lixko.ts3j.client.net.filetransfer.FileTransferManager;
|
import eu.lixko.ts3j.client.net.filetransfer.FileTransferManager;
|
||||||
import eu.lixko.ts3j.client.net.ban.BanEntry;
|
|
||||||
import eu.lixko.ts3j.client.net.ban.BanRule;
|
|
||||||
import eu.lixko.ts3j.client.net.filetransfer.RemoteFile;
|
|
||||||
import eu.lixko.ts3j.client.sound.SoundEvent;
|
import eu.lixko.ts3j.client.sound.SoundEvent;
|
||||||
import eu.lixko.ts3j.client.sound.SoundNotifier;
|
import eu.lixko.ts3j.client.sound.SoundNotifier;
|
||||||
import eu.lixko.ts3j.client.text.TsLink;
|
import eu.lixko.ts3j.client.text.TsLink;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,12 +43,6 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
/** Upper bound for a group icon; anything larger is not an icon. Also used by {@link ChannelAdmin}. */
|
/** Upper bound for a group icon; anything larger is not an icon. Also used by {@link ChannelAdmin}. */
|
||||||
static final int MAX_ICON_BYTES = 1024 * 1024;
|
static final int MAX_ICON_BYTES = 1024 * 1024;
|
||||||
|
|
||||||
/** The longest reason the protocol carries with a kick. */
|
|
||||||
public static final int KICK_REASON_LIMIT = 40;
|
|
||||||
|
|
||||||
/** The protocol's reason ids for the two flavours of <b>clientkick</b>. */
|
|
||||||
private static final int REASON_KICK_CHANNEL = 4;
|
|
||||||
private static final int REASON_KICK_SERVER = 5;
|
|
||||||
/** The reason ids of our own leaving that nobody chose: timing out, the server going down. */
|
/** The reason ids of our own leaving that nobody chose: timing out, the server going down. */
|
||||||
private static final int REASON_CONNECTION_LOST = 3;
|
private static final int REASON_CONNECTION_LOST = 3;
|
||||||
private static final int REASON_SERVER_SHUTDOWN = 11;
|
private static final int REASON_SERVER_SHUTDOWN = 11;
|
||||||
@@ -78,7 +63,7 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
private final IconRepository icons;
|
private final IconRepository icons;
|
||||||
private final AvatarRepository avatars;
|
private final AvatarRepository avatars;
|
||||||
/** Friends, blocked clients and their per-client filters; also read by {@link ConnectionEventHandler}. */
|
/** Friends, blocked clients and their per-client filters; also read by {@link ConnectionEventHandler}. */
|
||||||
final ContactStore contacts;
|
final ClientContacts contacts;
|
||||||
/** The chat log on disk, opened once the server is known; package-private for {@link ConnectionEventHandler}. */
|
/** The chat log on disk, opened once the server is known; package-private for {@link ConnectionEventHandler}. */
|
||||||
final ChatLog chatLog;
|
final ChatLog chatLog;
|
||||||
/** Log lines and sounds for what happens; package-private for {@link ConnectionEventHandler}. */
|
/** Log lines and sounds for what happens; package-private for {@link ConnectionEventHandler}. */
|
||||||
@@ -89,6 +74,9 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
final ConnectionStatsCollector stats = new ConnectionStatsCollector(this);
|
final ConnectionStatsCollector stats = new ConnectionStatsCollector(this);
|
||||||
/** The server administration helpers; package-private for {@link ConnectionEventHandler}, which feeds them replies. */
|
/** The server administration helpers; package-private for {@link ConnectionEventHandler}, which feeds them replies. */
|
||||||
final ChannelAdmin channels;
|
final ChannelAdmin channels;
|
||||||
|
/** Package-private for {@link ConnectionStatsCollector}, which asks for client details. */
|
||||||
|
final ClientAdmin clients;
|
||||||
|
private final ChannelFiles files;
|
||||||
final BanAdmin bans = new BanAdmin(uplink);
|
final BanAdmin bans = new BanAdmin(uplink);
|
||||||
final PrivilegeKeyAdmin privilegeKeys = new PrivilegeKeyAdmin(uplink);
|
final PrivilegeKeyAdmin privilegeKeys = new PrivilegeKeyAdmin(uplink);
|
||||||
final ComplaintAdmin complaints;
|
final ComplaintAdmin complaints;
|
||||||
@@ -164,19 +152,21 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
SoundNotifier sounds, ContactStore contacts) {
|
SoundNotifier sounds, ContactStore contacts) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.ui = ui;
|
this.ui = ui;
|
||||||
this.contacts = contacts;
|
|
||||||
this.chatLog = new ChatLog(settings, ui);
|
this.chatLog = new ChatLog(settings, ui);
|
||||||
this.announce = new Announcer(model, sounds, ui, chatLog, () -> ownClient().isDeafened(), uplink::isUp);
|
this.announce = new Announcer(model, sounds, ui, chatLog, () -> ownClient().isDeafened(), uplink::isUp);
|
||||||
this.events = new ConnectionEventHandler(this);
|
this.events = new ConnectionEventHandler(this);
|
||||||
this.icons = new IconRepository(this::fetchIcon, ui::onIconsUpdated);
|
this.icons = new IconRepository(this::fetchIcon, ui::onIconsUpdated);
|
||||||
this.avatars = new AvatarRepository(this::fetchAvatar, ui::onInfoUpdated);
|
this.avatars = new AvatarRepository(this::fetchAvatar, ui::onInfoUpdated);
|
||||||
this.channels = new ChannelAdmin(uplink, model);
|
this.channels = new ChannelAdmin(uplink, model, announce);
|
||||||
|
this.clients = new ClientAdmin(uplink, model, announce, () -> selfClientId, ui::onInfoUpdated);
|
||||||
|
this.files = new ChannelFiles(uplink, announce);
|
||||||
this.complaints = new ComplaintAdmin(uplink, announce);
|
this.complaints = new ComplaintAdmin(uplink, announce);
|
||||||
this.offlineMessages = new OfflineMessageAdmin(uplink, announce);
|
this.offlineMessages = new OfflineMessageAdmin(uplink, announce);
|
||||||
this.avatarAdmin = new AvatarAdmin(uplink, model.permissions(), avatars, this::getSelfUniqueId,
|
this.avatarAdmin = new AvatarAdmin(uplink, model.permissions(), avatars, this::getSelfUniqueId,
|
||||||
flag -> ownClient().updateEntry(self -> self.avatarFlag = flag));
|
flag -> ownClient().updateEntry(self -> self.avatarFlag = flag));
|
||||||
this.own = new OwnClient(settings, audio, uplink, model, ui, announce, () -> selfClientId);
|
this.own = new OwnClient(settings, audio, uplink, model, ui, announce, () -> selfClientId);
|
||||||
this.recording = new Recording(audio, uplink, model, own, this::getSelfUniqueId);
|
this.recording = new Recording(audio, uplink, model, own, this::getSelfUniqueId);
|
||||||
|
this.contacts = new ClientContacts(contacts, settings, model, own, uplink, () -> serverHost + ":" + serverPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerModel getModel() {
|
public ServerModel getModel() {
|
||||||
@@ -286,7 +276,7 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
client.addListener(events);
|
client.addListener(events);
|
||||||
client.setVoiceHandler(playback::handleVoice);
|
client.setVoiceHandler(playback::handleVoice);
|
||||||
client.setWhisperHandler(whisper -> {
|
client.setWhisperHandler(whisper -> {
|
||||||
if (!isWhisperAllowed(whisper.getClientId())) return;
|
if (!contacts.isWhisperAllowed(whisper.getClientId())) return;
|
||||||
lastWhisperer = whisper.getClientId();
|
lastWhisperer = whisper.getClientId();
|
||||||
playback.handleWhisper(whisper);
|
playback.handleWhisper(whisper);
|
||||||
});
|
});
|
||||||
@@ -531,123 +521,6 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
|
|
||||||
// ---- self actions ----
|
// ---- self actions ----
|
||||||
|
|
||||||
public void joinChannel(int channelId, String password) {
|
|
||||||
act("Could not join channel: ", sock ->
|
|
||||||
sock.joinChannel(channelId, (password == null || password.isEmpty()) ? null : password));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Moves another client (or ourselves) into a channel. */
|
|
||||||
public void moveClient(int clientId, int channelId, String password) {
|
|
||||||
act("Could not move client: ", sock -> sock.clientMove(clientId, channelId,
|
|
||||||
(password == null || password.isEmpty()) ? null : password));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Moves several clients (ourselves among them, if wanted) into a channel in one piped
|
|
||||||
* command. Clients already in it are left out, which the server would refuse.
|
|
||||||
*/
|
|
||||||
public void moveClients(Collection<Integer> clientIds, int channelId) {
|
|
||||||
List<SingleCommand> rows = new ArrayList<>(clientIds.size());
|
|
||||||
for (int id : clientIds) {
|
|
||||||
ClientEntry client = model.getClient(id);
|
|
||||||
if (client != null && client.channelId == channelId) continue;
|
|
||||||
rows.add(new SingleCommand("clientmove", ProtocolRole.CLIENT,
|
|
||||||
new CommandSingleParameter("clid", Integer.toString(id))));
|
|
||||||
}
|
|
||||||
if (rows.isEmpty()) return;
|
|
||||||
act(rows.size() == 1 ? "Could not move client: " : "Could not move clients: ", sock -> {
|
|
||||||
MultiCommand cmd = new MultiCommand("clientmove", ProtocolRole.CLIENT, rows);
|
|
||||||
cmd.add(new CommandSingleParameter("cid", Integer.toString(channelId)));
|
|
||||||
sock.executeCommand(cmd).complete();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Kicks a client out of its channel, back into the server's default one. */
|
|
||||||
public void kickFromChannel(int clientId, String reason) {
|
|
||||||
kickFromChannel(List.of(clientId), reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Kicks clients out of their channels in one command; we are never among them, nor are
|
|
||||||
* clients already in the default channel, as the server would refuse the whole command.
|
|
||||||
*/
|
|
||||||
public void kickFromChannel(Collection<Integer> clientIds, String reason) {
|
|
||||||
int defaultChannel = model.defaultChannelId();
|
|
||||||
List<Integer> ids = new ArrayList<>(clientIds.size());
|
|
||||||
for (int id : clientIds) {
|
|
||||||
ClientEntry client = model.getClient(id);
|
|
||||||
if (client == null || client.channelId != defaultChannel) ids.add(id);
|
|
||||||
}
|
|
||||||
kick(ids, REASON_KICK_CHANNEL, reason, "channel");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Kicks a client off the server entirely. */
|
|
||||||
public void kickFromServer(int clientId, String reason) {
|
|
||||||
kickFromServer(List.of(clientId), reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Kicks clients off the server in one command; we are never among them. */
|
|
||||||
public void kickFromServer(Collection<Integer> clientIds, String reason) {
|
|
||||||
kick(clientIds, REASON_KICK_SERVER, reason, "server");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void kick(Collection<Integer> clientIds, int reasonId, String reason, String from) {
|
|
||||||
List<SingleCommand> rows = new ArrayList<>(clientIds.size());
|
|
||||||
for (int id : clientIds) {
|
|
||||||
if (id == selfClientId) continue;
|
|
||||||
rows.add(new SingleCommand("clientkick", ProtocolRole.CLIENT,
|
|
||||||
new CommandSingleParameter("clid", Integer.toString(id))));
|
|
||||||
}
|
|
||||||
if (rows.isEmpty()) return;
|
|
||||||
String errorPrefix = "Could not kick " + (rows.size() == 1 ? "client" : "clients") + " from the " + from + ": ";
|
|
||||||
act(errorPrefix, sock -> {
|
|
||||||
MultiCommand cmd = new MultiCommand("clientkick", ProtocolRole.CLIENT, rows);
|
|
||||||
cmd.add(new CommandSingleParameter("reasonid", Integer.toString(reasonId)));
|
|
||||||
if (reason != null && !reason.isEmpty()) {
|
|
||||||
cmd.add(new CommandSingleParameter("reasonmsg", reason));
|
|
||||||
}
|
|
||||||
sock.executeCommand(cmd).complete();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bans a client from the server.
|
|
||||||
*
|
|
||||||
* @param seconds how long the ban lasts, or 0 for a permanent one
|
|
||||||
*/
|
|
||||||
public void banClient(int clientId, long seconds, String reason) {
|
|
||||||
act("Could not ban client: ", sock -> sock.banClient(clientId,
|
|
||||||
seconds <= 0 ? null : (int) Math.min(seconds, Integer.MAX_VALUE),
|
|
||||||
reason == null || reason.isEmpty() ? null : reason));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Re-parents and repositions a channel.
|
|
||||||
*
|
|
||||||
* @param orderPredecessorId the channel this one should sit below among its new
|
|
||||||
* siblings, or 0 to place it first
|
|
||||||
*/
|
|
||||||
public void moveChannel(int channelId, int newParentId, int orderPredecessorId) {
|
|
||||||
ChannelNode channel = model.getChannel(channelId);
|
|
||||||
// The server refuses channelmove within the same parent ("already member of
|
|
||||||
// channel"); sorting among the same siblings is an edit of channel_order.
|
|
||||||
boolean reorder = channel != null && channel.parentId == newParentId;
|
|
||||||
act("Could not move channel: ", sock -> {
|
|
||||||
SingleCommand cmd;
|
|
||||||
if (reorder) {
|
|
||||||
cmd = new SingleCommand("channeledit", ProtocolRole.CLIENT);
|
|
||||||
cmd.add(new CommandSingleParameter("cid", Integer.toString(channelId)));
|
|
||||||
cmd.add(new CommandSingleParameter("channel_order", Integer.toString(orderPredecessorId)));
|
|
||||||
} else {
|
|
||||||
cmd = new SingleCommand("channelmove", ProtocolRole.CLIENT);
|
|
||||||
cmd.add(new CommandSingleParameter("cid", Integer.toString(channelId)));
|
|
||||||
cmd.add(new CommandSingleParameter("cpid", Integer.toString(newParentId)));
|
|
||||||
cmd.add(new CommandSingleParameter("order", Integer.toString(orderPredecessorId)));
|
|
||||||
}
|
|
||||||
sock.executeCommand(cmd).complete();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks the server to (re-)send its permission definitions, which arrive as a burst
|
* Asks the server to (re-)send its permission definitions, which arrive as a burst
|
||||||
* of {@code notifypermissionlist} events — the only way to learn permission names,
|
* of {@code notifypermissionlist} events — the only way to learn permission names,
|
||||||
@@ -683,43 +556,6 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
}, e -> model.permissions().unreportedRefused());
|
}, e -> model.permissions().unreportedRefused());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Assigns or removes a server group for a client (by database id, as {@code servergroupaddclient} needs). */
|
|
||||||
public void setClientServerGroup(int clientDatabaseId, int groupId, boolean assign) {
|
|
||||||
act("Could not " + (assign ? "assign" : "remove") + " server group: ", sock -> {
|
|
||||||
if (assign) sock.serverGroupAddClient(groupId, clientDatabaseId);
|
|
||||||
else sock.serverGroupRemoveClient(groupId, clientDatabaseId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Assigns a channel group for a client in the channel it currently sits in. */
|
|
||||||
public void setClientChannelGroup(int clientDatabaseId, int channelId, int groupId) {
|
|
||||||
act("Could not set channel group: ", sock -> {
|
|
||||||
SingleCommand cmd = new SingleCommand("setclientchannelgroup", ProtocolRole.CLIENT);
|
|
||||||
cmd.add(new CommandSingleParameter("cgid", Integer.toString(groupId)));
|
|
||||||
cmd.add(new CommandSingleParameter("cid", Integer.toString(channelId)));
|
|
||||||
cmd.add(new CommandSingleParameter("cldbid", Integer.toString(clientDatabaseId)));
|
|
||||||
sock.executeCommand(cmd).complete();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subscribes to (or unsubscribes from) a set of channels in one command. The model
|
|
||||||
* is left alone: the server answers with the subscription events that update it.
|
|
||||||
*/
|
|
||||||
public void setChannelsSubscribed(Collection<Integer> channelIds, boolean subscribed) {
|
|
||||||
if (channelIds.isEmpty()) return;
|
|
||||||
List<Integer> ids = List.copyOf(channelIds);
|
|
||||||
String name = subscribed ? "channelsubscribe" : "channelunsubscribe";
|
|
||||||
act(subscribed ? "Could not subscribe: " : "Could not unsubscribe: ", sock -> {
|
|
||||||
List<SingleCommand> parts = new ArrayList<>(ids.size());
|
|
||||||
for (int id : ids) {
|
|
||||||
parts.add(new SingleCommand(name, ProtocolRole.CLIENT,
|
|
||||||
new CommandSingleParameter("cid", Integer.toString(id))));
|
|
||||||
}
|
|
||||||
sock.executeCommand(new MultiCommand(name, ProtocolRole.CLIENT, parts)).complete();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendChannelMessage(String text) {
|
public void sendChannelMessage(String text) {
|
||||||
act("Message failed: ", sock -> {
|
act("Message failed: ", sock -> {
|
||||||
ClientEntry self = own.entry();
|
ClientEntry self = own.entry();
|
||||||
@@ -755,45 +591,6 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void poke(int clientId, String message) {
|
|
||||||
act("Poke failed: ", sock -> {
|
|
||||||
sock.clientPoke(clientId, message);
|
|
||||||
announce.sound(SoundEvent.OTHER_SENT_POKE, announce.clientVars(clientId, null));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Grants or revokes clients' talk power, which lets them talk whatever their channel needs. */
|
|
||||||
public void setTalker(Collection<Integer> clientIds, boolean talker) {
|
|
||||||
if (clientIds.isEmpty()) return;
|
|
||||||
act(talker ? "Error granting talk power: " : "Error revoking talk power: ", sock -> {
|
|
||||||
for (int id : clientIds) setTalker(sock, id, talker);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Grants talk power to whoever in our channel has waited longest for it, first revoking
|
|
||||||
* it from everyone who has it there when {@code revokeOthers}.
|
|
||||||
*/
|
|
||||||
public void grantNextTalkPower(boolean revokeOthers) {
|
|
||||||
ClientEntry self = own.entry();
|
|
||||||
if (self == null) return;
|
|
||||||
ClientEntry next = model.nextTalkRequest(self.channelId);
|
|
||||||
List<ClientEntry> talkers = revokeOthers ? model.talkersIn(self.channelId) : List.of();
|
|
||||||
if (next == null && talkers.isEmpty()) return;
|
|
||||||
act("Error granting talk power: ", sock -> {
|
|
||||||
for (ClientEntry c : talkers) {
|
|
||||||
if (c != next) setTalker(sock, c.id, false);
|
|
||||||
}
|
|
||||||
if (next != null) setTalker(sock, next.id, true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setTalker(LocalTeamspeakClientSocket sock, int clientId, boolean talker) throws Exception {
|
|
||||||
sock.executeCommand(new SingleCommand("clientedit", ProtocolRole.CLIENT,
|
|
||||||
new CommandSingleParameter("clid", Integer.toString(clientId)),
|
|
||||||
new CommandSingleParameter("client_is_talker", talker ? "1" : "0"))).complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getPingMillis() {
|
public double getPingMillis() {
|
||||||
try {
|
try {
|
||||||
LocalTeamspeakClientSocket sock = uplink.currentSocket();
|
LocalTeamspeakClientSocket sock = uplink.currentSocket();
|
||||||
@@ -807,77 +604,23 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
act("Rename failed: ", sock -> sock.setNickname(nickname));
|
act("Rename failed: ", sock -> sock.setNickname(nickname));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Info lookups use the commands the official client does. channelinfo/clientinfo would
|
|
||||||
* answer directly, but they are query commands that count heavily against the server's
|
|
||||||
* flood protection: clicking through the tree gets every command refused within seconds.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Asks for a channel's description. The answer arrives as a channel edit, see
|
|
||||||
* {@link ConnectionEventHandler#onChannelEdit}.
|
|
||||||
*/
|
|
||||||
public void requestChannelInfo(int channelId) {
|
|
||||||
requestInfo("channelgetdescription", "cid", channelId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Asks for a client's version and platform, the only details the enter-view event
|
|
||||||
* lacks. The answer arrives as a client update, see {@link ConnectionEventHandler#onClientChanged}.
|
|
||||||
*/
|
|
||||||
public void requestClientInfo(int clientId) {
|
|
||||||
requestInfo("clientgetvariables", "clid", clientId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** May be refused for lack of permission; the details then stay as they are. */
|
|
||||||
private void requestInfo(String command, String idParameter, int id) {
|
|
||||||
attempt(sock -> sock.executeCommand(new SingleCommand(command, ProtocolRole.CLIENT,
|
|
||||||
new CommandSingleParameter(idParameter, Integer.toString(id)))).complete());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads a client's description straight from the server, so an editor opens on the
|
|
||||||
* live text instead of whatever an earlier info request cached.
|
|
||||||
*/
|
|
||||||
public CompletableFuture<String> requestClientDescription(int clientId) {
|
|
||||||
return uplink.request(() -> {
|
|
||||||
Client c = uplink.socket().getClientInfo(clientId);
|
|
||||||
String description = c == null ? "" : orEmpty(c.get("client_description"));
|
|
||||||
ClientEntry e = model.getClient(clientId);
|
|
||||||
if (e != null) e.description = description;
|
|
||||||
return description;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes a client's description. Unlike the nickname or the away state, this is not
|
|
||||||
* a {@code clientupdate} property even for ourselves: the server only takes it
|
|
||||||
* through {@code clientedit}, gated by {@code b_client_modify_own_description}.
|
|
||||||
*/
|
|
||||||
public CompletableFuture<Void> setClientDescription(int clientId, String description) {
|
|
||||||
boolean self = clientId == selfClientId;
|
|
||||||
return uplink.requestVoid(() -> {
|
|
||||||
SingleCommand cmd = new SingleCommand("clientedit", ProtocolRole.CLIENT);
|
|
||||||
cmd.add(new CommandSingleParameter("clid", Integer.toString(clientId)));
|
|
||||||
cmd.add(new CommandSingleParameter("client_description", description));
|
|
||||||
uplink.socket().executeCommand(cmd).complete();
|
|
||||||
// Only the other clients are told about our own update, so the local entry
|
|
||||||
// (and the info panel showing it) has to be caught up here.
|
|
||||||
if (self) {
|
|
||||||
ClientEntry e = model.getClient(clientId);
|
|
||||||
if (e != null) e.description = description;
|
|
||||||
ui.onInfoUpdated();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- server administration ----
|
// ---- server administration ----
|
||||||
|
|
||||||
/** Channel editing and the server's icon store. */
|
/** Joining, moving and editing channels, and the server's icon store. */
|
||||||
public ChannelAdmin channels() {
|
public ChannelAdmin channels() {
|
||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Moving, kicking and banning clients, their groups, talk power and details. */
|
||||||
|
public ClientAdmin clients() {
|
||||||
|
return clients;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The channels' file repositories. */
|
||||||
|
public ChannelFiles files() {
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
public BanAdmin bans() {
|
public BanAdmin bans() {
|
||||||
return bans;
|
return bans;
|
||||||
}
|
}
|
||||||
@@ -924,84 +667,11 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
|
|
||||||
// ---- contacts ----
|
// ---- contacts ----
|
||||||
|
|
||||||
public ContactStore getContacts() {
|
/** The contact list as it applies to the clients on this server. */
|
||||||
|
public ClientContacts contacts() {
|
||||||
return contacts;
|
return contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The name a client is shown under: its contact's custom name where it has one. */
|
|
||||||
public String displayName(ClientEntry client) {
|
|
||||||
return contacts.displayName(client.uniqueId, client.nickname);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether a whisper from a client is played, per the global whisper policy and the
|
|
||||||
* client's contact entry. A client that has already left is judged by the policy alone.
|
|
||||||
*/
|
|
||||||
boolean isWhisperAllowed(int clientId) {
|
|
||||||
Settings.WhisperPolicy policy = settings.whisperPolicy;
|
|
||||||
if (policy == Settings.WhisperPolicy.NOBODY) return false;
|
|
||||||
ClientEntry c = model.getClient(clientId);
|
|
||||||
Contact contact = c == null ? null : contacts.find(c.uniqueId);
|
|
||||||
if (contact != null) return contact.whisperAllowed;
|
|
||||||
return policy == Settings.WhisperPolicy.ALLOW_UNLESS_DENIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies a client's contact entry to its playback — the automatic mute and the
|
|
||||||
* volume modifier — and records the sighting. Called when the client appears, which
|
|
||||||
* is also when its myTeamSpeak ID can first match a contact.
|
|
||||||
*/
|
|
||||||
void applyContact(ClientEntry client) {
|
|
||||||
contacts.link(client.uniqueId, client.myTeamSpeakId);
|
|
||||||
Contact contact = applyContactPlayback(client);
|
|
||||||
if (contact != null) contacts.markSeen(client.uniqueId, model.getServerName(), serverHost + ":" + serverPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Contact applyContactPlayback(ClientEntry client) {
|
|
||||||
if (client == null || client.self) return null;
|
|
||||||
Contact contact = contacts.find(client.uniqueId);
|
|
||||||
VoiceOutput out = own.playback();
|
|
||||||
if (contact != null && out != null) {
|
|
||||||
if (contact.automute) out.setClientMuted(client.id, true);
|
|
||||||
out.setClientVolume(client.id, contact.volumeGain());
|
|
||||||
}
|
|
||||||
return contact;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Re-applies every contact entry to the clients on the server, after the list changed.
|
|
||||||
* A client that just became a contact is also marked as seen. One seen before keeps
|
|
||||||
* where it was seen: with it on two servers, each re-application would claim it for its
|
|
||||||
* own server, which is a change that triggers the other's re-application, and so on.
|
|
||||||
*/
|
|
||||||
public void applyContacts() {
|
|
||||||
if (!uplink.isUp()) return;
|
|
||||||
for (ClientEntry c : model.allClients()) {
|
|
||||||
Contact contact = applyContactPlayback(c);
|
|
||||||
if (contact != null && contact.lastSeen == null) {
|
|
||||||
contacts.markSeen(c.uniqueId, model.getServerName(), serverHost + ":" + serverPort);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Remembers a per-client volume, in the contact entry when the client has one. */
|
|
||||||
public void setClientVolumeModifier(ClientEntry client, double decibels) {
|
|
||||||
VoiceOutput out = own.playback();
|
|
||||||
if (out != null) out.setClientVolume(client.id, Math.pow(10.0, decibels / 20.0));
|
|
||||||
Contact contact = contacts.find(client.uniqueId);
|
|
||||||
if (contact == null) return;
|
|
||||||
contact.hasVolumeModifier = decibels != 0;
|
|
||||||
contact.volumeModifier = decibels;
|
|
||||||
contacts.put(contact);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getClientVolumeModifier(ClientEntry client) {
|
|
||||||
VoiceOutput out = own.playback();
|
|
||||||
if (out == null) return 0;
|
|
||||||
double gain = out.getClientVolume(client.id);
|
|
||||||
return gain <= 0 ? -60 : 20.0 * Math.log10(gain);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSelfUniqueId() {
|
public String getSelfUniqueId() {
|
||||||
ClientEntry self = own.entry();
|
ClientEntry self = own.entry();
|
||||||
if (self != null && !self.uniqueId.isEmpty()) return self.uniqueId;
|
if (self != null && !self.uniqueId.isEmpty()) return self.uniqueId;
|
||||||
@@ -1075,65 +745,6 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
return id == 0 ? null : model.getClient(id);
|
return id == 0 ? null : model.getClient(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- file transfers ----
|
|
||||||
|
|
||||||
/** Whether a live connection capable of file transfers is available. */
|
|
||||||
public boolean canTransferFiles() {
|
|
||||||
return uplink.canTransferFiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lists the files under {@code path} in a channel's repository. Blocking; call
|
|
||||||
* off the UI thread. Throws if not connected or the server denies the request.
|
|
||||||
*/
|
|
||||||
public java.util.List<RemoteFile> listFiles(int channelId, String channelPassword, String path)
|
|
||||||
throws Exception {
|
|
||||||
return uplink.files().list(channelId, channelPassword, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createDirectory(int channelId, String channelPassword, String dirPath) throws Exception {
|
|
||||||
uplink.files().createDirectory(channelId, channelPassword, dirPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteFile(int channelId, String channelPassword, String fullPath) throws Exception {
|
|
||||||
uplink.files().delete(channelId, channelPassword, fullPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renameFile(int channelId, String channelPassword, String oldFullPath, String newFullPath)
|
|
||||||
throws Exception {
|
|
||||||
uplink.files().rename(channelId, channelPassword, oldFullPath, newFullPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Begins downloading a channel file to {@code target}; progress arrives via {@code listener}. */
|
|
||||||
public FileTransfer downloadFile(int channelId, String channelPassword, String remoteFullPath,
|
|
||||||
File target, FileTransfer.Listener listener) {
|
|
||||||
return uplink.files().download(channelId, channelPassword, remoteFullPath, target, announcing(listener));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Begins uploading {@code source} into a channel; progress arrives via {@code listener}. */
|
|
||||||
public FileTransfer uploadFile(int channelId, String channelPassword, String remoteFullPath,
|
|
||||||
File source, boolean overwrite, FileTransfer.Listener listener) {
|
|
||||||
return uplink.files().upload(channelId, channelPassword, remoteFullPath, source, overwrite, announcing(listener));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wraps a transfer listener so the completion and failure sounds play once the
|
|
||||||
* transfer finishes, whoever is watching it.
|
|
||||||
*/
|
|
||||||
private FileTransfer.Listener announcing(FileTransfer.Listener listener) {
|
|
||||||
java.util.concurrent.atomic.AtomicBoolean announced = new java.util.concurrent.atomic.AtomicBoolean();
|
|
||||||
return transfer -> {
|
|
||||||
FileTransfer.State state = transfer.getState();
|
|
||||||
if (state != FileTransfer.State.CANCELLED && transfer.isDone()
|
|
||||||
&& announced.compareAndSet(false, true)) {
|
|
||||||
announce.sound(state == FileTransfer.State.COMPLETED
|
|
||||||
? SoundEvent.OTHER_FILETRANSFER_COMPLETE
|
|
||||||
: SoundEvent.OTHER_FILETRANSFER_FAILED, announce.serverVars());
|
|
||||||
}
|
|
||||||
if (listener != null) listener.onTransferChanged(transfer);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- connection info ----
|
// ---- connection info ----
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,7 +11,18 @@ import eu.lixko.ts3j.client.myts.MyTsException;
|
|||||||
import eu.lixko.ts3j.client.contacts.ContactStore;
|
import eu.lixko.ts3j.client.contacts.ContactStore;
|
||||||
import eu.lixko.ts3j.client.net.AvatarAdmin;
|
import eu.lixko.ts3j.client.net.AvatarAdmin;
|
||||||
import eu.lixko.ts3j.client.net.BanAdmin;
|
import eu.lixko.ts3j.client.net.BanAdmin;
|
||||||
|
import eu.lixko.ts3j.client.audio.VoiceInput;
|
||||||
|
import eu.lixko.ts3j.client.audio.VoiceOutput;
|
||||||
|
import eu.lixko.ts3j.client.myts.MyTeamSpeakLogin;
|
||||||
import eu.lixko.ts3j.client.net.ChannelAdmin;
|
import eu.lixko.ts3j.client.net.ChannelAdmin;
|
||||||
|
import eu.lixko.ts3j.client.net.ChannelFiles;
|
||||||
|
import eu.lixko.ts3j.client.net.ClientAdmin;
|
||||||
|
import eu.lixko.ts3j.client.net.ClientContacts;
|
||||||
|
import eu.lixko.ts3j.client.net.ConnectionStats;
|
||||||
|
import eu.lixko.ts3j.client.net.IconRepository;
|
||||||
|
import eu.lixko.ts3j.client.net.ServerModel;
|
||||||
|
import eu.lixko.ts3j.client.net.avatar.Avatar;
|
||||||
|
import eu.lixko.ts3j.client.net.avatar.AvatarRepository;
|
||||||
import eu.lixko.ts3j.client.net.ChannelNode;
|
import eu.lixko.ts3j.client.net.ChannelNode;
|
||||||
import eu.lixko.ts3j.client.net.ClientEntry;
|
import eu.lixko.ts3j.client.net.ClientEntry;
|
||||||
import eu.lixko.ts3j.client.net.ComplaintAdmin;
|
import eu.lixko.ts3j.client.net.ComplaintAdmin;
|
||||||
@@ -37,6 +48,7 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,6 +56,10 @@ import java.util.stream.Collectors;
|
|||||||
* connection lifecycle, the microphone/speaker/away flags, chat sending and channel
|
* connection lifecycle, the microphone/speaker/away flags, chat sending and channel
|
||||||
* lookups. A frontend keeps one per server tab and hears from it through {@link Listener}.
|
* lookups. A frontend keeps one per server tab and hears from it through {@link Listener}.
|
||||||
*
|
*
|
||||||
|
* <p>It is the frontends' way in to the server: what they read lives in its {@link #model()},
|
||||||
|
* and what they do beyond their own state goes through the helpers it hands out
|
||||||
|
* ({@link #clients()}, {@link #channels()}, {@link #files()} and the other admin helpers).
|
||||||
|
*
|
||||||
* <p>Listener callbacks arrive on connection threads, so frontends marshal them onto their
|
* <p>Listener callbacks arrive on connection threads, so frontends marshal them onto their
|
||||||
* UI thread. The getters may be called from any thread.
|
* UI thread. The getters may be called from any thread.
|
||||||
*/
|
*/
|
||||||
@@ -117,10 +133,6 @@ public final class ServerSession {
|
|||||||
this.recording = conn.recording();
|
this.recording = conn.recording();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TeamspeakConnection connection() {
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The server's name once known, the address before that. */
|
/** The server's name once known, the address before that. */
|
||||||
public String title() {
|
public String title() {
|
||||||
return title;
|
return title;
|
||||||
@@ -149,6 +161,38 @@ public final class ServerSession {
|
|||||||
return conn.getServerPort();
|
return conn.getServerPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The server's unique id, worked out from its key; null before it has introduced itself. */
|
||||||
|
public String serverUniqueId() {
|
||||||
|
return conn.serverUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Channels, clients, groups and server properties as last heard; empty while not connected. */
|
||||||
|
public ServerModel model() {
|
||||||
|
return conn.getModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Our client id on the server, or -1 while not connected. */
|
||||||
|
public int selfClientId() {
|
||||||
|
return conn.getSelfClientId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String selfUniqueId() {
|
||||||
|
return conn.getSelfUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Round-trip time to the server, or a negative value while unknown. */
|
||||||
|
public double pingMillis() {
|
||||||
|
return conn.getPingMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches a client's connection statistics, ourselves included, and delivers them on a
|
||||||
|
* connection thread. May be called repeatedly to poll; does nothing while not connected.
|
||||||
|
*/
|
||||||
|
public void requestConnectionInfo(int clientId, Consumer<ConnectionStats> callback) {
|
||||||
|
conn.requestConnectionInfo(clientId, callback);
|
||||||
|
}
|
||||||
|
|
||||||
public String identityId() {
|
public String identityId() {
|
||||||
return identityId;
|
return identityId;
|
||||||
}
|
}
|
||||||
@@ -167,6 +211,23 @@ public final class ServerSession {
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- myTeamSpeak ----
|
||||||
|
|
||||||
|
/** The account whose identity to show servers; null when signed out. */
|
||||||
|
public void setMyTeamSpeakLogin(MyTeamSpeakLogin login) {
|
||||||
|
conn.setMyTeamSpeakLogin(login);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether to show this server our myTeamSpeak account, as its bookmark says. */
|
||||||
|
public void setMyTeamSpeakFeatures(boolean enabled) {
|
||||||
|
conn.setMyTeamSpeakFeatures(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Tells the server about a sign-in or sign-out while connected. */
|
||||||
|
public void updateMyTeamSpeak() {
|
||||||
|
conn.updateMyTeamSpeak();
|
||||||
|
}
|
||||||
|
|
||||||
// ---- connection lifecycle ----
|
// ---- connection lifecycle ----
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -225,7 +286,7 @@ public final class ServerSession {
|
|||||||
ChannelNode target = link.channel.isEmpty() ? null : conn.getModel().findChannelByPath(link.channel);
|
ChannelNode target = link.channel.isEmpty() ? null : conn.getModel().findChannelByPath(link.channel);
|
||||||
ChannelNode current = currentChannel();
|
ChannelNode current = currentChannel();
|
||||||
if (target != null && (current == null || target.id != current.id)) {
|
if (target != null && (current == null || target.id != current.id)) {
|
||||||
conn.joinChannel(target.id, link.channelPassword.isEmpty() ? null : link.channelPassword);
|
conn.channels().join(target.id, link.channelPassword);
|
||||||
}
|
}
|
||||||
tokenLink = link.token.isEmpty() ? null : link;
|
tokenLink = link.token.isEmpty() ? null : link;
|
||||||
useConnectToken();
|
useConnectToken();
|
||||||
@@ -318,6 +379,20 @@ public final class ServerSession {
|
|||||||
if (isBusy()) conn.disconnect();
|
if (isBusy()) conn.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** {@link #disconnect()} on the calling thread, returning once the server is left. */
|
||||||
|
public void disconnectNow(String reason) {
|
||||||
|
reconnects.cancel();
|
||||||
|
if (isBusy()) conn.disconnectBlocking(reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The error id the server refused the last connect with ({@code 3329} for a ban, for
|
||||||
|
* one), or 0 when it was not refused or did not get that far.
|
||||||
|
*/
|
||||||
|
public int connectErrorId() {
|
||||||
|
return conn.getConnectErrorId();
|
||||||
|
}
|
||||||
|
|
||||||
/** Synchronous teardown for shutdown paths, so the server sees us leave and recordings are written. */
|
/** Synchronous teardown for shutdown paths, so the server sees us leave and recordings are written. */
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
reconnects.cancel();
|
reconnects.cancel();
|
||||||
@@ -415,6 +490,16 @@ public final class ServerSession {
|
|||||||
listener.onSessionChanged();
|
listener.onSessionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The capture device while connected, null otherwise. */
|
||||||
|
public VoiceInput microphone() {
|
||||||
|
return own.microphone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The speakers while connected, null otherwise. */
|
||||||
|
public VoiceOutput playback() {
|
||||||
|
return own.playback();
|
||||||
|
}
|
||||||
|
|
||||||
/** Hands the capture device to (or takes it from) this connection. */
|
/** Hands the capture device to (or takes it from) this connection. */
|
||||||
public void setMicrophoneActive(boolean active) {
|
public void setMicrophoneActive(boolean active) {
|
||||||
own.setMicrophoneActive(active);
|
own.setMicrophoneActive(active);
|
||||||
@@ -439,7 +524,8 @@ public final class ServerSession {
|
|||||||
|
|
||||||
/** Grants talk power to whoever in our channel asked first, after revoking everyone else's when {@code revokeOthers}. */
|
/** Grants talk power to whoever in our channel asked first, after revoking everyone else's when {@code revokeOthers}. */
|
||||||
public void grantNextTalkPower(boolean revokeOthers) {
|
public void grantNextTalkPower(boolean revokeOthers) {
|
||||||
if (conn.isConnected()) conn.grantNextTalkPower(revokeOthers);
|
ClientEntry self = own.entry();
|
||||||
|
if (conn.isConnected() && self != null) conn.clients().grantNextTalkPower(self.channelId, revokeOthers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String phoneticNickname() {
|
public String phoneticNickname() {
|
||||||
@@ -619,7 +705,12 @@ public final class ServerSession {
|
|||||||
|
|
||||||
private String peerName(int clientId) {
|
private String peerName(int clientId) {
|
||||||
ClientEntry c = conn.getModel().getClient(clientId);
|
ClientEntry c = conn.getModel().getClient(clientId);
|
||||||
return c != null ? conn.displayName(c) : "Client " + clientId;
|
return c != null ? conn.contacts().displayName(c) : "Client " + clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Hands {@link Listener#onPrivateChatHistory} what was said with a client before. */
|
||||||
|
public void loadPrivateChatHistory(int clientId, String uniqueId) {
|
||||||
|
conn.loadPrivateChatHistory(clientId, uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- channels ----
|
// ---- channels ----
|
||||||
@@ -642,7 +733,7 @@ public final class ServerSession {
|
|||||||
public void joinChannelPath(String path) {
|
public void joinChannelPath(String path) {
|
||||||
if (!conn.isConnected() || path == null || path.isBlank()) return;
|
if (!conn.isConnected() || path == null || path.isBlank()) return;
|
||||||
ChannelNode target = conn.getModel().findChannelByPath(path);
|
ChannelNode target = conn.getModel().findChannelByPath(path);
|
||||||
if (target != null) conn.joinChannel(target.id, null);
|
if (target != null) conn.channels().join(target.id, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Every channel of this server as a "/"-separated path, in the tree's own order. */
|
/** Every channel of this server as a "/"-separated path, in the tree's own order. */
|
||||||
@@ -665,6 +756,11 @@ public final class ServerSession {
|
|||||||
return conn.isConnected() ? conn.getModel().permissions() : Permissions.NONE;
|
return conn.isConnected() ? conn.getModel().permissions() : Permissions.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Unread messages in our offline message inbox. */
|
||||||
|
public int unreadOfflineMessages() {
|
||||||
|
return conn.unreadOfflineMessages();
|
||||||
|
}
|
||||||
|
|
||||||
/** Whether we publish an avatar on this server. */
|
/** Whether we publish an avatar on this server. */
|
||||||
public boolean hasAvatar() {
|
public boolean hasAvatar() {
|
||||||
if (!conn.isConnected()) return false;
|
if (!conn.isConnected()) return false;
|
||||||
@@ -678,12 +774,42 @@ public final class ServerSession {
|
|||||||
return permissions().canRequestTalkPower() && self != null && conn.getModel().lacksTalkPower(self);
|
return permissions().canRequestTalkPower() && self != null && conn.getModel().lacksTalkPower(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- icons, avatars and contacts ----
|
||||||
|
|
||||||
|
/** Group icons for this server: bundled defaults plus the server's own uploads. */
|
||||||
|
public IconRepository icons() {
|
||||||
|
return conn.getIcons();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The avatar a client currently shows, or null if none or not yet downloaded. */
|
||||||
|
public Avatar avatarOf(ClientEntry client) {
|
||||||
|
return conn.avatarOf(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Client avatars for this server, downloaded on demand. */
|
||||||
|
public AvatarRepository avatars() {
|
||||||
|
return conn.getAvatars();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The contact list as it applies to the clients on this server. */
|
||||||
|
public ClientContacts contacts() {
|
||||||
|
return conn.contacts();
|
||||||
|
}
|
||||||
|
|
||||||
// ---- server administration ----
|
// ---- server administration ----
|
||||||
|
|
||||||
|
public ClientAdmin clients() {
|
||||||
|
return conn.clients();
|
||||||
|
}
|
||||||
|
|
||||||
public ChannelAdmin channels() {
|
public ChannelAdmin channels() {
|
||||||
return conn.channels();
|
return conn.channels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChannelFiles files() {
|
||||||
|
return conn.files();
|
||||||
|
}
|
||||||
|
|
||||||
public BanAdmin bans() {
|
public BanAdmin bans() {
|
||||||
return conn.bans();
|
return conn.bans();
|
||||||
}
|
}
|
||||||
@@ -802,7 +928,7 @@ public final class ServerSession {
|
|||||||
/** Passes the sender on under their contact display name. */
|
/** Passes the sender on under their contact display name. */
|
||||||
@Override
|
@Override
|
||||||
public void onChat(ChatScope scope, int fromClientId, String fromUniqueId, String fromName, String message) {
|
public void onChat(ChatScope scope, int fromClientId, String fromUniqueId, String fromName, String message) {
|
||||||
String name = conn.getContacts().displayName(fromUniqueId, fromName);
|
String name = conn.contacts().store().displayName(fromUniqueId, fromName);
|
||||||
listener.onChat(scope, fromClientId, fromUniqueId, name, message);
|
listener.onChat(scope, fromClientId, fromUniqueId, name, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public final class Sessions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static VoiceInput microphoneOf(ServerSession session) {
|
private static VoiceInput microphoneOf(ServerSession session) {
|
||||||
return session == null || !session.isConnected() ? null : session.connection().ownClient().microphone();
|
return session == null || !session.isConnected() ? null : session.microphone();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- the user's own state ----
|
// ---- the user's own state ----
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package eu.lixko.ts3j.client.ui;
|
package eu.lixko.ts3j.client.ui;
|
||||||
|
|
||||||
import eu.lixko.ts3j.client.net.ClientEntry;
|
import eu.lixko.ts3j.client.net.ClientEntry;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
import eu.lixko.ts3j.client.net.avatar.Avatar;
|
import eu.lixko.ts3j.client.net.avatar.Avatar;
|
||||||
|
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
@@ -20,28 +20,28 @@ final class AvatarActions {
|
|||||||
private static File lastDirectory;
|
private static File lastDirectory;
|
||||||
|
|
||||||
private final Component owner;
|
private final Component owner;
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
|
|
||||||
AvatarActions(Component owner, TeamspeakConnection conn) {
|
AvatarActions(Component owner, ServerSession session) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Asks for an image and uploads it as our avatar. */
|
/** Asks for an image and uploads it as our avatar. */
|
||||||
void choose() {
|
void choose() {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
JFileChooser chooser = new JFileChooser(lastDirectory);
|
JFileChooser chooser = new JFileChooser(lastDirectory);
|
||||||
chooser.setDialogTitle("Select your avatar");
|
chooser.setDialogTitle("Select your avatar");
|
||||||
chooser.setFileFilter(new FileNameExtensionFilter("Images", "png", "jpg", "jpeg", "gif", "bmp"));
|
chooser.setFileFilter(new FileNameExtensionFilter("Images", "png", "jpg", "jpeg", "gif", "bmp"));
|
||||||
if (chooser.showOpenDialog(owner) != JFileChooser.APPROVE_OPTION) return;
|
if (chooser.showOpenDialog(owner) != JFileChooser.APPROVE_OPTION) return;
|
||||||
File file = chooser.getSelectedFile();
|
File file = chooser.getSelectedFile();
|
||||||
lastDirectory = file.getParentFile();
|
lastDirectory = file.getParentFile();
|
||||||
Edt.onFailure(conn.avatarAdmin().set(file), failure -> show("Error uploading avatar: " + failure.getMessage()));
|
Edt.onFailure(session.avatarAdmin().set(file), failure -> show("Error uploading avatar: " + failure.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Uploads someone else's avatar as ours. */
|
/** Uploads someone else's avatar as ours. */
|
||||||
void steal(Avatar avatar) {
|
void steal(Avatar avatar) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
File file;
|
File file;
|
||||||
try {
|
try {
|
||||||
file = Files.createTempFile("avatar", "." + avatar.format().extension).toFile();
|
file = Files.createTempFile("avatar", "." + avatar.format().extension).toFile();
|
||||||
@@ -50,20 +50,20 @@ final class AvatarActions {
|
|||||||
show("Error uploading avatar: " + e.getMessage());
|
show("Error uploading avatar: " + e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CompletableFuture<Void> upload = conn.avatarAdmin().set(file);
|
CompletableFuture<Void> upload = session.avatarAdmin().set(file);
|
||||||
upload.whenComplete((ignored, failure) -> file.delete());
|
upload.whenComplete((ignored, failure) -> file.delete());
|
||||||
Edt.onFailure(upload, failure -> show("Error uploading avatar: " + failure.getMessage()));
|
Edt.onFailure(upload, failure -> show("Error uploading avatar: " + failure.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete() {
|
void delete() {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
Edt.onFailure(conn.avatarAdmin().remove(), failure -> show("Error deleting avatar: " + failure.getMessage()));
|
Edt.onFailure(session.avatarAdmin().remove(), failure -> show("Error deleting avatar: " + failure.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Deletes another client's avatar for everyone. */
|
/** Deletes another client's avatar for everyone. */
|
||||||
void deleteOf(ClientEntry client) {
|
void deleteOf(ClientEntry client) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
Edt.onFailure(conn.avatarAdmin().removeOf(client), failure -> show("Error deleting avatar: " + failure.getMessage()));
|
Edt.onFailure(session.avatarAdmin().removeOf(client), failure -> show("Error deleting avatar: " + failure.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show(String message) {
|
private void show(String message) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
import eu.lixko.ts3j.client.config.BanReasonPresets;
|
import eu.lixko.ts3j.client.config.BanReasonPresets;
|
||||||
import eu.lixko.ts3j.client.config.Settings;
|
import eu.lixko.ts3j.client.config.Settings;
|
||||||
import eu.lixko.ts3j.client.net.Permissions;
|
import eu.lixko.ts3j.client.net.Permissions;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
import eu.lixko.ts3j.client.net.ban.BanEntry;
|
import eu.lixko.ts3j.client.net.ban.BanEntry;
|
||||||
import eu.lixko.ts3j.client.net.ban.BanRule;
|
import eu.lixko.ts3j.client.net.ban.BanRule;
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ final class BanListDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final Frame owner;
|
private final Frame owner;
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
private final Settings settings;
|
private final Settings settings;
|
||||||
private final BanReasonPresets presets;
|
private final BanReasonPresets presets;
|
||||||
|
|
||||||
@@ -117,10 +117,10 @@ final class BanListDialog extends JDialog {
|
|||||||
|
|
||||||
private boolean loading;
|
private boolean loading;
|
||||||
|
|
||||||
BanListDialog(Frame owner, TeamspeakConnection conn, Settings settings, BanReasonPresets presets) {
|
BanListDialog(Frame owner, ServerSession session, Settings settings, BanReasonPresets presets) {
|
||||||
super(owner, "Ban List", false);
|
super(owner, "Ban List", false);
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.presets = presets;
|
this.presets = presets;
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ final class BanListDialog extends JDialog {
|
|||||||
|
|
||||||
/** Follows the server's name, as the official window's "Ban List - <server>" title does. */
|
/** Follows the server's name, as the official window's "Ban List - <server>" title does. */
|
||||||
void serverNameChanged() {
|
void serverNameChanged() {
|
||||||
String name = conn.getModel().getServerName();
|
String name = session.model().getServerName();
|
||||||
setTitle(name == null || name.isBlank() ? "Ban List" : "Ban List - " + name);
|
setTitle(name == null || name.isBlank() ? "Ban List" : "Ban List - " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,7 +375,7 @@ final class BanListDialog extends JDialog {
|
|||||||
if (loading) return;
|
if (loading) return;
|
||||||
loading = true;
|
loading = true;
|
||||||
status.setText("Loading…");
|
status.setText("Loading…");
|
||||||
Edt.handle(conn.bans().list(), bans -> {
|
Edt.handle(session.bans().list(), bans -> {
|
||||||
loading = false;
|
loading = false;
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
tableModel.setBans(bans);
|
tableModel.setBans(bans);
|
||||||
@@ -395,7 +395,7 @@ final class BanListDialog extends JDialog {
|
|||||||
private void applyFilter() {
|
private void applyFilter() {
|
||||||
String needle = searchField.getText().trim().toLowerCase(Locale.ROOT);
|
String needle = searchField.getText().trim().toLowerCase(Locale.ROOT);
|
||||||
boolean own = onlyOwn.isSelected();
|
boolean own = onlyOwn.isSelected();
|
||||||
String self = conn.getSelfUniqueId();
|
String self = session.selfUniqueId();
|
||||||
sorter.setRowFilter(new RowFilter<>() {
|
sorter.setRowFilter(new RowFilter<>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean include(Entry<? extends BanTableModel, ? extends Integer> entry) {
|
public boolean include(Entry<? extends BanTableModel, ? extends Integer> entry) {
|
||||||
@@ -419,17 +419,17 @@ final class BanListDialog extends JDialog {
|
|||||||
// ---- permissions ----
|
// ---- permissions ----
|
||||||
|
|
||||||
private void updateButtons() {
|
private void updateButtons() {
|
||||||
Permissions permissions = conn.getModel().permissions();
|
Permissions permissions = session.model().permissions();
|
||||||
List<BanEntry> selected = selectedBans();
|
List<BanEntry> selected = selectedBans();
|
||||||
addButton.setEnabled(permissions.canCreateBans());
|
addButton.setEnabled(permissions.canCreateBans());
|
||||||
removeButton.setEnabled(!selected.isEmpty() && permissions.canDeleteBans(selected, conn.getSelfUniqueId()));
|
removeButton.setEnabled(!selected.isEmpty() && permissions.canDeleteBans(selected, session.selfUniqueId()));
|
||||||
editButton.setEnabled(selected.size() == 1 && permissions.canEditBan(selected.get(0), conn.getSelfUniqueId()));
|
editButton.setEnabled(selected.size() == 1 && permissions.canEditBan(selected.get(0), session.selfUniqueId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- actions ----
|
// ---- actions ----
|
||||||
|
|
||||||
private long maxBanSeconds() {
|
private long maxBanSeconds() {
|
||||||
return conn.getModel().permissions().maxBanSeconds();
|
return session.model().permissions().maxBanSeconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBan() {
|
private void addBan() {
|
||||||
@@ -438,7 +438,7 @@ final class BanListDialog extends JDialog {
|
|||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
BanRule rule = dialog.getRule();
|
BanRule rule = dialog.getRule();
|
||||||
if (rule == null) return;
|
if (rule == null) return;
|
||||||
afterChange(conn.bans().add(rule), "Error adding ban: ",
|
afterChange(session.bans().add(rule), "Error adding ban: ",
|
||||||
() -> JOptionPane.showMessageDialog(this, "Your ban was successfully added.", "Ban List",
|
() -> JOptionPane.showMessageDialog(this, "Your ban was successfully added.", "Ban List",
|
||||||
JOptionPane.INFORMATION_MESSAGE));
|
JOptionPane.INFORMATION_MESSAGE));
|
||||||
}
|
}
|
||||||
@@ -450,7 +450,7 @@ final class BanListDialog extends JDialog {
|
|||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
BanRule rule = dialog.getRule();
|
BanRule rule = dialog.getRule();
|
||||||
if (rule == null) return;
|
if (rule == null) return;
|
||||||
afterChange(conn.bans().replace(ban.id, rule), "Error editing ban: ");
|
afterChange(session.bans().replace(ban.id, rule), "Error editing ban: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeBans() {
|
private void removeBans() {
|
||||||
@@ -460,7 +460,7 @@ final class BanListDialog extends JDialog {
|
|||||||
"Delete bans", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
"Delete bans", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||||
if (answer != JOptionPane.YES_OPTION) return;
|
if (answer != JOptionPane.YES_OPTION) return;
|
||||||
List<Integer> ids = bans.stream().map(b -> b.id).collect(Collectors.toList());
|
List<Integer> ids = bans.stream().map(b -> b.id).collect(Collectors.toList());
|
||||||
afterChange(conn.bans().delete(ids), "Error deleting ban: ");
|
afterChange(session.bans().delete(ids), "Error deleting ban: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reports a failed change, or re-reads the list so the table shows what the server now holds. */
|
/** Reports a failed change, or re-reads the list so the table shows what the server now holds. */
|
||||||
@@ -582,7 +582,7 @@ final class BanListDialog extends JDialog {
|
|||||||
BanEntry ban = tableModel.get(t.convertRowIndexToModel(row));
|
BanEntry ban = tableModel.get(t.convertRowIndexToModel(row));
|
||||||
Column c = Column.values()[t.convertColumnIndexToModel(column)];
|
Column c = Column.values()[t.convertColumnIndexToModel(column)];
|
||||||
super.getTableCellRendererComponent(t, tableModel.text(ban, c), selected, focused, row, column);
|
super.getTableCellRendererComponent(t, tableModel.text(ban, c), selected, focused, row, column);
|
||||||
boolean bold = highlightOwn.isSelected() && ban.createdBy(conn.getSelfUniqueId());
|
boolean bold = highlightOwn.isSelected() && ban.createdBy(session.selfUniqueId());
|
||||||
setFont(bold ? Theme.uiBold() : Theme.uiFont());
|
setFont(bold ? Theme.uiBold() : Theme.uiFont());
|
||||||
setHorizontalAlignment(c == Column.ENFORCED ? RIGHT : LEFT);
|
setHorizontalAlignment(c == Column.ENFORCED ? RIGHT : LEFT);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import com.formdev.flatlaf.util.ScaledEmptyBorder;
|
|||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
import eu.lixko.ts3j.client.net.ChannelNode;
|
import eu.lixko.ts3j.client.net.ChannelNode;
|
||||||
import eu.lixko.ts3j.client.net.ChannelSettings;
|
import eu.lixko.ts3j.client.net.ChannelSettings;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
@@ -79,7 +79,7 @@ final class ChannelDialog extends JDialog {
|
|||||||
+ " special spacer: \"---\", \"...\", \"-.-\", \"___\", \"-..\"</td></tr>"
|
+ " special spacer: \"---\", \"...\", \"-.-\", \"___\", \"-..\"</td></tr>"
|
||||||
+ "</table></html>";
|
+ "</table></html>";
|
||||||
|
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
private final GroupIcons groupIcons;
|
private final GroupIcons groupIcons;
|
||||||
/** The channel being edited, or {@code null} when a new one is being created. */
|
/** The channel being edited, or {@code null} when a new one is being created. */
|
||||||
private final ChannelNode channel;
|
private final ChannelNode channel;
|
||||||
@@ -107,9 +107,9 @@ final class ChannelDialog extends JDialog {
|
|||||||
private boolean passwordEdited;
|
private boolean passwordEdited;
|
||||||
|
|
||||||
/** The editor for an existing channel. */
|
/** The editor for an existing channel. */
|
||||||
static ChannelDialog toEdit(Window owner, TeamspeakConnection conn, GroupIcons groupIcons,
|
static ChannelDialog toEdit(Window owner, ServerSession session, GroupIcons groupIcons,
|
||||||
ChannelNode channel) {
|
ChannelNode channel) {
|
||||||
return new ChannelDialog(owner, conn, groupIcons, "Edit Channel: " + channel.name,
|
return new ChannelDialog(owner, session, groupIcons, "Edit Channel: " + channel.name,
|
||||||
channel, channel.parentId, null);
|
channel, channel.parentId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,20 +119,20 @@ final class ChannelDialog extends JDialog {
|
|||||||
* @param parentId the channel it goes below, 0 being the top level
|
* @param parentId the channel it goes below, 0 being the top level
|
||||||
* @param defaults what the dialog opens with, e.g. the channel type its caller prefers
|
* @param defaults what the dialog opens with, e.g. the channel type its caller prefers
|
||||||
*/
|
*/
|
||||||
static ChannelDialog toCreate(Window owner, TeamspeakConnection conn, GroupIcons groupIcons,
|
static ChannelDialog toCreate(Window owner, ServerSession session, GroupIcons groupIcons,
|
||||||
String title, int parentId, ChannelSettings defaults) {
|
String title, int parentId, ChannelSettings defaults) {
|
||||||
return new ChannelDialog(owner, conn, groupIcons, title, null, parentId, defaults);
|
return new ChannelDialog(owner, session, groupIcons, title, null, parentId, defaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChannelDialog(Window owner, TeamspeakConnection conn, GroupIcons groupIcons, String title,
|
private ChannelDialog(Window owner, ServerSession session, GroupIcons groupIcons, String title,
|
||||||
ChannelNode channel, int parentId, ChannelSettings defaults) {
|
ChannelNode channel, int parentId, ChannelSettings defaults) {
|
||||||
super(owner, title, ModalityType.APPLICATION_MODAL);
|
super(owner, title, ModalityType.APPLICATION_MODAL);
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
this.groupIcons = groupIcons;
|
this.groupIcons = groupIcons;
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
this.standardPanel = new ChannelStandardPanel(channel != null
|
this.standardPanel = new ChannelStandardPanel(channel != null
|
||||||
? conn.getModel().siblingsOf(channel.id) : conn.getModel().childrenOf(parentId));
|
? session.model().siblingsOf(channel.id) : session.model().childrenOf(parentId));
|
||||||
|
|
||||||
standardPanel.onTypeChanged(advancedPanel::setChannelType);
|
standardPanel.onTypeChanged(advancedPanel::setChannelType);
|
||||||
settingsTabs = List.of(standardPanel, audioPanel, advancedPanel);
|
settingsTabs = List.of(standardPanel, audioPanel, advancedPanel);
|
||||||
@@ -286,12 +286,12 @@ final class ChannelDialog extends JDialog {
|
|||||||
// ---- loading ----
|
// ---- loading ----
|
||||||
|
|
||||||
private void load() {
|
private void load() {
|
||||||
Edt.handle(conn.channels().settings(channel.id), this::apply, failure -> {
|
Edt.handle(session.channels().settings(channel.id), this::apply, failure -> {
|
||||||
JOptionPane.showMessageDialog(this, "Could not read the channel: " + failure.getMessage(),
|
JOptionPane.showMessageDialog(this, "Could not read the channel: " + failure.getMessage(),
|
||||||
"Error", JOptionPane.ERROR_MESSAGE);
|
"Error", JOptionPane.ERROR_MESSAGE);
|
||||||
dispose();
|
dispose();
|
||||||
});
|
});
|
||||||
Edt.handle(conn.channels().permissions(channel.id), permissionsPanel::read,
|
Edt.handle(session.channels().permissions(channel.id), permissionsPanel::read,
|
||||||
failure -> permissionsPanel.showUnavailable("No permission to view channel permissions."));
|
failure -> permissionsPanel.showUnavailable("No permission to view channel permissions."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ final class ChannelDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void chooseIcon() {
|
private void chooseIcon() {
|
||||||
IconChooserDialog chooser = new IconChooserDialog(this, conn.channels(), groupIcons);
|
IconChooserDialog chooser = new IconChooserDialog(this, session.channels(), groupIcons);
|
||||||
chooser.setVisible(true);
|
chooser.setVisible(true);
|
||||||
if (chooser.isAccepted()) setIconId(chooser.getIconId());
|
if (chooser.isAccepted()) setIconId(chooser.getIconId());
|
||||||
}
|
}
|
||||||
@@ -397,7 +397,7 @@ final class ChannelDialog extends JDialog {
|
|||||||
|
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
ok.setEnabled(false);
|
ok.setEnabled(false);
|
||||||
finish(conn.channels().create(parentId, edited.creationParameters(), permissionsPanel.changed()),
|
finish(session.channels().create(parentId, edited.creationParameters(), permissionsPanel.changed()),
|
||||||
"Could not create the channel: ");
|
"Could not create the channel: ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -411,7 +411,7 @@ final class ChannelDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ok.setEnabled(false);
|
ok.setEnabled(false);
|
||||||
finish(conn.channels().edit(channel.id, changes, setPermissions, clearedPermissions),
|
finish(session.channels().edit(channel.id, changes, setPermissions, clearedPermissions),
|
||||||
"Could not save the channel: ");
|
"Could not save the channel: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package eu.lixko.ts3j.client.ui;
|
|||||||
|
|
||||||
import com.formdev.flatlaf.util.ScaledEmptyBorder;
|
import com.formdev.flatlaf.util.ScaledEmptyBorder;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
import eu.lixko.ts3j.client.net.ClientContacts;
|
||||||
import eu.lixko.ts3j.client.net.ClientEntry;
|
import eu.lixko.ts3j.client.net.ClientEntry;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
@@ -24,17 +24,17 @@ final class ClientVolumeDialog extends JDialog {
|
|||||||
|
|
||||||
private static final int RANGE_DB = 40;
|
private static final int RANGE_DB = 40;
|
||||||
|
|
||||||
private final TeamspeakConnection conn;
|
private final ClientContacts contacts;
|
||||||
private final ClientEntry client;
|
private final ClientEntry client;
|
||||||
private final JSlider slider = new JSlider(-RANGE_DB, RANGE_DB, 0);
|
private final JSlider slider = new JSlider(-RANGE_DB, RANGE_DB, 0);
|
||||||
private final JLabel value = new JLabel();
|
private final JLabel value = new JLabel();
|
||||||
|
|
||||||
ClientVolumeDialog(Frame owner, TeamspeakConnection conn, ClientEntry client) {
|
ClientVolumeDialog(Frame owner, ClientContacts contacts, ClientEntry client) {
|
||||||
super(owner, "Change Volume: " + conn.displayName(client), false);
|
super(owner, "Change Volume: " + contacts.displayName(client), false);
|
||||||
this.conn = conn;
|
this.contacts = contacts;
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
|
||||||
slider.setValue((int) Math.round(conn.getClientVolumeModifier(client)));
|
slider.setValue((int) Math.round(contacts.volumeModifier(client)));
|
||||||
slider.setMajorTickSpacing(20);
|
slider.setMajorTickSpacing(20);
|
||||||
slider.setMinorTickSpacing(5);
|
slider.setMinorTickSpacing(5);
|
||||||
slider.setPaintTicks(true);
|
slider.setPaintTicks(true);
|
||||||
@@ -75,6 +75,6 @@ final class ClientVolumeDialog extends JDialog {
|
|||||||
private void onChanged() {
|
private void onChanged() {
|
||||||
int db = slider.getValue();
|
int db = slider.getValue();
|
||||||
value.setText((db > 0 ? "+" : "") + db + " dB");
|
value.setText((db > 0 ? "+" : "") + db + " dB");
|
||||||
if (!slider.getValueIsAdjusting()) conn.setClientVolumeModifier(client, db);
|
if (!slider.getValueIsAdjusting()) contacts.setVolumeModifier(client, db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
import eu.lixko.ts3j.client.net.ClientEntry;
|
import eu.lixko.ts3j.client.net.ClientEntry;
|
||||||
import eu.lixko.ts3j.client.net.Complaint;
|
import eu.lixko.ts3j.client.net.Complaint;
|
||||||
import eu.lixko.ts3j.client.net.ServerModel;
|
import eu.lixko.ts3j.client.net.ServerModel;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
@@ -88,7 +88,7 @@ final class ComplaintsDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
private final Consumer<ClientEntry> banClient;
|
private final Consumer<ClientEntry> banClient;
|
||||||
|
|
||||||
private final ComplaintTableModel tableModel = new ComplaintTableModel();
|
private final ComplaintTableModel tableModel = new ComplaintTableModel();
|
||||||
@@ -112,9 +112,9 @@ final class ComplaintsDialog extends JDialog {
|
|||||||
private boolean loading;
|
private boolean loading;
|
||||||
|
|
||||||
/** @param banClient opens the ban dialog for an online client */
|
/** @param banClient opens the ban dialog for an online client */
|
||||||
ComplaintsDialog(Frame owner, TeamspeakConnection conn, Consumer<ClientEntry> banClient) {
|
ComplaintsDialog(Frame owner, ServerSession session, Consumer<ClientEntry> banClient) {
|
||||||
super(owner, "Complaints List", false);
|
super(owner, "Complaints List", false);
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
this.banClient = banClient;
|
this.banClient = banClient;
|
||||||
|
|
||||||
JPanel content = new JPanel(new BorderLayout(0, UIScale.scale(6)));
|
JPanel content = new JPanel(new BorderLayout(0, UIScale.scale(6)));
|
||||||
@@ -244,7 +244,7 @@ final class ComplaintsDialog extends JDialog {
|
|||||||
|
|
||||||
/** Follows the server's name, as the ban list's title does. */
|
/** Follows the server's name, as the ban list's title does. */
|
||||||
void serverNameChanged() {
|
void serverNameChanged() {
|
||||||
String name = conn.getModel().getServerName();
|
String name = session.model().getServerName();
|
||||||
setTitle(name == null || name.isBlank() ? "Complaints List" : "Complaints List - " + name);
|
setTitle(name == null || name.isBlank() ? "Complaints List" : "Complaints List - " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ final class ComplaintsDialog extends JDialog {
|
|||||||
if (loading) return;
|
if (loading) return;
|
||||||
loading = true;
|
loading = true;
|
||||||
status.setText("Loading…");
|
status.setText("Loading…");
|
||||||
Edt.handle(conn.complaints().list(), complaints -> {
|
Edt.handle(session.complaints().list(), complaints -> {
|
||||||
loading = false;
|
loading = false;
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
setTargets(groupByTarget(complaints));
|
setTargets(groupByTarget(complaints));
|
||||||
@@ -349,13 +349,13 @@ final class ComplaintsDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int selfDbId() {
|
private int selfDbId() {
|
||||||
ClientEntry self = conn.getModel().getClient(conn.getSelfClientId());
|
ClientEntry self = session.model().getClient(session.selfClientId());
|
||||||
return self == null ? 0 : self.databaseId;
|
return self == null ? 0 : self.databaseId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtons() {
|
private void updateButtons() {
|
||||||
Selection sel = selection();
|
Selection sel = selection();
|
||||||
removeButton.setEnabled(!sel.isEmpty() && conn.getModel().permissions().canDeleteComplaints(sel.affected(), selfDbId()));
|
removeButton.setEnabled(!sel.isEmpty() && session.model().permissions().canDeleteComplaints(sel.affected(), selfDbId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -365,11 +365,11 @@ final class ComplaintsDialog extends JDialog {
|
|||||||
private ClientEntry banTarget() {
|
private ClientEntry banTarget() {
|
||||||
int[] rows = table.getSelectedRows();
|
int[] rows = table.getSelectedRows();
|
||||||
if (rows.length != 1) return null;
|
if (rows.length != 1) return null;
|
||||||
ServerModel model = conn.getModel();
|
ServerModel model = session.model();
|
||||||
if (!model.permissions().canBanClients()) return null;
|
if (!model.permissions().canBanClients()) return null;
|
||||||
Row row = tableModel.get(rows[0]);
|
Row row = tableModel.get(rows[0]);
|
||||||
ClientEntry client = model.findClientByDatabaseId(row.isTarget() ? row.target().dbId() : row.complaint().fromDbId());
|
ClientEntry client = model.findClientByDatabaseId(row.isTarget() ? row.target().dbId() : row.complaint().fromDbId());
|
||||||
return client == null || client.id == conn.getSelfClientId() ? null : client;
|
return client == null || client.id == session.selfClientId() ? null : client;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- actions ----
|
// ---- actions ----
|
||||||
@@ -384,7 +384,7 @@ final class ComplaintsDialog extends JDialog {
|
|||||||
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||||
if (answer != JOptionPane.YES_OPTION) return;
|
if (answer != JOptionPane.YES_OPTION) return;
|
||||||
List<Integer> whole = sel.whole().stream().map(Target::dbId).toList();
|
List<Integer> whole = sel.whole().stream().map(Target::dbId).toList();
|
||||||
Edt.handle(conn.complaints().delete(whole, sel.single()), () -> {
|
Edt.handle(session.complaints().delete(whole, sel.single()), () -> {
|
||||||
if (isDisplayable()) reload();
|
if (isDisplayable()) reload();
|
||||||
}, failure -> {
|
}, failure -> {
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import eu.lixko.ts3j.client.net.ConnectionStats;
|
|||||||
import eu.lixko.ts3j.client.net.ConnectionStatsFormat;
|
import eu.lixko.ts3j.client.net.ConnectionStatsFormat;
|
||||||
import eu.lixko.ts3j.client.net.ConnectionStatsFormat.Row;
|
import eu.lixko.ts3j.client.net.ConnectionStatsFormat.Row;
|
||||||
import eu.lixko.ts3j.client.net.ConnectionStatsFormat.TrafficRow;
|
import eu.lixko.ts3j.client.net.ConnectionStatsFormat.TrafficRow;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
import eu.lixko.ts3j.client.net.avatar.Avatar;
|
import eu.lixko.ts3j.client.net.avatar.Avatar;
|
||||||
|
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
@@ -53,7 +53,7 @@ public final class ConnectionInfoDialog extends JDialog {
|
|||||||
private static final String TOTAL_SAMPLE = "100.00 %";
|
private static final String TOTAL_SAMPLE = "100.00 %";
|
||||||
private static final String VALUE_SAMPLE = "1023.00 KiB/s";
|
private static final String VALUE_SAMPLE = "1023.00 KiB/s";
|
||||||
|
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
private final int clientId;
|
private final int clientId;
|
||||||
private final String nickname;
|
private final String nickname;
|
||||||
private final javax.swing.Timer timer;
|
private final javax.swing.Timer timer;
|
||||||
@@ -69,9 +69,9 @@ public final class ConnectionInfoDialog extends JDialog {
|
|||||||
private Figures quota;
|
private Figures quota;
|
||||||
private final Figures voice = new Figures(List.of(ConnectionStatsFormat.voiceRows(null)), false);
|
private final Figures voice = new Figures(List.of(ConnectionStatsFormat.voiceRows(null)), false);
|
||||||
|
|
||||||
public ConnectionInfoDialog(Frame owner, TeamspeakConnection conn, int clientId, String nickname) {
|
public ConnectionInfoDialog(Frame owner, ServerSession session, int clientId, String nickname) {
|
||||||
super(owner, "Connection Info - " + nickname, false);
|
super(owner, "Connection Info - " + nickname, false);
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.nickname = nickname;
|
this.nickname = nickname;
|
||||||
this.summary = new Figures(List.of(ConnectionStatsFormat.summaryRows(null, nickname)), true);
|
this.summary = new Figures(List.of(ConnectionStatsFormat.summaryRows(null, nickname)), true);
|
||||||
@@ -169,12 +169,12 @@ public final class ConnectionInfoDialog extends JDialog {
|
|||||||
// ---- live update ----
|
// ---- live update ----
|
||||||
|
|
||||||
private void refresh() {
|
private void refresh() {
|
||||||
if (!conn.isConnected()) {
|
if (!session.isConnected()) {
|
||||||
timer.stop();
|
timer.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!inFlight.compareAndSet(false, true)) return; // a previous poll is still running
|
if (!inFlight.compareAndSet(false, true)) return; // a previous poll is still running
|
||||||
conn.requestConnectionInfo(clientId, stats -> SwingUtilities.invokeLater(() -> {
|
session.requestConnectionInfo(clientId, stats -> SwingUtilities.invokeLater(() -> {
|
||||||
inFlight.set(false);
|
inFlight.set(false);
|
||||||
apply(stats);
|
apply(stats);
|
||||||
}));
|
}));
|
||||||
@@ -192,8 +192,8 @@ public final class ConnectionInfoDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showAvatar() {
|
private void showAvatar() {
|
||||||
ClientEntry client = conn.getModel().getClient(clientId);
|
ClientEntry client = session.model().getClient(clientId);
|
||||||
Avatar current = conn.avatarOf(client);
|
Avatar current = session.avatarOf(client);
|
||||||
if (current == shownAvatar) return;
|
if (current == shownAvatar) return;
|
||||||
shownAvatar = current;
|
shownAvatar = current;
|
||||||
avatar.setIcon(current == null ? null : avatarIcon(current));
|
avatar.setIcon(current == null ? null : avatarIcon(current));
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ final class DesktopNotifier {
|
|||||||
frame.bringToFront();
|
frame.bringToFront();
|
||||||
frame.selectTab(tab);
|
frame.selectTab(tab);
|
||||||
if (clientId != null) {
|
if (clientId != null) {
|
||||||
var client = tab.connection().getModel().getClient(clientId);
|
var client = tab.session().model().getClient(clientId);
|
||||||
if (client != null) tab.chat().openPrivateChat(clientId, client.uniqueId, client.nickname);
|
if (client != null) tab.chat().openPrivateChat(clientId, client.uniqueId, client.nickname);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package eu.lixko.ts3j.client.ui;
|
|||||||
import com.formdev.flatlaf.util.ScaledEmptyBorder;
|
import com.formdev.flatlaf.util.ScaledEmptyBorder;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
import eu.lixko.ts3j.client.net.ChannelNode;
|
import eu.lixko.ts3j.client.net.ChannelNode;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
import eu.lixko.ts3j.client.net.filetransfer.FileTransfer;
|
import eu.lixko.ts3j.client.net.filetransfer.FileTransfer;
|
||||||
import eu.lixko.ts3j.client.net.filetransfer.RemoteFile;
|
import eu.lixko.ts3j.client.net.filetransfer.RemoteFile;
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public final class FileBrowserDialog extends JDialog {
|
public final class FileBrowserDialog extends JDialog {
|
||||||
|
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
private final int channelId;
|
private final int channelId;
|
||||||
private final String channelPassword;
|
private final String channelPassword;
|
||||||
|
|
||||||
@@ -61,9 +61,9 @@ public final class FileBrowserDialog extends JDialog {
|
|||||||
|
|
||||||
private volatile String currentPath = "/";
|
private volatile String currentPath = "/";
|
||||||
|
|
||||||
public FileBrowserDialog(Frame owner, TeamspeakConnection conn, ChannelNode channel) {
|
public FileBrowserDialog(Frame owner, ServerSession session, ChannelNode channel) {
|
||||||
super(owner, "Files — " + channel.name, false);
|
super(owner, "Files — " + channel.name, false);
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
this.channelId = channel.id;
|
this.channelId = channel.id;
|
||||||
this.channelPassword = "";
|
this.channelPassword = "";
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ public final class FileBrowserDialog extends JDialog {
|
|||||||
final String path = currentPath;
|
final String path = currentPath;
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
List<RemoteFile> files = conn.listFiles(channelId, channelPassword, path);
|
List<RemoteFile> files = session.files().list(channelId, channelPassword, path);
|
||||||
Collections.sort(files, DIRECTORIES_FIRST);
|
Collections.sort(files, DIRECTORIES_FIRST);
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
if (path.equals(currentPath)) tableModel.setFiles(files);
|
if (path.equals(currentPath)) tableModel.setFiles(files);
|
||||||
@@ -243,7 +243,7 @@ public final class FileBrowserDialog extends JDialog {
|
|||||||
|
|
||||||
private void startDownload(RemoteFile file, File target) {
|
private void startDownload(RemoteFile file, File target) {
|
||||||
TransferRow row = new TransferRow();
|
TransferRow row = new TransferRow();
|
||||||
FileTransfer transfer = conn.downloadFile(channelId, channelPassword, file.getFullPath(), target,
|
FileTransfer transfer = session.files().download(channelId, channelPassword, file.getFullPath(), target,
|
||||||
t -> SwingUtilities.invokeLater(() -> row.update(t)));
|
t -> SwingUtilities.invokeLater(() -> row.update(t)));
|
||||||
row.attach(transfer);
|
row.attach(transfer);
|
||||||
addTransferRow(row);
|
addTransferRow(row);
|
||||||
@@ -258,7 +258,7 @@ public final class FileBrowserDialog extends JDialog {
|
|||||||
if (!source.isFile()) continue;
|
if (!source.isFile()) continue;
|
||||||
String remotePath = currentPath + source.getName();
|
String remotePath = currentPath + source.getName();
|
||||||
TransferRow row = new TransferRow();
|
TransferRow row = new TransferRow();
|
||||||
FileTransfer transfer = conn.uploadFile(channelId, channelPassword, remotePath, source, true,
|
FileTransfer transfer = session.files().upload(channelId, channelPassword, remotePath, source, true,
|
||||||
t -> SwingUtilities.invokeLater(() -> {
|
t -> SwingUtilities.invokeLater(() -> {
|
||||||
row.update(t);
|
row.update(t);
|
||||||
if (t.getState() == FileTransfer.State.COMPLETED) refresh();
|
if (t.getState() == FileTransfer.State.COMPLETED) refresh();
|
||||||
@@ -275,7 +275,7 @@ public final class FileBrowserDialog extends JDialog {
|
|||||||
final String dirPath = currentPath + name.trim();
|
final String dirPath = currentPath + name.trim();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
conn.createDirectory(channelId, channelPassword, dirPath);
|
session.files().createDirectory(channelId, channelPassword, dirPath);
|
||||||
SwingUtilities.invokeLater(this::refresh);
|
SwingUtilities.invokeLater(this::refresh);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
SwingUtilities.invokeLater(() -> error("Could not create folder", ex));
|
SwingUtilities.invokeLater(() -> error("Could not create folder", ex));
|
||||||
@@ -295,7 +295,7 @@ public final class FileBrowserDialog extends JDialog {
|
|||||||
Exception failure = null;
|
Exception failure = null;
|
||||||
for (RemoteFile f : files) {
|
for (RemoteFile f : files) {
|
||||||
try {
|
try {
|
||||||
conn.deleteFile(channelId, channelPassword, f.getFullPath());
|
session.files().delete(channelId, channelPassword, f.getFullPath());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
failure = ex;
|
failure = ex;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -829,7 +829,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
|||||||
settings.save();
|
settings.save();
|
||||||
|
|
||||||
ServerTab tab = (replaceCurrent && selected != null) ? selected : tabForNewConnection();
|
ServerTab tab = (replaceCurrent && selected != null) ? selected : tabForNewConnection();
|
||||||
tab.session().connection().setMyTeamSpeakFeatures(mytsFeatures);
|
tab.session().setMyTeamSpeakFeatures(mytsFeatures);
|
||||||
// The first connection to come up takes the microphone; later ones are muted
|
// The first connection to come up takes the microphone; later ones are muted
|
||||||
// until the user activates them.
|
// until the user activates them.
|
||||||
if (sessions.microphoneOwner() == null) sessions.giveMicrophoneTo(tab.session());
|
if (sessions.microphoneOwner() == null) sessions.giveMicrophoneTo(tab.session());
|
||||||
@@ -859,7 +859,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ServerTab tab = tabForNewConnection();
|
ServerTab tab = tabForNewConnection();
|
||||||
tab.session().connection().setMyTeamSpeakFeatures(true);
|
tab.session().setMyTeamSpeakFeatures(true);
|
||||||
if (sessions.microphoneOwner() == null) sessions.giveMicrophoneTo(tab.session());
|
if (sessions.microphoneOwner() == null) sessions.giveMicrophoneTo(tab.session());
|
||||||
tab.session().open(link, "");
|
tab.session().open(link, "");
|
||||||
}
|
}
|
||||||
@@ -1034,8 +1034,8 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
|||||||
// Device and voice-gating changes apply to the capturing connection and the
|
// Device and voice-gating changes apply to the capturing connection and the
|
||||||
// playback of the visible one; the rest pick the new settings up on connect.
|
// playback of the visible one; the rest pick the new settings up on connect.
|
||||||
SettingsDialog dlg = new SettingsDialog(this, settings, audio,
|
SettingsDialog dlg = new SettingsDialog(this, settings, audio,
|
||||||
sessions.microphoneOwner() == null ? null : sessions.microphoneOwner().connection().ownClient().microphone(),
|
sessions.microphoneOwner() == null ? null : sessions.microphoneOwner().microphone(),
|
||||||
selected == null ? null : selected.connection().ownClient().playback(),
|
selected == null ? null : selected.session().playback(),
|
||||||
sounds, hotkeys,
|
sounds, hotkeys,
|
||||||
new MyTeamSpeakPanel(myTeamSpeak, new TeamSpeakImporter(identities, bookmarks, settings, contacts),
|
new MyTeamSpeakPanel(myTeamSpeak, new TeamSpeakImporter(identities, bookmarks, settings, contacts),
|
||||||
menuBar::rebuildBookmarks, this::myTeamSpeakChanged),
|
menuBar::rebuildBookmarks, this::myTeamSpeakChanged),
|
||||||
@@ -1051,7 +1051,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
|||||||
boolean signedIn = myTeamSpeak.isSignedIn();
|
boolean signedIn = myTeamSpeak.isSignedIn();
|
||||||
for (ServerTab tab : tabs) {
|
for (ServerTab tab : tabs) {
|
||||||
tab.chat().setSharingAvailable(signedIn);
|
tab.chat().setSharingAvailable(signedIn);
|
||||||
tab.session().connection().updateMyTeamSpeak();
|
tab.session().updateMyTeamSpeak();
|
||||||
}
|
}
|
||||||
if (signedIn) {
|
if (signedIn) {
|
||||||
pictures.retryFailed();
|
pictures.retryFailed();
|
||||||
@@ -1077,7 +1077,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
|||||||
private void applyOutputSettingsToAllTabs() {
|
private void applyOutputSettingsToAllTabs() {
|
||||||
soundPlayer.setOutputDevice(settings.outputDevice);
|
soundPlayer.setOutputDevice(settings.outputDevice);
|
||||||
for (ServerTab tab : tabs) {
|
for (ServerTab tab : tabs) {
|
||||||
VoiceOutput playback = tab.connection().ownClient().playback();
|
VoiceOutput playback = tab.session().playback();
|
||||||
if (playback == null) continue;
|
if (playback == null) continue;
|
||||||
playback.setMasterVolume(settings.effectiveOutputVolume());
|
playback.setMasterVolume(settings.effectiveOutputVolume());
|
||||||
playback.setOutputDevice(settings.outputDevice);
|
playback.setOutputDevice(settings.outputDevice);
|
||||||
@@ -1139,12 +1139,12 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
|||||||
toolbar.showHostButton(hostButtonOf(selected));
|
toolbar.showHostButton(hostButtonOf(selected));
|
||||||
menuBar.refresh(connected, anyConnected, micMuted, deaf, active, away, commander);
|
menuBar.refresh(connected, anyConnected, micMuted, deaf, active, away, commander);
|
||||||
statusBar.showRecording(connected && selected.session().isRecording());
|
statusBar.showRecording(connected && selected.session().isRecording());
|
||||||
statusBar.showUnreadMessages(connected ? selected.connection().unreadOfflineMessages() : 0);
|
statusBar.showUnreadMessages(connected ? selected.session().unreadOfflineMessages() : 0);
|
||||||
updateTray();
|
updateTray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HostButton hostButtonOf(ServerTab tab) {
|
private static HostButton hostButtonOf(ServerTab tab) {
|
||||||
return tab != null && tab.session().isConnected() ? tab.connection().getModel().hostButton() : null;
|
return tab != null && tab.session().isConnected() ? tab.session().model().hostButton() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1181,11 +1181,11 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
|||||||
private void updateConnectionStatus() {
|
private void updateConnectionStatus() {
|
||||||
ServerTab tab = selected;
|
ServerTab tab = selected;
|
||||||
if (tab == null || !tab.session().isConnected()) return;
|
if (tab == null || !tab.session().isConnected()) return;
|
||||||
int users = tab.connection().getModel().clientCount();
|
int users = tab.session().model().clientCount();
|
||||||
StringBuilder s = new StringBuilder("Connected to ")
|
StringBuilder s = new StringBuilder("Connected to ")
|
||||||
.append(tab.connection().getModel().getServerName())
|
.append(tab.session().model().getServerName())
|
||||||
.append(" | ").append(users).append(users == 1 ? " user" : " users");
|
.append(" | ").append(users).append(users == 1 ? " user" : " users");
|
||||||
double ping = tab.connection().getPingMillis();
|
double ping = tab.session().pingMillis();
|
||||||
if (ping >= 0) s.append(" | ping ").append(Math.round(ping)).append(" ms");
|
if (ping >= 0) s.append(" | ping ").append(Math.round(ping)).append(" ms");
|
||||||
if (tab != micTab()) s.append(" | microphone on another tab");
|
if (tab != micTab()) s.append(" | microphone on another tab");
|
||||||
statusBar.setStatus(s.toString());
|
statusBar.setStatus(s.toString());
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package eu.lixko.ts3j.client.ui;
|
|||||||
import com.formdev.flatlaf.util.ScaledEmptyBorder;
|
import com.formdev.flatlaf.util.ScaledEmptyBorder;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
import eu.lixko.ts3j.client.net.OfflineMessage;
|
import eu.lixko.ts3j.client.net.OfflineMessage;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
import eu.lixko.ts3j.client.text.BBCode;
|
import eu.lixko.ts3j.client.text.BBCode;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
@@ -86,7 +86,7 @@ final class OfflineMessagesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
private final Composer composer;
|
private final Composer composer;
|
||||||
|
|
||||||
private final MessageTableModel tableModel = new MessageTableModel();
|
private final MessageTableModel tableModel = new MessageTableModel();
|
||||||
@@ -124,9 +124,9 @@ final class OfflineMessagesDialog extends JDialog {
|
|||||||
private boolean selectingForPopup;
|
private boolean selectingForPopup;
|
||||||
private boolean loading;
|
private boolean loading;
|
||||||
|
|
||||||
OfflineMessagesDialog(Frame owner, TeamspeakConnection conn, Composer composer) {
|
OfflineMessagesDialog(Frame owner, ServerSession session, Composer composer) {
|
||||||
super(owner, "Offline Messages", false);
|
super(owner, "Offline Messages", false);
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
this.composer = composer;
|
this.composer = composer;
|
||||||
|
|
||||||
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, buildTable(), buildReader());
|
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, buildTable(), buildReader());
|
||||||
@@ -314,7 +314,7 @@ final class OfflineMessagesDialog extends JDialog {
|
|||||||
// ---- data ----
|
// ---- data ----
|
||||||
|
|
||||||
void serverNameChanged() {
|
void serverNameChanged() {
|
||||||
String name = conn.getModel().getServerName();
|
String name = session.model().getServerName();
|
||||||
setTitle(name == null || name.isBlank() ? "Offline Messages" : "Offline Messages on " + name);
|
setTitle(name == null || name.isBlank() ? "Offline Messages" : "Offline Messages on " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ final class OfflineMessagesDialog extends JDialog {
|
|||||||
if (loading) return;
|
if (loading) return;
|
||||||
loading = true;
|
loading = true;
|
||||||
status.setText("Loading…");
|
status.setText("Loading…");
|
||||||
Edt.handle(conn.offlineMessages().list(), messages -> {
|
Edt.handle(session.offlineMessages().list(), messages -> {
|
||||||
loading = false;
|
loading = false;
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
setMessages(messages);
|
setMessages(messages);
|
||||||
@@ -363,7 +363,7 @@ final class OfflineMessagesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtons() {
|
private void updateButtons() {
|
||||||
boolean canSend = conn.getModel().permissions().canSendOfflineMessages();
|
boolean canSend = session.model().permissions().canSendOfflineMessages();
|
||||||
composeButton.setEnabled(canSend);
|
composeButton.setEnabled(canSend);
|
||||||
replyButton.setEnabled(canSend && singleSelected() != null);
|
replyButton.setEnabled(canSend && singleSelected() != null);
|
||||||
deleteButton.setEnabled(table.getSelectedRowCount() > 0);
|
deleteButton.setEnabled(table.getSelectedRowCount() > 0);
|
||||||
@@ -388,7 +388,7 @@ final class OfflineMessagesDialog extends JDialog {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bodyPane.setText("");
|
bodyPane.setText("");
|
||||||
Edt.handle(conn.offlineMessages().body(message.id()), text -> {
|
Edt.handle(session.offlineMessages().body(message.id()), text -> {
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
bodies.put(message.id(), text);
|
bodies.put(message.id(), text);
|
||||||
if (shownId == message.id()) showBody(message, text);
|
if (shownId == message.id()) showBody(message, text);
|
||||||
@@ -419,7 +419,7 @@ final class OfflineMessagesDialog extends JDialog {
|
|||||||
composer.reply(message, body);
|
composer.reply(message, body);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Edt.handle(conn.offlineMessages().body(message.id()), text -> {
|
Edt.handle(session.offlineMessages().body(message.id()), text -> {
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
bodies.put(message.id(), text);
|
bodies.put(message.id(), text);
|
||||||
composer.reply(message, text);
|
composer.reply(message, text);
|
||||||
@@ -436,7 +436,7 @@ final class OfflineMessagesDialog extends JDialog {
|
|||||||
private void mark(List<OfflineMessage> messages, boolean read) {
|
private void mark(List<OfflineMessage> messages, boolean read) {
|
||||||
if (messages.isEmpty()) return;
|
if (messages.isEmpty()) return;
|
||||||
for (OfflineMessage m : messages) tableModel.replace(m.withRead(read));
|
for (OfflineMessage m : messages) tableModel.replace(m.withRead(read));
|
||||||
Edt.onFailure(conn.offlineMessages().markRead(messages.stream().map(OfflineMessage::id).toList(), read), failure -> {
|
Edt.onFailure(session.offlineMessages().markRead(messages.stream().map(OfflineMessage::id).toList(), read), failure -> {
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
status.setText("Failed to update offline message: " + failure.getMessage());
|
status.setText("Failed to update offline message: " + failure.getMessage());
|
||||||
reload();
|
reload();
|
||||||
@@ -460,7 +460,7 @@ final class OfflineMessagesDialog extends JDialog {
|
|||||||
for (OfflineMessage m : selected) bodies.remove(m.id());
|
for (OfflineMessage m : selected) bodies.remove(m.id());
|
||||||
reload();
|
reload();
|
||||||
};
|
};
|
||||||
Edt.handle(conn.offlineMessages().delete(selected.stream().map(OfflineMessage::id).toList()), () -> {
|
Edt.handle(session.offlineMessages().delete(selected.stream().map(OfflineMessage::id).toList()), () -> {
|
||||||
if (isDisplayable()) deleted.run();
|
if (isDisplayable()) deleted.run();
|
||||||
}, failure -> {
|
}, failure -> {
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
|
|||||||
+7
-7
@@ -5,7 +5,7 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
import eu.lixko.ts3j.client.net.ChannelNode;
|
import eu.lixko.ts3j.client.net.ChannelNode;
|
||||||
import eu.lixko.ts3j.client.net.Group;
|
import eu.lixko.ts3j.client.net.Group;
|
||||||
import eu.lixko.ts3j.client.net.ServerModel;
|
import eu.lixko.ts3j.client.net.ServerModel;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
|
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
import javax.swing.ButtonGroup;
|
import javax.swing.ButtonGroup;
|
||||||
@@ -34,7 +34,7 @@ import java.awt.datatransfer.StringSelection;
|
|||||||
*/
|
*/
|
||||||
final class PrivilegeKeyCreateDialog extends JDialog {
|
final class PrivilegeKeyCreateDialog extends JDialog {
|
||||||
|
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
private final Runnable onCreated;
|
private final Runnable onCreated;
|
||||||
|
|
||||||
private final JRadioButton serverGroup = new JRadioButton("Server Group", true);
|
private final JRadioButton serverGroup = new JRadioButton("Server Group", true);
|
||||||
@@ -47,9 +47,9 @@ final class PrivilegeKeyCreateDialog extends JDialog {
|
|||||||
private final JButton create = new JButton("Create");
|
private final JButton create = new JButton("Create");
|
||||||
|
|
||||||
/** @param onCreated runs on the UI thread after each key is created */
|
/** @param onCreated runs on the UI thread after each key is created */
|
||||||
PrivilegeKeyCreateDialog(Window owner, TeamspeakConnection conn, GroupIcons groupIcons, Runnable onCreated) {
|
PrivilegeKeyCreateDialog(Window owner, ServerSession session, GroupIcons groupIcons, Runnable onCreated) {
|
||||||
super(owner, "Create Privilege Key", ModalityType.APPLICATION_MODAL);
|
super(owner, "Create Privilege Key", ModalityType.APPLICATION_MODAL);
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
this.onCreated = onCreated;
|
this.onCreated = onCreated;
|
||||||
|
|
||||||
ButtonGroup type = new ButtonGroup();
|
ButtonGroup type = new ButtonGroup();
|
||||||
@@ -75,7 +75,7 @@ final class PrivilegeKeyCreateDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
groupBox.addActionListener(e -> updateCreate());
|
groupBox.addActionListener(e -> updateCreate());
|
||||||
ServerModel model = conn.getModel();
|
ServerModel model = session.model();
|
||||||
channelBox.setRenderer(new DefaultListCellRenderer() {
|
channelBox.setRenderer(new DefaultListCellRenderer() {
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||||
@@ -133,7 +133,7 @@ final class PrivilegeKeyCreateDialog extends JDialog {
|
|||||||
|
|
||||||
private void typeChanged() {
|
private void typeChanged() {
|
||||||
groupBox.removeAllItems();
|
groupBox.removeAllItems();
|
||||||
for (Group g : conn.getModel().privilegeKeyGroups(forChannelGroup())) groupBox.addItem(g);
|
for (Group g : session.model().privilegeKeyGroups(forChannelGroup())) groupBox.addItem(g);
|
||||||
channelBox.setEnabled(forChannelGroup());
|
channelBox.setEnabled(forChannelGroup());
|
||||||
updateCreate();
|
updateCreate();
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ final class PrivilegeKeyCreateDialog extends JDialog {
|
|||||||
Group group = (Group) groupBox.getSelectedItem();
|
Group group = (Group) groupBox.getSelectedItem();
|
||||||
ChannelNode channel = (ChannelNode) channelBox.getSelectedItem();
|
ChannelNode channel = (ChannelNode) channelBox.getSelectedItem();
|
||||||
create.setEnabled(false);
|
create.setEnabled(false);
|
||||||
Edt.handle(conn.privilegeKeys().add(forChannelGroup(), group.id, channel == null ? 0 : channel.id,
|
Edt.handle(session.privilegeKeys().add(forChannelGroup(), group.id, channel == null ? 0 : channel.id,
|
||||||
descriptionField.getText().trim()), key -> {
|
descriptionField.getText().trim()), key -> {
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
updateCreate();
|
updateCreate();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
import eu.lixko.ts3j.client.net.Group;
|
import eu.lixko.ts3j.client.net.Group;
|
||||||
import eu.lixko.ts3j.client.net.PrivilegeKey;
|
import eu.lixko.ts3j.client.net.PrivilegeKey;
|
||||||
import eu.lixko.ts3j.client.net.ServerModel;
|
import eu.lixko.ts3j.client.net.ServerModel;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
@@ -68,7 +68,7 @@ final class PrivilegeKeysDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
private final GroupIcons groupIcons;
|
private final GroupIcons groupIcons;
|
||||||
|
|
||||||
private final KeyTableModel tableModel = new KeyTableModel();
|
private final KeyTableModel tableModel = new KeyTableModel();
|
||||||
@@ -79,9 +79,9 @@ final class PrivilegeKeysDialog extends JDialog {
|
|||||||
|
|
||||||
private boolean loading;
|
private boolean loading;
|
||||||
|
|
||||||
PrivilegeKeysDialog(Frame owner, TeamspeakConnection conn, GroupIcons groupIcons) {
|
PrivilegeKeysDialog(Frame owner, ServerSession session, GroupIcons groupIcons) {
|
||||||
super(owner, "Privilege Keys", false);
|
super(owner, "Privilege Keys", false);
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
this.groupIcons = groupIcons;
|
this.groupIcons = groupIcons;
|
||||||
|
|
||||||
JPanel content = new JPanel(new BorderLayout(0, UIScale.scale(6)));
|
JPanel content = new JPanel(new BorderLayout(0, UIScale.scale(6)));
|
||||||
@@ -200,7 +200,7 @@ final class PrivilegeKeysDialog extends JDialog {
|
|||||||
|
|
||||||
/** Follows the server's name, as the ban list's title does. */
|
/** Follows the server's name, as the ban list's title does. */
|
||||||
void serverNameChanged() {
|
void serverNameChanged() {
|
||||||
String name = conn.getModel().getServerName();
|
String name = session.model().getServerName();
|
||||||
setTitle(name == null || name.isBlank() ? "Privilege Keys" : "Privilege Keys - " + name);
|
setTitle(name == null || name.isBlank() ? "Privilege Keys" : "Privilege Keys - " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ final class PrivilegeKeysDialog extends JDialog {
|
|||||||
if (loading) return;
|
if (loading) return;
|
||||||
loading = true;
|
loading = true;
|
||||||
status.setText("Loading…");
|
status.setText("Loading…");
|
||||||
Edt.handle(conn.privilegeKeys().list(), keys -> {
|
Edt.handle(session.privilegeKeys().list(), keys -> {
|
||||||
loading = false;
|
loading = false;
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
tableModel.setKeys(keys);
|
tableModel.setKeys(keys);
|
||||||
@@ -234,7 +234,7 @@ final class PrivilegeKeysDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtons() {
|
private void updateButtons() {
|
||||||
ServerModel model = conn.getModel();
|
ServerModel model = session.model();
|
||||||
createButton.setEnabled(model.permissions().canAddPrivilegeKeys());
|
createButton.setEnabled(model.permissions().canAddPrivilegeKeys());
|
||||||
removeButton.setEnabled(!selectedKeys().isEmpty() && model.permissions().canDeletePrivilegeKeys());
|
removeButton.setEnabled(!selectedKeys().isEmpty() && model.permissions().canDeletePrivilegeKeys());
|
||||||
}
|
}
|
||||||
@@ -243,7 +243,7 @@ final class PrivilegeKeysDialog extends JDialog {
|
|||||||
|
|
||||||
private void createKey() {
|
private void createKey() {
|
||||||
if (!createButton.isEnabled()) return;
|
if (!createButton.isEnabled()) return;
|
||||||
new PrivilegeKeyCreateDialog(this, conn, groupIcons, this::reload).setVisible(true);
|
new PrivilegeKeyCreateDialog(this, session, groupIcons, this::reload).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeKeys() {
|
private void removeKeys() {
|
||||||
@@ -252,7 +252,7 @@ final class PrivilegeKeysDialog extends JDialog {
|
|||||||
"Delete Privilege Keys", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
"Delete Privilege Keys", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||||
if (answer != JOptionPane.YES_OPTION) return;
|
if (answer != JOptionPane.YES_OPTION) return;
|
||||||
List<String> tokens = selectedKeys().stream().map(PrivilegeKey::token).collect(Collectors.toList());
|
List<String> tokens = selectedKeys().stream().map(PrivilegeKey::token).collect(Collectors.toList());
|
||||||
Edt.handle(conn.privilegeKeys().delete(tokens), () -> {
|
Edt.handle(session.privilegeKeys().delete(tokens), () -> {
|
||||||
if (isDisplayable()) reload();
|
if (isDisplayable()) reload();
|
||||||
}, failure -> {
|
}, failure -> {
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
@@ -272,7 +272,7 @@ final class PrivilegeKeysDialog extends JDialog {
|
|||||||
// ---- table ----
|
// ---- table ----
|
||||||
|
|
||||||
private Group groupOf(PrivilegeKey key) {
|
private Group groupOf(PrivilegeKey key) {
|
||||||
ServerModel model = conn.getModel();
|
ServerModel model = session.model();
|
||||||
return key.channelGroup() ? model.channelGroup(key.groupId()) : model.serverGroup(key.groupId());
|
return key.channelGroup() ? model.channelGroup(key.groupId()) : model.serverGroup(key.groupId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ final class PrivilegeKeysDialog extends JDialog {
|
|||||||
return group != null ? group.name : Integer.toString(key.groupId());
|
return group != null ? group.name : Integer.toString(key.groupId());
|
||||||
case CHANNEL:
|
case CHANNEL:
|
||||||
if (!key.channelGroup()) return "";
|
if (!key.channelGroup()) return "";
|
||||||
String path = conn.getModel().channelPath(key.channelId());
|
String path = session.model().channelPath(key.channelId());
|
||||||
return path.isEmpty() ? Integer.toString(key.channelId()) : path;
|
return path.isEmpty() ? Integer.toString(key.channelId()) : path;
|
||||||
case CREATED:
|
case CREATED:
|
||||||
return key.createdEpochSeconds() <= 0 ? "" : DATE.format(
|
return key.createdEpochSeconds() <= 0 ? "" : DATE.format(
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
import eu.lixko.ts3j.client.net.ClientEntry;
|
import eu.lixko.ts3j.client.net.ClientEntry;
|
||||||
import eu.lixko.ts3j.client.net.Group;
|
import eu.lixko.ts3j.client.net.Group;
|
||||||
import eu.lixko.ts3j.client.net.GroupChoice;
|
import eu.lixko.ts3j.client.net.GroupChoice;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
|
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.GrayFilter;
|
import javax.swing.GrayFilter;
|
||||||
@@ -29,7 +29,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
final class ServerGroupsDialog extends JDialog {
|
final class ServerGroupsDialog extends JDialog {
|
||||||
|
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
private final GroupIcons groupIcons;
|
private final GroupIcons groupIcons;
|
||||||
private final int clientId;
|
private final int clientId;
|
||||||
private final ServerTreePanel.Actions actions;
|
private final ServerTreePanel.Actions actions;
|
||||||
@@ -39,10 +39,10 @@ final class ServerGroupsDialog extends JDialog {
|
|||||||
/** Cached grayscale icons, keyed by the source icon's identity. */
|
/** Cached grayscale icons, keyed by the source icon's identity. */
|
||||||
private final Map<ImageIcon, ImageIcon> grayscale = new HashMap<>();
|
private final Map<ImageIcon, ImageIcon> grayscale = new HashMap<>();
|
||||||
|
|
||||||
ServerGroupsDialog(MainFrame owner, TeamspeakConnection conn, GroupIcons groupIcons,
|
ServerGroupsDialog(MainFrame owner, ServerSession session, GroupIcons groupIcons,
|
||||||
ClientEntry client, ServerTreePanel.Actions actions) {
|
ClientEntry client, ServerTreePanel.Actions actions) {
|
||||||
super(owner, "Server Groups", true);
|
super(owner, "Server Groups", true);
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
this.groupIcons = groupIcons;
|
this.groupIcons = groupIcons;
|
||||||
this.clientId = client.id;
|
this.clientId = client.id;
|
||||||
this.actions = actions;
|
this.actions = actions;
|
||||||
@@ -75,7 +75,7 @@ final class ServerGroupsDialog extends JDialog {
|
|||||||
|
|
||||||
/** Rebuilds the list from the current model state; closes the dialog if the client left. */
|
/** Rebuilds the list from the current model state; closes the dialog if the client left. */
|
||||||
void refresh() {
|
void refresh() {
|
||||||
ClientEntry client = conn.getModel().getClient(clientId);
|
ClientEntry client = session.model().getClient(clientId);
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
dispose();
|
dispose();
|
||||||
return;
|
return;
|
||||||
@@ -83,7 +83,7 @@ final class ServerGroupsDialog extends JDialog {
|
|||||||
header.setText(client.nickname);
|
header.setText(client.nickname);
|
||||||
|
|
||||||
list.removeAll();
|
list.removeAll();
|
||||||
for (GroupChoice choice : conn.getModel().serverGroupChoices(client)) {
|
for (GroupChoice choice : session.model().serverGroupChoices(client)) {
|
||||||
Group g = choice.group();
|
Group g = choice.group();
|
||||||
ImageIcon icon = groupIcons.iconOf(g);
|
ImageIcon icon = groupIcons.iconOf(g);
|
||||||
JCheckBox box = new JCheckBox(g.name, choice.allowed() ? icon : grayscale(icon));
|
JCheckBox box = new JCheckBox(g.name, choice.allowed() ? icon : grayscale(icon));
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import eu.lixko.ts3j.client.net.RequestException;
|
|||||||
import eu.lixko.ts3j.client.net.ServerLogEntry;
|
import eu.lixko.ts3j.client.net.ServerLogEntry;
|
||||||
import eu.lixko.ts3j.client.net.ServerLogEntry.Level;
|
import eu.lixko.ts3j.client.net.ServerLogEntry.Level;
|
||||||
import eu.lixko.ts3j.client.net.ServerLogPage;
|
import eu.lixko.ts3j.client.net.ServerLogPage;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
import eu.lixko.ts3j.client.text.TextQuery;
|
import eu.lixko.ts3j.client.text.TextQuery;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
@@ -64,7 +64,7 @@ final class ServerLogDialog extends JDialog {
|
|||||||
private static final String TITLE = "Server Log";
|
private static final String TITLE = "Server Log";
|
||||||
private static final int LEVEL_WIDTH = "Critical".length();
|
private static final int LEVEL_WIDTH = "Critical".length();
|
||||||
|
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
private final Settings settings;
|
private final Settings settings;
|
||||||
private final ServerLogSettings view;
|
private final ServerLogSettings view;
|
||||||
|
|
||||||
@@ -100,9 +100,9 @@ final class ServerLogDialog extends JDialog {
|
|||||||
private TextQuery onlyMatching;
|
private TextQuery onlyMatching;
|
||||||
private boolean loading;
|
private boolean loading;
|
||||||
|
|
||||||
ServerLogDialog(Frame owner, TeamspeakConnection conn, Settings settings) {
|
ServerLogDialog(Frame owner, ServerSession session, Settings settings) {
|
||||||
super(owner, TITLE, false);
|
super(owner, TITLE, false);
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.view = settings.serverLog;
|
this.view = settings.serverLog;
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ final class ServerLogDialog extends JDialog {
|
|||||||
// ---- data ----
|
// ---- data ----
|
||||||
|
|
||||||
void serverNameChanged() {
|
void serverNameChanged() {
|
||||||
String name = conn.getModel().getServerName();
|
String name = session.model().getServerName();
|
||||||
setTitle(name == null || name.isBlank() ? TITLE : TITLE + " - " + name);
|
setTitle(name == null || name.isBlank() ? TITLE : TITLE + " - " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ final class ServerLogDialog extends JDialog {
|
|||||||
loading = true;
|
loading = true;
|
||||||
olderButton.setEnabled(false);
|
olderButton.setEnabled(false);
|
||||||
showStatus("Loading…", Theme.chatEvent());
|
showStatus("Loading…", Theme.chatEvent());
|
||||||
Edt.handle(conn.serverLog().read(from), page -> {
|
Edt.handle(session.serverLog().read(from), page -> {
|
||||||
loading = false;
|
loading = false;
|
||||||
if (isDisplayable()) received(page, from > 0);
|
if (isDisplayable()) received(page, from > 0);
|
||||||
}, failure -> {
|
}, failure -> {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import eu.lixko.ts3j.client.net.ClientEntry;
|
|||||||
import eu.lixko.ts3j.client.net.ConnectionListener.ChatScope;
|
import eu.lixko.ts3j.client.net.ConnectionListener.ChatScope;
|
||||||
import eu.lixko.ts3j.client.net.OfflineMessage;
|
import eu.lixko.ts3j.client.net.OfflineMessage;
|
||||||
import eu.lixko.ts3j.client.net.PictureDownloads;
|
import eu.lixko.ts3j.client.net.PictureDownloads;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
|
||||||
import eu.lixko.ts3j.client.net.avatar.Avatar;
|
import eu.lixko.ts3j.client.net.avatar.Avatar;
|
||||||
import eu.lixko.ts3j.client.session.ServerSession;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
import eu.lixko.ts3j.client.sound.SoundNotifier;
|
import eu.lixko.ts3j.client.sound.SoundNotifier;
|
||||||
@@ -38,7 +37,6 @@ final class ServerTab {
|
|||||||
|
|
||||||
private final ServerSession session;
|
private final ServerSession session;
|
||||||
private final ContactStore contacts;
|
private final ContactStore contacts;
|
||||||
private final TeamspeakConnection conn;
|
|
||||||
private final GroupIcons groupIcons;
|
private final GroupIcons groupIcons;
|
||||||
private final ServerTabTreeActions treeActions;
|
private final ServerTabTreeActions treeActions;
|
||||||
private final ServerTreePanel treePanel;
|
private final ServerTreePanel treePanel;
|
||||||
@@ -72,13 +70,12 @@ final class ServerTab {
|
|||||||
// everything is built. Nothing fires callbacks before then.
|
// everything is built. Nothing fires callbacks before then.
|
||||||
ServerTabConnectionEvents events = new ServerTabConnectionEvents(host, this, settings);
|
ServerTabConnectionEvents events = new ServerTabConnectionEvents(host, this, settings);
|
||||||
this.session = new ServerSession(settings, identities, audio, sounds, contacts, events);
|
this.session = new ServerSession(settings, identities, audio, sounds, contacts, events);
|
||||||
this.conn = session.connection();
|
|
||||||
session.setAutoReconnect(true);
|
session.setAutoReconnect(true);
|
||||||
this.conn.setMyTeamSpeakLogin(host.myTeamSpeakLogin());
|
session.setMyTeamSpeakLogin(host.myTeamSpeakLogin());
|
||||||
this.groupIcons = new GroupIcons(conn.getIcons());
|
this.groupIcons = new GroupIcons(session.icons());
|
||||||
this.chatPanel = new ChatPanel(host.chatZoom(), settings, pictures, conn::serverUniqueId);
|
this.chatPanel = new ChatPanel(host.chatZoom(), settings, pictures, session::serverUniqueId);
|
||||||
this.treeActions = new ServerTabTreeActions(host, this, conn, chatPanel, infoPanel, groupIcons);
|
this.treeActions = new ServerTabTreeActions(host, this, session, chatPanel, infoPanel, groupIcons);
|
||||||
this.treePanel = new ServerTreePanel(conn.getModel(), groupIcons, contacts, settings, treeActions);
|
this.treePanel = new ServerTreePanel(session.model(), groupIcons, contacts, settings, treeActions);
|
||||||
treeActions.attach(treePanel);
|
treeActions.attach(treePanel);
|
||||||
events.attach(session, treePanel, chatPanel, treeActions);
|
events.attach(session, treePanel, chatPanel, treeActions);
|
||||||
|
|
||||||
@@ -120,7 +117,7 @@ final class ServerTab {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.avatar = new AvatarActions(host, conn);
|
this.avatar = new AvatarActions(host, session);
|
||||||
infoPanel.setAvatarHandler(new InfoPanel.AvatarHandler() {
|
infoPanel.setAvatarHandler(new InfoPanel.AvatarHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void steal(Avatar other) {
|
public void steal(Avatar other) {
|
||||||
@@ -176,10 +173,6 @@ final class ServerTab {
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamspeakConnection connection() {
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatPanel chat() {
|
ChatPanel chat() {
|
||||||
return chatPanel;
|
return chatPanel;
|
||||||
}
|
}
|
||||||
@@ -188,7 +181,7 @@ final class ServerTab {
|
|||||||
void showBanList(BanReasonPresets presets) {
|
void showBanList(BanReasonPresets presets) {
|
||||||
if (!session.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
if (banList == null || !banList.isDisplayable()) {
|
if (banList == null || !banList.isDisplayable()) {
|
||||||
banList = new BanListDialog(host, conn, settings, presets);
|
banList = new BanListDialog(host, session, settings, presets);
|
||||||
}
|
}
|
||||||
banList.setVisible(true);
|
banList.setVisible(true);
|
||||||
banList.toFront();
|
banList.toFront();
|
||||||
@@ -198,7 +191,7 @@ final class ServerTab {
|
|||||||
void showComplaints() {
|
void showComplaints() {
|
||||||
if (!session.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
if (complaints == null || !complaints.isDisplayable()) {
|
if (complaints == null || !complaints.isDisplayable()) {
|
||||||
complaints = new ComplaintsDialog(host, conn, treeActions::banClient);
|
complaints = new ComplaintsDialog(host, session, treeActions::banClient);
|
||||||
}
|
}
|
||||||
complaints.setVisible(true);
|
complaints.setVisible(true);
|
||||||
complaints.toFront();
|
complaints.toFront();
|
||||||
@@ -208,7 +201,7 @@ final class ServerTab {
|
|||||||
void showServerLog() {
|
void showServerLog() {
|
||||||
if (!session.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
if (serverLog == null || !serverLog.isDisplayable()) {
|
if (serverLog == null || !serverLog.isDisplayable()) {
|
||||||
serverLog = new ServerLogDialog(host, conn, settings);
|
serverLog = new ServerLogDialog(host, session, settings);
|
||||||
}
|
}
|
||||||
serverLog.setVisible(true);
|
serverLog.setVisible(true);
|
||||||
serverLog.toFront();
|
serverLog.toFront();
|
||||||
@@ -218,7 +211,7 @@ final class ServerTab {
|
|||||||
void showOfflineMessages() {
|
void showOfflineMessages() {
|
||||||
if (!session.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
if (offlineMessages == null || !offlineMessages.isDisplayable()) {
|
if (offlineMessages == null || !offlineMessages.isDisplayable()) {
|
||||||
offlineMessages = new OfflineMessagesDialog(host, conn, new OfflineMessagesDialog.Composer() {
|
offlineMessages = new OfflineMessagesDialog(host, session, new OfflineMessagesDialog.Composer() {
|
||||||
@Override
|
@Override
|
||||||
public void compose() {
|
public void compose() {
|
||||||
composeOfflineMessage();
|
composeOfflineMessage();
|
||||||
@@ -227,7 +220,7 @@ final class ServerTab {
|
|||||||
@Override
|
@Override
|
||||||
public void reply(OfflineMessage message, String body) {
|
public void reply(OfflineMessage message, String body) {
|
||||||
if (!session.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
OfflineMessageComposeDialog.reply(offlineMessages, conn.offlineMessages(), contacts, message, body).setVisible(true);
|
OfflineMessageComposeDialog.reply(offlineMessages, session.offlineMessages(), contacts, message, body).setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -238,7 +231,7 @@ final class ServerTab {
|
|||||||
void composeOfflineMessage() {
|
void composeOfflineMessage() {
|
||||||
if (!session.permissions().canSendOfflineMessages()) return;
|
if (!session.permissions().canSendOfflineMessages()) return;
|
||||||
Window owner = offlineMessages != null && offlineMessages.isShowing() ? offlineMessages : host;
|
Window owner = offlineMessages != null && offlineMessages.isShowing() ? offlineMessages : host;
|
||||||
OfflineMessageComposeDialog.compose(owner, conn.offlineMessages(), contacts).setVisible(true);
|
OfflineMessageComposeDialog.compose(owner, session.offlineMessages(), contacts).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** New mail refreshes an open inbox; a message being read does not need to. */
|
/** New mail refreshes an open inbox; a message being read does not need to. */
|
||||||
@@ -254,7 +247,7 @@ final class ServerTab {
|
|||||||
String key = (String) JOptionPane.showInputDialog(host, "Privilege Key:", "Use Privilege Key",
|
String key = (String) JOptionPane.showInputDialog(host, "Privilege Key:", "Use Privilege Key",
|
||||||
JOptionPane.PLAIN_MESSAGE, Icons.of("TOKEN_USE"), null, null);
|
JOptionPane.PLAIN_MESSAGE, Icons.of("TOKEN_USE"), null, null);
|
||||||
if (key == null || key.isBlank()) return;
|
if (key == null || key.isBlank()) return;
|
||||||
Edt.onFailure(conn.privilegeKeys().use(key.trim()), failure -> JOptionPane.showMessageDialog(host,
|
Edt.onFailure(session.privilegeKeys().use(key.trim()), failure -> JOptionPane.showMessageDialog(host,
|
||||||
failure.getMessage(), "Error using Privilege Key", JOptionPane.ERROR_MESSAGE));
|
failure.getMessage(), "Error using Privilege Key", JOptionPane.ERROR_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +255,7 @@ final class ServerTab {
|
|||||||
void showPrivilegeKeys() {
|
void showPrivilegeKeys() {
|
||||||
if (!session.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
if (privilegeKeys == null || !privilegeKeys.isDisplayable()) {
|
if (privilegeKeys == null || !privilegeKeys.isDisplayable()) {
|
||||||
privilegeKeys = new PrivilegeKeysDialog(host, conn, groupIcons);
|
privilegeKeys = new PrivilegeKeysDialog(host, session, groupIcons);
|
||||||
}
|
}
|
||||||
privilegeKeys.setVisible(true);
|
privilegeKeys.setVisible(true);
|
||||||
privilegeKeys.toFront();
|
privilegeKeys.toFront();
|
||||||
@@ -295,7 +288,7 @@ final class ServerTab {
|
|||||||
|
|
||||||
/** The contact list changed: names, colours and per-client playback follow. */
|
/** The contact list changed: names, colours and per-client playback follow. */
|
||||||
void contactsChanged() {
|
void contactsChanged() {
|
||||||
conn.applyContacts();
|
session.contacts().applyAll();
|
||||||
treePanel.refreshRowSizes();
|
treePanel.refreshRowSizes();
|
||||||
treeActions.renderInfo();
|
treeActions.renderInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-7
@@ -2,7 +2,6 @@ package eu.lixko.ts3j.client.ui;
|
|||||||
|
|
||||||
import eu.lixko.ts3j.client.config.Settings;
|
import eu.lixko.ts3j.client.config.Settings;
|
||||||
import eu.lixko.ts3j.client.net.ChannelNode;
|
import eu.lixko.ts3j.client.net.ChannelNode;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
|
||||||
import eu.lixko.ts3j.client.session.ServerSession;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
@@ -27,7 +26,6 @@ final class ServerTabConnectionEvents implements ServerSession.Listener {
|
|||||||
private final AtomicBoolean modelChangePending = new AtomicBoolean();
|
private final AtomicBoolean modelChangePending = new AtomicBoolean();
|
||||||
|
|
||||||
private ServerSession session;
|
private ServerSession session;
|
||||||
private TeamspeakConnection conn;
|
|
||||||
private ServerTreePanel treePanel;
|
private ServerTreePanel treePanel;
|
||||||
private ChatPanel chatPanel;
|
private ChatPanel chatPanel;
|
||||||
private ServerTabTreeActions treeActions;
|
private ServerTabTreeActions treeActions;
|
||||||
@@ -41,7 +39,6 @@ final class ServerTabConnectionEvents implements ServerSession.Listener {
|
|||||||
void attach(ServerSession session, ServerTreePanel treePanel, ChatPanel chatPanel,
|
void attach(ServerSession session, ServerTreePanel treePanel, ChatPanel chatPanel,
|
||||||
ServerTabTreeActions treeActions) {
|
ServerTabTreeActions treeActions) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.conn = session.connection();
|
|
||||||
this.treePanel = treePanel;
|
this.treePanel = treePanel;
|
||||||
this.chatPanel = chatPanel;
|
this.chatPanel = chatPanel;
|
||||||
this.treeActions = treeActions;
|
this.treeActions = treeActions;
|
||||||
@@ -63,7 +60,7 @@ final class ServerTabConnectionEvents implements ServerSession.Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void onOwnChat(ChatScope scope, int peerClientId, String peerName, String text) {
|
public void onOwnChat(ChatScope scope, int peerClientId, String peerName, String text) {
|
||||||
String me = settings.nickname + " (you)";
|
String me = settings.nickname + " (you)";
|
||||||
int myId = conn.getSelfClientId();
|
int myId = session.selfClientId();
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
switch (scope) {
|
switch (scope) {
|
||||||
case SERVER -> chatPanel.appendServerMessage(myId, me, text);
|
case SERVER -> chatPanel.appendServerMessage(myId, me, text);
|
||||||
@@ -89,7 +86,7 @@ final class ServerTabConnectionEvents implements ServerSession.Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void onConnected() {
|
public void onConnected() {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
treePanel.setSelfClientId(conn.getSelfClientId());
|
treePanel.setSelfClientId(session.selfClientId());
|
||||||
chatPanel.setInputEnabled(true);
|
chatPanel.setInputEnabled(true);
|
||||||
host.tabConnected(tab);
|
host.tabConnected(tab);
|
||||||
});
|
});
|
||||||
@@ -122,7 +119,7 @@ final class ServerTabConnectionEvents implements ServerSession.Listener {
|
|||||||
host.refreshHostButton(tab);
|
host.refreshHostButton(tab);
|
||||||
if (session.isConnected()) {
|
if (session.isConnected()) {
|
||||||
ChannelNode channel = session.currentChannel();
|
ChannelNode channel = session.currentChannel();
|
||||||
chatPanel.setServerName(conn.getModel().getServerName());
|
chatPanel.setServerName(session.model().getServerName());
|
||||||
chatPanel.setChannelName(channel == null ? null : channel.name);
|
chatPanel.setChannelName(channel == null ? null : channel.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -178,7 +175,7 @@ final class ServerTabConnectionEvents implements ServerSession.Listener {
|
|||||||
public void onTalkStateChanged(int clientId, boolean talking) {
|
public void onTalkStateChanged(int clientId, boolean talking) {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
treePanel.refreshVisual();
|
treePanel.refreshVisual();
|
||||||
if (clientId == conn.getSelfClientId()) host.selfStateChanged(tab);
|
if (clientId == session.selfClientId()) host.selfStateChanged(tab);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ package eu.lixko.ts3j.client.ui;
|
|||||||
|
|
||||||
import eu.lixko.ts3j.client.audio.VoiceOutput;
|
import eu.lixko.ts3j.client.audio.VoiceOutput;
|
||||||
import eu.lixko.ts3j.client.contacts.ContactType;
|
import eu.lixko.ts3j.client.contacts.ContactType;
|
||||||
|
import eu.lixko.ts3j.client.net.ClientAdmin;
|
||||||
import eu.lixko.ts3j.client.net.ChannelNode;
|
import eu.lixko.ts3j.client.net.ChannelNode;
|
||||||
import eu.lixko.ts3j.client.net.Spacers;
|
import eu.lixko.ts3j.client.net.Spacers;
|
||||||
import eu.lixko.ts3j.client.net.ChannelSettings;
|
import eu.lixko.ts3j.client.net.ChannelSettings;
|
||||||
import eu.lixko.ts3j.client.net.ClientEntry;
|
import eu.lixko.ts3j.client.net.ClientEntry;
|
||||||
import eu.lixko.ts3j.client.net.ComplaintAdmin;
|
import eu.lixko.ts3j.client.net.ComplaintAdmin;
|
||||||
import eu.lixko.ts3j.client.net.Group;
|
import eu.lixko.ts3j.client.net.Group;
|
||||||
import eu.lixko.ts3j.client.net.TeamspeakConnection;
|
import eu.lixko.ts3j.client.session.ServerSession;
|
||||||
import eu.lixko.ts3j.client.text.TsLink;
|
import eu.lixko.ts3j.client.text.TsLink;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
@@ -29,7 +30,7 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
|
|
||||||
private final MainFrame host;
|
private final MainFrame host;
|
||||||
private final ServerTab tab;
|
private final ServerTab tab;
|
||||||
private final TeamspeakConnection conn;
|
private final ServerSession session;
|
||||||
private final ChatPanel chatPanel;
|
private final ChatPanel chatPanel;
|
||||||
private final InfoPanel infoPanel;
|
private final InfoPanel infoPanel;
|
||||||
private final GroupIcons groupIcons;
|
private final GroupIcons groupIcons;
|
||||||
@@ -39,11 +40,11 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
/** The one open {@link ServerGroupsDialog}, if any, refreshed whenever the model changes. */
|
/** The one open {@link ServerGroupsDialog}, if any, refreshed whenever the model changes. */
|
||||||
private ServerGroupsDialog groupsDialog;
|
private ServerGroupsDialog groupsDialog;
|
||||||
|
|
||||||
ServerTabTreeActions(MainFrame host, ServerTab tab, TeamspeakConnection conn,
|
ServerTabTreeActions(MainFrame host, ServerTab tab, ServerSession session,
|
||||||
ChatPanel chatPanel, InfoPanel infoPanel, GroupIcons groupIcons) {
|
ChatPanel chatPanel, InfoPanel infoPanel, GroupIcons groupIcons) {
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.tab = tab;
|
this.tab = tab;
|
||||||
this.conn = conn;
|
this.session = session;
|
||||||
this.chatPanel = chatPanel;
|
this.chatPanel = chatPanel;
|
||||||
this.infoPanel = infoPanel;
|
this.infoPanel = infoPanel;
|
||||||
this.groupIcons = groupIcons;
|
this.groupIcons = groupIcons;
|
||||||
@@ -65,11 +66,11 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
infoPanel.showChannel((ChannelNode) sel);
|
infoPanel.showChannel((ChannelNode) sel);
|
||||||
} else if (sel instanceof ClientEntry) {
|
} else if (sel instanceof ClientEntry) {
|
||||||
ClientEntry client = (ClientEntry) sel;
|
ClientEntry client = (ClientEntry) sel;
|
||||||
infoPanel.showClient(client, conn.getModel(), conn.getIcons(),
|
infoPanel.showClient(client, session.model(), session.icons(),
|
||||||
conn.getContacts().find(client.uniqueId), conn.avatarOf(client));
|
session.contacts().store().find(client.uniqueId), session.avatarOf(client));
|
||||||
} else if (sel instanceof String && conn.isConnected()) {
|
} else if (sel instanceof String && session.isConnected()) {
|
||||||
// The root row is the server itself, whose user object is just its name.
|
// The root row is the server itself, whose user object is just its name.
|
||||||
infoPanel.showServer(conn.getModel(), conn.getServerHost() + ":" + conn.getServerPort());
|
infoPanel.showServer(session.model(), session.address() + ":" + session.port());
|
||||||
} else {
|
} else {
|
||||||
infoPanel.clear();
|
infoPanel.clear();
|
||||||
}
|
}
|
||||||
@@ -83,25 +84,25 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
|
|
||||||
/** A client link in the chat log was clicked: show the same menu as the tree does. */
|
/** A client link in the chat log was clicked: show the same menu as the tree does. */
|
||||||
void handleClientLink(TsLink.Ref ref, Component source, int x, int y) {
|
void handleClientLink(TsLink.Ref ref, Component source, int x, int y) {
|
||||||
ClientEntry client = conn.getModel().getClient(ref.id);
|
ClientEntry client = session.model().getClient(ref.id);
|
||||||
// The id is only valid for the session the link was made in; fall back to
|
// The id is only valid for the session the link was made in; fall back to
|
||||||
// the unique id (and finally the nickname) so older links still resolve.
|
// the unique id (and finally the nickname) so older links still resolve.
|
||||||
if (client == null || (!ref.uniqueId.isEmpty() && !ref.uniqueId.equals(client.uniqueId))) {
|
if (client == null || (!ref.uniqueId.isEmpty() && !ref.uniqueId.equals(client.uniqueId))) {
|
||||||
ClientEntry byUid = ref.uniqueId.isEmpty() ? null
|
ClientEntry byUid = ref.uniqueId.isEmpty() ? null
|
||||||
: conn.getModel().findClientByUniqueId(ref.uniqueId);
|
: session.model().findClientByUniqueId(ref.uniqueId);
|
||||||
if (byUid == null && !ref.name.isEmpty()) byUid = conn.getModel().findClientByName(ref.name);
|
if (byUid == null && !ref.name.isEmpty()) byUid = session.model().findClientByName(ref.name);
|
||||||
if (byUid != null) client = byUid;
|
if (byUid != null) client = byUid;
|
||||||
}
|
}
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
chatPanel.appendSystem("That client is no longer on the server.");
|
chatPanel.appendSystem("That client is no longer on the server.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ClientMenu.build(client, client.id == conn.getSelfClientId(), false, conn.getModel(), groupIcons, this)
|
ClientMenu.build(client, client.id == session.selfClientId(), false, session.model(), groupIcons, this)
|
||||||
.show(source, x, y);
|
.show(source, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleChannelLink(TsLink.Ref ref, Component source, int x, int y) {
|
void handleChannelLink(TsLink.Ref ref, Component source, int x, int y) {
|
||||||
ChannelNode channel = conn.getModel().getChannel(ref.id);
|
ChannelNode channel = session.model().getChannel(ref.id);
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
chatPanel.appendSystem("That channel no longer exists.");
|
chatPanel.appendSystem("That channel no longer exists.");
|
||||||
return;
|
return;
|
||||||
@@ -113,57 +114,57 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void joinChannel(int channelId) {
|
public void joinChannel(int channelId) {
|
||||||
if (conn.isConnected()) conn.joinChannel(channelId, null);
|
if (session.isConnected()) session.channels().join(channelId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveClientsToChannel(List<ClientEntry> clients, ChannelNode target) {
|
public void moveClientsToChannel(List<ClientEntry> clients, ChannelNode target) {
|
||||||
if (conn.isConnected()) conn.moveClients(ids(clients), target.id);
|
if (session.isConnected()) session.clients().move(ids(clients), target.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveChannel(ChannelNode channel, int newParentId, int orderPredecessorId) {
|
public void moveChannel(ChannelNode channel, int newParentId, int orderPredecessorId) {
|
||||||
if (conn.isConnected()) conn.moveChannel(channel.id, newParentId, orderPredecessorId);
|
if (session.isConnected()) session.channels().move(channel.id, newParentId, orderPredecessorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openPrivateChat(ClientEntry client) {
|
public void openPrivateChat(ClientEntry client) {
|
||||||
chatPanel.openPrivateChat(client.id, client.uniqueId, conn.displayName(client));
|
chatPanel.openPrivateChat(client.id, client.uniqueId, session.contacts().displayName(client));
|
||||||
conn.loadPrivateChatHistory(client.id, client.uniqueId);
|
session.loadPrivateChatHistory(client.id, client.uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pokeClient(ClientEntry client) {
|
public void pokeClient(ClientEntry client) {
|
||||||
String msg = JOptionPane.showInputDialog(host, "Poke message for " + client.nickname + ":", "Poke!");
|
String msg = JOptionPane.showInputDialog(host, "Poke message for " + client.nickname + ":", "Poke!");
|
||||||
if (msg != null) conn.poke(client.id, msg);
|
if (msg != null) session.clients().poke(client.id, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void complainAboutClient(ClientEntry client) {
|
public void complainAboutClient(ClientEntry client) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
String reason = ReasonDialog.prompt(host, "Make a Complaint", "Enter the reason for your complaint:",
|
String reason = ReasonDialog.prompt(host, "Make a Complaint", "Enter the reason for your complaint:",
|
||||||
ComplaintAdmin.REASON_LIMIT);
|
ComplaintAdmin.REASON_LIMIT);
|
||||||
if (reason != null) conn.complaints().complain(client, reason);
|
if (reason != null) session.complaints().complain(client, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void kickClientsFromChannel(List<ClientEntry> clients) {
|
public void kickClientsFromChannel(List<ClientEntry> clients) {
|
||||||
String reason = kickReason("Channel", clients);
|
String reason = kickReason("Channel", clients);
|
||||||
if (reason != null) conn.kickFromChannel(ids(clients), reason);
|
if (reason != null) session.clients().kickFromChannel(ids(clients), reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void kickClientsFromServer(List<ClientEntry> clients) {
|
public void kickClientsFromServer(List<ClientEntry> clients) {
|
||||||
String reason = kickReason("Server", clients);
|
String reason = kickReason("Server", clients);
|
||||||
if (reason != null) conn.kickFromServer(ids(clients), reason);
|
if (reason != null) session.clients().kickFromServer(ids(clients), reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String kickReason(String from, List<ClientEntry> clients) {
|
private String kickReason(String from, List<ClientEntry> clients) {
|
||||||
if (!conn.isConnected()) return null;
|
if (!session.isConnected()) return null;
|
||||||
boolean one = clients.size() == 1;
|
boolean one = clients.size() == 1;
|
||||||
String whom = one ? clients.get(0).nickname : clients.size() + " clients";
|
String whom = one ? clients.get(0).nickname : clients.size() + " clients";
|
||||||
return ReasonDialog.prompt(host, "Kick " + (one ? "Client" : "Clients") + " from " + from,
|
return ReasonDialog.prompt(host, "Kick " + (one ? "Client" : "Clients") + " from " + from,
|
||||||
"Reason for kicking " + whom + ":", TeamspeakConnection.KICK_REASON_LIMIT);
|
"Reason for kicking " + whom + ":", ClientAdmin.KICK_REASON_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Integer> ids(List<ClientEntry> clients) {
|
private static List<Integer> ids(List<ClientEntry> clients) {
|
||||||
@@ -174,16 +175,16 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void banClient(ClientEntry client) {
|
public void banClient(ClientEntry client) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
BanDialog dialog = new BanDialog(host, client.nickname,
|
BanDialog dialog = new BanDialog(host, client.nickname,
|
||||||
conn.getModel().permissions().maxBanSeconds());
|
session.model().permissions().maxBanSeconds());
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
if (dialog.isConfirmed()) conn.banClient(client.id, dialog.getSeconds(), dialog.getReason());
|
if (dialog.isConfirmed()) session.clients().ban(client.id, dialog.getSeconds(), dialog.getReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggleClientMute(ClientEntry client) {
|
public void toggleClientMute(ClientEntry client) {
|
||||||
VoiceOutput playback = conn.ownClient().playback();
|
VoiceOutput playback = session.playback();
|
||||||
if (playback != null) playback.setClientMuted(client.id, !playback.isClientMuted(client.id));
|
if (playback != null) playback.setClientMuted(client.id, !playback.isClientMuted(client.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,31 +196,31 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showConnectionInfo(ClientEntry client) {
|
public void showConnectionInfo(ClientEntry client) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
new ConnectionInfoDialog(host, conn, client.id, client.nickname).setVisible(true);
|
new ConnectionInfoDialog(host, session, client.id, client.nickname).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveClientsToOwnChannel(List<ClientEntry> clients) {
|
public void moveClientsToOwnChannel(List<ClientEntry> clients) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
ClientEntry self = conn.getModel().getClient(conn.getSelfClientId());
|
ClientEntry self = session.model().getClient(session.selfClientId());
|
||||||
if (self != null) conn.moveClients(ids(clients), self.channelId);
|
if (self != null) session.clients().move(ids(clients), self.channelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setClientServerGroup(ClientEntry client, Group group, boolean assign) {
|
public void setClientServerGroup(ClientEntry client, Group group, boolean assign) {
|
||||||
if (conn.isConnected()) conn.setClientServerGroup(client.databaseId, group.id, assign);
|
if (session.isConnected()) session.clients().setServerGroup(client.databaseId, group.id, assign);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setClientChannelGroup(ClientEntry client, Group group) {
|
public void setClientChannelGroup(ClientEntry client, Group group) {
|
||||||
if (conn.isConnected()) conn.setClientChannelGroup(client.databaseId, client.channelId, group.id);
|
if (session.isConnected()) session.clients().setChannelGroup(client.databaseId, client.channelId, group.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showServerGroupsDialog(ClientEntry client) {
|
public void showServerGroupsDialog(ClientEntry client) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
groupsDialog = new ServerGroupsDialog(host, conn, groupIcons, client, this);
|
groupsDialog = new ServerGroupsDialog(host, session, groupIcons, client, this);
|
||||||
groupsDialog.setVisible(true);
|
groupsDialog.setVisible(true);
|
||||||
groupsDialog = null;
|
groupsDialog = null;
|
||||||
}
|
}
|
||||||
@@ -230,17 +231,17 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canDeleteOtherAvatars() {
|
public boolean canDeleteOtherAvatars() {
|
||||||
return tab.session().permissions().canDeleteOtherAvatars();
|
return session.permissions().canDeleteOtherAvatars();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canGrantTalkPower() {
|
public boolean canGrantTalkPower() {
|
||||||
return tab.session().permissions().canGrantTalkPower();
|
return session.permissions().canGrantTalkPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTalker(List<ClientEntry> clients, boolean talker) {
|
public void setTalker(List<ClientEntry> clients, boolean talker) {
|
||||||
conn.setTalker(ids(clients), talker);
|
session.clients().setTalker(ids(clients), talker);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -250,13 +251,13 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeClientDescription(ClientEntry client) {
|
public void changeClientDescription(ClientEntry client) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
Edt.handle(conn.requestClientDescription(client.id), description -> {
|
Edt.handle(session.clients().description(client.id), description -> {
|
||||||
String edited = (String) JOptionPane.showInputDialog(host,
|
String edited = (String) JOptionPane.showInputDialog(host,
|
||||||
"Description for " + client.nickname + ":", "Change Description",
|
"Description for " + client.nickname + ":", "Change Description",
|
||||||
JOptionPane.PLAIN_MESSAGE, Icons.of("EDIT"), null, description);
|
JOptionPane.PLAIN_MESSAGE, Icons.of("EDIT"), null, description);
|
||||||
if (edited == null || edited.equals(description)) return;
|
if (edited == null || edited.equals(description)) return;
|
||||||
Edt.onFailure(conn.setClientDescription(client.id, edited), failure -> JOptionPane.showMessageDialog(host,
|
Edt.onFailure(session.clients().setDescription(client.id, edited), failure -> JOptionPane.showMessageDialog(host,
|
||||||
"Could not change the description: " + failure.getMessage(), "Error", JOptionPane.ERROR_MESSAGE));
|
"Could not change the description: " + failure.getMessage(), "Error", JOptionPane.ERROR_MESSAGE));
|
||||||
}, failure -> JOptionPane.showMessageDialog(host, "Could not read the description: " + failure.getMessage(),
|
}, failure -> JOptionPane.showMessageDialog(host, "Could not read the description: " + failure.getMessage(),
|
||||||
"Error", JOptionPane.ERROR_MESSAGE));
|
"Error", JOptionPane.ERROR_MESSAGE));
|
||||||
@@ -264,7 +265,7 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addContact(ClientEntry client, ContactType type) {
|
public void addContact(ClientEntry client, ContactType type) {
|
||||||
conn.getContacts().add(client.uniqueId, client.nickname, type, host.settings().contactDefaults);
|
session.contacts().store().add(client.uniqueId, client.nickname, type, host.settings().contactDefaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -274,18 +275,18 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeContact(ClientEntry client) {
|
public void removeContact(ClientEntry client) {
|
||||||
conn.getContacts().remove(client.uniqueId);
|
session.contacts().store().remove(client.uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContactType contactTypeOf(ClientEntry client) {
|
public ContactType contactTypeOf(ClientEntry client) {
|
||||||
return conn.getContacts().typeOf(client.uniqueId);
|
return session.contacts().store().typeOf(client.uniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeClientVolume(ClientEntry client) {
|
public void changeClientVolume(ClientEntry client) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
new ClientVolumeDialog(host, conn, client).setVisible(true);
|
new ClientVolumeDialog(host, session.contacts(), client).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -295,18 +296,18 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setChannelSubscribed(ChannelNode channel, boolean family, boolean subscribed) {
|
public void setChannelSubscribed(ChannelNode channel, boolean family, boolean subscribed) {
|
||||||
if (conn.isConnected()) conn.setChannelsSubscribed(channel.familyIds(family), subscribed);
|
if (session.isConnected()) session.channels().setSubscribed(channel.familyIds(family), subscribed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void editChannel(ChannelNode channel) {
|
public void editChannel(ChannelNode channel) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
ChannelDialog.toEdit(host, conn, groupIcons, channel).setVisible(true);
|
ChannelDialog.toEdit(host, session, groupIcons, channel).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteChannel(ChannelNode channel) {
|
public void deleteChannel(ChannelNode channel) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
// Like TeamSpeak, a channel that is not empty takes its sub-channels along and sends its clients away.
|
// Like TeamSpeak, a channel that is not empty takes its sub-channels along and sends its clients away.
|
||||||
boolean occupied = !channel.children.isEmpty() || !channel.clients.isEmpty();
|
boolean occupied = !channel.children.isEmpty() || !channel.clients.isEmpty();
|
||||||
String question = "Delete channel \"" + channel.name + "\""
|
String question = "Delete channel \"" + channel.name + "\""
|
||||||
@@ -315,50 +316,50 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
|
JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Edt.onFailure(conn.channels().delete(channel.id, true), failure -> JOptionPane.showMessageDialog(host,
|
Edt.onFailure(session.channels().delete(channel.id, true), failure -> JOptionPane.showMessageDialog(host,
|
||||||
"Could not delete the channel: " + failure.getMessage(), "Error", JOptionPane.ERROR_MESSAGE));
|
"Could not delete the channel: " + failure.getMessage(), "Error", JOptionPane.ERROR_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createChannel(ChannelNode parent, ChannelSettings.Type type) {
|
public void createChannel(ChannelNode parent, ChannelSettings.Type type) {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
ChannelSettings defaults = new ChannelSettings();
|
ChannelSettings defaults = new ChannelSettings();
|
||||||
defaults.type = type;
|
defaults.type = type;
|
||||||
ChannelDialog.toCreate(host, conn, groupIcons,
|
ChannelDialog.toCreate(host, session, groupIcons,
|
||||||
parent == null ? "Create Channel" : "Create Sub-Channel of " + parent.name,
|
parent == null ? "Create Channel" : "Create Sub-Channel of " + parent.name,
|
||||||
parent == null ? 0 : parent.id, defaults).setVisible(true);
|
parent == null ? 0 : parent.id, defaults).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createSpacer() {
|
public void createSpacer() {
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
ChannelSettings defaults = new ChannelSettings();
|
ChannelSettings defaults = new ChannelSettings();
|
||||||
// Spacers are cosmetic root channels, so they outlive everyone and, being channels,
|
// Spacers are cosmetic root channels, so they outlive everyone and, being channels,
|
||||||
// need a name no other channel has — which is what the tag's number is for.
|
// need a name no other channel has — which is what the tag's number is for.
|
||||||
defaults.name = Spacers.freeName(conn.getModel().childrenOf(0));
|
defaults.name = Spacers.freeName(session.model().childrenOf(0));
|
||||||
ChannelDialog.toCreate(host, conn, groupIcons, "Create Spacer", 0, defaults)
|
ChannelDialog.toCreate(host, session, groupIcons, "Create Spacer", 0, defaults)
|
||||||
.setVisible(true);
|
.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return conn.isConnected();
|
return session.isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBrowseFiles() {
|
public boolean canBrowseFiles() {
|
||||||
return tab.session().permissions().canBrowseFiles();
|
return session.permissions().canBrowseFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void browseFiles(ChannelNode channel) {
|
public void browseFiles(ChannelNode channel) {
|
||||||
if (!conn.canTransferFiles()) return;
|
if (!session.files().isAvailable()) return;
|
||||||
new FileBrowserDialog(host, conn, channel).setVisible(true);
|
new FileBrowserDialog(host, session, channel).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClientLocallyMuted(int clientId) {
|
public boolean isClientLocallyMuted(int clientId) {
|
||||||
VoiceOutput playback = conn.ownClient().playback();
|
VoiceOutput playback = session.playback();
|
||||||
return playback != null && playback.isClientMuted(clientId);
|
return playback != null && playback.isClientMuted(clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,12 +367,12 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions {
|
|||||||
public void onSelectionChanged(Object userObject) {
|
public void onSelectionChanged(Object userObject) {
|
||||||
currentSelection = userObject;
|
currentSelection = userObject;
|
||||||
renderInfo();
|
renderInfo();
|
||||||
if (!conn.isConnected()) return;
|
if (!session.isConnected()) return;
|
||||||
if (userObject instanceof ChannelNode) {
|
if (userObject instanceof ChannelNode) {
|
||||||
ChannelNode ch = (ChannelNode) userObject;
|
ChannelNode ch = (ChannelNode) userObject;
|
||||||
if (!ch.descriptionLoaded) conn.requestChannelInfo(ch.id);
|
if (!ch.descriptionLoaded) session.channels().requestInfo(ch.id);
|
||||||
} else if (userObject instanceof ClientEntry) {
|
} else if (userObject instanceof ClientEntry) {
|
||||||
conn.requestClientInfo(((ClientEntry) userObject).id);
|
session.clients().requestInfo(((ClientEntry) userObject).id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user