[PATCH setup libsolv, v2] Let the user review added dependencies

Ken Brown kbrown@cornell.edu
Mon Jan 22 17:37:00 GMT 2018


If the solver found no problems but added packages to resolve
dependencies, ask the user whether they want to review the added
packages before proceeding.

If they answer Yes, go back to the chooser with the 'Pending' view
selected.  The implementation adds several new members to the
PrereqChecker class so that the latter can communicate with the
chooser page.
---
 choose.cc |  3 +++
 prereq.cc | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
 prereq.h  |  8 ++++++++
 3 files changed, 70 insertions(+), 9 deletions(-)

diff --git a/choose.cc b/choose.cc
index 1c79cca..846b169 100644
--- a/choose.cc
+++ b/choose.cc
@@ -286,6 +286,9 @@ ChooserPage::OnInit ()
   /* Set focus to search edittext control. */
   PostMessage (GetHWND (), WM_NEXTDLGCTL,
 	       (WPARAM) GetDlgItem (IDC_CHOOSE_SEARCH_EDIT), TRUE);
+
+  /* Store the HWNDs that the PrereqChecker will need.  */
+  PrereqChecker::setChooserHWNDs (GetHWND (), viewlist);
 }
 
 void
diff --git a/prereq.cc b/prereq.cc
index effa7cc..7821d63 100644
--- a/prereq.cc
+++ b/prereq.cc
@@ -35,6 +35,7 @@
 #include "msg.h"
 #include "Exception.h"
 #include "getopt++/BoolOption.h"
+#include "PickView.h"
 
 // Sizing information.
 static ControlAdjuster::ControlInfo PrereqControlsInfo[] = {
@@ -139,8 +140,8 @@ PrereqPage::whatNext ()
   return IDD_INSTATUS;
 }
 
-long
-PrereqPage::OnBack ()
+static void
+prepBack ()
 {
   // Add reinstall tasks
   PrereqChecker p;
@@ -149,7 +150,12 @@ PrereqPage::OnBack ()
   // Reset the package database to correspond to the solver's solution
   packagedb db;
   db.solution.trans2db();
+}
 
+long
+PrereqPage::OnBack ()
+{
+  prepBack ();
   return IDD_CHOOSE;
 }
 
@@ -170,6 +176,7 @@ PrereqPage::OnUnattended ()
 // instantiate the static members
 bool PrereqChecker::use_test_packages;
 SolverTasks PrereqChecker::q;
+HWND PrereqChecker::hChooser, PrereqChecker::hChooseView;
 
 bool
 PrereqChecker::isMet ()
@@ -204,6 +211,15 @@ PrereqChecker::augment ()
   db.solution.augmentTasks(q);
 }
 
+void
+PrereqChecker::setChooserView (PickView::views view)
+{
+  PostMessage (hChooseView, CB_SETCURSEL, (WPARAM)view, 0);
+  PostMessage (hChooser, WM_COMMAND,
+	       MAKEWPARAM (IDC_CHOOSE_VIEW, CBN_SELCHANGE),
+	       (LPARAM)hChooseView);
+}
+
 /* Formats problems and solutions as a string for display to the user.  */
 void
 PrereqChecker::getUnmetString (std::string &s)
@@ -224,6 +240,23 @@ PrereqChecker::getUnmetString (std::string &s)
 // progress page glue
 // ---------------------------------------------------------------------------
 
+static bool
+added_deps ()
+{
+  packagedb db;
+  const SolverTransactionList & trans = db.solution.transactions ();
+  for (SolverTransactionList::const_iterator i = trans.begin ();
+       i != trans.end (); i++)
+    if (i->type == SolverTransaction::transInstall)
+      {
+	packageversion pv = i->version;
+	packagemeta *pkg = db.findBinary (PackageSpecification (pv.Name ()));
+	if (!pkg->desired)
+	  return true;
+      }
+  return false;
+}
+
 static int
 do_prereq_check_thread(HINSTANCE h, HWND owner)
 {
@@ -232,17 +265,34 @@ do_prereq_check_thread(HINSTANCE h, HWND owner)
 
   if (p.isMet ())
     {
-      p.finalize();
-
-      if (source == IDC_SOURCE_LOCALDIR)
-	Progress.SetActivateTask (WM_APP_START_INSTALL);  // install
+      if (added_deps () && !unattended_mode
+	  && MessageBox (owner, "Packages were added to resolve dependencies.  "
+			 "Do you want to review them before proceeding?"
+			 "\r\n\r\n"
+			 "Answering 'Yes' will take you back to the Package "
+			 "Selection page, with the 'Pending' view selected.",
+			 "Added Dependencies",
+			 MB_YESNO | MB_DEFBUTTON2) == IDYES)
+	{
+	  Progress.SetText1 ("Preparing package review...");
+	  prepBack ();
+	  p.setChooserView ();
+	  retval = IDD_CHOOSE;
+	}
       else
-	Progress.SetActivateTask (WM_APP_START_DOWNLOAD); // start download
-      retval = IDD_INSTATUS;
+	{
+	  p.finalize();
+
+	  if (source == IDC_SOURCE_LOCALDIR)
+	    Progress.SetActivateTask (WM_APP_START_INSTALL);  // install
+	  else
+	    Progress.SetActivateTask (WM_APP_START_DOWNLOAD); // start download
+	  retval = IDD_INSTATUS;
+	}
     }
   else
     {
-      // rut-roh, some required things are not selected
+      // The solver reported problems.
       retval = IDD_PREREQ;
     }
 
diff --git a/prereq.h b/prereq.h
index 24e6de5..d60ef59 100644
--- a/prereq.h
+++ b/prereq.h
@@ -5,6 +5,8 @@
 #include "proppage.h"
 #include "PackageTrust.h"
 #include "package_meta.h"
+#include "win32.h"
+#include "PickView.h"
 
 using namespace std;
 
@@ -45,11 +47,17 @@ public:
 
   void augment ();
 
+  void setChooserView (PickView::views = PickView::views::PackagePending);
+
   static void setTestPackages (bool t) { use_test_packages = t; };
 
+  static void setChooserHWNDs (HWND hc, HWND hv)
+  { hChooser = hc; hChooseView = hv; };
+
 private:
   static bool use_test_packages;
   static SolverTasks q;
+  static HWND hChooser, hChooseView;
 };
 
 #endif /* SETUP_PREREQ_H */
-- 
2.15.1



More information about the Cygwin-apps mailing list