ui: a password dialog for locked channels, and pokes with a message

Joining a locked channel sent no password, so the server refused it and
nothing said so; pokes always went out empty. Every join (a double-click
in the tree, joining a friend) now goes through App::join_channel: a
locked channel asks for its password first (join_password), which is
kept for the session until voice disconnects, and it is used when
connecting into the channel too. Event::JoinFailed asks again under
"Wrong password", or says the channel is full or why the server refused.
Without voice, a double-click connects into the channel, as joining a
friend did.

Connecting into a channel names it by id (`/<cid>`): by name the server
finds only a top-level channel, so a subchannel's name connected into
the default channel. A wrong password when connecting also puts us into
the default channel without a word, so the channel is joined again once
it shows in the presence (after_connect), and that move asks again.
Both seen on the dev TS3 and TS6 servers.

Poking opens a dialog with an optional message, its length counted up
to 100 characters; the UI trims and cuts it (poke_message), and the
engine cuts it on characters too. Both dev servers take 100 characters
of any width (400 bytes of emoji) and refuse 101 (seen through
ServerQuery). Dev switches channel-password[:wrong] and poke.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
This commit is contained in:
Claude committed 2026-10-06 17:46:43 +00:00
1 parent 7e43178e04
commit 42639fd206
18 files changed
+512 -63

No files matched your search

+6 -1
View File
@@ -99,6 +99,10 @@ pub use voice::VoiceOptions;
pub type SessionId = u64;
/// The longest poke message servers take, in characters; a longer one is
/// cut ([`Command::Poke`]).
pub const POKE_MESSAGE_MAX: usize = 100;
/// What the UI asks for.
#[derive(Clone, Debug)]
pub enum Command {
@@ -274,7 +278,8 @@ pub enum Command {
volume: f32,
},
/// Poke a client (voice): the server shows it a notification with
/// `message`. Failures come as [`Event::Error`].
/// `message`, cut to [`POKE_MESSAGE_MAX`] characters. Failures come as
/// [`Event::Error`].
Poke {
session: SessionId,
client: u16,
+29 -3
View File
@@ -33,7 +33,7 @@ use crate::cache;
use crate::files::{self, FileEntry, Report, RequestId, Sink, TransferId, TransferState};
use crate::offline::{OfflineMessage, OfflineMessageInfo};
use crate::settings::{FILES_PROGRESS_MS, SharedSettings};
use crate::{Event, JoinFailure, SessionId};
use crate::{Event, JoinFailure, POKE_MESSAGE_MAX, SessionId};
#[derive(Clone, Debug)]
pub struct VoiceOptions {
@@ -43,7 +43,7 @@ pub struct VoiceOptions {
/// Signed compatibility version; `None` selects the native platform's tuple.
pub client_version: Option<Version>,
pub server_password: Option<String>,
/// Channel path to join, e.g. `Lobby/Sub`.
/// Channel path to join, e.g. `Lobby/Sub`, or `/<id>`.
pub channel: Option<String>,
/// The password of `channel`.
pub channel_password: Option<String>,
@@ -889,7 +889,7 @@ impl Voice {
let cmd = c2s::OutClientPokeRequestMessage::new(&mut std::iter::once(
c2s::OutClientPokeRequestPart {
client_id: tsclientlib::ClientId(client),
message: message.as_str().into(),
message: poke_message(&message).into(),
},
));
self.send(cmd, Pending::Report("poke"))?;
@@ -1098,6 +1098,15 @@ fn join_failure(error: TsError) -> Option<JoinFailure> {
Some(JoinFailure::Other(text))
}
/// A poke's message as servers take it: its first [`POKE_MESSAGE_MAX`]
/// characters (not bytes, so a letter is never cut in half).
fn poke_message(message: &str) -> &str {
match message.char_indices().nth(POKE_MESSAGE_MAX) {
Some((end, _)) => &message[..end],
None => message,
}
}
/// A TeamSpeak error's name in lowercase words:
/// `ChannelIsPrivateChannel` is "channel is private channel".
fn error_words(error: TsError) -> String {
@@ -1145,6 +1154,23 @@ mod join_tests {
}
}
#[cfg(test)]
mod poke_tests {
use super::*;
#[test]
fn long_pokes_are_cut_by_characters() {
assert_eq!(poke_message("hi"), "hi");
assert_eq!(poke_message(""), "");
let exact = "x".repeat(POKE_MESSAGE_MAX);
assert_eq!(poke_message(&exact), exact);
// Two bytes each: cut after 100 letters, not 100 bytes.
let long = "ä".repeat(150);
assert_eq!(poke_message(&long), "ä".repeat(POKE_MESSAGE_MAX));
assert_eq!(poke_message(&"🙂".repeat(101)).chars().count(), POKE_MESSAGE_MAX);
}
}
#[cfg(test)]
mod image_download_tests {
use super::*;