Request, grant and revoke talk power
Core keeps client_is_talker, the request's time and reason, and each
channel's needed talk power; clientedit grants or revokes, and "grant
next" picks whoever in our channel asked first, optionally revoking the
rest. The server refuses a request or a grant ("invalid parameter") from
or for a client that can already talk, so both are offered only to those
short of talk power. Grants dropped without an invoker (leaving the
channel, the channel's need changing) are not announced. Verified on a
local 3.13.7 server.
Desktop: Grant/Revoke Talk Power in the client menu, also for several
selected clients; the tree's badges in TeamSpeak's order (granted or
insufficient ahead of the groups, a request after them); the request's
reason in the info panel; log lines; the three talk power hotkeys. The
Self menu's request item shows only while it is needed.
Android: grant/revoke among the client sheet's admin actions, request or
cancel on our own sheet, the same badges in the tree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -174,6 +174,10 @@ class ServerController internal constructor(
|
||||
|
||||
fun setAway(away: Boolean) = session.setAway(away, null)
|
||||
|
||||
/** Asks for talk power giving [reason], or withdraws the request with null. */
|
||||
fun setTalkRequest(reason: String?) =
|
||||
if (reason == null) session.cancelTalkRequest() else session.requestTalkPower(reason)
|
||||
|
||||
// ---- channels and clients ----
|
||||
|
||||
fun joinChannel(channelId: Int, password: String? = null) {
|
||||
@@ -291,6 +295,8 @@ class ServerController internal constructor(
|
||||
val canKickFromChannel: Boolean get() = session.canKickFromChannel()
|
||||
val canKickFromServer: Boolean get() = session.canKickFromServer()
|
||||
val canBanClients: Boolean get() = session.canBanClients()
|
||||
val canGrantTalkPower: Boolean get() = session.canGrantTalkPower()
|
||||
val canRequestTalkPower: Boolean get() = session.canRequestTalkPower()
|
||||
val canViewBanList: Boolean get() = session.canViewBanList()
|
||||
val canBrowseFiles: Boolean get() = session.canBrowseFiles()
|
||||
val canCreateBans: Boolean get() = session.isConnected && conn.model.permits("b_client_ban_create")
|
||||
@@ -306,6 +312,10 @@ class ServerController internal constructor(
|
||||
if (session.isConnected) conn.kickFromServer(clientIds, reason)
|
||||
}
|
||||
|
||||
fun setTalker(clientIds: Collection<Int>, talker: Boolean) {
|
||||
if (session.isConnected) conn.setTalker(clientIds, talker)
|
||||
}
|
||||
|
||||
/** Bans a client for [seconds], or for good with 0. */
|
||||
fun ban(clientId: Int, seconds: Long, reason: String) {
|
||||
if (session.isConnected) conn.banClient(clientId, seconds, reason)
|
||||
|
||||
@@ -138,6 +138,9 @@ data class ServerTree(
|
||||
country = c.country.orEmpty(),
|
||||
serverGroupIds = c.serverGroupIds.toList(),
|
||||
channelGroupId = c.channelGroupId,
|
||||
talker = c.talker,
|
||||
lacksTalkPower = model.lacksTalkPower(c),
|
||||
talkRequest = c.talkRequest,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -189,4 +192,10 @@ data class ClientItem(
|
||||
val country: String,
|
||||
val serverGroupIds: List<Int>,
|
||||
val channelGroupId: Int,
|
||||
/** Granted talk power. */
|
||||
val talker: Boolean,
|
||||
/** Short of the channel's needed talk power, so kept from talking. */
|
||||
val lacksTalkPower: Boolean,
|
||||
/** Waiting for talk power. */
|
||||
val talkRequest: Boolean,
|
||||
)
|
||||
|
||||
@@ -350,7 +350,11 @@ private fun ClientRow(
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
}
|
||||
// TeamSpeak's order: talk power ahead of the groups, a talk request after them.
|
||||
if (client.talker) PackIcon("IS_TALKER", "Talk power granted", size = ICON)
|
||||
else if (client.lacksTalkPower) PackIcon("INPUT_MUTED", "Insufficient talk power", size = ICON)
|
||||
for (id in client.groupIconIds) ServerIcon(id, size = ICON)
|
||||
if (client.talkRequest) PackIcon("TALK_POWER_REQUEST", "Talk power requested", size = ICON)
|
||||
// The country's flag comes last, at the row's edge.
|
||||
if (countryFlags) CountryFlag(client.country)
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ fun GroupsDialog(
|
||||
}
|
||||
|
||||
/**
|
||||
* The kicks, the ban and the groups of [client], as far as we may use them; [onDone] once one went out.
|
||||
* Talk power, the kicks, the ban and the groups of [client], as far as we may use them; [onDone] once one went out.
|
||||
* Null when there is none of them.
|
||||
*/
|
||||
@Composable
|
||||
@@ -193,11 +193,12 @@ fun clientModeration(server: ServerController, client: ClientItem, onDone: () ->
|
||||
val kickChannel = !client.self && server.canKickFromChannel
|
||||
val kickServer = !client.self && server.canKickFromServer
|
||||
val ban = !client.self && server.canBanClients
|
||||
val talker = server.canGrantTalkPower && (client.talker || client.lacksTalkPower)
|
||||
val showServerGroups = serverGroups.any { it.allowed() }
|
||||
val showChannelGroups = channelGroups.any { it.allowed() && !it.assigned() }
|
||||
if (!(kickChannel || kickServer || ban || showServerGroups || showChannelGroups)) return null
|
||||
if (!(talker || kickChannel || kickServer || ban || showServerGroups || showChannelGroups)) return null
|
||||
return {
|
||||
ClientModeration(server, client, serverGroups, channelGroups, kickChannel, kickServer, ban,
|
||||
ClientModeration(server, client, serverGroups, channelGroups, talker, kickChannel, kickServer, ban,
|
||||
showServerGroups, showChannelGroups, onDone)
|
||||
}
|
||||
}
|
||||
@@ -208,6 +209,7 @@ private fun ClientModeration(
|
||||
client: ClientItem,
|
||||
serverGroups: List<GroupChoice>,
|
||||
channelGroups: List<GroupChoice>,
|
||||
talker: Boolean,
|
||||
kickChannel: Boolean,
|
||||
kickServer: Boolean,
|
||||
ban: Boolean,
|
||||
@@ -219,6 +221,10 @@ private fun ClientModeration(
|
||||
var banning by remember { mutableStateOf(false) }
|
||||
var groups by remember { mutableStateOf<Boolean?>(null) }
|
||||
|
||||
if (talker) {
|
||||
if (client.talker) Action("TALK_POWER_REVOKE", "Revoke talk power") { server.setTalker(listOf(client.id), false); onDone() }
|
||||
else Action("TALK_POWER_GRANT", "Grant talk power") { server.setTalker(listOf(client.id), true); onDone() }
|
||||
}
|
||||
if (kickChannel) Action("KICK_FROM_CHANNEL", "Kick from channel") { kick = false }
|
||||
if (kickServer) Action("KICK_FROM_SERVER", "Kick from server") { kick = true }
|
||||
if (ban) Action("BAN_CLIENT", "Ban") { banning = true }
|
||||
|
||||
@@ -433,6 +433,9 @@ fun ServerScreen(
|
||||
onPoke = { server.poke(id, it); clientSheet = null },
|
||||
onVolume = { server.setClientVolume(id, it) },
|
||||
onAway = { server.setAway(it); clientSheet = null },
|
||||
onTalkRequest = if (client.self && (client.talkRequest || server.canRequestTalkPower)) {
|
||||
{ server.setTalkRequest(it); clientSheet = null }
|
||||
} else null,
|
||||
onAddContact = { server.addContact(id, it) },
|
||||
onEditContact = { clientSheet = null; onEditContact(client.uniqueId) },
|
||||
onConnectionInfo = { clientSheet = null; connectionInfo = id },
|
||||
|
||||
@@ -64,6 +64,8 @@ fun ClientSheet(
|
||||
onPoke: (String) -> Unit,
|
||||
onVolume: (Double) -> Unit,
|
||||
onAway: (Boolean) -> Unit,
|
||||
/** Asks for talk power with a reason, or withdraws the request with null; null when we may not ask. */
|
||||
onTalkRequest: ((String?) -> Unit)?,
|
||||
onAddContact: (ContactType) -> Unit,
|
||||
onEditContact: () -> Unit,
|
||||
onConnectionInfo: () -> Unit,
|
||||
@@ -80,6 +82,7 @@ fun ClientSheet(
|
||||
moderation: (@Composable () -> Unit)? = null,
|
||||
) {
|
||||
var poking by remember { mutableStateOf(false) }
|
||||
var requesting by remember { mutableStateOf(false) }
|
||||
val sheetState = rememberModalBottomSheetState()
|
||||
val scope = rememberCoroutineScope()
|
||||
// A half-open sheet would fold the admin actions out below the screen's edge.
|
||||
@@ -112,6 +115,10 @@ fun ClientSheet(
|
||||
onFindInTree?.let { Action("CHANNEL_SWITCH", "Find client in channel tree", onClick = it) }
|
||||
if (client.self) {
|
||||
Action("AWAY", if (away) "Back" else "Away") { onAway(!away) }
|
||||
onTalkRequest?.let { request ->
|
||||
if (client.talkRequest) Action("TALK_POWER_CANCEL_REQUEST", "Cancel talk power request") { request(null) }
|
||||
else Action("TALK_POWER_REQUEST", "Request talk power") { requesting = true }
|
||||
}
|
||||
moderation?.let { adminActions { it() } }
|
||||
} else {
|
||||
Action("PLAYER_CHAT", "Send message", onClick = onMessage)
|
||||
@@ -157,6 +164,15 @@ fun ClientSheet(
|
||||
onConfirm = { poking = false; onPoke(it) },
|
||||
)
|
||||
}
|
||||
if (requesting) {
|
||||
TextPrompt(
|
||||
title = "Request talk power",
|
||||
label = "Reason",
|
||||
confirm = "Request",
|
||||
onDismiss = { requesting = false },
|
||||
onConfirm = { requesting = false; onTalkRequest?.invoke(it.trim()) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** What can be done with a channel: join it, whether to hear who is in it, whisper to it, its files, and editing it. */
|
||||
|
||||
Reference in New Issue
Block a user