diff --git a/atspi-common/src/cache.rs b/atspi-common/src/cache.rs index 8cc00321..dac0b4f6 100644 --- a/atspi-common/src/cache.rs +++ b/atspi-common/src/cache.rs @@ -4,7 +4,7 @@ use crate::{InterfaceSet, ObjectRef, Role, StateSet}; use serde::{Deserialize, Serialize}; use zbus_lockstep_macros::validate; -use zbus_names::BusName; +use zbus_names::UniqueName; use zvariant::{ObjectPath, Type}; /// The item type provided by `Cache:Add` signals @@ -38,19 +38,19 @@ impl Default for CacheItem { fn default() -> Self { Self { object: ObjectRef { - name: BusName::from_static_str(":0.0").unwrap().into(), + name: UniqueName::from_static_str(":0.0").unwrap().into(), path: ObjectPath::from_static_str("/org/a11y/atspi/accessible/object") .unwrap() .into(), }, app: ObjectRef { - name: BusName::from_static_str(":0.0").unwrap().into(), + name: UniqueName::from_static_str(":0.0").unwrap().into(), path: ObjectPath::from_static_str("/org/a11y/atspi/accessible/application") .unwrap() .into(), }, parent: ObjectRef { - name: BusName::from_static_str(":0.0").unwrap().into(), + name: UniqueName::from_static_str(":0.0").unwrap().into(), path: ObjectPath::from_static_str("/org/a11y/atspi/accessible/parent") .unwrap() .into(), @@ -93,19 +93,19 @@ impl Default for LegacyCacheItem { fn default() -> Self { Self { object: ObjectRef { - name: BusName::from_static_str(":0.0").unwrap().into(), + name: UniqueName::from_static_str(":0.0").unwrap().into(), path: ObjectPath::from_static_str("/org/a11y/atspi/accessible/object") .unwrap() .into(), }, app: ObjectRef { - name: BusName::from_static_str(":0.0").unwrap().into(), + name: UniqueName::from_static_str(":0.0").unwrap().into(), path: ObjectPath::from_static_str("/org/a11y/atspi/accessible/application") .unwrap() .into(), }, parent: ObjectRef { - name: BusName::from_static_str(":0.0").unwrap().into(), + name: UniqueName::from_static_str(":0.0").unwrap().into(), path: ObjectPath::from_static_str("/org/a11y/atspi/accessible/parent") .unwrap() .into(), diff --git a/atspi-common/src/events/document.rs b/atspi-common/src/events/document.rs index 7d13aaaf..a8d4518e 100644 --- a/atspi-common/src/events/document.rs +++ b/atspi-common/src/events/document.rs @@ -3,7 +3,7 @@ use crate::{ events::{BusProperties, EventBodyOwned, HasMatchRule, HasRegistryEventString, ObjectRef}, Event, EventProperties, EventTypeProperties, }; -use zbus_names::BusName; +use zbus_names::UniqueName; use zvariant::{ObjectPath, OwnedValue}; #[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] @@ -76,7 +76,7 @@ impl EventProperties for DocumentEvents { Self::PageChanged(inner) => inner.path(), } } - fn sender(&self) -> BusName<'_> { + fn sender(&self) -> UniqueName<'_> { match self { Self::LoadComplete(inner) => inner.sender(), Self::Reload(inner) => inner.sender(), diff --git a/atspi-common/src/events/focus.rs b/atspi-common/src/events/focus.rs index 25831bd0..5f177561 100644 --- a/atspi-common/src/events/focus.rs +++ b/atspi-common/src/events/focus.rs @@ -3,7 +3,7 @@ use crate::{ events::{BusProperties, EventBodyOwned, HasMatchRule, HasRegistryEventString, ObjectRef}, Event, EventProperties, EventTypeProperties, }; -use zbus_names::BusName; +use zbus_names::UniqueName; use zvariant::{ObjectPath, OwnedValue}; #[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] @@ -41,7 +41,7 @@ impl EventProperties for FocusEvents { Self::Focus(inner) => inner.path(), } } - fn sender(&self) -> BusName<'_> { + fn sender(&self) -> UniqueName<'_> { match self { Self::Focus(inner) => inner.sender(), } diff --git a/atspi-common/src/events/keyboard.rs b/atspi-common/src/events/keyboard.rs index 4b2d5b3c..2e196aad 100644 --- a/atspi-common/src/events/keyboard.rs +++ b/atspi-common/src/events/keyboard.rs @@ -3,7 +3,7 @@ use crate::{ events::{BusProperties, EventBodyOwned, HasMatchRule, HasRegistryEventString, ObjectRef}, Event, EventProperties, EventTypeProperties, }; -use zbus_names::BusName; +use zbus_names::UniqueName; use zvariant::{ObjectPath, OwnedValue}; #[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] @@ -41,7 +41,7 @@ impl EventProperties for KeyboardEvents { Self::Modifiers(inner) => inner.path(), } } - fn sender(&self) -> BusName<'_> { + fn sender(&self) -> UniqueName<'_> { match self { Self::Modifiers(inner) => inner.sender(), } diff --git a/atspi-common/src/events/mod.rs b/atspi-common/src/events/mod.rs index d25b9829..fba66441 100644 --- a/atspi-common/src/events/mod.rs +++ b/atspi-common/src/events/mod.rs @@ -28,7 +28,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use zbus_lockstep_macros::validate; -use zbus_names::{BusName, OwnedBusName, OwnedUniqueName, UniqueName}; +use zbus_names::{OwnedUniqueName, UniqueName}; #[cfg(feature = "zbus")] use zvariant::OwnedObjectPath; use zvariant::{ObjectPath, OwnedValue, Signature, Type, Value}; @@ -60,7 +60,7 @@ pub struct EventBody<'a, T> { /// Map of string to an any type. /// This is not used for anything, but it is defined by AT-SPI. #[serde(borrow)] - pub properties: HashMap, Value<'a>>, + pub properties: HashMap, Value<'a>>, } impl Type for EventBody<'_, T> { @@ -120,7 +120,7 @@ pub struct EventBodyOwned { pub any_data: OwnedValue, /// A map of properties. /// Not in use. - pub properties: HashMap, + pub properties: HashMap, } impl From for EventBodyOwned { @@ -301,7 +301,7 @@ impl EventProperties for Event { Self::Listener(inner) => inner.path(), } } - fn sender(&self) -> BusName<'_> { + fn sender(&self) -> UniqueName<'_> { match self { Self::Document(inner) => inner.sender(), Self::Focus(inner) => inner.sender(), @@ -387,7 +387,7 @@ impl EventProperties for CacheEvents { Self::Remove(inner) => inner.path(), } } - fn sender(&self) -> BusName<'_> { + fn sender(&self) -> UniqueName<'_> { match self { Self::Add(inner) => inner.sender(), Self::LegacyAdd(inner) => inner.sender(), @@ -572,8 +572,7 @@ impl TryFrom<&zbus::Message> for ObjectRef { let owned_path: OwnedObjectPath = path.clone().into(); let sender: UniqueName<'_> = header.sender().expect("No sender in header").into(); - let bus_name: BusName<'_> = sender.into(); - let name: OwnedBusName = bus_name.to_owned().into(); + let name: OwnedUniqueName = sender.to_owned().into(); Ok(ObjectRef { name, path: owned_path }) } @@ -670,7 +669,7 @@ impl EventProperties for EventListenerEvents { Self::Deregistered(inner) => inner.path(), } } - fn sender(&self) -> BusName<'_> { + fn sender(&self) -> UniqueName<'_> { match self { Self::Registered(inner) => inner.sender(), Self::Deregistered(inner) => inner.sender(), @@ -921,7 +920,7 @@ assert_obj_safe!(EventTypeProperties); /// /// This trait *is* object-safe. pub trait EventProperties { - fn sender(&self) -> BusName<'_>; + fn sender(&self) -> UniqueName<'_>; fn path(&self) -> ObjectPath<'_>; fn object_ref(&self) -> ObjectRef { ObjectRef { name: self.sender().into(), path: self.path().into() } diff --git a/atspi-common/src/events/mouse.rs b/atspi-common/src/events/mouse.rs index b5de3f0e..75d46bc4 100644 --- a/atspi-common/src/events/mouse.rs +++ b/atspi-common/src/events/mouse.rs @@ -3,7 +3,7 @@ use crate::{ events::{BusProperties, EventBodyOwned, HasMatchRule, HasRegistryEventString, ObjectRef}, Event, EventProperties, EventTypeProperties, }; -use zbus_names::BusName; +use zbus_names::UniqueName; use zvariant::ObjectPath; #[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] @@ -55,7 +55,7 @@ impl EventProperties for MouseEvents { Self::Button(inner) => inner.path(), } } - fn sender(&self) -> BusName<'_> { + fn sender(&self) -> UniqueName<'_> { match self { Self::Abs(inner) => inner.sender(), Self::Rel(inner) => inner.sender(), diff --git a/atspi-common/src/events/object.rs b/atspi-common/src/events/object.rs index e6d5bbcc..bed64eae 100644 --- a/atspi-common/src/events/object.rs +++ b/atspi-common/src/events/object.rs @@ -5,7 +5,7 @@ use crate::{ events::{BusProperties, EventBodyOwned, HasMatchRule, HasRegistryEventString, ObjectRef}, Event, EventProperties, EventTypeProperties, State, }; -use zbus_names::BusName; +use zbus_names::UniqueName; use zvariant::{ObjectPath, OwnedValue, Value}; #[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] @@ -190,7 +190,7 @@ impl EventProperties for ObjectEvents { Self::TextCaretMoved(inner) => inner.path(), } } - fn sender(&self) -> BusName<'_> { + fn sender(&self) -> UniqueName<'_> { match self { Self::PropertyChange(inner) => inner.sender(), Self::BoundsChanged(inner) => inner.sender(), diff --git a/atspi-common/src/events/terminal.rs b/atspi-common/src/events/terminal.rs index 2a5749a9..14105922 100644 --- a/atspi-common/src/events/terminal.rs +++ b/atspi-common/src/events/terminal.rs @@ -3,7 +3,7 @@ use crate::{ events::{BusProperties, EventBodyOwned, HasMatchRule, HasRegistryEventString, ObjectRef}, Event, EventProperties, EventTypeProperties, }; -use zbus_names::BusName; +use zbus_names::UniqueName; use zvariant::ObjectPath; /// All events related to the `org.a11y.atspi.Event.Terminal` interface. @@ -70,7 +70,7 @@ impl EventProperties for TerminalEvents { Self::CharWidthChanged(inner) => inner.path(), } } - fn sender(&self) -> BusName<'_> { + fn sender(&self) -> UniqueName<'_> { match self { Self::LineChanged(inner) => inner.sender(), Self::ColumnCountChanged(inner) => inner.sender(), diff --git a/atspi-common/src/events/window.rs b/atspi-common/src/events/window.rs index 30f64df4..2290c6a5 100644 --- a/atspi-common/src/events/window.rs +++ b/atspi-common/src/events/window.rs @@ -3,7 +3,7 @@ use crate::{ events::{BusProperties, EventBodyOwned, HasMatchRule, HasRegistryEventString, ObjectRef}, Event, EventProperties, EventTypeProperties, }; -use zbus_names::BusName; +use zbus_names::UniqueName; use zvariant::ObjectPath; /// All events on the `org.a11y.atspi.Event.Window` interface. @@ -168,7 +168,7 @@ impl EventProperties for WindowEvents { Self::Restyle(inner) => inner.path(), } } - fn sender(&self) -> BusName<'_> { + fn sender(&self) -> UniqueName<'_> { match self { Self::PropertyChange(inner) => inner.sender(), Self::Minimize(inner) => inner.sender(), diff --git a/atspi-common/src/macros.rs b/atspi-common/src/macros.rs index 2d693649..f328ebb7 100644 --- a/atspi-common/src/macros.rs +++ b/atspi-common/src/macros.rs @@ -9,7 +9,7 @@ /// /// ```ignore /// impl EventProperties for TextCaretMovedEvent { -/// fn sender(&self) -> BusName<'_> { +/// fn sender(&self) -> UniqueName<'_> { /// self.item.name.as_ref() /// } /// fn path(&self) -> ObjectPath<'_> { @@ -20,7 +20,7 @@ macro_rules! impl_event_properties { ($type:ty) => { impl EventProperties for $type { - fn sender(&self) -> BusName<'_> { + fn sender(&self) -> UniqueName<'_> { self.item.name.as_ref() } fn path(&self) -> ObjectPath<'_> { @@ -118,9 +118,9 @@ macro_rules! impl_from_user_facing_event_for_interface_event_enum { /// Expands to a conversion given two arguments, /// 1. the user facing event type `(inner_type)` -/// which relies on a conversion to its interface variant enum type variant. +/// which relies on a conversion to its interface variant enum type variant. /// 2. the outer `Event::)>` wrapper., -/// the enum type and outtermost variant. +/// the enum type and outtermost variant. /// /// ```ignore user facing type, outer event variant /// impl_from_user_facing_type_for_event_enum!(StateChangedEvent, Event::Object); diff --git a/atspi-common/src/object_ref.rs b/atspi-common/src/object_ref.rs index 045e1a2f..e3f765ab 100644 --- a/atspi-common/src/object_ref.rs +++ b/atspi-common/src/object_ref.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; use zbus_lockstep_macros::validate; -use zbus_names::{BusName, OwnedBusName}; +use zbus_names::{OwnedUniqueName, UniqueName}; use zvariant::{ObjectPath, OwnedObjectPath, Signature, Type}; pub const OBJECT_REF_SIGNATURE: Signature<'_> = Signature::from_static_str_unchecked("(so)"); @@ -16,14 +16,14 @@ pub const OBJECT_REF_SIGNATURE: Signature<'_> = Signature::from_static_str_unche #[validate(signal: "Available")] #[derive(Debug, Clone, Serialize, Deserialize, Type, PartialEq, Eq, Hash)] pub struct ObjectRef { - pub name: OwnedBusName, + pub name: OwnedUniqueName, pub path: OwnedObjectPath, } impl Default for ObjectRef { fn default() -> Self { ObjectRef { - name: BusName::from_static_str(":0.0").unwrap().into(), + name: UniqueName::from_static_str(":0.0").unwrap().into(), path: ObjectPath::from_static_str("/org/a11y/atspi/accessible/null") .unwrap() .into(), diff --git a/atspi-common/tests/tests.rs b/atspi-common/tests/tests.rs index de9a9cfe..73c38118 100644 --- a/atspi-common/tests/tests.rs +++ b/atspi-common/tests/tests.rs @@ -5,7 +5,7 @@ use atspi_connection::AccessibilityConnection; use std::time::Duration; use tokio_stream::StreamExt; use zbus::Message; -use zbus_names::OwnedBusName; +use zbus_names::OwnedUniqueName; use zvariant::OwnedObjectPath; #[tokio::test] @@ -19,7 +19,7 @@ async fn test_recv_remove_accessible() { let msg = { let remove_body = ObjectRef { - name: OwnedBusName::try_from(":69.420").unwrap(), + name: OwnedUniqueName::try_from(":69.420").unwrap(), path: OwnedObjectPath::try_from("/org/a11y/atspi/accessible/remove").unwrap(), }; diff --git a/atspi-proxies/src/accessible.rs b/atspi-proxies/src/accessible.rs index 551469f2..4f020dd0 100644 --- a/atspi-proxies/src/accessible.rs +++ b/atspi-proxies/src/accessible.rs @@ -233,7 +233,7 @@ impl TryFrom> for ObjectRef { type Error = AtspiError; fn try_from(proxy: AccessibleProxy<'_>) -> Result { Ok(ObjectRef { - name: proxy.inner().destination().to_owned().into(), + name: proxy.inner().destination().as_str().try_into()?, path: proxy.inner().path().to_string().try_into()?, }) } @@ -243,7 +243,7 @@ impl TryFrom<&AccessibleProxy<'_>> for ObjectRef { type Error = AtspiError; fn try_from(proxy: &AccessibleProxy<'_>) -> Result { Ok(ObjectRef { - name: proxy.inner().destination().to_owned().into(), + name: proxy.inner().destination().as_str().try_into()?, path: proxy.inner().path().to_string().try_into()?, }) } @@ -254,7 +254,7 @@ pub trait ObjectRefExt { /// /// # Errors /// - /// `BusName` or `ObjectPath` are assumed to be valid because they are obtained from a valid `ObjectRef`. + /// `UniqueName` or `ObjectPath` are assumed to be valid because they are obtained from a valid `ObjectRef`. /// If the builder is lacking the necessary parameters to build a proxy. See [`zbus::ProxyBuilder::build`]. /// If this method fails, you may want to check the `AccessibleProxy` default values for missing / invalid parameters. fn as_accessible_proxy( diff --git a/atspi/Cargo.toml b/atspi/Cargo.toml index c894fb44..80b09496 100644 --- a/atspi/Cargo.toml +++ b/atspi/Cargo.toml @@ -32,8 +32,7 @@ tracing = ["atspi-connection/tracing"] atspi-common = { path = "../atspi-common", version = "0.5.0", default-features = false } atspi-connection = { path = "../atspi-connection", version = "0.5.0", default-features = false, optional = true } atspi-proxies = { path = "../atspi-proxies", version = "0.5.0", default-features = false, optional = true } -zbus = { workspace = true, optional = true } - +zbus = { workspace = true, default-features = false, optional = true } [[bench]] name = "event_parsing"