-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Use flatpak portal for background and autostart #882
Conversation
Currently maybe blocked by the same as this |
We could prepare shipping Mail as Flatpak by guarding your code with something like this: public bool is_running_flatpaked {
get {
return FileUtils.test ("/.flatpak-info", FileTest.IS_REGULAR);
}
} |
I updated it so that mail will only use the flatpak portal if it's sandboxed, so in theory this PR is ready for review again. |
Another thing: currently the background daemon isn't started automatically after it was granted permission on first run, it only starts after restart. Should this be changed? |
in the calendar PR, i changed it to always start with the application, the |
Makes sense to me I'll do the same here then |
@leolost2605 is this ready for review now that the background portal stuff has landed? Also I remember seeing some discussions around host apps being able to use the portal as well? |
…l into use-portal-for-background
@danirabbit yes it is! And yes the deb version of mail can use the portal too (at least on elementary OS but that's probably enough :) |
elementary/switchboard-plug-applications#184 is the fix for that. |
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.
Don't make the request_background call in the startup() method (i would say the call to activate here is wrong too), this will mess with DBus activation.
The way to go here is:
- call only
InboxMonitor.start()
in thestartup()
method. - in
activate()
check if the background flag got used, if so callhold()
and then request background, not having a parent window shouldn't be a issue. - if the request fail, call
release()
.
there's no need to make the request if we open an window. instead, we should make the request in the window's delete_event and hold() if permission was granted. but this one can be done in a follow-up.
src/Application.vala
Outdated
command.add ("--background"); | ||
|
||
try { | ||
return yield portal.request_background (parent, _("Mail needs to run in background in order to send notifications."), (owned) command, Xdp.BackgroundFlags.AUTOSTART, null); |
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 line pass the 120 line limit, would be good to break it.
return yield portal.request_background (parent, _("Mail needs to run in background in order to send notifications."), (owned) command, Xdp.BackgroundFlags.AUTOSTART, null); | |
return yield portal.request_background ( | |
active_window != null ? Xdp.parent_new_gtk (active_window) : null, | |
_("Mail needs to run in background in order to send notifications."), | |
(owned) command, | |
Xdp.BackgroundFlags.AUTOSTART, | |
null | |
); |
Also, IIRC, the background frontend do not check if the application already has permission, so this would end in the permission dialog begin shown in every launch even when the user already give permission.
in the calendar PR, it stores if it had an successful request and skip the request_background call in the next launches.
If that's okay from a design perspective I would integrate this here because it makes implementing the other suggestions quite a bit easier
Actually I think it does here. However it would still overwrite any settings made by the switchboard plug every time mail is launched. On the other hand it allows to disable the autostart via flatpak permission which might be the way to go for the future? |
This comment was marked as outdated.
This comment was marked as outdated.
Co-authored-by: Gustavo Marques <[email protected]>
Should I guard the hold with something like a first_activation variable? I saw that in the calendar PR it wasn't so I dont know... |
Yes, it will be problematic when sandboxed, ask_background will always be true when running from host, so the amount of hold() done doesn't matter we will always hold. will update that there. |
Co-authored-by: Danielle Foré <[email protected]>
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.
LGTM.
Use the flatpak background portal to install the autostart file and request background permission.
Uses libportal.
Requires elementary/portals#73
Closes #880