Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update to ZBus v4 #456

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
634 changes: 342 additions & 292 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions platforms/atspi-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ simplified-api = []
[dependencies]
accesskit = { version = "0.16.1", path = "../../common" }
accesskit_consumer = { version = "0.24.1", path = "../../consumer" }
atspi-common = { version = "0.3.0", default-features = false }
atspi-common = { version = "0.6", default-features = false }
serde = "1.0"
thiserror = "1.0.39"
zvariant = { version = "3", default-features = false }
thiserror = "1.0"
zvariant = { version = "4.2", default-features = false }
6 changes: 3 additions & 3 deletions platforms/unix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ tokio = ["dep:tokio", "dep:tokio-stream", "atspi/tokio", "zbus/tokio"]
[dependencies]
accesskit = { version = "0.16.1", path = "../../common" }
accesskit_atspi_common = { version = "0.9.1", path = "../atspi-common" }
atspi = { version = "0.19", default-features = false }
futures-lite = "1.13"
atspi = { version = "0.22", default-features = false }
futures-lite = "2.3"
serde = "1.0"
zbus = { version = "3.14", default-features = false }
zbus = { version = "4.4", default-features = false }

# async-io support
async-channel = { version = "2.1.1", optional = true }
Expand Down
30 changes: 15 additions & 15 deletions platforms/unix/src/atspi/interfaces/accessible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::collections::HashMap;

use accesskit_atspi_common::{NodeIdOrRoot, PlatformNode, PlatformRoot};
use atspi::{Interface, InterfaceSet, Role, StateSet};
use zbus::{fdo, names::OwnedUniqueName};
use zbus::{fdo, interface, names::OwnedUniqueName};

use super::map_root_error;
use crate::atspi::{ObjectId, OwnedObjectAddress};
Expand All @@ -27,19 +27,19 @@ impl NodeAccessibleInterface {
}
}

#[dbus_interface(name = "org.a11y.atspi.Accessible")]
#[interface(name = "org.a11y.atspi.Accessible")]
impl NodeAccessibleInterface {
#[dbus_interface(property)]
#[zbus(property)]
fn name(&self) -> fdo::Result<String> {
self.node.name().map_err(self.map_error())
}

#[dbus_interface(property)]
#[zbus(property)]
fn description(&self) -> fdo::Result<String> {
self.node.description().map_err(self.map_error())
}

#[dbus_interface(property)]
#[zbus(property)]
fn parent(&self) -> fdo::Result<OwnedObjectAddress> {
self.node.parent().map_err(self.map_error()).map(|parent| {
match parent {
Expand All @@ -53,17 +53,17 @@ impl NodeAccessibleInterface {
})
}

#[dbus_interface(property)]
#[zbus(property)]
fn child_count(&self) -> fdo::Result<i32> {
self.node.child_count().map_err(self.map_error())
}

#[dbus_interface(property)]
#[zbus(property)]
fn locale(&self) -> &str {
""
}

#[dbus_interface(property)]
#[zbus(property)]
fn accessible_id(&self) -> fdo::Result<String> {
self.node.accessible_id().map_err(self.map_error())
}
Expand Down Expand Up @@ -135,34 +135,34 @@ impl RootAccessibleInterface {
}
}

#[dbus_interface(name = "org.a11y.atspi.Accessible")]
#[interface(name = "org.a11y.atspi.Accessible")]
impl RootAccessibleInterface {
#[dbus_interface(property)]
#[zbus(property)]
fn name(&self) -> fdo::Result<String> {
self.root.name().map_err(map_root_error)
}

#[dbus_interface(property)]
#[zbus(property)]
fn description(&self) -> &str {
""
}

#[dbus_interface(property)]
#[zbus(property)]
fn parent(&self) -> OwnedObjectAddress {
OwnedObjectAddress::null()
}

#[dbus_interface(property)]
#[zbus(property)]
fn child_count(&self) -> fdo::Result<i32> {
self.root.child_count().map_err(map_root_error)
}

#[dbus_interface(property)]
#[zbus(property)]
fn locale(&self) -> &str {
""
}

#[dbus_interface(property)]
#[zbus(property)]
fn accessible_id(&self) -> &str {
""
}
Expand Down
6 changes: 3 additions & 3 deletions platforms/unix/src/atspi/interfaces/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// the LICENSE-MIT file), at your option.

use accesskit_atspi_common::{Action, PlatformNode};
use zbus::{dbus_interface, fdo};
use zbus::{fdo, interface};

pub(crate) struct ActionInterface(PlatformNode);

Expand All @@ -18,9 +18,9 @@ impl ActionInterface {
}
}

#[dbus_interface(name = "org.a11y.atspi.Action")]
#[interface(name = "org.a11y.atspi.Action")]
impl ActionInterface {
#[dbus_interface(property)]
#[zbus(property)]
fn n_actions(&self) -> fdo::Result<i32> {
self.0.n_actions().map_err(self.map_error())
}
Expand Down
14 changes: 7 additions & 7 deletions platforms/unix/src/atspi/interfaces/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@
// the LICENSE-MIT file), at your option.

use accesskit_atspi_common::PlatformRoot;
use zbus::fdo;
use zbus::{fdo, interface};

use super::map_root_error;

pub(crate) struct ApplicationInterface(pub PlatformRoot);

#[dbus_interface(name = "org.a11y.atspi.Application")]
#[interface(name = "org.a11y.atspi.Application")]
impl ApplicationInterface {
#[dbus_interface(property)]
#[zbus(property)]
fn toolkit_name(&self) -> fdo::Result<String> {
self.0.toolkit_name().map_err(map_root_error)
}

#[dbus_interface(property)]
#[zbus(property)]
fn version(&self) -> fdo::Result<String> {
self.0.toolkit_version().map_err(map_root_error)
}

#[dbus_interface(property)]
#[zbus(property)]
fn atspi_version(&self) -> &str {
"2.1"
}

#[dbus_interface(property)]
#[zbus(property)]
fn id(&self) -> fdo::Result<i32> {
self.0.id().map_err(map_root_error)
}

#[dbus_interface(property)]
#[zbus(property)]
fn set_id(&mut self, id: i32) -> fdo::Result<()> {
self.0.set_id(id).map_err(map_root_error)
}
Expand Down
4 changes: 2 additions & 2 deletions platforms/unix/src/atspi/interfaces/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use accesskit_atspi_common::{PlatformNode, Rect};
use atspi::{CoordType, Layer};
use zbus::{fdo, names::OwnedUniqueName};
use zbus::{fdo, interface, names::OwnedUniqueName};

use crate::atspi::{ObjectId, OwnedObjectAddress};

Expand All @@ -24,7 +24,7 @@ impl ComponentInterface {
}
}

#[dbus_interface(name = "org.a11y.atspi.Component")]
#[interface(name = "org.a11y.atspi.Component")]
impl ComponentInterface {
fn contains(&self, x: i32, y: i32, coord_type: CoordType) -> fdo::Result<bool> {
self.node
Expand Down
8 changes: 4 additions & 4 deletions platforms/unix/src/atspi/interfaces/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use accesskit_atspi_common::{PlatformNode, Rect};
use atspi::{CoordType, Granularity, ScrollType};
use std::collections::HashMap;
use zbus::fdo;
use zbus::{fdo, interface};

pub(crate) struct TextInterface {
node: PlatformNode,
Expand All @@ -22,14 +22,14 @@ impl TextInterface {
}
}

#[dbus_interface(name = "org.a11y.atspi.Text")]
#[interface(name = "org.a11y.atspi.Text")]
impl TextInterface {
#[dbus_interface(property)]
#[zbus(property)]
fn character_count(&self) -> fdo::Result<i32> {
self.node.character_count().map_err(self.map_error())
}

#[dbus_interface(property)]
#[zbus(property)]
fn caret_offset(&self) -> fdo::Result<i32> {
self.node.caret_offset().map_err(self.map_error())
}
Expand Down
14 changes: 7 additions & 7 deletions platforms/unix/src/atspi/interfaces/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// the LICENSE-MIT file), at your option.

use accesskit_atspi_common::PlatformNode;
use zbus::fdo;
use zbus::{fdo, interface};

pub(crate) struct ValueInterface {
node: PlatformNode,
Expand All @@ -20,29 +20,29 @@ impl ValueInterface {
}
}

#[dbus_interface(name = "org.a11y.atspi.Value")]
#[interface(name = "org.a11y.atspi.Value")]
impl ValueInterface {
#[dbus_interface(property)]
#[zbus(property)]
fn minimum_value(&self) -> fdo::Result<f64> {
self.node.minimum_value().map_err(self.map_error())
}

#[dbus_interface(property)]
#[zbus(property)]
fn maximum_value(&self) -> fdo::Result<f64> {
self.node.maximum_value().map_err(self.map_error())
}

#[dbus_interface(property)]
#[zbus(property)]
fn minimum_increment(&self) -> fdo::Result<f64> {
self.node.minimum_increment().map_err(self.map_error())
}

#[dbus_interface(property)]
#[zbus(property)]
fn current_value(&self) -> fdo::Result<f64> {
self.node.current_value().map_err(self.map_error())
}

#[dbus_interface(property)]
#[zbus(property)]
fn set_current_value(&mut self, value: f64) -> fdo::Result<()> {
self.node.set_current_value(value).map_err(self.map_error())
}
Expand Down
11 changes: 6 additions & 5 deletions platforms/unix/src/atspi/object_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
// the LICENSE-APACHE file) or the MIT license (found in
// the LICENSE-MIT file), at your option.

use atspi::Accessible;
use atspi::ObjectRef;
use serde::{Deserialize, Serialize};
use zbus::{
names::UniqueName,
zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value},
zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Str, Type, Value},
};

// https://gnome.pages.gitlab.gnome.org/at-spi2-core/libatspi/const.DBUS_PATH_NULL.html
const NULL_PATH: &str = "/org/a11y/atspi/null";

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, OwnedValue, Type, Value)]
Expand All @@ -34,10 +35,10 @@ impl OwnedObjectAddress {
}
}

impl From<Accessible> for OwnedObjectAddress {
fn from(object: Accessible) -> Self {
impl From<ObjectRef> for OwnedObjectAddress {
fn from(object: ObjectRef) -> Self {
Self {
bus_name: object.name,
bus_name: Str::from(object.name).into(),
path: object.path,
}
}
Expand Down
3 changes: 0 additions & 3 deletions platforms/unix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
/// - If you use tokio, make sure to enable the `tokio` feature of this crate.
/// - If you use another async runtime or if you don't use one at all, the default feature will suit your needs.

#[macro_use]
extern crate zbus;

#[cfg(all(not(feature = "async-io"), not(feature = "tokio")))]
compile_error!("Either \"async-io\" (default) or \"tokio\" feature must be enabled.");

Expand Down