xmpp: new Config struct for Agent, with bookmarks_autojoin for now

Signed-off-by: pep <pep@bouah.net>
This commit is contained in:
pep 2025-11-13 20:23:45 +01:00
commit 147b79ca52
6 changed files with 84 additions and 18 deletions

View file

@ -9,7 +9,7 @@ use crate::tokio_xmpp::connect::{DnsConfig, StartTlsServerConnector};
use core::str::FromStr;
use crate::{
Agent, ClientFeature, RoomNick,
Agent, ClientFeature, Config, RoomNick,
jid::{BareJid, Jid, ResourceRef},
parsers::{
disco::{DiscoInfoResult, Feature, Identity},
@ -43,6 +43,7 @@ pub struct ClientBuilder<'a, C: ServerConnector> {
jid: BareJid,
password: &'a str,
server_connector: C,
config: Config,
website: String,
default_nick: RoomNick,
lang: Vec<String>,
@ -73,6 +74,7 @@ impl<C: ServerConnector> ClientBuilder<'_, C> {
jid,
password,
server_connector,
config: Config::default(),
website: String::from("https://gitlab.com/xmpp-rs/tokio-xmpp"),
default_nick: RoomNick::from_str("xmpp-rs").unwrap(),
lang: vec![String::from("en")],
@ -89,6 +91,11 @@ impl<C: ServerConnector> ClientBuilder<'_, C> {
self
}
pub fn set_config(mut self, config: Config) -> Self {
self.config = config;
self
}
pub fn set_client(mut self, type_: ClientType, name: &str) -> Self {
self.disco = (type_, String::from(name));
self
@ -169,6 +176,13 @@ impl<C: ServerConnector> ClientBuilder<'_, C> {
let disco = self.make_disco();
let node = self.website;
Agent::new(client, self.default_nick, self.lang, disco, node)
Agent::new(
client,
self.config,
self.default_nick,
self.lang,
disco,
node,
)
}
}