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

+9
View File
@@ -54,6 +54,8 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows
- zbus's warnings about desktop portal requests are left out of the logs.
- Pop-ups, menus and tooltips have a clearer edge, and the member card, the
emoji picker and the notifications panel dim the window behind them.
- Double-clicking a channel of a server without voice connects into it
(it said "not connected with voice").
### Fixed
@@ -66,6 +68,13 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows
are drawn as TeamSpeak draws them, like `[cspacer]` was, and chats, search
results, notifications and the other screens show a spacer's text instead
of its raw name.
- Locked channels ask for their password (kept until voice disconnects, and
asked again when it is wrong), and joining a full channel or one the
server refuses says why; joining did nothing before.
- Pokes can carry a message (up to 100 characters); they were always sent
empty.
- Joining a friend in a subchannel of a server without voice connects into
that subchannel; it connected into the default channel.
## [0.0.1-alpha] - 2026-10-04
+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::*;
+23 -2
View File
@@ -234,6 +234,11 @@ pub(crate) struct SessionView {
pub gateway_caps: Vec<String>,
/// The client whose member card is open.
pub member_card: Option<u16>,
/// Passwords given for locked channels, until voice disconnects.
pub channel_passwords: HashMap<ChannelId, String>,
/// The channel a voice connection was asked into, until it is joined
/// or joined again (`App::join_after_connect`).
pub join_after_connect: Option<ChannelId>,
/// Viewers of the streams in the gateway's directory, by stream id.
pub stream_viewers: HashMap<String, u32>,
/// Downloads started from chat, by transfer id.
@@ -266,6 +271,8 @@ impl Default for SessionView {
channel_groups: Vec::new(),
gateway_caps: Vec::new(),
member_card: None,
channel_passwords: HashMap::new(),
join_after_connect: None,
stream_viewers: HashMap::new(),
downloads: HashMap::new(),
next_transfer: 1,
@@ -454,6 +461,10 @@ pub(crate) struct App {
pub contacts: HashMap<String, voelin_core::Contact>,
/// The client in the volume dialog: session, client id, unique id.
pub playback_dialog: Option<(i64, u16, Option<String>)>,
/// The locked channel the password dialog is for: session, channel.
pub join_target: Option<(i64, ChannelId)>,
/// Who the poke dialog pokes: session, client, nickname.
pub poke_target: Option<(i64, u16, String)>,
pub mic_test: bool,
pub ptt: GlobalPtt,
pub video: Video,
@@ -695,6 +706,8 @@ pub fn run(options: RunOptions) -> Result<()> {
playback,
contacts: HashMap::new(),
playback_dialog: None,
join_target: None,
poke_target: None,
mic_test: false,
ptt,
video,
@@ -902,6 +915,11 @@ impl App {
if state.voice != VoiceState::Connected {
view.focused_own_channel = false;
}
if state.voice == VoiceState::Disconnected && was_voice != VoiceState::Disconnected
{
view.channel_passwords.clear();
view.join_after_connect = None;
}
if state.voice == VoiceState::Connected && was_voice != VoiceState::Connected {
// A new connection: volumes are sent again.
view.applied_playback.clear();
@@ -926,6 +944,7 @@ impl App {
if self.open_client_pending && self.current == Some(id) {
self.open_first_client();
}
self.join_after_connect(id);
}
Event::ServerInfo { session, name, flavor, capabilities } => {
self.sessions.entry(session as i64).or_default().capabilities = capabilities;
@@ -944,6 +963,7 @@ impl App {
Event::Presence { session, presence } => {
self.sessions.entry(session as i64).or_default().presence = presence;
self.apply_client_playback(session as i64);
self.join_after_connect(session as i64);
if self.current == Some(session as i64) {
self.refresh_toolbar();
self.refresh_tree();
@@ -1056,8 +1076,9 @@ impl App {
// The sample sessions of VOELIN_DEMO_UI are unknown to the engine.
Event::Error { .. } if self.demo_ui => {}
Event::Error { message, .. } => self.set_status(message),
// Not shown yet: the channel password dialog will handle it.
Event::JoinFailed { .. } => {}
Event::JoinFailed { session, channel, reason } => {
self.join_failed(session as i64, channel, reason);
}
Event::SettingChanged { key } => self.setting_changed(&key),
Event::SettingRejected { key, message } => {
self.set_status(format!("Setting {key}: {message}"));
+3
View File
@@ -61,6 +61,9 @@ pub(super) fn wire(ui: &MainWindow) {
bridge.on_member_action(|action| {
with_app(|app| app.member_action(&action));
});
bridge.on_send_poke(|text| {
with_app(|app| app.send_poke(&text));
});
bridge.on_member_volume(|percent| {
with_app(|app| app.member_volume(percent));
});
+6 -5
View File
@@ -25,13 +25,14 @@ pub(super) fn wire(ui: &MainWindow) {
});
bridge.on_join_channel(|cid| {
with_app(|app| {
app.command(|session| Command::MoveToChannel {
session,
channel: cid as ChannelId,
password: None,
})
if let Some(session) = app.current {
app.join_channel(session, cid as ChannelId);
}
});
});
bridge.on_join_with_password(|password| {
with_app(|app| app.join_with_password(password.to_string()));
});
bridge.on_toggle_collapse(|cid| {
with_app(|app| app.toggle_collapse(cid as ChannelId));
});
+43 -3
View File
@@ -21,7 +21,11 @@
//! notification), `shared:<text>` (text shared to the app on Android),
//! `pins`, `topics` (the drawers),
//! `topic:<id>` (a topic's messages), `member` (the member card of the
//! first other client), `watch` (the first stream; with sample data the
//! first other client), `poke` (the poke dialog: for the contact shown
//! after `friends`, else for the first other client, its card open),
//! `channel-password` (the password dialog of the first locked channel,
//! the sample's Officers; `channel-password:wrong` as after a refused
//! one), `watch` (the first stream; with sample data the
//! local test pattern in its place), `popout` (the same, popped out),
//! `tab:<home|servers|chat|activity|you>` (phone layout); `friends[:<uid>]`,
//! `messages[:<uid>]` (a private chat), `inbox` (offline messages),
@@ -49,8 +53,8 @@ use slint::{ComponentHandle, Rgba8Pixel, SharedPixelBuffer};
use voelin_core::gateway::Pin;
use voelin_core::stream::{StreamInfo, StreamKind};
use voelin_core::{
Contact, Event, GatewayUpdate, HistoryMessage, HistorySource, ObserveState, OfflineMessageInfo,
Relation, SessionState, Source, VoiceState,
Contact, Event, GatewayUpdate, HistoryMessage, HistorySource, JoinFailure, ObserveState,
OfflineMessageInfo, Relation, SessionState, Source, VoiceState,
};
use voelin_gateway_proto::{
Action, Attendee, ConfigEntry, ConfigSource, EventInfo, EventKind, EventSpec, PermRule,
@@ -255,6 +259,23 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running {
"member" => {
with_app(|app| app.open_first_member());
}
// After `friends` the contact path (Kairo without a contact
// chosen), else the member card's.
"poke" => {
let friends = nav.get_page() == Page::Friends;
with_app(|app| {
if friends {
let uid = app.social.selected.clone().unwrap_or_else(|| "demo-3".into());
app.contact_action(&uid, "poke");
} else {
app.open_first_member();
app.member_action("poke");
}
});
}
"channel-password" => {
with_app(|app| open_channel_password(app, arg == "wrong"));
}
"watch" | "popout" => {
with_app(|app| {
if switches.demo_ui { app.demo_watch() } else { app.watch_first_stream() }
@@ -382,6 +403,25 @@ fn save_png(image: &SharedPixelBuffer<Rgba8Pixel>, path: &std::path::Path) -> Re
Ok(())
}
/// `VOELIN_OPEN=channel-password`: join the current server's first locked
/// channel, which asks for its password; `wrong` as if the server had
/// refused one.
fn open_channel_password(app: &mut App, wrong: bool) {
let Some(session) = app.current else { return };
let locked = app
.view()
.and_then(|v| v.presence.channels.values().filter(|c| c.has_password).map(|c| c.id).min());
let Some(channel) = locked else { return };
if wrong {
if let Some(view) = app.view_mut() {
view.channel_passwords.insert(channel, "guess".into());
}
app.join_failed(session, channel, JoinFailure::Password);
} else {
app.join_channel(session, channel);
}
}
const DEMO: i64 = 9001;
fn channel(id: u64, parent: u64, order: u64, name: &str) -> ChannelInfo {
+26 -9
View File
@@ -6,7 +6,7 @@ use slint::ComponentHandle;
use voelin_core::{Command, Contact, Relation};
use voelin_model::ChatTarget;
use crate::app::{App, Bridge, MemberCard};
use crate::app::{App, Bridge, MemberCard, Nav};
use crate::settings::ClientPlayback;
use crate::vm;
@@ -96,14 +96,7 @@ impl App {
self.open_member(-1);
self.watch_client(client_id);
}
"poke" => {
self.command(|session| Command::Poke {
session,
client: client_id,
message: String::new(),
});
self.set_status(format!("Poked {nickname}"));
}
"poke" => self.ask_poke(id, client_id),
"friend" | "blocked" => {
let Some(uid) = uid else { return };
let wanted = if action == "friend" { Relation::Friend } else { Relation::Blocked };
@@ -126,6 +119,30 @@ impl App {
}
}
/// Open the poke dialog for a client (the member card, a contact).
pub(crate) fn ask_poke(&mut self, session: i64, client: u16) {
let Some(view) = self.sessions.get(&session) else { return };
let name = view.nickname(client);
self.poke_target = Some((session, client, name.clone()));
let Some(ui) = self.ui.upgrade() else { return };
let nav = ui.global::<Nav>();
nav.set_poke_name(name.into());
nav.set_poke_open(true);
}
/// The poke dialog's Send, with its message (may be empty).
pub(crate) fn send_poke(&mut self, text: &str) {
let Some((session, client, name)) = self.poke_target.take() else { return };
if !self.demo_ui {
self.engine.send(Command::Poke {
session: session as u64,
client,
message: vm::social::poke_message(text),
});
}
self.set_status(format!("Poked {name}"));
}
/// The card's volume slider, in percent.
pub(crate) fn member_volume(&mut self, percent: f32) {
let Some(view) = self.view() else { return };
+126 -9
View File
@@ -4,11 +4,13 @@
use slint::{ComponentHandle, SharedString};
use tracing::{info, warn};
use voelin_core::identity::LaunchImport;
use voelin_core::{Command, ObserveState, Source, VoiceOptions, VoiceState};
use voelin_core::{Command, JoinFailure, ObserveState, Source, VoiceOptions, VoiceState};
use voelin_model::ChannelId;
use voelin_store::{Bookmark, QueryTransport};
use crate::app::{App, BookmarkForm, Bridge, SessionView, later};
use crate::app::{App, BookmarkForm, Bridge, Nav, SessionView, later};
use crate::vm;
use crate::vm::servers::{AfterConnect, JoinStep};
/// The name of the identity the app creates when it has none.
pub(crate) const CREATED_IDENTITY: &str = "Default";
@@ -84,15 +86,19 @@ impl App {
pub(crate) fn connect_voice(&mut self) {
let channel =
self.current.and_then(|id| self.bookmark(id)).and_then(|b| b.default_channel.clone());
self.connect_voice_to(channel);
self.connect_voice_to(channel, None);
}
/// Connect the current server with voice, into `channel` (a name or
/// path) if given.
pub(crate) fn connect_voice_to(&mut self, channel: Option<String>) {
let Some(b) = self.current.and_then(|id| self.bookmark(id)).cloned() else { return };
/// Connect the current server with voice, into `channel` (a path, or
/// `/<id>`, with its password) if given; whether it was asked for.
pub(crate) fn connect_voice_to(
&mut self,
channel: Option<String>,
channel_password: Option<String>,
) -> bool {
let Some(b) = self.current.and_then(|id| self.bookmark(id)).cloned() else { return false };
if self.demo_ui {
return;
return false;
}
let mut options = VoiceOptions::new(&b.address, &b.nickname);
if let Some(spec) = &b.client_version {
@@ -100,13 +106,14 @@ impl App {
Ok(version) => options.client_version = version,
Err(error) => {
self.set_status(format!("Invalid client compatibility version: {error}"));
return;
return false;
}
}
}
options.identity = Some(self.identity_for(Some(b.id)));
options.server_password = self.secrets.get(&b.server_password_key()).ok().flatten();
options.channel = channel;
options.channel_password = channel_password;
options.audio = true;
options.stream_peer = self.video.peer_config(options.stream_peer);
self.engine
@@ -114,6 +121,7 @@ impl App {
self.set_status(format!("Connecting to {}…", b.address));
// The admin may have published the gateway since it was added.
self.discover_gateway(b.id);
true
}
/// The nickname a new server gets: the default identity's (one imported
@@ -533,6 +541,115 @@ impl App {
link
}
/// Join a channel of a session (a double-click in the tree, joining a
/// friend): move there with voice, or connect into it. A locked channel
/// asks for its password first, unless it was given this connection.
pub(crate) fn join_channel(&mut self, session: i64, channel: ChannelId) {
let Some(view) = self.sessions.get(&session) else { return };
let Some(info) = view.presence.channels.get(&channel) else { return };
let remembered = view.channel_passwords.get(&channel).map(String::as_str);
match vm::servers::join_password(info, remembered) {
JoinStep::Send(password) => self.enter_channel(session, channel, password),
JoinStep::Ask => self.ask_channel_password(session, channel, false),
}
}
/// The password dialog's Join.
pub(crate) fn join_with_password(&mut self, password: String) {
let Some((session, channel)) = self.join_target.take() else { return };
if password.is_empty() {
return;
}
if let Some(view) = self.sessions.get_mut(&session) {
view.channel_passwords.insert(channel, password.clone());
}
self.enter_channel(session, channel, Some(password));
}
/// Move into a channel; without voice on its server, connect into it.
fn enter_channel(&mut self, session: i64, channel: ChannelId, password: Option<String>) {
let Some(view) = self.sessions.get_mut(&session) else { return };
if view.state.voice != VoiceState::Disconnected {
// Chosen while connecting: no longer the one to join after.
view.join_after_connect = None;
if !self.demo_ui {
self.engine.send(Command::MoveToChannel {
session: session as u64,
channel,
password,
});
}
return;
}
if self.current != Some(session) {
self.select_server(session);
}
// By id: by its name the server finds only a top-level channel (a
// subchannel's name connects into the default channel).
if self.connect_voice_to(Some(format!("/{channel}")), password)
&& let Some(view) = self.sessions.get_mut(&session)
{
view.join_after_connect = Some(channel);
}
}
/// Connected into another channel than the one asked for
/// (`SessionView::join_after_connect`): the server says nothing when,
/// for one, the password was wrong, so it is joined again, and that
/// move says why. Once the channel shows in the voice
/// connection's presence, which can come after the own channel.
pub(crate) fn join_after_connect(&mut self, session: i64) {
let Some(view) = self.sessions.get_mut(&session) else { return };
let (VoiceState::Connected, Some(asked)) = (view.state.voice, view.join_after_connect)
else {
return;
};
let known = view.presence.channels.contains_key(&asked);
match vm::servers::after_connect(view.state.own_channel, asked, known) {
AfterConnect::Wait => {}
AfterConnect::Joined => view.join_after_connect = None,
AfterConnect::JoinAgain => {
view.join_after_connect = None;
self.join_channel(session, asked);
}
}
}
/// Open the password dialog for a locked channel; `wrong`: the one
/// given was refused.
fn ask_channel_password(&mut self, session: i64, channel: ChannelId, wrong: bool) {
let Some(info) =
self.sessions.get(&session).and_then(|v| v.presence.channels.get(&channel))
else {
return;
};
let name = vm::tree::channel_title(info).0.to_owned();
self.join_target = Some((session, channel));
let Some(ui) = self.ui.upgrade() else { return };
let nav = ui.global::<Nav>();
nav.set_channel_password_name(name.into());
nav.set_channel_password_error(wrong);
nav.set_channel_password_open(true);
}
/// The server refused a move ([`voelin_core::Event::JoinFailed`]): a
/// password asks again (the one given is forgotten), the rest is a
/// toast.
pub(crate) fn join_failed(&mut self, session: i64, channel: ChannelId, reason: JoinFailure) {
match reason {
JoinFailure::Password => {
let given = self
.sessions
.get_mut(&session)
.and_then(|v| v.channel_passwords.remove(&channel))
.is_some();
self.ask_channel_password(session, channel, given);
}
JoinFailure::Full => self.set_status("The channel is full"),
JoinFailure::Other(text) => self.set_status(text),
}
}
pub(crate) fn toggle_collapse(&mut self, channel: u64) {
if let Some(view) = self.view_mut()
&& !view.collapsed.remove(&channel)
+3 -24
View File
@@ -130,8 +130,6 @@ pub(crate) struct Spot {
pub server: String,
pub client: u16,
pub channel: u64,
/// The channel's name as the server has it (to join it by name).
pub channel_name: String,
/// The channel's name as shown (a spacer's text).
pub channel_title: String,
pub away: Option<String>,
@@ -284,7 +282,6 @@ impl App {
server: self.server_name(id),
client: c.id,
channel: c.channel,
channel_name: channel.map(|ch| ch.name.clone()).unwrap_or_default(),
channel_title: channel
.map(|ch| vm::tree::channel_title(ch).0.to_owned())
.unwrap_or_default(),
@@ -492,15 +489,7 @@ impl App {
self.set_status("Connect with voice to a server they are on to poke them.");
return;
};
if !self.demo_ui {
self.engine.send(Command::Poke {
session: s.session as u64,
client: s.client,
message: String::new(),
});
}
let name = self.sessions[&s.session].nickname(s.client);
self.set_status(format!("Poked {name}"));
self.ask_poke(s.session, s.client);
}
"join" => self.join_person(&spots),
"watch" => self.watch_person(&spots),
@@ -532,24 +521,14 @@ impl App {
}
/// Go to someone's channel: move there with voice, or connect to that
/// server into it.
/// server into it (`join_channel`, which asks for a password first).
fn join_person(&mut self, spots: &[Spot]) {
let Some(s) = spots.iter().find(|s| s.voice).or(spots.first()).cloned() else {
self.set_status("They are not on any of your servers right now.");
return;
};
self.show_server(s.session);
if s.voice {
if !self.demo_ui {
self.engine.send(Command::MoveToChannel {
session: s.session as u64,
channel: s.channel,
password: None,
});
}
} else {
self.connect_voice_to(Some(s.channel_name.clone()));
}
self.join_channel(s.session, s.channel);
}
/// Watch someone's stream: from any channel of a server we are on with
+66 -1
View File
@@ -1,6 +1,7 @@
//! The server rail.
//! The server rail, and joining a channel.
use voelin_core::{ObserveState, SessionState, VoiceState};
use voelin_model::{ChannelId, ChannelInfo};
use voelin_store::Bookmark;
use crate::app::ServerItem;
@@ -96,6 +97,50 @@ pub fn invite_link(address: &str, path: &[&str]) -> String {
link
}
/// What joining a channel takes ([`join_password`]).
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum JoinStep {
/// Move there, with this password.
Send(Option<String>),
/// Ask for the channel's password first.
Ask,
}
/// How to join `channel`, given the password remembered for it this
/// connection: a locked channel asks for one unless it was given before,
/// as TeamSpeak does. A password given before goes along even when the
/// channel shows no lock: one locked since then still lets us in.
pub fn join_password(channel: &ChannelInfo, remembered: Option<&str>) -> JoinStep {
match remembered.filter(|p| !p.is_empty()) {
Some(password) => JoinStep::Send(Some(password.to_owned())),
None if channel.has_password => JoinStep::Ask,
None => JoinStep::Send(None),
}
}
/// Where a voice connection asked into a channel stands ([`after_connect`]).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AfterConnect {
/// Not known yet.
Wait,
/// In it.
Joined,
/// Put elsewhere without a word (a wrong password, for one): joining
/// it again says why.
JoinAgain,
}
/// A connection asked into `asked`, connected with voice: `own` is our
/// channel once known, `known` whether `asked` shows in the presence yet
/// (it can come after our own channel).
pub fn after_connect(own: Option<ChannelId>, asked: ChannelId, known: bool) -> AfterConnect {
match own {
Some(own) if own == asked => AfterConnect::Joined,
Some(_) if known => AfterConnect::JoinAgain,
_ => AfterConnect::Wait,
}
}
#[cfg(test)]
mod tests {
use super::*;
@@ -150,6 +195,26 @@ mod tests {
assert_eq!(invite_link("h:x", &["Ä/b"]), "ts3server://h:x?channel=%C3%84%2Fb");
}
#[test]
fn locked_channels_ask_for_their_password_once() {
let open = ChannelInfo { id: 1, name: "Lobby".into(), ..Default::default() };
let locked = ChannelInfo { has_password: true, ..open.clone() };
assert_eq!(join_password(&open, None), JoinStep::Send(None));
assert_eq!(join_password(&locked, None), JoinStep::Ask);
assert_eq!(join_password(&locked, Some("")), JoinStep::Ask);
assert_eq!(join_password(&locked, Some("pw")), JoinStep::Send(Some("pw".into())));
assert_eq!(join_password(&open, Some("pw")), JoinStep::Send(Some("pw".into())));
}
#[test]
fn connecting_into_a_channel() {
assert_eq!(after_connect(None, 4, true), AfterConnect::Wait);
assert_eq!(after_connect(Some(4), 4, false), AfterConnect::Joined);
// Put into the default channel: once the channel is known, again.
assert_eq!(after_connect(Some(1), 4, false), AfterConnect::Wait);
assert_eq!(after_connect(Some(1), 4, true), AfterConnect::JoinAgain);
}
#[test]
fn states() {
let mut s = SessionState::default();
+22 -1
View File
@@ -1,6 +1,6 @@
//! Texts of the home, friends, messages, bell and events screens: times
//! ("12m ago", "Yesterday"), message previews without BBCode, mentions,
//! event dates; pure, so they are tested here.
//! event dates, a poke's message; pure, so they are tested here.
use chrono::{DateTime, Local, NaiveDateTime, TimeZone};
@@ -120,6 +120,13 @@ pub fn matches(query: &str, fields: &[&str]) -> bool {
q.is_empty() || fields.iter().any(|f| f.to_lowercase().contains(&q))
}
/// A poke's message as it is sent: trimmed, and cut to the
/// [`voelin_core::POKE_MESSAGE_MAX`] characters servers take.
pub fn poke_message(text: &str) -> String {
let cut: String = text.trim().chars().take(voelin_core::POKE_MESSAGE_MAX).collect();
cut.trim_end().to_owned()
}
/// The channels the search (Ctrl+K) finds for `query`, with their titles:
/// a spacer by its text, never a line or an empty spacer.
pub fn found_channels<'a>(
@@ -237,6 +244,20 @@ mod tests {
assert!(!matches("zz", &["Kairo"]));
}
#[test]
fn poke_messages() {
assert_eq!(poke_message(" Raid in 5? "), "Raid in 5?");
assert_eq!(poke_message(""), "");
assert_eq!(poke_message(" \n "), "");
let exact = "x".repeat(100);
assert_eq!(poke_message(&exact), exact);
// Characters, not bytes: two bytes each.
assert_eq!(poke_message(&"ä".repeat(150)), "ä".repeat(100));
assert_eq!(poke_message(&format!("{}€!", "ü".repeat(99))), format!("{}€", "ü".repeat(99)));
// A cut that ends in a space leaves it out.
assert_eq!(poke_message(&format!("{} more", "a".repeat(99))), "a".repeat(99));
}
/// The search shows spacers by their text and leaves out lines.
#[test]
fn search_channels() {
+9 -1
View File
@@ -32,7 +32,7 @@ import { ServerLinks, EventsPage, EventDialog } from "screens/events.slint";
import { NotificationsPanel, SearchPalette, Lightbox } from "screens/overlays.slint";
import { MobileServers, ActivityPage, YouPage, PhoneSheet } from "screens/mobile.slint";
import { MobileVoice } from "screens/mobile-voice.slint";
import { BookmarkDialog, ShareDialog, ClientAudioDialog, AboutDialog } from "screens/dialogs.slint";
import { BookmarkDialog, ShareDialog, ClientAudioDialog, ChannelPasswordDialog, PokeDialog, AboutDialog } from "screens/dialogs.slint";
import { StudioBridge } from "studio-bridge.slint";
import { StudioPage, MobileStudio } from "screens/studio.slint";
@@ -403,6 +403,14 @@ export component MainWindow inherits Window {
done => { Nav.client-open = false; }
}
if !Bridge.myts.prompt && (Nav.channel-password-open): ChannelPasswordDialog {
done => { Nav.channel-password-open = false; }
}
if !Bridge.myts.prompt && (Nav.poke-open): PokeDialog {
done => { Nav.poke-open = false; }
}
if !Bridge.myts.prompt && (Nav.about-open): AboutDialog {
done => { Nav.about-open = false; }
}
+6
View File
@@ -957,7 +957,10 @@ export global Bridge {
callback search(string);
callback connect-voice();
callback disconnect-voice();
// A double-click on a channel: Rust moves there, or asks for its
// password first (Nav.channel-password-open); the dialog's Join.
callback join-channel(int);
callback join-with-password(string);
callback open-channel-chat(int);
callback toggle-collapse(int);
callback select-tab(int);
@@ -983,6 +986,9 @@ export global Bridge {
// The member card: open it for a client (-1 closes it).
callback open-member(int);
callback member-action(string);
// The poke dialog's Send (Nav.poke-open, opened by Rust for the member
// card and contacts), with its message.
callback send-poke(string);
callback member-volume(float);
callback set-input-muted(bool);
callback set-output-muted(bool);
+7
View File
@@ -82,6 +82,13 @@ export global Nav {
in-out property <string> draft;
in-out property <BookmarkForm> bookmark-form;
in-out property <ShareForm> share-form;
// Rust opens these two: a locked channel's password (its name, and
// whether the last one given was refused) and a poke's message.
in-out property <bool> channel-password-open;
in-out property <string> channel-password-name;
in-out property <bool> channel-password-error;
in-out property <bool> poke-open;
in-out property <string> poke-name;
// The bell's panel, the search (Ctrl+K) and its selected result, a
// picture opened from the chat, the event and offline message forms,
+121 -1
View File
@@ -1,4 +1,5 @@
// Dialogs: add/edit a server, share the screen, a client's volume, About.
// Dialogs: add/edit a server, share the screen, a client's volume, a
// channel's password, a poke, About.
import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
@@ -530,6 +531,125 @@ export component ClientAudioDialog inherits Modal {
}
}
// A locked channel's password, asked for before joining it and again when
// the server refused it. Rust opens it and keeps the channel
// (`App::join_channel`).
export component ChannelPasswordDialog inherits Modal {
callback done();
title: @tr("Join {}", Nav.channel-password-name);
subtitle: @tr("This channel has a password.");
icon: Icons.lock;
card-width: 440px;
card-height: Nav.channel-password-error ? 224px : 208px;
dismissed => { done(); }
function join() {
if field.text != "" {
Bridge.join-with-password(field.text);
done();
}
}
VerticalLayout {
spacing: Theme.space-2;
field := TextField {
input-type: InputType.password;
placeholder: @tr("Password");
label: @tr("Channel password");
icon: Icons.lock;
init => { self.focus(); }
accepted => { root.join(); }
// The field has the keys, so Escape is handled here.
key-pressed(event) => {
if event.text == Key.Escape {
root.done();
return accept;
}
reject
}
}
if Nav.channel-password-error: Text {
text: @tr("Wrong password");
color: Theme.danger;
font-size: Theme.font-sm;
}
}
Rectangle { vertical-stretch: 1; }
Footer {
Button {
text: @tr("Cancel");
clicked => { done(); }
}
Button {
kind: ButtonKind.primary;
icon: Icons.log-in;
text: @tr("Join");
enabled: field.text != "";
clicked => { root.join(); }
}
}
}
// A poke, with an optional message of up to 100 characters (what servers
// take; Rust cuts longer ones). Rust opens it and keeps who is poked.
export component PokeDialog inherits Modal {
callback done();
// As Slint counts characters (grapheme clusters); Rust counts code
// points, so a long run of combined emoji may still be cut there.
property <int> count: field.text.character-count;
property <bool> too-long: count > 100;
title: @tr("Poke {}", Nav.poke-name);
subtitle: @tr("They get a notice right away.");
icon: Icons.hand;
card-width: 460px;
card-height: 224px;
dismissed => { done(); }
function send() {
if !root.too-long {
Bridge.send-poke(field.text);
done();
}
}
VerticalLayout {
spacing: Theme.space-2;
field := TextField {
placeholder: @tr("Message (optional)");
label: @tr("Message");
init => { self.focus(); }
accepted => { root.send(); }
key-pressed(event) => {
if event.text == Key.Escape {
root.done();
return accept;
}
reject
}
}
Text {
text: @tr("{}/100", root.count);
horizontal-alignment: right;
font-size: Theme.font-xs;
color: root.too-long ? Theme.danger : Theme.text-muted;
}
}
Rectangle { vertical-stretch: 1; }
Footer {
Button {
text: @tr("Cancel");
clicked => { done(); }
}
Button {
kind: ButtonKind.primary;
icon: Icons.hand;
text: @tr("Send");
enabled: !root.too-long;
clicked => { root.send(); }
}
}
}
// Bundled assets that need crediting where the app shows its notices.
export component Credits inherits VerticalLayout {
spacing: Theme.space-2;
+3 -2
View File
@@ -195,8 +195,9 @@ announces its hash (`clientupdate client_flag_avatar`), or removes it.
## Pokes, private and offline messages
`Command::Poke` sends `clientpoke`; incoming pokes are `Event::Poke` (they
used to be stored as private messages). Private messages to any client on
`Command::Poke` sends `clientpoke`, its message cut to 100 characters
(`POKE_MESSAGE_MAX`); incoming pokes are `Event::Poke` (they used to be
stored as private messages). Private messages to any client on
the server are a `ChatTarget::Private(unique id)` chat over the voice
connection, stored in the chat history under the peer's unique id, so the
conversation survives reconnects and new client ids. Gateways and query
+4 -1
View File
@@ -147,6 +147,8 @@ comes from the engine's events; what a gateway adds is hidden without it.
| Chat | `server` | Header with Pinned Messages, Topics, the voice channel and the members button; chat tabs; messages grouped by author ("Today at 10:14"), avatars, emoji, reactions with an add button, pin and topic marks, file cards with download; composer with attach, emoji and send. Opens at the newest message and follows new ones while at the end | `ChatHistory` (and `Chat` for servers without history), `AvatarReady`, `Transfer`, `Gateway` (pins; reactions arrive as stored messages); `Command::LoadOlderHistory`, `DownloadChatFile`, `UploadFile`, `GatewayRequest::React`, `Unreact`, `Pin`, `Unpin` |
| Members panel | `server` (`panel`, `no-panel`) | "Members — N" and a search; those streaming first (the people in our channel while the voice channel or a stream is shown), then each server group in the server's order with its icon, then those without a group. Rows: avatar with status, name, crown (admin groups), priority speaker, channel commander, recording, moderator role, talk power, what they do or the channel they are in. Resizable: the width is `ui.members_width` | `Presence`, `Groups`, `Talking`, `IconReady` |
| Member card | `member` | Description, groups, talk power, country; private message, poke, friend, block; volume and mute for us | `ContactsChanged`; `Command::SetContact`, `SetClientVolume`, `SetClientMuted`, `Poke` |
| Poke | `poke` (the first other member's, card open; after `friends` a contact's) | `PokeDialog`, from the member card, a friend's row and the direct message header: an optional message with a "12/100" count, Send off above 100 characters, Enter sends, Escape cancels | `Command::Poke` (trimmed, cut to 100 characters; the engine cuts too) |
| Channel password | `channel-password`, `channel-password:wrong` | Joining a channel (a double-click in the tree, joining a friend) moves there with voice, or connects into it (by its id) without; when the server puts us elsewhere on connecting, as it does for a wrong password, it is joined again, which says why. A locked channel first asks for its password in `ChannelPasswordDialog`, unless one was given since voice connected; a refused one asks again under "Wrong password". A full channel or another refusal is a toast | `Presence` (`has_password`), `JoinFailed`; `Command::MoveToChannel`, `ConnectVoice` (`channel_password`) |
| Pinned messages | `pins` | In the members panel's place: cards with author, time, text, files and reactions; the pin unpins, a click jumps to the message | `Gateway` `Pins`, `Pinned`, `Unpinned`; `GatewayRequest::Pins`, `Unpin` |
| Topics | `topics`, `topic:<id>` | In the members panel's place: search, cards with the message count, creator and last activity, Create Topic; an open topic replaces the chat's messages and takes replies | `Gateway` `Topics`, `Topic`, `TopicHistory`; `GatewayRequest::Topics`, `TopicHistory`, `CreateTopic`, `Post` |
| Voice channel | `voice` | Title, topic, "5 in voice / 50 total", Copy invite link (a `ts3server://` link to the channel; the phone's Invite button does the same), Chat only, Voice Settings, Leave; the people as large avatars (talking ring and bars, muted, crown, streaming); the streams as cards (LIVE, viewers, kind, bitrate, sound, Watch Stream); the channel's chat | `Presence`, `Talking`, `StreamsChanged`, viewer counts from `StreamsChanged`, else the `Gateway` stream directory |
@@ -384,7 +386,8 @@ Environment variables (see `src/dev.rs`):
a stream, without a server (nothing is stored).
- `VOELIN_OPEN=<what>[,<what>...]`: `home`, `server`, `settings[:voice|keybinds|streaming|privacy|appearance|profiles]` (`identities` is the same as `profiles`),
`about`, `share[:live]`, `bookmark[:edit]`, `emoji`, `client`, `panel`, `no-panel`,
`voice`, `pins`, `topics`, `topic:<id>`, `member`, `watch`, `popout`
`voice`, `pins`, `topics`, `topic:<id>`, `member`, `poke`,
`channel-password[:wrong]`, `watch`, `popout`
(the server page, above), `tab:<home|servers|chat|activity|you>` (phone
layout); `friends[:<uid>]`, `messages[:<uid>]`, `inbox`, `offline`,
`library`, `events`, `event-form`, `search[:<text>]`, `notifications`,