diff --git a/crates/proto/UPSTREAM.md b/crates/proto/UPSTREAM.md index faf3d63..f9a7792 100644 --- a/crates/proto/UPSTREAM.md +++ b/crates/proto/UPSTREAM.md @@ -100,3 +100,9 @@ against or offered back to upstream. (RFC 2782 order). A CNAME among the SRV answers no longer panics. The lookups are injectable inside the module, and the tests use a fake TSDNS server and fake names; the upstream tests that need DNS and the internet are `#[ignore]`d. +12. **Private keys with leading zero bytes** (`tsproto-types/src/crypto.rs`, + "Voelin patch"). The TeamSpeak export stores the private scalar as a DER + integer, which drops leading zero bytes, and `EccKeyPrivP256::from_tomcrypt` + handed those fewer than 32 bytes to `from_short`, which refused them: one + identity in 256 (the official client's ones included) could not be imported. + The scalar is padded to 32 bytes now; a test round-trips such keys. diff --git a/crates/proto/tsproto-types/src/crypto.rs b/crates/proto/tsproto-types/src/crypto.rs index 85affd1..65d91fd 100644 --- a/crates/proto/tsproto-types/src/crypto.rs +++ b/crates/proto/tsproto-types/src/crypto.rs @@ -394,14 +394,23 @@ impl EccKeyPrivP256 { if (*len != 1 && *len != 2) || content[0] & 0x80 == 0 { return Err(Error::NoPrivateKey); } + // Voelin patch: DER drops the leading zero bytes of a scalar + // below 2^248 (one key in 256), which `from_short` refused. + let short = |i: &BigInt| -> Result { + let bytes = i.to_bytes_be().1; + let mut padded = [0u8; 32]; + let start = padded.len().checked_sub(bytes.len()).ok_or(Error::NoShortKey)?; + padded[start..].copy_from_slice(&bytes); + Self::from_short(&padded) + }; if *len == 1 { if let Some(ASN1Block::Integer(_, i)) = blocks.get(4) { - Self::from_short(&i.to_bytes_be().1) + short(i) } else { Err(Error::NoPrivateKey) } } else if let Some(ASN1Block::Integer(_, i)) = blocks.get(2) { - Self::from_short(&i.to_bytes_be().1) + short(i) } else { Err(Error::NoPrivateKey) } @@ -602,6 +611,21 @@ mod tests { assert_eq!(short, short2); } + /// Voelin patch: a private key whose first bytes are zero survives the + /// TeamSpeak export (DER stores the scalar without them). + #[test] + fn small_priv_key_round_trips() { + for leading_zeros in [1, 2, 31] { + let mut short = [0x5au8; 32]; + short[..leading_zeros].fill(0); + let key = EccKeyPrivP256::from_short(&short).unwrap(); + let back = EccKeyPrivP256::from_ts(&key.to_ts()).unwrap(); + assert_eq!(back.to_short().as_slice(), short); + let back = EccKeyPrivP256::from_ts_obfuscated(&key.to_ts_obfuscated()).unwrap(); + assert_eq!(back.to_short().as_slice(), short); + } + } + #[test] fn parse_ed25519_pub_key() { EccKeyPubEd25519::from_base64("zQ3irtRjRVCafjz9j2iz3HVVsp3M7HPNGHUPmTgSQIo=").unwrap(); diff --git a/crates/voelin-core/src/identity.rs b/crates/voelin-core/src/identity.rs index 35721be..bbda305 100644 --- a/crates/voelin-core/src/identity.rs +++ b/crates/voelin-core/src/identity.rs @@ -31,7 +31,7 @@ use std::{fs, str}; use rusqlite::{Connection, OpenFlags, OptionalExtension}; use tsclientlib::Identity; use voelin_gateway_proto::UniqueIds; -use voelin_store::Store; +use voelin_store::{IdentityOrigin, Store}; /// Name given to an identity whose source kept none. pub const DEFAULT_NICKNAME: &str = "imported"; @@ -168,29 +168,65 @@ pub fn import(store: &Store, found: &[Found]) -> Result, IdentityE if !known.insert(f.uid()) { return Ok(Imported::Duplicate); } - Ok(Imported::Added(store.add_identity(&f.nickname, &f.identity)?)) + Ok(Imported::Added(store.add_identity( + &f.nickname, + &f.identity, + IdentityOrigin::Imported, + )?)) }) .collect() } +/// What [`import_new`] did. +#[derive(Debug, Default)] +pub struct LaunchImport { + /// The identities added, the official clients' defaults first. + pub added: Vec, + /// The identity that became our default. + pub default: Option, + /// That took the place of the identity the app had created on its own + /// ([`IdentityOrigin::Created`]), which is kept. + pub replaced: bool, +} + /// Store the identities in the official clients' files at `paths` (usually /// [`discover`]) that the store does not have yet, as the app does when it /// starts. Files that cannot be read or hold no identity are skipped; none is -/// written. The identities the clients use by default go in first, so on a -/// store without identities the official client's default becomes ours (the -/// first identity) and servers see the same unique id. Returns what was -/// added. -pub fn import_new(store: &Store, paths: &[PathBuf]) -> Result, IdentityError> { +/// written. +/// +/// Servers should see the user as on the official client: while our +/// default is an identity nobody chose, the one the app created on its own +/// ([`IdentityOrigin::Created`]), or there is none, the identity the official +/// client uses by default becomes ours (the TeamSpeak 6 client's before the +/// TeamSpeak 3 client's), once: an identity the user picked as the default +/// is [`IdentityOrigin::User`] and stays. +pub fn import_new(store: &Store, paths: &[PathBuf]) -> Result { + let before = store.default_identity()?; let mut found: Vec = paths.iter().filter_map(|path| read(path).ok()).flatten().collect(); // Stable: TeamSpeak 6's default before TeamSpeak 3's, as `locations` lists them. found.sort_by_key(|f| !f.selected); let outcomes = import(store, &found)?; - Ok(found + if before.as_ref().is_none_or(|b| b.origin == IdentityOrigin::Created) + && let Some(official) = found.iter().find(|f| f.selected) + { + let uid = official.uid(); + if let Some(entry) = store.identities()?.into_iter().find(|e| e.uid == uid) { + store.set_default_identity(entry.id, false)?; + } + } + let after = store.default_identity()?; + let mut report = LaunchImport::default(); + if let Some(after) = after.filter(|a| before.as_ref().is_none_or(|b| b.id != a.id)) { + report.default = found.iter().find(|f| f.uid() == after.uid).cloned(); + report.replaced = before.is_some() && report.default.is_some(); + } + report.added = found .into_iter() .zip(outcomes) .filter(|(_, outcome)| matches!(outcome, Imported::Added(_))) .map(|(f, _)| f) - .collect()) + .collect(); + Ok(report) } /// The TeamSpeak 3 `.ini` export of an identity, which the official client @@ -636,6 +672,14 @@ mod tests { } } + fn nicknames(found: &[Found]) -> Vec<&str> { + found.iter().map(|f| f.nickname.as_str()).collect() + } + + fn default_uid(store: &Store) -> String { + store.default_identity().unwrap().unwrap().uid + } + #[test] fn launch_import_makes_the_clients_default_ours_and_adds_only_new_ones() { let dir = temp_dir("launch"); @@ -647,21 +691,71 @@ mod tests { let missing = dir.join("missing.db"); let store = Store::open_in_memory().unwrap(); - let added = import_new(&store, &[ts6.clone(), missing.clone()]).unwrap(); - let nicknames: Vec<_> = added.iter().map(|f| f.nickname.as_str()).collect(); - assert_eq!(nicknames, ["Main", "Spare"]); - // The first identity is the app's default: the client's default. - assert_eq!(store.identities().unwrap()[0].uid, main.key().to_pub().get_uid()); + let report = import_new(&store, &[ts6.clone(), missing.clone()]).unwrap(); + assert_eq!(nicknames(&report.added), ["Main", "Spare"]); + // Without an identity of its own the app takes the client's default. + assert_eq!(report.default.unwrap().nickname, "Main"); + assert!(!report.replaced); + assert_eq!(default_uid(&store), main.key().to_pub().get_uid()); - // The next start finds only what is new. + // The next start finds only what is new, and an imported default + // stays even when another client has a different one. client_database(&ts3, &[(&old, "Old", true), (&main, "Main", true)]); - let added = import_new(&store, &[ts6, ts3, missing]).unwrap(); - let nicknames: Vec<_> = added.iter().map(|f| f.nickname.as_str()).collect(); - assert_eq!(nicknames, ["Old"]); - let stored = store.identities().unwrap(); - assert_eq!(stored.len(), 3); - // A store that has identities keeps its default. - assert_eq!(stored[0].uid, main.key().to_pub().get_uid()); + let report = import_new(&store, &[ts6, ts3, missing]).unwrap(); + assert_eq!(nicknames(&report.added), ["Old"]); + assert!(report.default.is_none() && !report.replaced); + assert_eq!(store.identities().unwrap().len(), 3); + assert_eq!(default_uid(&store), main.key().to_pub().get_uid()); + fs::remove_dir_all(dir).unwrap(); + } + + /// The identity the app made on its first start gives way to the + /// official client's default once; the user's later choice stays. + #[test] + fn the_created_identity_gives_way_once() { + let dir = temp_dir("replace"); + let ts6 = dir.join("ts6.db"); + let (made, main) = (synthetic(), synthetic()); + let store = Store::open_in_memory().unwrap(); + let made_id = store.add_identity("Default", &made, IdentityOrigin::Created).unwrap(); + // The official client is not there yet: nothing changes. + let report = import_new(&store, std::slice::from_ref(&ts6)).unwrap(); + assert!(report.added.is_empty() && report.default.is_none()); + assert_eq!(default_uid(&store), made.key().to_pub().get_uid()); + + client_database(&ts6, &[(&main, "Main", true)]); + let report = import_new(&store, std::slice::from_ref(&ts6)).unwrap(); + assert_eq!(report.default.unwrap().nickname, "Main"); + assert!(report.replaced); + assert_eq!(default_uid(&store), main.key().to_pub().get_uid()); + // The one the app made is kept. + assert_eq!(store.identities().unwrap().len(), 2); + + // The user goes back to it: later starts leave that alone. + store.set_default_identity(made_id, true).unwrap(); + for _ in 0..2 { + let report = import_new(&store, std::slice::from_ref(&ts6)).unwrap(); + assert!(report.added.is_empty() && report.default.is_none() && !report.replaced); + assert_eq!(default_uid(&store), made.key().to_pub().get_uid()); + } + fs::remove_dir_all(dir).unwrap(); + } + + /// An identity imported earlier (by `voelinctl identity import`, which + /// does not choose a default) still takes the created one's place. + #[test] + fn an_earlier_import_still_replaces_the_created_identity() { + let dir = temp_dir("earlier"); + let ts6 = dir.join("ts6.db"); + let (made, main) = (synthetic(), synthetic()); + client_database(&ts6, &[(&main, "Main", true)]); + let store = Store::open_in_memory().unwrap(); + store.add_identity("Default", &made, IdentityOrigin::Created).unwrap(); + import(&store, &read(&ts6).unwrap()).unwrap(); + assert_eq!(default_uid(&store), made.key().to_pub().get_uid()); + let report = import_new(&store, &[ts6]).unwrap(); + assert!(report.added.is_empty() && report.replaced); + assert_eq!(default_uid(&store), main.key().to_pub().get_uid()); fs::remove_dir_all(dir).unwrap(); } diff --git a/crates/voelin-store/src/contacts.rs b/crates/voelin-store/src/contacts.rs index 54099ac..0b83679 100644 --- a/crates/voelin-store/src/contacts.rs +++ b/crates/voelin-store/src/contacts.rs @@ -274,8 +274,7 @@ mod tests { db.execute_batch("INSERT INTO settings (key, value) VALUES ('k', '1');").unwrap(); } let store = Store::open(&path).unwrap(); - assert_eq!(store.schema_version().unwrap(), 3); - assert_eq!(Store::SCHEMA_VERSION, 3); + assert_eq!(store.schema_version().unwrap(), Store::SCHEMA_VERSION); assert_eq!(store.setting::("k").unwrap(), Some(1)); store.put_contact(&friend("a=")).unwrap(); drop(store); diff --git a/crates/voelin-store/src/lib.rs b/crates/voelin-store/src/lib.rs index 58a672d..64f9e5a 100644 --- a/crates/voelin-store/src/lib.rs +++ b/crates/voelin-store/src/lib.rs @@ -21,7 +21,7 @@ pub use contacts::{Contact, ContactSeen, Relation}; #[cfg(feature = "keyring")] pub use secrets::KeyringSecrets; pub use secrets::{MemorySecrets, Secrets}; -pub use store::{Bookmark, IdentityEntry, QueryConfig, QueryTransport, Store}; +pub use store::{Bookmark, IdentityEntry, IdentityOrigin, QueryConfig, QueryTransport, Store}; #[derive(Debug, thiserror::Error)] pub enum Error { diff --git a/crates/voelin-store/src/store.rs b/crates/voelin-store/src/store.rs index d782bba..42ee0d2 100644 --- a/crates/voelin-store/src/store.rs +++ b/crates/voelin-store/src/store.rs @@ -22,8 +22,22 @@ const MIGRATIONS: &[Migration] = &[ Migration::Sql(SCHEMA_1), Migration::Code(crate::chat::migrate_2), Migration::Sql(crate::contacts::SCHEMA_3), + Migration::Sql(SCHEMA_4), ]; +/// Version 4: where each identity came from ([`IdentityOrigin`]) and which +/// one is the default. Until now the app created an identity named +/// `Default` when it had none, and the only other way in was an import; +/// the default was the first identity. +const SCHEMA_4: &str = r#" + ALTER TABLE identities ADD COLUMN origin TEXT NOT NULL DEFAULT 'user'; + ALTER TABLE identities ADD COLUMN is_default INTEGER NOT NULL DEFAULT 0; + UPDATE identities SET origin = 'imported'; + UPDATE identities SET origin = 'created' + WHERE id = (SELECT MIN(id) FROM identities) AND name = 'Default'; + UPDATE identities SET is_default = 1 WHERE id = (SELECT MIN(id) FROM identities); +"#; + /// Version 1: identities, bookmarks, settings and a first chat cache. pub(crate) const SCHEMA_1: &str = r#" CREATE TABLE identities ( @@ -62,6 +76,39 @@ pub struct IdentityEntry { pub name: String, pub uid: String, pub level: u8, + pub origin: IdentityOrigin, + /// The identity the app connects with. + pub is_default: bool, +} + +/// Where an identity came from. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum IdentityOrigin { + /// Made by the app on its own because it had none; nobody chose it, so + /// the official client's identity may take its place as the default. + Created, + /// From another client (`voelin_core::identity`). + Imported, + /// Made or chosen as the default by the user. + User, +} + +impl IdentityOrigin { + fn as_str(self) -> &'static str { + match self { + Self::Created => "created", + Self::Imported => "imported", + Self::User => "user", + } + } + + fn parse(text: &str) -> Self { + match text { + "created" => Self::Created, + "imported" => Self::Imported, + _ => Self::User, + } + } } /// How to reach a server's ServerQuery for invisible presence and relay chat. @@ -179,28 +226,71 @@ impl Store { // Identities - pub fn add_identity(&self, name: &str, identity: &Identity) -> Result { + /// Store an identity; it is the default when no other one is. + pub fn add_identity( + &self, + name: &str, + identity: &Identity, + origin: IdentityOrigin, + ) -> Result { let uid = identity.key().to_pub().get_uid(); self.db.execute( - "INSERT INTO identities (name, uid, data) VALUES (?1, ?2, ?3)", - params![name, uid, serde_json::to_string(identity)?], + "INSERT INTO identities (name, uid, data, origin, is_default) + VALUES (?1, ?2, ?3, ?4, NOT EXISTS (SELECT 1 FROM identities WHERE is_default))", + params![name, uid, serde_json::to_string(identity)?, origin.as_str()], )?; Ok(self.db.last_insert_rowid()) } pub fn identities(&self) -> Result> { - let mut stmt = self.db.prepare("SELECT id, name, uid, data FROM identities ORDER BY id")?; + let mut stmt = self.db.prepare( + "SELECT id, name, uid, data, origin, is_default FROM identities ORDER BY id", + )?; let rows = stmt.query_map([], |r| { - Ok((r.get::<_, i64>(0)?, r.get(1)?, r.get(2)?, r.get::<_, String>(3)?)) + Ok(( + r.get::<_, i64>(0)?, + r.get(1)?, + r.get(2)?, + r.get::<_, String>(3)?, + r.get::<_, String>(4)?, + r.get(5)?, + )) })?; rows.map(|row| { - let (id, name, uid, data) = row?; + let (id, name, uid, data, origin, is_default) = row?; let identity: Identity = serde_json::from_str(&data)?; - Ok(IdentityEntry { id, name, uid, level: identity.level() }) + let origin = IdentityOrigin::parse(&origin); + Ok(IdentityEntry { id, name, uid, level: identity.level(), origin, is_default }) }) .collect() } + /// The identity the app connects with: the one marked as the default, + /// else the first. + pub fn default_identity(&self) -> Result> { + let identities = self.identities()?; + Ok(identities.iter().find(|i| i.is_default).or(identities.first()).cloned()) + } + + /// Make `id` the default identity. `by_user`: the user chose it, so one + /// the app created on its own becomes theirs ([`IdentityOrigin::User`]) + /// and is never replaced by an import again. + pub fn set_default_identity(&self, id: i64, by_user: bool) -> Result<()> { + let tx = self.db.unchecked_transaction()?; + if tx.execute("UPDATE identities SET is_default = 1 WHERE id = ?1", [id])? == 0 { + return Err(Error::NotFound("identity", id)); + } + tx.execute("UPDATE identities SET is_default = 0 WHERE id <> ?1", [id])?; + if by_user { + tx.execute( + "UPDATE identities SET origin = 'user' WHERE id = ?1 AND origin = 'created'", + [id], + )?; + } + tx.commit()?; + Ok(()) + } + pub fn identity(&self, id: i64) -> Result { let data: Option = self .db @@ -337,22 +427,86 @@ mod tests { fn identities() { let store = Store::open_in_memory().unwrap(); let identity = Identity::create(); - let id = store.add_identity("main", &identity).unwrap(); + let id = store.add_identity("main", &identity, IdentityOrigin::Imported).unwrap(); let list = store.identities().unwrap(); assert_eq!(list.len(), 1); assert_eq!(list[0].name, "main"); assert_eq!(list[0].uid, identity.key().to_pub().get_uid()); assert!(list[0].level >= 8); + assert_eq!(list[0].origin, IdentityOrigin::Imported); let loaded = store.identity(id).unwrap(); assert_eq!(loaded.counter(), identity.counter()); // The same key twice is rejected (uid is unique). - assert!(store.add_identity("dup", &identity).is_err()); + assert!(store.add_identity("dup", &identity, IdentityOrigin::User).is_err()); store.rename_identity(id, "renamed").unwrap(); assert_eq!(store.identities().unwrap()[0].name, "renamed"); store.delete_identity(id).unwrap(); assert!(matches!(store.identity(id), Err(Error::NotFound(..)))); } + #[test] + fn the_default_identity() { + let store = Store::open_in_memory().unwrap(); + assert_eq!(store.default_identity().unwrap(), None); + let made = store.add_identity("Default", &Identity::create(), IdentityOrigin::Created); + let made = made.unwrap(); + let other = store.add_identity("Other", &Identity::create(), IdentityOrigin::Imported); + let other = other.unwrap(); + // The first one is the default. + let default = store.default_identity().unwrap().unwrap(); + assert_eq!((default.id, default.origin), (made, IdentityOrigin::Created)); + // An import moves the default without making the old one the user's. + store.set_default_identity(other, false).unwrap(); + assert_eq!(store.default_identity().unwrap().unwrap().id, other); + assert_eq!(store.identities().unwrap()[0].origin, IdentityOrigin::Created); + // The user's choice makes the created one theirs. + store.set_default_identity(made, true).unwrap(); + let list = store.identities().unwrap(); + assert_eq!((list[0].is_default, list[0].origin), (true, IdentityOrigin::User)); + assert_eq!((list[1].is_default, list[1].origin), (false, IdentityOrigin::Imported)); + assert!(matches!(store.set_default_identity(99, true), Err(Error::NotFound(..)))); + assert_eq!(store.default_identity().unwrap().unwrap().id, made); + } + + /// A database of version 3 learns where its identities came from: the + /// first one, named `Default`, is the one the app made; the others were + /// imported; the first stays the default. + #[test] + fn migrates_version_3_identities() { + let dir = std::env::temp_dir().join(format!("voelin-store-v3-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + let path = dir.join("client.db"); + let (made, imported) = (Identity::create(), Identity::create()); + { + let mut db = rusqlite::Connection::open(&path).unwrap(); + db.execute_batch(SCHEMA_1).unwrap(); + let tx = db.transaction().unwrap(); + crate::chat::migrate_2(&tx).unwrap(); + tx.commit().unwrap(); + db.execute_batch(crate::contacts::SCHEMA_3).unwrap(); + db.pragma_update(None, "user_version", 3).unwrap(); + for (name, identity) in [("Default", &made), ("Main", &imported)] { + let uid = identity.key().to_pub().get_uid(); + let data = serde_json::to_string(identity).unwrap(); + db.execute( + "INSERT INTO identities (name, uid, data) VALUES (?1, ?2, ?3)", + params![name, uid, data], + ) + .unwrap(); + } + } + let store = Store::open(&path).unwrap(); + assert_eq!(store.schema_version().unwrap(), Store::SCHEMA_VERSION); + let list = store.identities().unwrap(); + assert_eq!((list[0].origin, list[0].is_default), (IdentityOrigin::Created, true)); + assert_eq!((list[1].origin, list[1].is_default), (IdentityOrigin::Imported, false)); + // The keys are untouched. + assert_eq!(store.identity(list[1].id).unwrap().counter(), imported.counter()); + drop(store); + std::fs::remove_dir_all(dir).unwrap(); + } + #[test] fn bookmarks_keep_order_and_fields() { let store = Store::open_in_memory().unwrap(); diff --git a/crates/voelin-ui/src/app.rs b/crates/voelin-ui/src/app.rs index 17f2190..9420d28 100644 --- a/crates/voelin-ui/src/app.rs +++ b/crates/voelin-ui/src/app.rs @@ -534,24 +534,24 @@ pub fn run(options: RunOptions) -> Result<()> { let prefs = open_settings(&dir, &options.setting_overrides); let switches = crate::dev::Switches::from_env(); // New identities of the official TeamSpeak clients, on every start (not - // with the sample data of VOELIN_DEMO_UI); with none of our own yet, the - // client's default identity becomes ours. - let had_identity = !store.identities()?.is_empty(); + // 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()) .unwrap_or_else(|e| { warn!(%e, "could not import TeamSpeak identities"); - Vec::new() + Default::default() }) } else { - Vec::new() + Default::default() }; - let identity = match store.identities()?.first() { + let identity = match store.default_identity()? { Some(entry) => store.identity(entry.id)?, None => { // Creating an identity takes a moment (security level 8). let identity = tsclientlib::Identity::create(); - store.add_identity(crate::servers::CREATED_IDENTITY, &identity)?; + let origin = voelin_store::IdentityOrigin::Created; + store.add_identity(crate::servers::CREATED_IDENTITY, &identity, origin)?; identity } }; @@ -636,7 +636,7 @@ pub fn run(options: RunOptions) -> Result<()> { if app.demo { app.start_demo(); } - if let Some(text) = crate::servers::imported_status(&imported, had_identity) { + if let Some(text) = crate::servers::imported_status(&imported) { app.set_status(text); } }); diff --git a/crates/voelin-ui/src/bind/settings.rs b/crates/voelin-ui/src/bind/settings.rs index ee4aa09..d6717a7 100644 --- a/crates/voelin-ui/src/bind/settings.rs +++ b/crates/voelin-ui/src/bind/settings.rs @@ -52,4 +52,10 @@ pub(super) fn wire(ui: &MainWindow) { bridge.on_open_about(|| { with_app(|app| app.load_notices()); }); + bridge.on_use_identity(|id| { + with_app(|app| app.use_identity(id as i64)); + }); + bridge.on_set_identity_import(|on| { + with_app(|app| app.set_identity_import(on)); + }); } diff --git a/crates/voelin-ui/src/dev.rs b/crates/voelin-ui/src/dev.rs index 8f56942..4c6aaa1 100644 --- a/crates/voelin-ui/src/dev.rs +++ b/crates/voelin-ui/src/dev.rs @@ -12,7 +12,7 @@ //! - `VOELIN_DEMO_STREAM=1`: a local test stream in the viewer. //! - `VOELIN_OPEN=[,...]`: open screens on start: `home`, //! `server`, `settings[:
]` (voice, keybinds, streaming, privacy, -//! appearance, or 0-4), `about`, `share`, `bookmark` (add a server; +//! appearance, identities, or 0-5), `about`, `share`, `bookmark` (add a server; //! `bookmark:edit` the current one, Advanced open), //! `emoji` (the picker), `client` (the volume dialog of the first other //! client once connected), `panel` / `no-panel` (the members panel), @@ -108,6 +108,7 @@ fn section(name: &str) -> SettingsSection { "2" | "streaming" => SettingsSection::Streaming, "3" | "privacy" => SettingsSection::Privacy, "4" | "appearance" => SettingsSection::Appearance, + "5" | "identities" => SettingsSection::Identities, _ => SettingsSection::Voice, } } diff --git a/crates/voelin-ui/src/identities.rs b/crates/voelin-ui/src/identities.rs new file mode 100644 index 0000000..39892dd --- /dev/null +++ b/crates/voelin-ui/src/identities.rs @@ -0,0 +1,101 @@ +//! Settings → Identities: the stored identities, which one servers see us +//! as (the default), and the import of the official clients' identities on +//! start (`voelin_core::identity::import_new`, app.rs). + +use slint::ComponentHandle; +use tracing::warn; +use voelin_core::settings::IDENTITY_IMPORT; +use voelin_store::{IdentityEntry, IdentityOrigin}; + +use crate::app::{App, Bridge, IdentityItem, model}; +use crate::vm::avatar; + +/// A row of the identities card. +fn item(entry: &IdentityEntry) -> IdentityItem { + let origin = match entry.origin { + IdentityOrigin::Imported => "From TeamSpeak", + IdentityOrigin::Created | IdentityOrigin::User => "Made in Voelin", + }; + IdentityItem { + id: entry.id as i32, + name: entry.name.clone().into(), + detail: format!("{origin} · level {}", entry.level).into(), + uid: entry.uid.clone().into(), + initials: avatar::initials(&entry.name).into(), + tint: avatar::tint(&entry.name), + is_default: entry.is_default, + } +} + +impl App { + pub(crate) fn refresh_identities(&self) { + let Some(ui) = self.ui.upgrade() else { return }; + let bridge = ui.global::(); + let mut entries = self.store.identities().unwrap_or_default(); + // A store from before defaults were marked: the first one. + let default = self.store.default_identity().ok().flatten().map(|e| e.id); + for entry in &mut entries { + entry.is_default = Some(entry.id) == default; + } + bridge.set_identities(model(entries.iter().map(item).collect())); + bridge.set_identity_import(self.prefs.get(&IDENTITY_IMPORT)); + } + + /// The user's choice of the identity servers see us as, from the next + /// connection on; no import replaces it. + pub(crate) fn use_identity(&mut self, id: i64) { + let result = + self.store.set_default_identity(id, true).and_then(|()| self.store.identity(id)); + match result { + Ok(identity) => { + self.identity = identity; + let name = self + .store + .identities() + .ok() + .and_then(|all| all.into_iter().find(|e| e.id == id)) + .map(|e| e.name) + .unwrap_or_default(); + self.set_status(format!( + "Servers see you as \u{201c}{name}\u{201d} from your next connection" + )); + } + Err(e) => self.set_status(format!("Could not change the identity: {e}")), + } + self.refresh_identities(); + } + + pub(crate) fn set_identity_import(&mut self, on: bool) { + if let Err(e) = self.prefs.set(&IDENTITY_IMPORT, on) { + warn!(%e, "could not store the setting"); + } + self.refresh_identities(); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn rows_say_where_an_identity_came_from() { + let entry = |origin, is_default| IdentityEntry { + id: 3, + name: "Main Nick".into(), + uid: "uid=".into(), + level: 8, + origin, + is_default, + }; + let row = item(&entry(IdentityOrigin::Imported, true)); + assert_eq!((row.id, row.name.as_str(), row.uid.as_str()), (3, "Main Nick", "uid=")); + assert_eq!(row.detail, "From TeamSpeak · level 8"); + assert!(row.is_default); + assert_eq!(row.initials, avatar::initials("Main Nick")); + for origin in [IdentityOrigin::Created, IdentityOrigin::User] { + let row = item(&entry(origin, false)); + assert_eq!(row.detail, "Made in Voelin · level 8"); + assert!(!row.is_default); + } + } +} diff --git a/crates/voelin-ui/src/lib.rs b/crates/voelin-ui/src/lib.rs index ae07dbc..ef10c12 100644 --- a/crates/voelin-ui/src/lib.rs +++ b/crates/voelin-ui/src/lib.rs @@ -7,6 +7,7 @@ mod chat; mod dev; mod emoji; mod hotkey; +mod identities; mod images; mod inbox; mod members; diff --git a/crates/voelin-ui/src/servers.rs b/crates/voelin-ui/src/servers.rs index 14107db..1e9217d 100644 --- a/crates/voelin-ui/src/servers.rs +++ b/crates/voelin-ui/src/servers.rs @@ -3,7 +3,7 @@ use slint::{ComponentHandle, SharedString}; use tracing::warn; -use voelin_core::identity::Found; +use voelin_core::identity::LaunchImport; use voelin_core::{Command, ObserveState, Source, VoiceOptions, VoiceState}; use voelin_store::{Bookmark, QueryConfig, QueryTransport}; @@ -14,20 +14,20 @@ use crate::vm; 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 any. -/// `had_identity`: we had one before, so it stays the default. -pub(crate) fn imported_status(imported: &[Found], had_identity: bool) -> Option { - let first = imported.first()?; - let n = imported.len(); - let names = imported.iter().map(|f| f.nickname.as_str()).collect::>().join(", "); - Some(match (had_identity, n) { - (true, 1) => format!("Imported the identity \u{201c}{names}\u{201d} from TeamSpeak"), - (true, _) => format!("Imported {n} identities from TeamSpeak: {names}"), - (false, 1) => format!("Using your TeamSpeak identity \u{201c}{names}\u{201d}"), - (false, _) => format!( - "Using your TeamSpeak identity \u{201c}{}\u{201d} ({n} imported: {names})", - first.nickname +/// clients at start ([`voelin_core::identity::import_new`]), if anything. +pub(crate) fn imported_status(report: &LaunchImport) -> Option { + let n = report.added.len(); + let names = report.added.iter().map(|f| f.nickname.as_str()).collect::>().join(", "); + let more = if n > 1 { format!(" ({n} imported: {names})") } else { String::new() }; + Some(match &report.default { + Some(f) if report.replaced => format!( + "You now use your TeamSpeak identity \u{201c}{}\u{201d}; your previous one is kept{more}", + f.nickname ), + Some(f) => format!("Using your TeamSpeak identity \u{201c}{}\u{201d}{more}", f.nickname), + None if n == 1 => format!("Imported the identity \u{201c}{names}\u{201d} from TeamSpeak"), + None if n > 1 => format!("Imported {n} identities from TeamSpeak: {names}"), + None => return None, }) } @@ -104,9 +104,9 @@ impl App { /// from TeamSpeak keeps the nickname used there), else the system user's. pub(crate) fn default_nickname(&self) -> String { self.store - .identities() + .default_identity() .ok() - .and_then(|identities| identities.into_iter().next()) + .flatten() .map(|identity| identity.name) .filter(|name| { ![CREATED_IDENTITY, voelin_core::identity::DEFAULT_NICKNAME] @@ -470,6 +470,8 @@ impl App { #[cfg(test)] mod tests { + use voelin_core::identity::Found; + use super::*; #[test] @@ -536,14 +538,24 @@ mod tests { source: "settings.db".into(), selected: false, }; - assert_eq!(imported_status(&[], false), None); + let report = |added: &[&str], default: Option<&str>, replaced| LaunchImport { + added: added.iter().map(|n| found(n)).collect(), + default: default.map(found), + replaced, + }; + assert_eq!(imported_status(&report(&[], None, false)), None); assert_eq!( - imported_status(&[found("Main")], false).unwrap(), + imported_status(&report(&["Main"], Some("Main"), false)).unwrap(), "Using your TeamSpeak identity \u{201c}Main\u{201d}" ); assert_eq!( - imported_status(&[found("Main"), found("Alt")], true).unwrap(), + imported_status(&report(&["Main", "Alt"], None, false)).unwrap(), "Imported 2 identities from TeamSpeak: Main, Alt" ); + // Imported earlier, now ours instead of the one the app made. + assert_eq!( + imported_status(&report(&[], Some("Main"), true)).unwrap(), + "You now use your TeamSpeak identity \u{201c}Main\u{201d}; your previous one is kept" + ); } } diff --git a/crates/voelin-ui/src/settings_page.rs b/crates/voelin-ui/src/settings_page.rs index b0c9bb3..7dc3d17 100644 --- a/crates/voelin-ui/src/settings_page.rs +++ b/crates/voelin-ui/src/settings_page.rs @@ -41,6 +41,7 @@ impl App { bridge.set_h264_enabled(self.settings.openh264); bridge.set_image_cache_usage(crate::images::usage_text().into()); self.refresh_h264(); + self.refresh_identities(); } pub(crate) fn close_settings(&mut self) { diff --git a/crates/voelin-ui/ui/app.slint b/crates/voelin-ui/ui/app.slint index 1362f86..762a5a0 100644 --- a/crates/voelin-ui/ui/app.slint +++ b/crates/voelin-ui/ui/app.slint @@ -212,6 +212,7 @@ export component MainWindow inherits Window { x: (parent.width - self.width) / 2; y: parent.height - self.height - (Nav.narrow ? 140px : 96px); text: Bridge.status-text; + widest: min(560px, parent.width - 32px); } // The member card of the members panel, over everything. diff --git a/crates/voelin-ui/ui/bridge.slint b/crates/voelin-ui/ui/bridge.slint index 0417086..22392f3 100644 --- a/crates/voelin-ui/ui/bridge.slint +++ b/crates/voelin-ui/ui/bridge.slint @@ -276,6 +276,19 @@ export struct ShareForm { auto-accept: bool, } +// An identity in Settings → Identities. +export struct IdentityItem { + id: int, + name: string, + // "From TeamSpeak · level 8" + detail: string, + // The unique id servers know it by (TeamSpeak 3 form). + uid: string, + initials: string, + tint: color, + is-default: bool, +} + export struct AudioForm { // 0 = system default, then the devices. input-index: int, @@ -448,6 +461,12 @@ export global Bridge { in property crash-notice; // Third-party notices, one entry per line, for the About page. in property <[string]> notices; + // Settings → Identities: who servers see us as, and the import of the + // official clients' identities on start (identity.import_from_teamspeak). + in property <[IdentityItem]> identities; + in-out property identity-import; + callback use-identity(int); + callback set-identity-import(bool); callback select-server(int); // The search field of the top bar: filters the channel tree. diff --git a/crates/voelin-ui/ui/components/overlay.slint b/crates/voelin-ui/ui/components/overlay.slint index 9d75603..04dabb5 100644 --- a/crates/voelin-ui/ui/components/overlay.slint +++ b/crates/voelin-ui/ui/components/overlay.slint @@ -234,8 +234,10 @@ export component Toast inherits Rectangle { in property icon: Icons.info; in property timeout: 5s; in-out property shown; + // The widest it gets (e.g. the window less a margin); longer text wraps. + in property widest: 560px; height: shown ? row.preferred-height + 16px : 0px; - width: min(row.preferred-width + 24px, 560px); + width: min(row.preferred-width + 24px, widest); visible: shown; border-radius: Theme.radius-lg; background: Theme.surface-3; @@ -266,7 +268,7 @@ export component Toast inherits Rectangle { text: root.text; color: Theme.text; vertical-alignment: center; - overflow: elide; + wrap: word-wrap; } } } diff --git a/crates/voelin-ui/ui/nav.slint b/crates/voelin-ui/ui/nav.slint index de0ed93..a58388b 100644 --- a/crates/voelin-ui/ui/nav.slint +++ b/crates/voelin-ui/ui/nav.slint @@ -22,6 +22,7 @@ export enum SettingsSection { streaming, privacy, appearance, + identities, } // Tabs of the bottom navigation in the narrow (mobile) layout. diff --git a/crates/voelin-ui/ui/screens/settings.slint b/crates/voelin-ui/ui/screens/settings.slint index e92bf90..b59b981 100644 --- a/crates/voelin-ui/ui/screens/settings.slint +++ b/crates/voelin-ui/ui/screens/settings.slint @@ -4,7 +4,7 @@ import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; import { Bridge } from "../bridge.slint"; import { Nav, SettingsSection } from "../nav.slint"; -import { Icon, Button, ButtonKind, TextField, Field, Select, Toggle, ToggleRow, Slider, SegmentedTabs, Card, Meter, NavItem, Divider, ScrollView } from "../components/index.slint"; +import { Icon, Button, ButtonKind, TextField, Field, Select, Toggle, ToggleRow, Slider, SegmentedTabs, Card, Meter, NavItem, Divider, ScrollView, Avatar, Chip } from "../components/index.slint"; // A label, a control (@children) and a value at the right. component SliderRow inherits HorizontalLayout { @@ -89,6 +89,13 @@ export component SettingsNav inherits VerticalLayout { selected: Nav.settings-section == SettingsSection.appearance; clicked => { Nav.open-settings(SettingsSection.appearance); } } + NavItem { + icon: Icons.user; + text: @tr("Identities"); + subtitle: @tr("Who servers see you as"); + selected: Nav.settings-section == SettingsSection.identities; + clicked => { Nav.open-settings(SettingsSection.identities); } + } Divider { } NavItem { icon: Icons.info; @@ -450,6 +457,77 @@ component AppearanceSection inherits VerticalLayout { } } +// The identities (key pairs; servers know us by their unique ids) and which +// one is used. +component IdentitiesSection inherits VerticalLayout { + alignment: start; + spacing: Theme.space-5; + Card { + title: @tr("Your identities"); + icon: Icons.user; + for identity in Bridge.identities: HorizontalLayout { + spacing: Theme.space-4; + Avatar { + initials: identity.initials; + tint: identity.tint; + label: identity.name; + y: (parent.height - self.height) / 2; + } + VerticalLayout { + alignment: center; + horizontal-stretch: 1; + Text { + text: identity.name; + color: Theme.text; + font-weight: Theme.weight-semibold; + overflow: elide; + } + Text { + text: identity.detail; + color: Theme.text-secondary; + font-size: Theme.font-sm; + overflow: elide; + } + Text { + text: identity.uid; + color: Theme.text-muted; + font-size: Theme.font-xs; + overflow: elide; + } + } + if identity.is-default: Chip { + text: @tr("Default"); + icon: Icons.check; + tint: Theme.accent-text; + fill: Theme.accent-soft; + y: (parent.height - self.height) / 2; + } + if !identity.is-default: Button { + small: true; + text: @tr("Use as default"); + y: (parent.height - self.height) / 2; + clicked => { Bridge.use-identity(identity.id); } + } + } + Hint { + text: @tr("Servers know you by the default identity's unique id, from the next connection on. An identity is a key: whoever has a copy can be you on every server."); + } + } + Card { + title: @tr("TeamSpeak"); + icon: Icons.download; + ToggleRow { + text: @tr("Import identities from TeamSpeak on start"); + description: @tr("Reads the official clients' identities, never changes them"); + checked <=> Bridge.identity-import; + toggled => { Bridge.set-identity-import(Bridge.identity-import); } + } + Hint { + text: @tr("While you use the identity Voelin made for you, the one TeamSpeak uses becomes your default, once."); + } + } +} + // The page of the selected section. export component SettingsPage inherits Rectangle { // Show the section navigation above the content (narrow windows). @@ -457,15 +535,18 @@ export component SettingsPage inherits Rectangle { property section-icon: Nav.settings-section == SettingsSection.voice ? Icons.mic : Nav.settings-section == SettingsSection.keybinds ? Icons.keyboard : Nav.settings-section == SettingsSection.streaming ? Icons.radio - : Nav.settings-section == SettingsSection.privacy ? Icons.shield : Icons.palette; + : Nav.settings-section == SettingsSection.privacy ? Icons.shield + : Nav.settings-section == SettingsSection.identities ? Icons.user : Icons.palette; property section-title: Nav.settings-section == SettingsSection.voice ? @tr("Voice & Video") : Nav.settings-section == SettingsSection.keybinds ? @tr("Keybinds") : Nav.settings-section == SettingsSection.streaming ? @tr("Streaming") - : Nav.settings-section == SettingsSection.privacy ? @tr("Privacy & Safety") : @tr("Appearance"); + : Nav.settings-section == SettingsSection.privacy ? @tr("Privacy & Safety") + : Nav.settings-section == SettingsSection.identities ? @tr("Identities") : @tr("Appearance"); property section-subtitle: Nav.settings-section == SettingsSection.voice ? @tr("Set up your microphone, speakers and voice processing.") : Nav.settings-section == SettingsSection.keybinds ? @tr("Talk with a key, even while other windows have focus.") : Nav.settings-section == SettingsSection.streaming ? @tr("Codecs for watching streams.") - : Nav.settings-section == SettingsSection.privacy ? @tr("What the app keeps on this device.") : @tr("Theme, text size and layout. Changes apply at once."); + : Nav.settings-section == SettingsSection.privacy ? @tr("What the app keeps on this device.") + : Nav.settings-section == SettingsSection.identities ? @tr("Who servers see you as.") : @tr("Theme, text size and layout. Changes apply at once."); accessible-role: AccessibleRole.groupbox; accessible-label: section-title; sv := ScrollView { @@ -475,11 +556,11 @@ export component SettingsPage inherits Rectangle { spacing: Theme.space-5; alignment: start; if root.compact: SegmentedTabs { - model: [@tr("Voice"), @tr("Keys"), @tr("Streams"), @tr("Privacy"), @tr("Look")]; - current-index: Nav.settings-section == SettingsSection.voice ? 0 : Nav.settings-section == SettingsSection.keybinds ? 1 : Nav.settings-section == SettingsSection.streaming ? 2 : Nav.settings-section == SettingsSection.privacy ? 3 : 4; + model: [@tr("Voice"), @tr("Keys"), @tr("Streams"), @tr("Privacy"), @tr("Look"), @tr("ID")]; + current-index: Nav.settings-section == SettingsSection.voice ? 0 : Nav.settings-section == SettingsSection.keybinds ? 1 : Nav.settings-section == SettingsSection.streaming ? 2 : Nav.settings-section == SettingsSection.privacy ? 3 : Nav.settings-section == SettingsSection.identities ? 5 : 4; label: @tr("Settings sections"); selected(i) => { - Nav.open-settings(i == 0 ? SettingsSection.voice : i == 1 ? SettingsSection.keybinds : i == 2 ? SettingsSection.streaming : i == 3 ? SettingsSection.privacy : SettingsSection.appearance); + Nav.open-settings(i == 0 ? SettingsSection.voice : i == 1 ? SettingsSection.keybinds : i == 2 ? SettingsSection.streaming : i == 3 ? SettingsSection.privacy : i == 5 ? SettingsSection.identities : SettingsSection.appearance); } } HorizontalLayout { @@ -510,6 +591,7 @@ export component SettingsPage inherits Rectangle { if Nav.settings-section == SettingsSection.streaming: StreamingSection { } if Nav.settings-section == SettingsSection.privacy: PrivacySection { } if Nav.settings-section == SettingsSection.appearance: AppearanceSection { } + if Nav.settings-section == SettingsSection.identities: IdentitiesSection { } } } } diff --git a/docs/identity.md b/docs/identity.md index fa33050..233fec3 100644 --- a/docs/identity.md +++ b/docs/identity.md @@ -171,14 +171,27 @@ voelinctl identity export [--store ] **On every start** the app does the same as `import --auto` (`voelin_core::identity::import_new`): identities found in the default locations that the client database does not have yet are added, the files -are only read. The identity the official client uses by default (field 5 of -its payload, below) goes in first, so when Voelin has no identity of its own -yet, that one becomes Voelin's default (the first identity) and servers see -the same unique id; otherwise Voelin's default stays. What was imported is -shown once, in the status line (the toast on desktop), by nickname. The -runtime setting `identity.import_from_teamspeak` (default on) turns it off, -e.g. `--set identity.import_from_teamspeak=false`. The sample data of -`VOELIN_DEMO_UI` never imports. +are only read. The user should appear as on the official client, so the +identity the official client uses by default (field 5 of its payload, below; +TeamSpeak 6's before TeamSpeak 3's) becomes Voelin's default when Voelin has +none, or only the one it created on its own the first time it started, +which nobody chose. That happens once: the created identity is kept, and +choosing it again in Settings → Identities makes it the user's own, which +no import replaces; identities that were imported or chosen are never +replaced. The store keeps where each identity came from and which one is the +default (`identities.origin`: `created`, `imported`, `user`; +`identities.is_default`; schema version 4, which marks the first identity +named `Default` of an older database as created). What happened is shown +once in the status line (the toast on desktop), by nickname, e.g. "You now +use your TeamSpeak identity "X"; your previous one is kept". The runtime +setting `identity.import_from_teamspeak` (default on, also in Settings → +Identities) turns it off, e.g. `--set identity.import_from_teamspeak=false`. +The sample data of `VOELIN_DEMO_UI` never imports. + +**Settings → Identities** lists the stored identities with where they came +from, their security level and unique id; "Use as default" picks the one +servers see from the next connection on. `voelinctl identity list` shows +the same (origin and default). - **Import** prints what it found as nickname, unique id and security level — all three are public, everything else in an identity is the private key — diff --git a/docs/screenshots/desktop-settings-identities.png b/docs/screenshots/desktop-settings-identities.png new file mode 100644 index 0000000..85e13ae Binary files /dev/null and b/docs/screenshots/desktop-settings-identities.png differ diff --git a/docs/ui.md b/docs/ui.md index 401d016..bb9700f 100644 --- a/docs/ui.md +++ b/docs/ui.md @@ -227,6 +227,12 @@ server is saved without one and when it connects and one found is stored as if typed. `bookmark` and `bookmark:edit` open it (below). +Settings → Identities (`IdentitiesSection` in `screens/settings.slint`, +`identities.rs`) lists the stored identities, marks the default and has +"Use as default" for the others, plus the switch for importing the +official clients' identities on start ([identity.md](identity.md)). +`settings:identities` opens it. + ## Adding a screen 1. Write the screen in `ui/screens/.slint` from the components @@ -288,7 +294,7 @@ Environment variables (see `src/dev.rs`): - `VOELIN_DEMO_UI=1`: sample servers, channels, members, chat with emoji and a stream, without a server (nothing is stored). -- `VOELIN_OPEN=[,...]`: `home`, `server`, `settings[:voice|keybinds|streaming|privacy|appearance]`, +- `VOELIN_OPEN=[,...]`: `home`, `server`, `settings[:voice|keybinds|streaming|privacy|appearance|identities]`, `about`, `share[:live]`, `bookmark[:edit]`, `emoji`, `client`, `panel`, `no-panel`, `voice`, `pins`, `topics`, `topic:`, `member`, `watch`, `popout` (the server page, above), `tab:` (phone @@ -344,6 +350,7 @@ the window's size so the pointer is not over the window, and passes | ![emoji](screenshots/desktop-emoji-picker.png) | ![volume](screenshots/desktop-client-volume.png) | | ![share](screenshots/desktop-share-dialog.png) | ![sharing](screenshots/desktop-share-live.png) | | ![add server](screenshots/desktop-add-server.png) | ![about](screenshots/desktop-about.png) | +| ![identities](screenshots/desktop-settings-identities.png) | | | Phone layout | | | | | |---|---|---|---|---| diff --git a/tools/voelinctl/src/identity.rs b/tools/voelinctl/src/identity.rs index cb3f136..366739e 100644 --- a/tools/voelinctl/src/identity.rs +++ b/tools/voelinctl/src/identity.rs @@ -25,8 +25,14 @@ fn open_store(path: Option) -> Result { /// Identities in the client database, with the id `export` takes. pub fn list(store: Option) -> Result<()> { - for entry in open_store(store)?.identities()? { - println!("{:>3} {:<20} {} level {}", entry.id, entry.name, entry.uid, entry.level); + let store = open_store(store)?; + let default = store.default_identity()?.map(|entry| entry.id); + for entry in store.identities()? { + let mark = if Some(entry.id) == default { " default" } else { "" }; + println!( + "{:>3} {:<20} {} level {:<3} {:?}{mark}", + entry.id, entry.name, entry.uid, entry.level, entry.origin + ); } Ok(()) }