feat(client): redesign native UI, themes, settings and avatars

Separate conversation drafts and voice view state, add native settings and restricted CSS themes, implement validated avatar cropping, and refresh dependencies with documented desktop compatibility backports.
This commit is contained in:
Loki 2026-10-24 14:23:48 +02:00
parent 44d284a568
commit 8e5ab56611
Signed by: boba
GPG key ID: 253067914055423B
276 changed files with 53546 additions and 3399 deletions

68
patches/zbus-lockstep-macros/Cargo.toml vendored Normal file
View file

@ -0,0 +1,68 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
name = "zbus-lockstep-macros"
version = "0.5.2"
authors = ["Luuk van der Duim <luukvanderduim@gmail.com>"]
build = false
include = [
"src/**/*",
"LICENSE-MIT",
"README.md",
]
publish = true
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Macros to keep types in lockstep with DBus XML definitions"
documentation = "https://docs.rs/zbus-lockstep-macro"
readme = "README.md"
keywords = [
"type-safety",
"zbus",
"DBus",
"IPC",
]
license = "MIT"
repository = "https://github.com/luukvanderduim/zbus-lockstep"
[lib]
name = "zbus_lockstep_macros"
path = "src/lib.rs"
proc-macro = true
[dependencies.proc-macro2]
version = "1.0"
[dependencies.quote]
version = "1.0"
[dependencies.syn]
version = "2.0"
[dependencies.zbus-lockstep]
version = "0.5.2"
[dependencies.zbus_xml]
version = "6"
[dev-dependencies.version-sync]
version = "0.9"
[dependencies.zbus]
version = "6.1"
default-features = false
features = ["default-rt", "proxy", "service", "object-manager"]

View file

@ -0,0 +1,23 @@
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

57
patches/zbus-lockstep-macros/README.md vendored Normal file
View file

@ -0,0 +1,57 @@
# zbus-lockstep-macros
[![CI](https://github.com/luukvanderduim/zbus-lockstep/actions/workflows/rust.yml/badge.svg)](https://github.com/luukvanderduim/zbus-lockstep/actions/workflows/rust.yml)
![Maintenance](https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg)
[![crates-io](https://img.shields.io/crates/v/zbus-lockstep.svg)](https://crates.io/crates/zbus-lockstep)
[![api-docs](https://docs.rs/zbus-lockstep/badge.svg)](https://docs.rs/zbus-lockstep)
`zbus-lockstep-macros` extends `zbus-lockstep` to match the signature of signal types [`<T as zvariant::Type>::signature()`](https://docs.rs/zvariant/latest/zvariant/trait.Type.html#tymethod.signature) with a corresponding signature from a DBus XML file more conveniently and succinctly.
## Motivation
In the context of IPC over `DBus`, especially where there are multiple implementations of servers and/or clients communicating, it is necessary for each implementation to send what others expect and that expectations are in accordance with what is sent over the bus.
The `XML` protocol-descriptions may act as a shared frame of reference or "single source of all truth" for all implementers.
Having a single point of reference helps all implementers meet expectations on protocol conformance.
Keeping the types you send over `DBus` in lockstep with currently valid protocol-descriptions will reduce chances of miscommunication or failure to communicate.
## Use
Add `zbus-lockstep-macros` to `Cargo.toml`'s dependencies:
```toml
[dependencies]
zbus-lockstep-macros = "0.5.2"
```
If the `DBus` XML descriptions can be found in the crates root,
in either `xml/` or `XML/`, validating the type can be as easy as:
```rust
use zbus_lockstep_macros::validate;
use zvariant::Type;
#[validate]
#[derive(Type)]
struct BirthdayEvent {
name: String,
new_age: u8,
}
```
Note that the macro assumes that the member name is contained in the struct name.
You can provide the member name if you have another naming-scheme in use.
Also, it may be necessary to disambiguate if multiple interfaces across the `DBus`
descriptions provide signals with the same name.
Any of the arguments are optional.
`#[validate(xml: <xml_path>, interface: <interface_name>, member: <member_name>)]`
See also the [crates docs](https://docs.rs/zbus-lockstep-macros/latest) for more detailed descriptions of the arguments.
## LICENSE
MIT

View file

@ -0,0 +1,9 @@
# Vnox maintenance patch: zbus-lockstep-macros 0.5.2
Source: published crates.io zbus-lockstep-macros 0.5.2, original licenses included.
This is a maintained-parent compatibility backport, not a fork of an unmaintained D-Bus codec. Vnox updates dependencies/imports to maintained zbus 6, which merged zvariant and zbus_names. The original package version identifies its API baseline; no version is spoofed to suppress RustSec.
The Slint Winit patch additionally uses Winit's supported crossfont CSD backend to avoid the unmaintained ttf-parser chain while retaining Wayland client-side title decorations.
Remove this patch once upstream publishes the equivalent migration. Changes must be tested with full client build, native rendering, accessibility/portal interfaces and RustSec audit.

333
patches/zbus-lockstep-macros/src/lib.rs vendored Normal file
View file

@ -0,0 +1,333 @@
//! # zbus-lockstep-macros
//!
//! This provides the `validate` macro that builds on `zbus-lockstep`.
#![doc(html_root_url = "https://docs.rs/zbus-lockstep-macros/0.5.2")]
type Result<T> = std::result::Result<T, syn::Error>;
use std::{collections::HashMap, path::PathBuf};
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse::ParseStream, parse_macro_input, DeriveInput, Ident, LitStr, Token};
/// Validate a struct's type signature against XML signal body type.
///
/// Retrieves the signal body type from a (collection of) XML file(s) and compares it to the
/// struct's type signature.
///
/// If the XML file(s) are found in the default location, `xml/` or `XML/` of the crate root,
/// or provided as environment variable, `LOCKSTEP_XML_PATH`, the macro can be used without
/// arguments.
///
///
/// # Arguments
///
/// `#[validate]` can take three optional arguments:
///
/// * `xml`: Path to XML file(s) containing the signal definition.
/// * `interface`: Interface name of the signal.
/// * `signal`: Signal name.
///
/// `#[validate(xml: <xml_path>, interface: <interface_name>, member: <member_name>)]`
///
/// ## `xml_path`
///
/// Without an argument, the macro looks for XML file(s) in `xml/` or `XML/` of the crate root.
/// If the definitions are to be found elsewhere, there are two options:
///
/// Use the `xml` argument:
///
/// ```ignore
/// #[validate(xml: "xml")]
/// #[derive(Type)]
/// struct RemoveNodeSignal {
/// name: String,
/// path: OwnedObjectPath,
/// }
/// ```
///
///
/// Alternatively, you can provide the XML directory path as environment variable,
/// `LOCKSTEP_XML_PATH`, which will override both default and the path argument.
///
/// ## `interface`
///
/// If more than one signal with the same name is defined in the XML file(s),
/// the macro will fail and you can provide an interface name to disambiguate.
///
/// ```ignore
/// #[validate(interface: "org.example.Node")]
/// #[derive(Type)]
/// struct RemoveNodeSignal {
/// name: String,
/// path: OwnedObjectPath,
/// }
/// ```
///
///
/// ## `signal`
///
/// If a custom signal name is desired, you can be provided using `signal:`.
///
/// ```ignore
/// #[validate(signal: "RemoveNode")]
/// #[derive(Type)]
/// struct RemoveNodeSignal {
/// name: String,
/// path: OwnedObjectPath,
/// }
/// ```
///
/// ## Multiple arguments
///
/// You can provide multiple arguments with a comma separated list.
///
/// # Examples
///
/// ```rust
/// use zbus::wire::OwnedObjectPath;
/// use zbus_lockstep_macros::validate;
/// use zbus::wire::Type;
///
/// #[validate(xml: "xml", interface: "org.example.Node", signal: "RemoveNode")]
/// #[derive(Type)]
/// struct RemoveNodeSignal {
/// name: String,
/// path: OwnedObjectPath,
/// }
/// ```
#[proc_macro_attribute]
pub fn validate(args: TokenStream, input: TokenStream) -> TokenStream {
// Parse the macro arguments.
let args = parse_macro_input!(args as ValidateArgs);
// Parse the item struct.
let item = parse_macro_input!(input as DeriveInput);
let item_name = item.ident.to_string();
let xml_str = args.xml.as_ref().and_then(|p| p.to_str());
let xml = match zbus_lockstep::resolve_xml_path(xml_str) {
Ok(xml) => xml,
Err(e) => {
return syn::Error::new(
proc_macro2::Span::call_site(),
format!("Failed to resolve XML path: {e}"),
)
.to_compile_error()
.into();
}
};
// Store each file's XML as a string in a with the XML's file path as key.
let mut xml_files: HashMap<PathBuf, String> = HashMap::new();
let read_dir = std::fs::read_dir(xml);
// If the path does not exist, the process lacks permissions to read the path,
// or the path is not a directory, return an error.
if let Err(e) = read_dir {
return syn::Error::new(
proc_macro2::Span::call_site(),
format!("Failed to read XML directory: {e}"),
)
.to_compile_error()
.into();
}
// Iterate over the directory and store each XML file as a string.
for entry in read_dir.expect("Failed to read XML directory") {
let entry = entry.expect("Failed to read XML file");
// Skip directories.
if entry.path().is_dir() {
continue;
}
if entry.path().extension().expect("File has no extension.") == "xml" {
let xml =
std::fs::read_to_string(entry.path()).expect("Unable to read XML file to string");
xml_files.insert(entry.path().clone(), xml);
}
}
// These are later needed to call `get_signal_body_type`.
let mut xml_file_path = None;
let mut interface_name = None;
let mut signal_name = None;
// Iterate over `xml_files` and find the signal that is contained in the struct's name.
// Or if `signal_arg` is provided, use that.
for (path_key, xml_string) in xml_files {
let node = zbus_xml::Node::try_from(xml_string.as_str());
if node.is_err() {
return syn::Error::new(
proc_macro2::Span::call_site(),
format!(
"Failed to parse XML file: \"{}\" Err: {}",
path_key.to_str().unwrap(),
node.err().unwrap()
),
)
.to_compile_error()
.into();
}
let node = node.unwrap();
for interface in node.interfaces() {
// We were called with an interface argument, so if the interface name does not match,
// skip it.
if args.interface.is_some()
&& interface.name().as_str() != args.interface.as_ref().unwrap()
{
continue;
}
for signal in interface.signals() {
if args.signal.is_some() && signal.name().as_str() != args.signal.as_ref().unwrap()
{
continue;
}
let xml_signal_name = signal.name();
if args.signal.is_some()
&& xml_signal_name.as_str() == args.signal.as_ref().unwrap()
{
interface_name = Some(interface.name().to_string());
signal_name = Some(xml_signal_name.to_string());
xml_file_path = Some(path_key.clone());
continue;
}
if item_name.contains(xml_signal_name.as_str()) {
// If we have found a signal with the same name in an earlier iteration:
if interface_name.is_some() && signal_name.is_some() {
return syn::Error::new(
proc_macro2::Span::call_site(),
"Multiple interfaces with the same signal name. Please disambiguate.",
)
.to_compile_error()
.into();
}
interface_name = Some(interface.name().to_string());
signal_name = Some(xml_signal_name.to_string());
xml_file_path = Some(path_key.clone());
}
}
}
}
// Lets be nice and provide a informative compiler error message.
// We searched all XML files and did not find a match.
if interface_name.is_none() {
return syn::Error::new(
proc_macro2::Span::call_site(),
format!(
"No interface matching signal name '{}' found.",
args.signal.unwrap_or_else(|| item_name.clone())
),
)
.to_compile_error()
.into();
}
// If we did find a matching interface we have also set `xml_file_path` and `signal_name`.
let interface_name = interface_name.expect("Interface should have been found in search loop.");
let signal_name = signal_name.expect("Signal should have been found in search loop.");
let xml_file_path = xml_file_path.expect("XML file path should be found in search loop.");
let xml_file_path = xml_file_path
.to_str()
.expect("XML file path should be valid UTF-8");
// Create a block to return the item struct with a uniquely named validation test.
let test_name = format!("test_{item_name}_type_signature");
let test_name = Ident::new(&test_name, proc_macro2::Span::call_site());
let item_name = item.ident.clone();
let item_name = Ident::new(&item_name.to_string(), proc_macro2::Span::call_site());
let item_plus_validation_test = quote! {
#item
#[cfg(test)]
#[test]
fn #test_name() {
use zbus::wire::Type;
let xml_file = std::fs::File::open(#xml_file_path).expect("\"#xml_file_path\" expected to be a valid file path." );
let item_signature_from_xml = zbus_lockstep::get_signal_body_type(
xml_file,
#interface_name,
#signal_name,
None
).expect("Failed to get signal body type from XML file.");
let item_signature_from_struct = <#item_name as Type>::SIGNATURE;
assert_eq!(&item_signature_from_xml, item_signature_from_struct);
}
};
item_plus_validation_test.into()
}
struct ValidateArgs {
// Optional path to XML file
xml: Option<PathBuf>,
// Optional interface name
interface: Option<String>,
// Optional signal name
signal: Option<String>,
}
impl syn::parse::Parse for ValidateArgs {
fn parse(input: ParseStream) -> Result<Self> {
let mut xml = None;
let mut interface = None;
let mut signal = None;
while !input.is_empty() {
let ident = input.parse::<Ident>()?;
match ident.to_string().as_str() {
"xml" => {
input.parse::<Token![:]>()?;
let lit = input.parse::<LitStr>()?;
xml = Some(PathBuf::from(lit.value()));
}
"interface" => {
input.parse::<Token![:]>()?;
let lit = input.parse::<LitStr>()?;
interface = Some(lit.value());
}
"signal" => {
input.parse::<Token![:]>()?;
let lit = input.parse::<LitStr>()?;
signal = Some(lit.value());
}
_ => {
return Err(syn::Error::new(
ident.span(),
format!("Unexpected argument: {ident}"),
))
}
}
if !input.is_empty() {
input.parse::<Token![,]>()?;
}
}
Ok(ValidateArgs {
xml,
interface,
signal,
})
}
}