Track TeamSpeak 6 channel banners in the book and the model
A TeamSpeak 6 channel can have a banner picture (channel_banner_gfx_url, channel_banner_mode) that the official client draws behind the channel. The server sends both in channellist, notifychannelcreated and notifychanneledited (seen on 6.0.0-beta13.1), but the declarations only had them in channellist and the book had no place for them, so they were dropped with an "Unknown argument" warning. The book's Channel keeps them now (local patch 13 in crates/proto/UPSTREAM.md) and ChannelInfo carries the address and the mode. The mode's numbers are those of the host banner (the server's channeledit documentation: 0 as it is, 1 stretched, 2 scaled keeping the aspect ratio), so HostBannerMode becomes BannerMode and serves both. The book keeps the mode as text, as upstream declared it: a value the generated parser does not know would otherwise drop the whole channel list. The query observer asks channellist for -icon and -banners (TeamSpeak 3 and 6 ignore flags they do not know) and reads banners from the channel events too, so invisible presence shows them as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e0d9618989
commit
27d0d950cb
9 files changed
+201
-18
No files matched your search
@@ -14,6 +14,6 @@ pub use presence::{
|
||||
Presence, PresenceDelta, PresenceSnapshot, parse_badges,
|
||||
};
|
||||
pub use server::{
|
||||
Capabilities, HostBannerMode, HostMessageMode, ServerDetails, ServerFlavor, ServerVersion,
|
||||
BannerMode, Capabilities, HostMessageMode, ServerDetails, ServerFlavor, ServerVersion,
|
||||
};
|
||||
pub use tree::{TreeRow, order_siblings, tree_rows};
|
||||
@@ -13,7 +13,7 @@ use std::collections::BTreeMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::server::ServerDetails;
|
||||
use crate::server::{BannerMode, ServerDetails};
|
||||
|
||||
pub type ChannelId = u64;
|
||||
pub type ClientId = u16;
|
||||
@@ -32,6 +32,10 @@ fn is_false(b: &bool) -> bool {
|
||||
!*b
|
||||
}
|
||||
|
||||
fn is_default<T: Default + PartialEq>(v: &T) -> bool {
|
||||
*v == T::default()
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ChannelInfo {
|
||||
pub id: ChannelId,
|
||||
@@ -56,6 +60,12 @@ pub struct ChannelInfo {
|
||||
/// Icon id (`channel_icon_id`); 0: none.
|
||||
#[serde(default, skip_serializing_if = "is_zero_u32")]
|
||||
pub icon: u32,
|
||||
/// The address of the channel's banner picture (TeamSpeak 6,
|
||||
/// `channel_banner_gfx_url`), drawn behind the channel.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub banner_gfx_url: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "is_default")]
|
||||
pub banner_mode: BannerMode,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
||||
@@ -116,10 +116,11 @@ pub enum HostMessageMode {
|
||||
ModalQuit,
|
||||
}
|
||||
|
||||
/// How the host banner image is scaled.
|
||||
/// How a banner picture (the host banner, a TeamSpeak 6 channel banner) is
|
||||
/// scaled to its area: `0`, `1` and `2` on the wire.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum HostBannerMode {
|
||||
pub enum BannerMode {
|
||||
/// As it is.
|
||||
#[default]
|
||||
NoAdjust,
|
||||
@@ -129,6 +130,18 @@ pub enum HostBannerMode {
|
||||
KeepAspect,
|
||||
}
|
||||
|
||||
impl BannerMode {
|
||||
/// From its number on the wire; an unknown one shows the picture as it
|
||||
/// is.
|
||||
pub fn from_wire(value: &str) -> Self {
|
||||
match value.trim() {
|
||||
"1" => Self::IgnoreAspect,
|
||||
"2" => Self::KeepAspect,
|
||||
_ => Self::NoAdjust,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What a server tells its (voice) clients about itself.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ServerDetails {
|
||||
@@ -152,7 +165,7 @@ pub struct ServerDetails {
|
||||
#[serde(default)]
|
||||
pub banner_gfx_interval_s: u64,
|
||||
#[serde(default)]
|
||||
pub banner_mode: HostBannerMode,
|
||||
pub banner_mode: BannerMode,
|
||||
#[serde(default)]
|
||||
pub host_button_tooltip: String,
|
||||
#[serde(default)]
|
||||
|
||||
Reference in new issue
Block a user