-
Notifications
You must be signed in to change notification settings - Fork 44
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
USB Portal #210
base: master
Are you sure you want to change the base?
USB Portal #210
Conversation
fced97d
to
ecb8189
Compare
Currently includes a revert for #208 |
4d81103
to
de86287
Compare
The build failure is because it needs a flatpak version that isn't available. |
Signed-off-by: Hubert Figuière <hub@figuiere.net>
This allow running the release build. Signed-off-by: Hubert Figuière <hub@figuiere.net>
Signed-off-by: Hubert Figuière <hub@figuiere.net>
Signed-off-by: Hubert Figuière <hub@figuiere.net>
- Added UI for USB Signed-off-by: Hubert Figuière <hub@figuiere.net>
…evice Added rusb to the crates. Added libusb to the manifest. Signed-off-by: Hubert Figuière <hub@figuiere.net>
239d19c
to
1f7eec3
Compare
#[doc(alias = "EnumerateDevices")] | ||
pub async fn enumerate_devices( | ||
&self, | ||
options: UsbOptions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no options here, so just pass Default? Also seems to have both a request_handle, yet it doesn't use the mechanism for requests and do a plain dbus call?
#[doc(alias = "AcquireDevices")] | ||
pub async fn acquire_devices( | ||
&self, | ||
parent_window: &WindowIdentifier, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should become Option<&WindowIdentifier>
with the changes in main.
pub async fn acquire_devices( | ||
&self, | ||
parent_window: &WindowIdentifier, | ||
devices: &[(&String, bool)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are those string/bool supposed to be? I haven't looked at the spec, but it would be nice to clarify their meaning. If they are returned by some other method call, then they should have an alias to make it easier to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see from the rest of the code, imho, make it take a new type called `Device(String /* ID */ , bool / * writable */); or so.
/// Option for AcquireDevice call. | ||
#[derive(SerializeDict, Type, Debug, Default)] | ||
#[zvariant(signature = "dict")] | ||
pub struct AcquireOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no reason for making this struct public
} | ||
|
||
/// Call on success of acquire_devices. | ||
#[doc(alias = "FinishAcquireDevices")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it can be just called at the end of acquire_device, why it is a separate method?
async move { | ||
let root = row.native().unwrap(); | ||
let identifier = WindowIdentifier::from_native(&root).await; | ||
let usb = UsbProxy::new().await.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unwraps here are not good, once you move it to a separate function, you can make it report errors using the notifications support in PortalPage
#[strong] | ||
page, | ||
async move { | ||
let usb = UsbProxy::new().await.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the proxy around
} | ||
)); | ||
let device_id = device.0.clone(); | ||
row.connect_unshare_clicked(clone!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, move it to a separate function
self.session.lock().await.replace(session); | ||
|
||
let session = self.session.clone(); | ||
glib::spawn_future(async move { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is already async, no need for using glib here
|
||
pub(super) async fn stop_session(&self) -> anyhow::Result<()> { | ||
if let Some(session) = self.session.lock().await.take() { | ||
session.close().await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should switch the buttons state
This is a draft, needs a lot of cleanup. Also the portal hasn't landed yet.
But I'm using this to exercise / test the USB portal.