From f2ff983864409af899d8c753836124ff7d6fa9ab Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sat, 21 Sep 2002 09:36:46 +0000 Subject: [PATCH] 2002-09-21 Robert Collins * choose.h: Add OnUnattended method. * desktop.cc (DesktopSetupPage::OnInit): Allow fine grained control via command line options. (DesktopSetupPage::OnUnattended): Implement. (DesktopSetupPage::OnMessageApp): Implement. * desktop.h (DesktopSetupPage::OnUnattended): declare. (DesktopSetupPage::OnMessageApp): Ditto. * download.cc (do_download_thread): Support unattended mode. * install.cc (do_install_thread): Ditto. * localdir.h: Ditto. * main.cc (main): Ditto. * net.cc (NetPage::OnUnattended): Ditto. * net.h (NetPage::OnUnattended): Declare. * proppage.cc (PropertyPage::DialogProc): Support unattended mode. * proppage.h (PropertyPage::OnUnattended): Declare. * root.cc (RootPage::OnInit): Support unattended mode. (RootPage::OnUnattended): Implement. * root.h (RootPage::OnUnattended): Declare. * site.cc (register_saved_site): Extract Method from get_saved_sites. (get_saved_sites): Remove common code for adding a site. (SitePage::OnInit): Support unattended mode. (SitePage::OnUnattended): Implement. * site.h (SitePage::OnUnattended): Declare. * source.cc (SourcePage::OnActivate): Support unattended mode. (SourcePage::OnUnattended): Implement. * source.h (SourcePage::OnUnattended): Declare. * splash.h (SplashPage::OnUnattended): Declare. * state.cc (unattended_mode): Declare. * state.h (unattended_mode): Declare. * threebar.h (ThreeBarProgressPage::OnUnattended): New method. --- ChangeLog | 33 +++++++++++++++++++++++++ choose.h | 4 +++ desktop.cc | 70 +++++++++++++++++++++++++++++++++++++++++++++-------- desktop.h | 5 ++++ download.cc | 2 +- install.cc | 6 ++--- localdir.h | 4 +++ main.cc | 5 ++++ net.cc | 6 +++++ net.h | 1 + proppage.cc | 42 +++++++++++++++++++++++++++++--- proppage.h | 4 +++ root.cc | 12 +++++++++ root.h | 1 + site.cc | 66 ++++++++++++++++++++++++++++++++++---------------- site.h | 1 + source.cc | 21 +++++++++++++++- source.h | 1 + splash.h | 4 +++ state.cc | 2 ++ state.h | 2 ++ threebar.h | 5 ++++ 22 files changed, 258 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24e8b67f..d68b87ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2002-09-21 Robert Collins + + * choose.h: Add OnUnattended method. + * desktop.cc (DesktopSetupPage::OnInit): Allow fine grained + control via command line options. + (DesktopSetupPage::OnUnattended): Implement. + (DesktopSetupPage::OnMessageApp): Implement. + * desktop.h (DesktopSetupPage::OnUnattended): declare. + (DesktopSetupPage::OnMessageApp): Ditto. + * download.cc (do_download_thread): Support unattended mode. + * install.cc (do_install_thread): Ditto. + * localdir.h: Ditto. + * main.cc (main): Ditto. + * net.cc (NetPage::OnUnattended): Ditto. + * net.h (NetPage::OnUnattended): Declare. + * proppage.cc (PropertyPage::DialogProc): Support unattended mode. + * proppage.h (PropertyPage::OnUnattended): Declare. + * root.cc (RootPage::OnInit): Support unattended mode. + (RootPage::OnUnattended): Implement. + * root.h (RootPage::OnUnattended): Declare. + * site.cc (register_saved_site): Extract Method from get_saved_sites. + (get_saved_sites): Remove common code for adding a site. + (SitePage::OnInit): Support unattended mode. + (SitePage::OnUnattended): Implement. + * site.h (SitePage::OnUnattended): Declare. + * source.cc (SourcePage::OnActivate): Support unattended mode. + (SourcePage::OnUnattended): Implement. + * source.h (SourcePage::OnUnattended): Declare. + * splash.h (SplashPage::OnUnattended): Declare. + * state.cc (unattended_mode): Declare. + * state.h (unattended_mode): Declare. + * threebar.h (ThreeBarProgressPage::OnUnattended): New method. + 2002-09-21 Robert Collins * res.rc: Commit Harry Johnston's dialog caption patch. From July. diff --git a/choose.h b/choose.h index b89fe503..2e6a817c 100644 --- a/choose.h +++ b/choose.h @@ -39,6 +39,10 @@ public: virtual void OnInit (); virtual long OnNext (); virtual long OnBack (); + virtual long OnUnattended () + { + return OnNext (); + }; }; #endif /* __cplusplus */ diff --git a/desktop.cc b/desktop.cc index f2523b5e..a393fddb 100644 --- a/desktop.cc +++ b/desktop.cc @@ -26,6 +26,7 @@ static const char *cvsid = #include "win32.h" #include #include "desktop.h" +#include "propsheet.h" #include #include @@ -55,6 +56,8 @@ static const char *cvsid = #include "PackageSpecification.h" static BoolOption NoShortcutsOption (false, 'n', "no-shortcuts", "Disable creation of desktop and start menu shortcuts"); +static BoolOption NoStartMenuOption (false, 'N', "no-startmenu", "Disable creation of start menu shortcut"); +static BoolOption NoDesktopOption (false, 'd', "no-desktop", "Disable creation of desktop shortcut"); static OSVERSIONINFO verinfo; @@ -473,19 +476,38 @@ DesktopSetupPage::OnInit () CoInitialize (NULL); verinfo.dwOSVersionInfoSize = sizeof (verinfo); GetVersionEx (&verinfo); - root_desktop = - check_desktop ("Cygwin", backslash (cygpath ("/cygwin.bat"))); - root_menu = - check_startmenu ("Cygwin Bash Shell", - backslash (cygpath ("/cygwin.bat"))); - if (NoShortcutsOption) + + if (NoShortcutsOption) { - root_desktop=false; - root_menu=false; - OnFinish(); + root_desktop = root_menu = 0; } else - load_dialog (GetHWND ()); + { + if (NoStartMenuOption) + { + root_menu = 0; + MessageBox(NULL, "NoStartMenuOption", "NoStartMenuOption", MB_OK); + } + else + { + root_menu = + check_startmenu ("Cygwin Bash Shell", + backslash (cygpath ("/cygwin.bat"))); + } + + if (NoDesktopOption) + { + root_desktop = 0; + } + else + { + root_desktop = + check_desktop ("Cygwin", backslash (cygpath ("/cygwin.bat"))); + } + } + + load_dialog (GetHWND ()); + } long @@ -508,3 +530,31 @@ DesktopSetupPage::OnFinish () return true; } + +long +DesktopSetupPage::OnUnattended () +{ + Window::PostMessage (WM_APP_UNATTENDED_FINISH); + // GetOwner ()->PressButton(PSBTN_FINISH); + return -1; +} + +bool +DesktopSetupPage::OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_APP_UNATTENDED_FINISH: + { + GetOwner ()->PressButton(PSBTN_FINISH); + break; + } + default: + { + // Not handled + return false; + } + } + + return true; +} diff --git a/desktop.h b/desktop.h index b6dda19c..d8f98b3c 100644 --- a/desktop.h +++ b/desktop.h @@ -21,6 +21,9 @@ #include "proppage.h" +// WM_APP through WM_APP+7: see threebar.h +#define WM_APP_UNATTENDED_FINISH WM_APP+8 + class DesktopSetupPage:public PropertyPage { public: @@ -36,6 +39,8 @@ public: virtual void OnInit (); virtual bool OnFinish (); virtual long OnBack (); + virtual long OnUnattended (); + virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam); }; #endif // CINSTALL_DESKTOP_H diff --git a/download.cc b/download.cc index 6a375a9c..a1754e95 100644 --- a/download.cc +++ b/download.cc @@ -310,7 +310,7 @@ do_download_thread (HINSTANCE h, HWND owner) { if (errors) exit_msg = IDS_DOWNLOAD_INCOMPLETE; - else + else if (!unattended_mode) exit_msg = IDS_DOWNLOAD_COMPLETE; next_dialog = 0; } diff --git a/install.cc b/install.cc index a187764e..7b120efe 100644 --- a/install.cc +++ b/install.cc @@ -597,18 +597,18 @@ do_install_thread (HINSTANCE h, HWND owner) check_for_old_cygwin (); if (num_installs == 0 && num_uninstalls == 0) { - exit_msg = IDS_NOTHING_INSTALLED; + if (!unattended_mode) exit_msg = IDS_NOTHING_INSTALLED; return; } if (num_installs == 0) { - exit_msg = IDS_UNINSTALL_COMPLETE; + if (!unattended_mode) exit_msg = IDS_UNINSTALL_COMPLETE; return; } if (errors) exit_msg = IDS_INSTALL_INCOMPLETE; - else + else if (!unattended_mode) exit_msg = IDS_INSTALL_COMPLETE; } diff --git a/localdir.h b/localdir.h index 5795f201..c0f5e1b1 100644 --- a/localdir.h +++ b/localdir.h @@ -38,6 +38,10 @@ public: virtual void OnInit (); virtual long OnNext (); virtual long OnBack (); + virtual long OnUnattended () + { + return OnNext (); + }; }; diff --git a/main.cc b/main.cc index 4bd0065a..13c5dac1 100644 --- a/main.cc +++ b/main.cc @@ -58,11 +58,14 @@ static const char *cvsid = #include "desktop.h" #include "getopt++/GetOption.h" +#include "getopt++/BoolOption.h" int next_dialog; HINSTANCE hinstance; +static BoolOption UnattendedOption (false, 'q', "quiet-mode", "Unattended setup mode"); + /* Maximum size of a SID on NT/W2K. */ #define MAX_SID_LEN 40 @@ -208,6 +211,8 @@ main (int argc, char **argv) theLog.exit(1); // #endif + unattended_mode = UnattendedOption; + /* Set the default DACL only on NT/W2K. 9x/ME has no idea of access control lists and security at all. */ if (iswinnt) diff --git a/net.cc b/net.cc index 25f0bf2f..698726ce 100644 --- a/net.cc +++ b/net.cc @@ -121,6 +121,12 @@ NetPage::OnNext () return IDD_INSTATUS; } +long +NetPage::OnUnattended() +{ + return OnNext (); +} + long NetPage::OnBack () { diff --git a/net.h b/net.h index 2928330a..b60b0ed8 100644 --- a/net.h +++ b/net.h @@ -39,6 +39,7 @@ public: virtual void OnInit (); virtual long OnNext (); virtual long OnBack (); + virtual long OnUnattended (); virtual bool OnMessageCmd (int id, HWND hwndctl, UINT code); }; diff --git a/proppage.cc b/proppage.cc index c9d98433..426e4ddd 100644 --- a/proppage.cc +++ b/proppage.cc @@ -20,6 +20,9 @@ #include "propsheet.h" #include "win32.h" #include "resource.h" +#include "state.h" + +#include "getopt++/BoolOption.h" bool PropertyPage::DoOnceForSheet = true; @@ -158,9 +161,42 @@ PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam) OnActivate (); - // 0 == Accept activation, -1 = Don't accept - ::SetWindowLong (GetHWND (), DWL_MSGRESULT, 0); - return TRUE; + if (unattended_mode) + { + // -2 == disable unattended mode, display page + // -1 == display page but stay in unattended mode (progress bars) + // 0 == skip to next page + // IDD_* == skip to specified page + long nextwindow = OnUnattended(); + if (nextwindow == -2) + { + unattended_mode = false; + SetWindowLong (GetHWND (), DWL_MSGRESULT, 0); + return TRUE; + } + else if (nextwindow == -1) + { + SetWindowLong (GetHWND (), DWL_MSGRESULT, 0); + return TRUE; + } + else if (nextwindow == 0) + { + SetWindowLong (GetHWND (), DWL_MSGRESULT, -1); + return TRUE; + } + else + { + SetWindowLong (GetHWND (), DWL_MSGRESULT, nextwindow); + return TRUE; + } + } + else + { + // 0 == Accept activation, -1 = Don't accept + ::SetWindowLong (GetHWND (), DWL_MSGRESULT, 0); + return TRUE; + } + } break; case PSN_KILLACTIVE: diff --git a/proppage.h b/proppage.h index 29f3b151..dd9c1a59 100644 --- a/proppage.h +++ b/proppage.h @@ -107,6 +107,10 @@ public: { return true; }; + virtual long OnUnattended () + { + return -2; + }; PropSheet *GetOwner () const { diff --git a/root.cc b/root.cc index d8aeba3d..cc8be721 100644 --- a/root.cc +++ b/root.cc @@ -36,6 +36,10 @@ static const char *cvsid = #include "log.h" #include "root.h" +#include "getopt++/StringOption.h" + +StringOption RootOption ("", 'R', "root", "Root installation directory"); + static int rb[] = { IDC_ROOT_TEXT, IDC_ROOT_BINARY, 0 }; static int su[] = { IDC_ROOT_SYSTEM, IDC_ROOT_USER, 0 }; @@ -164,6 +168,8 @@ RootPage::Create () void RootPage::OnInit () { + if (((string)RootOption).size()) + set_root_dir((string)RootOption); if (!get_root_dir ().size()) read_mounts (); load_dialog (GetHWND ()); @@ -204,3 +210,9 @@ RootPage::OnBack () NEXT (IDD_SOURCE); return 0; } + +long +RootPage::OnUnattended () +{ + return OnNext(); +} diff --git a/root.h b/root.h index bf083974..85304984 100644 --- a/root.h +++ b/root.h @@ -18,6 +18,7 @@ public: virtual void OnInit (); virtual long OnNext (); virtual long OnBack (); + virtual long OnUnattended (); }; #endif // CINSTALL_ROOT_H diff --git a/site.cc b/site.cc index 61045e2f..542486f2 100644 --- a/site.cc +++ b/site.cc @@ -45,9 +45,13 @@ static const char *cvsid = #include "threebar.h" extern ThreeBarProgressPage Progress; +#include "getopt++/StringOption.h" + SiteList site_list; SiteList all_site_list; +StringOption SiteOption("", 's', "site", "Download site"); + void site_list_type::init (String const &newurl) { @@ -220,6 +224,31 @@ get_site_list (HINSTANCE h, HWND owner) #define NOSAVE3 "ftp://gcc.gnu.org/" #define NOSAVE3_LEN (sizeof ("ftp://gcc.gnu.org/") - 1) +static void +register_saved_site (const char * site) +{ + site_list_type tempSite(site); + SiteList::iterator i = find (all_site_list.begin(), + all_site_list.end(), tempSite); + if (i == all_site_list.end()) + { + /* Don't default to certain machines ever since they suffer + from bandwidth limitations. */ + if (strnicmp (site, NOSAVE1, NOSAVE1_LEN) == 0 + || strnicmp (site, NOSAVE2, NOSAVE2_LEN) == 0 + || strnicmp (site, NOSAVE3, NOSAVE3_LEN) == 0) + return; + SiteList result; + merge (all_site_list.begin(), all_site_list.end(), + &tempSite, &tempSite + 1, + inserter (result, result.begin())); + all_site_list = result; + site_list.push_back (tempSite); + } + else + site_list.push_back (tempSite); +} + static void get_saved_sites () { @@ -239,26 +268,8 @@ get_saved_sites () if (eos < site) continue; - site_list_type tempSite(site); - SiteList::iterator i = find (all_site_list.begin(), - all_site_list.end(), tempSite); - if (i == all_site_list.end()) - { - /* Don't default to certain machines ever since they suffer - from bandwidth limitations. */ - if (strnicmp (site, NOSAVE1, NOSAVE1_LEN) == 0 - || strnicmp (site, NOSAVE2, NOSAVE2_LEN) == 0 - || strnicmp (site, NOSAVE3, NOSAVE3_LEN) == 0) - return; - SiteList result; - merge (all_site_list.begin(), all_site_list.end(), - &tempSite, &tempSite + 1, - inserter (result, result.begin())); - all_site_list = result; - site_list.push_back (tempSite); - } - else - site_list.push_back (tempSite); + register_saved_site (site); + } delete f; @@ -316,7 +327,11 @@ bool SitePage::Create () void SitePage::OnInit () { - get_saved_sites (); + string SiteOptionString = SiteOption; + if (SiteOptionString.size()) + register_saved_site (SiteOptionString.c_str()); + else + get_saved_sites (); } long @@ -362,6 +377,15 @@ SitePage::OnActivate () CheckControlsAndDisableAccordingly (); } +long +SitePage::OnUnattended () +{ + if (SendMessage (GetDlgItem (IDC_URL_LIST), LB_GETSELCOUNT, 0, 0) > 0) + return OnNext (); + else + return -2; +} + void SitePage::CheckControlsAndDisableAccordingly () const { diff --git a/site.h b/site.h index 6d5d4852..284d7fa6 100644 --- a/site.h +++ b/site.h @@ -40,6 +40,7 @@ public: virtual void OnActivate (); virtual long OnNext (); virtual long OnBack (); + virtual long OnUnattended (); virtual bool OnMessageCmd (int id, HWND hwndctl, UINT code); diff --git a/source.cc b/source.cc index 335061ce..01402133 100644 --- a/source.cc +++ b/source.cc @@ -33,6 +33,11 @@ static const char *cvsid = #include "source.h" +#include "getopt++/BoolOption.h" + +static BoolOption DownloadOption (false, 'D', "download", "Download from internet"); +static BoolOption LocalOption (false, 'L', "local-install", "Install from local directory"); + static int rb[] = { IDC_SOURCE_NETINST, IDC_SOURCE_DOWNLOAD, IDC_SOURCE_CWD, 0 }; @@ -79,7 +84,15 @@ void SourcePage::OnActivate () { if (!source) - source = IDC_SOURCE_NETINST; + { + if (DownloadOption) + source = IDC_SOURCE_DOWNLOAD; + else if (LocalOption) + source = IDC_SOURCE_CWD; + else + source = IDC_SOURCE_NETINST; + } + load_dialog (GetHWND ()); // Check to see if any radio buttons are selected. If not, select a default. if ((!SendMessage @@ -122,3 +135,9 @@ SourcePage::OnDeactivate () ((source == IDC_SOURCE_DOWNLOAD) ? "download" : (source == IDC_SOURCE_NETINST) ? "network install" : "from cwd")); } + +long +SourcePage::OnUnattended () +{ + return OnNext(); +} diff --git a/source.h b/source.h index 2cf86270..cbcf0649 100644 --- a/source.h +++ b/source.h @@ -38,6 +38,7 @@ public: virtual void OnDeactivate (); virtual long OnNext (); virtual long OnBack (); + virtual long OnUnattended (); }; #endif diff --git a/splash.h b/splash.h index f6a9597f..3567c8c7 100644 --- a/splash.h +++ b/splash.h @@ -33,6 +33,10 @@ public: bool Create (); virtual void OnInit (); + long OnUnattended () + { + return 0; + }; }; #endif // CINSTALL_SPLASH_H diff --git a/state.cc b/state.cc index 5bf813b6..941e10b8 100644 --- a/state.cc +++ b/state.cc @@ -22,6 +22,8 @@ static const char *cvsid = #include "state.h" +bool unattended_mode; + int source; String local_dir; diff --git a/state.h b/state.h index 7ee54f62..3f107be9 100644 --- a/state.h +++ b/state.h @@ -28,6 +28,8 @@ #include "String++.h" +extern bool unattended_mode; + extern int source; extern String local_dir; diff --git a/threebar.h b/threebar.h index 2e804694..0fb104cb 100644 --- a/threebar.h +++ b/threebar.h @@ -31,6 +31,7 @@ #define WM_APP_SITE_INFO_DOWNLOAD_COMPLETE WM_APP+5 #define WM_APP_START_SETUP_INI_DOWNLOAD WM_APP+6 #define WM_APP_SETUP_INI_DOWNLOAD_COMPLETE WM_APP+7 +// desktop.h: WM_APP_UNATTENDED_FINISH WM_APP+8 class ThreeBarProgressPage:public PropertyPage { @@ -62,6 +63,10 @@ public: virtual void OnInit (); virtual void OnActivate (); virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam); + virtual long OnUnattended () + { + return -1; + }; void SetText1 (const TCHAR * t); void SetText2 (const TCHAR * t); -- 2.43.5