From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from re-prd-fep-042.btinternet.com (mailomta21-re.btinternet.com [213.120.69.114]) by sourceware.org (Postfix) with ESMTPS id 4DDCD385695F for ; Thu, 20 Apr 2023 13:58:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DDCD385695F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dronecode.org.uk Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dronecode.org.uk Received: from re-prd-rgout-003.btmx-prd.synchronoss.net ([10.2.54.6]) by re-prd-fep-042.btinternet.com with ESMTP id <20230420135802.GOUZ30996.re-prd-fep-042.btinternet.com@re-prd-rgout-003.btmx-prd.synchronoss.net>; Thu, 20 Apr 2023 14:58:02 +0100 Authentication-Results: btinternet.com; auth=pass (LOGIN) smtp.auth=jonturney@btinternet.com; bimi=skipped X-SNCR-Rigid: 63FE98D205C9DFA7 X-Originating-IP: [81.129.146.164] X-OWM-Source-IP: 81.129.146.164 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-VadeSecure-score: verdict=clean score=0/300, class=clean X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvhedrfedtvddgieelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuueftkffvkffujffvgffngfevqffopdfqfgfvnecuuegrihhlohhuthemuceftddunecunecujfgurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomheplfhonhcuvfhurhhnvgihuceojhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukheqnecuggftrfgrthhtvghrnhepveffkeffjeekjedvhefgudettdeggfekgfeujeehheelvdeluedujeejveetudefnecuffhomhgrihhnpehgnhhurdhorhhgnecukfhppeekuddruddvledrudegiedrudeigeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhinhgvthepkedurdduvdelrddugeeirdduieegpdhmrghilhhfrhhomhepjhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukhdpnhgspghrtghpthhtohepvddprhgtphhtthhopegthihgfihinhdqrghpphhssegthihgfihinhdrtghomhdprhgtphhtthhopehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkpdhrvghvkffrpehhohhsthekuddquddvledqudegiedqudeigedrrhgrnhhgvgekuddquddvledrsghttggvnhhtrhgrlhhplhhushdrtghomhdprghuthhhpghushgvrhepjhhonhhtuhhrnhgvhiessght ihhnthgvrhhnvghtrdgtohhmpdhgvghokffrpefiuedpoffvtefjohhstheprhgvqdhprhguqdhrghhouhhtqddttdef X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from localhost.localdomain (81.129.146.164) by re-prd-rgout-003.btmx-prd.synchronoss.net (5.8.814) (authenticated as jonturney@btinternet.com) id 63FE98D205C9DFA7; Thu, 20 Apr 2023 14:58:02 +0100 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney Subject: [PATCH setup] Enhance quiet mode to allow window to be input-disabled or hidden Date: Thu, 20 Apr 2023 14:57:45 +0100 Message-Id: <20230420135745.2406-1-jon.turney@dronecode.org.uk> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,KAM_SHORT,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: '-q'/'--quiet-mode' now accepts an optional parameter specifying how the setup wizard behaves: 'unattended' is the existing behaviour (basically, the wizard automatically advances rather than requiring 'next' to be pressed, and MessageBox()es automatically performn some default action), 'noinput' also disables mouse and keyboard interaction with the wizard, and 'hidden' hides the the wizard. No exhaustive audit has taken place that there aren't places in setup where we don't loop forever, or get stuck waiting for user input to resolve some unexpected condition. (In particular, I suspect that dialogs which may occur if some authorization credentials need to be provided for the network connection to the package repository (HTTP auth, or proxy auth, or FTP password) don't handle unattended mode correctly, and there's currently no non-interactive way to provide these credentials) --- Notes: The names of the quite modes probably could use a bit more thought. The ideal approach to this problem is probably to decouple the GUI and install logic, so we can build a CLI installer, but things are sufficently entangled that that's would be a substantial amount of work to do. main.cc | 18 +++++++++++++++--- propsheet.cc | 17 +++++++++++++++-- quiet.h | 26 ++++++++++++++++++++++++++ res/en/res.rc | 2 +- 4 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 quiet.h diff --git a/main.cc b/main.cc index 1d65d53..01c90b9 100644 --- a/main.cc +++ b/main.cc @@ -36,6 +36,7 @@ #include "resource.h" #include "dialog.h" #include "state.h" +#include "quiet.h" #include "msg.h" #include "find.h" #include "mount.h" @@ -95,8 +96,14 @@ static StringChoiceOption::StringChoices symlink_types({ {"wsl", SymlinkTypeWsl}, }); +static StringChoiceOption::StringChoices quiet_types({ + {"unattended", QuietUnattended}, + {"noinput", QuietNoInput}, + {"hidden", QuietHidden}, + }); + static StringOption Arch ("", 'a', "arch", IDS_HELPTEXT_ARCH, false); -static BoolOption UnattendedOption (false, 'q', "quiet-mode", IDS_HELPTEXT_QUIET_MODE); +StringChoiceOption UnattendedOption (quiet_types, 'q', "quiet-mode", IDS_HELPTEXT_QUIET_MODE, true, -1, QuietUnattended); static BoolOption PackageManagerOption (false, 'M', "package-manager", IDS_HELPTEXT_PACKAGE_MANAGER); static BoolOption NoAdminOption (false, 'B', "no-admin", IDS_HELPTEXT_NO_ADMIN); static BoolOption WaitOption (false, 'W', "wait", IDS_HELPTEXT_WAIT); @@ -275,8 +282,13 @@ WinMain (HINSTANCE h, SetThreadUILanguage(langid); } - unattended_mode = PackageManagerOption ? chooseronly - : (UnattendedOption ? unattended : attended); + if (PackageManagerOption) + unattended_mode = chooseronly; + else + if (UnattendedOption < 0) + unattended_mode = attended; + else + unattended_mode = unattended; bool output_only = help_option || VersionOption; diff --git a/propsheet.cc b/propsheet.cc index a2dca45..092293f 100644 --- a/propsheet.cc +++ b/propsheet.cc @@ -25,6 +25,7 @@ #include "ControlAdjuster.h" #include "choose.h" #include "msg.h" +#include "quiet.h" // Sort of a "hidden" Windows structure. Used in the PropSheetCallback. #include @@ -243,16 +244,28 @@ PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam) { case PSCB_PRECREATE: { - LONG additionalStyle = - (WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME); + LONG additionalStyle = (WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME); + + // 'noinput' quiet mode adds WS_DISABLE to prevent user interaction + // with the propsheet + if (UnattendedOption == QuietNoInput) + additionalStyle |= WS_DISABLED; + + // 'hidden' quiet mode totally hides the propsheet window + LONG forbiddenStyle = 0; + if (UnattendedOption == QuietHidden) + forbiddenStyle |= WS_VISIBLE; + // Add a minimize box to the sheet/wizard. if (((LPDLGTEMPLATEEX) lParam)->signature == 0xFFFF) { ((LPDLGTEMPLATEEX) lParam)->style |= additionalStyle; + ((LPDLGTEMPLATEEX) lParam)->style &= ~forbiddenStyle; } else { ((LPDLGTEMPLATE) lParam)->style |= additionalStyle; + ((LPDLGTEMPLATE) lParam)->style &= ~forbiddenStyle; } } return TRUE; diff --git a/quiet.h b/quiet.h new file mode 100644 index 0000000..9f2b6d8 --- /dev/null +++ b/quiet.h @@ -0,0 +1,26 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * A copy of the GNU General Public License can be found at + * http://www.gnu.org/ + * + */ + +#ifndef SETUP_QUIET_H +#define SETUP_QUIET_H + +#include "getopt++/StringChoiceOption.h" + +typedef enum +{ + QuietUnattended, + QuietNoInput, + QuietHidden, +} QuietEnum; + +extern StringChoiceOption UnattendedOption; + +#endif /* SETUP_QUIET_H */ diff --git a/res/en/res.rc b/res/en/res.rc index e2f04fd..68869af 100644 --- a/res/en/res.rc +++ b/res/en/res.rc @@ -693,7 +693,7 @@ BEGIN IDS_HELPTEXT_PROXY "HTTP/FTP proxy (host:port)" IDS_HELPTEXT_PRUNE_INSTALL "Prune the installation to only the requested packages" IDS_HELPTEXT_PUBKEY "URL or absolute path of extra public key file (RFC4880 format)" - IDS_HELPTEXT_QUIET_MODE "Unattended setup mode" + IDS_HELPTEXT_QUIET_MODE "Unattended setup mode (unattended, noinput, hidden)" IDS_HELPTEXT_REMOVE_CATEGORIES "Specify categories to uninstall" IDS_HELPTEXT_REMOVE_PACKAGES "Specify packages to uninstall" IDS_HELPTEXT_ROOT "Root installation directory" -- 2.39.0