Move the TeamSpeak implementation into src/ts

ts_link.rs, voice.rs, book.rs, ts_session/, versions.rs and identity.rs move
under crates/voelin-core/src/ts (git mv, so git log --follow keeps their
history). voelin_core::versions and voelin_core::identity are
voelin_core::ts::versions and voelin_core::ts::identity now; the UI and
voelinctl follow with the new paths. Nothing else changes: the module
declarations, the use paths and the path of Versions.csv are the only
edits to the moved files.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-24 06:08:10 +03:00
1 parent 362e2b9da1
commit 029b8464b7
26 files changed
+74 -49

No files matched your search

+3 -8
View File
@@ -47,14 +47,12 @@
//! volume) are engine-wide ([`contacts`]).
mod audio;
mod book;
pub mod cache;
pub mod contacts;
pub mod discover;
pub mod files;
pub mod gateway;
pub mod history;
pub mod identity;
pub mod link;
#[cfg(feature = "media")]
pub mod media;
@@ -67,10 +65,7 @@ pub mod stream;
mod stream_types;
#[cfg(feature = "media")]
pub mod studio;
mod ts_link;
mod ts_session;
pub mod versions;
mod voice;
pub mod ts;
mod web;
use std::collections::HashMap;
@@ -102,7 +97,7 @@ pub use route::{ChatRoute, Dedup, route_chat};
use settings::{SettingChange, Settings, SharedSettings};
use stream::{EncodedFrame, LayerId, LayerSpec, StreamInfo, StreamSetup, ViewerInfo};
pub use stream::{StreamFrame, StreamSink, StreamState, WatchState};
pub use ts_link::TsLink;
pub use ts::TsLink;
/// Banners are downloaded and shown by the same rule.
pub use web::is_svg;
/// Pictures from the web go through the desktop's proxy (set at startup).
@@ -812,7 +807,7 @@ impl Engine {
link: Arc<dyn ServerLink>,
) -> Self {
let mut backends = Backends::empty();
backends.register_local(Arc::new(ts_session::LinkConnector::any(link)));
backends.register_local(Arc::new(ts::ts_session::LinkConnector::any(link)));
Self::start_with_backends(settings, history, backends)
}
+1 -1
View File
@@ -146,7 +146,7 @@ impl Default for Backends {
/// `teamspeak://`, and an address without a scheme).
fn default() -> Self {
let mut backends = Self::empty();
backends.register_local(Arc::new(crate::ts_session::TsConnector::new()));
backends.register_local(Arc::new(crate::ts::ts_session::TsConnector::new()));
backends
}
}
+2 -2
View File
@@ -17,8 +17,8 @@ use voelin_proto::link::Features;
use voelin_proto::v1::{self, ChannelKind, MessageFlag, RoleScope};
use super::media::TalkTracker;
use crate::ts_session::entities::user_uid;
use crate::ts_session::ids::{self, FOREIGN_SYSTEM};
use crate::ts::ts_session::entities::user_uid;
use crate::ts::ts_session::ids::{self, FOREIGN_SYSTEM};
/// What the projection needs to know besides the replica.
pub(crate) struct View<'a> {
+7 -7
View File
@@ -207,7 +207,7 @@ async fn drive(
) -> Option<String> {
let (media_tx, media_rx) = mpsc::unbounded_channel();
let sink: Arc<dyn MediaSink> = Arc::new(MediaQueue(media_tx));
let params = match crate::ts_session::connect_params(options, sink, backends) {
let params = match crate::ts::ts_session::connect_params(options, sink, backends) {
Ok(params) => params,
Err(e) => return connect_failure(&e),
};
@@ -498,7 +498,7 @@ impl Conn {
let backend = self.backend();
let own_uid =
self.replica.user(self.own_user()).and_then(crate::ts_session::entities::user_uid);
self.replica.user(self.own_user()).and_then(crate::ts::ts_session::entities::user_uid);
let name = self
.replica
.server(self.server)
@@ -906,7 +906,7 @@ impl Conn {
.filter(|n| !n.is_empty());
self.send(LinkEvent::Poke {
from: u16::try_from(signal.from_participant).unwrap_or_default(),
from_uid: user.and_then(crate::ts_session::entities::user_uid),
from_uid: user.and_then(crate::ts::ts_session::entities::user_uid),
from_name: nick.or_else(|| user.map(|u| u.name.clone())).unwrap_or_default(),
message: poke.message,
});
@@ -1261,7 +1261,7 @@ impl Conn {
/// user to make one with.
fn direct_channel(&self, uid: &str) -> Direct {
let user_of = |id: u64| {
self.replica.user(id).and_then(crate::ts_session::entities::user_uid).as_deref()
self.replica.user(id).and_then(crate::ts::ts_session::entities::user_uid).as_deref()
== Some(uid)
};
let own = self.own_user();
@@ -1752,7 +1752,7 @@ mod tests {
("Fake", "1.2"),
] {
let info = BackendInfo { product: product.into(), version: version.into() };
assert_eq!(backend_info(&crate::ts_session::backend_to_v1(&info)), info);
assert_eq!(backend_info(&crate::ts::ts_session::backend_to_v1(&info)), info);
}
}
@@ -1795,8 +1795,8 @@ mod tests {
{
let caps =
Capabilities { streams, file_transfer, offline_messages, ..Default::default() };
let features = Features::new(crate::ts_session::features_of(&caps));
let host = crate::ts_session::backend_to_v1(&BackendInfo::default());
let features = Features::new(crate::ts::ts_session::features_of(&caps));
let host = crate::ts::ts_session::backend_to_v1(&BackendInfo::default());
let back = capabilities(&features, &host, true);
assert_eq!(
(back.streams, back.file_transfer, back.offline_messages),
+1 -1
View File
@@ -27,7 +27,7 @@ use crate::files::{DownloadTo, FileEntry, TransferState};
use crate::offline::OfflineMessage;
use crate::offline::OfflineMessageInfo;
use crate::stream::{OwnStreamEvent, StreamCmd, StreamKind};
use crate::ts_session::LinkConnector;
use crate::ts::ts_session::LinkConnector;
use crate::{BackendInfo, Event, JoinFailure};
const ME: u16 = 7;
+1 -1
View File
@@ -1135,7 +1135,7 @@ pub static CACHE_FETCH_IMAGES: Key<bool> = Key::new(
);
/// Import identities from the official TeamSpeak clients when the app
/// starts ([`crate::identity::import_new`]; their files are only read).
/// starts ([`crate::ts::identity::import_new`]; their files are only read).
pub static IDENTITY_IMPORT: Key<bool> = Key::new(
"identity.import_from_teamspeak",
Kind::Bool,
@@ -345,7 +345,7 @@ mod tests {
use crate::link::media::TalkTracker;
use crate::link::project::{View, presence as project};
use crate::ts_session::entities::build;
use crate::ts::ts_session::entities::build;
let built = build(presence, ts6, own);
let mut replica = Replica::new(SCHEMA_GENERATION);
File renamed without changes.
+29
View File
@@ -0,0 +1,29 @@
//! The TeamSpeak implementation of the session seam.
//!
//! Everything of the engine that is TeamSpeak's lives here, so that it can
//! leave this crate for the TeamSpeak gateway (`voelin-gateway-ts` of
//! VoelinGateWay) as one piece (`docs/session-seam.md`, H9):
//!
//! - `ts_link.rs` and `voice.rs` are the connection of `tsclientlib`
//! (chat, voice, files, pokes, offline messages, the stream task's
//! requests) with `book.rs`, its presence from the library's book;
//! - `ts_session/` makes a `voelin_proto::link::Session` of such a connection
//! ([`TsConnector`] is the `Connector` the engine registers for
//! `ts3server://` and `teamspeak://`);
//! - [`versions`] and [`identity`] are what a TeamSpeak client has to know
//! about itself: the signed compatibility versions it can claim, and the
//! identities (reading, importing from the official clients, the security
//! level).
//!
//! The TeamSpeak crates' types (`tsclientlib::Identity`, `Version`, ...) are
//! named in the public items of this module and nowhere else of the crate's
//! API.
mod book;
pub mod identity;
mod ts_link;
pub(crate) mod ts_session;
pub mod versions;
mod voice;
pub use ts_link::TsLink;
@@ -1,7 +1,7 @@
//! [`TsLink`]: the TeamSpeak implementation of [`ServerLink`].
//!
//! It connects as a normal TeamSpeak 3 or 6 client with `tsclientlib` and
//! runs the connection ([`crate::voice`]) with everything that rides on it:
//! runs the connection ([`super::voice`]) with everything that rides on it:
//! chat, voice, files, pokes, offline messages and, on TeamSpeak 6, the
//! stream task. Which product the server is (and what it can do) is decided
//! there, from the version it sends, and reported in
@@ -14,8 +14,8 @@
use tokio::sync::mpsc;
use super::voice;
use crate::link::{ConnectOptions, LinkCmd, LinkCtx, LinkEvent, ServerLink};
use crate::voice;
/// Connects to TeamSpeak 3 and 6 servers. The engine's default link.
#[derive(Clone, Copy, Debug, Default)]
@@ -43,11 +43,12 @@ use voelin_proto::link::{
use voelin_proto::v1::{self, response::Result as Answer};
use self::driver::{Cmd, Config, Driver, Parts, rejected};
use crate::BackendInfo;
use crate::link::{
Backends, BoxDuplex, ConnectOptions, LinkCmd, LinkCtx, LinkEvent, LocalConnected,
LocalConnector, LocalCtx, ServerLink, StreamPort,
};
use crate::{BackendInfo, TsLink};
use crate::ts::TsLink;
/// The `Credential::Foreign` kind of a stored TeamSpeak identity.
const IDENTITY_KIND: &str = "teamspeak";
@@ -756,7 +757,7 @@ mod tests {
options.channel_password = Some("p w+%".into());
options.token = Some("tokenvalue".into());
options.identity = Some(tsclientlib::Identity::create());
options.client_version = Some(crate::versions::native_version().unwrap());
options.client_version = Some(crate::ts::versions::native_version().unwrap());
options.audio = false;
let sent = params(&options);
assert_eq!(sent.hello.password, "s3cret pass&word");
@@ -8,7 +8,7 @@ use anyhow::{Context, Result, bail};
use base64::prelude::*;
use tsclientlib::Version;
const VERSIONS_CSV: &str = include_str!("../../proto/tsproto-structs/declarations/Versions.csv");
const VERSIONS_CSV: &str = include_str!("../../../proto/tsproto-structs/declarations/Versions.csv");
/// The signed generic version of every platform, tsclientlib's default.
const GENERIC_VERSION: &str = "3.?.? [Build: 5680278000]";
@@ -36,7 +36,7 @@ use voelin_audio::{EncodedVoice, TalkerId, VoiceCodec, VoicePacket};
use voelin_model::{Capabilities, ChannelId, ChatMessage, ChatTarget, ServerFlavor};
use voelin_stream::{ClientState, Request, StreamNotification};
use crate::book::presence_from_book;
use super::book::presence_from_book;
use crate::cache::{self, IMAGE_NEGOTIATION, image_download_time};
use crate::files::{self, FileEntry, Report, RequestId, Sink, TransferId, TransferState};
use crate::link::{BoxDuplex, BoxRead, ConnectOptions, LinkCmd, LinkCtx, LinkEvent, Remote};
@@ -296,12 +296,12 @@ async fn run_inner(
) -> anyhow::Result<()> {
let version = match &options.client_version {
Some(version) => version.clone(),
None => crate::versions::native_version()?,
None => super::versions::native_version()?,
};
let mut builder = Connection::build(options.address.clone())
.name(options.nickname.clone())
.version(version)
.metadata(crate::versions::client_metadata());
.metadata(super::versions::client_metadata());
if let Some(identity) = &options.identity {
builder = builder.identity(identity.clone());
}
+1 -1
View File
@@ -769,7 +769,7 @@ pub fn run(options: RunOptions) -> Result<()> {
// with the sample data of VOELIN_DEMO_UI); the client's default
// identity becomes ours while we have none the user chose.
let imported = if prefs.get(&IDENTITY_IMPORT) && !switches.demo_ui {
voelin_core::identity::import_new(&store, &voelin_core::identity::discover())
voelin_core::ts::identity::import_new(&store, &voelin_core::ts::identity::discover())
.unwrap_or_else(|e| {
warn!(%e, "could not import TeamSpeak identities");
Default::default()
+1 -1
View File
@@ -1,7 +1,7 @@
//! The identity servers see us as: the store's default (schema 4,
//! `Store::default_identity`), chosen under Settings → Profiles, and the
//! import of the official clients' identities on start
//! (`voelin_core::identity::import_new`, app.rs). The rest of the Profiles
//! (`voelin_core::ts::identity::import_new`, app.rs). The rest of the Profiles
//! page is in `settings_pages.rs`.
use tracing::warn;
+5 -5
View File
@@ -5,7 +5,7 @@ use std::time::Instant;
use slint::ComponentHandle;
use tracing::{debug, info, warn};
use voelin_core::identity::LaunchImport;
use voelin_core::ts::identity::LaunchImport;
use voelin_core::{Command, JoinFailure, ObserveState, Source, VoiceOptions, VoiceState};
use voelin_model::ChannelId;
use voelin_store::{Bookmark, QueryTransport};
@@ -18,7 +18,7 @@ use crate::vm::servers::{AfterConnect, JoinStep};
pub(crate) const CREATED_IDENTITY: &str = "Default";
/// What to tell the user about the identities imported from the official
/// clients at start ([`voelin_core::identity::import_new`]), if anything.
/// clients at start ([`voelin_core::ts::identity::import_new`]), if anything.
pub(crate) fn imported_status(report: &LaunchImport) -> Option<String> {
let n = report.added.len();
let names = report.added.iter().map(|f| f.nickname.as_str()).collect::<Vec<_>>().join(", ");
@@ -122,7 +122,7 @@ impl App {
}
let mut options = VoiceOptions::new(&b.address, &b.nickname);
if let Some(spec) = &b.client_version {
match voelin_core::versions::resolve(spec) {
match voelin_core::ts::versions::resolve(spec) {
Ok(version) => options.client_version = version,
Err(error) => {
self.set_status(format!("Invalid client compatibility version: {error}"));
@@ -154,7 +154,7 @@ impl App {
.flatten()
.map(|identity| identity.name)
.filter(|name| {
![CREATED_IDENTITY, voelin_core::identity::DEFAULT_NICKNAME]
![CREATED_IDENTITY, voelin_core::ts::identity::DEFAULT_NICKNAME]
.contains(&name.as_str())
})
.or_else(|| std::env::var("USER").or_else(|_| std::env::var("USERNAME")).ok())
@@ -750,7 +750,7 @@ impl App {
#[cfg(test)]
mod tests {
use voelin_core::identity::Found;
use voelin_core::ts::identity::Found;
use super::*;
use voelin_store::QueryConfig;
+7 -7
View File
@@ -55,7 +55,7 @@ pub(crate) struct Improving {
pub(crate) struct Pages {
pub improving: HashMap<i64, Improving>,
/// Identities found in other clients' files, picked for import.
pub found: Vec<(voelin_core::identity::Found, bool)>,
pub found: Vec<(voelin_core::ts::identity::Found, bool)>,
pub settings_filter: String,
/// The gateway being administered.
pub admin: Option<i64>,
@@ -1112,7 +1112,7 @@ impl App {
.map(|c| if c.is_alphanumeric() || c == '-' { c } else { '_' })
.collect::<String>();
let path = dir.join(format!("{file}.ini"));
match voelin_core::identity::write_export(&path, &entry.name, &identity) {
match voelin_core::ts::identity::write_export(&path, &entry.name, &identity) {
Ok(()) => self.set_identity_status(format!(
"Exported to {} (it holds the private key: keep it safe).",
path.display()
@@ -1160,7 +1160,7 @@ impl App {
.name("identity-level".into())
.spawn(move || {
let better =
voelin_core::identity::improve_level(&identity, target, &cancel, |level| {
voelin_core::ts::identity::improve_level(&identity, target, &cancel, |level| {
later(move |app| {
if let Some(i) = app.pages.improving.get_mut(&id) {
i.reached = i.reached.max(level);
@@ -1197,8 +1197,8 @@ impl App {
pub(crate) fn find_identities(&mut self) {
let mut found = Vec::new();
let mut errors = Vec::new();
for path in voelin_core::identity::discover() {
match voelin_core::identity::read(&path) {
for path in voelin_core::ts::identity::discover() {
match voelin_core::ts::identity::read(&path) {
Ok(list) => found.extend(list),
Err(e) => errors.push(e.to_string()),
}
@@ -1231,11 +1231,11 @@ impl App {
pub(crate) fn import_identities(&mut self) {
let picked: Vec<_> =
self.pages.found.iter().filter(|(_, p)| *p).map(|(f, _)| f.clone()).collect();
match voelin_core::identity::import(&self.store, &picked) {
match voelin_core::ts::identity::import(&self.store, &picked) {
Ok(results) => {
let added = results
.iter()
.filter(|r| matches!(r, voelin_core::identity::Imported::Added(_)))
.filter(|r| matches!(r, voelin_core::ts::identity::Imported::Added(_)))
.count();
self.set_identity_status(format!("{added} identities imported."));
}