-
Notifications
You must be signed in to change notification settings - Fork 47
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. |
239d19c
to
1f7eec3
Compare
#[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
|
||
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
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 is done by the non-imp version which is the one called from the UI.
3aee673
to
9146631
Compare
7eadba8
to
7697720
Compare
Signed-off-by: Hubert Figuière <[email protected]>
This allow running the release build. Signed-off-by: Hubert Figuière <[email protected]>
@@ -13,6 +13,8 @@ | |||
"--share=ipc", | |||
"--socket=wayland", | |||
"--device=dri", | |||
"--own-name=com.belmoussaoui.ashpd.demo", |
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.
why is this needed? Isn't this only to own names for app ids which don't match the app id?
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.
I use this build using fenv
, and that allow to build and run the non "Devel" version. It's not required for this PR per see (hint it's still in draft).
<property name="margin-top">6</property> | ||
<property name="margin-bottom">6</property> | ||
<style> | ||
<class name="linked" /> |
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.
In think the consensus is that we want to avoid linked buttons whenever possible.
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.
link (to the documentation) ?
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 none, ask in the #design:gnome.org room if you would like more context.
src/desktop/usb.rs
Outdated
pub struct UsbDevice { | ||
parent: Option<String>, | ||
readable: Option<bool>, | ||
/// Device is writable. Default is false. |
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 is an option, please document None
. Ditto for readable.
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.
"Default is false". I thought this was clear.
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.
documented readable
. (cf the D-Bus xml)
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 does None
mean? How is it different from false
? Why would you get one over the other?
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.
because it's the a{sv}
from D-Bus. As per the D-Bus interface it can be omitted so it has to be omittable here.
5d2cff3
to
85d3611
Compare
Signed-off-by: Hubert Figuière <[email protected]>
- Added UI for USB - Added rusb to the crates. - Added libusb to the manifest. Signed-off-by: Hubert Figuière <[email protected]>
@@ -50,14 +62,15 @@ | |||
{ | |||
"name": "ashpd-demo", |
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.
I rather have a change that puts the manifest in ./ and see if that helps? :)
} | ||
} | ||
|
||
mod imp { |
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 doesn't follow the current code style that puts mod imp at the top of the file
impl ActionRowImpl for UsbDeviceRow {} | ||
|
||
#[derive(Debug, gtk::CompositeTemplate, Default)] | ||
#[template(resource = "/com/belmoussaoui/ashpd/demo/usb.ui")] |
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.
and split different types in a separate mod, see https://github.com/bilelmoussaoui/ashpd/blob/master/ashpd-demo/src/portals/desktop/notification.rs#L161
@@ -268,7 +268,8 @@ where | |||
self.0.call("Close", &()).await | |||
} | |||
|
|||
pub(crate) fn path(&self) -> &ObjectPath<'_> { | |||
/// Return the object path of the request. | |||
pub fn path(&self) -> &ObjectPath<'_> { |
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.
Why was this made public?
pub struct UsbDevice { | ||
parent: Option<String>, | ||
/// Device can be opened for reading. Default is false. | ||
readable: Option<bool>, | ||
/// Device can be opened for writing. Default is false. | ||
pub writable: Option<bool>, | ||
/// The device node for the USB. | ||
#[zvariant(rename = "device-file")] | ||
pub device_file: Option<String>, | ||
/// Device properties | ||
pub properties: Option<HashMap<String, OwnedValue>>, | ||
} |
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 way we deal with structs in general is that no field is public, only add getters or setters that would be public. This allow us to change the way we deserialize/serialize things without impacting the public API.
#[zvariant(signature = "dict")] | ||
struct AcquiredDevice { | ||
success: bool, | ||
fd: Option<OwnedFd>, |
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.
So if success = true, do we always receive an fd or not? or if the success = true and fd = None, there are no more fds to acquire?
#[doc(alias = "FinishAcquireDevices")] | ||
async fn finish_acquire_devices( | ||
&self, | ||
handle_token: &ObjectPath<'_>, |
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.
Why is this param called handle_token? is it really one or a request path?
Ok(Self(proxy)) | ||
} | ||
|
||
/// Create Session |
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.
Please follow the doc style for proxies that are public.
let mut result = self.finish_acquire_devices(path).await?; | ||
let finished = result.1; | ||
devices.append(&mut result.0); |
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.
let mut result = self.finish_acquire_devices(path).await?; | |
let finished = result.1; | |
devices.append(&mut result.0); | |
let (new_devices, finished) = self.finish_acquire_devices(path).await?; | |
devices.append(&new_devices); |
?
} | ||
|
||
/// Device to acquire | ||
pub struct Device(pub String /* ID */, pub bool /* writable */); |
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 needs a constructor/getters
|
||
/// USB error for acquiring device. | ||
#[derive(Debug)] | ||
pub struct UsbError(pub Option<String>); |
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.
Needs to implement std::error::Error
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.