From 807eed0ffc060be0e41980f26cac55bf74aa0a7f Mon Sep 17 00:00:00 2001 From: PartialVolume <22084881+PartialVolume@users.noreply.github.com> Date: Wed, 20 Dec 2023 20:53:43 +0000 Subject: [PATCH] Make completion footer more informative These changes solve three issues. The first issue was that it wasn't obvious that the PDFs are only created once you press return to exit after all the wipes have finished. It is now explicitly stated in the footer message if PDFs are enabled. It also now specifies the logfile name on the footer if the user has specified a log file as a command line option. If no logfile is specified then STDOUT is displayed. If the user specified --PDFreportpath=noPDF on the command line, prior to this commit it had no affect. This is now fixed so that it disables PDF's irrespective of what is in nwipe.conf. i.e command line options override the entries in nwipe.conf If the user has specified a --PDFreportpath=noPDF=/some/path then PDF's are enabled irrespective of the value in nwipe.conf --- src/gui.c | 67 ++++++++++++++++++++++++++++++++++++++------------- src/logging.c | 3 ++- src/options.c | 17 +++++++++++++ src/version.c | 4 +-- 4 files changed, 71 insertions(+), 20 deletions(-) diff --git a/src/gui.c b/src/gui.c index c53a02d3..9c34910b 100644 --- a/src/gui.c +++ b/src/gui.c @@ -169,8 +169,6 @@ const char* end_wipe_footer = "B=[Toggle between dark\\blank\\blue screen] Ctrl+ const char* rounds_footer = "Left=Erase Esc=Cancel Ctrl+C=Quit"; const char* selection_footer_text_entry = "Esc=Cancel Return=Submit Ctrl+C=Quit"; -const char* wipes_finished_footer = "Wipe finished - press enter to exit. Logged to STDOUT"; - /* The number of lines available in the terminal */ int stdscr_lines; @@ -6067,6 +6065,53 @@ void* nwipe_gui_status( void* ptr ) /* Spinner character */ char spinner_string[2]; + /* Create the finish message, this changes based on whether PDF creation is enabled + * and whether a logfile has been specified + */ + char finish_message[NWIPE_GUI_FOOTER_W + 132]; + if( nwipe_options.logfile[0] == 0 && nwipe_options.PDF_enable != 0 ) + { + snprintf( finish_message, + sizeof( finish_message ), + "Wipe finished - press enter to create pdfs & exit. Logged to STDOUT" ); + } + else + { + if( nwipe_options.logfile[0] != 0 && nwipe_options.PDF_enable != 0 ) + { + snprintf( finish_message, + sizeof( finish_message ), + "Wipe finished - press enter to create pdfs & exit. Logged to %s", + nwipe_options.logfile ); + } + else + { + if( nwipe_options.logfile[0] != 0 && nwipe_options.PDF_enable == 0 ) + { + snprintf( finish_message, + sizeof( finish_message ), + "Wipe finished - press enter to exit (pdfs disabled in config). Logged to %s", + nwipe_options.logfile ); + } + else + { + if( nwipe_options.logfile[0] == 0 && nwipe_options.PDF_enable == 0 ) + { + snprintf( finish_message, + sizeof( finish_message ), + "Wipe finished - press enter to exit (pdfs disabled in config). Logged to STDOUT" ); + } + else + { + /* This is a catch all something unexpected happens with the above logic */ + snprintf( finish_message, + sizeof( finish_message ), + "Wipe finished - press enter to exit. Logged to STDOUT" ); + } + } + } + } + /* We count time from when this function is first called. */ static time_t nwipe_time_start = 0; @@ -6224,7 +6269,7 @@ void* nwipe_gui_status( void* ptr ) else { /* and if the wipes have finished a different footer is required */ - nwipe_gui_create_all_windows_on_terminal_resize( 0, wipes_finished_footer ); + nwipe_gui_create_all_windows_on_terminal_resize( 0, finish_message ); } } @@ -6242,7 +6287,7 @@ void* nwipe_gui_status( void* ptr ) if( nwipe_active == 0 || terminate_signal == 1 ) { - nwipe_gui_title( footer_window, wipes_finished_footer ); + nwipe_gui_title( footer_window, finish_message ); // Refresh the footer_window ; wnoutrefresh( footer_window ); @@ -6625,19 +6670,7 @@ void* nwipe_gui_status( void* ptr ) } /* End of while loop */ - if( nwipe_options.logfile[0] == '\0' ) - { - nwipe_gui_title( footer_window, wipes_finished_footer ); - } - else - { - char finish_message[NWIPE_GUI_FOOTER_W]; - snprintf( finish_message, - sizeof( finish_message ), - "Wipe finished - press enter to exit. Logged to %s", - nwipe_options.logfile ); - nwipe_gui_title( footer_window, finish_message ); - } + nwipe_gui_title( footer_window, finish_message ); terminate_signal = 1; return NULL; diff --git a/src/logging.c b/src/logging.c index cb01e98d..ca103ef8 100644 --- a/src/logging.c +++ b/src/logging.c @@ -892,7 +892,8 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected ) serial_no ); /* Create the PDF report/certificate */ - if( strcmp( nwipe_options.PDFreportpath, "noPDF" ) != 0 ) + if( nwipe_options.PDF_enable == 1 ) + // if( strcmp( nwipe_options.PDFreportpath, "noPDF" ) != 0 ) { /* to have some progress indication. can help if there are many/slow disks */ fprintf( stderr, "." ); diff --git a/src/options.c b/src/options.c index d145c9c8..95050db8 100644 --- a/src/options.c +++ b/src/options.c @@ -398,6 +398,23 @@ int nwipe_options_parse( int argc, char** argv ) nwipe_options.PDFreportpath[strlen( optarg )] = '\0'; strncpy( nwipe_options.PDFreportpath, optarg, sizeof( nwipe_options.PDFreportpath ) ); + + /* Command line options will override what's in nwipe.conf */ + if( strcmp( nwipe_options.PDFreportpath, "noPDF" ) == 0 ) + { + nwipe_options.PDF_enable = 0; + nwipe_conf_update_setting( "PDF_Certificate.PDF_Enable", "DISABLED" ); + } + else + { + if( strcmp( nwipe_options.PDFreportpath, "." ) ) + { + /* and if the user has specified a PDF path then enable PDF */ + nwipe_options.PDF_enable = 1; + nwipe_conf_update_setting( "PDF_Certificate.PDF_Enable", "ENABLED" ); + } + } + break; case 'e': /* exclude drives option */ diff --git a/src/version.c b/src/version.c index 4bd301b9..48b33692 100644 --- a/src/version.c +++ b/src/version.c @@ -4,7 +4,7 @@ * used by configure to dynamically assign those values * to documentation files. */ -const char* version_string = "0.35.4"; +const char* version_string = "0.35.5"; const char* program_name = "nwipe"; const char* author_name = "Martijn van Brummelen"; const char* email_address = "git@brumit.nl"; @@ -14,4 +14,4 @@ Modifications to original dwipe Copyright Andy Beverley \n\ This is free software; see the source for copying conditions.\n\ There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\ FOR A PARTICULAR PURPOSE.\n"; -const char* banner = "nwipe 0.35.4"; +const char* banner = "nwipe 0.35.5";