odilia-app / atspi

A fast, zbus-based, permissively licensed AT-SPI library written in pure Rust!
Apache License 2.0
32 stars 6 forks source link

Cache proxy only supports "new" `GetItems` signature #83

Closed Ablu closed 1 year ago

Ablu commented 1 year ago

The crate expects a((so)(so)(so)iiassusau) as signature. But at least at-spi2-core is still exporting the old version of a((so)(so)(so)a(so)assusau) (probably for compatibility): https://gitlab.gnome.org/GNOME/at-spi2-core/-/blob/b10fcf21b1ef49dd3d6297ac657434ece3b23578/registryd/registry.c#L864-876

Reference to comment that explains the history: https://gitlab.gnome.org/GNOME/at-spi2-core/-/blob/6364851c4b92ab4ed3a3abb0af654f7a5dc9c519/xml/Cache.xml#L72-78

So probably both versions should be supported.

Reproducer:

use std::error::Error;

use atspi::{cache::CacheProxy, zbus::zvariant::ObjectPath};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let atspi = atspi::AccessibilityConnection::open().await?;
    let cache = CacheProxy::builder(atspi.connection())
        .destination(atspi.destination())?
        .path(ObjectPath::from_static_str("/org/a11y/atspi/cache")?)?
        .build()
        .await?;
    let items = cache.get_items().await?;
    dbg!(items);
    Ok(())
}

Error:

Error: Variant(SignatureMismatch(Signature("a((so)(so)(so)a(so)assusau)"), "`a((so)(so)(so)iiassusau)`"))
luukvanderduim commented 1 year ago

Thanks for the detailed report.

This is interesting in the sense that at-spi2's registryd returns CacheItems in a layout they deprecated 8 years ago. Maybe for compatibility, but keeping it this way at-spi more or less justifies QT for not moving to the protocols stipulated layout. But it also goes the other way arround. The fact that Qt still uses it, makes perhaps that AT-SPI2 is more or less forced? However they should be notified as this interface is not too often used, nevertheless the use it has is really important.

We likely want a fix to support both signatures, I am looking into how to fix this as we speak.

I am also curious to hear about what items registryd has cached. If these are a collection of items of all servers on the bus, that would be nice for ATs which want to initialize their own cache.