Skip to content
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

Add update checks for new Dangerzone versions #466

Merged
merged 15 commits into from
Jul 24, 2023
Merged

Add update checks for new Dangerzone versions #466

merged 15 commits into from
Jul 24, 2023

Conversation

apyrgio
Copy link
Contributor

@apyrgio apyrgio commented Jul 4, 2023

This is a PR that brings notification updates for new Dangerzone versions. It follows most of the workflow in issue #189, but uses notification bubbles instead of pop-ups, as the main method of grabbing the user's attention.

This PR is mostly complete, but there are some minor issues that still persist:

  1. There are some medium priority FIXME/TODO comments in the code. These can be fixed in a subsequent PR, since this one has grown too large.
  2. The test coverage can be improved, especially for the Qt part of the code. Again, this can take place in a subsequent PR.

Closes #189

screenshot_2023-06-29_17-19-22_720 screenshot_2023-06-29_17-17-26_720

@deeplow deeplow self-requested a review July 5, 2023 05:47
@deeplow
Copy link
Contributor

deeplow commented Jul 5, 2023

  1. Some tests are failing on Windows/MacOS, but the same thing applies to Add "change document selection" button #439

Turns out the recursion issue was caused by parallel tests in Docker. I solved the issue on the other PR by completely removing parallel tests (they have caused issues in the past as well). See this diff.

Copy link
Contributor

@deeplow deeplow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra things to think about:

  • on linux the check for updates will appear disabled by default. We should mark it as checked and say that it's updated via the package manager.
  • the hamburger menu probably needs to be a bit bigger and equally spaced from each margin
  • the "new version available" option in the menu should somehow be highlighted (see how Tor Browser shows it).

dangerzone/settings.py Outdated Show resolved Hide resolved
dangerzone/gui/updater.py Show resolved Hide resolved
dangerzone/gui/updater.py Outdated Show resolved Hide resolved
dangerzone/gui/updater.py Outdated Show resolved Hide resolved
dangerzone/gui/main_window.py Outdated Show resolved Hide resolved
dangerzone/gui/main_window.py Outdated Show resolved Hide resolved
dangerzone/gui/main_window.py Show resolved Hide resolved
tests/test_updater.py Outdated Show resolved Hide resolved
tests/test_updater.py Outdated Show resolved Hide resolved
tests/__init__.py Outdated Show resolved Hide resolved
@apyrgio
Copy link
Contributor Author

apyrgio commented Jul 11, 2023

Hey, thanks a lot for the detailed review :-).

Extra things to think about:

* on linux the check for updates will appear disabled by default. We should mark it as checked and say that it's updated via the package manager.

I think it's still worth having this option in two cases:

  1. If the user has installed a .deb / .rpm (e.g., because they don't want to use our repos.
  2. If the user has installed Dangerzone through an unofficial package (think AUR), which may not be fully maintained.
* the hamburger menu probably needs to be a bit bigger and equally spaced from each margin

Definitely, I agree.

* the "new version available" option in the menu should somehow be highlighted (see how Tor Browser shows it).

Yeap, I agree as well.

@deeplow
Copy link
Contributor

deeplow commented Jul 11, 2023

I think it's still worth having this option in two cases:

  • If the user has installed a .deb / .rpm (e.g., because they don't want to use our repos.
  • If the user has installed Dangerzone through an unofficial package (think AUR), which may not be fully maintained.

OK! You mean having different behaviors on RPM vs DEB versus unnoficial ones, right?

@apyrgio
Copy link
Contributor Author

apyrgio commented Jul 12, 2023

I think it's still worth having this option in two cases:

  • If the user has installed a .deb / .rpm (e.g., because they don't want to use our repos.
  • If the user has installed Dangerzone through an unofficial package (think AUR), which may not be fully maintained.

OK! You mean having different behaviors on RPM vs DEB versus unnoficial ones, right?

Even for the official RPMs / DEBs, if the user just downloads and installs them manually, they will not learn about updates. Hopefully, this will be a rare situation...

@apyrgio
Copy link
Contributor Author

apyrgio commented Jul 17, 2023

@deeplow Reminder, I have re-implemented your commit for the cooldown period, because I had made some changes to the code and couldn't rebase them on top of your commit. You'll see that the logic and the tests are a bit different in places, so please take a cursory look.

dangerzone/gui/updater.py Outdated Show resolved Hide resolved
dangerzone/gui/updater.py Outdated Show resolved Hide resolved
@apyrgio apyrgio marked this pull request as ready for review July 20, 2023 07:12
Makefile Outdated Show resolved Hide resolved
@deeplow
Copy link
Contributor

deeplow commented Jul 20, 2023

I have addded equal padding on the top-right margins and changed the icon:

version_available

How does this look?

@deeplow
Copy link
Contributor

deeplow commented Jul 20, 2023

I'm pushing a commit to center the dialog because it looks better:

Before After
afterr all

apyrgio added 9 commits July 24, 2023 14:22
Run tests sequentially, because in subsequent commits we will add
Qt tests that do not play nice when `pytest` creates new processes [1].

Also, remove the pytest wrapper, whose main task was to decide if tests
can run in parallel [2].

[1]: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2393
[2]: #217
Pass the X11 socket of the Linux CI runners to the container where our
CI tests run, with the `-g` flag of `dev_scripts/env.py`. By having a
working X11 socket, we can run GUI tests. Prior to this fix, we would
encounter this error:

    tests/gui/test_main_window.py::test_change_document_button qt.qpa.xcb: could not connect to display
    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

    Available platform plugins are: xcb, offscreen, wayland-egl, wayland, eglfs, vnc, minimalegl, vkkhrdisplay, linuxfb, minimal.

Another alternative we considered was to use the
`QT_QPA_PLATFORM=offscreen` environment variable. This alternative
works, but it's less close to the end-user's environment, so we decided
in favor of the approach above.
Add some settings prefixed with `"updater_"`, which will be used for
updates later on.
Add the following two features in the Settings class:

1. Add a way to save the settings, if the contents of a key have
   changed.
2. Add a way to get all the updater settings, by getting fetching the
   keys that start with `"updater_"`.
Get the default settings of Dangezone for the current version, without
having to instantiate the Settings class. Note that instantiating the
Settings class also writes the settings to the underlying
`settings.json` file, and there are cases where we don't want this
behavior.
Add a new Python module called "updater", which contains the logic for
prompting the user to enable updates, and checking our GitHub releases
for new updates.

This class has some light dependency to Qt functionality, since it needs
to:

* Show a prompt to the user,
* Run update checks asynchronously in a Qt thread,
* Provide the main window with the result of the update check

Refs #189
Add a Pytest fixture that returns an UpdaterThread instance which has
its own unique settings directory. Note that the UpdaterThread instance
needs to be slightly nerfed, so that it doesn't rely on Qt functionality
or any isolation providers.
Add three status icon for the hamburger menu:

* hamburger_menu.svg: The typical hamburger menu. Taken from
  https://commons.wikimedia.org/wiki/File:Hamburger_icon.svg, which is
  in the public domain.
* hamburger_menu_update_error.svg: A hamburger menu with a red
  notification bubble on the top right corner.
* hamburger_menu_update_success.svg: A hamburger menu with a green
  notification bubble on the top right corner.
apyrgio added 3 commits July 24, 2023 14:22
Factor out some parts of the Alert class into a more generic dialog
class. This class will be used for a new type of dialog that we will
introduce in a subsequent commit.

Note that this commit does not alter the functionality of the Alert
class.
Add a Qt widget called "CollapsibleBox", in order to build sections that
you can hide/show with a single click. There is no native widget for
this functionality, so we borrow some code from a StackOverflow user:
https://stackoverflow.com/a/52617714
Add a dialog that we will show for update-related tasks. This dialog has
a different layout than the Alert class: it has a message, followed by
a widget that the user chooses (can be a text box or collapsible
element), and then one last message.
Copy link
Contributor

@deeplow deeplow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to merge. The remaining TODOs were agreed to tb be tackled later as not to further delay is rather large PR.

apyrgio added 3 commits July 24, 2023 16:49
Add a hamburger button in the main window of Dangerzone, that will be
the entry point for update information. Whenever a new update is
released, users will see a green notification bubble. If an update error
happens, they will see a red notification bubble.

In the hamburger menu, users have the option to enable or disable update
checks. Depending on the update check status, users will see in a pop-up
dialog more info about the new update or the error.

Closes #189
Add a very rudimentary test for GUI update logic.

Refs #290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notify when updates are available (Mac & Windows)
2 participants