public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH setup libsolv, v2] Let the user review added dependencies
@ 2018-01-22 17:37 Ken Brown
  2018-01-22 21:51 ` Brian Inglis
  2018-01-24 20:30 ` Jon Turney
  0 siblings, 2 replies; 9+ messages in thread
From: Ken Brown @ 2018-01-22 17:37 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-01-28 18:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-22 17:37 [PATCH setup libsolv, v2] Let the user review added dependencies Ken Brown
2018-01-22 21:51 ` Brian Inglis
2018-01-22 22:40   ` Ken Brown
2018-01-23  1:07     ` Brian Inglis
2018-01-23 15:05       ` cyg Simple
2018-01-24 20:30 ` Jon Turney
2018-01-25  3:25   ` Ken Brown
2018-01-25  3:57     ` Ken Brown
2018-01-28 18:11       ` Jon Turney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).