Update to latest crates

This commit is contained in:
Marc-André Lureau 2021-08-12 22:52:32 +04:00
parent 7431fbab65
commit 998a8e7ddd
9 changed files with 47 additions and 31 deletions

View File

@ -11,15 +11,18 @@ members = [
default-members = ["qemu-rdw"]
[patch.crates-io]
zbus = { git = 'https://gitlab.freedesktop.org/dbus/zbus.git' }
zvariant = { git = 'https://gitlab.freedesktop.org/dbus/zbus.git' }
vnc = { git = 'https://github.com/elmarco/rust-vnc', branch = 'server' }
usbredirhost = { path = "../usbredir-rs/usbredirhost" }
libusb1-sys = { path = "../rusb/libusb1-sys" }
rusb = { path = "../rusb" }
zbus = { path = "../zbus/zbus" }
zvariant = { path = "../zbus/zvariant" }
[patch."https://gitlab.gnome.org/malureau/rdw.git"]
rdw = { path = '/home/elmarco/src/rdw/rdw' }
rdw = { path = '../rdw/rdw' }
[patch."https://github.com/gtk-rs/gtk4-rs"]
gdk4-wayland = { path = '/home/elmarco/src/gtk4-rs/gdk4-wayland' }
gdk4-x11 = { path = '/home/elmarco/src/gtk4-rs/gdk4-x11' }
gtk4 = { path = '/home/elmarco/src/gtk4-rs/gtk4' }
gtk4-sys = { path = '/home/elmarco/src/gtk4-rs/gtk4/sys' }
gdk4-wayland = { path = '../gtk4-rs/gdk4-wayland' }
gdk4-x11 = { path = '../gtk4-rs/gdk4-x11' }
gtk4 = { path = '../gtk4-rs/gtk4' }
gtk4-sys = { path = '../gtk4-rs/gtk4/sys' }

View File

@ -6,7 +6,7 @@ use std::sync::mpsc::{self, Receiver, SendError};
use std::sync::Arc;
use std::{os::unix::io::AsRawFd, thread};
use zbus::{dbus_interface, dbus_proxy, export::zvariant::Fd};
use zbus::{dbus_interface, dbus_proxy, zvariant::Fd};
use crate::{EventSender, Result};
@ -267,9 +267,10 @@ impl Audio {
// TODO: we may want to generalize interface detection
let ip = zbus::fdo::AsyncIntrospectableProxy::builder(conn)
.destination("org.qemu")
.unwrap()
.path("/org/qemu/Display1")
.unwrap()
.build_async()
.build()
.await
.unwrap();
let introspect = zbus::xml::Node::from_str(&ip.introspect().await.unwrap()).unwrap();
@ -288,7 +289,10 @@ impl Audio {
.await?;
let _thread = thread::spawn(move || {
let c = zbus::Connection::new_unix_client(p1, false).unwrap();
let c = zbus::ConnectionBuilder::unix_stream(p1)
.p2p()
.build()
.unwrap();
let mut s = zbus::ObjectServer::new(&c);
let listener = AudioOutListener::new(tx);
let err = listener.err();
@ -317,7 +321,10 @@ impl Audio {
.await?;
let _thread = thread::spawn(move || {
let c = zbus::Connection::new_unix_client(p1, false).unwrap();
let c = zbus::ConnectionBuilder::unix_stream(p1)
.p2p()
.build()
.unwrap();
let mut s = zbus::ObjectServer::new(&c);
let listener = AudioInListener::new(tx);
let err = listener.err();

View File

@ -1,6 +1,6 @@
use std::convert::TryFrom;
use zbus::dbus_proxy;
use zbus::export::zvariant::{Fd, ObjectPath};
use zbus::zvariant::{Fd, ObjectPath};
use crate::Result;
@ -37,7 +37,7 @@ impl Chardev {
let obj_path = ObjectPath::try_from(format!("/org/qemu/Display1/Chardev_{}", id))?;
let proxy = AsyncChardevProxy::builder(conn)
.path(&obj_path)?
.build_async()
.build()
.await?;
Ok(Self { proxy })
}

View File

@ -1,9 +1,9 @@
use once_cell::sync::OnceCell;
use serde_repr::{Deserialize_repr, Serialize_repr};
use std::convert::TryFrom;
use std::sync::mpsc::{channel, SendError, Sender};
use std::sync::mpsc::{channel, Sender};
use std::sync::Arc;
use zbus::{dbus_interface, dbus_proxy, export::zvariant::ObjectPath};
use zbus::{dbus_interface, dbus_proxy, zvariant::ObjectPath};
use zvariant::derive::Type;
use crate::{EventSender, Result};
@ -60,7 +60,7 @@ pub enum ClipboardEvent {
#[derive(Debug)]
pub(crate) struct ClipboardListener<E: EventSender<Event = ClipboardEvent>> {
tx: E,
err: Arc<OnceCell<SendError<ClipboardEvent>>>,
err: Arc<OnceCell<String>>,
}
#[dbus_interface(name = "org.qemu.Display1.Clipboard")]
@ -112,11 +112,11 @@ impl<E: 'static + EventSender<Event = ClipboardEvent>> ClipboardListener<E> {
fn send(&mut self, event: ClipboardEvent) {
if let Err(e) = self.tx.send_event(event) {
let _ = self.err.set(e);
let _ = self.err.set(e.to_string());
}
}
pub fn err(&self) -> Arc<OnceCell<SendError<ClipboardEvent>>> {
pub fn err(&self) -> Arc<OnceCell<String>> {
self.err.clone()
}
}
@ -134,7 +134,7 @@ impl Clipboard {
let obj_path = ObjectPath::try_from("/org/qemu/Display1/Clipboard")?;
let proxy = AsyncClipboardProxy::builder(conn)
.path(&obj_path)?
.build_async()
.build()
.await?;
Ok(Self {
conn: conn.clone(),

View File

@ -5,7 +5,7 @@ use std::{os::unix::io::AsRawFd, thread};
use zbus::{
dbus_proxy,
export::zvariant::{Fd, ObjectPath},
zvariant::{Fd, ObjectPath},
};
use crate::Result;
@ -60,15 +60,15 @@ impl Console {
let obj_path = ObjectPath::try_from(format!("/org/qemu/Display1/Console_{}", idx))?;
let proxy = AsyncConsoleProxy::builder(conn)
.path(&obj_path)?
.build_async()
.build()
.await?;
let keyboard = AsyncKeyboardProxy::builder(conn)
.path(&obj_path)?
.build_async()
.build()
.await?;
let mouse = AsyncMouseProxy::builder(conn)
.path(&obj_path)?
.build_async()
.build()
.await?;
Ok(Self {
proxy,
@ -117,7 +117,10 @@ impl Console {
let (wait_tx, wait_rx) = mpsc::channel();
let _thread = thread::spawn(move || {
let c = zbus::Connection::new_unix_client(p1, false).unwrap();
let c = zbus::ConnectionBuilder::unix_stream(p1)
.p2p()
.build()
.unwrap();
let mut s = zbus::ObjectServer::new(&c);
let listener = ConsoleListener::new(tx, wait_rx);
let err = listener.err();
@ -147,7 +150,10 @@ impl Console {
let (wait_tx, wait_rx) = mpsc::channel();
let _thread = thread::spawn(move || {
let c = zbus::Connection::new_unix_client(p1, false).unwrap();
let c = zbus::ConnectionBuilder::unix_stream(p1)
.p2p()
.build()
.unwrap();
let mut s = zbus::ObjectServer::new(&c);
let listener = ConsoleListener::new(tx, wait_rx);
let err = listener.err();

View File

@ -6,7 +6,7 @@ use std::sync::mpsc::{Receiver, RecvError, SendError};
use std::sync::Arc;
use derivative::Derivative;
use zbus::{dbus_interface, export::zvariant::Fd};
use zbus::{dbus_interface, zvariant::Fd};
use crate::EventSender;

View File

@ -1,12 +1,12 @@
use std::sync::mpsc::{SendError, Sender};
pub(crate) trait EventSender {
pub(crate) trait EventSender: Send {
type Event;
fn send_event(&self, t: Self::Event) -> Result<(), SendError<Self::Event>>;
}
impl<T> EventSender for Sender<T> {
impl<T: Send> EventSender for Sender<T> {
type Event = T;
fn send_event(&self, t: Self::Event) -> Result<(), SendError<Self::Event>> {
@ -15,7 +15,7 @@ impl<T> EventSender for Sender<T> {
}
#[cfg(feature = "glib")]
impl<T> EventSender for glib::Sender<T> {
impl<T: Send> EventSender for glib::Sender<T> {
type Event = T;
fn send_event(&self, t: Self::Event) -> Result<(), SendError<Self::Event>> {

View File

@ -16,7 +16,7 @@ fn main() {
let app = gtk::Application::new(Some("org.qemu.rdw.demo"), ApplicationFlags::NON_UNIQUE);
let conn: zbus::azync::Connection = Connection::new_session()
let conn: zbus::azync::Connection = Connection::session()
.expect("Failed to connect to DBus")
.into();

View File

@ -22,7 +22,7 @@ fn main() {
window.set_child(Some(&term));
MainContext::default().spawn_local(clone!(@strong window => async move {
let conn = Connection::new_session().await
let conn = Connection::session().await
.expect("Failed to connect to DBus");
if let Ok(c) = Chardev::new(&conn, "serial").await {