Commit graph

608 commits

Author SHA1 Message Date
deeplow
6707cbbc4a
Add conversion status icon next to each document
Allows the user to see the staus of each document at a gance.
2022-11-21 12:38:23 +00:00
deeplow
9641a61bb3
Typing: ignore 'unreachable' lint warning
Mypy complains about a line being unreachable. This is probably a false
positive. It must assume the code is not using a framework and thus it
can't when a PySide 'connect()' is being called.
2022-11-21 12:38:21 +00:00
deeplow
ce4efc0c25
Lint mypy: ignore type inconsistency w/ official docs
The official docs state the setProperty() method is (str, Any) but
mypy-pyside says it is (bytes, Any). So we ignore it.

[1]: https://doc.qt.io/qtforpython-5/PySide2/QtCore/QObject.html#PySide2.QtCore.PySide2.QtCore.QObject.setProperty
2022-11-21 12:38:20 +00:00
deeplow
df8e2f1b8b
Remove window management logic
Since everything now happens in a single window, there is no need
to have a way to keep track other windows. They simply won't exist.

But on windows and Linux it will still be possible to start
multiple windows by starting various Dangerzone processes. On MacOS
this doesn't seem to be as easy from the launcher, but it should
not be critical as multiple documents can be converted at the same
time in the one window.
2022-11-21 12:38:19 +00:00
deeplow
6f8eb96b35
Remove systray
Having the application in the systray is no longer needed, since
the new_window() logic no longer applies.
2022-11-21 12:38:17 +00:00
deeplow
814b8b9d0f
Unwrap ApplicationWrapper in GUI
Reverts commit b8e8c74 as the conditions that lead the
ApplicationWrapper to crash if not done with a wrapper no longer
seem to apply.
2022-11-21 12:38:16 +00:00
deeplow
c40502fb46
Don't close MainWindow when first conversion ends
First step in removing the multi-window approach, which got replaced
by multi-document single-window.

Fixes #205.
2022-11-21 12:38:14 +00:00
deeplow
f791dc70ab
Hide widgets: select docs -> settings -> conversion
To help debugging and visualizing what was happening, we set all
widgets to be visible at the same time. Now that is no longer needed,
we can hide them.

This keeps the original program flow:
  1. select the documents
  2. set the settings
  3. see the conversion progress

This diverges from the proposed design in issue #117 for simplification
and consistency (with past program flow) purposes.
2022-11-21 12:38:13 +00:00
deeplow
41017745ec
Add greyed out document name right before '-safe.pdf'
The user is supposed to only be able to select the safe PDF extension.
In a multi-file scenario, the extension will be the same for all files.

We follow here the design document [1]. To achieve this, we needed a
QLabel right next to a QLineEdit, to give the user the illusion that
it is the same graphical object.

[1]: https://github.com/firstlookmedia/dangerzone/files/6657536/DangerZone_NA02a.pdf
2022-11-21 12:38:12 +00:00
deeplow
0e36f8d2eb
Set application stylesheet (.css)
Sets the style for LineEdit boxes similarly to the specified design
in issue #117.
2022-11-21 12:38:10 +00:00
deeplow
e64954acfa
Validate safe-extension (-safe.pdf) before converting
Avoid conversion issues when saving the output file when it is set
wrongly. Inform the user with a red box saying "must end in .pdf"
and prevent the user from clicking "convert" before that is fixed.

Combines the validation logic with the already-existing 'update_ui()'
2022-11-21 12:38:09 +00:00
deeplow
1790231db0
Set default output dir and allow users changing it
Set the default directory for saving the file as the one from
the first document. This one will show just the directory name.
If the user changes it by choosing another directory, then show the new
directory name and its full path.
2022-11-21 12:37:57 +00:00
deeplow
4a42627f45
GUI settings: enable & adapt to muti-document
- shows settings again
- removes documents arg from settings widget - this is now stored
  under DangerzoneGui instance.
- removes widget 'dangerous_doc_label' - the doc label is already
  shown next to each document.
- 'Save as' button now serves the purpose of selecting where all
  output files should be saved. Before, it was for selecting where
  the file would be saved.
- 'save_lineedit' widget which was read-only and showed the path
  where the file would be saved, it now called 'safe_suffix' and is
  writable. It is where the user can type the safe file extension
  (e.g. '-safe.pdf'). Validation is not yet implemented.
- when 'start_button' is clicked it now changes the output_filename
  of all the documents to set their output directory to the one the
  user has selected (if 'save_checkbox' enabled) and to set their
  new 'safe_suffix'
- change to plural text for selection of multiple documents
2022-11-21 12:37:49 +00:00
deeplow
5a6c72f09e
Add output_dir manipulation methods to DocumentHolder
These will be needed in for the GUI's settings. This also adds test
cases for these documents. The methods are the following:

  - set_output_dir()
    For changing the output directory of the safe file

  - suffix setter and getter - for changing the suffix of the file
2022-11-21 12:37:47 +00:00
deeplow
fc3cfba450
Security: GUI (via CLI) wildcard injection mitigation
Similar to the mitigation implemented in the CLI version of dangerzone
(commit f9b564be)
2022-11-21 12:37:46 +00:00
deeplow
2e477b8a12
Initial refactor: GUI one-window multi-document support
Allows the user to:
  a) specify filenames via the terminal (for the GUI)
  b) select multiple documents via the GUI

The conversion process can't yet be started since the settings are
broken and disabled (expect mypy complaints).
2022-11-21 12:37:45 +00:00
deeplow
a8001d4f3e
Comment out settings_widget temporarily
The settings widget will be broken when we add multiple document
support in the GUI, at first, at least.
2022-11-21 12:37:43 +00:00
deeplow
bf8ca96a44
Rename 'convert_widget' to 'documents_list' 2022-11-21 12:37:42 +00:00
deeplow
0444fc56ec
Temporarily show all dangerzone widgets (for debugging) 2022-11-21 12:37:41 +00:00
deeplow
89f5e99b0c
Initial GUI multi-window opening via terminal
Allow opening multiple documents at the same time from the terminal
by calling

  $ dangerzone document1.pdf document2.pdf

It will open each document in its own window, making use of the
already existing 'multi-document multi-window' parallel conversion
implementation.
2022-11-21 12:37:39 +00:00
deeplow
1e16eca392
remove unneeded imports: plistlib, grp, getpass
plistlib:
  - originaly added in commit 3be1d63330
  - no longer needed

grp, getpass:
  - originally added in commit ae7c919d8e
  - used for finding the 'docker' executable. No longer needed.
2022-11-18 13:09:01 +00:00
deeplow
0b738ba490
Do not create outfile files when checking if writeable
Checking if files were writeable created files in the process. In the
case where someone adds a list of N files to dangerzone but exits before
converting, they would be left with N 0-byte files for the -safe
version. Now they don't.

Fixes #214
2022-11-14 09:04:54 +00:00
deeplow
93f17b3166
Specialize DocumentFilenameException() for disambiguation
All filename-related exceptions were of class DocumentFilenameException.
This made it difficult to disambiguate them. Specializing them makes it
it easier for tests to detect which exception in particular we want to
verify.
2022-11-14 09:04:23 +00:00
deeplow
1bdbb1959c
Changelog: add cli multi-doc support 2022-11-14 09:04:19 +00:00
deeplow
d71e230173
Update document state exclusively in convert()
The document's state update is better update in the convert() function.
This is because this function is always called for the conversion
progress regardless of the frontend.
2022-11-14 09:03:50 +00:00
deeplow
65ac0d19c3
Add an identifier to each document
With multiple input documents it is possible only one of them has
issues. Mentioning the document id can help debug.
2022-11-14 09:03:36 +00:00
deeplow
6d2fdf0afe
Deduplicate container output parsing (stdout_callback)
The container output logging logic was in both the CLI and the GUI.
This change moves the core parsing logic to container.py.

Since the code was largely the same, now cli does need to specify
a stdout_callback since all the necessary logging already happens.

The GUI now only adds an stdout_callback to detect if there was an
error during the conversion process.
2022-11-14 08:54:02 +00:00
deeplow
2d587f4082
Parallel cli bulk conversions via threading
Initial parallel document conversion: creates a pool of N threads
defined by the setting 'parallel_conversions'. Each thread calls
convert() on a document.
2022-11-14 08:54:00 +00:00
deeplow
e17912888a
Add test cases for bulk document conversion 2022-11-14 08:53:59 +00:00
deeplow
f9b564be03
Security: cli wildcard injection mitigation
Wildcard arguments like `*` can lead to security vulnerabilities
if files are maliciously named as would-be parameters. In the following
scenario if a file in the current directory was named '--help', running
the following command would show the help.

  $ dangerzone-cli *

By checking if parameters also happen to be files, we mitigate this
risk and have a chance to warn the user.
2022-11-14 08:53:38 +00:00
deeplow
981716ccff
Sequential bulk document support in cli
Basic implementation of bulk document support in dangerzone-cli.

Usage: dangerzone-cli [OPTIONS] doc1.pdf doc2.pdf
2022-11-14 08:51:00 +00:00
Alex Pyrgiotis
1147698287
Update changelog wrt Ubuntu Focal
Signed-off-by: Alex Pyrgiotis <alex.p@freedom.press>
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
e7a8ea8e9f
Add extra installation steps for Ubuntu Focal
Add extra installations steps for installing Podman in Ubuntu Focal,
since it's not present in the official Ubuntu repos. This is the final
requirement to reinstate Ubuntu Focal support.

Closes #206
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
badafaaf15
ci: Reinstate Ubuntu Focal support
Reinstate support for Ubuntu Focal, which was previously removed in
commit 229ebbda14.

Refs #206
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
1daaafe2a3
install: Introduce a script for installing Podman
Introduce a script for installing Podman in Ubuntu Focal, in
environments that may, or may not, have sudo installed.

Also, update our CircleCI configuration to use this script when
installing Podman.
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
5a3a46cd46
Support Click 7.x callback handling
Support Click version 7.x and below, which inspect the number of
arguments a callback handler supports.

Refs #206
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
ef5abe1419
Report missing supported versions
Report some Linux versions that were recently supported (Debian 12 /
Fedora 37) in the installation instructions. These instructions where
copied from the Dangerzone wiki, which is why the recently supported
versions were missing.
2022-11-10 16:35:48 +02:00
Alex Pyrgiotis
b9fdafe5cc
Copy installation instructions to source
Copy installation instructions from the Dangerzone wiki [1] into the
Dangerzone source. This has several benefits:

1. Devs can update installation instructions as part of a PR.
2. Users can see installation instructions for previous releases.

The last point is important, because we can update our instructions in
the main branch, without affecting the instructions a user follows from
the website (currently pointing to the Dangerzone Wiki).

Refs #240

[1]: https://github.com/freedomofpress/dangerzone/wiki/Installing-Dangerzone
2022-11-10 16:35:43 +02:00
Guthrie McAfee Armstrong
2085405d05
Remove redundant f-strings 2022-11-10 09:59:09 +00:00
deeplow
968fd20ac7
fix comma typo 2022-11-10 09:59:08 +00:00
deeplow
e4ff9801ee
make lint happy 2022-11-10 09:59:05 +00:00
Guthrie McAfee Armstrong
1bd8354228
simplify setting percentage to 0.0 2022-11-10 09:59:04 +00:00
Guthrie McAfee Armstrong
9989ffea37
catch ValueError, simplify try/except on top-level job runs
See https://github.com/freedomofpress/dangerzone/pull/167#discussion_r915757189
2022-11-10 09:59:02 +00:00
Guthrie McAfee Armstrong
6b44db9043
Update container/dangerzone.py
Co-authored-by: deeplow <47065258+deeplow@users.noreply.github.com>
2022-11-10 09:59:01 +00:00
Guthrie McAfee Armstrong
3ef8b183e2
Update container/dangerzone.py
Co-authored-by: deeplow <47065258+deeplow@users.noreply.github.com>
2022-11-10 09:58:59 +00:00
Guthrie McAfee Armstrong
2533eac4be
Rename ConversionJob back to DangerzoneConverter
Co-authored-by: deeplow <47065258+deeplow@users.noreply.github.com>
2022-11-10 09:58:57 +00:00
Guthrie McAfee Armstrong
5a4bf99211
Remove another "END OF FOR LOOP" comment 2022-11-10 09:58:54 +00:00
Guthrie McAfee Armstrong
c18f170caf
Remove "END OF FOR LOOP" comment
Co-authored-by: deeplow <47065258+deeplow@users.noreply.github.com>
2022-11-10 09:58:53 +00:00
Guthrie McAfee Armstrong
17939cb70c
Wrap dangerzone.py back into a class to keep track of percentage 2022-11-10 09:58:51 +00:00
Guthrie McAfee Armstrong
eaa08c9c3d
refactor dangerzone.py, raise exceptions instead of returning int
Standardize calls to subprocess.run to shrink file by about 100 lines
2022-11-10 09:58:50 +00:00