Add GUI support for selecting files to collect/upload#238
Conversation
| def choose_folder(self) -> None: | ||
| if self._closed: | ||
| return | ||
|
|
There was a problem hiding this comment.
I noticed there is empty space here, most of the style/lint issues can be fixed by running tox run -e fix and then you can check it with tox run -e lint
| self.choose_files() | ||
| elif lParam == self.start_button: | ||
| user32.EnableWindow(self.start_button, False) | ||
| user32.EnableWindow(self.choose_folder_button, False) |
There was a problem hiding this comment.
| self.choose_files() | |
| elif lParam == self.start_button: | |
| user32.EnableWindow(self.start_button, False) | |
| user32.EnableWindow(self.choose_folder_button, False) | |
| self.choose_files() | |
| elif lParam == self.start_button: | |
| user32.EnableWindow(self.start_button, False) | |
| user32.EnableWindow(self.choose_folder_button, False) | |
| user32.EnableWindow(self.choose_files_button, False) |
| user32.SetWindowTextA(self.choose_files_button, b"Clear file(s)") | ||
| user32.EnableWindow(self.start_button, True) | ||
| else: | ||
| print("User cancelled file selection") |
There was a problem hiding this comment.
Technically it could also be because the filename(s) exceeded the 4096 wchar buffer. Is there a way to distinguish between those errors? And then, show it to the user if it isn't a cancelled operation?
| ("lStructSize", w.DWORD), | ||
| ("hwndOwner", w.HWND), | ||
| ("hInstance", w.HINSTANCE), | ||
| ("lpstrFilter", w.LPWSTR), |
There was a problem hiding this comment.
| ("lpstrFilter", w.LPWSTR), | |
| ("lpstrFilter", w.LPCWSTR), |
| ("lpstrDefExt", w.LPWSTR), | ||
| ("lCustData", w.LPARAM), | ||
| ("lpfnHook", w.LPVOID), | ||
| ("lpTemplateName", w.LPWSTR), |
There was a problem hiding this comment.
| ("lpTemplateName", w.LPWSTR), | |
| ("lpTemplateName", w.LPCSTR), |
| ("lpstrInitialDir", w.LPWSTR), | ||
| ("lpstrTitle", w.LPWSTR), |
There was a problem hiding this comment.
| ("lpstrInitialDir", w.LPWSTR), | |
| ("lpstrTitle", w.LPWSTR), | |
| ("lpstrInitialDir", w.LPCWSTR), | |
| ("lpstrTitle", w.LPCWSTR), |
| get_last_error, | ||
| sizeof, | ||
| string_at, | ||
| wstring_at |
|
Hi! Sorry for the long wait. I only remembered this PR was still open when I ran into the same issue again: there's no easy way for clients to upload investigation material (without 3rd party tools), which is exactly what acquire GUI aims to fix. I've addressed your feedback:
|
Miauwkeru
left a comment
There was a problem hiding this comment.
If acquire output folder is selected, it might be good to disable the
"select file(s) to collect" chooser.
As currently you can select both where the upload part will get ignored. Looking just at the GUI you would not expect that to happen
| def wait_for_start(self, args: Namespace) -> tuple[str, bool, bool]: | ||
| return args.output, args.auto_upload, False | ||
| def wait_for_start(self, args: Namespace) -> tuple[str, list[str], bool, bool]: | ||
| return args.output, None, args.auto_upload, False |
There was a problem hiding this comment.
| return args.output, None, args.auto_upload, False | |
| return args.output, [], args.auto_upload, False |
Either an empty list or change the typehint that you know you could get a None value
| error_code = comdlg32.CommDlgExtendedError() | ||
| if error_code == FNERR_BUFFERTOOSMALL: | ||
| user32.MessageBoxA( | ||
| self.hwnd, b"Too many or too long file names selected. Please select fewer files.", b"Acquire", 0 |
There was a problem hiding this comment.
| self.hwnd, b"Too many or too long file names selected. Please select fewer files.", b"Acquire", 0 | |
| self.hwnd, b"The combined filename length exceeded the expected size. Please select fewer files.", b"Acquire", 0 |
This reads better to me, but feel free to add some suggestions
86ae76a to
e7db77c
Compare
| ofn.nMaxFile = buffer_size | ||
| ofn.lpstrFilter = "All Files\0*.*\0Text Files\0*.txt\0\0" | ||
| ofn.nFilterIndex = 1 | ||
| ofn.Flags = 0x00002000 | 0x00080000 | 0x00000200 |
There was a problem hiding this comment.
Could you add a comment with what these magic numbers actually mean?
There was a problem hiding this comment.
I noticed I was using a wrong flag so I corrected this and changed the numbers with named constants
Co-authored-by: Miauwkeru <Miauwkeru@users.noreply.github.com>
|
|
||
|
|
||
| comdlg32 = WinDLL("comdlg32", use_last_error=True) | ||
| comdlg32.GetOpenFileNameW.argtypes = (POINTER(OPENFILENAME),) |
There was a problem hiding this comment.
| comdlg32.GetOpenFileNameW.argtypes = (POINTER(OPENFILENAME),) | |
| comdlg32.GetOpenFileNameW.argtypes = (POINTER(OPENFILENAMEW),) |
| ofn = OPENFILENAME() | ||
| ofn.lStructSize = sizeof(OPENFILENAME) |
There was a problem hiding this comment.
| ofn = OPENFILENAME() | |
| ofn.lStructSize = sizeof(OPENFILENAME) | |
| ofn = OPENFILENAMEW() | |
| ofn.lStructSize = sizeof(OPENFILENAMEW) |
ec8f8ab to
35b7016
Compare
|
I reordered some function definitions so its a bit more visually distinct what belongs together. This was some general cleanup that wasn't related to the PR, so I did it myself. I will now do some final checks! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #238 +/- ##
==========================================
- Coverage 44.75% 43.74% -1.01%
==========================================
Files 26 26
Lines 3546 3630 +84
==========================================
+ Hits 1587 1588 +1
- Misses 1959 2042 +83
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Great! Thank you for everything @Miauwkeru 😄 |
|
no problem @raverburg :) |
This update adds functionality to the GUI that allows users to select specific files for collection and/or upload. Selected files are passed to the existing logic used by acquire, allowing users to either collect them during acquisition or upload them independently.
Notes:
We use a custom version of acquire internally that looks for a config.json file in the same directory instead of using config.py